2.5 Sliding Window Protocol: Selective Repeat (SR) ARQ
π‘ Core Intuition: The E-Commerce Package Delivery Analogyβ
π³ The Everyday Analogy: The Hallway Storage Closetβ
Imagine ordering a 4-piece home audio system (Amplifier, Left Speaker, Right Speaker, Subwoofer) from an online retailer:
- The warehouse ships all 4 items simultaneously in separate delivery vans.
- Van 1 (Amplifier) arrives safely at your door; you accept it.
- Van 2 (Left Speaker) encounters an accident and is lost in transit.
- Van 3 (Right Speaker) and Van 4 (Subwoofer) arrive safely at your door.
Under Go-Back-N rules, because you strictly wanted item 2 next and refused to hold out-of-order boxes, you would throw the Right Speaker and Subwoofer into the trash and demand the seller re-ship items 2, 3, and 4 from scratch!
Under Selective Repeat (SR) rules:
- You have a storage closet in your hallway (Receiver Buffer).
- You place the Right Speaker and Subwoofer into the closet, notify customer support that the Left Speaker is missing (Negative Acknowledgment / NAK), and wait.
- The retailer re-ships only the Left Speaker.
- When the Left Speaker arrives, you retrieve the Right Speaker and Subwoofer from your closet, assemble the complete 4-piece audio set in order, and enjoy your music. Zero undamaged packages are wasted!
π» Bridging to Computer Scienceβ
Selective Repeat resolves the primary bottleneck of sliding window protocols on noisy channels: by adding memory buffers at the receiver and dedicating individual timers at the transmitter, the protocol isolates errors to only the corrupted frame, achieving maximum throughput with zero redundant retransmissions.
πTable of Contents
- β‘ Why Selective Repeat? Overcoming GBN Inefficiencies
- πͺ Selective Repeat Architecture & Windows
- π The Master Mathematical Theorem: W_S + W_R \le 2^k
- βοΈ Operating Mechanics: Buffers, Timers & Negative ACKs
- π Interactive Flagship Blueprint: Selective Repeat ARQ Space-Time Protocol Ladder
- π Master Flow Control Comparison Matrix
- π Real-World Production Context
- π Numerical Applications & Worked Examples
- π― Exam & Interview Pitfall Check
β‘ Why Selective Repeat? Overcoming GBN Inefficienciesβ
While Go-Back-N provides full channel pipelining, it suffers from a fatal flaw on noisy transmission links:
- In GBN, losing a single frame forces the retransmission of an entire window of frames, even though the receiver may have already ingested subsequent frames error-free.
- On high-speed, long-distance links with large Bandwidth-Delay Products (), retransmitting frames consumes enormous channel capacity, causing throughput to drop precipitously.
Selective Repeat (SR) ARQ eliminates this retransmission waste:
- The receiver is equipped with a memory buffer of size to hold out-of-order, undamaged frames.
- The sender maintains an independent timer for every outstanding frame.
- When an error occurs, the sender retransmits only the specific missing or damaged frame, preserving all other packets in the receiver's buffer.
πͺ Selective Repeat Architecture & Windowsβ
In Selective Repeat, both the sender and the receiver maintain active sliding windows over the sequence number space.
Selective Repeat Window Symmetry & Buffer Architecture
Symmetric sender and receiver buffer allocation across sequence space 2^k
Sender Window Ws = 2^(k-1)
Tracks up to 2^(k-1) outstanding frames, each with an independent timer.
Receiver Window Wr = 2^(k-1)
Buffers out-of-order undamaged frames within range [Rf, Rf + Wr).
Network Layer L3 Sink
Packets delivered strictly in sequential order when lowest frame arrives.
The Symmetrical Window Configurationβ
In standard implementations, the sender window size and receiver window size are set symmetrically: Where is the number of bits allocated to sequence numbers in the frame header.
- For bits: Sequence space is (values ).
- .
- .
π The Master Mathematical Theorem: β
The most fundamental theorem governing sliding window protocols dictates that the sum of the sender window size and receiver window size cannot exceed the total sequence number space:
Proof by Contradiction: What Happens If ?β
Let bits total sequence numbers available (values ).
Suppose we violate the theorem and set and , so that :
- Initial Window State:
- Sender Window (Slots:
0, 1, 2). - Receiver Window (Slots:
0, 1).
- Sender Window (Slots:
- Initial Burst:
- Sender transmits Frames 0, 1, and 2.
- Receiver Progress:
- Receiver ingests Frame 0 and Frame 1 safely into its buffer.
- Receiver delivers Frames 0 and 1 to the Network Layer and advances its window forward by 2 positions:
Receive window slides from
[0, 1]to[2, 3]! - Receiver transmits and .
- Channel Failure:
- Both and are destroyed in transit by electromagnetic interference.
- Timeout & Retransmission:
- Sender timer for Frame 0 expires.
- Sender retransmits duplicate Frame 0 of the previous cycle.
- The Receiver Overlap Catastrophe:
- Suppose the receiver window had been sized slightly larger (e.g., , so ).
- Upon sliding forward by 2 positions, the receive window would cover slots
[2, 3, 0]! - Notice that slot
0is now an active member of the receiver's current acceptance window! - When duplicate Frame 0 arrives, the receiver cannot determine whether it is an old duplicate or brand-new data belonging to the next round. The duplicate is erroneously accepted, permanently corrupting user data!
- The Conclusion: To guarantee that an old retransmitted frame can never fall inside the current receive window, the window sizes must satisfy:
- For symmetric windows where :
βοΈ Operating Mechanics: Buffers, Timers & Negative ACKsβ
1. Independent Timersβ
Unlike Go-Back-N (which uses a single timer for the oldest frame), Selective Repeat maintains an independent countdown timer for every single unacknowledged frame in the sender window:
- When Frame is transmitted, its dedicated timer is started.
- When an acknowledgment for Frame arrives, timer is stopped.
- If timer expires, only Frame is retransmitted.
2. Receiver Buffering & Window Slidingβ
- If an incoming frame has an undamaged CRC and its sequence number falls within the receive window :
- The frame is stored in the receiver's local memory buffer.
- An ACK for that specific frame is returned to the sender.
- When does the receive window slide?
- The receive window slides forward only when the lowest in-order frame (at ) arrives!
- If Frames 2 and 3 are buffered while Frame 1 is missing, the window remains pinned at .
- As soon as missing Frame 1 arrives, the receiver delivers Frames 1, 2, and 3 to the Network Layer as an in-order batch, and the window slides forward past Frame 3!
3. Negative Acknowledgments (NAK / SACK)β
- When the receiver detects a missing sequence number (e.g., receives Frame 2 when awaiting Frame 1), it immediately dispatches a Negative Acknowledgment ().
- The triggers an immediate selective retransmission of Frame 1 without waiting for the sender's timeout timer to expire, cutting recovery delay down to .
4. Piggybackingβ
On full-duplex links where both stations are transmitting data, acknowledgment bits are embedded directly into the header of outgoing data frames (Piggybacking). This eliminates the bandwidth overhead of sending standalone ACK control packets.
π Interactive Flagship Blueprint: Selective Repeat ARQ Space-Time Protocol Ladderβ
The interactive space-time protocol ladder below traces Selective Repeat in action (): sender bursts Frames 0, 1, 2, 3; Frame 1 is lost in transit; the receiver buffers out-of-order Frames 2 and 3 in local RAM; negative ACK () triggers retransmission of ONLY Frame 1; and finally all frames are reassembled in-order and delivered to the upper layers.
Selective Repeat ARQ: Out-of-Order Buffering & Selective Retransmission Ladder
Space-time protocol ladder showing burst send, Frame 1 channel drop, receiver RAM buffering of F2/F3, NAK 1 dispatch, selective retransmit, and in-order release
Sender transmits Frame 0 and starts its dedicated retransmission timer. Frame 0 arrives at receiver with zero bit errors.
π Master Flow Control Comparison Matrixβ
The table below contrasts the operational parameters, hardware requirements, and mathematical boundaries of the three fundamental Data Link Layer flow control protocols:
| Feature / Metric | Stop-and-Wait ARQ | Go-Back-N (GBN) ARQ | Selective Repeat (SR) ARQ |
|---|---|---|---|
| Sender Window Size () | |||
| Receiver Window Size () | |||
| Window Size Relation | |||
| Sequence Number Bits () | ( and ) | ||
| Active Timers at Sender | (for oldest frame ) | independent timers | |
| Receiver Buffer Memory | (No buffer needed) | (Discards out-of-order) | frame buffers |
| Out-of-Order Frames | Discarded | Discarded | Buffered in local RAM |
| Acknowledgment Type | Individual / Alternating | Cumulative () | Selective / Individual (, ) |
| Retransmission Policy | Single frame | Go-Back- (All outstanding) | Selective (Only lost frame) |
| Efficiency () | |||
| Performance on Noisy Links | Poor | Extremely Poor (Retransmission storm) | Excellent (Zero redundant retransmission) |
| Implementation Complexity | Minimal | Moderate | High (Buffer sorting + multiple timers) |
π Real-World Production Contextβ
How TCP SACK and 5G Radio Links Implement Selective Repeatβ
In modern internet transport and cellular infrastructure:
- TCP Selective Acknowledgment (TCP SACK, RFC 2018): When packets drop across high-latency transoceanic fiber links, standard TCP would collapse into Go-Back-N retransmissions. SACK allows the receiver to report non-contiguous received byte blocks (e.g., received bytes 5000β6000 and 7000β8000), allowing the sender to selectively retransmit only the missing byte span 6001β6999.
- 5G New Radio (NR) RLC Layer: Operates in Acknowledged Mode (AM) using Selective Repeat with specialized status reports (
STATUS PDU) to prevent retransmission of massive 100MB blocks over volatile millimeter-wave radio links.
π Numerical Applications & Worked Examplesβ
Example 1: Minimum Sequence Number Bits for Selective Repeat on Long-Haul Linksβ
Problem Statement:
Consider two communication hosts X and Y connected by a direct point-to-point link of rate (). The physical distance between the hosts is and signal propagation speed through the medium is . Host X transmits data frames of size each to host Y using Selective Repeat sliding window protocol. Calculate the minimum number of bits required for the sequence number field in the frame header to achieve link efficiency.
Step-by-Step Solution:β
- Given Parameters:
- Bandwidth .
- Distance .
- Velocity .
- Frame size .
- Calculate Propagation Delay () and Transmission Delay ():
- Calculate Parameter and Optimal Window Size ():
- Compute Minimum Sequence Number Bits ():
- In symmetric Selective Repeat: .
- For : (Insufficient).
- For : (Satisfied!).
- Final Result: At least are required in the sequence number field.
Example 2: Mathematical Proof of Maximum Window Size with n-Bit Identifiersβ
Problem Statement:
Prove analytically why the maximum allowable sender window size for data transmission using the Selective Repeat protocol with -bit frame sequence numbers is .
Step-by-Step Solution:β
- General Sliding Window Condition: To avoid overlap between the current receive window and old retransmitted duplicate frames, the window sizes must satisfy:
- Symmetric Window Allocation: In Selective Repeat, to handle bidirectional symmetric communication and ensure identical buffer memory allocations at both endpoints, the receive window is chosen equal to the send window:
- Substitute into Inequality:
- Final Result: The maximum possible sender window size is strictly .
Example 3: Feasibility Analysis of Full Sequence Space Allocation ( Window)β
Problem Statement:
Suppose an engineer attempts to configure a sliding window protocol with a sender window size of , where is the total number of bits in the sequence number field. Analyze whether this protocol can operate correctly under Selective Repeat without data corruption.
Step-by-Step Solution:β
- Evaluate Against the Master Theorem:
- The fundamental condition is .
- Even under the most restrictive receiver configuration possible ():
- Analyze Failure Mode for :
- If , the sender window consumes the entire sequence space.
- If all acknowledgments for an entire window are lost, the sender times out and retransmits duplicate frames.
- Because the sequence numbers have wrapped around by an entire cycle (), the receiver will misidentify duplicate frames as brand-new frames from the next cycle.
- Final Result: A sender window size of will inevitably lead to protocol failure. The maximum allowable window size is for symmetric Selective Repeat.
π― Exam & Interview Pitfall Checkβ
Question 1: "Why is Selective Repeat much harder to implement in hardware than Go-Back-N?"
Key Focus Points:
- Memory Buffer Management: SR requires active RAM buffers at both the transmitter and the receiver to store, reorder, and track out-of-order packets.
- Multiple Concurrent Timers: The transmitter must maintain and update an independent hardware countdown timer for every unacknowledged frame in the window, creating significant interrupt-handling overhead.
- In-Order Assembly Logic: The receiver must implement sorting and gap-detection logic to deliver frames to the Network Layer in strict order.
Question 2: "What happens in Selective Repeat if an ACK for Frame 0 is lost, but the sender receives an ACK for Frame 1?"
Key Focus Points:
- In Selective Repeat, acknowledgments are selective and independent, not cumulative.
- Receiving confirms only Frame 1. It tells the sender nothing about Frame 0.
- Frame 0 remains unacknowledged in the sender's window until its dedicated timer expires or a arrives, at which point only Frame 0 is retransmitted.
Question 3: "Under what channel conditions is Go-Back-N preferred over Selective Repeat?"
Key Focus Points:
- On ultra-reliable, low-error channels (such as local Ethernet fiber), packet loss is nearly zero ().
- Under zero-loss conditions, the retransmission storm of GBN never triggers, and GBN achieves identical efficiency to Selective Repeat while saving significant buffer memory and timer complexity.
Trap 1: "Does Selective Repeat use cumulative ACKs like Go-Back-N?"
Answer: Standard Selective Repeat uses individual/selective ACKs. An in pure Selective Repeat acknowledges only frame . However, modern advanced transport protocols like TCP SACK (Selective Acknowledgment) combine both: the standard TCP header carries a cumulative ACK, while TCP options carry SACK blocks describing out-of-order received chunks!
Trap 2: "Can the receiver window () in Selective Repeat be larger than the sender window ()?"
Answer: Technically yes mathematically (), but practically never. If , the extra receive slots sit completely empty because the sender can never transmit more than frames at any time! Symmetrical sizing () maximizes bandwidth utilization in both directions.