Search

How TCP sliding window work, TCP sliding window, TCP Window

In this lesson, you will learn the terms "TCP Window", "TCP Sliding Window" and how "TCP Sliding Window" works.

What is a TCP Window?

A TCP window is the amount of unacknowledged data a sender can send on a particular connection before it gets an acknowledgment back from the receiver, that it has received some of the data.

TCP Sliding Window

The working of the TCP sliding window mechanism can be explained as below.

The sending device can send all packets within the TCP window size (as specified in the TCP header) without receiving an ACK, and should start a timeout timer for each of them.

The receiving device should acknowledge each packet it received, indicating the sequence number of the last well-received packet. After receiving the ACK from the receiving device, the sending device slides the window to right side.

TCP Sliding Window 1

In this case, the sending device can send up to 5 TCP Segments without receiving an acknowledgement from the receiving device. After receiving the acknowledgement for Segment 1 from the receiving device, the sending device can slide its window one TCP Segment to the right side and the sending device can transmit segment 6 also.

If any TCP Segment lost while its journey to the destination, the receiving device cannot acknowledge the sender. Consider while transmission, all other Segments reached the destination except Segment 3. The receiving device can acknowledge up to Segment 2. At the sending device, a timeout will occur and it will re-transmit the lost Segment 3. Now the receiving device has received all the Segments, since only Segment 3 was lost. Now the receiving device will send the ACK for Segment 5, because it has received all the Segments to Segment 5.

Acknowledgement (ACK) for Segment 5 ensures the sender the receiver has succesfully received all the Segments up to 5.

TCP uses a byte level numbering system for communication. If the sequence number for a TCP segment at any instance was 5000 and the Segment carry 500 bytes, the sequence number for the next Segment will be 5000+500+1. That means TCP segment only carries the sequence number of the first byte in the segment.

The Window size is expressed in number of bytes and is determined by the receiving device when the connection is established and can vary later. You might have noticed when transferring big files from one Windows machine to another, initially the time remaining calculation will show a large value and will come down later.

TCP Sliding Window 2

We have four catagories in above example.

1) Bytes already sent and acknowledged (upto Byte 20).

2) Bytes sent but not acknowledged (Bytes 21-24).

3) Bytes the receiver is ready to accept (Bytes 25-28).

4) Bytes the receiver is not ready to accept (Byte 29 onwards).

The Send Window is the sum of Bytes sent but not acknowledged and Bytes the receiver is ready to accept (Usable Window).

A visual demo of TCP Sliding Window mechanism can be viewed here.

In this lesson, you have learned what is a TCP Window, and how TCP Sliding Window mechanism works. Click "Next" to continue.

Related Tutorials
• TCP/IP Transport Layer
• Transmission Control Protocol (TCP)
• Transmission Control Protocol (TCP) Segment Header
• TCP Three-way Handshake
• Multiplexing and Demultiplexing using port numbers
• Transmission Control Block (TCB)
• TCP Connection Termination
• User Datagram Protocol (UDP)
• Differences between TCP and UDP