What is the sliding window protocol for flow control in  Computer Network?


The computer networks use a sliding window protocol for optimal usage of the underlying network bandwidth. It allows a sender to send more than one packet at a single time. If there is no need for reliable delivery, the sliding window protocol is an optional implementation in the protocol layers.  The sliding window protocol belongs to the category of flow control mechanism in computer networks.

Why do we need flow control?

How does reliable communication work?  For reliable communication, the first basic thing is that the sender should make sure that the sent packet has been received by the receiver.  For that, there is an acknowledgment for each data unit sent.

The simple approach for reliable communication is that the sender sends a single packet at a time and waits for the acknowledgment.  Upon receiving acknowledgment, the sender sends the next packet else, assuming the packet has been lost or corrupted.

For error recovery same packet is retransmitted and again waits for an acknowledgment.  The problem with this basic approach is that at a time there will be a single packet over the network even though there is more bandwidth available.

The basic approach for a reliable delivery reduces the usage of underlying bandwidth and slower communication between the sender and receiver.

What is a window in a computer network? And sliding means?

To overcome the issue discussed above, the sender and receiver have the concept of a window.  A window is a space that holds or can hold multiple bytes. For example, if there is a window of 1024 bytes and the size of the individual frame is 128 bytes. There could be a maximum of 8 messages at any time in the window.

Sliding window and sliding

How does the window slide?  Sliding means moving to a new set of messages. Suppose a window of size 1024 initially contains frames for sequence numbers from 1 to 1024.  After communication, the receiver receives the acknowledgment till frame sequence number 100.  After that window will have frames for sequence numbers from 101 to 1124.  if we visualize, it looks that the window has shifted to the new set of frames.

OSI model and sliding window :

The OSI model provides guidelines for communication. It has seven layers each layer communicates peer to peer. So at which layer implements the sliding window protocol? The answer is simple, layers/protocols that are responsible for reliable communication. As per the OSI model, the data link layer is responsible for reliable communication with the next hope.  The transport layer depends if an implementation is using a reliable transport layer protocol such as TCP  or if using UDP (unreliable).  The TCP uses flow control for reliable communication with its peer.

Why do we have flow control at two layers? Yes, it looks redundant, but having flow control at two layers is an optimization. The transport layer works on the message level while the data link works at the frame level.   A message is broken into several frames. So if a frame is corrupted, then there will be full message retransmission at the transport layer, if there is no flow control at the data link layer.

In this tutorial, we will mainly mention layer two for sliding window discussion.

How many sliding window types in computer communication?

For flow control, there are two types of sliding windows.  One is the receiver window and another is the sender window.  At the start of the communication setup, each side sends its receiver window size to the far end.  After that, each successive acknowledgment has the available size of the receiver sliding window.  If the receiver is slower, the receiver window keeps reducing and the sender reduces the sender window too.

It looks the sender will always send bytes equal to the sender’s sliding window. But not so, as the application may be delivering a lesser number of bytes. These bytes should be delivered immediately to the network.

Types of Sliding window protocols:

Above are just the names of protocols. The Stop and Wait we have described at the beginning.  We will publish another tutorial for each sliding window protocol.