Skip to content

IPv6 - Headers

The IPv6 header structure is a key design improvement over IPv4. While an IPv6 address is four times larger than an IPv4 address, the basic IPv6 header is only twice the size of the IPv4 header (40 bytes fixed, compared to IPv4’s 20-byte fixed header plus options). IPv6 achieves this by moving optional and non-essential information to Extension Headers, which are only included when needed.

An IPv6 packet consists of a mandatory 40-byte Fixed Header and, optionally, one or more Extension Headers, followed by the Upper-Layer Payload (e.g., TCP or UDP segment).

The IPv6 fixed header contains essential information for routing and packet handling. It has the following fields:

A textual representation of the IPv6 fixed header fields and their sizes:

  • Version (4 bits): Always set to 6 (binary 0110) for IPv6.
  • Traffic Class (8 bits): Used for Quality of Service (QoS). The first 6 bits are for Differentiated Services Code Point (DSCP), and the last 2 bits are for Explicit Congestion Notification (ECN).
  • Flow Label (20 bits): Used to identify packets belonging to the same traffic flow, allowing routers to apply consistent handling (e.g., for QoS or load balancing) without deep packet inspection.
  • Payload Length (16 bits): Specifies the length of the IPv6 payload (Extension Headers + Upper-Layer Data) in bytes. With 16 bits, it can indicate up to 65,535 bytes. For larger payloads (jumbograms), this field is set to 0, and a Jumbo Payload option is used in a Hop-by-Hop Options extension header.
  • Next Header (8 bits): Identifies the type of header immediately following the IPv6 fixed header. This could be an Extension Header (e.g., value 44 for Fragment Header) or an upper-layer protocol (e.g., value 6 for TCP, 17 for UDP).
  • Hop Limit (8 bits): Similar to IPv4’s Time To Live (TTL). It is decremented by 1 by each router that forwards the packet. If the Hop Limit reaches 0, the packet is discarded to prevent indefinite looping.
  • Source Address (128 bits): The IPv6 address of the originating host.
  • Destination Address (128 bits): The IPv6 address of the intended recipient.

Extension Headers provide additional functionality and are placed between the fixed header and the upper-layer payload. Each EH has its own ‘Next Header’ field to point to the subsequent EH or the upper-layer protocol, forming a chain.

Common Extension Headers (with typical ‘Next Header’ values they use):

  • Hop-by-Hop Options Header (Next Header value 0): Carries options that must be examined by every node along the packet’s path. (Rarely used for general traffic due to performance impact on routers).
  • Routing Header (Next Header value 43): Used for source routing (specifying a path for the packet). Type 0 Routing Header (RH0) is deprecated due to security concerns.
  • Fragment Header (Next Header value 44): Used if the source needs to fragment a packet larger than the path MTU. IPv6 routers do not fragment packets in transit; fragmentation is handled by the source.
  • Destination Options Header (Next Header value 60): Carries options to be examined by the destination node(s). Can appear twice: once before a Routing Header (for intermediate destinations) and once before the upper-layer header (for the final destination).
  • Authentication Header (AH) (Next Header value 51): Part of IPsec, provides data integrity, authentication, and anti-replay protection for the IP packet.
  • Encapsulating Security Payload (ESP) Header (Next Header value 50): Part of IPsec, provides confidentiality (encryption), and optionally data integrity and authentication.

The recommended order of Extension Headers if multiple are present (as per RFC 8200):

  1. IPv6 Fixed Header
  2. Hop-by-Hop Options Header
  3. Destination Options Header (for options processed by intermediate destinations specified in a Routing Header)
  4. Routing Header
  5. Fragment Header
  6. Authentication Header (AH)
  7. Encapsulating Security Payload (ESP) Header
  8. Destination Options Header (for options processed only by the final destination)
  9. Upper-Layer Header (e.g., TCP, UDP)

The ‘Next Header’ field of the last EH points to the upper-layer protocol. If there are no EHs, the ‘Next Header’ field in the fixed header directly indicates the upper-layer protocol. A ‘Next Header’ value of 59 indicates ‘No Next Header’, meaning there is no payload data following that header.