ARQ Protocol Comparison: Stop-and-Wait, Go-Back-N, and Selective Repeat
Complexity Trade-offs
Read aloud is unavailable in this browser.
The Price of Efficiency
Efficiency numbers tell only half the story. Selective Repeat may achieve 95% utilization where Go-Back-N manages only 12%—but at what cost? How much more memory, processing power, and engineering effort does that efficiency require?
In real systems, resources are finite. A network interface card (NIC) has limited on-chip memory. An embedded sensor node runs on a microcontroller with 4KB of RAM. A satellite transceiver must minimize power consumption. The 'best' protocol isn't always the most efficient—it's the one that delivers acceptable performance within the available resource envelope.
This page quantifies the implementation complexity of each ARQ protocol, enabling informed tradeoff decisions.
By the end of this page, you will understand the memory requirements, computational overhead, state management complexity, and implementation difficulty of Stop-and-Wait, Go-Back-N, and Selective Repeat. You'll be able to estimate resource needs for specific scenarios and justify protocol choices based on complexity constraints.
Dimensions of Complexity
Protocol complexity manifests across multiple dimensions. A thorough comparison must consider each:
Memory Complexity:
- Buffer space for frames awaiting acknowledgment (sender)
- Buffer space for out-of-order frames (receiver)
- State variables (sequence numbers, window bounds, flags)
- Timer state
Computational Complexity:
- Processing per frame sent/received
- Timer management overhead
- Reordering/sorting operations
- Acknowledgment processing
Implementation Complexity:
- Lines of code
- Edge cases and corner conditions
- Testing and verification difficulty
- Potential for bugs
State Management Complexity:
- Number of distinct states
- State transition complexity
- Concurrency considerations
- Recovery from inconsistent states
- •Memory costs money — On-chip SRAM in NICs costs ~10× more per bit than DRAM. Large buffers increase hardware cost.
- •Computation costs power — In battery-powered devices, every CPU cycle drains the battery. Complex protocols reduce operational lifetime.
- •Bugs cost reliability — Complex protocols have more edge cases and are harder to verify. Subtle bugs can cause data corruption or deadlocks.
- •Development costs time — More complex protocols take longer to implement, test, and debug. Time-to-market matters.
- •Maintenance costs effort — Complex code is harder to understand, modify, and extend. Technical debt accumulates.
In high-speed networking, protocol operations are often moved to hardware (ASICs, FPGAs) for performance. But hardware has stricter complexity limits than software—simpler protocols are much easier to implement in silicon and consume less chip area.
Stop-and-Wait: Minimal Complexity
Stop-and-Wait represents the baseline—the simplest possible reliable protocol. Its complexity analysis sets the lower bound.
Memory Requirements:
| Component | Sender | Receiver | Size |
|---|---|---|---|
| Frame buffer | 1 frame copy | None needed | L bits |
| Sequence state | Current seq (1 bit) | Expected seq (1 bit) | 2 bits total |
| Timer state | Single timeout value | None | ~32 bits |
| Total | L + 33 bits | 1 bit | ~L + 34 bits |
For a 1500-byte frame: Sender needs ~1502 bytes, Receiver needs 1 bit. This is essentially zero overhead beyond the frame itself.
Computational Overhead:
- •Copy frame to buffer: O(L) — one-time copy
- •Set sequence number: O(1) — single bit toggle
- •Start timer: O(1) — single timer operation
- •On ACK: Check sequence match: O(1)
- •On timeout: Retransmit buffered frame: O(L)
- •Validate checksum/CRC: O(L) — standard for all protocols
- •Check sequence number: O(1) — single bit comparison
- •Deliver to upper layer (if new): O(1) — pointer handoff
- •Send ACK: O(1) — tiny fixed-size packet
- •Toggle expected sequence: O(1)
State Machine:
Stop-and-Wait has the simplest state machine. The sender alternates between two states:
- Wait for data from upper layer → Send frame, start timer
- Wait for ACK → On ACK: advance to next frame. On timeout: resend.
The receiver is even simpler:
- Wait for frame → If expected seq: deliver and ACK. If duplicate: just ACK.
Implementation Statistics:
| Metric | Typical Value | Notes |
|---|---|---|
| Lines of code (sender) | 50-100 | Core logic only |
| Lines of code (receiver) | 30-50 | Minimal state |
| Distinct states (sender) | 2-3 | Idle, Wait ACK, (Timeout) |
| Distinct states (receiver) | 1-2 | Wait frame, (Process) |
| Edge cases | ~5 | Lost ACK, lost frame, duplicate, timeout, corruption |
| Test scenarios | ~10 | Normal + each edge case × 2 |
Stop-and-Wait is perfect for: bootloaders, firmware update protocols, low-speed sensors, serial links, and any scenario where simplicity and correctness trump throughput. Many embedded UART protocols use Stop-and-Wait implicitly.
Go-Back-N: Moderate Sender Complexity
Go-Back-N adds significant complexity to the sender while keeping the receiver simple. This asymmetry was historically important when receivers had limited resources (terminals, early PCs).
Memory Requirements:
| Component | Sender | Receiver | Size |
|---|---|---|---|
| Frame buffer | N frame copies | None needed | N × L bits |
| Sequence state | base, nextseq (2 × log₂N bits) | Expected seq (log₂N bits) | 3 × log₂N bits |
| Timer state | Single timeout for base | None | ~32 bits |
| Window metadata | N outstanding flags (optional) | None | N bits (optional) |
| Total Sender | N × L + O(N) bits | ||
| Total Receiver | O(log N) bits |
For N=127, 1500-byte frames:
- Sender: 127 × 12,000 bits = 190 KB
- Receiver: ~10 bytes
The sender bears the entire memory burden. The receiver remains trivial.
Computational Overhead:
- •Buffer frame at window position: O(L) — copy to circular buffer
- •Set sequence number: O(1)
- •Start/update timer (if first in window): O(1)
- •Track window bounds: O(1)
- •On cumulative ACK: slide window, discard acknowledged frames: O(1) amortized
- •On timeout: retransmit all outstanding frames: O(N × L) worst case
- •Validate checksum/CRC: O(L)
- •Check if sequence equals expected: O(1)
- •If in-order: deliver, increment expected: O(1)
- •If out-of-order: discard (no buffering!): O(1)
- •Send cumulative ACK for highest in-order: O(1)
The Single Timer Simplification:
Go-Back-N uses one timer for the entire window—the timer for the oldest unacknowledged frame (at base). When this timer expires, all frames from base onward are retransmitted.
This simplification has profound implications:
- Advantage: Only one timer to manage, minimal timer overhead
- Disadvantage: Can't individually timeout specific frames
- Consequence: If one frame is lost deep in the window, we wait for the base timer even though the loss was detected earlier
State Machine Complexity:
Go-Back-N sender states:
- Idle: Window empty, waiting for data
- Sending: Data available, window not full, actively transmitting
- Window Full: Waiting for ACKs before sending more
- Timeout Recovery: Retransmitting from base
Receiver states:
- Wait for expected frame: Same as Stop-and-Wait
The sender state machine has more transitions but remains manageable.
| Metric | Typical Value | Notes |
|---|---|---|
| Lines of code (sender) | 150-300 | Circular buffer, window mgmt |
| Lines of code (receiver) | 40-60 | Nearly unchanged from SW |
| Distinct states (sender) | 4-6 | Window full adds states |
| Distinct states (receiver) | 1-2 | Same as SW |
| Edge cases | ~15 | Window wraparound, cumulative ACK edge cases |
| Test scenarios | ~30 | Varies with window size |
Cumulative ACKs provide implicit recovery from lost ACKs. If ACK 3 is lost but ACK 5 arrives, the sender knows frames 0-5 are all received. This reduces retransmission triggered by ACK loss, a significant practical advantage.
Selective Repeat: Maximum Complexity
Selective Repeat achieves optimal efficiency at the cost of maximum complexity. Both sender and receiver must maintain substantial state.
Memory Requirements:
| Component | Sender | Receiver | Size |
|---|---|---|---|
| Frame buffer | N frame copies | N frame slots | 2 × N × L bits |
| Sequence state | base, nextseq | rcv_base, window bounds | 4 × log₂N bits |
| Timer state | N individual timers | None | N × 32 bits |
| ACK/received flags | N bits (ACK status) | N bits (received status) | 2N bits |
| Total Sender | N × L + N × 33 bits | ||
| Total Receiver | N × L + N + log₂N bits |
For N=127, 1500-byte frames:
- Sender: 127 × 12,000 + 127 × 33 = ~190 KB + 528 bytes
- Receiver: 127 × 12,000 + 127 + 7 = ~190 KB + 17 bytes
Total: ~380 KB — nearly double Go-Back-N's memory!
The receiver now needs as much buffer as the sender. This is the fundamental resource cost of efficiency.
Computational Overhead:
- •Buffer frame at indexed position: O(L)
- •Set sequence number: O(1)
- •Start individual timer for this frame: O(1) or O(log N) with timer heap
- •Track per-frame ACK status: O(1)
- •On individual ACK: mark frame acknowledged: O(1)
- •On ACK for base: slide window, possibly multiple positions: O(N) worst case
- •On timeout for specific frame k: retransmit only frame k: O(L)
- •Validate checksum/CRC: O(L)
- •Check if sequence falls within window: O(1)
- •If in window: buffer at indexed position, mark received: O(L)
- •Send individual ACK for received frame: O(1)
- •Check if base position is now filled: O(1)
- •If base filled: deliver consecutive frames, slide window: O(N) worst case
The N Timers Challenge:
Selective Repeat requires N independent timers—one for each outstanding frame. This creates substantial implementation complexity:
Naive Implementation:
- Array of N timer structures
- Check all N timers periodically (inefficient)
- O(N) time per timer check
Efficient Implementation (Timer Wheel/Heap):
- Priority queue (heap) of pending timeouts
- O(log N) to insert/cancel timers
- O(log N) to get next expiring timer
- Significantly more complex code
The Reordering Challenge:
When the receiver delivers frames to the upper layer, it must deliver them in order. This requires tracking which buffer positions are filled and scanning for consecutive filled positions from the base.
| Metric | Typical Value | Notes |
|---|---|---|
| Lines of code (sender) | 300-500 | Timer management, individual ACK handling |
| Lines of code (receiver) | 200-350 | Buffering, reordering, window management |
| Distinct states (sender) | Multiple per-frame | Each frame has its own state |
| Distinct states (receiver) | Multiple per-slot | Each slot: empty/filled/delivered |
| Edge cases | ~30+ | Window wraparound, out-of-window frames, duplicate handling |
| Test scenarios | ~100+ | Combinatorial explosion of frame arrival orders |
Selective Repeat's correctness is notoriously difficult to verify. With N=8, there are 8! = 40,320 possible orderings of 8 frames. With random losses, retransmissions, and duplicate possibilities, the state space explodes. Formal verification methods are often employed for high-reliability implementations.
Comparative Complexity Summary
Let's consolidate the complexity analysis across all dimensions:
| Dimension | Stop-and-Wait | Go-Back-N | Selective Repeat |
|---|---|---|---|
| Sender Buffer | 1 frame | N frames | N frames |
| Receiver Buffer | 0 frames | 0 frames | N frames |
| Total Buffer | L bits | N × L bits | 2N × L bits |
| Timer Count | 1 | 1 | N |
| Timer Complexity | Trivial | Simple | O(log N) operations |
| Sender Code | ~75 LOC | ~225 LOC | ~400 LOC |
| Receiver Code | ~40 LOC | ~50 LOC | ~275 LOC |
| Total Code | ~115 LOC | ~275 LOC | ~675 LOC |
| State Variables | 2-3 | 4-6 | 2N + 4 |
| Edge Cases | ~5 | ~15 | ~30+ |
| Test Scenarios | ~10 | ~30 | ~100+ |
Complexity Ratios (relative to Stop-and-Wait):
| Metric | SW | GBN | SR |
|---|---|---|---|
| Buffer Memory | 1× | N× | 2N× |
| Code Size | 1× | ~2.4× | ~5.9× |
| Test Scenarios | 1× | 3× | 10×+ |
| Bug Risk | Low | Medium | High |
Implications by Deployment Scenario:
- •Memory is severely constrained (microcontrollers)
- •Implementation time is limited
- •Correctness is paramount (safety-critical)
- •Error rates are very low (fiber, local cable)
- •Bandwidth-delay product is small (LANs)
- •Power consumption must be minimized
- •Memory is abundant (servers, modern PCs)
- •Development resources are available
- •Throughput maximization is critical
- •Error rates are significant (wireless, satellite)
- •Bandwidth is expensive or scarce
- •High-BDP links must be utilized efficiently
On modern systems with GBs of RAM, the memory cost of Selective Repeat is trivial. A 190 KB buffer is negligible. The primary remaining concerns are code complexity (bug risk) and timer management overhead. Most high-performance stacks (TCP, SCTP) implement SR-like mechanisms because the efficiency gains far outweigh the complexity costs on modern hardware.
Hardware Implementation Considerations
When protocols are implemented in hardware (NICs, switches, FPGAs), complexity constraints differ significantly from software.
Hardware Resource Categories:
- •Logic Elements (LEs) — Combinational and sequential logic gates. Complex state machines consume more LEs.
- •Block RAM (BRAM) — On-chip memory for buffers. Typically 18-36 Kb per block. Frame buffers consume many blocks.
- •Flip-Flops (FFs) — Storage for state variables. Each bit of state requires one FF.
- •Clock Frequency — Complex logic paths slow down maximum clock rate. Simpler protocols run faster.
- •Power Consumption — Proportional to switching activity. More logic = more power.
| Resource | Stop-and-Wait | Go-Back-N | Selective Repeat |
|---|---|---|---|
| BRAM (18 Kb blocks) | 1 | 8 | 16 |
| Logic Elements | ~200 | ~800 | ~2500 |
| Flip-Flops | ~50 | ~200 | ~1000 |
| Maximum Clock | High | Medium | Lower |
| Power (relative) | 1× | 2-3× | 5-8× |
Line-Rate Processing Challenges:
At 100 Gbps, a minimum-size 64-byte packet arrives every ~5 nanoseconds. The protocol logic must complete all per-packet operations within this budget. Complex operations like heap-based timer management may not achieve line rate.
Hardware solutions:
- Pipelining: Spread operations across multiple clock cycles
- Parallelism: Process multiple packets simultaneously
- Approximation: Use simpler timer schemes (e.g., coarse-grained timer wheels)
- Offloading: Handle common case in hardware, exceptions in software
SmartNIC Example (TCP Offload):
Modern SmartNICs implement Selective Repeat-like TCP processing. They use:
- Multi-bank SRAM for out-of-order packet buffers
- Hardware timer wheels with 1024+ slots
- Dedicated reordering engines
- ~500K logic elements (substantial silicon investment)
Intel's FPGA-based 100G SmartNIC (N6000) uses significant die area for TCP offload. Simpler protocols would reduce chip cost by 20-30%. For cost-sensitive applications (consumer NICs), this matters. For datacenters prioritizing CPU offload, the investment pays off in reduced host processing.
Debugging and Verification Challenges
Protocol complexity directly impacts the difficulty of ensuring correctness. This section examines the verification challenges for each protocol.
Stop-and-Wait Verification:
With only 2 states per endpoint and 5 edge cases, exhaustive testing is feasible. A test suite can cover:
- Normal operation (frame sent, ACK received)
- Lost frame (timeout, retransmit)
- Lost ACK (timeout, retransmit, duplicate delivery prevented)
- Corrupted frame (CRC fails, silence, timeout)
- Corrupted ACK (treated as lost)
Formal verification is straightforward—the state space is tiny.
Go-Back-N Verification:
The window adds complexity. Test scenarios must include:
- Window fill and drain
- Cumulative ACK advancement (multiple frames acknowledged at once)
- Timeout with partially acknowledged window
- Window wraparound (sequence number recycling)
- Out-of-order frame arrival (should be discarded)
The state space grows with window size but remains manageable. Model checking tools can verify correctness for small N.
Selective Repeat Verification:
SR's state space explodes combinatorially. For a window of N frames, each can be in multiple states (sent/not-sent at sender; received/not-received at receiver). The receiver buffer can hold any subset of frames. Arrival orders are arbitrary.
Critical Edge Cases:
- •Sequence number wraparound with full windows — Old frame from previous cycle arrives after gaps are filled
- •Receiver window slides while frames in transit — Frame arrives for position that has already been delivered
- •Timer race conditions — Timer expires just as ACK arrives
- •Duplicate detection after window advance — Retransmitted frame arrives after original was delivered
- •ACK loss for critical positions — ACK for base frame lost, preventing window slide despite all frames received
- •Out-of-window frame handling — Frame outside window must be correctly identified and discarded or re-ACKed
Multiple TCP implementations have had subtle bugs in SACK (Selective ACK) processing. Linux kernel commit logs contain numerous fixes for corner cases in TCP's Selective Repeat mechanisms—edge cases discovered years after initial implementation. This underscores the verification challenge.
Verification Techniques:
| Technique | Applicability | Coverage |
|---|---|---|
| Unit testing | All protocols | Limited edge cases |
| Property-based testing | All protocols | Better coverage of random scenarios |
| Model checking (TLA+, SPIN) | SW, GBN, small SR | Exhaustive for tractable state spaces |
| Formal proof | SW, simplified GBN | Complete correctness guarantee |
| Fuzzing | All protocols | Finds unexpected behaviors |
| Network simulation (ns-3) | All protocols | Realistic scenarios |
KEEP LEARNING
Keep learning for free.
Read the complete lesson, save your notes and pick up where you left off with a free account. No card needed.