Skip to main content

TCP header and its fields

Short answer

TCP is a connection-oriented, reliable, byte-stream transport protocol. Its header (20–60 bytes) contains source/destination ports, 32-bit sequence and acknowledgement numbers for ordering/reliability, flags (SYN, FIN, ACK etc.), window size for flow control, checksum, and optional MSS.

Explain the TCP protocol with its header (structure of the TCP header and the purpose of its fields).

TCP is a connection-oriented, reliable, byte-stream transport protocol (RFC 793). It provides full-duplex communication, sequence numbering, acknowledgements, retransmission, flow control (sliding window), congestion control and error checking. Data from the application is divided into segments; each segment has a TCP header followed by data.

TCP header (20 bytes minimum, 60 maximum)

 0              15 16             31
+-----------------+-----------------+
| Source port     | Destination port|
+-----------------+-----------------+
|        Sequence number (32)       |
+-----------------------------------+
|     Acknowledgement number (32)   |
+------+-----+------+---------------+
| HLEN | Rsv | Flags| Window size   |
+------+-----+------+---------------+
| Checksum        | Urgent pointer  |
+-----------------+-----------------+
|   Options (0-40 bytes) + padding  |
+-----------------------------------+
|              Data                 |
+-----------------------------------+

Fields

FieldSizePurpose
Source port16Port of sending application
Destination port16Port of receiving application
Sequence number32Number of the first data byte in the segment
Acknowledgement number32Next byte expected by the receiver
HLEN (data offset)4Header length in 32-bit words (5 to 15)
Reserved6Future use
Flags6URG, ACK, PSH, RST, SYN, FIN
Window size16Receiver's available buffer (flow control)
Checksum16Error detection over header, data and pseudo-header
Urgent pointer16Offset of urgent data when URG is set
Optionsup to 40 BMSS, window scale, timestamps, SACK

Flags

  • URG: urgent pointer is valid. ACK: acknowledgement number is valid. PSH: deliver data to the application immediately.
  • RST: reset the connection. SYN: open a connection (synchronise sequence numbers). FIN: close the connection.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Networks and Security chapter 5 questions →