Loading content...
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.
Protocol complexity manifests across multiple dimensions. A thorough comparison must consider each:
Memory Complexity:
Computational Complexity:
Implementation Complexity:
State Management Complexity:
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 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:
State Machine:
Stop-and-Wait has the simplest state machine. The sender alternates between two states:
The receiver is even simpler:
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 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:
The sender bears the entire memory burden. The receiver remains trivial.
Computational Overhead:
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:
State Machine Complexity:
Go-Back-N sender states:
Receiver states:
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 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:
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:
The N Timers Challenge:
Selective Repeat requires N independent timers—one for each outstanding frame. This creates substantial implementation complexity:
Naive Implementation:
Efficient Implementation (Timer Wheel/Heap):
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.
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:
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.
When protocols are implemented in hardware (NICs, switches, FPGAs), complexity constraints differ significantly from software.
Hardware Resource Categories:
| 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:
SmartNIC Example (TCP Offload):
Modern SmartNICs implement Selective Repeat-like TCP processing. They use:
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.
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:
Formal verification is straightforward—the state space is tiny.
Go-Back-N Verification:
The window adds complexity. Test scenarios must include:
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:
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 |
Protocol complexity is the price paid for efficiency. This page has quantified that price across multiple dimensions:
The Complexity-Efficiency Tradeoff Curve:
Visualize complexity vs. efficiency as a curve:
The 'knee' of this curve shifts based on error rates. At p=0.001%, GBN is nearly optimal (why pay for SR?). At p=5%, SR's complexity is amply justified by its 7× throughput advantage.
What's Next:
With efficiency and complexity both quantified, we can now synthesize decision criteria. The next page provides comprehensive guidance on when to use each protocol, integrating channel characteristics, system constraints, and application requirements into actionable selection rules.
You now understand the full complexity cost of each ARQ protocol—memory requirements, computational overhead, code complexity, and verification challenges. Combined with the previous efficiency analysis, you can make informed tradeoff decisions. Next, we'll synthesize these factors into practical protocol selection guidelines.