Transport Layer Protocols TCP Gail Hopkins Introduction Features of TCP Packet loss and retransmission Adaptive retransmission Flow control Three way handshake Congestion control 1
Common Networking Issues Out-of-order delivery Duplicate packets Can be caused by malfunctioning hardware Lost packets Replay caused by excessive delay Data overrun Network congestion Reliable Transport IP is unreliable End hosts can be unreliable (e.g., crashes and reboots) Application programmers typically require reliability (although not always) The Transmission Control Protocol (TCP) establishes a reliable end-to-end communication service on top of IP 2
Seven Major Features of TCP 1. Connection oriented 2. Point to point 3. Complete reliability - delivered as sent 4. Full duplex communication 5. Stream interface 6. Reliable connection startup 7. Graceful connection shutdown Part 34 Internetworking Using End to End Communication TCP has no knowledge of the underlying Internet structure 3
Sequencing to Handle Duplicates and Out-of-Order Delivery Connectionless network with dynamic routing may deliver packets out of order Transport protocols solve this with sequencing Each packet is given a sequence number The receiver notes the number of the last packet that arrived in sequence and stores additional out of order packets The packets are delivered in sequence to the next layer up Avoiding Replay Caused by Delay A duplicate packet might turn up in a later session (e.g., if it was queued in a switch for a long time) May be confused with a packet from the later session that uses the same sequence number Solution is to include a session identifier in the packet 4
Re-Transmitting Lost Packets Packet loss is a fundamental problem due to transmission errors One approach to reliable transmission involves positive acknowledgements sender transmits and starts a timer receiver receives and acknowledges on time-out the sender transmits again the receiver must watch out for duplicates limit number of attempts before giving up Part 34 Internetworking Using Packet Loss and Retransmission Sender sets a timer Receiver sends an acknowledgement Timeout results in retransmission 5
Adaptive Retransmission Sensible timer values vary greatly on an Internet TCP monitors the delay on a connection and adapts the timer notes time taken to receive acknowledgements computes weighted average and variance over many transmissions and uses these to set the timer Part 34 Internetworking Using Two Different Timeouts 6
Flow Control to Prevent Overrun Data overrun occurs when the sender sends faster than the receiver can receive Simple solution is to acknowledge each packet before sending the next ( stop and go ) However, this can be wasteful of bandwidth capacity = 2 Mbps, packet size = 1000 octets, delay = 50 ms sender has to wait 100 ms before sending next packet data rate is 1000 octets every 100 ms = 80000 bps = 4% of available capacity Sliding Window Protocols Alternative to stop and go Sender and receiver agree a window size (number of packets) Initially a whole window is sent After that, each packet is acknowledged and then another can be sent 7
Sliding Window Protocols (2) Each end of the connection allocates a buffer and notifies the other end of its size Receiver sends available window size in each acknowledgement (window advertisement) Receiver sends window advertisement when the application consumes some data Zero window advertisement tells the sender to stop transmitting until further notice 8
Part 34 Internetworking Using T w = T g x W Comparison of Stop and Go and Sliding Window Protocols 9
Congestion Congestion arises due to too much traffic and/or bottlenecks in the network Limited storage in switches means that packets get dropped Dealing with Congestion Detecting congestion switches can inform senders packet loss can be used as a measure of congestion Solution is rate control 10
Congestion Control TCP monitors congestion through message loss first lost message, TCP backs right off and sends just one small message if this is not lost, doubles data size and sends two continues exponential growth until half receiver s window size is reached then slows down rate of increase Three Way Handshake To guarantee that connections are established or terminated reliably Uses special synchronization (SYN) and finish (FIN) messages to open and close connections Also confirms that all data has been received at both sides Each end of each new connection randomly generates a 32 bit connection identifier 11
Part 34 Internetworking Using TCP Segment Format TCP messages are called segments 12
Summary Features of TCP Packet loss and retransmission Adaptive retransmission Flow control Congestion control Three way handshake Reading: Chapter 26, Computer Networks and Internets, Comer, 5 th Edition, 2009 13