The Go-Back-N protocol only works effectively if the error rate and packet loss are low. If a connection is weak, the sender often needs to resend each packet and the channel's bandwidth gets wasted. As a result, the network traffic increases and the network becomes congested. To solve this problem, we can use selective repeat protocol instead.
The selective repeat (SR) protocol is a sliding window-based data link layer protocol.
Following are some salient features of SR protocol:
The sender window size is always the same as the receiver window size.
The receiver side sends only independent acknowledgements when it successfully receives packets from the sender instead of cumulative acknowledgments.
The SR protocol does not tolerate corrupted frames. The receiver side sends back a negative acknowledgement when it sees a a corrupted frame from the sender side.
The SR protocol accepts out-of-order frames.
The receiver has to perform sorting to sort frame numbers sequentially.
The sender has to search the lost frames to re-transmit them.
After the time-out timer expires, the SR protocol re-transmits the lost frames.
The sender and receiver sides are the two primary components that assist in the working of selective repeat protocol. We discuss both of these with the help of an example scenario below.
Let's assume that the window size is 4, and the sender window has a packet sequence range from 0 to 3. The following happen:
Packets 0, 1, 2, 3 are sent to the receiver.
The sender receives an acknowledgment for frames 0 and 1, and the sender window slides by two slots.
Later, the sender receives an acknowledgement stating that Packet 3 is out-of-order.
Since the sender has not yet received an acknowledgement for Packet 2, the sender window does not slide.
As a result, the sender must resend packet 2 as the time-out for Packet 2 has expired.
Let's assume that the receiver window has a size of 4, and it also has a packet sequence range from 0 to 3. The following happen:
It receives Packets 0 and 1 first and sends an acknowledgment instantly.
It then receives Packet 3 out of order and sends an acknowledgment.
A detailed illustration of the selective repeat protocol operations in the example scenario is given below:
A complicated logic is required to sort the packets in the correct order on the receiver side. Moreover, the sender needs sophisticated logic to search and transmit the lost packet. In this manner, the selective repeat reduces network bandwidth by only re-transmitting corrupted or lost packets.