Sliding window protocol is a transmission control protocol. To hold the outgoing and incoming packets both the sender and receiver maintains a finite buffer. Every packet sent from the sender side must be acknowledged by the receiver.
The sender is maintaining a timer for every packet sent, and any unacknowledged packet in a certain time is resent. The sender will send a complete window of packets before receiving an acknowledgement for the first packet in the window. This leads to a higher transfer rate, as the sender may send multiple packets without waiting for each packet's acknowledgement.
The Receiver advertises a window size that tells the sender how much data it can receive, for the sender not to fill up the receiver's buffers.
The 3-bit sliding window protocol is called a packet-based protocol and it consists of the data transmission protocols. It is used in the Transmission Control Protocol and in the Data Link Layer.
The 3-bit sliding window protocol is diagrammatically represented as follows −
In the 3-bit sliding window, three frames are sent by the sender at a time before receiving an acknowledgment. Sliding window refers to the imaginary boxes that hold the frames on both sender and receiver side.
2 5 6 2 1 3 9 2 5 6 2 1 3 9 2 5 6 2 1 3 9 2 5 6 2 1 3 9 2 5 6 2 1 3 9
The step wise explanation is as follows −
Step 1 − The above blocks represent a sliding window of size 3.
Step 2 − After receiving a frame from the sender, the receiver sends an acknowledgment (ACK), which includes the number of the next frame it expects to receive.
Step 3 − The diagram above shows an example of transactions of signals between the sending window and the receiver window for a 3-bit sliding window. There you can see the sender first sends 1, 2, and 3 to the receiver, then after receiving an acknowledgment for received 1 and sending 4 from the receiver, the sender again sends 4. It works similarly for sending 5 and 6.
Step 4 − But this process can face errors sometimes. Considering the receiver faces some error while receiving a frame, the receiver doesn't send an ACK back. For these situations, the sender maintains a timeout for receiving an ACK for every frame.
Step 5 − If it exceeds the time, then the sender resends the frame and adds it to the receiver if it's not already present there otherwise ignores it.
Step 6 − Another error is faced when an ACK is sent by the receiver and lost before receiving it by the sender. A similar use of timeout is applied for this error handling too.