Zigbee Protocol Stack
The Zigbee protocol stack is a powerful communication framework designed for IoT applications, offering a detailed seven-layer architecture that ensures reliable, low-power wireless communication. In this tutorial, we explore each layer of the Zigbee stack, from the Physical Layer to the Application Layer, and how they work together to facilitate efficient data transmission in IoT networks. Whether you're implementing Zigbee in smart home devices, industrial automation, or sensor networks, understanding these seven layers is crucial for optimizing performance and interoperability.
Out of these seven layers, two layers (PHY, MAC) are defined in IEEE 802.15.4 WPAN standard where as the other two layers (network & security and application layer) are managed by zigbee alliance. The following figure depicts zigbee protocol stack architecture diagram. Let us understand all the seven layers.
1. Physical Layer (PHY)
• Function: This layer handles the actual transmission and reception of data over the wireless medium. It defines the hardware and procedures for modulation, demodulation, and error detection.
• Standards: Based on IEEE 802.15.4, it operates in the 2.4 GHz ISM band (globally), as well as 868 MHz (Europe) and 915 MHz (North America) frequency bands.
• Key Components: Radio transceiver, modulation schemes (e.g., Offset Quadrature Phase Shift Keying - O-QPSK), and power management.
2. MAC Layer
This layer controls access to the physical channel, manages channel access (using mechanisms like CSMA/CA), frame validation and maintains the link quality.
Each MAC frame consists of three fields MAC header, MAC payload and MFR (FCS). Each MAC frame will contain Frame control field (16 bit), which carry frame type, addressing fields and other control flags. This MAC control field contain frame type field, which is the main differentiating factor in identifying one MAC frame with the other. It is 3 bit in length.
The MAC frames are divided into following four major categories, which is used by zigbee devices to establish connection to the PAN by exchanging system information.
1. Beacon
2. Data
3. Acknowledgement
4. MAC command
Refer Zigbee MAC frame formats which describes beacon, data, ack,frame and command frames.
3. Network Layer and security layer
(3.a) : The network layer is responsible for network formation, maintenance, and routing. It handles the creation of network topologies (star, mesh, or tree), node addressing, and routing of data between devices. The key components of network layer include network addressing, routing protocols (e.g., AODV - Ad hoc On-demand Distance Vector), and security functions.
(3.b) : Security mechanisms are distributed across multiple layers, ensuring data encryption, authentication and integrity. Zigbee uses AES-128 encryption for secure communication. If security is enabled, zigbee device will start up using a 128 bit AES encryption key. Devices having same security key can communicate on PAN.
How to obtain this key?
1. Pre-installation
2. Key is received over the air during joining.
4. Application support sublayer
This layer provides an interface between the network layer and the application layer. It manages binding tables (associating clusters with devices), frame formatting, and data encapsulation. The key components are Binding, group management and data security.
There are two profiles at this layer.
1. Manufacturer specific application profile- Operate as closed systems and also ensure that they can coexist with other zigbee systems.
2. Public application profile- for this to work interoperability between various zigbee devices is a must. A single zigbee node supports up to 240 application objects called end points. An end point specifies specific application, for example, 0 dedicated to ZDO (Zigbee device object), provides control and management commands. 6 used for control of light. 8 used for managing heating and air conditioning.
5. Application Framework (AF)
• Function: This layer supports the development of application-specific objects (endpoints) and their communication within the Zigbee network. It defines how application objects can interact with each other.
• Key Components: Application objects (such as sensors, switches), endpoints (addressable entities), and clusters (groupings of attributes and commands).
6. Zigbee Device Objects (ZDO)
• Function: The ZDO is a special entity that manages device roles (such as coordinator, router or end device) and handles network-level functions like joining and leaving networks, device discovery and security.
• Key Components: Device management, security management, and network management.
7. Application Layer
• Function: This is where user-defined applications reside. It includes application profiles, which define the standard behaviors of Zigbee devices for interoperability.
• Key Components: Application profiles (e.g., Home Automation, Smart Energy), custom applications, and data handling for specific use cases.
Key features
Low Power Consumption: Ideal for battery-operated devices.
Low Data Rate: Suitable for control and sensor applications.
Scalability: Supports large networks with up to 65,000 nodes.
Reliability: Mesh networking and multi-hop routing enhance communication reliability.
Topologies
Zigbee supports multiple network topologies:
Star: A single central coordinator communicates with multiple end devices.
Mesh: Devices can communicate with each other, allowing multi-hop routing and greater reliability.
Tree: A hierarchical structure with a root coordinator and multiple levels of routers and end devices.
Summary
Zigbee's seven layered architecture enables flexibility, allowing developers to create robust, interoperable, and energy-efficient wireless networks for a wide range of applications.
ps:Zigbee protocol stack layers with architecture diagram
Carrier Sense Multiple Access (CSMA)
CSMA is a basic method that controls the communication of multiple participants on a shared and decentralized transmission medium. However, this is now available in three different variants, which depend on the transmission medium. While CSMA/CA is mainly used in wireless networks, CSMA/CD was developed for Ethernet, and CSMA/CR is used in controller area networks (CAN), which are mainly used in cars and machines.
To understand exactly what is behind Carrier Sense Multiple Access with Collision Avoidance, it makes sense to look at the components individually:
- Carrier sense (CA): The initial idea is that participants may only send data over the network if the transmission medium is free. The carrier status detection checks the channel any time, and data is not sent until it’s available.
- Multiple access (MA): Several stations share a transmission medium. It is crucial for functioning communication that all of them adhere to a binding protocol.
- Collision avoidance (CA): A complex schedule tries to ensure that two or more participants do not start a transmission at the same time to avoid collisions. If overlapping does occur, this will be detected and the transmission will be tried again.