# Improving Route Selections in ZigBee Wireless Sensor Networks
## 3 Estimating Link and Route Costs
### Link Quality Indicator (LQI)-Based Estimation Procedure  
In the LQI-based estimation procedure suggested in the ZigBee specifications (Section 3.6.3.1 of [13]), the cost \(c_{z_{1},z_{2}}\) of a node \(z_{1}\) transmitting to a node \(z_{2}\) is estimated from the average LQI of received messages: Let \(T_{arg}\) be the duration of the estimation window; let \(N_{LQI}\) be the number of transmissions from node \(z_{1}\) successfully received at node \(z_{2}\) during the last \(T_{arg}\) seconds; and let \(LQI_{z_{1},z_{2}}(j)\) be the value of the LQI at the \(j^{th}\) received packet. The average LQI at time \(t\) is given by  
\[\overline{LQI}_{z_{1},z_{2}}(t):=\frac{1}{N_{LQI}}\sum_{j=1}^{N_{LQI}}LQI_{z_ {1},z_{2}}(j), \tag{6}\]  
where we highlight that \(N_{LQI}\) includes both broadcast and unicast received messages.  
From the average LQI, the estimated cost \(\hat{c}_{z_{1},z_{2}}^{(LQI)}(t)\) is obtained from the mapping shown in Table 1; i.e., \(\hat{c}_{z_{1},z_{2}}^{(LQI)}(t)\) is obtained from one of seven LQI intervals corresponding to each of the seven possible costs. As the ZigBee specifications suggest (see page 338 of [13]), the LQI intervals of Table 1 should be obtained based on tests on the actual hardware. In here, the LQI intervals were obtained from off-line tests as follows: In a network of only 2 nodes without interference, the distance between the 2 nodes were varied, and at each distance, node \(z_{1}\) transmitted various packets to node \(z_{2}\). For each distance, the average LQI value and the ratio of successful transmissions were computed. The ratio of successful transmissions was then used as \(p_{z_{1},z_{2}}\) in the link cost Equation (2) to obtain the cost for the average LQI value.  
It is important to observe that \(\overline{LQI}_{z_{1},z_{2}}(t)\) is obtained only from successfully received packets; i.e., if the SINR of a packet is so low that the IEEE 802.15.4 receiver cannot decode the packet, then the packet is discarded. No packet is sent to upper layers, and no LQI indication is generated.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Average LQI Interval** & \(\mathbf{\varepsilon}_{z_{1},z_{2}}^{(LQI)}(t)\) & **Average LQI Interval** & \(\mathbf{\varepsilon}_{z_{1},z_{2}}^{(LQI)}(t)\) & **Average LQI Interval** & \(\mathbf{\varepsilon}_{z_{1},z_{2}}^{(LQI)}(t)\) \\ \hline \(239<\overline{LQI}_{z_{1},z_{2}}(t)\leq 255\) & 1 & \(185<\overline{LQI}_{z_{1},z_{2}}(t)\leq 195\) & 4 & \(\overline{LQI}_{z_{1},z_{2}}(t)\leq 170\) & 7 \\ \(206<\overline{LQI}_{z_{1},z_{2}}(t)\leq 239\) & 2 & \(174<\overline{LQI}_{z_{1},z_{2}}(t)\leq 185\) & 5 & & \\ \(195<\overline{LQI}_{z_{1},z_{2}}(t)\leq 206\) & 3 & \(170<\overline{LQI}_{z_{1},z_{2}}(t)\leq 174\) & 6 & & \\ \hline \hline \end{tabular}
\end{table}
Table 1: Mapping between the average link quality indicators (LQIs) of transmissions from a node \(z_{1}\) and successfully received at node \(z_{2}\) (\(\overline{LQI}_{z_{1},z_{2}}(t)\)), and the estimated link cost \(\hat{c}_{z_{1},z_{2}}^{(LQI)}(t)\).  
As in the LS-based procedure, the cost estimate \(\hat{c}_{z_{1},z_{2}}^{(LQI)}(t)\) is obtained at the receiving node \(z_{2}\); the latest estimate is transmitted to node \(z_{1}\) when node \(z_{2}\) transmits its LS messages; the route cost  
\[\hat{c}_{z_{1},\ldots,z_{K}}^{(LQI)}(t)=\sum_{i=1}^{K-1}\hat{c}_{z_{i}z_{i+1}}^{ (LQI)}(t), \tag{7}\]  
is computed in a distributed manner, and \(\hat{c}_{z_{1},\ldots,z_{K}}^{(LQI)}(t)\) varies over time due to randomness in LQI measurements.