2. TCP Sliding Window
TCP Sliding Window provides,
reliable delivery of data,
data is delivered in order, and
flow control between the sender and the receiver.
Reliable delivery and Ordered Delivery:
3. TCP Sliding Window
Sending Side
LastByteAcked ≤ LastByteSent
- Receiver cannot acknowledge a byte that has not been sent.
LastByteSent ≤ LastByteWritten
- TCP cannot send a byte that the application process has not yet written.
Left side of the LastByteAcked need not to be saved in the buffer.
Receiving Side
LastByteRead < NextByteExpected
- All preceding bytes are already received.
- Byte cannot be read by application until it is received.
NextByteExpected ≤ LastByteRcvd + 1
- If data has arrived in order, NextByteExpected points to the byte after
LastByteRcvd
- If data has arrives out of order, NextByteExpected points to the start of the first gap
in the data.
Bytes to the left of LastByteRead need not be buffered.
4. TCP Sliding Window
Flow Control
– Both sender and receiver buffer size is finite size, denoted by MaxSendBuffer,
MaxRcvBuffer.
– In sliding window, window size sets the amount of data that can be sent without
waiting for acknowledgement.
– Here receiver give the maximum window size for the sender by advertising a
window that is no larger than the data that it can buffer.
Receiver side must keep,
LastByteRcvd – LastByteRead ≤ MaxRcvBuffer
- To avoid overflowing its buffer (Receive Buffer).
AdvertisedWindow = MaxRcvBuffer – ((NextByteExpected -1) –
LastByteRead)
- Represents the amount of free space remaining in the buffer
Sender side must keep,
LastByteSent – LastByteAcked ≤ AdvertisedWindow
EffectiveWindow = AdvertisedWindow – (LastByteSent – LastByteAcked)
5. TCP Sliding Window
To avoid the overflow of the send buffer by local application process, sender must
make sure,
LastByteWritten – LastByteAcked ≤ MaxSendBuffer
Protecting against Wraparound
SequenceNum – 32 bit long
AdvertisedWindow – 16 bit long
Sequence number space is twice as big as window size.
Relevance of the 32-bit sequence number space
• The sequence number used on a given connection might wraparound
• A byte with sequence number x could be sent at one time, and then at a later time a
second byte with the same sequence number x could be sent
• Packets cannot survive in the Internet for longer than the MSL
• MSL is set to 120 sec
• We need to make sure that the sequence number does not wrap around within a 120-
second period of time.
6. TCP Sliding Window
Keeping the Pipe Full
• 16-bit AdvertisedWindow field must be big enough to allow the sender to keep
the pipe full.
7. TCP Sliding Window
• Clearly the receiver is free not to open the window as large as the
AdvertisedWindow field allows
• If the receiver has enough buffer space
– The window needs to be opened far enough to allow a full
– delay × bandwidth product’s worth of data
– Assuming an RTT of 100 ms
Required Window Size for 100ms RTT