# La-CTP: Loop-Aware Routing for Energy-Harvesting Wireless Sensor Networks
## 5 Design of La-CTP
### Handling Loops and Invalid Routes  
From the experiment results shown in Figure 4, we can observe that the beacons with too long interval are unable to \"awake\" the nodes that have been devoured by loops or are joining some loop, although the looping sub-network is not totally separated from the main network topology. CTP employs the Trickle scheme in route beaconing. Specifically, a node will exponentially double its local beacon interval, if it does not experience the parent update, the significant link dynamics, and the request from neighbors for connection. For example, Figure 4b shows that after joining the loop formed by nodes \(A\), \(B\), and \(C\), node \(Y\) thinks it has already achieved a stable routing and then it doubles its beacon timer. Meanwhile, \(S\), the sink node, also slows its beaconing in route maintenance because no  
Figure 6: Illustration of a loop caused by conditional expression C3 of CTP which holds true after node \(Y\) (parent of \(X\)) is removed out. The numbers near by the node and along the link are the path ETX and the link ETX values, respectively. traffics arrive by then. Now, \(S\) and \(Y\) both broadcast beacons with longer and longer intervals over unreliable channel; the behavior of these two nodes almost devastates the possibility of recovering their re-connection in a short term. CTP assumes that loops, though unavoidable, are not too many during network; and thus its forwarding engine mainly takes into account the efficiency of network resource, rather than the assisting approaches to resolving loops. The proposed La-CTP uses a more loop-aware timer adjustment scheme in route beaconing, which is described in Algorithm 2. As a well-engineered protocol, CTP synergistically integrates the 4-bit link estimator, the Trickle beaconing scheme, and the ETX-based routing gradient computation. La-CTP follows the structure and the pattern of CTP and only replaces the Trickle scheme of CTP with a proactive and adaptive scheme of adjusting beacon timer. The experiment results show that La-CTP can effectively unlock the loops and recover forwarding paths with low overhead. Algorithm 2 involves three event-driven processes; their critical jobs are to adaptively manipulate parameter \(T_{b}\), the period of the beacon timer--when the timer goes off, node will immediately broadcast beacons. ```
0:\(T_{b}\): the period of the current beacon timer; \(\Delta t\): the interval between the current time and the time of receiving last packet \(\Diamond\) upon the traffic checking timer being fired at \(u\) if\(\Delta t\geq\) NO_TRAFFICthen post the task adjustBeaconTimer(MIN_INTERVAL) endif return \(\Diamond\) upon receiving a packet at \(u\) from \(v\) if\(\Delta t<\) NO_TRAFFICthen post the task adjustBeaconTimer(\(T_{b}\times\)SCALE_RATIO) endif return \(\Diamond\) upon receiving a beacon message at node \(u\) from its neighbor \(v\) Extract this beacon message if\(v\) is seeking a valid route then post the task adjustBeaconTimer(MIN_INTERVAL) endif if\(v\) has already detected loop then post the task adjustBeaconTimer(\(T_{b}/\)SCALE_RATIO) endif return task adjustBeaconTimer(\(t\)) if\(t<\)MIN_INTERVALthen \(t=\) MIN_INTERVAL endif \(T_{b}\gets t+\tau\) /* \(\tau\) is chosen randomly from [0, MIN_INTERVAL] */  Stop the current beacon timer and start a new one that will be fired every \(T_{b}\) return
```  
**Algorithm 2** Beacon timer adjustment of La-CTP  
First, if a node, say \(u\), has not received in-going traffics for a longer time, it will shorten its beacon timer to MIN_INTERVAL such that it can proactively catch on to the local network status. By doing so, \(u\) could save those neighboring nodes already lost in loops as soon as possible, by telling them about \"a better way exists\".