Open In App

Options Field in TCP Header

Last Updated : 08 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

TCP users communicate with each other by sending packets. The packet contains data and other information about the source and destination and other TCP variables. These details are stored in the TCP header which is the top part of the packet. When a data packet is transmitted via different network devices the header is processed every time and then the packet is further forwarded. The data is not altered while the packet is in transit but some details might get changed in the header like IP address and port number via passing through NAT devices.

TCP Header

TCP Header

After headers, there is an options field. The maximum size of the options field is 40 bytes. Its size is variable; keeps on changing packet to packet.

Importance of the Options Field:

When TCP was developed initially, the internet, memory, and technology were not so advanced and cheap. The basic headers were enough at that time for successful communication between two computer nodes. But as the internet became popular the old TCP started to become outdated and changes in headers were required to accommodate the available changes in the internet and memory. But once the TCP is so popular globally, it would be practically impossible to introduce new changes into it and deploy it on every device. So then how do TCP and the internet come out with the solution?

They left the options field just below the main headers into the packet. At the time the use of the options field was very limited but now every new change or optimization is implemented using this options field. Around 35 optimizations are implemented using this options field in the TCP header as of today. Since the kind variable is of 1-byte size, it can represent 256 numbers. Other than 35 optimizations, other values are reserved. This field is optional because it is used on very special occasions and isn’t used in every packet. Many optimizations use the options fields in the SYN packets and others use it when the network is congested.

Various Options:

Maximum Segment Size (MSS):

Kind = 2
Length = 4
MSS

The client tells about the packet size which it can accept from the server. This option field is used in the SYN packet when the client establishes a connection with the server.

“Kind=2” takes 1 bytes space, “length=4” takes 1-byte space and “MSS” takes 2-byte space. Thus, the total space consumed (length = 4) by the MSS option is 4 bytes.

Maximum Segment Size (MSS)

Maximum Segment Size (MSS)

Window Scaling:

Kind = 3
Length = 3
Window Scaling: shift.cnt

The “window size” field is 16 bits long and can represent the maximum value 216=65,536. The client can advertise its buffer up to 64KB using this “window size” field in the TCP header. Using the window scaling option, the client can tell the server its scaling factor, which gives the sender the capability to advertise its buffer size up to 230=1 GB. shift.cnt takes the values from 0-14. So, 16+14=30 is the maximum bits available to advertize the buffer size.

Window Scaling

Window Scaling

Selective ACK:

Kind=4
Length=2
SACK Permitted

Kind=5
Length= 8n
SACK

SACK informs the sender about multiple packets lost, so that sender can recover the loss asap. In the SYN packet sender tells the server that it supports the SACK option by using the “Sack permitted” option.

When there is the delivery of packets out of order at the receiver side, the receiver sends the SACK option telling about the lost packets. One block of SACK takes 8 bytes, so the size of the sack is the multiple of 8 bytes.

Selective ACK

Selective ACK

Timestamps:

Kind=8
Length=10
Timestamps

Kind and Length variables take 1 byte each. Timestamps have two parts: sending time and receiving time, each consuming 4 bytes. So, this option field occupies 10 bytes in total. 

Use of timestamps are: RTTM(Round Trip Time Measurement), PAWS( Protection against wrapped Sequence number)

Timestamps

Timestamps

TCP FastOpen:

Kind=34
Length=18
TCP Fast Open Cookie

The client first tells the server in the SYN packet that it supports TCP FastOpen. Then the server sends encrypted cookies in the SYN+ACK packet. The kind and length variable takes 2 bytes together. The cookie is of size 16 bytes. Thus, this option consumes 18 bytes in total. 

TFO avoids a 3-way-handshake each time the client request server for connection establishment. Using TFO client can directly send GET requests to the server.

TCP FastOpen

TCP FastOpen

NOP:

Kind=1

This option field is used between two options. This option tells the beginning of the next option field in the options field/block. This may or may not be used by the sender, so the receiver must be prepared to process the options with or without this NOP. It just consumes 1 byte of space and has no length or significant information unlike other options do.

NOP

NOP

End of the Options List:

Kind=0

This option is used at the end of the options list. The kind value is 0 but this is used at the end of all the options. This must be noted that it is used only once after all the options in the header are being listed, it doesn’t occur after every option, unlike NOP. If the header field is completely filled and occupied the maximum possible space available, then this option is not mandatory. If there is still some space available in the header, then this option is inserted explicitly but the sender highlights the end of the options list. 

End of the option list

End of the option list

Note that MSS, Window Scaling, and TCP FastOpen are used in SYN packet only. After that, they are never used. The remaining options (discussed in this article) might be used in any packet sent during the communication as per the requirement of their use.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads