Definition

sliding window (windowing)

What is sliding window (windowing)?

The sliding window (windowing) technique is used by Transmission Control Protocol (TCP) to manage the flow of packets between two computers or network hosts. TCP is a core component of the Internet Protocol suite and operates at the transport layer.

The data link layer in the Open Systems Interconnection model also supports a class of protocols that use the sliding window technique. Protocols that support this technique are often referred to sliding window protocols. Sliding window protocols ensure the reliable and sequential delivery of data packets between network devices.

OSI network communications model
Figure 1. Data link layer of OSI's network model supports a class of protocols that use the sliding window technique.

How does the sliding window technique work?

A sliding window protocol controls and optimizes packet flow between a sender and receiver, while ensuring a balanced approach to packet delivery. The protocol requires the receiver to acknowledge receipt of each data packet, and it enables the receiver to use a single acknowledgment (ACK) to confirm the delivery of multiple packets.

The receiver maintains a buffer to manage the flow of data packets. The receive buffer holds the packets that have been sent by the sender but have not yet been processed. During data transmission, the receiver notifies the sender of the amount of free space available in the receive buffer. This space is referred to as the receive window, which is the buffer size less the amount of unprocessed data. The sender cannot send more data packets than the amount of space available in the receive window.

Data packets are numbered sequentially so they can be tracked when data is being transmitted from the sender to the receiver. During the transmission process, the data packets pass through one of four stages:

  1. Sent and acknowledged by the receiver.
  2. Sent but not acknowledged by the receiver.
  3. Not sent but the receiver is ready accept them.
  4. Not sent and the receiver is not ready to accept them.

Figure 2 provides a conceptual overview of the packets in a data segment as they pass through each stage. The packets are numbered sequentially, which serves as a reference point for both the sender and receiver.

how sliding window works
Figure 2. Conceptual overview of the packets in a data segment as they pass through each sliding window stage

Under normal operations, each data packet passes through each stage in the order specified. The sender supports its own send window that corresponds to the receive window. The send window includes the data packets in the second and third stages.

For example, Figure 2 shows that packets 16-20 have been sent, but the receiver has not yet acknowledged them. Figure 2 also shows that the receiver is ready to accept packets 21-25, but they have not yet been sent. In all, the send window includes packets 16-25. All packets up to 15 have been sent and acknowledged, and packets 26 onward have not been sent nor are they ready to be accepted.

As data is transmitted, the receiver acknowledges the packets it has accepted and continues to provide an updated status of the size of receive window. The sender adjusts its send window accordingly to reflect which sent packets have yet to be acknowledged and which additional packets can now be sent.

With each ACK and update on the receive window size, the sender adjusts the window to incorporate one or more of the next consecutive data packets. In effect, the send window slides along the data segment -- from left to right in Figure 2 -- to incorporate the next set of data packets in the sequence, continuously responding to the receiver's acknowledgments and receive window updates.

Each ACK sent by the receiver acknowledges packet receipt and specifies the current size of the receive window. A single ACK can apply to one or more packets. For example, returning again to Figure 2, if the receiver sends an ACK for packet 20, it means that all packets up to and including 20 have been successfully received.

However, if the receiver acknowledges only packet 18, it means that the receiver has accepted all packets up to and including 18 but has still not received packets 19 and 20. If the sender does not receive an ACK for these packets within a specified amount of time, the sender will resend the two packets.

The sender must continuously adjust its send window based on received ACKs and amount of space available in the receive window. If the window size is zero, the sender must wait for an ACK before sending the next chunk of data. If the receiver reports that the receive window size is larger than the size of a single data packet, the sender can send multiple packets without waiting for an ACK.

Transmitting multiple packets between ACKs enables the data to be transferred faster and more efficiently than if an ACK must be received prior to each transmission.

This was last updated in August 2021

Continue Reading About sliding window (windowing)

Dig Deeper on Network infrastructure

Unified Communications
Mobile Computing
Data Center
ITChannel
Close