Week 8 · Lesson 6

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.

CCNA 200-301 Domain 1.4 Transport Verified 2026-10-11
Part 1

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.

Definition — base header The TCP base header is 20 bytes (five 32-bit words) with no options. Adding the Options field can extend it up to 60 bytes total. The minimum-size TCP segment is therefore 20 bytes of header with zero data.

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.

Part 2

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.

32-bit word byte offset Source Port (16) Destination Port (16) 0 – 3 Sequence Number (32) 4 – 7 Acknowledgment Number (32) 8 – 11 Data Offset (4) | Flags (9) + Reserved (3) Window Size (16) 12 – 15 Checksum (16) Urgent Pointer (16) 16 – 19 Options (variable, 0 – 40 bytes) 20 – ... Data (variable) ... base header = words 0–4 = 20 bytes
Part 3

Field-by-field reference

Select any field in the explorer below to see its width, its size, and its job.

TCP header explorer · select a field
The base header · bytes 0 to 19, then options and data

Source Port

FieldBitsBytesPurpose
Source Port162Sender’s port; identifies the sending application or socket.
Destination Port162Receiver’s port; the service the segment is for (e.g. 443).
Sequence Number324Position of the first data byte in this segment (Lesson 5).
Acknowledgment Number324Next byte expected from the peer; valid only when ACK is set.
Data Offset4—Header length in 32-bit words; minimum 5 (= 20 bytes).
Reserved3—Unused; set to zero by the sender.
Flags (control bits)9—NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN.
Window Size162Bytes the sender is willing to receive from the peer (flow control).
Checksum162Error check over header, data, and a pseudo-header.
Urgent Pointer162Offset to urgent data; meaningful only when URG is set.
Optionsvariable0–40Optional features such as MSS, window scale, SACK, timestamps; padded to a 32-bit boundary.
DatavariablevariableThe payload — the application’s bytes.
Exam tip The base header is 20 bytes. Data Offset of 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.
Part 4

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.
FlagNameMeaning when set
NSECN-nonceECN-nonce concealment (RFC 3540); rarely used in practice.
CWRCongestion Window ReducedThe sender lowered its rate in response to congestion signalling (RFC 3168).
ECEECN-EchoThe receiver is signalling congestion (or, during the handshake, that it supports ECN).
URGUrgentThe Urgent Pointer field is significant.
ACKAcknowledgmentThe Acknowledgment Number field is valid. Set on every segment after the very first SYN.
PSHPushDeliver the data to the application immediately instead of buffering.
RSTResetAbort the connection immediately (Lesson 5).
SYNSynchronizeSynchronise sequence numbers; opens a connection in the handshake.
FINFinishThe sender has finished sending data; closes one direction.
Historical note RFC 793 defined only six flag bits (URG, ACK, PSH, RST, SYN, FIN) with six reserved bits. ECE and CWR were later carved out of the reserved space for explicit congestion notification (RFC 3168), and NS for ECN-nonce (RFC 3540). Modern implementations treat the field as three reserved bits plus nine control bits.
Flag byte decoder · type a hex value

Part 5

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.

Data Offset calculator · move the slider

Part 6

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.

Reading tip In 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.
Part 7

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 headerBase sizeNotes
TCP20 bytesFixed base; up to 60 bytes with options.
UDP8 bytesFixed; no options (Lesson 7).
IPv420 bytesUp to 60 bytes with options.
IPv640 bytesFixed 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.

Header overhead compared · bytes on the wire

Common pitfalls

Key terms

TermMeaning
Base headerThe minimum TCP header, 20 bytes, with no options.
Data Offset4-bit field giving the header length in 32-bit words; minimum value 5.
Reserved3 bits held at zero for future use.
Control bits / flagsThe nine bits NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN.
Window Size16-bit receive window used for flow control.
Checksum16-bit error check over a pseudo-header, the TCP header, and the data.
Urgent Pointer16-bit pointer to urgent data; used only when URG is set.
Options0–40 bytes of optional fields (MSS, window scale, SACK, timestamps).
Part 8 · Your turn

Review

Check what you have learned with these review questions.

Review · 6 questions

Sources

Sources & references

  1. Postel, J. RFC 793: Transmission Control Protocol (1981), Section 3.1 (Header Format). rfc-editor.org/rfc/rfc793.
  2. 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.
  3. Eddy, W. RFC 9293: Transmission Control Protocol (TCP) (2022) — the current consolidated TCP specification, Section 3.1. rfc-editor.org/rfc/rfc9293.
  4. IANA. Service Name and Transport Protocol Port Number Registry. iana.org.
  5. 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.