TCP Header
The TCP header is the control panel that makes the reliable byte stream of the last two lessons possible. It is exactly twenty bytes in its base form, and every field earns its place. Learn the layout, the bit widths, and how to read a real segment — the exam tests these details directly.
What the header must carry
A TCP segment is a header followed by a payload. The header has to answer four questions for the receiving stack: which application (ports), where in the byte stream (sequence number), what has been received (acknowledgment number), and how to manage the conversation (flags, window, checksum, options). Every field in the layout below exists to serve one of those jobs.
Which application?
Source and destination ports — 16 bits each.
Where in the stream?
Sequence and acknowledgment numbers — 32 bits each.
How to behave?
Data Offset, flags, window, checksum, urgent pointer, options.
The 32-bit word layout
TCP is defined in RFC 793. The header is drawn as rows of 32 bits; the field boundaries fall on bit positions as shown. The layout is decades old and unchanged at its core, so memorising it pays off in every packet-analysis question.
TCP Header (RFC 793) 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port | Destination Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data | |N|C|E|U|A|P|R|S|F| | | Offset| Resv |S|W|C|R|C|S|S|Y|I| Window | | (4) | (3) | |R|E|G|K|H|T|N|N| (16 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum | Urgent Pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options (if any, else start of Data) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The first four rows are 4 bytes each: ports and ports, then the 32-bit sequence number, then the 32-bit acknowledgment number. The fifth row packs the header-length nibble, the reserved bits, the flag bits, and the 16-bit window. The sixth row carries the checksum and the urgent pointer. After that comes the optional options area and finally the payload.
Field-by-field reference
Select any field in the explorer below to see its width, its size, and its job.
| Field | Bits | Bytes | Purpose |
|---|---|---|---|
| Source Port | 16 | 2 | Sender’s port; identifies the sending application or socket. |
| Destination Port | 16 | 2 | Receiver’s port; the service the segment is for (e.g. 443). |
| Sequence Number | 32 | 4 | Position of the first data byte in this segment (Lesson 5). |
| Acknowledgment Number | 32 | 4 | Next byte expected from the peer; valid only when ACK is set. |
| Data Offset | 4 | — | Header length in 32-bit words; minimum 5 (= 20 bytes). |
| Reserved | 3 | — | Unused; set to zero by the sender. |
| Flags (control bits) | 9 | — | NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN. |
| Window Size | 16 | 2 | Bytes the sender is willing to receive from the peer (flow control). |
| Checksum | 16 | 2 | Error check over header, data, and a pseudo-header. |
| Urgent Pointer | 16 | 2 | Offset to urgent data; meaningful only when URG is set. |
| Options | variable | 0–40 | Optional features such as MSS, window scale, SACK, timestamps; padded to a 32-bit boundary. |
| Data | variable | variable | The payload — the application’s bytes. |
5 means 5 × 4 = 20 bytes of header, i.e. no options. If Data Offset is 8, the header is 32 bytes, so 12 bytes of options are present. Data Offset is the only field that tells a receiver where the header ends and the data begins.
The nine flag bits
The control bits live in the two bytes at offsets 12 and 13. Zooming in on just those two bytes:
byte 12 (bits 96..103) byte 13 (bits 104..111) +-----------+-----------+--------+ +-----+-----+-----+-----+-----+-----+-----+-----+ | Data Off. | Reserved | NS | | CWR | ECE | URG | ACK | PSH | RST | SYN | FIN | | 4 bits | 3 bits | 1 bit | | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | +-----------+-----------+--------+ +-----+-----+-----+-----+-----+-----+-----+-----+ Control area total = 4 (Data Offset) + 3 (Reserved) + 1 (NS) + 8 = 16 bits. The nine flag bits are therefore: NS CWR ECE URG ACK PSH RST SYN FIN.
| Flag | Name | Meaning when set |
|---|---|---|
| NS | ECN-nonce | ECN-nonce concealment (RFC 3540); rarely used in practice. |
| CWR | Congestion Window Reduced | The sender lowered its rate in response to congestion signalling (RFC 3168). |
| ECE | ECN-Echo | The receiver is signalling congestion (or, during the handshake, that it supports ECN). |
| URG | Urgent | The Urgent Pointer field is significant. |
| ACK | Acknowledgment | The Acknowledgment Number field is valid. Set on every segment after the very first SYN. |
| PSH | Push | Deliver the data to the application immediately instead of buffering. |
| RST | Reset | Abort the connection immediately (Lesson 5). |
| SYN | Synchronize | Synchronise sequence numbers; opens a connection in the handshake. |
| FIN | Finish | The sender has finished sending data; closes one direction. |
Data Offset and options
Data Offset is a 4-bit number, so it can hold values 0–15. It counts 32-bit words, not bytes. Since the base header is five words, the minimum legal value is 5, giving 5 × 4 = 20 bytes. The maximum is 15, giving 15 × 4 = 60 bytes — so options may be at most 40 bytes. A value below 5 would be malformed and is dropped.
Options carry capabilities negotiated at the start of the connection. The best known is Maximum Segment Size (MSS), advertised in the SYN, which tells the peer the largest payload it should send. Others include Window Scale (multiplies the 16-bit window to allow very large receive windows) and SACK-Permitted for selective acknowledgment. Options are padded with zeros to the next 32-bit boundary so Data Offset stays a whole number of words.
Parsing a real header
Here is a practical example. A client at 10.0.0.10:52413 opens a connection to a web server at 203.0.113.5:80. The first segment is the client’s SYN; the second is the server’s reply, which has source port 80 and an ephemeral destination port, with the SYN and ACK flags set.
! Segment 1 - client to server (the initial SYN), values illustrative Source Port = 52413 (ephemeral, chosen by the client) Destination Port = 80 (HTTP) Sequence Number = 1001 (client ISN) Acknowledgment Number= 0 (not valid yet - ACK flag is clear) Data Offset = 8 (0x8 -> 32-byte header, 12 bytes of options) Flags = 0x02 (only SYN set) Window Size = 64240 (0xFAF0; client can receive 64240 bytes) Checksum = 0x1c2f Urgent Pointer = 0x0000 Options = MSS 1460, SACK permitted, Window Scale 7 ! Segment 2 - server to client (the SYN-ACK reply) Source Port = 80 (from the server's web service) Destination Port = 52413 (back to the client's ephemeral port) Sequence Number = 5001 (server ISN) Acknowledgment Number= 1002 (client ISN + 1; SYN consumed one number) Data Offset = 5 (20-byte header) Flags = 0x12 (ACK and SYN set: 0x10 + 0x02) Window Size = 65535 Checksum = 0x8a44 Urgent Pointer = 0x0000
Work through the flag byte. 0x12 is 0001 0010 in binary. Reading the bits from most significant to least significant as CWR, ECE, URG, ACK, PSH, RST, SYN, FIN gives 0001 0010 = ACK (0x10) plus SYN (0x02). That is exactly a SYN-ACK. A pure FIN would be 0x01; a FIN-ACK 0x11; a RST 0x04.
tcpdump and Wireshark you rarely see the raw bytes — you see a decoded line such as Flags [S.] or Flags [S], where S is SYN and . is ACK. The byte values above are what those tools are decoding for you.
Header sizes compared, and common pitfalls
Header overhead is a favourite comparison question. The TCP header is fixed at 20 bytes base; the IPv4 header is also 20 bytes base but may grow with options; the IPv6 header is a fixed 40 bytes with no options in the base header (extension headers follow instead).
| Protocol header | Base size | Notes |
|---|---|---|
| TCP | 20 bytes | Fixed base; up to 60 bytes with options. |
| UDP | 8 bytes | Fixed; no options (Lesson 7). |
| IPv4 | 20 bytes | Up to 60 bytes with options. |
| IPv6 | 40 bytes | Fixed base header; options move to extension headers. |
For a typical web segment with no TCP options, the transport overhead is 20 bytes. Over IPv6 that adds 40 bytes before the payload even begins, which is one reason IPv6 seeks large MSS values and avoids tiny packets.
Common pitfalls
- Confusing ports and addresses. Ports are 16-bit transport identifiers; IP addresses are network-layer fields. The TCP header contains no IP addresses.
- Reading Data Offset as bytes. It is in 32-bit words; multiply by 4 to get bytes.
- Forgetting the ACK validity rule. The Acknowledgment Number is only meaningful when the ACK flag is set.
- Thinking SYN/FIN carry data. They consume a sequence number but carry no payload.
- Saying the header is always 20 bytes. The base is 20; options can extend it to 60.
Key terms
| Term | Meaning |
|---|---|
| Base header | The minimum TCP header, 20 bytes, with no options. |
| Data Offset | 4-bit field giving the header length in 32-bit words; minimum value 5. |
| Reserved | 3 bits held at zero for future use. |
| Control bits / flags | The nine bits NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN. |
| Window Size | 16-bit receive window used for flow control. |
| Checksum | 16-bit error check over a pseudo-header, the TCP header, and the data. |
| Urgent Pointer | 16-bit pointer to urgent data; used only when URG is set. |
| Options | 0–40 bytes of optional fields (MSS, window scale, SACK, timestamps). |
Review
Check what you have learned with these review questions.
Sources & references
- Postel, J. RFC 793: Transmission Control Protocol (1981), Section 3.1 (Header Format). rfc-editor.org/rfc/rfc793.
- Ramakrishnan, K., Floyd, S. & Black, D. RFC 3168: The Addition of Explicit Congestion Notification (ECN) to IP (2001) — defines ECE and CWR. rfc-editor.org/rfc/rfc3168.
- Eddy, W. RFC 9293: Transmission Control Protocol (TCP) (2022) — the current consolidated TCP specification, Section 3.1. rfc-editor.org/rfc/rfc9293.
- IANA. Service Name and Transport Protocol Port Number Registry. iana.org.
- Cisco. CCNA (200-301) Exam Topics, TCP/IP transport. cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.