---
title: "TCP header and its fields"
subject: "Computer Networks and Security"
chapter: 5
key: "semester_7/computer_networks_and_security:tcp-header-structure"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/tcp-header-structure
site: BCT Engineering
---

# TCP header and its fields

Computer Networks and Security · Chapter 5: Transport Layer

- Asked in: 2074 Asoj, 5 marks; 2070 Asar, 4 marks (asked 2 times)
- Video: [TCP Header Format || Transport Layer || Computer Networks || Transmission Control Protocol](https://www.youtube.com/watch?v=YB-k9F-NqxQ) — Sudhakar Atchala
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/tcp-header-structure
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-5

## Question

Explain the TCP protocol with its header (structure of the TCP header and the purpose of 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.

## Answer

**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)
```text
 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
| Field | Size | Purpose |
|---|---|---|
| Source port | 16 | Port of sending application |
| Destination port | 16 | Port of receiving application |
| Sequence number | 32 | Number of the first data byte in the segment |
| Acknowledgement number | 32 | Next byte expected by the receiver |
| HLEN (data offset) | 4 | Header length in 32-bit words (5 to 15) |
| Reserved | 6 | Future use |
| Flags | 6 | URG, ACK, PSH, RST, SYN, FIN |
| Window size | 16 | Receiver's available buffer (flow control) |
| Checksum | 16 | Error detection over header, data and pseudo-header |
| Urgent pointer | 16 | Offset of urgent data when URG is set |
| Options | up to 40 B | MSS, 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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What are the minimum and maximum TCP header sizes?
   A. 8 and 20 bytes
   B. 20 and 60 bytes
   C. 40 and 60 bytes
   D. 20 and 40 bytes
   Answer: B. The 20-byte base header can have up to 40 bytes of options. (Key point: Header size)

2. What does the TCP acknowledgement number contain?
   A. The receiver's window size
   B. The segment length
   C. The first byte of the current segment
   D. The next byte expected by the receiver
   Answer: D. ACK number gives the next byte the receiver expects. (Key point: Acknowledgement number)

3. What is the Window size field used for?
   A. Error detection
   B. Urgent data
   C. Flow control by advertising the receiver's free buffer
   D. Port selection
   Answer: C. It tells the sender how much data the receiver can accept. (Key point: Window size field)

4. Which flag opens and which closes a connection?
   A. RST opens, PSH closes
   B. ACK opens, URG closes
   C. FIN opens, SYN closes
   D. SYN opens, FIN closes
   Answer: D. SYN synchronises sequence numbers to open; FIN closes. (Key point: SYN and FIN flags)

5. What does the TCP checksum cover?
   A. Header only
   B. Header, data and pseudo-header
   C. Data only
   D. Pseudo-header only
   Answer: B. It is computed over the header, data and a pseudo-header. (Key point: Checksum coverage)

## Related in Computer Networks and Security

- [Compare IPv6/IPv4 headers; migration](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aipv6-ipv4-header-migration) — Computer Networks and Security, chapter 7, asked 2×
- [Why two transport protocols exist](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Awhy-two-transport-protocols) — Computer Networks and Security, chapter 5

## Related in other subjects

- [UNIX goals; NFS protocol and structure](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aunix-goals-nfs) — Operating System, chapter 5
- [SS7 protocol structure](https://www.bctengineer.com/question.md?key=semester_8%2Ftelecommunications%3Ass7-protocol-structure) — Telecommunications, chapter 5
- [Types and purpose of admixtures](https://www.bctengineer.com/question.md?key=semester_5%2Fconcrete_technology_and_masonry_structure%3Aadmixture-types-purpose) — Concrete Technology and Masonry Structure, chapter 1, asked 7×
- [Red-Black tree and its purpose](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Ared-black-tree) — Data Structure and Algorithm, chapter 6, asked 2×
