Context: You are designing an 802.15.4 smart home system with door locks, window sensors, and motion detectors. You must select a security level that balances payload efficiency, power consumption, and threat protection.
Step 1: Understand Security Level Options
IEEE 802.15.4 defines 8 security levels (0-7):
| 0 |
None |
0 |
0 |
0 bytes |
None |
| 1 |
MIC-32 |
4 |
5-6 |
9-10 bytes |
Auth only (32-bit) |
| 2 |
MIC-64 |
8 |
5-6 |
13-14 bytes |
Auth only (64-bit) |
| 3 |
MIC-128 |
16 |
5-6 |
21-22 bytes |
Auth only (128-bit) |
| 4 |
ENC |
0 |
5-6 |
5-6 bytes |
Encrypt only (no auth) |
| 5 |
ENC-MIC-32 |
4 |
5-6 |
9-10 bytes |
Encrypt + auth (32-bit) |
| 6 |
ENC-MIC-64 |
8 |
5-6 |
13-14 bytes |
Encrypt + auth (64-bit) |
| 7 |
ENC-MIC-128 |
16 |
5-6 |
21-22 bytes |
Encrypt + auth (128-bit) |
Auxiliary Security Header (5-6 bytes):
- Security Control: 1 byte
- Frame Counter: 4 bytes (replay protection)
- Key Identifier: 0-9 bytes (typically 0-1 for home networks)
Step 2: Threat Model for Home Automation
Threat 1: Eavesdropping (Eve listens to sensor data)
- Impact: Privacy violation (knows when you are home/away)
- Mitigation: Encryption (Levels 4-7)
- Required: Yes (Level 4 minimum)
Threat 2: Packet Injection (Mallory sends fake “unlock door” command)
- Impact: Physical security breach
- Mitigation: Message authentication (MIC)
- Required: Yes (Level 1-3, or 5-7 with encryption)
Threat 3: Replay Attack (Mallory captures and retransmits “unlock door” packet)
- Impact: Physical security breach (attack works even if encrypted)
- Mitigation: Frame counter monotonicity check
- Required: Yes (automatic with security enabled)
Threat 4: Brute-Force MIC Forgery (Mallory tries to craft valid fake packet)
- Impact: Fake commands accepted
- Mitigation: Larger MIC (longer to brute-force)
- Analysis:
- 32-bit MIC: 2^32 = 4.3 billion attempts (feasible in hours on GPU)
- 64-bit MIC: 2^64 = 18 quintillion attempts (infeasible)
- 128-bit MIC: 2^128 = 3.4x10^38 attempts (astronomically infeasible)
Conclusion: Level 6 (ENC-MIC-64) is the minimum for actuator control.
Step 3: Calculate Payload Impact
Smart home sensor frame composition (door sensor example):
| PHY Header |
6 |
Preamble + SFD + length |
| MAC Header |
9 |
Frame control + seq + PAN ID + short addresses |
| Security (Level 6) |
14 |
6-byte aux header + 8-byte MIC |
| Payload |
? |
Sensor data |
| FCS |
2 |
CRC |
Available payload:
Max frame: 127 bytes
Overhead: 6 (PHY) + 9 (MAC) + 14 (Security) + 2 (FCS) = 31 bytes
Available payload: 127 - 31 = 96 bytes
Sensor data requirements (door sensor):
Device ID: 2 bytes (short address already in MAC header -- skip this!)
Sensor state: 1 byte (open/closed/tampered)
Battery voltage: 1 byte (0-255 = 0-3.3V scaled)
Reed switch count: 2 bytes (number of open/close cycles)
Timestamp: 4 bytes (Unix time, coordinator provides via beacon)
Total: 8 bytes (fits easily in 96-byte payload)
Payload utilization: 8 / 96 = 8.3% (plenty of headroom)
Step 4: Compare Security Levels
| 0 (None) |
0 |
116 bytes |
Yes (8 bytes) |
No |
None |
NEVER for home automation |
| 1 (MIC-32) |
9-10 |
106-107 bytes |
Yes |
No |
Weak (GPU brute-force) |
Insufficient |
| 4 (ENC only) |
5-6 |
110-111 bytes |
Yes |
Yes |
No auth (packet injection) |
Dangerous |
| 5 (ENC-MIC-32) |
9-10 |
106-107 bytes |
Yes |
Yes |
Weak (GPU brute-force) |
Marginal |
| 6 (ENC-MIC-64) |
13-14 |
102-103 bytes |
Yes |
Yes |
Strong (2^64) |
RECOMMENDED |
| 7 (ENC-MIC-128) |
21-22 |
94-95 bytes |
Yes |
Yes |
Very strong |
Also acceptable |
Decision: Use Level 6 (ENC-MIC-64)
Rationale:
- 14 bytes overhead is acceptable (sensor data only needs 8 bytes)
- Provides encryption (privacy) + 64-bit MIC (infeasible brute-force)
- Frame counter prevents replay attacks automatically
- 102 bytes available payload leaves room for future features
Why not Level 7 (ENC-MIC-128)?
- 128-bit MIC provides no practical security benefit over 64-bit (2^64 is already computationally infeasible)
- Extra 8 bytes (16-byte MIC vs 8-byte) wastes bandwidth and power (longer transmission time)
- For small sensor data, the overhead difference is negligible, but Level 6 is more efficient
Step 5: Verify Power Consumption Impact
Transmission time comparison:
No security (Level 0):
Frame size: 6 (PHY) + 9 (MAC) + 8 (payload) + 2 (FCS) = 25 bytes
Transmission time @ 250 kbps: 25 x 8 bits / 250,000 bps = 0.8 ms
Level 6 (ENC-MIC-64):
Frame size: 6 + 9 + 14 (security) + 8 + 2 = 39 bytes
Transmission time: 39 x 8 / 250,000 = 1.25 ms
Power impact:
Transmit current: 12 mA
Additional TX time: 1.25 - 0.8 = 0.45 ms
Extra energy per transmission: 12 mA x 0.45 ms = 5.4 uA-ms
For 5-minute reporting interval (300,000 ms):
Average current impact: 5.4 / 300,000 = 0.000018 mA = 0.018 uA
Compared to sleep current (3 uA), this is 0.6% increase -- negligible!
Conclusion: Security overhead has almost no impact on battery life for low-duty-cycle sensors.
Step 6: Implementation Checklist
Required for Level 6 Security:
- Key Management:
- Pre-install network key during manufacturing OR
- Use secure commissioning (e.g., Thread DTLS handshake, Zigbee Trust Center)
- NEVER transmit keys in plaintext
- Frame Counter Management:
- Persist frame counter to non-volatile memory every 1,000 increments
- On reboot, load counter from NVM and add 1,001 (ensures monotonicity)
- Reset counter only when changing network key
- Neighbor Table:
- Store highest frame counter seen from each neighbor
- Drop frames with counter less than or equal to stored value (replay protection)
- Table size: 10-50 entries (80-400 bytes RAM)
- Security Processing Pipeline:
- On TX: Increment counter -> Build aux header -> Encrypt payload -> Compute MIC -> Append
- On RX: Extract counter -> Check replay -> Decrypt -> Verify MIC -> Pass to app if valid
Real-World Example: Zigbee vs Thread Security Choices
Zigbee 3.0:
- Uses Level 5 (ENC-MIC-32) for most traffic
- Rationale: Legacy (backward compatibility with older devices)
- Trade-off: Accepted slightly weaker MIC for ecosystem compatibility
Thread 1.3:
- Uses Level 5 or Level 6 (ENC-MIC-32/64) depending on message type
- Link-local traffic: Level 5 (lower overhead for frequent neighbor discovery)
- Network-wide traffic: Level 6 (stronger auth for routed messages)
Your Smart Home System:
- Recommendation: Level 6 uniformly across all device types
- Simpler codebase (one security configuration)
- Future-proof (64-bit MIC will remain secure for decades)
- Performance impact is negligible for home-scale networks (< 100 devices)