An IPv6 packet has three parts: an IPv6 basic header, one or more IPv6 extension headers, and an upper-layer protocol data unit (PDU).
An upper-layer PDU is composed of the upper-layer protocol header and its payload, which maybe an ICMPv6 packet, a TCP packet, or a UDP packet.
An IPv6 basic header is fixed as 40 bytes long and has eight fields. Each IPv6 packet must have an IPv6 basic header that provides basic packet forwarding information, and which all devices parse on the forwarding path.
Figure 1 shows the IPv6 basic header.
Unlike the IPv4 packet header, the IPv6 packet header does not carry IHL, identifier, flag, fragment offset, header checksum, option, or padding fields, but it carries the flow label field. This facilitates IPv6 packet processing and improves processing efficiency. To support various options without changing the existing packet format, the Extension Header information field is added to the IPv6 packet header, improving flexibility. The following paragraphs describe IPv6 extension headers.
An IPv4 packet header has an optional field (Options), which includes security, timestamp, and record route options. The variable length of the Options field makes the IPv4 packet header length range from 20 bytes to 60 bytes. When devices forward IPv4 packets with the Options field, many resources need to be used. Therefore, these IPv4 packets are rarely used in practice.
To improve packet processing efficiency, IPv6 uses extension headers to replace the Options field in the IPv4 header. Extension headers are placed between the IPv6 basic header and upper-layer PDU. An IPv6 packet may carry zero or more extension headers. The sender of a packet adds one or more extension headers to the packet only when the sender requests the destination device or other devices to perform special handling. Unlike IPv4, IPv6 has variable-length extension headers, which are not limited to 40 bytes. This facilitates further extension. To improve extension header processing efficiency and transport protocol performance, IPv6 requires that the extension header length be an integer multiple of 8 bytes.
When multiple extension headers are used, the Next Header field of an extension header indicates the type of the next header following this extension header. As shown in Figure 2, the Next Header field in the IPv6 basic header indicates the type of the first extension header, and the Next Header field in the first extension header indicates the type of the next extension header. If there are no extension headers following the current one, the Next Header field indicates the upper-layer protocol type. Figure 2 shows the IPv6 extension header format.
RFC 2460 defines six IPv6 extension headers: Hop-by-Hop Options header, Destination Options header, Routing header, Fragment header, Authentication header, and Encapsulating Security Payload header.
Header Type |
Next Header Field Value |
Description |
---|---|---|
Hop-by-Hop Options header |
0 |
This header carries information that every node must examine along the delivery path of a packet. This header is used in the following applications:
|
Destination Options header |
60 |
This header carries information that only the destination node of a packet examines. Currently, this header is used in mobile IPv6. |
Routing header |
43 |
An IPv6 source node uses this header to specify the intermediate nodes that a packet must pass through on the way to its destination. This option is similar to the Loose Source and Record Route option in IPv4. |
Fragment header |
44 |
Like IPv4 packets, the length of IPv6 packets to be forwarded cannot exceed the maximum transmission unit (MTU). When the packet length exceeds the MTU, the packet needs to be fragmented. In IPv6, the Fragment header is used by an IPv6 source node to send a packet larger than the MTU. |
Authentication header |
51 |
IPSec uses this header to provide data origin authentication, data integrity check, and packet anti-replay functions. It also protects some fields in the IPv6 basic header. |
Encapsulating Security Payload header |
50 |
This header provides the same functions as the Authentication header plus IPv6 packet encryption. |
When a single packet uses more than one extension header, the headers must be listed in the following order:
IPv6 basic header
Hop-by-Hop Options header
Destination Options header
Routing header
Fragment header
Authentication header
Encapsulating Security Payload header
Destination Options header
Upper-layer header
Intermediate devices determine whether to process extension headers based on the Next Header field value in the IPv6 basic header. The intermediate devices do not need to examine or process all extension headers.
Each extension header can only occur once in an IPv6 packet, except for the Destination Options header which may occur twice (once before a Routing header and once before the upper-layer header).