Skip to content
Related Articles

Related Articles

Options Field in IPv4 Header

View Discussion
Improve Article
Save Article
  • Last Updated : 08 Mar, 2022
View Discussion
Improve Article
Save Article

All IP datagrams must have the standard 20-byte header, which contains key information such as the source and destination address of the datagram, fragmentation control parameters, length information, and more. In addition to these invariable fields, the creators of IPv4 included the ability to add options that provide additional flexibility in how IP handles datagrams.

IPv4 Header format

IPv4 Header format

The IP datagram may contain zero, one, or more options, which makes the total length of the Options field in the IPv4 header variable. Each of the options can be either a single byte long, or multiple bytes in length, depending on how much information the option needs to convey. When more than one option is included they are just concatenated together and put into the Options field as a whole. All datagrams may not contain this field. This field is optional.

Options field in Ipv4 Header

Options field in Ipv4 Header

Options Field in IPv4 Header

Here are some functioning supported by this field:

1. Record Route:

Record Routing

Record Routing

If the packet is going and options record route is set then at router R1, IP address of router R1 say R1 will be recorded on the packet and at router R2, the IP address of router R2 says R2 will get recorded.

Therefore, by the time the destination D receives the packet, it will see that the packet has come through routers R1 and R2.

The maximum size of the Options field in the IPv4 header is 40 bytes and every IP address is 4 bytes. Therefore, the maximum number of  IP addresses that can be recorded on any IPv4 datagram when the record route option is set should be 10. But since in the Options field first 8 bits are reserved for option type and the next 8 bits are reserved for option length, we have 38 bytes left for the actual data field. So, in 38 bytes we can record a maximum of 9 IP addresses. 

Because of most of the security reasons this record route option is not allowed to be used by the users. Only the network administrator will use it for various purposes like network management and debugging, but an end-user will never be given control over it.

2. Source Routing

If the source does not want to follow pre-defined routing protocols, it can set its own routing protocols and paths. It can specify the route that packet has to take on the path we are sending the packet.

Strict Source Routing

Strict Source Routing

Here for one hop, destination IP address will become IP address of router R1 say R1, and for the next-hop destination, IP address will become IP address of router R2 say R2. Similarly, for the next-hop destination, the IP address will become the IP address of router R4 say R4 and for the next-hop destination, the IP address will be the IP address of destination D say D. This routing is called strict source routing.

The next source routing option is loose source routing in which we don’t have to specify the entire route. We should only specify that the packet should go to router R1 and we don’t care whether it goes to router R2 or R3. So, we will skip specifying the IP address of R2 or R3. And then we will specify the IP address of router R4 and destination D.

Loose Source Routing

Loose Source Routing

The network manager at Internet Service Provider will use loose source routing to check if a path is working or not or if they want to test a specific path. Otherwise, if you send a packet it would not always be guaranteed that it has taken a specified path. So, end users cannot use this option. Here, also a maximum of 9 IP addresses can be recorded on the datagram.

3. Padding

Padding is used to ensure that the IP packet header has a length that is a multiple of 32 bits. It is needed because of the varying length of the options field in the IP header. If one or more options are chosen from the Options field, and the number of bits used for them is not a multiple of 32, enough zero bits are added to “pad out” the header to a multiple of 32 bits (4 bytes). 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!