# La-CTP: Loop-Aware Routing for Energy-Harvesting Wireless Sensor Networks
## 5 Design of La-CTP
### Depressing Loops  
In CTP, a node makes a decision on parent update according to the logic OR of three conditions, which is shown in Algorithm 1 and the three conditions are denoted by C1, C2, and C3, respectively. The routing engine component of CTP maintains two parameters: currentEtx and minEtx. Once the task of updating route is triggered, the CTP routing engine will immediately scan its routing table to obtain the latest neighbor information, and then determine a new parent. Parameter currentEtx represents the latest ETX value of the current parent, and parameter minEtx, the minimum ETX value that the current node can turn to so far. The three conditional expressions map three different cases. C1 is designed to create neighboring relationship and find the first desirable parent in the network initialization. C2 demands the routing engine to quickly respond to the congestion occurring at the parent. C3 guarantees that the routing engine could always find a best route, without experiencing too much frequent parent updates. Specifically, the two constants of MAX_METRIC and PARENT_SWITCH_THRESHOLD are empirically set to be 0 xffff and 1.5 in CTP, respectively. ```
\(\lozenge\) upon the route updating triggered at node \(u\)  Update the local routing table  currentEtx = the node ETX of parent of \(u\) (parentEx) + the link ETX of the link between \(u\) and its parent  minEtx = the minimum node ETX value provided by current neighbors \(v\) = the neighbor node that can achieve minEtx  minLinkK = the link ETX value of the link between \(u\) and \(v\) if currentEtx == MAX_METRIC or /* condition C1 */  minEtx < parentEtx + 1.0 or /* condition C2 */  minEtx + PARENT_SWITCH_THRESHOLD < currentEtx /* condition C3 */ then  parent = \(v\)  currentEtx = minEtx + minLinkEtx endif return
```  
**Algorithm 1** Determination of parent update in CTP  
In experiments we traced the valuation of these three logic expressions; however, we found that C3 overwhelmingly dominates the overall logic OR result in the if statement of Algorithm 1, regardless of whether energy-harvesting nodes are involved. In particular, almost all the loops in experiments running CTP are exactly resulted by the ineffective parent updates determined by the valuation of C3. Figure 6 shows how the C3 condition of CTP gives rise to a loop in parent updating. At time \(t_{1}\), node \(X\) has three neighbors in its routing table, nodes \(Y\), \(A\), and \(B\); and the parent of \(X\) is \(Y\). At time \(t_{2}\), \(Y\) has left the network and then \(X\) loses its parent. Continually-failed retransmissions at \(X\) will increase the ETX value of link \(l_{X,Y}\) from 1.5 to 7.5, which will finally trigger the CTP routing engine at \(X\) to start finding a new route. Before examining the local routing table to determine the neighbor with the minimum path ETX, \(X\) will first update its routing information. At time \(t_{2}\), parameter currentEtx of \(X\) is changed into 10.6, because \(X\) thinks that the path ETX provided by its parent, \(Y\) is still 3.1. By checking the routing entries one by one, \(X\) can figure out which neighbor is the best and which neighbor should be evicted from its routing table. At time \(t_{2}\), \(X\) believes that \(B\) will be possibly its best forwarder, which can provide a path ETX value of \((2.0+7.0)=9.0\); \(X\) will not choose \(A\) as its parent because it can easily know that \(A\) is its previous hop. At time \(t_{3}\), the C3 conditional expression is satisfied, so \(X\) chooses \(B\) as its new parent--a loop is formed. Even though \(X\) will update its currentEtx with a smaller value, 9.0, it will surely detect loops once it receives packets sent out by  
node \(A\). Nevertheless, such loops cannot be easily unlocked due to the struggling increases of ETX values at all the three in-loop nodes (see the analyses for Figure 3). In this paper, we propose a slightly-different but effective condition for deciding the parent updating.