14 min read

IPV6 — The Deep Dive

Archived from MediumRead original →

Internet Redefined

Recently, while I was reviewing the ns-3(network simulator)’s SixLoWPAN code base, I couldn't understand how packets are sent and received, what the multicast protocol is, or any other terminology.

This article will explain IPv6, the packet header, and its key concepts.

What is IPv6?

First, let me set the context: IPv6 is the most advanced yet most recent version of the Internet Protocol, the fundamental communication protocol enabling devices to identify and communicate across networks.

IPv6 was designed to conquer the limitations of IPv4, primarily the issue of IP address exhaustion.

Key Highlights of IPv6:

  • 128-bit Adress Space:- Unlike IPv4 which has 32 bits collectively for network and host bits, IPv6 has 128 bits which allows around 3.4*10³⁸ unique IP address — virtually limitless for future needs.
  • Hexadecimal Representation: IPv6 addresses are written in hexadecimal and separated by colons(e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334), making them more compact to read than binary.
  • Simplified Header Structure: IPv6 simplifies packet processing by reducing the number of header fields, enabling faster routing and improved performance.
  • Built-in Security: IPsec, a suite for securing IP communications, is an integral part of the IPv6 protocol stack.
  • No Need for NAT: Because of the large network address NAT(Network address translation) is not checked for IPv6, enabling true end-to-end communications.

Why IPv6 Matters

With the exponential growth of technologies, the need for Internet-supportive devices increases which leads also to increased demand for unique IP addresses, the internet protocol IPv4 has around~4.3a a billion unique addresses which is not sufficient. IPv6 provides the scale, flexibility, and efficiency required for the modern internet and beyond.

IPv6 Addressing

One of the deciding features of IPv6 is its vastly expanded addressing systems. With approximately 340 undecillion unique addresses — more than enough to assign an IP to every grain of sand on earth and we still have room to grow.

IPv6 Address Format

  • Written in hexadecimal, separated by colons.
  • Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Leading zeros in a group can be omitted: 2001:db8:85a3:0:0:8a2e:370:7334
  • One sequence of zero groups can be compressed using :::
     2001:db8:85a3::8a2e:370:7334

Types of IPv6 Addresses

  1. Unicast: Identifies a single unique interface. Packets sent to a unicast address are delivered to that one specific node.
  2. Multicast is the most important concept in IPv6 and was used most often. It delivers the packet to multiple destinations simultaneously(e.g., all routers in a network).
  3. Anycast: Assigned to multiple interfaces, send a packet to the closest one first, based on routing distance.

Special IPv6 Address Ranges

  • Link-local(fe80::/10):- This is an auto-assigned IP address, used for communication within the same local link. Not routable globally.
  • Global unicast(2000::/3):- Publicly routable address, which is equivalent to the public IPv4 addresses.
  • Unique local(fc00::/7):- Used within a site or organization. Similar to IPv4 private ranges.
  • Loopback(::1):- Refers to the host itself. Equivalent to 127.0.0.1 or localhost in IPv4.
  • Unspecified(::):- This represents the absence of an address that may be used during the initialization or DHCP requests.

IPv6 Header Format

This is the most important part which I am going to explain to you deeply because this is the place where things get interesting, if you are not a computer networks nerd then you can skip through this by understanding the basic part of it like the packet structure.e

So, IPv6 employs a streamlined design despite supporting addresses four times the size of IPv4. This 40-byte fixed-length header consists of 8 distinct fields, which enhance routing efficiency while reducing network processing complexity.

Structure of IPv6 Header Format

IPv6 Header Format

As mentioned before, IPv6 employs a standardized 40-byte header divided into 8 key fields. This fixed-length design makes packet processing straightforward for routers, improving overall network performance.

This structure drops unnecessary or rarely used options and fields in IPv4.

IPv6 Header Fields in Detail

The 40-byte IPv6 header consists of eight carefully designed fields, each serving specific functions essential for modern Internet communication.

Version Field (4 bits): The Version field identifies the IP version in use and is set to 6(represented as 0110 in binary) for IPv6 packets.

  • While this field serves a similar purpose to its IPv4 counterpart, it’s important to note that actual protocol identification typically occurs through the link-layer headers before the packet reaches another IP layer.
  • For example, Ethernet 2 uses the EtherType field(set to 0x86DD for IPv6) to identify the protocol before passing it to the appropriate layer.

Traffic Class Field (8 bits): The Traffic Class field enables the differentiation and the prioritization of packets based on their service requirements. This 8-bit field is divided into two main parts:

  • The most significant 6 bits from the Differentiated Services Code Point(DSCP), which has the job of informing routers about what services should be provided to the packet.
  • Followed by, the next 2 significant bits which are used for Explicit Congestion Notation(ECN), which is a network feature used to signal congestion without dropping packets. This makes sure that the transmission rate is modified according to the congestion.

Both of them in combination provide similar functionality to the Type of service in IPv4 and allow networks to prioritize latency-sensitive traffic like video and voice communications over less critical data such as email and web browsing.

