In the routing discovery, the broadcasting coverage of the routing request has to be large enough to ensure that the global shortest path can be found, while it also should be as small as possible to save the bandwidth and energy consumption. A common method in the ZigBee network is to limit the retransmission times to control the range, like the ZBARD in [13]. Limited to the resources in the ZigBee devices, the location-based controlling strategies are difficult to implement. However, the hierarchical ZigBee networks can be seen as clustering ones. If these clusters are organized by nearby principle and not overlapping, they may imply the inaccurate relative location of the devices. Considering the case in Figure 1, we assume the parameter *Cm* is 5; the network can be seen as consisting of five clusters that take the nodes in depth 1 as the cluster heads. If node A tries to send a packet to node B by Z-AODV, the global shortest path must start in cluster 1 and finish in cluster 4. Moreover, when we treat the network as round, the two radiuses through the nodes A and B divide it into two sectors; the intermediate nodes of the global shortest path are almost certainly in the smaller one (including the ZC), as the shaded area shown in Figure 1. By limiting the routing request within this region, the overhead in the routing discovery can be reduced.

Firstly, we have to find a proper method to represent the area and the direction. Based on the DAAM, one device can easily decide its cluster by searching its ancestor in the cluster head list. So, the cluster headers should contain all the network addresses without overlapping. The number of clusters is preset, and the cluster heads are chosen based on the principle mentioned above by the ZC; for a simple case, if the cluster count is equal to the *Cm*, all the routers in depth 1 are selected. The network address of the *k*-th router in depth *d*, according to (2), can be represented as

{\mathit{A}}_{\mathit{k},\mathit{d}}={\mathit{A}}_{\mathrm{parent}}+\mathit{C}\mathrm{skip}\left(\mathit{d}-1\right)\xb7\left(\mathit{k}-1\right)+1

(3)

The *A*_{parent} is the address of its parent, which is also a router. For the depth 1 routers, their parent is the ZC whose address is 0. So, we can use the sequential number *k* to differentiate the clusters. Since the clusters are fan-shaped and not overlapping with a common vertex, each one may have at most two neighbours on both sides. Their relative positioning information can be represented by a sequence of adjacency (SoA). Since the neighbour device information is maintained by the neighbour table for each node, and we can tell which cluster a node belongs to if its network address is given, the SoA can be easily obtained. In Figure 1, nodes 1 and C can find each other in their neighbour tables, so it is the case with nodes D and 3; therefore, it can be concluded that cluster 1 is adjacent to clusters 2 and 3. However, if two clusters are too far apart to communicate, it may lead to the isolation. If all the nodes in one cluster can only find neighbours for the only other cluster, the cluster is isolated on one side, and if the communication is limited in the cluster, it is completely isolated. We use an isolation indicator (II) to announce such situations. Cluster 5 is a completely isolated cluster; the whole SoA of the network is [2,1,3,4,II,5,II]. The SoA is recursive and the last and the first clusters are adjacent by default, so another II is needed at the last.

The ZigBee network is organized as a hierarchical structure based on the DAAM, so the only task in the clustering is to choose the proper heads. Since the nodes in the same depth have different address spaces, it results in the fact that the number of the clusters can be only some specific integers, such as *Cm* and 2 × *Cm* − 1. This may decline the performance of the algorithm. In the hierarchical network, the address subblock overlapping of two routers (not including the ZC) only occurs when one node is the ancestor of the other, and the smaller space must be part of the greater one. So, we may allow the overlapping by making the nodes in the common parts only belong to the cluster with the smaller address space. For the cluster members, if it finds more than one ancestor in the cluster head list, the principle can be simply implemented by joining the cluster with the greatest depth. The above mechanism guarantees that the clusters are not overlapping by any cluster numbers.

In our algorithm, the clustering begins a short time after the network initialized. The ZC is in the charge of deciding the cluster heads (will be explained later). Then, all the devices that may find neighbours from other clusters are asked to report the adjacency to the head. Considering the overhead, if a certain device has announce its neighbour nodes from another cluster, all its descendants may be allowed to not monitor their neighbour tables anymore. Each cluster head may also report its adjacent cluster to the ZC, and the ZC may work out the SoA and announce it to the whole network.During the routing discovery, besides the range and duplication control, all the receiving nodes have to decide whether to rebroadcast or not based on the following principle: the node may find which clusters the source and the destination belong to separately; if possible, it may obtain the intervals between the two clusters in the SoA for both the forward and the reverse sequence. If the node is in the cluster which is part of the shorter path, it may rebroadcast the request; otherwise, the frame is abandoned. As shown in Figure 1, the nodes in clusters 2 and 5 may not participate the routing discovery from nodes 1 to 2. By this method, the routing request rebroadcasting can be roughly limited in the smaller sector. If there is one II in the SoA, the mechanism of calculating the length of the bi-directional sequence is similar, whereas if the II is in the shorter part, it can be deduced that the best link is a polyline whose inflection point is or near the ZC, so only the nodes in the source and target clusters may rebroadcast the routing request. In the case of at least two IIs in the SoA, the network is absolutely segmented into more than two parts. If the start and the end devices are in the same section, the rebroadcasting is limited in the area from the source cluster to the destination one; otherwise, the request can be transmitted within only these two clusters.

