Open In App

How Many Bits are Reserved for the TCP Flags?

Last Updated : 04 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Transmission Control Protocol  (TCP) is a transport layer protocol. TCP makes packet transmission from source to destination smoother. It is a connection-oriented and end-to-end protocol. Each data packet is wrapped in a header by TCP, which consists of 10 mandatory fields totaling 20 bytes and an optional data field of 0 to 40 bytes.

Here, we’ll look at the TCP header fields and bits required for these fields including flag bits in greater detail.  

TCP Header

TCP Header

1. Source Port(16 bits): This field identifies the port number of the Sender’s application program.

2. Destination Port(16 bits): This field identifies the port number of the Receiver’s application program.

3. Sequence Number(32 bits): After connection establishment(3-way handshaking), this field contains a 32-bit random initial sequence number/starting data bit which is subsequently incremented by the number of bytes transferred.

4. Acknowledgment Number(32 bits): The receiver uses this 32-bit parameter to request the next TCP segment. It’s the next predicted TCP segment’s sequence number.

5. Header length field(4 bits): This field indicates the size of the TCP header but in a scaled-down version.

6. Reserved bits(6 bits): The bits of this field are set to zero. These bits are reserved for later use.

7. Flag bits(6 bits): A grouping of six fields, each of which is one bit long. It can be used to control the flow of data in specific scenarios.

  1. URG flag (urgent flag): When this 1-bit value is set, the data is given precedence over other data.
  2. ACK flag (acknowledgment flag): This 1-bit field is used during connection establishment (3-way handshaking) and data transfer.
  3. PSH flag (push flag): This 1-bit field tells an application that the data should be sent immediately.
  4. RST flag (reset flag): To reset the TCP connection this 1-bit field is set.
  5. SYN flag (synchronization flag): This 1-bit flag is used to set the initial sequence number.
  6. FIN flag (the finish flag): This 1-bit field indicates the end of the TCP connection.

8. Window Size(16 bits): This parameter represents the buffer capacity at the receiver’s end. The size of the window is used to manage the flow of data.

9. Checksum(16 bits): The sender calculates a Cyclic Redundancy Check (CRC) checksum and adds it to this field before transmission of data to prevent errors in data. The checksum can be used by the receiving device to check for flaws in the received header and payload.

10. Urgent Pointer(16 bits): The urgent pointer points to the end of urgent data in the segment. However, this field appears only if the URG flag is set.

11. Options/optional data(0-40 Bytes): This field contains optional pieces of information such as Maximum Segment Size, Timestamp, Window size extension, Padding, etc.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads