984  Zigbee Protocol Stack and Architecture

Understanding the layered architecture from IEEE 802.15.4 to application profiles

984.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Explain the layered structure of the Zigbee protocol stack
  • Describe the role of IEEE 802.15.4 as the physical and MAC layer foundation
  • Understand the Zigbee Network Layer (NWK) functions and responsibilities
  • Identify the Application Support Sub-layer (APS) and its binding capabilities
  • Recognize how Application Framework enables interoperable device communication

984.2 Introduction

Zigbee is a low-power wireless mesh networking protocol designed for IoT applications requiring reliable, low-data-rate communication. Understanding its protocol stack is essential for designing, deploying, and troubleshooting Zigbee networks. This chapter examines each layer of the Zigbee architecture, from the physical radio to the application profiles that enable device interoperability.

Think of a protocol stack like sending a letter through the postal system:

  • Physical layer: The mail truck that carries the letter
  • MAC layer: The envelope with addresses that identifies sender/receiver
  • Network layer: The sorting system that routes the letter through multiple post offices
  • Application layer: The actual message content inside the letter

Each layer has a specific job, and they work together to deliver your message from source to destination. In Zigbee, the protocol stack defines how data travels from a sensor to a hub through the wireless mesh network.

984.3 IEEE 802.15.4: The Foundation

Zigbee builds on the IEEE 802.15.4 standard, which provides the physical (PHY) and medium access control (MAC) layers. This foundation handles radio transmission and basic packet framing.

984.3.1 Physical Layer (PHY)

The physical layer manages radio transmission:

Parameter Value
Frequency Band 2.4 GHz (global), 868 MHz (EU), 915 MHz (Americas)
Channels 16 channels in 2.4 GHz band (channels 11-26)
Data Rate 250 Kbps (2.4 GHz)
Modulation O-QPSK with DSSS
TX Power -3 dBm to +20 dBm typical

984.3.2 MAC Layer

The MAC layer provides:

  • CSMA/CA: Carrier Sense Multiple Access with Collision Avoidance for channel access
  • Frame Types: Beacon, data, acknowledgment, and command frames
  • Addressing: 64-bit IEEE addresses and 16-bit short addresses
  • Acknowledgments: Optional per-packet acknowledgments for reliability

%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#E67E22', 'secondaryColor': '#7F8C8D', 'tertiaryColor': '#ECF0F1', 'fontSize': '13px'}}}%%
flowchart TB
    subgraph APP["Application Framework"]
        ZCL["Zigbee Cluster Library<br/>Standard device behaviors"]
        PROF["Application Profiles<br/>ZHA, ZLL, Zigbee 3.0"]
    end

    subgraph APS["Application Support Sub-layer"]
        BIND["Binding Table<br/>Device-to-device links"]
        GRP["Group Management<br/>Multicast addressing"]
        SEC1["Security Services<br/>Link keys"]
    end

    subgraph NWK["Network Layer (NWK)"]
        ROUTE["Routing<br/>AODV, Tree, Source"]
        ADDR["Address Management<br/>16-bit network addresses"]
        SEC2["Security<br/>Network key encryption"]
    end

    subgraph MAC["IEEE 802.15.4 MAC"]
        CSMA["CSMA/CA<br/>Channel access"]
        FRAME["Framing<br/>ACKs, retries"]
    end

    subgraph PHY["IEEE 802.15.4 PHY"]
        RADIO["2.4 GHz Radio<br/>O-QPSK, 250 Kbps"]
    end

    APP --> APS --> NWK --> MAC --> PHY

    style APP fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
    style APS fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style NWK fill:#2C3E50,stroke:#16A085,stroke-width:2px,color:#fff
    style MAC fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
    style PHY fill:#34495E,stroke:#2C3E50,stroke-width:2px,color:#fff

Figure 984.1: Zigbee protocol stack showing the layered architecture from PHY to Application Framework

984.4 Network Layer (NWK)

The Zigbee Network Layer adds mesh networking capabilities on top of IEEE 802.15.4:

984.4.1 Key Functions

  1. Network Formation: Coordinator creates the network with a unique PAN ID
  2. Address Assignment: Devices receive 16-bit network addresses upon joining
  3. Routing: AODV-based mesh routing enables multi-hop communication
  4. Security: Network-wide encryption using AES-128

984.4.2 Network Addressing

Zigbee uses two address types:

Address Type Length Purpose
IEEE Address 64-bit Unique device identifier (like MAC address)
Network Address 16-bit Efficient in-network routing

The 64-bit IEEE address uniquely identifies each device globally. When a device joins a Zigbee network, it receives a 16-bit network address for efficient routing within that network.

Example Address Assignment:
- Coordinator: 0x0000 (always)
- First router: 0x0001
- First end device: 0x0023

