Mesh networking: Zigbee, Thread and Matter
Self-healing meshes and the IP-based smart home stack.
Why mesh
In a star network, every device talks directly to a hub; range is limited to one radio hop. In a mesh, devices relay each other's messages, so the network covers a whole building with low-power radios, and if one path fails, messages route around it (self-healing). The cost is complexity: routing, more traffic, and relays that must be powered.
The smart home is the classic application: lights, switches, sensors, locks and thermostats spread across a house.
Node types
All three technologies below share the same idea of roles:
| Role | Power | Job |
|---|---|---|
| Coordinator / leader / border router | Mains | Forms or manages the network, connects it to other networks |
| Router | Mains (always on) | Relays messages for others |
| End device / sleepy end device | Battery | Does not relay; sleeps; has a parent router that buffers its messages |
Battery-powered sensors are almost always end devices; mains-powered lights and plugs act as routers and strengthen the mesh.
Zigbee
Zigbee runs on IEEE 802.15.4 radios (2.4 GHz worldwide, 250 kbit/s) and has been used in smart homes and building automation since the mid-2000s (Philips Hue, IKEA, many sensors).
- Network layer: Zigbee's own (not IP). A coordinator forms the network; routers relay using mesh routing.
- Application layer: the Zigbee Cluster Library (ZCL) standardises device behaviour: an On/Off cluster, a Level Control cluster, a Temperature Measurement cluster, so a switch from one vendor can control a light from another.
- Zigbee 3.0 unified older profiles; security uses AES-128 network and link keys, with install codes for secure joining.
- Talking to the internet requires a gateway that translates Zigbee to IP.
Thread
Thread also runs on 802.15.4 radios, but is IP-native: every device has an IPv6 address (6LoWPAN compresses IPv6 headers to fit 127-byte frames).
- Border routers connect the Thread mesh to Wi-Fi or Ethernet at the IP level, without application-level translation. A home can have several (smart speakers, TVs, hubs), giving redundancy.
- Routers elect a leader automatically; there is no single coordinator to fail.
- The mesh supports up to about 32 routers and hundreds of end devices; routing and repairs are automatic.
- Sleepy end devices poll their parent for buffered messages; synchronised sleepy end devices (Thread 1.2+) wake at agreed times for lower latency.
- Thread defines networking only. It needs an application layer on top: that is Matter's role.
- OpenThread, an open-source implementation, is used by most vendors.
Matter
Matter (from the Connectivity Standards Alliance, formerly the Zigbee Alliance, with Apple, Google, Amazon and Samsung) is an application layer that runs over IP, on Thread, Wi-Fi or Ethernet. Its goal: one device works with every major ecosystem.
+------------------------------------------+
| Matter data model: clusters (from ZCL) |
| Interaction model, security, commissioning|
+------------------------------------------+
| IPv6, UDP/TCP |
+-------------------+----------+-----------+
| Thread (802.15.4) | Wi-Fi | Ethernet |
+-------------------+----------+-----------+
BLE is used only for commissioning
Key ideas:
- Commissioning over BLE using a set-up code (QR code or numeric code on the device), with device attestation certificates proving the device is genuine and certified.
- Multi-admin: the same device can be controlled by several ecosystems at once (Apple Home and Google Home).
- Local control: devices are controlled over the local network, not through a cloud.
- The data model reuses Zigbee's clusters, so concepts carry over.
Comparing them
| Zigbee | Thread | Matter | |
|---|---|---|---|
| Layer | Full stack, including application | Network (IPv6 mesh) | Application (over Thread/Wi-Fi/Ethernet) |
| Radio | 802.15.4 | 802.15.4 | Thread, Wi-Fi, Ethernet |
| IP-based | No | Yes | Yes |
| Internet access | Through a translating gateway | Through border routers at IP level | Through the IP network |
| Single point of failure | Coordinator | None (leader re-elected) | Depends on transport |
| Ecosystem | Mature, huge installed base | Growing | The industry's convergence point |
Mesh design concerns
- Routers must stay powered. A mesh of battery devices that cannot relay is just a star with poor range. Users turning off a smart bulb at the wall switch removes a router.
- Latency grows with hops, and broadcast traffic grows with network size.
- Channel planning: 802.15.4 channels 11 to 26 overlap Wi-Fi; pick channels like 15, 20, 25 or 26 that fall between common Wi-Fi channels.
- Sleepy devices depend on their parent; parent changes and message buffering limits affect reliability and battery.
- Firmware updates over a mesh are slow and must not saturate it.
#include <stdio.h>
/* Which 802.15.4 channels (2405 + 5*(k-11) MHz, 2 MHz wide) avoid Wi-Fi channels 1, 6 and 11 (22 MHz wide)? */
int main(void) {
int wifi[3] = { 2412, 2437, 2462 };
for (int k = 11; k <= 26; k++) {
int f = 2405 + 5 * (k - 11), clear = 1;
for (int w = 0; w < 3; w++) if (f + 1 > wifi[w] - 11 && f - 1 < wifi[w] + 11) clear = 0;
printf("ch %2d (%d MHz) %s\n", k, f, clear ? "clear of Wi-Fi 1/6/11" : "-");
}
return 0;
}
Pitfall: "Thread" and "Matter" are often used interchangeably. Thread is the mesh network; Matter is the application protocol that may or may not run on it. A Wi-Fi Matter device does not need Thread at all.
Interview question: Explain the relationship between Zigbee, Thread and Matter.
Answer: Zigbee is a complete stack on 802.15.4 radios, including its own non-IP network layer and an application layer, the Zigbee Cluster Library, and needs a translating gateway to reach IP networks. Thread uses the same 802.15.4 radios but only defines an IPv6 mesh network, with border routers connecting it to Wi-Fi and Ethernet. Matter is an application layer, whose data model descends from Zigbee's clusters, that runs over IP on Thread, Wi-Fi or Ethernet, adds standard commissioning and security, and lets one device work across the major smart-home ecosystems.
Interview question: Why are battery-powered devices usually end devices rather than routers in a mesh?
Answer: Routers must keep their receivers on to relay other nodes' traffic at any time, which costs milliamps continuously and would drain a battery in days. End devices can sleep and rely on a parent router to buffer their incoming messages, polling it when they wake. So mains-powered nodes such as lights and plugs form the routing backbone, and sensors and switches run for years as sleepy end devices.
Build it: relay through a warehouse full of tags
This is step 6 of the module project, the shipping-container tracker tag. Inside a bonded warehouse, steel containers stacked five high block every radio, and only the outer tags can hear the gateway. So the tags form a mesh and relay each other's messages, by managed flooding, as Bluetooth Mesh does: every tag repeats what it hears. Without care, two hundred tags repeating everything they hear, including each other's repeats, fill the channel within seconds.
Lab: Relay each message once, and never forever
mesh_rx(m, in, out) decides what tag m->me does with a message header it has just received. It returns M_DELIVER (pass it to this tag's application), M_RELAY (send out), both or-ed together, or 0 to drop it. In this order:
- A message whose
srcis this tag is its own, heard back from a neighbour: drop it. - A message seen before, the same
srcandseq, is dropped. Otherwise remember it in the cache of the lastCACHE_SIZEmessages, replacing the oldest entry once the cache is full. - Addressed to this tag: deliver it, and do not relay it; it has arrived.
- Addressed to
BROADCAST: deliver it, and relay it too. - Addressed to another tag: relay it.
Relay only when ttl is at least 2, with out a copy of the header whose ttl is one less. A ttl of 0 or 1 means the message may not travel further.
Going deeper
Interview question: How would you make smart bulbs in every room reachable from one hub?
Answer: Use a mesh standard (Zigbee or Thread) where mains-powered bulbs route for each other, so coverage grows with every bulb, and Matter on top so they work with any brand of hub. Plan for network healing when a bulb is switched off at the wall, and secure joining with per-device credentials.
Interview question: What is a Thread leader and what happens if it fails?
Answer: The leader is a router elected to manage network-wide data, such as assigning router IDs and distributing network configuration. If it disappears, the remaining routers detect it and elect a new leader automatically, so there is no single point of failure. Border routers similarly have redundancy: several can serve the same Thread network.
Interview question: Why does Matter use BLE during commissioning?
Answer: A new device is not yet on any network and has no credentials. BLE lets a phone discover it nearby, establish a secure session using the setup code from the QR code (a passcode-authenticated key exchange), verify its device attestation certificate, and send it the Thread or Wi-Fi network credentials. After commissioning, communication moves to IP over Thread or Wi-Fi.
Explain it: In your own words, explain how a mesh network keeps working when one node is removed.
Answer: In a mesh, routers relay messages for each other, so there are usually several possible paths from any node to the destination. Routers continuously exchange information about their neighbours and link quality, so when a node disappears its neighbours notice that links through it have failed and the routing tables are updated to send traffic along other paths. End devices attached to the missing router find a new parent. As long as an alternative path exists, messages keep flowing, which is what self-healing means.