1. Gyanastra
  2. Computer Networks
  3. TCP
  4. TCP Header Format and Field Sizes
Free lesson, no account needed 5 min read 27 practice questions after it
Asked in past papers2 times
  • GATE CSE2018
  • UGC NET2014

Computer Networks · TCP

TCP Header Format and Field Sizes

Overview

Every TCP segment consists of a TCP header followed by data, just as an IP packet has an IP header plus data. The header is a fixed-layout structure whose fields have defined sizes, giving a minimum length of 20 bytes and a maximum of 60 bytes.

Key concepts

  • TCP header layout: a fixed sequence of fields, each with a defined size in bits, except the Options field, which is measured in bytes.
  • Source Port: 16-bit field identifying the sending port.
  • Destination Port: 16-bit field identifying the receiving port.
  • Sequence Number: 32-bit field.
  • Acknowledgement Number: 32-bit field — distinct from the 1-bit ACK flag.
  • Header Length: 4-bit field.
  • Reserved: 6-bit field, not used and normally all zeros.
  • Flags: six flags of 1 bit each — URG (Urgent), ACK (Acknowledgement), PSH (Push), RST (Reset), SYN (Synchronization), FIN (Finish).
  • Advertisement Window / Window Size: 16-bit field used for flow control.
  • Checksum: 16-bit field.
  • Urgent Pointer: 16-bit field.
  • Options: 0 to 40 bytes — the only field measured in bytes.

How it works

The header fields appear in this order, with sizes in bits unless stated otherwise:

  1. Source Port — 16 bits
  2. Destination Port — 16 bits
  3. Sequence Number — 32 bits
  4. Acknowledgement Number — 32 bits
  5. Header Length — 4 bits
  6. Reserved — 6 bits
  7. Flags — 1 bit each: URG, ACK, PSH, RST, SYN, FIN
  8. Advertisement Window / Window Size — 16 bits
  9. Checksum — 16 bits
  10. Urgent Pointer — 16 bits
  11. Options — 0 to 40 bytes

Formulas

  • Fixed header size in bits =16+16+32+32+4+6+6+16+16+16=160 bits=20 bytes= 16 + 16 + 32 + 32 + 4 + 6 + 6 + 16 + 16 + 16 = 160 \text{ bits} = 20 \text{ bytes}

  • Options size =0 to 40 bytes= 0 \text{ to } 40 \text{ bytes}

  • Minimum TCP header length =20 bytes= 20 \text{ bytes}

  • Maximum TCP header length =20+40=60 bytes= 20 + 40 = 60 \text{ bytes}

  • TCP Header Field Layout

  • Shows the fixed order of TCP header fields with their sizes, from Source Port through the optional Options field.

Worked examples

Computing minimum and maximum header length:

  • Each row of the header diagram is 32 bits = 4 bytes.
  • The first 5 rows are always present: 5×4=205 \times 4 = 20 bytes, so the minimum header length is 20 bytes.
  • If Options are used, they can be at most 40 bytes.
  • Maximum header length =20+40=60= 20 + 40 = 60 bytes.

Comparison

FieldSizeUnit
Source Port16bits
Destination Port16bits
Sequence Number32bits
Acknowledgement Number32bits
Header Length4bits
Reserved6bits
URG, ACK, PSH, RST, SYN, FIN1 eachbit
Window Size16bits
Checksum16bits
Urgent Pointer16bits
Options0 to 40bytes

Revision summary

  • TCP header = fixed 20-byte base + optional Options field (0–40 bytes).
  • Minimum header size is 20 bytes; maximum header size is 60 bytes.
  • All fields are specified in bits except Options, which is in bytes.
  • Each of the six flags (URG, ACK, PSH, RST, SYN, FIN) is exactly 1 bit.
  • Do not confuse the Acknowledgement Number (32-bit field) with the ACK flag (1-bit field), or the Sequence Number (32-bit field) with the SYN flag (1-bit field).
  • The Window Size field is used for flow control.
  • Reserved bits are unused and are normally zero.

Previous-year exam insights

  • The 4-bit Header Length / Data Offset field gives the TCP header length in 32-bit words, so actual header bytes = field value × 4;
    legal values are 5 through 15, corresponding to 20 through 60 bytes.
  • TCP does not include IPv4 header fields such as source/destination IP address, fragment offset, total length, TTL, or protocol; those belong to the IP header.
    Asked inUGC NET 2014
  • The TCP checksum is computed over a pseudo-header containing source IP, destination IP, zero, protocol, and TCP length, plus the TCP header and data.
  • TCP options are padded with zero bytes to a 32-bit boundary, and the 40-byte maximum for Options includes padding.
  • The Acknowledgement Number is valid only when the ACK flag is set and gives the next byte expected; the Sequence Number gives the first data byte, with SYN and FIN each consuming one sequence number.
  • The 16-bit Window Size allows at most 65535 bytes per window without scaling; the Window Scale option can increase the effective window.
Pages 1–2 of 2