Based on the principle above, the direction of the routing request flooding can be well controlled. However, its effectiveness and efficiency are closely related to the geometric parameters of the clusters. The expected clustering should have the similar scales, be uniformly distributed and not overlapping. The original networking method in the ZigBee specification cannot meet these requirements. So, a cluster head decision method is also proposed. Suppose the cluster number is *n*, the ZC has to decide *n* cluster heads, denoted as CH_{
i
}. Based on the ZigBee specification, the LQI is a mandatory term in the neighbour table, and this value could reflect the distance between two devices (is approximately proportional to the square of the space). So, the distance between a node to the ZC, *d*_{
i
}, and that between two nodes, *d*_{i,j}, can be denoted by the LQI of the corresponding links 1/LQI_{
i
} and 1/LQI_{i,j}, respectively. The cosine of the angle between the two lines of the ZC to the devices CH_{
i
} and CH_{
j
}, *α*_{i,j}, can be calculated by the Cosine Theorem, as (4):

\begin{array}{l}cos{\mathit{\alpha}}_{\mathit{i},\mathit{j}}=\left({\mathit{d}}_{\mathit{i}}^{2}+{\mathit{d}}_{\mathit{j}}^{2}-{\mathit{d}}_{\mathit{i},\mathit{j}}^{2}\right)/2\xb7{\mathit{d}}_{\mathit{i}}\xb7{\mathit{d}}_{\mathit{j}}\\ \phantom{\rule{2.5em}{0ex}}=\frac{1}{2}\left(1/{\mathrm{LQI}}_{\mathit{i}}+1/{\mathrm{LQI}}_{\mathit{j}}-1/{\mathrm{LQI}}_{\mathit{i},\mathit{j}}\right)\xb7\sqrt{{\mathrm{LQI}}_{\mathit{i}}\xb7{\mathrm{LQI}}_{\mathit{j}}}\end{array}

(4)

For *n* clusters, there should be *n* lines from the ZC to the cluster heads. We only focus on the angles between two adjacent lines, *α*_{<i,j>}. To a uniformly distributed clustering, each *α*_{<i,j>} is 2*π*/*n*. Based on the neighbour table information, the mechanism of finding the adjacent lines is similar as the one deciding the relative position relationship in the SoA. Among all its neighbours, the ZC will choose *n* nodes that have the minimum mean square error (MSE) of the cos*α*_{
ij
} to be the cluster heads, as shown in (5):

\mathrm{RMSE}={\displaystyle \sum _{\mathit{i},\mathit{j}}}{\left(cos{\mathit{\alpha}}_{<\mathit{i},\mathit{j}>}-cos\frac{2\mathit{\pi}}{\mathit{n}}\right)}^{2}

(5)

Note that due to the limited transmission range of the ZigBee nodes, it is possible that two neighbours of the ZC may not find each other in their own neighbour tables. For that case, it implies that one node is out of the transmission range of the other, the LQI_{i,j} is considered the least value.

However, this method cannot guarantee that every device outside the ZC’s neighbourhood belongs to a certain cluster. To solve this problem, when the *n* candidates are decided, the address space of all the clusters is also obtained. If it cannot cover the whole network, the ancestor nodes that contain the missing region may substitute the origin candidates. In the rare case that part of addresses are still not included, if the *k* routers with lower depths which have the corresponding address subblocks have other child devices, they will be selected as *k* determined cluster heads and the deciding process will be repeated for the other *n*-*k* candidates. If one candidate has missing addresses, but it is the only child of the parent, it is decided as the cluster head and its parent may take part in all the routing discovery as a free node.

There is only one more issue we should consider. The effectiveness of the directional broadcasting algorithm requires that all the newly joining devices have to decide their parents (clusters) based on the minimum distance. The specified mechanism in the ZigBee, which meet this demand, is that a node tries to take the node with the best LQI as its parent. However, when the router with the best LQI has no more addresses to allocate, it may decline the joining request, and the joining node has to be the child of the second best candidate that may be from different clusters. In our algorithm, a node should be aware of the SoA when joining the network. When finding the potential parent refuses its joining, it is only allowed to be the descendant of the declining device by checking the network addresses.

Based on the scheme described in the subsection, the direction of the routing request broadcasting is controlled. In our algorithm, the transmission range is also limited by a similar method as the ZBARD. As a known path, the length of the hierarchical path that passes through the first common ancestor is used as the maximum hops in the routing discovery, and that length can be worked out if the network addresses of the source and destination are given.