Detailed explanation of ZigBee ad hoc network address allocation and routing protocol technology
[Copy link]
1. Introduction to ZigBee
ZigBee is a low-power LAN protocol based on the IEEE802.15.4 standard. According to international standards, ZigBee technology is a short-range, low-power wireless communication technology.
From bottom to top, the ZigBee protocol consists of the physical layer (PHY), media access control layer (MAC), transport layer (TL), network layer (NWK), application layer (APL), etc. The physical layer (PHY) and media access control layer (MAC) follow the provisions of the IEEE802.15.4 standard.
2. ZigBee device types
2.1 Coordinator
The main function of the coordinator in the ZigBee network is to establish and maintain the network, store network information, and serve as the authentication center of the entire network.
2.2 Router
The main function of the router in the ZigBee network is to expand the network, dynamically route around obstacles, and provide information channels between remote nodes and the central node.
2.3 Terminal Equipment
The terminal device in the ZigBee network is a simple ZigBee device that only receives and sends information. It can only be at the end of the ZigBee network and can only communicate with its parent node. It can support low power consumption functions, but has no routing and network maintenance capabilities.
3. ZigBee network structure
ZigBee networks can be divided into: star network, tree network, and mesh network (MESH network).
(Special note: Star and tree networks are suitable for applications with many points and relatively close distances)
3.1 Star Network
The ZigBee star network topology is shown in the figure below. Star topology is the simplest topology, which includes a Coordinator node and a series of End Device nodes. Each End Device node can only communicate with the Coordinator node. If communication is required between two End Device nodes, the information must be forwarded through the Coordinator node.
The disadvantage of this topology is that there is only one path for data routing between nodes. The Coordinator may become the bottleneck of the entire network. To implement a star network topology, you do not need to use the Zigbee network layer protocol, because the IEEE 802.15.4 protocol layer has already implemented the star topology, but this requires developers to do more work at the application layer, including handling the forwarding of information themselves.
ZigBee Star Network Topology
3.2 Tree Network
The ZigBee tree network topology is shown in the figure below. The tree topology includes a Coordinator and a series of Routers and End Devices. The Coordinator connects a series of Routers and End Devices, and its child Routers can also connect a series of Routers and End Devices. This can be repeated for multiple levels.
have to be aware of is:
-
Coordinator and Router nodes can contain their own child nodes.
-
End Device cannot have its own child nodes.
-
Nodes with the same parent node are called sibling nodes.
-
Nodes with the same grandfather node are called cousin nodes.
-
Each node can only communicate with its parent node and child nodes.
If data needs to be sent from one node to another, the information is passed up the tree to the nearest ancestor node and then down to the target node.
The disadvantage of this topology is that the information has only one routing channel. In addition, the routing of information is handled by the protocol stack layer, and the entire routing process is completely transparent to the application layer.
ZigBee Tree Network Topology
3.3 Mesh Network
The ZigBee mesh network topology is shown in the figure below. The mesh topology consists of a Coordinator and a series of Routers and End Devices. This network topology is the same as the tree topology; please refer to the tree network topology mentioned above. However, the mesh network topology has more flexible information routing rules, and routing nodes can communicate directly when possible. This routing mechanism makes information communication more efficient, and means that once a routing path has a problem, the information can be automatically transmitted along other routing paths.
Usually, in the implementation of supporting mesh networks, the network layer will provide corresponding routing exploration functions, which enables the network layer to find the most optimized path for information transmission. It should be noted that the above-mentioned features are all implemented by the network layer, and the application layer does not need to participate in any way.
The network with mesh network topology has powerful functions. The network can communicate through "multi-hop" mode. The topology can also form a very complex network. The network also has self-organization and self-healing functions.
ZigBee Mesh Network Topology
4. ZigBee address allocation mechanism
In the ZigBee 2007 protocol, the network address allocation mechanism is a tree network allocation mechanism, which is mainly implemented as follows:
Assuming the maximum number of child devices is nwkMaxChildren(Cm), the maximum network depth is nwkMaxDepth(Lm), the maximum number of routing devices that a parent node can use as its child devices is nwkMaxRouters(Rm), and the network depth itself is (d), we can calculate the function Cskip(d)m, which is the number of sub-segment addresses that a parent node can allocate under the conditions of a given network depth and the number of routing child devices:
If the value of Cskip(d) of a device is 0, it has no routing capability and is a terminal device;
If the value of Cskip(d) of a device is greater than 0, it has routing capability and is a router device.
The addresses allocated in the network are (n is the number of currently allocated nodes)
Terminal: An=Ak+1+Cskip(d)*(n-1)
Router: An=Ak+Cskip(d)*Rm*(n-1);
The next router device assigned address is the previous assigned router address plus the Cskip offset
CurNodeInfo.NextRouterAddr+ = CurNodeInfo.Cskip;
The next terminal device address to be assigned is the previous known assigned address + 1
CurNodeInfo.NextEndDevAddr++;
5. ZigBee tree routing mechanism
Suppose a router wants to send a data packet to the destination address D. The network address and network depth of this router are A and d. It will first determine whether the destination address device is its child device, which should satisfy:
A < D < A+Cskip(d-1)
If the target device is its child device, the next hop address is
Otherwise, the router sends the packet to its parent node.
|