Flow Label Field (20 bits):- The flow label field enables the identification of packets belonging to a specific data flow between source and destination that may require special handling by intermediate routers. This 20-bit field helps maintain the sequential flow of packets in a communication stream and assists in avoiding packet reordering issues.

For example, in normal routing without special handling, it is set to 0, while when used it may request specific needed treatment fromIPv6-compliantt routers, which is particularly valuable for prioritized delivery of real-time data such as voice and video streams.

It provides a quality of service depending on the bit value in modern networks.

Payload Length Field (16 bits): The payload length is a 16-bit indicator that specifies the length of the data following the IPv6 header, measured in bytes. This is used to notify the size of the packet to the source, routers, and destination.

As of the rule, the 16-bit field allows payloads up to 65535 bytes but for larger payloads, we can use IPv6’s extension header system.

Next Header Field (8 bits): The Next Header field serves as an 8-bit selector that identifies the type of header immediately following the IPv6 header.

Unlike IPv4’s fixed header format, IPv6 can carry zero, one, or multiple extension headers chained together, each identified by the Next Header field of the preceding header.

This approach simultaneously provides additional functionality, such as routing instructions, fragmentation information, authentications, and encryption, to be included only when needed, maintaining efficiency while providing extensibility.

If it is too complicated to digest let me tell you an example

Let's say we have a packet that has the following header

[IPv6 Header] → [Routing Header] → [TCP Header] → [Data]
  • The IPv6 header’s Next Header field says: “Routing Header”.
  • The Routing Header’s Next Header field says: “TCP”.
  • The TCP Header doesn’t need to specify Next Header because it’s the final protocol layer.

They work together like a linked list.

Hop Limit Field (8 bits): As we see the TTL(Time to Live) field in IPv4, we see the hop limit in IPv6, this is an 8-bit unsigned integer that prevents packets from circulating indefinitely in the network.

This value is decremented by 1 at each node that forwards the packet.

When a router receives a packet with a Hop Limit of zero or decreases it to zero during processing, it drops or discards it from the network to reduce congestion. However, if the Hop Limit is zero at the destination, the packet is processed as usual.

Source and Destination Address Fields (128 bits each): The Source and Destination Address fields are two 128-bit fields that contain the IPv6 address of the packet’s originator and intended recipient, respectively.

The dramatic expansion of IPv6 addresses approximately 10²⁹make it more advanced than IPv4 addresses. This 128-bit addressing scheme offers enough addresses to assign a unique identifier to virtually every device on the earth for the foreseeable future.

Common Extension Headers

As we studied earlier IPv6 helps in providing an in-depth Next-hop technology which makes it special as in the header itself you can provide the information needed for traversal.

  • Hop-by-Hop Options: Contains information that must be examined by every node along the packet’s delivery path.
  • Routing Header: This provides a list of intermediate nodes that the packet should follow to reach the destination
  • Fragment Header: This is used when packets need to be broken up so that they obey the rule of MTU(Maximum Transmission Unit).
  • Authentication Header: This provides integrity using the sequence number on the packet and authentication.
  • Encapsulation Security Payload Integrity: This provides privacy and data security.
  • Destination Options Header: This is the destination-specific header which is only examined and analyzed by the destination node.

Address Allocation and Configuration

The IPv6 addressing system is made future-proof with a carefully structured global allocation framework designed to ensure efficient routing while accommodating future growth.

At the apex of this hierarchy, the IANA manages the entire IPv6 address space, allocating large blocks to Regional Internet Registers(RIRs). These RIRs subsequently distribute smaller prefixes to Local Internet Registers(LIRs) and Internet Service Providers(ISPs), typically in /32 to /48 blocks, which then assign /56 to /64 subnets to end users.

Address Configuration Mechanisms

Stateless Address Autoconfiguration (SLAAC): SLAAC enables devices to self-configure IPv6 addresses without the involvement of centralized servers through Neighbor Discovery Protocol(NDP) interactions.

Working:- When a device connects to a network, it sends Router Solicitation (RS) messages, prompting the router to respond with a Router Advertisement (RA) message containing the network prefix and configuration parameters. Using the prefix and the Interface identifier, a device generates unique global addresses through either EUI-64 derivation or privacy extensions.

Stateful DHCPv6 Configuration: Similar to IPv4 DHCP, IPv6 also provides a central stateful configuration of address management. Administrators define address pools with specific ranges (e.g., 2001:db8::1000 to 2001:db8::2000) and prefix delegation options.

They are generally used in zero-touch configurations, for home and small business networks, and enabling plug-and-play functionality for IPv6.

Critical configuration constraints prohibit using addresses that begin with

  • FE80::/10(link-local)
  • FEC0::/10 (deprecated site-local)
  • FF00::/8 (multicast)
  • 2002::/16 (6to4 tunneling unless properly formatted)

These restrictions prevent misconfiguration scenarios that could disrupt network operations or cause addressing conflicts.

They are generally used in enterprise environments, and scenarios requiring IP tracking or reservations.

IPv6 Routing

Ipv6 routing protocols are designed to distribute and manage routing information efficiently across networks. We also maintain many logics of IPv4, including the new one, for various enhancements like scalability, security, and simplified management.

