wire / wire-format / tcp-header
The TCP segment header is at least 20 bytes: source and destination ports, a 32-bit sequence number, a 32-bit acknowledgement number, a data-offset/flags word (including SYN/ACK/FIN/RST/PSH/URG), a 16-bit window, checksum, and urgent pointer, followed by optional options padded to a 32-bit boundary.
aka: TCP segment header · Transmission Control Protocol header
spec: RFC 9293
Fixed 20-byte header (plus options). Reliable, ordered, connection-oriented transport. The 4-bit Data Offset gives the header length in 32-bit words so a parser knows where options end and payload begins.
| field | size | meaning |
|---|---|---|
| Source Port | 16 bits | Sending port. |
| Destination Port | 16 bits | Receiving port. |
| Sequence Number | 32 bits | Byte-stream sequence number of the first data octet (or the ISN+1 if SYN set). |
| Acknowledgement Number | 32 bits | Next sequence number the sender expects, valid when the ACK flag is set. |
| Data Offset | 4 bits | Header length in 32-bit words (5 = 20 bytes minimum, up to 15 = 60 bytes with options). |
| Reserved | 4 bits | Must be zero (formerly part of a 6-bit reserved + flags layout). |
| Flags | 8 bits | CWR, ECE, URG, ACK, PSH, RST, SYN, FIN control bits. |
| Window | 16 bits | Receive window: bytes the sender of this segment is willing to accept (scaled by the Window Scale option if negotiated). |
| Checksum | 16 bits | Ones-complement checksum over the header, payload, and a pseudo-header. |
| Urgent Pointer | 16 bits | Offset of urgent data, valid when the URG flag is set. |
| Options | 0-320 bits | Optional, e.g. MSS, Window Scale, SACK-Permitted, Timestamps; padded with zeros to a 32-bit boundary. |
example:
01 BB C0 A8 ... (illustrative ports)
First two bytes 0x01BB = 443 as a destination port (HTTPS). Full segment parsing requires the IP header for length/pseudo-header checksum.
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/tcp-header
or /wire-format/tcp-header.json