Sub topic 1
Why IPv6 exists
Prerequisites
This chapter assumes you know basic IPv4 addressing and dotted-decimal notation. It also assumes you can read binary and hexadecimal numbers and understand CIDR prefix notation. You should know what routers, switches, and default gateways do.
The problem: IPv4 ran out
An IPv4 address is 32 bits long, so it allows 2^32 addresses, about 4.3 billion. That looked huge in the early 1980s. Today a single person may own a phone, a laptop, a TV, and several smart devices, and every one of them needs an address.
The regional registries that hand out address blocks have exhausted their free IPv4 pools. IANA, the central registry, gave out its last blocks in 2011. Networks that need more addresses now buy them or share the ones they have.
How IPv4 stretched
Operators used several workarounds to extend IPv4:
- CIDR replaced fixed address classes, so blocks could be sized more closely to need.
- Private ranges such as 10.0.0.0/8 let many networks reuse the same addresses internally.
- Network Address Translation (NAT) lets many private hosts share one public address by rewriting addresses and ports on the way out.
These measures worked, but they have costs. NAT breaks the end-to-end model, where any host can reach any other host directly. Peer-to-peer apps, VoIP, and inbound connections need extra tricks to work behind NAT. Carrier-grade NAT, which stacks a second layer of NAT inside the provider, makes this worse.
What IPv6 changes
IPv6 uses 128-bit addresses. That gives 2^128 addresses, about 3.4 × 10^38. The number is large enough that addresses stop being a scarce resource, and each device can have a globally unique address.
print(2 ** 32) # 4294967296
print(2 ** 128) # 340282366920938463463374607431768211456
print(2 ** 128 // 2 ** 32) # 79228162514264337593543950336IPv6 has about 7.9 × 10^28 times as many addresses as IPv4.
The larger space is the main reason for IPv6, but the protocol also changes other things:
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address length | 32 bits | 128 bits |
| Broadcast | Yes | No, replaced by multicast |
| Header | Variable length, with options | Fixed 40 bytes, with extension headers |
| Fragmentation | Routers and hosts | Sending host only |
| Address assignment | Manual or DHCP | SLAAC, DHCPv6, or manual |
| Checksum in IP header | Yes | No |
The simpler fixed header makes forwarding easier for routers. Built-in autoconfiguration lets a host build its own address without a server.
Where we are now
Adoption is uneven. Many mobile networks and large content providers run IPv6 widely, while some enterprise and home networks still use IPv4 only. Most networks today run both protocols at once.
The rest of this tutorial covers how IPv6 addresses are built, written, divided into subnets, and assigned to hosts.
Exercise
IPv4 has 2^32 addresses and IPv6 has 2^128. By what factor is the IPv6 space larger, and why does NAT become unnecessary for address conservation under IPv6?
Show answer
The IPv6 space is 2^128 / 2^32 = 2^96 times larger, about 7.9 × 10^28 times. With so many addresses, every device can have its own globally unique address, so hosts no longer need to share one public address through NAT.