The transmission Control protocol is connection-oriented protocol, and it ensures the proper delivery of data. To be a reliable protocol, it uses some extra data fields. This field is known as TCP Header.
Whenever data is received to the transport layer, a header is attached to the data, which includes some important information that helps TCP work in a way that delivers data end to end without any losses. TCP header ranges from 20 bytes to 60 bytes.
Let us discuss each TCP Header Field-
TCP Header Fields: Explained
It is a 16-bit field that indicates the port number of the sending device where the data originates It is a randomly assigned field.
This field indicates the port number on the receiving device where the data should be delivered. It is 16 bits field
TCP converts data into bytes and the collection of bytes is known as segment. Each TCP segment is assigned a sequence number, which helps the receiving end to reassemble the data in the correct order. It is a 32-bit value.
In TCP, data transmission is acknowledged to ensure reliability. This field contains the sequence number that the receiving device expects to receive next. Acknowledgment no is always an incremental value i.e., if the sequence number is x, than Acknowledgment no is set to x+1.
This field determines the size of the TCP header. It is necessary to locate the start of the data payload. It is a 4 bits field.
These bits are reserved and are currently set to zero.
Control Bits (Flags)
It is also called flags or TCP flags which are used to control and manage aspects of TCP connection and data transmission.
Some common flags include:
1. URG (Urgent)
This bit can be 0 or 1. When this bit is 1, it implies that the data should be treated as a priority. For example, data is always sent in a seq. but we have some urgent data bits that should be sent first. In that case, the Urgent bit is set ON for that particular data, and that data is sent first.
2. ACK (Acknowledgment)
Indicates whether the acknowledgment number field is valid or not. If ACK is 1 it implies that the acknowledgment number is valid and if ACK is 0, it means that the segment is missing acknowledgment.
3. PSH (Push)
In general, applications collect a certain number of data and then process it. When the Push flag is set ON, it tells the application to transmit the data immediately and not wait for data to stack to fill the entire TCP segment.
4. RST (Reset)
Resets the connection. If it is set to 1, the connection is abruptly reset.
5. SYN (Synchronize)
Initiates a connection and synchronizes sequence numbers. It is used in the 3-way handshake process.
6. FIN (Finish)
The fin flag is used to terminate the TCP connection. Whenever Host wants to end the connection with the receiving end, it sends data with FIN flag 1. Since TCP works in a full duplex mode, receiving end should also set its FIN flag as 1.
- Window Size: This field indicates the size of the receiving device’s receive window, which helps in flow control. It is a 16-bit field. It is used for flow control between the sender and receiver.
- Checksum: checksum is a 16-bit field numerical value calculated from the TCP header and data payload to detect errors during transmission.
- Urgent Pointer: If the URG flag is set, this field points to the last urgent data byte in the TCP segment i.e., it tells about the sequence number of the last urgent data byte. It is a 16 bit field.
- Options: This field is optional and can contain additional parameters or information related to the TCP connection.