TCP flags and sessions cheat sheet
The header, what each flag means, the handshake and the close step by step, and reading flags in a capture.
01 The header (20–60 bytes)
| Field | Bits | What to know |
|---|---|---|
| Source / destination port | 16 + 16 | Client picks a random high (ephemeral) port; server listens on the well-known one. |
| Sequence number | 32 | Number of the first data byte in this segment. The first one (ISN) is random. |
| Acknowledgment number | 32 | The next byte expected from the other side. Valid only when ACK is set. |
| Data offset | 4 | Header length in 32-bit words: 5 (20 bytes) to 15 (60 bytes). |
| Reserved | 4 | Must be zero. The last of these bits was once the NS flag (see the flags table). |
| Flags | 8 | CWR ECE URG ACK PSH RST SYN FIN. |
| Window | 16 | Receive buffer free, in bytes. The window-scale option multiplies it (up to ×2^14). |
| Checksum | 16 | Covers header, data and a pseudo-header with the IP addresses. |
| Urgent pointer | 16 | Used only with URG. |
| Options | 0–320 | MSS, window scale, SACK and timestamps; most are agreed in the SYN. |
On the full sheet
- The flags
- Opening: the three-way handshake
- Closing: graceful and abrupt
- Reading flags in a capture
- TCP or UDP
- Exam traps (5)