A capture full of unfamiliar fields
You open a packet capture to find out why a web page will not load. Each TCP segment shows a list of fields: flags, sequence numbers, a window size and more. To read the capture, you need to know what each field means. The good news is that there are only about a dozen.
20 to 60 bytes in front of the data
Every TCP segment starts with a header: a block of control information in front of the data. It is at least 20 bytes and at most 60 bytes, depending on how many options it carries. The diagram shows it in rows of 32 bits (4 bytes), the way the standards (RFCs) draw it.
Read each row from left to right. The ruler gives bit positions 0–31 within that row; field sizes are labelled in bits or bytes.
The job of each field
Imagine PC-1 sends a data segment with source port 52000, destination port 443, sequence number 1001 and 500 bytes of payload. The ports identify the application endpoints; SEQ 1001 says where the first byte belongs. If the ACK field is 5001 and the ACK flag is set, that number refers to the other direction: PC-1 expects byte 5001 from the server next.
SEQ describes this direction's byte stream; ACK reports progress in the opposite direction. The window field is also a statement by the sender of this header about its receiving space, not a measured network speed. An ACK-only segment can carry useful control information even when it has no application payload.
| Field | Size | Job |
|---|---|---|
| Source / destination port | 16 bits each | Which application sent the segment and which one should receive it |
| Sequence number | 32 bits | The number of the first data byte in this segment |
| Acknowledgement number | 32 bits | The next byte the sender of this segment expects to receive (valid when ACK is set) |
| Data offset | 4 bits | Header length in 4-byte words: 5 means 20 bytes, 15 means 60 |
| Flags | 8 bits | On/off bits that show what kind of segment this is |
| Window | 16 bits | How many more bytes the sender of this segment can receive right now |
| Checksum | 16 bits | Detects damaged headers or data; a damaged segment is discarded |
| Urgent pointer | 16 bits | Marks urgent data when URG is set; rarely used today |
| Options | 0–40 bytes | Extras such as MSS, window scaling, SACK and timestamps |
SYN, ACK, FIN, RST and the other flags
A flag is a single bit that is either on (1) or off (0). You will see these six classic flags most often:
| Flag | Meaning | Seen in |
|---|---|---|
| SYN | Synchronise: “I want to start a connection; here is my first sequence number” | The first two handshake messages |
| ACK | The acknowledgement number is valid | Almost every segment after the first SYN |
| FIN | Finish: “I have no more data to send” | Closing a connection |
| RST | Reset: “stop now; this connection is not valid” | Refused or broken connections |
| PSH | Push: requests delivery without waiting for more data; does not mark an application message boundary | Data segments |
| URG | The urgent pointer field is valid | Rare |
The other two flags, CWR and ECE, are used by Explicit Congestion Notification (ECN), a way for routers to warn about congestion without dropping packets.
When reading a capture of a failed connection, the flags are usually the first thing worth checking. A SYN with no reply points at something dropping traffic on the way; a SYN answered by RST means the host, or a firewall acting for it, refused a connection to that port.
Device key: Client (laptop)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- Client: 192.168.1.20:52000
- Server: 203.0.113.10:443
- 1. Opening: only SYN is set. The acknowledgement number is not used yet.
- 2. Reply: SYN and ACK are both set: the server starts its side of the connection and acknowledges the client's SYN.
- 3. Data: a normal data segment has ACK set, often with PSH.
- 4. Closing: FIN says this side has finished sending.
Why TCP needs 20 bytes and UDP only 8
Each feature of TCP needs a field. Reliable delivery needs sequence and acknowledgement numbers. Flow control needs the window. Setting up and closing a connection needs the flags. That is why the TCP header is at least 20 bytes, while the UDP header, which offers almost none of these features, is only 8 bytes. The options area has let TCP gain new features over the years without changing the fixed part.
A SYN segment decoded by a capture tool
A packet capture tool such as Wireshark decodes the header for you. Below is the first segment of a connection (a SYN). It is an example written for this lesson, not captured from a real network.
Transmission Control Protocol, Src Port: 52000, Dst Port: 443
Source Port: 52000
Destination Port: 443
Sequence Number (raw): 1520031250
Acknowledgment Number (raw): 0
1010 .... = Header Length: 40 bytes (10)
Flags: 0x002 (SYN)
Window: 64240
Checksum: 0x5c1a
Urgent Pointer: 0
Options: (20 bytes), Maximum segment size, SACK permitted,
Timestamps, No-Operation (NOP), Window scaleTest yourself on the TCP header
In a capture, the data offset field of a TCP segment is 5. How long is its TCP header?
A capture shows a connection that ends suddenly, with no orderly closing exchange. Which flag was most likely in the last segment?
A receiver's buffer is almost full and it wants the sender to slow down. Which header field does it use to say how much more data it can accept?
Technical references
RFC 9293: base TCP header, connection state, sequence space and delivery.