Concepts / TCP connections

TCP connections

Sequence and acknowledgement numbers

Also called seq, ack, cumulative acknowledgement

TCP's byte counters: what this segment carries, and the next byte expected from the other side.

seq is my first byte here; ack is the next byte I expect
seq is my first byte here; ack is the next byte I expect

Each side numbers its own bytes from its own start. The client's 100-byte request is bytes 1001 to 1100, so the server acks 1101: 1001 + 100. The server's 300-byte reply is 5001 to 5300, acked with 5301. A SYN and a FIN each count as one byte. A gap in the numbers is how the receiver notices a loss.

ack 7 means "everything up to byte 7 arrived, send byte 7 next". The numbering lets TCP detect loss, resend exactly what is missing and put data back in order.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab