Packets can arrive out of order, be duplicated, or get lost in the network. The receiver needs a way to detect these issues and reconstruct the original data order.
Unique, consecutive numbers assigned to each packet (or byte in TCP) that allow the receiver to detect missing packets, reorder out-of-sequence packets, and identify duplicates.
- Sender assigns incrementing sequence numbers to outgoing packets/bytes
- Receiver tracks expected sequence number
- If received sequence > expected: packets are missing (gap detected)
- If received sequence < expected: duplicate packet (discard)
- Receiver can buffer out-of-order packets and reorder when gaps are filled
- Enables ordered delivery despite out-of-order arrival
- Detects lost packets (gap in sequence)
- Detects duplicate packets (seq already seen)
- In TCP, sequence numbers are per-byte, not per-packet
- Built from: Reliable Data Transfer — enables reliability
- Built from: Sliding Window Protocol — window tracks sequence numbers
- Related: Acknowledgment — ACKs reference sequence numbers
- Related: TCP — uses byte-level sequence numbers
- Sequence number space is finite (wraps around) — must be large enough to avoid ambiguity
- Initial sequence numbers are randomly chosen to avoid confusion with old connections
- TCP sequence numbers increment by bytes, not segments