TCP header diagram
The format of the TCP segment header is shown in Figure
above. The segment consists of a header of20 to 60 bytes, followed by data from
the application program.
The header is 20 bytes.
i.
Source port address: This is a 16-bit field that defines the port number of the
application program in the host that is sending the segment. This serves the
same purpose as the source port address in the UDP header.
ii.
Destination port address: This is a 16-bit field that defines the port number
of the application program in the host that is receiving the segment. This
serves the same purpose as the destination port address in the UDP header.
iii.
Sequence number: This 32-bit field defines the number assigned to the first
byte of data contained in this segment. TCP is a stream transport protocol. To
ensure connectivity, each byte to be transmitted is numbered. The sequence
number tells the destination which byte in this sequence is the first byte in
the segment. During connection establishment, each party uses a random number
generator to create an initial sequence number (ISN), which is usually
different in each direction.
iv.
Acknowledgment Number: This 32-bit field defines the byte number that the
receiver of the segment is expecting to receive from the other party. If the receiver
of the segment has successfully received byte number x from the other party, it
returns x+ 1 as the acknowledgment number. Acknowledgment and data can be piggybacked together.
v.
Header length: This 4-bit field indicates the number of 4-byte words in the TCP
header. The length of the header can be between 20 and 60 bytes. Therefore, the
value of this field is always between 5 and 15.
vi.
Reserved: This is a 6-bit field reserved for future use.
vii.
Control: This field defines 6 different control bits or flags as shown in
Figure2.One or more of these bits can be set at a time. These bits enable flow
control, connection establishment and termination, connection abortion, and the
mode of data transfer in TCP.
Figure 2. Control Segment
viii.
Window size: This field defines the window size of the sending TCP in bytes.
Length
of this field is 16 bits, which means that the maximum size of the window is
65,535 bytes. This value is normally referred to as the receiving window and is
determined by the receiver.
ix.
Checksum: This 16-bit field contains the checksum. However, the use of the
checksum in the UDP datagram is optional, whereas the use of the checksum for
TCP is mandatory. The same pseudo-header, serving the same purpose, is added to
the segment. For the TCP pseudo-header, the value for the protocol field is 6.
x.
Urgent pointer: This 16-bit field, which is valid only if the urgent flag is
set, is issued when the segment contains urgent data. It defines a value that must
be added to the sequence number to obtain the number of the last urgent byte in
the data section of the segment.
xi.
Options: There can be up to 40 bytes of optional information in the TCP header.
(Source:
https://www.ques10.com/p/18497/explain-tcp-segment-header-format-in-detail-1/)
· DO: this is the 4-bit data offset field, also known as the header length. It indicates the length of the TCP header so that we know where the actual data begins.
· RSV: these are 3 bits for the reserved field. They are unused and are always set to 0.
0 Comments