network-programmingnetwork-protocols

Why is window size less than or equal to half the sequence number in SR protocol?


In selective repeat protocol, the window size must be less than or equal to half the size of the sequence number space for the SR protocol. Why is this so, and how?


Solution

  • This is to avoid packets being recognized incorrectly.

    If the windows size is greater than half the sequence number space, then if an ACK is lost, the sender may send new packets that the receiver believes are retransmissions.

    For example, if our sequence number range is 0-3 and the window size is 3, this situation can occur.

    [initially] (B's window = [0,1,2])
    A -> 0 -> B (B's window = [1,2,3])
    A -> 1 -> B (B's window = [2,3,0])
    A -> 2 -> B (B's window = [3,0,1])
    [lost] ACK0
    [lost] ACK1
    A <- ACK2 <- B
    A -> 3 -> B
    A -> 0 -> B [retransmission]
    A -> 1 -> B [retransmission]
    

    After the lost packet, B now expects the next packets to have sequence numbers 3, 0, and 1.

    But, the 0 and 1 that A is sending are actually retransmissions, so B receives them out of order.

    By limiting the window size to 2 in this example, we avoid this problem because B will be expecting 2 and 3, and only 0 and 1 can be retransmissions.