
IPv4 and IPv6
In today's highly connected digital world, IP addresses are like the "house numbers" of the internet. Every device connected to the internet needs a unique identifier. Since the early 1980s, IPv4 (Internet Protocol version 4) has been the foundation of internet communication.
However, with the explosive growth in the number of internet devices, the problem of IPv4 address exhaustion has become increasingly serious. This has led to the creation and development of IPv6 (Internet Protocol version 6).
This article will start with the basics and systematically introduce the technical features, differences, and transition mechanisms of IPv4 and IPv6. It aims to help university students with some computer background fully understand these two key network protocols.
IPv4 uses 32-bit binary addresses, usually shown in dotted decimal notation, for example: 192.168.1.1
Address Structure Analysis:
- 32-bit addresses are divided into 4 groups of 8 bits (octets).
- Each octet has a value range from 0 to 255 (00000000 to 11111111 in binary).
- There are about 4.3 billion possible addresses in total (2^32 = 4,294,967,296).
Initially, IPv4 addresses were divided into 5 classes:
| Class | Address Range | Network Part | Host Part | Use |
|---|---|---|---|---|
| A | 1.0.0.0 - 126.255.255.255 | 8 bits | 24 bits | Large Networks |
| B | 128.0.0.0 - 191.255.255.255 | 16 bits | 16 bits | Medium Networks |
| C | 192.0.0.0 - 223.255.255.255 | 24 bits | 8 bits | Small Networks |
| D | 224.0.0.0 - 239.255.255.255 | - | - | Multicast |
| E | 240.0.0.0 - 255.255.255.255 | - | - | Experimental |
Subnetting is a technique introduced to use the address space more efficiently. It uses a subnet mask (like 255.255.255.0) to divide an IP address into a network part and a host part.
Example: Calculating the number of usable hosts for the network 192.168.1.0/24
- Network Address: 192.168.1.0
- Broadcast Address: 192.168.1.255
- Usable Host Addresses: 192.168.1.1 - 192.168.1.254 (254 addresses in total)
- Address Exhaustion: 4.3 billion addresses are not enough for all the devices in the world.
- Reliance on NAT: Network Address Translation helps with the address shortage but breaks the end-to-end principle.
- Complex Configuration: Often requires manual setup; low automation.
- Insufficient Security: IPSec support is optional and not widely used.
- Quality of Service: Limited support for real-time applications.
IPv6 uses 128-bit addresses, which creates a vastly larger address space (about 3.4×10^38 addresses).
Representation Method:
- Shown in hexadecimal, with each 16-bit block as one group, making 8 groups in total.
- Groups are separated by colons.
- Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Simplification Rules:
- Leading zeros in a group can be omitted: 2001:db8:85a3:0:0:8a2e:370:7334
- Consecutive groups of all zeros can be replaced with "::" (only once per address): 2001:db8:85a3::8a2e:370:7334
IPv6 defines three basic address types:
Unicast Address: Identifies a single interface.
- Global Unicast Address (like IPv4 public addresses).
- Link-Local Address (starts with fe80::/10).
- Unique Local Address (starts with fc00::/7).
Multicast Address: Identifies a group of interfaces.
- Replaces IPv4 broadcasting and is more efficient.
- Format: starts with ff00::/8.
Anycast Address: Identifies a group of interfaces, but data is sent to the nearest one.
- Assigned from the unicast address space.
- Used for load balancing and redundancy.
- Huge Address Space: Enough to give an address to every grain of sand on Earth.
- Simplified Header Format: Fixed 40-byte header improves routing efficiency.
- Auto-configuration: Stateless Address Auto-configuration (SLAAC).
- Built-in Security: IPSec is mandatory.
- Better QoS Support: Flow Label field helps real-time applications.
- Mobility Support: Better experience with Mobile IP.
IPv4 Header (Usually 20 bytes, up to 60 bytes):
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options (if IHL > 5) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+IPv6 Header (Fixed 40 bytes):
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class | Flow Label |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Payload Length | Next Header | Hop Limit |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Source Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Destination Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Feature | IPv4 | IPv6 |
|---|---|---|
| Address Length | 32 bits | 128 bits |
| Number of Addresses | ~4.3 billion | ~3.4×10^38 |
| Address Notation | Dotted Decimal | Colon-Separated Hex |
| Header Length | Variable (20-60 bytes) | Fixed 40 bytes |
| Header Checksum | Yes | No (relies on higher layers) |
| Fragmentation | By routers and hosts | By source host only |
| Configuration | Manual / DHCP | Auto-config (SLAAC) / DHCPv6 |
| Security | IPSec Optional | IPSec Mandatory |
| QoS Support | Type of Service field | Flow Label field |
| Broadcast | Supported | Replaced by Multicast |
The simplest transition method. Devices run both IPv4 and IPv6 protocol stacks at the same time.
Configuration Example (Cisco router):
interface GigabitEthernet0/0
ip address 192.168.1.1 255.255.255.0
ipv6 address 2001:db8:1::1/64
ipv6 enableEncapsulates IPv6 packets within IPv4 packets to connect IPv6 "islands" over an IPv4 network.
Common Tunnel Types:
- Manually Configured Tunnels
- 6to4 Tunnels (automatic)
- Teredo Tunnels (through NAT devices)
6to4 Tunnel Example: Sending an IPv6 packet to 2001:db8:1::1 over an IPv4 network via 192.0.2.1:
IPv6 Header | IPv6 Payload
↓ Encapsulation
IPv4 Header(Protocol 41) | IPv6 Header | IPv6 PayloadNAT64/DNS64: Allows IPv6-only clients to access IPv4-only servers.
- NAT64: Translates between IPv6 and IPv4 addresses.
- DNS64: Synthesizes AAAA records (IPv6) from A records (IPv4).
The transition from IPv4 to IPv6 is a major milestone in the history of the internet. Although the transition is taking longer than expected, the adoption of IPv6 is now unstoppable.