TCP Message Format

Like any other Protocol TCP Message(segment)also have a Header and Data part.Header has various fields and each field has its own significance. TCP header follows following format.


TCP Header Format

TCP Header Format
Here we explain the usage of various field of header shown above.

Source Port(16 Bits): It tells on which port, message originating application is running. As we know, Port is nothing but an identifier(Number) to uniquely identify an application on a Host/Computer.

Destination Port(16 Bits): It tells for which application on destination host this message is intended. I.e Application running on given port shall use this TCP Packet/Segment.

Sequence Number (32 Bits): Sequence Number is used to align the packets in an order, if the considered segment is first segment (SYN) then sequence number is Initial Sequence Number (ISN) i.e fresh generated. First Data Octet shall identified by ISD+1. It is take up in detail as we go for connection establishment

Acknowledgment Number (32 Bits): This field is significant when ACK bit of control Bits is set. when set then this field shall contain the sequence number that is Receiver is expecting in "Sequence Number" of next Segment. Explained in Connection Establishment section.

Data Offset (4 Bits): This field contains the length of header considering 32 bits as a single word. in other word it shall tell from where data shall begin.

Reserved (6 Bits): Reserved for future use.

Control Bits (6 Bits): Usage of control bits shall be discussed in connection establishment.

URG: Urgent Pointer Flag bit
ACK: Acknowledgement Field flag bit
PSH: Push Function
RST: Rest the connection
SYN: Synchronize sequence numbers
FIN: No more data to be sent from sender

Window (16 Bits): The number of data octet a receiver is willing to accept. This is used in congestion control,when two hosts have different bandwidth etc. 


Checksum (16 Bits): Checksum is used for integrity of TCP segment. Checksum field contains 16-bit one complement of one compliment sum of all 16-bit words of Header and Data.

[Pseudo Header + TCP Header + TCP Data + Padding(If required)]

While calculating Checksum a Pseudo header is added but this Pseudo header is not sent over the network, If the total length is odd then Last byte is padded with zeros to make 16-bit word.

Total Length = Pseudo Header Length + TCP Header Length + TCP Data Length + Padding(If required)


Pseudo TCP Header

Pseudo Header Fields:

Source Address: Source host IP Address.
Destination Address: Destination Host IP Address
Zero: for Padding
Protocol (PTCL): (6 in HEx) This value is associated with IP protocol. IP Protocol have a value for all Protocol that is to be passed in Protocol field of the IPv4 header and the Next Header field of IPv6 header.
TCP Length: contains length of TCP Header and TCP Data. Doesn't contain Pseudo Header Length.

Urgent Pointer (16 bit): Urgent Pointer value is significant when URG flag is set in control flags. When set it tells, where urgent data shall end. Urgent data starts from first byte of TCP Data field. Urgent Data nothing but the data that to be acted upon with priority. Basically Urgent Pointer field contains the 16 bit Offset of first byte after Urgent data.

Option(Variable Length): This section is majorly used in extension of TCP.



Data: Data part contains the actual data to be used by remote application.




Your Comments /Suggestions and Questions are always welcome. We would try to clarify doubts with best of our knowledge. So feel free to put Questions.

1 comment: