# Improving Route Selections in ZigBee Wireless Sensor Networks
## 6 Proposed Link Cost Estimation and Modified Route Selection Procedure
### Link Cost Estimation Procedure
Given the difficulty of applying the ideal estimator, we propose the following practical estimator (The reason for referring to our procedure with the superscript \(URR\) will become clear shortly. ): let \(N_{z_{1},z_{2}}^{(u),ack}(t)\) be the number of times that \(z_{1}\) receives the MAC ACK packet from \(z_{2}\) in the last \(T_{avg}\) seconds; and \(z_{1}\) estimates \(p_{z_{1},z_{2}}\) with  
\[\hat{p}_{z_{1},z_{2}}^{(URR)}(t)=\frac{N_{z_{1},z_{2}}^{(u),ack}(t)+\overline{p }_{z_{1},z_{2}}^{(LS)}(t)\cdot N_{z_{1}}^{(LS),tx}(t)}{N_{z_{1},z_{2}}^{(u),tx} (t)+N_{z_{1}}^{(LS),tx}(t)}, \tag{11}\]  
where \(\overline{p}_{z_{1},z_{2}}^{(LS)}(t)\) is the highest probability of successful transmissions that maps into the \(\hat{c}_{z_{1},z_{2}}^{(LS)}(t)\) received from \(z_{2}\). Table 2 lists \(\overline{p}_{z_{1},z_{2}}^{(LS)}(t)\) from each of the seven possible costs. The values listed were obtained by using Equation (2). From \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\), node \(z_{1}\) uses Equation (2) to generate the estimate \(\hat{c}_{z_{1},z_{2}}^{(URR)}(t)\). Although imperfect, the estimator \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\) is able to combine the information from both LS and unicast transmissions and adjust the importance of unicast transmissions as they increase. In other words, before \(z_{1}\) sends any unicast transmission to node \(z_{2}\), \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)=\overline{p}_{z_{1},z_{2}}^{(LS)}(t)\), which maps in the same link cost as if we were using the LS-based procedure. When \(N_{z_{1},z_{2}}^{(u),tx}(t)\gg N_{z_{1}}^{(LS),tx}(t)\), \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\approx N_{z_{1},z_{2}}^{(u),ack}(t)/N_{z_{1},z _{2}}^{(u),tx}(t)\) and the influence of \(\overline{p}_{z_{1},z_{2}}^{(LS)}(t)\) diminishes. And as \(N_{z_{1},z_{2}}^{(u),tx}(t)\rightarrow\infty\), the variance of \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\to 0\). It should be mentioned, however, that \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\) is a biased estimate because it estimates a probability different than \(p_{z_{1},z_{2}}\). Because \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\) uses \(N_{z_{1},z_{2}}^{(u),ack}(t)\), as \(N_{z_{1},z_{2}}^{(u),tx}(t)\) grows, \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\) converges to \(p_{z_{1},z_{2}}\cdot p_{z_{1},z_{2}}^{(ack)}\), where \(p_{z_{1},z_{2}}^{(ack)}\) is the probability of successful transmission of the MAC ACK from node \(z_{2}\) to node \(z_{1}\). This means that a router routes costs and decisions will be taken not based on estimates of \(p_{z_{1},z_{2}}\), but instead on estimates of \(p_{z_{1},z_{2}}\cdot p_{z_{1},z_{2}}^{(ack)}\). This is, however, not a problem, because the MAC ACK is needed to complete a transmission in the IEEE 802.15.4 MAC and if \(p_{z_{1},z_{2}}^{(ack)}\ll p_{z_{1},z_{2}}\), then sending packets through node \(z_{2}\) would not be a good choice. Note further that \(\overline{p}_{z_{1},z_{2}}^{(LS)}(t)\cdot N_{z_{1}}^{(LS),tx}(t)\) is a biased estimate for \(N_{z_{1},z_{2}}^{(LS),rx}(t)\); in fact, it gives an upper bound for \(N_{z_{1},z_{2}}^{(LS),rx}(t)\). This follows because of the 3-bit quantization of cost estimates, which means that there is a range of probabilities that map into the same cost \(\hat{c}_{z_{1},z_{2}}^{(LS)}(t)\) received from node \(z_{2}\); therefore, there is a range of possible \(N_{z_{1},z_{2}}^{(LS),rx}(t)\) for a given \(\hat{c}_{z_{1},z_{2}}^{(LS)}(t)\) received at node \(z_{1}\). The lower bound for \(N_{z_{1},z_{2}}^{(LS),rx}(t)\) reduces \(\hat{p}_{z_{1},z_{2}}^{(URR)}(t)\), and thus, increase \(\hat{c}_{z_{1},z_{2}}^{(URR)}(t)\); likewise, using the upper bound for \(N_{z_{1},z_{2}}^{(LS),rx}(t)\) decreases \(\hat{c}_{z_{1},z_{2}}^{(URR)}(t)\). Thus, using any value lower than \(N_{z_{1},z_{2}}^{(LS),rx}(t)\) may cause \(\hat{c}_{z_{1},z_{2}}^{(URR)}(t)\) to be higher than it would be if \(N_{z_{1},z_{2}}^{(LS),rx}(t)\) are known at node \(z_{1}\).