Back
Loading views...SixLoWPAN
6LoWPAN
Overview
6LoWPAN (IPv6 over Low-Power Wireless Personal Area Networks) is an adaptation layer that enables IPv6 packets to be sent over IEEE 802.15.4 networks. It provides header compression, fragmentation, and mesh-under routing to bring native IP connectivity to constrained IoT devices.
1. Theory & Fundamentals
- Adaptation layer between IPv6 and IEEE 802.15.4 MAC
- Compresses 40-byte IPv6 header + 8-byte UDP header to 2–7 bytes (IPHC)
- Fragments large IPv6 packets into 802.15.4 frames (127-byte MTU)
- Enables standard IP protocols (UDP, TCP, CoAP, DNS) on constrained devices
- Used by: Thread, Zigbee IP, Wi-SUN, and industrial mesh networks
- RFC 4944 original; RFC 6282 IPHC compression; RFC 6775 ND optimization
2. Frame / Packet Structure
6LoWPAN Dispatch byte:
00xxxxxx = Not 6LoWPAN
01000001 = Uncompressed IPv6
011xxxxx = LOWPAN_IPHC (compressed)
1110xxxx = Mesh addressing
11000xxx = FRAG1 (first fragment)
11100xxx = FRAGN (subsequent fragment)
IPHC compression:
Original IPv6 = 40 bytes → Compressed = 2–7 bytes
Compress: Version, Traffic Class, Flow Label, Next Header, Hop Limit
Source/Dest address: Inline, 64-bit, 16-bit, or elided (link-local)
Fragment header:
Dispatch | Datagram Size(11b) | Datagram Tag(16b) | [Offset(8b)]
3. Protocol Mechanics
- Mesh-under vs Route-over: Mesh-under handles routing at 802.15.4 level; Route-over uses IPv6
- ND (Neighbor Discovery): RFC 6775 optimizes IPv6 ND for 6LoWPAN
- Address registration: Devices register with Border Router
- RPL: IPv6 Routing Protocol for Low-Power and Lossy Networks (RFC 6550)
- DODAG: RPL builds a destination-oriented directed acyclic graph
4. Hardware Implementation
- OpenThread includes 6LoWPAN implementation
- Contiki-NG: Full 6LoWPAN/RPL/CoAP stack for constrained devices
- Zephyr RTOS: Built-in 6LoWPAN support
- Border router: Linux + wpantund + 6LoWPAN driver for IEEE 802.15.4 interface
- Hardware: Same as Zigbee (nRF52840, CC2652, EFR32)
5. Register-Level / Configuration
// Contiki-NG CoAP over 6LoWPAN
#include "net/app-layer/coap/coap.h"
COAP_RESOURCE(temp_resource, "title=\"Temperature\"",
temperature_get, NULL, NULL, NULL);
// In temperature_get handler:
void temperature_get(coap_message_t *req, coap_message_t *res, ...) {
char buf[16];
int len = snprintf(buf, sizeof(buf), "%d.%02d", temp_int, temp_frac);
coap_set_payload(res, (uint8_t*)buf, len);
}
6. Driver / Software Development
- Initialize hardware peripheral or SoC block
- Implement send/receive with interrupt or DMA
- Handle errors: timeout, CRC, NAK, bus-off
- Use circular buffers for RX data flow
- Implement retry logic for reliability
7. Debugging & Testing
- Wireshark with 802.15.4 capture + 6LoWPAN dissector
- Contiki-NG cooja simulator: Run network in simulation
- Common issues: IPv6 header not compressible (check IPHC settings); fragmentation reassembly timeout; RPL routing loops
- 'ping6' from border router to verify connectivity
8. Real-World Applications
- Thread smart home devices
- Wi-SUN field area networks (smart grid)
- Industrial 802.15.4g mesh networks
- Building automation (KNX IPv6)
- Medical body area networks
9. Advanced Topics & Edge Cases
- SCHC (Static Context Header Compression): Further compresses 6LoWPAN headers for LPWAN
- Wi-SUN: Uses 6LoWPAN on sub-GHz 802.15.4g for grid infrastructure
- RPL vs AODV: RPL is tree-based; AODV is on-demand; RPL preferred for 6LoWPAN
- IPv6 multicast: Compressed in 6LoWPAN to save bandwidth
10. Standards & Variants
| Aspect | 6LoWPAN | Native IPv6 | ZigBee |
|---|---|---|---|
| Header | 2–7B | 40B | Custom |
| IP | Native | Native | No |
| MTU | 127B | 1280B | 127B |
| Stack | Adaptation | Direct | Custom |
💡 Practical Examples
Ex 1: IPv6 ping over 6LoWPAN
Border router: ping6 fd00::1 where fd00::1 is node's IPv6 address.
Ex 2: CoAP GET resource
coap-client -m get coap://[fd00::1]/temperature # Returns "23.50"
Ex 3: RPL routing
Nodes auto-form DODAG with border router as root; RPL DIO/DAO messages establish routes.
🧪 Practice Questions
Beginner
- What does 6LoWPAN stand for?
- Why is header compression necessary in 6LoWPAN?
- What is the MTU of IEEE 802.15.4?
- What routing protocol does 6LoWPAN commonly use?
- What is a Border Router in a 6LoWPAN network?
Intermediate
- Explain 6LoWPAN IPHC header compression.
- How does 6LoWPAN handle fragmentation of large IPv6 packets?
- Implement a CoAP sensor resource on Contiki-NG.
- What is RPL DODAG and how is it formed?
- How does 6LoWPAN handle IPv6 neighbor discovery?
Advanced
- Design a 100-node 6LoWPAN mesh using RPL.
- Implement SCHC compression on top of 6LoWPAN for LoRaWAN.
- Build a 6LoWPAN border router with Linux and OpenThread.
- Analyze RPL convergence time after node failure.
- Debug 6LoWPAN fragmentation reassembly timeout issues.
Projects
- 6LoWPAN Sensor Net: 5 nodes with Contiki-NG, CoAP, RPL to border router.
- Border Router: Raspberry Pi + USB 802.15.4 dongle, route IPv6 to mesh.
- CoAP Dashboard: Periodic CoAP GET to all nodes, display on web UI.
Checklist
- [ ] Explain 6LoWPAN layer and its role
- [ ] Understand IPHC header compression format
- [ ] Set up Contiki-NG or Zephyr with 6LoWPAN
- [ ] Implement CoAP server over 6LoWPAN
- [ ] Configure RPL for mesh routing
- [ ] Set up 6LoWPAN border router
- [ ] Debug with Wireshark 6LoWPAN dissector
- [ ] Use Cooja simulator for network testing
- [ ] Handle fragmentation correctly
- [ ] Integrate with cloud via CoAP-HTTP proxy