Routing Basics in IPv6

  • IPv6 routers forward packets based on prefixes, similar to IPv4 subnetting but on a larger scale (e.g., /64, /56, /48).
  • The longest prefix match still applies during route lookup.
  • Since there’s no NAT, routing is end-to-end, which makes paths cleaner and often faster.

Common IPv6 Routing Protocols

OSPFv3(Open Shortest Path First Version 3): It is a link-state protocol optimized for IPv6. It uses Dijkstra’s shortest path first algorithm to compute the most efficient routes.

OSPFv3 supports multiple address families, making it suitable for dual-stack environments where both IPv4 and IPv6 coexist.

RIPng(Routing Information Protocol Next Generation): RIPng is an updated version of RIP designed for IPv6 networks. It uses distance-vector algorithms to calculate the best path based on hop count.

It is simple but less scalable on complex networks due to limitations in handling complex topologies.

BGP4(Border Gateway Protocol version 4): BGPv4 is the primary protocol for intern-domain routing and supports IPv6 through extension. Instead of using the hop count logic it uses autonomous systems as metrics.

BGPv4 ensures efficient route aggregation and scalability across large networks.

Unique Features of IPv6 Routing

Neighbor Discovery Protocol(NDP): NDP replaces the use of ARP in IPv6, using ICMPv6 messages for functions like router discovery, address resolution, and reachability confirmation.

Multicast-based communication ensures efficient handling of link-layer addresses without relying on broadcast.

Simplified Packet Processing: IPv6 eliminates packet fragmentation at routers; endpoints handle this task instead. This reduces the router processing overhead.

Multicast Routing: Multicast is integral to IPv6, enabling efficient group communication without relying on broadcast methods.

Routing Prefixes

Ipv6 uses a CIDR-style prefix, you can get to know the IPv4 subnetting here., IPv6 notations are similar to IPv4 but with larger block sizes:

Structure of IPv6 Address

An IPv6 consists of three main parts:

  1. Routing Prefix: The leftmost bits used to show the routing decision, typically assigned by the Internet registries and ISPs/
  2. Subnet ID: Defines the internal topology of a site or network, typically occupying 16 bits.
  3. Interface ID: The remaining 64 bits uniquely identify a device on the network.

Common IPv6 Routing Prefixes

::/128 — This is an unspecified address that is used by the source address before a host learns its address.

::1/128—This is a loopback address used for listening to internal communications within a host. It is similar to localhost(127.0.0.1) in IPv4.

FE80::/10 — This is a link-local address used for communications that the network channels with a single link; not routable beyond the link.

2000::/3 — This is the global unicast address used for assigning globally unique addresses used for internet communications.

2002::/8— These are reserved for the multicast address and are used to identify multicast groups; only as destination addresses.

Routing Without NAT

Unlike IPv4, IPv6 eliminates the need for Network Address Translation (NAT), allowing for true end-to-end connectivity. This simplifies routing logic and allows features such as P2P communications, VOIP, and direct device management to function more smoothly.

IPv6 Transition Mechanisms

Despite the advantages, IPv6 can’t just replace IPv4 overnight. To enable a smooth migration, several transition principles are needed for sure. These allow IPv6 and IPv4 to coexist during the global switchover.

  1. Dual Stack: Devices must run both IPv4 and IPv6 simultaneously.
  2. Tunneling: Used when IPv6 systems are connected over IPv4-only network. It encapsulates IPv6 packets inside IPv4 packets to traverse the legacy infrastructure.

Security in IPv6

While IPv6 is being created security is the foremost thing which key thing kept in the mind , unlike IPv4 security was afterthought.

Built-in IPsec Support

One of the major standout work in IPv6 is that it was originally designed to require IPsec, a suite of protocols for securing IP communications.

  • Authentication Header(AH): Ensures the integrity and authenticity of the packets.
  • Encapsulating Security Payload(ESP): Privdes encryptuiion and authentication for data confidentiality.

Elimination of NAT and Its Impacts

Pros: Without NAT, end-to-end encryption model and connectivity preferences became more feasible, by oversimplifying security models and reduced configuration complexity.

Cons: NAT had the side effect of hiding the internal networks. Removing it exposes devices more directly to the internet.

Larger Attack Surface

As we know that no one is perfect, everyone has vulnerability — you just have to find it and exploit it
— Elliot Alderson

Similarly as new components get introducedin IPv6, the exploits in it gets increased if not configured properly:

  • Router Advertisement (RA) Spoofing: Attackers can trick hosts into thinking they’re the default gateway.
  • Extension Header Abuse: IPv6 extension headers can be misused to evade intrusion detection systems.
  • SLAAC-based Attacks: Autoconfiguration can be manipulated by rogue devices.

Conclusion

So wrapping this up we upgraded to IPv6 not because of IP addresses are worn out totally,but also its necessary evolution made the internet foundations. With the massive address space, streamlined packet structure, and built in support for modern networking demands made the internet secure and adaptable to each and everyone in this world.

Maybe not all legacy supports IPv6 but one day we see each device more or less supports IPv6, we can see the results from this graph.

IPv6 Adaptation

This graph shows the potential of IPv6 in real.