Sub topic 1
Why IPv6 exists
IPv6 exists because the 32-bit address space of IPv4 ran out. This chapter explains how that shortage came about, how the industry worked around it, and what IPv6 changes besides making addresses longer. Later chapters cover the address format and how hosts get addresses.
Prerequisites
This chapter assumes you already know:
- How IPv4 addresses are written in dotted-decimal form, such as
192.0.2.10. - Binary and hexadecimal numbers, including that
nbits give2^nvalues. - CIDR prefix notation, such as
/24, and what a subnet mask does. - What routers, switches, and default gateways do on a network.
The problem: a 32-bit address space
An IPv4 address is 32 bits long, so there are 2^32 = 4,294,967,296 possible addresses. That sounded enormous when the protocol was standardized in 1981. Three things made it too small:
- Growth in devices. Each phone, laptop, server, and sensor that talks directly to the internet needs an address.
- Uneven allocation. Early allocations were made in classful blocks. A Class A block held about 16.7 million addresses and often went to a single organization that used a fraction of them.
- Reserved ranges. Loopback, private, multicast, and other special ranges are not usable as public unicast addresses. That leaves fewer than 4.29 billion public addresses.
The central pool kept by IANA (the Internet Assigned Numbers Authority) allocated its last blocks to the regional registries in February 2011. The regional registries then ran out of fresh space one after another. Today, new IPv4 space mostly comes from transfers between organizations and from leasing, and prices reflect the scarcity.
How IPv4 stretched
Two workarounds kept IPv4 usable long after the shortage began.
CIDR. Classless Inter-Domain Routing, introduced in the 1990s, replaced fixed class boundaries with variable-length prefixes. Allocations could match actual need, and routes could be aggregated into fewer routing table entries. CIDR slowed the exhaustion but could not prevent it.
NAT. Network Address Translation lets many hosts with private addresses (such as 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16) share one public address. The NAT device rewrites addresses and port numbers on outgoing packets and keeps a table so it can map replies back. Most home routers do this.
NAT has costs:
- State. The device must track every flow. If the entry expires or the device reboots, connections break.
- No inbound connections by default. An outside host cannot reach a private host unless the NAT device has a port-forwarding rule or the private host first opens a connection.
- Application workarounds. Protocols that carry addresses inside their payload, such as older FTP and SIP, need special helpers. Peer-to-peer applications and VoIP rely on techniques like STUN and relays to get through.
- Stacking. Internet providers now often use carrier-grade NAT (CGNAT) on the shared range
100.64.0.0/10. A customer can then sit behind two layers of NAT. Troubleshooting, logging, and port limits all get harder.
IPv6 removes the need for address sharing. Every device can have a globally unique address, so connections can be end-to-end again. Firewalls still decide what is allowed. Having a public address does not mean a host is reachable.
What IPv6 changes
Address size
An IPv6 address is 128 bits long. The following script puts the numbers side by side.
ipv4_total = 2 ** 32
ipv6_total = 2 ** 128
print(f"IPv4 addresses: {ipv4_total:,}")
print(f"IPv6 addresses: {ipv6_total:,}")
print(f"IPv6 / IPv4 ratio: {ipv6_total // ipv4_total:,}")
print(f"Addresses in one /64 subnet: {2 ** 64:,}")
print(f"One /64 equals the IPv4 space squared: {2 ** 64 == ipv4_total ** 2}")The output is:
IPv4 addresses: 4,294,967,296
IPv6 addresses: 340,282,366,920938,463,463,374,607,431,768,211,456The exact digits are not worth memorizing. Run the script yourself to see them. What matters is the scale. IPv6 has about 3.4 × 10^38 addresses, which is 2^96 times as many as IPv4. A single /64 subnet, the standard size for one local network, holds as many addresses as the entire IPv4 internet squared.
The size is not meant to let you number every grain of sand. It exists so that addresses can be assigned generously and in a structured way. Sites receive large blocks, every subnet gets the same fixed size, and routing prefixes can be aggregated. The design trades address efficiency for simplicity.
A simpler packet header
IPv4 headers are 20 to 60 bytes because of optional fields. IPv6 uses a fixed 40-byte base header, and rarely used features move into optional extension headers. Other differences:
- No header checksum. Link layers and transport protocols already check for errors. Routers no longer recompute a checksum at every hop.
- No router fragmentation. Only the sending host fragments packets. It uses Path MTU Discovery to learn the largest packet the path can carry. Every IPv6 link must support an MTU of at least 1280 bytes.
- Flow label. A 20-bit field lets routers recognize packets belonging to the same flow.
Fewer special cases on the local network
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address length | 32 bits | 128 bits |
| Notation | Dotted decimal | Hexadecimal groups separated by colons |
| Broadcast | Yes | No, replaced by multicast |
| Resolving a neighbor's link-layer address | ARP | Neighbor Discovery Protocol (NDP) |
| Automatic configuration | DHCP, or link-local `169.254.0.0/16` as a fallback | SLAAC, DHCPv6, or both, with link-local addresses always present |
| Header | 20 to 60 bytes, with checksum | 40 bytes, no checksum |
| Fragmentation | Hosts and routers | Hosts only |
IPv6 removes broadcast. A message that once went to every host now goes to a multicast group, and only interested hosts process it. NDP, which runs on ICMPv6, handles neighbor discovery and router discovery. Hosts can also build their own addresses from a router's advertisement through SLAAC. Later chapters cover each of these.
Common misconceptions
- "IPv6 is just IPv4 with longer addresses." The address length is the headline change, but the header, local-network protocols, and configuration model differ too.
- "IPv6 is faster." It is not inherently faster. Removing CGNAT or avoiding translation can help in some paths, but results depend on the network.
- "IPv6 is more secure because IPsec is built in." IPsec was originally mandatory for IPv6, but that requirement was dropped. Support is common, and use is optional.
- "IPv6 can talk directly to IPv4." It cannot. The two protocols are not compatible on the wire. A host must have an IPv6 address, or use a translation or tunneling mechanism, to reach IPv6-only services. Coexistence is covered in a later chapter.
Exercise
Exercise
Give two drawbacks of NAT that IPv6 avoids, and explain why a 128-bit address makes it practical to avoid NAT.
Show answer
Any two of the following: NAT keeps per-flow state that breaks connections when it is lost; it blocks inbound connections unless port forwarding is configured; it breaks protocols that embed addresses in their payload; and stacked NAT (CGNAT) complicates troubleshooting and limits ports. A 128-bit address space (about 3.4 × 10^38 addresses) is large enough that every device can have its own globally unique address, so no address sharing is needed.
Exercise
How many times larger is the IPv6 address space than the IPv4 address space, expressed as a power of 2? How many addresses does a single /64 subnet contain?
Show answer
IPv6 is 2^96 times larger, since 2^128 / 2^32 = 2^96. A /64 subnet leaves 64 host bits, so it contains 2^64 = 18,446,744,073,709,551,616 addresses.