Protocol Layers — Sequence Counters and Retries
Overview
Sequence counters are fundamental mechanisms used by communication protocols to ensure ordering, detect missing or duplicated frames, and prevent replay. Retries complement sequence counters by providing controlled retransmission when acknowledgments or expected frames are not received.
Together, these mechanisms form the backbone of reliability in packet‑based communication systems.
Sequence Counter Fundamentals
A sequence counter is a monotonically increasing value associated with each transmitted frame. Its primary purposes are:
- Ordering — ensuring frames are processed in the correct sequence
- Missing frame detection — identifying gaps in the sequence
- Duplicate detection — rejecting retransmitted or replayed frames
- Replay protection — preventing old frames from being accepted
Sequence counters may be:
- per‑frame
- per‑transaction
- per‑channel or per‑flow
- modulo‑N (wrapping counters)
How Sequence Counters Work
When a receiver processes a frame, it compares the received sequence number with the expected one:
- If equal, the frame is valid and accepted
- If greater, one or more frames were lost
- If lower, the frame is a duplicate or replay
- If out of range, the frame is invalid and discarded
Protocols may also implement:
- windowing (sliding window protocols)
- acknowledgment numbers
- selective acknowledgments
- negative acknowledgments (NACKs)
Retry Mechanisms
Retries are triggered when the sender does not receive an acknowledgment within a defined timeout window.
Retry logic typically includes:
1. Retry Counters
A maximum number of retries is enforced to avoid infinite loops.
2. Timeout Windows
The sender waits for an ACK for a predefined time before retrying.
3. Exponential Backoff
The retry interval increases after each failed attempt to reduce congestion.
4. Sequence Number Reuse Rules
Retransmitted frames must reuse the same sequence number to avoid ambiguity.
5. Abort Conditions
If the retry limit is reached, the protocol transitions to an error or recovery state.
Failure Modes
Sequence counters and retry mechanisms can fail in several ways:
1. Counter Corruption
A corrupted sequence number may cause:
- false missing‑frame detection
- acceptance of invalid frames
- loss of synchronization
2. Replay Attacks or Duplicates
Old frames may be re‑injected into the system if replay protection is weak.
3. Retry Storms
Excessive retries can overload the channel or cause congestion collapse.
4. Timeout Misconfiguration
Timeouts that are too short or too long lead to:
- premature retries
- excessive latency
- unnecessary retransmissions
5. Window Misalignment
In sliding‑window protocols, sender and receiver windows may desynchronize.
Safety Considerations
Sequence counters and retries are safety‑critical because they directly affect:
- detection of missing or corrupted data
- prevention of stale or replayed frames
- recovery from transient communication faults
- avoidance of deadlock or livelock conditions
Safety‑critical systems adopt:
- redundant sequence counters
- range and sanity checks
- timeout supervision with watchdogs
- bounded retry limits
- explicit recovery states
Related Technical Pages
Protocol Layer Fundamentals
- Protocol Layering — Architecture Fundamentals
- Protocol Layers & Packet Processing — Overview & Families