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 2m−12^m-1, the Selective-Repeat protocol restricts both the sender and receiver windows to at most one-half of the sequence number space.

Thus,

Maximum Window Size=2m2=2m−1\boxed{\text{Maximum Window Size} = \frac{2^m}{2}=2^{m-1}}

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

2m2^m

Maximum sender window size

2m−12^{m-1}

Maximum receiver window size

2m−12^{m-1}
Hence,Sender Window Size=Receiver Window Size=2m−1\boxed{\text{Sender Window Size}=\text{Receiver Window Size}=2^{m-1}}

Example

Suppose

m = 2

Number of sequence numbers

22=42^2=4

Sequence numbers are

0   1   2   3

Therefore,

Maximum window size

42=2\frac{4}{2}=2

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 = 2Window 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,

Window Size≤2m−1\boxed{\text{Window Size} \le 2^{m-1}}

Why is the Rule Different from Go-Back-N?

Go-Back-NSelective Repeat
Receiver window = 1Receiver window = Sender window
Receiver discards out-of-order packetsReceiver stores out-of-order packets
Sender window = 2m−12^m-1
Sender window = 2m−12^{m-1}
No ambiguity due to receiver window size 1Window 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 2m−12^{m-1}, which is one-half of the total sequence number space (2m2^m).
  • This restriction ensures that duplicate packets are never mistaken for new packets after sequence numbers wrap around.
  • If the window size exceeds 2m−12^{m-1}, 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

Popular posts from this blog

Computer Networks PCCST501 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Computer Networks

TCP/IP Protocol Suite