IPv6 Header Structure Format and Fields Explained

This tutorial explains the structure, format, and fields of the IPv6 header. Learn what extension headers are in IPv6 and how they are used.

The IPv6 header is a streamlined version of the IPv4 header. It provides new features while retaining the core concepts that made IPv4 popular. It eliminates the fields that are rarely used, improves the remaining fields, and adds an additional field to provide better support for real-time traffic. In this tutorial, we will discuss these changes in detail along with the structure and format of the IPv6 header.

To learn about the IPv4 header and its fields in detail, you can check the following tutorial.

IPv4 Header Structure and Fields Explained

The IPv6 header structure

The following image shows the basic structure of the IPv6 header.

structure of IPv6 header

Version

This field defines the version of the packet. In IPv6, the value of this field is set to 6. The size of this field is 4 bits.

Traffic class

This field defines how the packet should be handled through the intermediate devices. This field replaces the IPv4 type of service or differentiated services field. The size of this field is 8 bits. Same as the IPv4, the first 6 bits are defined as the DSCP field and the last 2 bits are defined as ECN. DSCP and ECN are respectively documented in RFC 2474 and RFC 3168.

The DSCP field indicates the type or priority of the packet that the router should follow when making the routing or forwarding decision. If a router fails to forward a packet, it uses the ECN field of the packet to send an Explicit Congestion Notification back to the original sender.

Flow label

A flow is a sequence of packets that are exchanged between a source and destination in a single session. A source can exchange data in multiple sessions simultaneous. To identify the sequence and session of the packet, the flow label field is used. In addition to identifying the packet's sequence and session, this field is also used to specify how the packet should be handled by intermediate routers.

The size of this field is 20 bits. For default router handling, the value of this field is set to 0. Intermediate routers use the packet's source address, a destination address, and flow label to distinguish between different flows.

Payload length

This field specifies the total length of the payload in bytes. This length includes the length of extension headers.

The size of this field is 16 bits. With 16 bits, this field can indicate a payload of up to 65535 bytes in length. A payload greater than 65535 bytes is known as a jumbo payload. IPv6 supports the jumbo payload. For the jumbo payload, the value of this field is set to 0 and the jumbo payload option is used in the Hop-by-Hop options extension header.

Since the base IPv6 header is fixed in length, a router can easily calculate the total length of the packet by adding the payload length and the base header length.

Next header

This field indicates the type of the first extension header. If an extension header is not present, it specifies the protocol in the upper-layer PDU. Protocols are identified with standard 8 bits values defined by IANA. If both an extension header and the upper-layer protocol are not available, the value 59 is used in this field. The size of this field is 8 bits.

The following lists the common next header values and their meanings.

Value Protocol header, or option
0 Hop-by-Hop Options header
6 TCP
17 UDP
41 Encapsulated IPv6 header
43 Routing header
44 Fragment header
50 Encapsulating Security Payload header
51 Authentication header
58 ICMPv6
59 No next header
60 Destination Options header

Hop limit

This field sets the lifetime of the packet. Every time a router forwards a packet, it decrements the value of this field by 1. If the value reaches zero, the packet is discarded. The size of this field is 8 bits.

Source IP Address

This field specifies the IPv6 address of the sender of the packet.

Destination IP Address

This field indicates the IPv6 address of the intended recipient(s) of this packet.

Extension headers

This is a new concept introduced in IPv6. In this concept, rarely used IP options are made optional and a new field called extension header is defined to add optional headers. The extension header field not only optimizes the rarely used options of IPv4 but also allows developers to define new options without modifying the structure of the IPv6 header. Any new option can easily be added to the extension header field.

Instead of adding all options, the sender node can select the required options and add them to the extension header field. Intermediate routers also do not need to process all options in the extension header. They can skip the options that are not intended for them. Options in this field are referred to as extension headers. Extension headers are added between the base header and the transport-layer header in a packet.

Let's discuss the most common options or extension headers.

Hop-by-Hop options header

If used, this header always appears on the first position in the field. This header contains two options that every intermediate router must examine and process. These options are the Jumbo payload option and the Router alert option.

The jumbo payload option is used to send a packet that contains a payload longer than 65535 bytes. If this option is enabled, it indicates that the packet contains the jumbo payload. Not all routers support the jumbo payload. If an intermediate router cannot forward a packet that contains the jumbo payload, it discards the packet and sends an ICMPv6 error message to the sender.

The router alert option is used to instruct intermediate routers that information inside the packet is intended to be viewed and processed by them even though the packet is addressed to some other node.

Routing header

The routing header is used to send the packet to the destination through a specific route. This option allows the sender device to specify multiple destination addresses in a list. The initial destination of the packet is not the same as the final destination of the packet, but rather the first address in the list contained in the Routing header. When the destination node which address is set in the first place of the list receives the packet, it resends the packet to the next node which address is set in the second place of the list. This process continues until the packet reaches its final destination.

Fragment header

Fragmentation allows a sender device to send a large packet in multiple smaller packets. In IPv4, fragment-related options are part of the main header. In IPv6, these options are moved to the fragment header. These options are a fragment offset, more fragments flag, and identification for the fragment.

Destination Options Header

This header contains options and information for the destination node. Currently, only padding options are specified for this header. Padding options are used to fill out the header on a 64 bits boundary.

Authentication Header

This header is used to calculate a cryptographic checksum on some parts of the IPv6 base header, extension headers, and payload.

Encapsulating Security Payload Header

This header indicates that the payload is encrypted. If the payload is encrypted it also includes enough information for the authorized destination node to decrypt it. If used, this header will always be the last in the extension header.

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 IPv6 Header Structure Format and Fields Explained