## 3 Alternative Paths for Message Streams in Cluster-Tree Wireless Sensor Networks
### Alternative-Path Activation Algorithm
In case all RP nodes are successfully allocated, the ARounD-act algorithm defines a set of _ARounD_Offsets_ (communication schedule), which correspond to the activation time for each RP node (lines 5-7 in Algorithm 2). As a consequence, each RP node will be awake at its respective _ARounD_Offset_ time to perform the ARounD communication. This communication is then performed without contention, node-to-node, from the source node until reaching the destination node. Importantly, when activating a new alternative path, ARounD algorithms consider the current paths in order to avoid overlapping communication. Moreover, as each repeater node has its own activating times for each message stream, multiple ARounD paths can use common repeater nodes without generating interferences during the communication. ```
input :\(MStreamm_{m}\): \([SRC_{m},\,DEST_{m}]\); \(ARounD\_{Pathm}\); // Shortest inter-cluster path \(cluster2 cluster_{m}\); // Set of pairs of ARounD clusters for \(ARounD\_Pathm\) RPnodes; // Set of Repeater nodes Scheduling; // Set of cluster IDs of the cluster-tree scheduling output :\(ARounD\_Offsets\); // Set of Offsets for repeater nodes
1 Base = Scheduling(initial); // Receive the ID of the first scheduled cluster
2 for(each pair\([RP_{i}\to RP_{j}]\in RPnodes\))do
3 while(Base < Scheduling(end))do
4 if(get_Cluster(\(RP_{j}\)) and get_Cluster(\(RP_{j}\)) are not overlapping with Base)then
5\(ARounD\_Offsets_{i,j}\) = get_Offset(Base);
6\(RP_{i}(SENT)\) = get_Offset(Base);
7\(RP_{j}(RECEIVER)\) = get_Offset(Base);
8 Base++;
9 breakbreak;
10 else
11 Base++;
12// If reaching the end of the cluster-tree scheduling. 13 if(Base == Scheduling(end))then
14 return(Not possible to allocate all repeater nodes);
15 return(ARounD_Offsets);
```  
**Algorithm 2**_Alternative-Path Activation_ (ARounD-act) Algorithm  
```
input :\(MStreamm_{m}\): \([SRC_{m},\,DEST_{m}]\); \(ARounD\_Pathm\); // Shortest inter-cluster path \(cluster2 cluster_{m}\); // Set of pairs of ARounD clusters for \(ARounD\_Pathm\) RPnodes; // Set of Repeater nodes Scheduling; // Set of cluster IDs of the cluster-tree scheduling output :\(ARounD\_Offsets\); // Set of Offsets for repeater nodes
1 Base = Scheduling(initial); // Receive the ID of the first scheduled cluster
2 for(each pair\([RP_{i}\to RP_{j}]\in RPnodes\))do
3 while(Base < Scheduling(end))do
4 if(get_Cluster(\(RP_{j}\)) and get_Cluster(\(RP_{j}\)) are not overlapping with Base)then
5\(ARounD\_Offsets_{i,j}\) = get_Offset(Base);
6\(RP_{i}(SENT)\) = get_Offset(Base);
7\(RP_{j}(RECEIVER)\) = get_Offset(Base);
8 Base++;
9 break;
10 else
11 Base++;
12
13// If reaching the end of the cluster-tree scheduling. 14 if(Base == Scheduling(end))then
15 return(Not possible to allocate all repeater nodes);
16
17 return(ARounD_Offsets);
```  
**Algorithm 3**_Alternative-Path Activation_ (ARounD-act) Algorithm  
In order to reduce the configuration overhead, the ARounD path is automatically maintained during a time pre-defined during the configuration phase. After this period, the ARounD path will be terminated, unless a new request for message stream communication is performed.