This site requires JavaScript for navigation. Please enable JavaScript for the best learning experience.
 

The Transmission Control Protocol (TCP) header is the first 24 bytes of a TCP segment that contains the parameters and state of an end-to-end TCP socket. The TCP header is used to track the state of communication between two TCP endpoints. Since TCP segments are inserted (encapsulated) in the payload of the IP packet the TCP header immediately follows the IP header during transmission. TCP does not need to keep track of which systems are communicating, it only needs to track which end to end sockets are currently open. Internet Protocol handles the logical addressing, routing and host-to-host connectivity.

TCP uses port numbers on each side of the connection to track the connection endpoints, state bits such as SYN, ACK, RST, FIN, sequence numbers and acknowledgement numbers to track the communication at each step in transmission.

An example of a TCP header is shown below.

TCP Packet Diagram

Source Port
(0 - 65535)

Destination Port
(0 - 65535)

Sequence Number
(0 - 4294967295)

Acknowledgement Number
(0 - 4294967295)

Data
Offset
Reserved U
R
G
A
C
K
P
S
H
R
S
T
S
Y
N
F
I
N
Window
Checksum
(CRC-Check)
Urgent Pointer
Options Padding
Data

 

TCP 'Packet' Field Bits Usage
Source Port

16

The TCP Source Port is the port number used by the computer sending the TCP segment and is usually a number above 1024 (but not always).
Destination Port

16

The TCP Destination Port is the port number used by the computer receiving the TCP packet and is usually a number below 1024 (but not always).
Sequence Number

32

Used for segmentation of application data into TCP segments and reassembling them on the other side.  The sequence number helps the TCP software on both sides keep track of how much data has been transferred and to put the data back into the correct order if it is received in the wrong order, and to request data when it has been lost in transit.
Data Offset

4

The TCP Data Offset indicates number of bytes into the TCP packet where data can be found Thus, it actually indicates the number of bytes in the TCP header and allows the receiver to jump directly to the data.
 Reserved

6

 
URG
Urgent Flag

1

 
ACK
Acknowledgement Flag

1

Used during 3-way handshake and data transfers.
PSH
Push Flag

1

Used for TCP push, which returns the buffer to the user application. Used primarilly in streaming.
RST
Reset Flag

1

Used to reset a TCP connection
SYN
Synchronize Flag

1

Used during 3-way handshake
FIN
End of data

1

Indicates end of the TCP session
Window

16

Number of octets in the TCP header
Checksum

16

A Cyclic Redundancy Check (CRC) checksum is calculated by the sender and added to this field before transmission. This field is used by the receiver to verify the integrity of the data in the TCP payload and rejects data that fails the CRC check.
Urgent Pointer

16

Points to the end of "urgent" data in the packet, but this field only exists if the URG flag is set.
Options

Varies

 
Padding

Varies

 
Data

Varies

This field contains a segment of data from the user application, such as part of an email or web page.

 

TCP Tutorials


Bookmark this page and SHARE:  

Search

Support InetDaemon.Com

Get Tutorials in your INBOX!

Free Training