What is the sliding window protocol for flow control in a Computer Network?
Sliding window protocols are used in computer networks to maximize the utilization of network bandwidth. A sender may send more than one packet at a time using a window without waiting for acknowledgment from the peer.
The sliding window protocol may be omitted from the protocol layer if reliable delivery is not required. As one of the flow control mechanisms in computer networks, the sliding window protocol falls into this category.
Why do we need flow control?
How does reliable communication work? For reliable communication, the first essential thing is that the sender should ensure the receiver has received the sent packet. 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, and starts the error recovery mechanism.
For error recovery, a sender retransmits the same packet 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 sliding 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.
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 in a peer-to-peer fashion.
Which layer implements the sliding window protocol? Layers/protocols that ensure reliable communication are the answer.
According to the OSI model, the data link layer ensures reliable communication with the next hop, while the transport layer ensures end-to-end communication.
In a data link layer, it is mandatory, while in transport, it layer depends on whether an implementation is for a reliable transport layer protocol such as TCP or for an unreliable protocol such as UDP.
The TCP uses flow control for reliable communication with its peer and for a slow receiver.
Why is there flow control at two layers? Yes, it looks redundant, but having flow control at layer two 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 at the data link layer. So if a frame is, the corrupted data link resends the same frame. The full message will retransmit at the transport layer if there is no such mechanism.
This tutorial will mainly mention layer two for sliding window discussion.
How many sliding window types are 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 (e.g., TCP handshake) setup, each side advertises its receiver window size to the far end.
While user data transfer, 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.
Will the sender 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:
- Stop and Wait – ARQ ( ARQ means Automatic Repeat Request for error correction.)
- Selective Repeat ARQ
- Go Back N
Above are just the names of the protocols. The Stop and Wait we have described at the beginning. We will publish another tutorial for each sliding window protocol.