Window Sizes in the Selective-Repeat (SR) Protocol
Window Sizes in the Selective-Repeat (SR) Protocol
One of the most important concepts in the Selective-Repeat (SR) Protocol is the size of the sender and receiver windows.
Unlike the Go-Back-N protocol, where the sender window can be as large as , the Selective-Repeat protocol restricts both the sender and receiver windows to at most one-half of the sequence number space.
Thus,
This rule is necessary to prevent duplicate packets from being mistaken for new packets after the sequence numbers wrap around.
Why is the Window Size Limited?
In Selective Repeat,
- packets may arrive out of order,
- the receiver stores out-of-order packets,
- acknowledgments are individual, and
- sequence numbers are reused after reaching their maximum value.
If the sender and receiver windows are too large, then after the sequence numbers wrap around, an old duplicate packet may appear to be a new packet, causing incorrect data delivery.
To avoid this ambiguity,
Both the sender and receiver window sizes must be at most one-half of the sequence number space.
Maximum Window Size Formula
If the sequence number field contains m bits, then
Number of sequence numbers
Maximum sender window size
Maximum receiver window size
Example
Suppose
m = 2
Number of sequence numbers
Sequence numbers are
0 1 2 3
Therefore,
Maximum window size
Thus,
Sender Window = 2 Receiver Window = 2
Case 1: Correct Window Size (Window Size = 2)
Initially,
Sender Window
0 1
Receiver Window
0 1
The sender transmits
Packet 0 Packet 1
Both packets reach the receiver successfully.
The receiver sends
ACK 0 ACK 1
Suppose both acknowledgments are lost.
The sender does not receive the ACKs.
After timeout,
the sender retransmits
Packet 0
However,
the receiver has already received Packets 0 and 1.
Its receive window has now moved to
2 3
Notice that
Packet 0
is not inside the current receive window.
Therefore,
the receiver correctly recognizes it as a duplicate packet and discards it.
Receive Window 2 3 Duplicate Packet 0 ↓ Discard
Thus,
no error occurs.
Case 2: Incorrect Window Size (Window Size = 3)
Now assume the window size is increased to
3
Initial receiver window
0 1 2
After successfully receiving Packets
0 1 2
the receiver window moves to
3 0 1
Notice something important.
After wrapping around,
the receiver window now contains
0
again.
Suppose all acknowledgments are lost.
The sender retransmits
Packet 0
The receiver now examines Packet 0.
Current receiver window
3 0 1
Packet 0 is inside the current receive window.
Therefore,
the receiver mistakenly believes that this duplicate packet is actually a new packet.
Instead of discarding it,
it accepts Packet 0 and delivers it as new data.
Duplicate Packet 0 ↓ Accepted as New Packet ↓ Wrong Data Delivered
This is a serious protocol error.
Why Does This Happen?
The receiver cannot distinguish between
Old Packet 0 and New Packet 0
because the sequence numbers have wrapped around.
When the receive window is too large,
both old and new packets may fall inside the receiver window at the same time.
This creates ambiguity.
Comparison
| Window Size = 2 | Window Size = 3 |
|---|---|
| Duplicate packet is outside receiver window | Duplicate packet falls inside receiver window |
| Receiver discards duplicate | Receiver accepts duplicate |
| Correct operation | Incorrect operation |
Important Rule
To prevent duplicate packets from being accepted as new packets,
the sender and receiver windows must never exceed one-half of the sequence number space.
Therefore,
Why is the Rule Different from Go-Back-N?
| Go-Back-N | Selective Repeat |
|---|---|
| Receiver window = 1 | Receiver window = Sender window |
| Receiver discards out-of-order packets | Receiver stores out-of-order packets |
| Sender window = | Sender window = |
| No ambiguity due to receiver window size 1 | Window size must be limited to avoid ambiguity |
Key Points to Remember
- In Selective Repeat, both the sender and receiver use sliding windows.
- The maximum size of both windows is , which is one-half of the total sequence number space ().
- This restriction ensures that duplicate packets are never mistaken for new packets after sequence numbers wrap around.
- If the window size exceeds , an old retransmitted packet may fall inside the receiver's current window and be incorrectly accepted as a new packet, leading to incorrect data delivery.

Comments
Post a Comment