The sliding window protocol is a flow control protocol for noisy channels. Being a flow control protocol, it prevents the receiver from overwhelming receiver from the data.
What is the purpose of Flow Control?
The rate at which the sender sends the data and at which the receiver receives the data may vary. However, the receiver maintains a data buffer as it has to process data before forwarding it to the upper layer.
Now, if the sender sends the data faster than the receiver can receive, then within some time, the data buffer at the receiver’s end will fill up and overflow while the receiver is still processing the old data.
This is why we require a flow control mechanism that prevents the sender from overwhelming the receiver with the data.
However, the sliding window protocol offers error control by adding the sequence number to the transmitted frames. Sequencing helps the receiver identify whether all the packets have arrived successfully and helps to sort them in the proper order.
Let’s learn more about this protocol in the section ahead.
Content: Sliding Window Protocol
- What is Sliding Window Protocol?
- Working Principle
- Types of Sliding Window Protocol
- Go-Back N Vs Selective Repeat
- Advantages and Disadvantages
What is Sliding Window Protocol?
The sliding window protocol allows the sender to send multiple frames without waiting for an acknowledgement. Thus, it applies the pipelining concept, where the transmission of the next frame starts even before the previous one is acknowledged.
Now to maintain the flow control, the sender and receiver both maintain a window, i.e. sending window and the receiving window. The sending window size corresponds to the number of frames the sender is permitted to send. And for error control, it maintains a sequence number of frames.
With sliding window protocol full duplex line is possible, which means several data packets and acknowledgement can be in the channel simultaneously. It even applies the concept of piggybacking, where the acknowledgement is delayed temporarily so that it can be hooked to the next outgoing packet.
Working Principle of Sliding Window Protocol
As we know, both sender and receiver maintain a buffer window. We refer senders’ buffer as sending window and the receiver’s buffer as receiving window.
Frames are assigned the sequence number from 0 to the maximum number. The maximum number of the frame is 2n – 1. Here, n is the number of bits that the packet’s header allows for the sequence number.
How many frames can be sent without waiting for the acknowledgement depends on the size of the sliding window. The maximum size of the window can be 2n – 1. However, some protocols have variable window sizes.
Types of Sliding Window Protocol
The types of sliding window protocols differ in terms of efficiency, complexity and buffer requirement.
Go back N ARQ
In the Go-Back N Automatic Repeat Request protocol, the sender can transmit several packets before receiving the acknowledgements. The packets are sequentially numbered, and at a time, only N number of packets are transmitted. Here, N is the size of the sliding window.
However, the receiver can receive only one packet at a time. This means the size of receiving window is one in Go-back N.
Now, the packets are sequentially numbered, and only N number of frames are sent at once. The sender keeps a copy of the sent frames until their acknowledgement is received. If any frame is not acknowledged within a particular time, all the frames starting from the unacknowledged one are retransmitted.
Let’s understand with the help of an example.
Example of Go-Back N ARQ Protocol
Consider that the packet’s header allows 3 bits for the sequence number. So, the packets will be numbered from 0 to 23 -1, i.e., from 0 to 7.
Now consider that the sender has 12 packets to send. These packets are sequentially numbered from 0 to 7, and the sequence is repeated again for the rest of the packets.
Now, as our window size is 7 the sender will send packets from 0 to 6 without waiting for the acknowledgement.
Now, as the receiver sends the acknowledgement for the 0th packet, the sliding window shifts forward and sends the 7th packet.
After receiving acknowledgement for the 1st packet, the sliding window moves forward and now sends the next packet in the sequence, i.e. 0th.
Meanwhile, the second packet is lost or gets damaged. It may even happen that its acknowledgement is lost.
So, after completing the waiting time for acknowledgement, the sender resends all the frames that the sliding window has, i.e. from 2 to 0. And even though after 2nd packet, the receiver has received the rest of the frames successfully, it discards them.
The sliding window divides the packets into three sections, as you can see in the image below:
Selective Repeat ARQ
Like Go-back N, in the Selective Repeat Automatic Repeat Request protocol, the sender can transmit several packets before receiving the acknowledgements. The maximum size of the sending and receiving window is the same in this protocol, i.e., 2m-1.
So, if we consider the same example we discussed in Go-back N., the packets will be numbered from 0 to 23-1, i.e., from 0 to 7.
The maximum size of the sliding window is 23-1 , i.e., 4.
Now consider that the sender has 12 packets to send. These packets are sequentially numbered from 0 to 7, and the sequence is repeated again for the rest of the packets.
Now the sender sends packet 0 to packet 3 without waiting for any acknowledgement.
When it receives the acknowledgement for packet 0, the sliding window moves forwards, and the sender sends packet 4.
Further, when the sender receives the acknowledgement of packet 1, the sliding window slides by one position and sends packet 5.
Meanwhile, there is a timeout for the acknowledgement of packet 2; however, the sender receives the acknowledgement for packets 3, 4 and 5.
So, the sender resends packet 2 and waits for its acknowledgement. As soon as it receives the acknowledgement for packet 2 the sliding window will slide, and the sender will send packet 6.
In this way, selective repeat protocol only resends the selective packet that is either lost, damaged, or negatively acknowledged, or if its acknowledgement is lost. It is quite complex as compared to Go-Back N but is comparatively efficient as it utilises the maximum bandwidth.
Go-Back N Vs Selective Repeat
Basis for Comparison | Go-Back N | Selective Repeat |
---|---|---|
Basic | If a packet is corrupted or lost, all the succeeding frames are resent | Only the corrupted frame is resent |
Bandwidth Wastage | If the error rate is high, Go-Back N waste a lot of bandwidth | Wastage of bandwidth is less |
Sorting | Do not require any searching and sorting. | Requires searching and sorting as it has to rearrange the resent packet. |
Storage | Comparatively less complicated as it doesn’t require any searching and sorting | Complicated as it requires searching and sorting, which in turn raises the need for storage |
Advantages and Disadvantages
Advantages
- It allows the sender to send multiple packets before receiving any acknowledgement.
- Manages flow control by using a buffer window at both the sender and receiver sides. And it manages the error control by adding sequence numbers to packets.
- It applies the pipelining concept, where multiple packets are sent, and a copy of them is stored in the buffer. As these packets are acknowledged, the copies are discarded, and the memory is freed. It increases the efficiency of the protocols and utilisation of available bandwidth.
- Achieve full-duplex and also allows piggybacking the acknowledgement with the next outgoing data packet.
Disadvantages
- With the protocols such as Go-Back N, there still needs to be more bandwidth.
So, this is all about the sliding window protocol, which allows the sender to send multiple data packets before receiving any acknowledgement to utilise the channel’s maximum bandwidth. We have discussed two types of sliding window protocols Go-Back N and Selective Repeat.
In the Go-Back N protocol, if a packet is lost or corrupted or the acknowledgement is lost, it resends all the subsequent packets it has already sent. In contrast, the Selective Repeat protocol only resents the damaged or lost packet.
Leave a Reply