Version Header Length Type of Service and Total Length Field in IPv4 Header

For Complete YouTube Video: Click Here

This class will understand Version Header Length Type of Service and Total Length Field in IPv4 Header.

The basic concepts related to the IPv4 address, like the minimum number of bytes and the maximum number of bytes that the IPv4 Header can accommodate, are discussed in our previous class.

Version Header Length Type of Service and Total Length Field in IPv4 Header

The image below is the IPV4 Header with all its fields.

IPv4 Header in Computer Networks
Version Header Length Type of Service and Total Length Field in IPv4 Header

We will discuss the fields in the first row of the IPv4 Header Version Header Length Type of Service and Total Length Field in IPv4 Header in this class.

Version

The version field can accommodate 4 bits. IP has six different types of versions, from IPv1 to IPv6. Among all of them, only IPv4 and IPv6 are in practical use.

In our course, we will discuss only IPv4.

IPv6 is out of the scope of this course.

Why do we need the version field?

Whenever the packet arrives at the receiver, based on the version field, the program of that particular field will get executed.

If the version 4 packet has arrived, the code to execute that Header or packed will get called.

Header Length

The Header Length field can accommodate only 4 bits.

These bits will let us know the number of bytes in the header.

We have discussed that header’s minimum, and maximum sizes are 20 Bytes and 60 Bytes.

With 4 bits, we can represent only the decimal numbers from 0 to 15.

The number of bytes is divided by four to address this, and the result is shown in 4 bits.

For example, we have a maximum header length of 60 Bytes.

60B/4 = 15.

The header length field will represent the binary equivalent of 15 [1111].

For example, if we have 22 Bytes in the header field, then 22/4 is 5.5.

How can we represent this in 4 bits?

We will add padding bits 0’s at the end so that the number of bytes is the multiple of 4.

In the above case, we add 16 padding bits or 2 bytes of 0’s at the end of the header.

Now 24/4 = 6.

The header length field will represent the binary equivalent of 6 [0110].

Type of Service

We will understand the type of service in our later classes whenever the context comes.

Total Length

The total length field represents the total number of bytes used in the IP packet, including the data and the header fields.

With 16 bits, we can accommodate a maximum of 65535 bytes of the packet.

The packet can accommodate a maximum of 65535 bytes of both data and header fields.