%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
graph TD
subgraph IPv6["IPv6 Address: 128 bits"]
P1["2001"]
P2["0db8"]
P3["85a3"]
P4["0000"]
P5["0000"]
P6["8a2e"]
P7["0370"]
P8["7334"]
end
Compressed["Compressed:<br/>2001:db8:85a3::8a2e:370:7334"]
P1 -.-> Compressed
P2 -.->|"Drop leading 0"| Compressed
P3 -.-> Compressed
P4 -.->|"::"| Compressed
P5 -.->|"Collapsed"| Compressed
P6 -.-> Compressed
P7 -.->|"Drop leading 0s"| Compressed
P8 -.-> Compressed
style P1 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style P2 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style P3 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style P4 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
style P5 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
style P6 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style P7 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style P8 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style Compressed fill:#2C3E50,stroke:#16A085,stroke-width:3px,color:#fff
609 IPv6 for IoT
609.1 Learning Objectives
By the end of this chapter, you will be able to:
- Explain IPv6 benefits: Understand why massive address space matters for IoT
- Interpret IPv6 addresses: Read and compress 128-bit hexadecimal addresses
- Apply 6LoWPAN compression: Understand header compression for constrained devices
- Choose addressing strategies: Select between global, unique-local, and link-local addresses
- Plan transition strategies: Design for IPv4/IPv6 coexistence
Core concept: IPv6 provides 340 undecillion addresses (2^128), enough for every IoT device to have a globally unique address without NAT.
Why it matters: IPv6 eliminates NAT traversal problems and enables direct end-to-end device connectivity.
Key takeaway: For Thread/Matter and 6LoWPAN protocols, IPv6 is mandatory - not optional.
609.2 Prerequisites
Before diving into this chapter, you should be familiar with:
- IPv4 Addressing Fundamentals: Understanding of 32-bit addressing
- Ports and NAT: Why NAT creates problems for IoT
The problem: IPv4 has only 4.3 billion addresses (2^32), but there are already 15+ billion IoT devices worldwide - and growing rapidly.
The solution: IPv6 has 340 undecillion addresses (2^128). Thatβs 340 followed by 36 zeros. Enough for every grain of sand on Earth to have billions of addresses.
What this means for IoT: - Every device can have a unique, globally routable address - No NAT needed - devices can connect directly - Protocols like Thread and Matter are built on IPv6
IPv6 addresses look different: 2001:db8:85a3::8a2e:370:7334 - Eight groups of 4 hex digits separated by colons - Can compress consecutive zeros with ::
609.3 Why IPv6 Matters for IoT
IPv4 Exhaustion Problem: - IPv4: 2^32 = ~4.3 billion addresses - Global population: ~8 billion people - IoT devices: 15+ billion (and growing) - Result: Not enough IPv4 addresses for every device
IPv6 Solution: - IPv6: 2^128 = 340 undecillion addresses - Enough for every device to have a globally unique address - No NAT required (every device can be directly addressable)
Decision context: When designing IP addressing for a new IoT deployment, you must choose between IPv4 (with NAT) or IPv6 addressing.
| Factor | IPv4 | IPv6 |
|---|---|---|
| Address Space | Limited (4.3 billion, exhausted) | Virtually unlimited (340 undecillion) |
| NAT Required | Yes (for internet access) | No (end-to-end connectivity) |
| Header Size | 20-60 bytes | 40 bytes (fixed) |
| Device Support | Universal (all devices) | Growing (most modern devices) |
| Configuration | Manual or DHCP | Auto-configuration (SLAAC) |
| Gateway Complexity | Higher (NAT translation) | Lower (direct routing) |
| Legacy Compatibility | Full | Requires dual-stack or tunneling |
Choose IPv4 when: - Deploying in brownfield environments with existing IPv4 infrastructure - Using legacy devices that lack IPv6 support - Network equipment or cloud services only support IPv4 - Simplicity is paramount and NAT overhead is acceptable
Choose IPv6 when: - Deploying large-scale IoT (thousands of devices needing unique addresses) - End-to-end connectivity is required (no NAT traversal issues) - Using 6LoWPAN/Thread/Matter protocols (IPv6 native) - Future-proofing the network for growth
Default recommendation: Use IPv6 for new greenfield IoT deployments, especially with 6LoWPAN-based protocols. Fall back to IPv4 only when legacy infrastructure or device compatibility requires it.
609.4 IPv6 Address Structure
An IPv6 address is 128 bits written as eight groups of four hexadecimal digits:
Full format: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Compressed format: 2001:db8:85a3::8a2e:370:7334
Compression rules: 1. Leading zeros in each group can be omitted: 0db8 β db8 2. Consecutive groups of zeros can be replaced with :: (once only): 0000:0000 β ::
{fig-alt=βIPv6 address compression showing full format (2001:0db8:85a3:0000:0000:8a2e:0370:7334) compressed to (2001:db8:85a3::8a2e:370:7334) by removing leading zeros and replacing consecutive zero groups with double colonβ}
609.5 IPv6 Address Types for IoT
| Type | Format | Scope | IoT Use Case |
|---|---|---|---|
| Global Unicast | 2000::/3 | Internet-routable | Cloud-connected sensors with unique IPs |
| Link-Local | fe80::/10 | Single network segment | Local device discovery, neighbor communication |
| Unique Local | fc00::/7 | Private networks | Internal IoT networks (like RFC 1918 for IPv4) |
| Multicast | ff00::/8 | Group communication | Firmware updates to device groups |
| Loopback | ::1 | Local device | Testing (equivalent to 127.0.0.1) |
Example IoT addressing scheme: - Global unicast: 2001:db8:1234:5678::sensor:100 (internet-facing gateway) - Unique local: fd12:3456:789a:1::sensor:100 (private sensor network) - Link-local: fe80::a2e:370:7334 (auto-configured on every interface)
609.6 IPv6 Benefits for IoT
- End-to-end connectivity: No NAT, direct device addressing
- Simplified network design: No private/public address translation
- Auto-configuration: Devices can self-assign addresses (SLAAC)
- Better security: IPsec is mandatory in IPv6 stack
- Efficient routing: Hierarchical addressing, better aggregation
- Multicast support: Efficient firmware distribution to device groups
609.7 6LoWPAN: IPv6 for Constrained Devices
Problem: Standard IPv6 packet with headers = 40 bytes (IPv6) + 8 bytes (UDP) = 48 bytes. IEEE 802.15.4 max payload = 127 bytes. Headers consume 38% of frame!
Solution: 6LoWPAN (IPv6 over Low-Power Wireless Personal Area Networks)
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
graph TD
IPv6["IPv6 Packet<br/>40 byte header<br/>+ 8 byte UDP<br/>= 48 bytes"]
subgraph Compression["6LoWPAN Compression"]
HC["Header Compression<br/>(LOWPAN_IPHC)"]
Frag["Fragmentation<br/>(if needed)"]
end
Result["Compressed Header<br/>2-8 bytes<br/>83-95% reduction!"]
Frame["802.15.4 Frame<br/>127 byte max payload"]
IPv6 --> HC
HC --> Frag
Frag --> Result
Result --> Frame
style IPv6 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
style HC fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style Frag fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style Result fill:#2C3E50,stroke:#16A085,stroke-width:3px,color:#fff
style Frame fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
{fig-alt=β6LoWPAN header compression showing IPv6 packet (48 bytes) compressed through LOWPAN_IPHC and fragmentation to 2-8 bytes (83-95% reduction) to fit in 802.15.4 frame (127 byte max)β}
6LoWPAN Compression Techniques:
- Header Compression (HC1/LOWPAN_IPHC)
- Omit IPv6 fields that can be inferred (version, traffic class, hop limit)
- Compress well-known UDP ports (61616 β 2 bits)
- Result: 40+8 bytes β 2-8 bytes (83-95% reduction)
- Fragmentation and Reassembly
- Split large IPv6 packets across multiple 802.15.4 frames
- Add fragmentation header (4-5 bytes)
- Mesh Routing
- Multi-hop routing under IPv6 layer
- Allows sensor networks to extend range
Example: Temperature sensor sending data: - IPv6 destination: 2001:db8::gateway:1 - Source: 2001:db8::sensor:42 - 6LoWPAN compresses to: 4 bytes (both addresses share prefix 2001:db8::) - Savings: 32 bytes (addresses alone) β 4 bytes = 87.5% reduction
609.8 Transition Strategies: IPv4 and IPv6 Coexistence
Dual Stack: Devices run both IPv4 and IPv6 simultaneously - Pro: Full compatibility with legacy and modern systems - Con: Requires more memory, processing
Tunneling: Encapsulate IPv6 packets in IPv4 (or vice versa) - 6to4, 6rd, Teredo tunnels - Used when one protocol must traverse network supporting only the other
Translation (NAT64/DNS64): Translate between IPv4 and IPv6 - IoT sensors use IPv6, cloud uses IPv4 - Gateway translates between protocols
609.9 Deep Dive: IPv6 Address Planning for Large-Scale IoT
Planning IPv6 addressing for large-scale IoT deployments requires a fundamentally different mindset than IPv4. With virtually unlimited addresses, the focus shifts from conservation to organization, aggregation, and operational simplicity.
609.9.1 Hierarchical Address Structure
A well-designed IPv6 addressing plan uses the 128-bit address space hierarchically:
Global Prefix (48 bits) Site/Building (16 bits) Subnet (16 bits) Interface ID (64 bits)
2001:db8:abcd :0001 :0100 :sensor-mac-derived
|__________________| |___| |___| |__________________|
From ISP/RIR Site ID Device Type SLAAC or EUI-64
Real-World Example: Smart City with 1 Million Sensors
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
graph TD
City["2001:db8:1234::/48<br/>City Allocation from ISP"]
D1T["2001:db8:1234:0001::/64<br/>District 1 - Traffic Sensors"]
D1E["2001:db8:1234:0002::/64<br/>District 1 - Environmental"]
D2["2001:db8:1234:0100::/56<br/>District 2 (256 subnets)"]
D2P["2001:db8:1234:0100::/64<br/>Parking Sensors"]
D2L["2001:db8:1234:0101::/64<br/>Lighting Control"]
D2R["2001:db8:1234:01ff::/64<br/>Reserved for Growth"]
IND["2001:db8:1234:1000::/52<br/>Industrial Zone (4,096 subnets)"]
FUT["2001:db8:1234:8000::/49<br/>Future Expansion (32,768 subnets)"]
City --> D1T
City --> D1E
City --> D2
City --> IND
City --> FUT
D2 --> D2P
D2 --> D2L
D2 --> D2R
style City fill:#2C3E50,stroke:#16A085,stroke-width:3px,color:#fff
style D1T fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style D1E fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
style D2 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
style D2P fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
style D2L fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
style D2R fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
style IND fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
style FUT fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
{fig-alt=βIPv6 hierarchical address planning diagram for smart city deployment. City-wide /48 allocation branches to District 1 traffic and environmental sensors (/64 each), District 2 with nested parking, lighting, and reserved subnets (/56 containing /64s), Industrial zone with 4,096 subnets (/52), and Future expansion with 32,768 subnets (/49).β}
609.9.2 Subnet Sizing Recommendations
| Deployment Type | Recommended Prefix | Subnets Available | Devices per Subnet |
|---|---|---|---|
| Single floor/zone | /64 | 1 | 18 quintillion (unlimited) |
| Building | /56 | 256 | Each /64 unlimited |
| Campus | /52 | 4,096 | Each /64 unlimited |
| City district | /48 | 65,536 | Each /64 unlimited |
| Enterprise | /44 | 1 million+ | Each /64 unlimited |
Key insight: Always use /64 for individual subnets. This is mandated by SLAAC and simplifies neighbor discovery. Never use longer prefixes (/65 or smaller) for device networks.
609.9.3 Interface Identifier Strategies
Option 1: Modified EUI-64 (Traditional)
MAC: AA:BB:CC:DD:EE:FF
Step 1: Insert FFFE β AA:BB:CC:FF:FE:DD:EE:FF
Step 2: Flip 7th bit β A8:BB:CC:FF:FE:DD:EE:FF
Interface ID: A8BB:CCFF:FEDD:EEFF
Full address: 2001:db8:1234:0001:a8bb:ccff:fedd:eeff
Option 2: Stable Semantically Opaque (RFC 7217) - Recommended - Generates stable but unpredictable interface IDs - Prevents address scanning attacks - Same address on same network, different on different networks - Linux: enabled by net.ipv6.conf.all.addr_gen_mode=3
Option 3: Temporary Addresses (RFC 8981) - Privacy extensions for mobile devices - Rotating addresses prevent tracking - Not suitable for servers or sensors (address changes)
609.10 Exercise: IPv6 Address Compression
Challenge: Compress the following IPv6 addresses using proper notation rules:
2001:0db8:0000:0000:0000:0000:0000:0001fe80:0000:0000:0000:a2e0:0370:7334:00002001:0db8:85a3:0000:0000:8a2e:0370:7334
Solutions:
2001:db8::1- Remove leading zeros: 0db8 β db8
- Replace consecutive zeros with
:::0000:0000:0000:0000:0000:0000β:: - Trailing :0001 β :1
fe80::a2e0:370:7334:0- fe80:0000:0000:0000 β fe80::
- a2e0:0370:7334:0000 β a2e0:370:7334:0
2001:db8:85a3::8a2e:370:7334- Remove leading zeros
- 0000:0000 β ::
Key Rule: You can only use :: once in an address (otherwise ambiguity exists).
609.11 Summary
- IPv6 provides 2^128 addresses - enough for every IoT device to have a globally unique address
- No NAT required with IPv6, enabling direct end-to-end device connectivity
- IPv6 addresses are 128 bits written as eight groups of four hex digits, compressible using
::for consecutive zeros - Address types include global unicast (internet-routable), link-local (single segment), unique-local (private), and multicast
- 6LoWPAN compression reduces IPv6+UDP headers from 48 bytes to 2-8 bytes for constrained 802.15.4 devices
- Thread and Matter protocols are IPv6-native - IPv4 would require protocol translation
- SLAAC enables automatic address configuration without DHCP
- Transition strategies (dual-stack, tunneling, NAT64) enable IPv4/IPv6 coexistence
609.12 Whatβs Next
Now that you understand IPv6 addressing, continue with:
- DHCP and Address Resolution: Learn DHCP, ARP, and IPv6 Neighbor Discovery
- Networking Addressing Index: Return to the main addressing overview
- 6LoWPAN Deep Dive: Detailed coverage of 6LoWPAN header compression and mesh addressing