Differences between the IPv4 header and IPv6 header

This tutorial compares the IPv4 header with the IPv6 header. Learn the similarities and differences between the IPv4 header and the IPv6 header in detail.

There are two versions of IP protocol: IPv4 and IPv6. IPv6 is a streamlined version of IPv4. To meet the requirements of modern networks, the IPv4 header has been completely redesigned in IPv6. In this process, five rarely used fields have been removed from the header while two new fields have been added. The remaining areas have been optimized for better performance. In this tutorial, we will discuss these changes in detail.

For this tutorial, I assume that you are familiar with IPv4 and IPv6 headers. If you want to know what the IPv4 and IPv6 headers are and how they work in IP protocol, you can check the following tutorials.

IPv4 Header Structure and Fields Explained

IPv6 Header Structure Format and Fields Explained

The following image shows the format of the IPv4 header.

IPv4 header

The following image shows the format of the IPv6 header.

 IPv6 header

Let's discuss how each field of the IPv4 header is updated and structured in the IPv6 header.

Version

This field specifies the version of the header. The length of this field is 4 bits. In IPv4, the value of this field is always set to 4 while in IPv6, the value of this field is always set to 6. This is the only field that is completely unchanged in IPv6.

Internet Header Length (IHL)

The length of the IPv4 header is variable. It can be a minimum of 20 bytes and a maximum of 60 bytes. This field specifies the length of the IPv4 header in the number of 4-byte blocks. For example, if the value in this field is 5, then the length of the packet will be 5 x 4 = 20 bytes. Intermediate devices use this field to calculate the length of the packet.

The length of the IPv6 header is fixed. It is always 40 bytes. Since the IPv6 header is always a fixed length of 40 bytes, this field has been removed in the IPv6 header.

Types of services /Differentiated Services

In the original IPv4 specification (RFC 791), this field was defined to be used by intermediate routers to tag packets for different types of handling. In the original IPv6 specification, the definition of this field was retained but the name was changed to the Traffic Class field.

The definition of this field was updated in RFC 2474 for both headers. This specification renames this field to the Differentiated Services field and defines a new definition for this field. In the new definition, this field is used to specify how the packet should be treated by intermediate routers to provide it an appropriate QoS (Quality of Service).

After RFC 2474, the name, length, and definition of this field are the same in both headers.

Total length

This field specifies the total length of the packet in bytes. In the IPv6, this field has been replaced by the payload length field. The payload length field indicates the length of payload and extension headers. It does not include the length of the base header. Since the length of the base header is always 40 bytes in the IPv6 header, a device can easily calculate the total length of the packet.

Total length of the packet = base header (40 bytes) + payload length.

Identification, Flags, and Fragment offset

Fragmentation is used to send a large packet over a narrow bandwidth link. In the IPv4 header identification, flags, and fragment offset fields are used for fragmentation. In IPv6, all fragment-related options have been moved to the Fragment extension header. The Fragment extension header is optional. If fragmentation is required, this option is added to the header. If fragmentation is not required, this option is omitted.

Time-to-Live

This field is used to set the maximum number of links on which the packet can travel before being discarded. In IPv6, this field has been replaced by the Hop limit field. The length and functions are the same in both versions.

Protocol

In IPv4, this field specifies the upper-layer protocol that will receive the payload of the packet at the destination node. In IPv6, this field is replaced by the Next Header field. The length of this field is the same in both versions but the functions of this field are different.

In IPv4, this field specifies the upper-layer protocol that will receive the payload of the packet at the destination node whereas, in IPv6, this field specifies the first extension header. If no extension header is used, it specifies the upper-layer protocol. In other words, if no extension header is used, this field performs the same function as the protocol field.

Header checksum

This field provides a checksum on some fields in the IPv4 header. The sender device computes a checksum value and puts that value in this field. The intermediate devices also perform the same calculation and match the result with the value stored in this field. If the result and the value stored in this field are the same, the packet is considered good. If both are not the same, the packet is considered damaged. Damaged packets are discarded. This approach avoids the processing of damaged packets.

Since the link-layer also uses a checksum that performs bit-level error detection for the entire packet, this field has been removed in the IPv6 header to avoid double calculation and save CPU cycles needed in performing the checksum calculation.

Source address

This field specifies the IP address of the sender device. In IPv4, an IP address is 32 bits in length while in IPv6, the length of the IP address is 128 bits.

Destination address

This field specifies the IP address of the destination device. This field is the same in both headers except for the destination IP address length.

Options

This field allows the sender device to specify how the intermediate devices and the destination device should handle the packet. In IPv6, this field has been replaced by the extension header field.

Flow label

This field is newly added in the IPv6 header. It does not replace or update any IPv4 header field. It is used to identify packets that belong to the same flow. A flow is the sequence of packets that are exchanged between the source node and the destination node in a single session. To identify all packets of a flow, the source device sets the same value in all packets of the flow. The source device uses a unique value for each flow. Since each flow uses a unique value, the source device can exchange data in multiple flows simultaneously.

That's all for this tutorial. If you like this tutorial, please share it with friends via your favorite social networking sites and subscribe to our YouTube channel.

ComputerNetworkingNotes Networking Tutorials Differences between the IPv4 header and IPv6 header