Summary

  • TCP sequence numbers occupy a finite space from zero through 2^32−1, so all sequence arithmetic is modulo 2^32.
  • Modular comparison preserves local ordering when the counter rolls from its largest value back to zero.
  • The rule governs acknowledgments, retransmission state and receive-window tests; ordinary integer comparison can reverse the meaning near rollover.

A counter that cannot grow forever

RFC 793 made the constraint explicit: TCP's sequence number space is large but finite. Its values run from zero to 2^32−1, and every operation on them must be performed modulo 2^32. RFC 9293 retains the rule and the warning that comparisons require care.

The reason is visible at the boundary. If a byte has the highest possible sequence number, the following byte is numbered zero. As ordinary unsigned integers, zero is smaller. In the connection's progression, it is later. A direct greater-than comparison would therefore mistake new sequence space for old sequence space at exactly the moment the counter wraps.

Modulo arithmetic changes the model from a line into a ring. Moving forward from the current connection frontier eventually passes the largest value and continues at zero. The numeric label repeats only after traversing the entire space; the receiver and sender interpret it against their current state and bounded windows.

Comparison is the mechanism

The specification does not reserve modular arithmetic for an exceptional rollover handler. It makes it the ordinary language of sequence state. TCP must decide whether an acknowledgment covers data that was sent, whether sequence positions remain outstanding for retransmission, and whether an arriving segment lies inside the receive window. Each decision involves relative position on the ring.

That is why the RFCs define relational notation such as less-than-or-equal in modulo-2^32 terms. The difficult part is not incrementing a 32-bit counter; hardware and software naturally discard overflow. The difficult part is preserving the intended before-and-after relation when values on opposite sides of zero are compared.

Connection context supplies the local frame. A recent acknowledgment frontier, send window and receive window identify the relevant neighborhood of the ring. The protocol does not claim that two arbitrary 32-bit values, detached from state, possess a universal temporal order.

The rollover is not a reset

Returning to zero does not reset the TCP connection, reopen the handshake or erase outstanding state. The number is one coordinate inside the existing transmission control block. Acknowledgment and window variables continue to move according to modular comparisons.

This separates the mechanism from nearby histories. SYN and FIN have special sequence-space accounting, but they still inhabit the same ring. TIME-WAIT and initial-sequence-number selection address old duplicates and connection incarnation. TCP-AO's Sequence Number Extension protects authentication input across wraparound. None changes the base fact that the wire sequence number is 32 bits and base TCP orders it modulo 2^32.

What the rule cannot guarantee

Correct arithmetic does not by itself prevent stale traffic from being mistaken for current traffic in every circumstance. Connection lifetimes, segment age, window bounds and later mechanisms address other ambiguity risks. The cited specifications also do not measure current implementation failures or how quickly a modern transfer might traverse the space.

The durable design decision is narrower. TCP did not need an unbounded integer on the wire to maintain an ordered byte stream. It needed a finite label space, a rule that made the end connect to the beginning, and stateful comparisons that kept “before” and “after” meaningful near the join.

Sources