130 likes | 427 Views
Transmission Control Protocol (TCP) Part II Neil Tang 11/21/2008. Outline. Revised Sliding Window Algorithm Silly Window Syndrome and Nagle’s Algorithm Retransmission. Revised Sliding Window Algorithm. It needs to guarantee packet delivery. It needs to ensure in-order packet delivery.
E N D
Transmission Control Protocol (TCP)Part IINeil Tang11/21/2008 CS440 Computer Networks
Outline • Revised Sliding Window Algorithm • Silly Window Syndrome and Nagle’s Algorithm • Retransmission CS440 Computer Networks
Revised Sliding Window Algorithm • It needs to guarantee packet delivery. • It needs to ensure in-order packet delivery. • It needs to support flow control. CS440 Computer Networks
Reliable and Ordered Delivery • In the sender: LastByteAcked LastByteSent LastByteWriten • In the receiver: LastByteRead < NextByteExpected LastByteRcvd + 1 • NextByteExpected: If in-order, NextByteExpected = LastByteRcvd + 1. If out-of-order, NextByteExpected points to the start of the first gap in the data. CS440 Computer Networks
Flow Control • The receiver can throttle the sender by advertising a window that is no larger than the amount of data it can buffer. • AdvertisedWindow = MaxRcvBuffer – ((NextByteExpected -1) – LastByteRead) • The sender must adhere to the advertised window. • EffectiveWindow = AdvertisedWindow – (LastByteSent - LastByteAcked) • In addition, if the sending process tries to write x bytes to TCP, but LastByteWritten – LastByteAcked + x > MaxSendBuffer, then TCP blocks the sending process. CS440 Computer Networks
Flow Control • When receive buffer is filled up, the advertised window shrinks to 0, which stops the sender to send more data. Then the send buffer will be filled up, which eventually causes TCP to block the sending process. • TCP uses the acknowledgement packet to carry out the value of current advertised window. Even if the advertised window shrinks to 0, the sender persists in sending a segment with 1 byte of data, which triggers a response containing the current advertised window. CS440 Computer Networks
Silly Window Syndrome • TCP sends a segment as soon as it has collected Maximum Segment Size (MSS) bytes from the sending process. MSS is set to the MTU of the directly connected network, minus the size of TCP and IP headers • Problem: Suppose there are enough data available in the send buffer but the sending window size < MSS, should the sender send a half-full segment immediately or wait for the window to open to a full MSS? • In the original TCP, a half-full segment will be immediately sent out, which results in a lot of tiny segments in the network. This situation is referred to as silly window syndrome. CS440 Computer Networks
Nagle’s Algorithm When the application produce data to send if both the available data and the window size MSS send a full segment else if there is unACKed data in flight buffer the new data until an ACK arrives else send all the new data now • The sender can never send a segment whose data size is larger than the window size or MSS. • Nagle’s algorithm can be disabled by setting TCP_NODELAY option CS440 Computer Networks
Adaptive Retransmission • Different TCP connections have quite different RTTs. So the retransmission timeout value needs to be set adaptively. • Original algorithm: EstimatedRTT = * EstimatedRTT + (1 - ) * SampleRTT Timeout = 2 * EstimatedRTT Here [0.8, 0.9] CS440 Computer Networks
Karn/Partridge Algorithm • SampleRTT can not be precisely measured if there are retransmissions. • Karn/Partridge Algorithm: If retransmission, the next timeout value will be simply doubled. Otherwise, the timeout is computed in the same way as the original algorithm. CS440 Computer Networks
Jacobson/Karels Algorithm • The variance of the sample RTTs has not been taken into account by the previous algorithms. • Jacobson/Karels Algorithm: Difference = SampleRTT - EstimatedRTT EstimatedRTT = EstimatedRTT + (δ * Difference) Deviation = Deviation + δ(|Difference| - Deviation) Timeout = μ* EstimatedRTT + ø * Deviation Here, δ[0,1], μ= 1, ø = 4 . CS440 Computer Networks
Record Boundaries • Two mechanisms can be used for the sender to insert record boundaries into the byte stream, thereby informing the application process how to break the stream of bytes into records. • URG and UrgPtr fields can be used as a record boundary marker. • Push operation can be used to achieve it by flushing segments to the receiver whenever there is a data packet coming from the application layer. The receiver notifies its application process whenever an incoming segment has the PUSH flag set. • The application process can always insert its own boundary markers into the byte stream. CS440 Computer Networks
TCP Extensions • A 32-bit time-stamp field can be inserted into a TCP header to record the time when the segment is sent. The timestamp can be used to measure RTT and can be combined with the sequence number to uniquely identify a segment/byte. • A scaling factor field can be inserted into a TCP header. For example, if scaling factor = 4, then the value of AdvertiseWindow indicates the window size in terms of 16-byte units. CS440 Computer Networks