984.4.3 Why 16-bit Addresses?

Using 16-bit addresses instead of 64-bit addresses for routing provides significant efficiency gains:

  • Packet overhead: 2 bytes vs 8 bytes per address
  • Routing table size: 200 bytes for 100 devices vs 800 bytes
  • Memory efficiency: Critical for resource-constrained devices with 8-32KB RAM

984.5 Application Support Sub-layer (APS)

The APS layer provides services for the application layer:

984.5.1 Binding

Binding creates logical connections between devices:

Example: Motion sensor bound to light bulb
- Source: Motion sensor endpoint 1
- Destination: Light bulb endpoint 8
- Cluster: On/Off (0x0006)

When motion detected:
1. Sensor sends On command to binding
2. APS looks up destination in binding table
3. Message routed to light bulb endpoint
4. Light turns on

984.5.2 Group Addressing

Groups enable multicast communication:

Group 1: "Living Room Lights"
- Bulb A (0x0001)
- Bulb B (0x0002)
- Bulb C (0x0003)

Command: "Group 1: Turn Off"
β†’ All three bulbs turn off simultaneously

984.5.3 Security Services

APS manages link-level security:

  • Link Keys: Unique keys between device pairs
  • Trust Center Link Key: Shared key with the Trust Center
  • Install Codes: Pre-shared secrets for secure joining

984.6 Application Framework

The Application Framework defines how devices communicate at the application level:

984.6.1 Endpoints

Each Zigbee device can have multiple endpoints (1-240), similar to TCP/UDP ports:

Endpoint Purpose
0 Zigbee Device Object (ZDO) - network management
1-239 Application endpoints
240 Green Power
255 Broadcast to all endpoints

984.6.2 Zigbee Cluster Library (ZCL)

ZCL defines standardized device behaviors through clusters:

Cluster ID Name Function
0x0000 Basic Device information (manufacturer, model)
0x0006 On/Off Toggle, on, off commands
0x0008 Level Control Dimming, brightness
0x0300 Color Control Hue, saturation, color temperature
0x0402 Temperature Measurement Sensor readings

Example cluster interaction:

Light bulb receives On/Off cluster command:
- Cluster ID: 0x0006
- Command: 0x01 (On)
- Payload: (none)

Light responds:
- Turns on
- Reports state via attribute (On/Off = true)

984.7 Frame Structure

Understanding the Zigbee frame structure helps with debugging and protocol analysis:

%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D', 'fontSize': '12px'}}}%%
flowchart LR
    subgraph Frame["Zigbee Frame Structure"]
        MHR["MAC Header<br/>23 bytes"]
        NWK["NWK Header<br/>8 bytes"]
        APS["APS Header<br/>8 bytes"]
        ZCL["ZCL Frame<br/>Variable"]
        MIC["MIC<br/>4 bytes"]
        FCS["FCS<br/>2 bytes"]
    end

    MHR --> NWK --> APS --> ZCL --> MIC --> FCS

    style MHR fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
    style NWK fill:#2C3E50,stroke:#16A085,stroke-width:2px,color:#fff
    style APS fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style ZCL fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
    style MIC fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
    style FCS fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff

Figure 984.2: Zigbee frame showing headers from each protocol layer

Maximum Frame Size: 127 bytes (IEEE 802.15.4 limit) Typical Payload: 60-80 bytes after headers and security

984.8 Protocol Stack Comparison

Understanding how Zigbee compares to similar protocols helps with technology selection:

Layer Zigbee Thread Bluetooth LE
PHY/MAC IEEE 802.15.4 IEEE 802.15.4 Bluetooth 5.x
Network Zigbee NWK (proprietary) IPv6 (6LoWPAN) None (mesh optional)
Transport None UDP L2CAP
Application ZCL Clusters CoAP/Matter GATT Profiles

Key Difference: Thread uses native IPv6 addressing, while Zigbee uses proprietary 16-bit addressing. This affects cloud connectivity - Thread devices can communicate directly over IP, while Zigbee requires a gateway for protocol translation.

984.9 Summary

This chapter covered the Zigbee protocol stack architecture:

  • IEEE 802.15.4 PHY/MAC: Provides the radio foundation with CSMA/CA channel access
  • Network Layer (NWK): Adds mesh routing, network addressing, and security
  • Application Support (APS): Enables binding, groups, and link-level security
  • Application Framework: Defines endpoints and the Zigbee Cluster Library for interoperability

Understanding the protocol stack is essential for: - Selecting appropriate device types for your application - Debugging communication issues at the correct layer - Optimizing network performance through proper configuration - Designing interoperable Zigbee products

984.10 What’s Next

In the next chapter, Zigbee Network Topologies, we explore the different network configurations (star, tree, mesh) and how to choose the right topology for your deployment.