Back

IEEE_802_15_4

Loading views...

IEEE 802.15.4

Overview

IEEE 802.15.4 is the foundational MAC and PHY standard for low-rate wireless personal area networks (LR-WPANs). It is the physical and MAC layer basis for Zigbee, Thread, 6LoWPAN, WirelessHART, ISA-100, and Z-Wave (indirectly). It defines channels, modulation, frame formats, and CSMA-CA access.


1. Theory & Fundamentals

  • Frequency bands: 2.4 GHz (16 channels, 250 kbps), 868 MHz (1 channel, 20 kbps), 915 MHz (10 channels, 40 kbps)
  • PHY: O-QPSK (2.4 GHz), BPSK (868/915 MHz); also 802.15.4g adds SUN PHY for sub-GHz
  • Range: 10–100m (indoor)
  • Power: Ultra-low; designed for years on batteries
  • Topology: Star or peer-to-peer
  • Device types: Full-Function Device (FFD), Reduced-Function Device (RFD)
  • PAN ID: 16-bit; distinguishes networks on same channel

2. Frame / Packet Structure

802.15.4 MAC Frame General Structure:
  MHR | MAC Payload | MFR
  MHR: FCF(2B) | Seq(1B) | Addressing(4–20B)
  FCF: Frame Type(3b) | Security(1b) | Pending(1b) | AR(1b) | PAN Compress(1b) | Reserved(3b) | Dest Mode(2b) | Frame Version(2b) | Src Mode(2b)
  MFR: FCS(2B) = CRC-16

Frame Types:
  000=Beacon, 001=Data, 010=ACK, 011=MAC Command

Beacon frame (from PAN coordinator):
  Superframe Spec | GTS fields | Pending addresses | Beacon payload

3. Protocol Mechanics

  • CSMA-CA: Listen before talk; backoff algorithm reduces collisions
  • Superframe structure (optional): Beacon interval divides into 16 slots; GTS for guaranteed access
  • ACK: Optional; requested by AR bit in FCF
  • Security: AES-128 CCM* in MAC layer; multiple security levels
  • Beacon-enabled PAN: Coordinator sends beacons at fixed interval; devices synchronize
  • Beacon-less PAN: Devices transmit without synchronization (simpler)

4. Hardware Implementation

  • Same hardware as Zigbee/Thread: CC2652, nRF52840, AT86RF233
  • Radio: IEEE 802.15.4-compliant transceiver or integrated SoC
  • SMAC, OpenThread, Zigbee stacks all run on 802.15.4 hardware
  • Frequency: 2.4 GHz most common (global); sub-GHz for longer range
  • PPDU: Physical Protocol Data Unit; starts with SHR (Sync Header) + PHR + PSDU

5. Register-Level / Configuration

// Direct 802.15.4 MAC frame send (using NXP MCR20A or similar)
// Most implementations use Zigbee/Thread stack on top
// Bare 802.15.4 TX (simplified pseudocode)
frame[0] = 0x61; // FCF byte 0: data frame, ACK req, no security
frame[1] = 0x88; // FCF byte 1: src+dst 16-bit addr, PAN compress
frame[2] = seq_num++;
// Destination address
frame[3] = pan_id & 0xFF; frame[4] = pan_id >> 8;
frame[5] = dst_addr & 0xFF; frame[6] = dst_addr >> 8;
frame[7] = src_addr & 0xFF; frame[8] = src_addr >> 8;
memcpy(&frame[9], payload, payload_len);
Radio_Transmit(frame, 9 + payload_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 plugin: Capture and decode raw frames
  • OpenThread CLI: 'scan', 'ping', 'state' for network diagnostics
  • USB sniffers: Zigbee Alliance sniffer, nRF52840 in sniffer mode
  • Common issues: Channel mismatch; PAN ID conflict; CSMA-CA collision (high load)
  • Verify FCS (CRC-16) is correct

8. Real-World Applications

  1. Zigbee home automation (ZHA profile)
  2. Thread smart home devices
  3. WirelessHART industrial sensors
  4. ISA-100.11a process automation
  5. IEEE 802.15.4g smart utility networks

9. Advanced Topics & Edge Cases

  • 802.15.4e: Enhanced MAC for TSCH (Time-Slotted Channel Hopping)
  • TSCH: Industrial-grade reliable mesh using time slots + frequency hopping
  • 802.15.4g: SUN PHY for wide-area sub-GHz (Wi-SUN)
  • 802.15.4z: Enhanced UWB ranging
  • Security: CCM* provides both encryption and authentication at MAC layer

10. Standards & Variants

Band Channels Data Rate Range Notes
2.4 GHz 11–26 250 kbps 100m Global
868 MHz 0 20 kbps 200m Europe
915 MHz 1–10 40 kbps 200m Americas
Sub-GHz g many 50–300kbps 500m 802.15.4g

💡 Practical Examples

Ex 1: Energy detect scan

Scan all 802.15.4 channels, measure RSSI per channel, pick least congested.

Ex 2: Associate with PAN coordinator

Send Association Request frame to coordinator; receive Association Response with short address.

Ex 3: Send data with ACK

Set AR=1 in FCF; verify ACK received within macAckWaitDuration.


🧪 Practice Questions

Beginner

  1. What frequency band does 802.15.4 primarily use?
  2. What is the maximum data rate at 2.4 GHz?
  3. What is a PAN ID?
  4. What are the 4 MAC frame types?
  5. What protocols are built on 802.15.4?

Intermediate

  1. Explain CSMA-CA collision avoidance.
  2. How does 802.15.4 superframe structure work?
  3. What is TSCH and what problems does it solve?
  4. Implement raw 802.15.4 beacon frame parsing.
  5. How does AES-CCM* provide security at MAC layer?

Advanced

  1. Implement TSCH scheduling for deterministic industrial mesh.
  2. Design a custom 802.15.4 MAC layer in C for a proprietary sensor protocol.
  3. Analyze 802.15.4 channel interference with 2.4 GHz Wi-Fi.
  4. Implement 802.15.4 MAC security (AES-128 CCM*).
  5. Build a 802.15.4 packet sniffer with nRF52840.

Projects

  1. Raw 802.15.4: Send/receive frames without Zigbee/Thread stack.
  2. Sniffer: nRF52840 sniffer firmware + Wireshark capture + decode.
  3. TSCH Demo: 2-node synchronized channel hopping with slot scheduling.

Checklist

  • [ ] Explain 802.15.4 PHY and MAC layers
  • [ ] Understand frame structure and FCF bits
  • [ ] Implement CSMA-CA in software
  • [ ] Configure PAN ID and channel
  • [ ] Send and receive data frames with ACK
  • [ ] Parse beacon frames
  • [ ] Use Wireshark to decode 802.15.4 traffic
  • [ ] Apply AES-CCM* security at MAC layer
  • [ ] Understand TSCH scheduling
  • [ ] Build on top: Zigbee, Thread, or 6LoWPAN