TCP Segment Header
What is the TCP Segment Header?
The TCP segment header is a structured block of information at the start of every TCP segment.
It contains essential fields that help TCP manage reliable, ordered, and error-checked delivery of
data between devices.
Structure of a TCP Segment Header
A standard TCP header is at least 20 bytes long and may include extra options (up to 60 bytes
total). Here are the main fields:
Field Size (bits) Description
Source Port 16 Identifies the sending application on the source device
Destination Port 16 Identifies the receiving application on the destination device
Sequence Number 32 Number of the first byte in this segment; used for data ordering
Acknowledgment Number 32 Number of the next expected byte; used for confirming receipt
Data Offset 4 Header length in 32-bit words (tells where data begins)
Reserved 4 Reserved for future use (usually set to zero)
Flags 8 Control bits (URG, ACK, PSH, RST, SYN, FIN, CWR, ECE)
Window Size 16 Number of bytes the receiver is willing to accept (flow control)
Checksum 16 Error-checking for header, data, and pseudoheader
Urgent Pointer 16 Indicates the end of urgent data (if URG flag is set)
Options Variable Extra features like MSS, window scaling, timestamps, SACK, etc.
Key Fields Explained
Source/Destination Port: Allow multiple applications to use TCP on one device by assigning
a unique port number to each.
Sequence Number: Ensures that data arrives in order and helps detect missing data.
Acknowledgment Number: Confirms which data has been received successfully.
Flags: Each flag has a specific purpose:
URG: Urgent pointer field is valid.
ACK: Acknowledgment field is valid.
PSH: Push function—deliver data to the application immediately.
RST: Reset the connection (used to abort).
SYN: Synchronize sequence numbers (used to establish connections).
FIN: No more data from sender (used to close connections).
CWR/ECE: Used for congestion notification.
Window Size: Controls how much data can be sent before waiting for an acknowledgment,
helping with flow control.
Checksum: Validates the integrity of the header and data.
Options: Used for advanced features, such as:
Maximum Segment Size (MSS): Largest segment the sender can handle.
Window Scale: Allows larger window sizes for high-speed networks.
Timestamp: Helps with round-trip time measurement and sequence number wrapping.
Selective Acknowledgment (SACK): Lets the receiver inform the sender about received
data ranges, improving efficiency after packet loss.
Example: TCP Header in Practice
When a device sends data using TCP, it fills in these header fields, attaches the header to the
data, and sends the segment. The receiver reads the header to:
Identify the connection,
Reassemble data in the correct order,
Confirm receipt,
Handle flow and congestion control,
Detect and correct errors.
Summary:
The TCP segment header is the backbone of TCP’s reliability and efficiency. By carefully
managing connections, sequencing, acknowledgments, and error checking, it allows
applications to communicate over the Internet with confidence that their data will arrive correctly
and in order [1] .
[1] Unit-5-notes.pdf
⁂
1. Unit-5-notes.pdf