# Computer Network | Sliding Window protocols Summary With Questions

Prerequisites – Stop & Wait, Go Back N, Selective Repeat

### Summary of all the protocols –

Before starting with the questions a quick recap for all the protocols.

Stop and wait –

1. Sender window size (Ws) = 1
2. Receiver window size (Wr) = 1
3. Sequence Number >= 1 + 1
4. Uses independent acknowledgement
5. Discards out of order packets
6. Packet Loss → Retransmit packet after time out
7. Acknowledgement loss → Resends packet after time out
8. Efficiency = 1/(1+2a) where a = Tp/Tt

Go Back N –

1. Sender window size Ws = N
2. Receiver window size Wr = 1
3. Sequence number >= N + 1
4. Can use both cumulative or independent acknowledgement depends on acknowledge timer
5. Discards out of order packets
6. Packet Loss → Track back N size from the last packet within the window limit to the lost packet and retransmit them
7. Acknowledgement loss → If not received before timeout the entire window N size is resend
8. Efficiency = N/(1+2a) where a = Tp/Tt

Selective Repeat –

1. Sender window size Ws = N
2. Receiver window size Wr = N
3. Sequence Number >= N + N
4. Uses only independent acknowledgement
5. Can Accept out of order packets
6. Packet Loss → Resend only the lost packet after timeout
7. Acknowledgement loss → Resend if not receive before timeout
8. Efficiency = N/(1+2a) where a = Tp/Tt

### Practice Questions –

• Example-1. In Stop and wait protocol every 4th packet is lost and we need to send total 10 packets so how many transmission it took to send all the packets ?
• Explanation –
```1 2 3 4 5 6 7 8 9 10 (Initially)
^
1 2 3 4 4 5 6 7 8 9 10 (Packet no. 4 retransmitted)
^
1 2 3 4 4 5 6 7 7 8 9 10 (Packet no. 10 retransmitted)
^
1 2 3 4 4 5 6 7 7 8 9 10 10 (Result)
```

So, we retransmitted packet noumber 4, 7, 10
Total count = 13

• Example-2. In S&W protocol if Error probability is p and no. of packets to send is ‘n’.How many packets we have to send ?
• Explanation –
Total retransmissions
= n+ n*p+ n*p^(2) + n*p^(3) + n*p^(4) + …
= n(1 + p + p^2 + p^3 + p^4 + …)
= n*(1/1-p) using infinite GP formula
• Example-3. In GBN sender Window size = 10 and Tp = 49.5ms & Tt = 1ms. What is the Efficiency of the protocol and Throughput given Bandwidth=1000 bps ?
• Explanation –
Efficiency = N/(1+2a), N = 10 (given), a = Tp/Tt = 49.5
Efficiency = 10/(1+2*49.5) = 10/100 = 0.1 or 10%
Throughput = Efficiency * Bandwidth
= 0.1*1000 = 100
• Example-4. In GB3 if every 5th packet is lost & we need to send 10 packets so how many retransmissions are required ?
• Explanation –
```1 2 3 4 5 6 7  | 8 9 10
^   \$            (packet no. 5 lost)
1 2 3 4 5 6 7 5 6 7 8 9 | 10
*   ^   \$
1 2 3 4 5 6 7 5 6 7 8 9 7 8 9 10
*   ^  \$
1 2 3 4 5 6 7 5 6 7 8 9 7 8 9 10 9 10 (count starts from * till ^)
(from ^ to \$ retranmission is done)
```

Note – From Last packet is window size to lost pocket we resend the entire window.
Total no. of transmissions = 18

• Example-5. In SR Ws= 5 and we are sending 10 packets where every 5th packet is lost find number of retransmissions ?
• Explanation –
```1 2 3 4 5 6 7 8 9 10
^
1 2 3 4 5 5 6 7 8 9 10
^
1 2 3 4 5 6 7 8 9 9 10
```

We see here there is no role of Window size in SR only the lost packet is resent.
Total transmissions = 12

• Example-6. If there is K bits sequence no. define require sender window size and receiver window size for S&W, GBN & SR?

Explanation –
Given, K bits, For S&W Ws = 1 and Wr= 1
For GBN, Ws = 2^(K)-1 and Wr = 1
For SR, Ws = 2^(K-1) and Wr = 2^(K-1)

• This article is contributed by SHAURYA UPPAL. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

My Personal Notes arrow_drop_up

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.