Every TCP segment consists of a 20 byte fixed format header. Header options may follow the fixed header. With a header so that it can tag up to 65535 data bytes.
The TCP header format is shown in the figure below −
It is a 16-bit source port number used by the receiver to reply.
It is a 16-bit destination port number.
The sequence number of the first data byte in this segment. During the SYN Control bit is set, and the sequence number is n, and the first data byte is n + 1.
If the ACK control bit is set, this field contains the next number that the receiver expects to receive.
The several 32-bit words in the TCP header shows from where the user data begins.
It is reserved for future use.
It indicates an urgent pointer field that data type is urgent or not.
It indicates that the acknowledgement field in a segment is significant, as discussed early.
The PUSH flag is set or reset according to a data type that is sent immediately or not.
It synchronizes the sequence number.
This indicates no more data from the sender.
It is used in Acknowledgement segment. It specifies the number of data bytes, beginning with the one indicated in the acknowledgement number field that the receiver is ready to accept.
It is used for error detection.
The IP datagram options provide additional punctuality. It can use several optional parameters between a TCP sender and receiver. It depends on the options used. The length of the field may vary in size, but it can't be larger than 40 bytes due to the header field's size, which is 4 bit.
The most typical option is the maximum segment size MASS option. A TCP receiver communicates to the TCP sender the total length of the segment it can accept with this option. The other various options are used for flow control and congestion control, each explained in the table shown in the table.
The table of options in TCP segment header is as follows −
| 0|| -|| End of option list|
| 1|| -|| No operation|
| 2|| 4|| Maximum segment size|
| 3|| 3|| Window Scale|
| 4|| 2|| Sack-permitted|
| 5|| X|| Sack|
| 8|| 10|| Time Stamps|
Options in each may vary in size, and it may be necessary to "pad" the TCP header with zeros so that the segment ends on a 32-bit word boundary as per the standard.
Although in some cases like acknowledgement segments with no data in the reverse direction, the variable-length field carries the application data from sender to receiver. This field, connected with the TCP header fields, constitute a TCP segment.