Octet

Walk me through sequence and acknowledgment numbers for a short exchange, with real numbers.

Show the answer

Say this first

The sequence number is the number of the first data byte in a segment; the acknowledgment number is the next byte the receiver expects, and it is cumulative. SYN and FIN each use one number; pure ACKs use none. If the client starts at 1000 and sends 200 bytes after the handshake, its data segment is seq 1001 and the server acknowledges 1201.

Go deeper

Worked example

Real ISNs are random 32-bit numbers. Small ones keep the arithmetic visible. Client ISN 1000, server ISN 5000.

#DirectionFlagsSeqAckLenWhy
1C to SSYN10000Client ISN
2S to CSYN, ACK500010010Server ISN; SYN used byte 1000
3C to SACK100150010Pure ACK uses no number
4C to SPSH, ACK10015001200Request, bytes 1001 to 1200
5S to CACK500112011460Response part 1, bytes 5001 to 6460
6S to CPSH, ACK64611201500Response part 2, bytes 6461 to 6960
7C to SACK120169610One ACK covers both segments
8C to SFIN, ACK120169610FIN uses byte 1201
9S to CFIN, ACK696112020Acks the FIN; FIN uses byte 6961
10C to SACK120269620Final ACK, client enters TIME_WAIT

Rules to say out loud

  • Next seq from a sender = this seq + payload length (+1 for SYN or FIN).
  • Ack = highest in-order byte received + 1. It never jumps over a hole.
  • One ACK can cover many segments (segment 7), and with delayed ACK it usually covers two.

When segment 5 is lost

The client receives segment 6 first. It cannot advance past the hole, so it sends ack 5001 again (a duplicate ACK), with a SACK block 6461-6961 if SACK was agreed. The server sees exactly which bytes to resend.

Traps

  • Adding 1 for a pure ACK. Only SYN, FIN and data bytes use sequence numbers.