# La-CTP: Loop-Aware Routing for Energy-Harvesting Wireless Sensor Networks
## 4 Dissection of CTP in EH-WSN
### Experiment T-I  
Experiment T-I involved five wireless nodes and ran for 1000 s. Figure 3 shows several chronological snapshots of T-I; the most left subfigure shows the initialized network topology where node \(S\) is the root (or the sink) of collecting the data generated by nodes \(A\), \(B\), \(C\), and \(X\) every 10 s. Especially, we set a lossy and time-varying link between \(X\) and \(S\) (the link PRR is 30% on average), in order to examine the effect of link quality attenuation on its upstream data routing. When T-I went to the 265 th second, the radio module of node \(X\) was turned off, i.e., it departed from the network. Next we will chronologically describe what happened in T-I. [T-I: 8.764 s]: at this time, the routing tree structure has been established and CTP runs normally without any routing inconsistency--each child node is higher than its parent node in terms of ETX value, as can be seen from the ETX values in Figure 3 that are listed below the snapshot of T-I: 8.764 s.  
[T-I: 36.849 s]: during the quality of link \(l_{XS}\) deteriorates continuously from the beginning till this time point, the route ETX of node \(X\) increases from 3 to 14.6. When this time point is hit, \(X\) first receives a packet sent out by \(A\) and finds that its local route ETX value, ETX(\(X\)) is greater than its child's route ETX value, ETX(\(A\)) = 4.7, indicating that routing inconsistency occurs. CTP is designed to determine the loop occurrence by comparing ETX values. In detail, when a packet arrives, the receiving node will immediately check the route ETX field of this packet; if the in-packet ETX is less than the local route ETX, the receiving node will conclude that there exists a loop or a routing inconsistency; and then it will immediately launch its Trickle-based adaptive beaconing scheme to notify its neighbors, in hope of repairing the broken forwarding path. Specifically, node \(X\) will broadcast its routing control beacons 64 ms after it detects routing inconsistency. After node \(A\) receives the beacon from \(X\), therefore, \(A\) decides to update its parent by looking up its routing table locally maintained. Now, the routing table of \(A\) has two potential parents, \(B\) and \(C\). However, \(A\) will choose \(C\) as its new parent because \(A\) knows that \(B\) is its child. In addition, then, \(A\) updates its route ETX from 4.7 to the value of 9.7, which equals the sum of the route ETX of \(C\), 6.7 and the link ETX of link \(l_{CA}\), 3.0. [T-I: 36.989 s]: just after finishing parent update, node \(A\) receives a packet from \(B\) and detects a loop event, because ETX(\(A\)) = 9.7 \(>\) ETX(\(B\)) = 5.7. [T-I: 38.036 s]: before this moment, ETX(\(X\)) has changed from 18.4 down to 15.8. Once the decrease in local route ETX is beyond 2.0, the node must broadcast its latest routing status in its neighborhood, as needed by CTP. At this moment, node \(A\) has detected loops and decides to update its parent; and finally, \(A\) chooses \(X\) as its new parent and updates its local route ETX(\(A\)) with the value of 17.5. Very close behind the routing beacons of \(A\) triggered by the parent update event, nodes \(B\) and \(C\) also update their routes. From now till the time point of 265 s, the routing tree works smoothly--everything is under the control of CTP. [T-I: 265.650 s]: we turn off the radio of \(X\) at time point 260 s; in other words, the departure of \(X\) from the current network makes \(A\) lose the next hop. Now, \(A\) has two potential parents to forward its data, nodes \(B\) and \(C\). However, \(A\) will update its parent with \(C\), instead of \(B\), because \(A\) knows \(B\) is its child. Hence, \(A\) finally updates its route ETX with the value of 20.7, by referring to the current ETX(C). Obviously, loop ensues without any hesitation and can never be unlocked by CTP until T-I ends at time point 1000 s.  
By comparing the local ETX and the ETX of the packet received, node \(A\) can detect the routing inconsistency the moment it receives a packet from \(B\).