Lecture notes for week of Nov. 27 - Dec. 1
IP - Provide computer to computer communication
(only provide source and destination UP address)
TCP/UDP - Provide application to application communication. (no reliability
TCP/UDP packets contain the port numbers of the source and destination application.
ports -> define src and dest applications.
- best for LAN applications
- minmal overhead - Connectionless (no state is kept in both ends)
- minimal computation
- Each UDP packet is encapsulated in IP packet
- If reliability is needed, the application has to implement it
- used in applications where it is necessary to have control in the timing and flow of messages, i.e. multimedia apps.
TCP: - major transport protocol used in INternet
- TCP is reliable
- Connection oriented
- stream interface (read/write)
How TCP achieves reliability?
- receiver sends an acknowledgement when data arrives
- sender starts a time whenever a message is transmitted
- if timer expires before the acknowledgement arrives, sender retransmits message
How long should TCP wait before retransmitting?
timer too long: slow to send data if packet are lost
time too slow: many retransmissions even if packets are no lost
time length: should be about the round trip time.
round trip time depends on: distance, traffic condition, media
TCP uses "adaptive" retransmission"
- TCP keeps an estimate of roundtrip time
- TCP uses this formula:
retransmission time = Avg. round-trip time + variance round-trip time
- Variance is used to take into account current changes in round-trip time
- adaptive retransmission is key to TCP success.
TCP has to run in slow and fast networks (28kbps or 100 Mbps ethernet)
- Window: the sender can send in parallel, multiple messages w/o waiting for acknowledgement
- Windows also allow the maximum usage of the network.
TCP FLOW CONTROL
| Sun Server | ------------------ XXXXXXXXXXXXX----------------| Laptop |
64 processors, send 100 MB file TCP buffers in laptop will be filled if application is too slow to read from them
- Receiver tells server to slow down when the buffers in the receiver
- Receivers in every acknowledge will also include the buffer space that is available.
- This available buffer space is also called "window size".
- sender can send up to the entire window size received before the next acknowledge arrives.
- acknowledgements will include:
- number of bytes (consecutive) received correctly so far
- windows size: Available buffer space in receiver
Notes of flow control:
- By using a window size, the sender can send in parallel data up to the windows size without waiting for an acknowledgement.
This increases throughput.
- Cummulative acknowledgements
The acknowledgements are sent for all consecutive bytes received correctly so far.
The TCP implementation in the receiver may decide not to send acknowledgements for every packets received but to wait until several packets arrive before sending an acknowledgement for all of them.
- when a network is congested, routers drop packets.
- If packets are dropped, more packets are retransmitted making things even worse.
- TCP decreases the problem by not being to aggressive in retransmissions.
- TCP uses a technique called "slow start"
- After a packet is lost, it will not send the complete window size full of bytes
- TCP is going to send only one message with data
- IF it succeeds, it will send two messages, then four until it reaches the window size.
- Reliable connection startup and shutdown
Why reliable connection/startup is difficult?
- Packets lost, duplicated, out of order, either side can crash or reboot.
- Duplicate shutdown messages may affect future connections.
- TCP uses a technique called "3-way handshake" in both the connection startup and shutdown.
FORMAT OF TCP Packets
size of Ethernet= 14 bytes
size of IP header = 20 bytes
size of TCP header = 20 bytes
total = 54 bytes
source port / destination port
- identify source + destination application within the source/destination machine.
- A TCP connection is defined uniquely in t the entire Internet by FOUR values:
IP source address
IP destination address
The TCP implementation will separate the packets receive based on these values.
- By default TCP does not reuse the same port 266 seconds after it has been
closed. An application may overwrite this behavior (http server)
- This is to prevent packets that survive after closing the connection to enter in newly opened connections.
- Offset of the data currently sent relative to all the data sent so far.
- The sequence number does not start from 0, but it starts from a random number that the sender chooses.
- This is for security (it is difficult to spoof a packet with right sequence number) and to prevent errant packets from previous connections to enter a new connection.
- A receiver only receives a packet that has a sequence number in the window range.
- maximum sequence number of the bytes consecutively received correctly so far.
NOTE: Each host when connection start chooses its own initial sequence number that they use to send data.
HLEN - header length in multiples of 4 bytes.
SYN - start connection
FIN - end connection
ACK - acknowledge (acknowledge number is valid)
PUSH - send ACK and pass to application as soon as possible
This bits are used to "piggy-back" the SYN, FIN, ACK messages to a data message.
- buffer size available in receiver (control flow)
- Offset in data for "out-of-band" data that is urgent for the application.
For Ex: Ctrl-C in telnet