Internet Protocol version 6
In our IPv4 Bunny Academy article, you learned that internet addresses have a lot in common with physical addresses and how mail works. However, IPv6 addresses don’t look like IPv4 addresses, and although IPv6 is based on IPv4, the two protocols are incompatible.
The use of IPv6 has increased since 2006, and it was ratified as an Internet Standard in 2017. IPv6 uses 128-bit addresses, which allow for roughly 2^128 unique addresses.
IPv6 packet structure
Like IPv4, the IPv6 packet consists of a header and a payload. The header’s fixed size of 40 bytes enables the protocol’s functionality. Also, the header can be extended to add functionality.
Figure 1: IPv6 packet header fields and relative field sizes.
The header always contains eight fields:
- Version: A 4-bit value that represents the version of the IP protocol.
- Traffic Class: An 8-bit value that describes the packet class or priority, which helps the router manage traffic and congestion.
- Flow Label: A 20-bit value that the source uses to label the packets belonging to the same flow for routing by intermediate routers. A flow is a group of packets, such as those in a TCP session or media stream.
- Payload Length: A 16-bit value representing the total size of the payload. It allows for a packet size of up to 65,535 bytes, which the jumbo payload header can extend to 4,294,967,295 bytes (4 GB).
- Next Header: An 8-bit value that indicates the type of extension header that follows, if present. It may also identify the protocol contained within the payload.
- Hop Limit: An 8-bit hop limit indicating the maximum number of nodes an IPv6 packet can traverse. Each time the packet is forwarded by a router, the hop limit decreases by one. If the value reaches zero, the router discards the packet. Similar to the time-to-live (TTL) field in IPv4 packets, the hop limit prevents infinite routing loops caused by errors or network issues.
- Source Address: A 128-bit IPv6 address of the packet’s source.
- Destination Address: A 128-bit IPv6 address representing the packet’s final destination.
Additionally, Extension Headers can extend the functionality of IPv6 for routing, fragmentation, security services, and increasing the maximum packet size. These headers are typically processed by the packet’s destination and rely on the Next Header field to indicate the type of the first extension header. The size of all extension headers is a multiple of 8 octets (where an octet equals 8 bits).
Future extension headers may be defined, but current examples include the following:
Extension header | Next Header field value | Description |
---|---|---|
Hop-by-Hop Options | 0 | Options that need to be examined by all devices on the path. |
Routing | 43 | Methods to specify the route for a packet (used with Mobile IPv6). |
Fragment | 44 | Contains parameters for fragmentation of packets. |
Authentication Header (AH) | 51 | Contains information used to verify the authenticity of most parts of the packet. |
Encapsulating Security Payload (ESP) | 50 | Carries encrypted data for secure communication. |
Destination Options (before upper-layer header) | 60 | Options that need to be examined only by the destination of the packet. |
Mobility (currently without upper-layer header) | 135 | Parameters used with Mobile IPv6. |
Host Identity Protocol | 139 | Used for Host Identity Protocol version 2 (HIPv2). |
Shim6 Protocol | 140 | Used for Shim6. |
Reserved | 253 | Used for experimentation and testing. |
Reserved | 254 | Used for experimentation and testing. |
Addressing
IPv6 addresses are represented as eight groups of 16 bits. Each group consists of 4 hexadecimal digits separated by colons (:
). For example, 2001:0db8:0000:0000:0000:ab00:0123:4567
. If you are unfamiliar with hexadecimal notation, it is a system of 16 numbers that uses the digits 0 through 9 and the letters A through F to represent the values 10 through 15.
Fun fact: nibbles aren’t just how bunnies eat. A nibble is a 4-bit chunk of data, perfectly representing a single hexadecimal digit.
IPv6 addresses can be shortened by omitting leading zeros in each group, and consecutive groups of zeros can be replaced with a double colon (::), but this can only be done once in an address. For example, 2001:db8::ab00:123:4567
.
Figure 2: IPv6 hexadecimal versus binary addressing.
Just like an IPv4 address, an IPv6 address is split into two halves. The most significant 64 bits serve as a network identifier, used for routing, while the least significant 64 bits serve as an interface identifier, which identifies the host. You can also subnet an IPv6 address. To do so, it is recommended to use the last quartet of the network identifier to create subnetworks.
The loopback address is defined as 0000:0000:0000:0000:0000:0000:0000:0001
and can be abbreviated to ::1
.
Because colons in Uniform Resource Locators (URLs) separate the host from the port number, IPv6 addresses that include colons must be enclosed in square brackets. For example: http://[2001:db8::ab00:123:4567]:8080/path/page.html
.
Address uniqueness and router solicitation
Link-local addresses are crucial for discovering Local Area Network (LAN) neighbors. When a host enables a new IPv6 interface, it generates a unique link-local address with the prefix fe80::/10
. To ensure the uniqueness of this IPv6 address within the LAN, the host sends a neighbor solicitation message, asking for the link-layer address of the given IP address.
If any other host in the LAN is using that address, it responds to the solicitation, prompting the first host to generate a new unique link-local address. This address is automatically assigned to the host’s interface without requiring communication with an external network entity.
IPv6 implements the Neighbor Discovery Protocol (NDP) at the link layer, which relies on Internet Control Message Protocol version 6 (ICMPv6) and multicast transmission. When a unique link-local address is successfully established, the host sends an ICMPv6 router solicitation message to the all-routers multicast group, using its link-local address as the source.
If a router is present on the network, it sends a router advertisement that includes the network configuration information necessary to establish a globally unique address with the correct unicast network prefix. The advertisement also contains two important flags:
1. Whether the host should use Dynamic Host Configuration Protocol (DHCP) to obtain additional addresses beyond the auto-generated one.
2. Whether the host should gather more information for subnets, such as the prefix lifetime, and whether to use direct on-link connections or create a global address.
Multicasting
IPv6 multicast addresses use the prefix ff00::/8
. IPv6 does not support broadcast addressing. However, using the multicast group address ff02::1
in a local network has the same effect.