**3.3. Region failure algorithms**

8 Will-be-set-by-IN-TECH

(a) Network Topology (b) Routing process

(c) Region 1 (d) Region 2

Similarly, For the failure *Region*2 shown in Fig. 4d, we apply Eq. 2 to get the weight of this region-failure as follows. For the calculation of the node weight *nw*(*si*) based on Eq. 3,each node in the disconnected partition of the topology is assigned a value of 1 except each of the mission-critical nodes *<sup>A</sup>* and *<sup>B</sup>* will have the value of 32. Hence, <sup>∑</sup>*si*∈*dsx*,*<sup>y</sup> nw*(*si*) = <sup>64</sup>+ <sup>6</sup> = 70. For the calculation of the path weight *pw*(*sj*) we use Eq. 4. As the failed nodes within the region-failure are carrying mission critical information of node *A* and *B*, we have to find the weight of each node on a mission-path to the sink node. The estimation of the *pw*(*sj*) is performed as follows. first, each mission-critical node such as *A* and *B* receives a weight of 32 based on equation 4. Since the node *B* has only two parent nodes (node *F* and node *E*), each of them will receive half of the weight of the node *B* (i.e 16). Node *D* will receive its *pw*(*D*) weight of 24 which is the sum of 8 (half of the *pw*(*F*) as node *F* has two parent nodes) and 16 (the *pw*(*E*) as node *E* has only one parent node) received from its child nodes *F* and *E*, respectively. In the same way, Node *G* will have a *pw*(*G*) weight of 8 ( half of the *pw*(*F*) of its child node *F*), Node *C* will have a *pw*(*C*) weight of 52 (the sum of *pw*(*G*) , *pw*(*A*), and half of *pw*(*D*)), Node *H* will receive a *pw*(*H*) of zero since the node *H* is not on a mission-path, Node *I* will receive a *pw*(*I*) weight of 12 which is half of the *pw*(*D*) weight of its child node *D*, Node *J* will receive a *pw*(*J*) of 64 that is the sum of *pw*(*I*) and *pw*(*C*). This process continues in the same way up to the sink node as shown in Fig. 4d. Then,

**Figure 4.** Calculations of the worst-case region-cut

In this section we introduce the main algorithms used to find out the worst-case region-failure under the single and dual region-failure scenarios in Section 3.3.1 and Section 3.3.2, respectively.

Hereafter, we present the main algorithms used in our model. The algorithm shown in Fig.5 finds all sensors within a region-failure. The algorithm depicted in Fig. 6 removes the failed sensors from the network topology (*nt*). The algorithm shown in Fig. 7 finds all paths between a given source/destination pair.


**Figure 5.** Find sensors within a region-failure Algorithm

The algorithm shown in Fig. 5 demonstrates how to find sensor nodes located within the region-failure. The input parameters to this algorithm are the network topology *nt*, center (*i*,*j*) and radius *r* of the region-failure. In this algorithm, we first calculate the distance *d* from the center of region failure to the sensor node. If d is less than the radius of region-failure, then the sensor is located within the failed region.

The algorithm shown in Fig. 6 presents our strategy for removing a sensor node from the routing table (*rt*) of all sensors in the network field. The input parameters to this algorithm are the network topology *nt*<sup>1</sup> and the list *rs* of sensor nodes to be removed. In this algorithm we perform the following steps. First, for each sensor node in the removed sensor list (*rs*) we search for that sensor id. If the sensor ID. is found in any routing table of a sensor node that


**Figure 6.** Remove sensors from the routing tables algorithm

belongs to the network topology, then it is removed from the routing table and the network topology is updated with the changes made.


**Figure 7.** Find All Paths from *s* to *d* Algorithm

The algorithm shown in Fig. 7 presents how to check if a sensor node *s* is still connected or not after a region-failure happens. In other words, we need to find all paths *p* from the given node *s* to the destination node *d* and add these paths to the empty list *paths* of paths. This is accomplished by checking first if the path already exists in the paths list *paths*. If it does not exist, a path search is initiated from each parent of the node *s*. If a path is found, the search is terminated, the found path is added to the paths list and the node *s* is considered a connected node. On the other hand, if no path exists from the parent node of node *s*, then a path search is initiated from the sibling node of node *s*. Finally, if no path is found from both the parent and the sibling nodes of node *s* the node is marked as disconnected node.

### *3.3.1. Single region-failure*

The algorithm shown in Fig. 8 demonstrates how to estimate the number of disconnected nodes due to a single region-failure. The input parameters to this algorithm are the network topology *nt*, the radius of the failure region *r*, the increment value Δ*r* for the radius *r*, the threshold of disconnected nodes *nsth*, and the network field's length *nfl* and width *nfw*. In this algorithm, we first generate a failure region with radius *r*. then we find all sensors located within the region by the algorithm shown in Fig. 5. Sensors located within the failure region are then removed from the routing tables of all nodes in the network topology by executing the algorithm shown in Fig. 6. For the rest of the remaining sensors, we investigate the availability of a path from each node to the sink node by carrying out the algorithm depicted in Fig. 7. If a path is found the node is marked as connected node and disconnected otherwise. then we calculate the number of disconnected nodes due to the failure region. The above mentioned scenario is repeated by incrementing the coordinates of center of the region-failure until th whole topology is scanned by region-failures. Finally, Equation 1 is applied to estimate the worst case region-failure.


**Figure 8.** Algorithm for Finding the number of disconnected nodes under single region-failure

### *3.3.2. Dual region-failure*

10 Will-be-set-by-IN-TECH

 *sn nt*<sup>1</sup> *& sn rt s*

*// rt refers to a routing table nt1 ĸ s rt sn nt1*

*nt1 ĸ nt*<sup>1</sup> *ŀ s // remove s from the nt1*

belongs to the network topology, then it is removed from the routing table and the network

*7 findAllPathsAlgorithm paths p sn sn, d*

The algorithm shown in Fig. 7 presents how to check if a sensor node *s* is still connected or not after a region-failure happens. In other words, we need to find all paths *p* from the given node *s* to the destination node *d* and add these paths to the empty list *paths* of paths. This is accomplished by checking first if the path already exists in the paths list *paths*. If it does not exist, a path search is initiated from each parent of the node *s*. If a path is found, the search is terminated, the found path is added to the paths list and the node *s* is considered a connected node. On the other hand, if no path exists from the parent node of node *s*, then a path search is initiated from the sibling node of node *s*. Finally, if no path is found from both the parent

The algorithm shown in Fig. 8 demonstrates how to estimate the number of disconnected nodes due to a single region-failure. The input parameters to this algorithm are the network topology *nt*, the radius of the failure region *r*, the increment value Δ*r* for the radius *r*, the threshold of disconnected nodes *nsth*, and the network field's length *nfl* and width *nfw*. In this algorithm, we first generate a failure region with radius *r*. then we find all sensors located within the region by the algorithm shown in Fig. 5. Sensors located within the failure region

 *nt1 // return the updated network topology*

*paths ĸ paths p // the path p is added to the set of paths*

*sn s sn p // to prevent cycle*

*s swr*

*removefailedSensorsAlgorithm nt1, swr*

**Figure 6.** Remove sensors from the routing tables algorithm

*findAllPathsAlgorithm paths p s, d s d // A path p is found*

 *paths* 

and the sibling nodes of node *s* the node is marked as disconnected node.

topology is updated with the changes made.

**Figure 7.** Find All Paths from *s* to *d* Algorithm

*3.3.1. Single region-failure*

Under dual region-failure scenario, we propose the following algorithm shown in Fig. 9 to estimate the number of disconnected nodes within the given network topology.

The algorithm shown in Fig. 9 demonstrates our strategy to determine the number of disconnected nodes under dual region-failures scenario.The input parameters to this algorithm are the same as that of a single region failure shown in Fig. 8. In this algorithm, at the beginning, we follow similar steps to that used to find the number of disconnected nodes of a single region failure where we first generate a failure region with radius *r*. then we


**Figure 9.** Algorithm for Finding the number of disconnected nodes under dual region-failures

find all sensors located within the region by the algorithm shown in Fig. 9. Sensors located within the failure region are then removed from the routing tables of all nodes in the network topology by executing the algorithm shown in Fig. 6. The above mentioned steps are repeated for the second region-failure. Now, we have come up with a network topology without the failed nodes due to the dual region-failure. Then, we examine the path availability from each node in the network topology to the sink node by executing the algorithm depicted in Fig. 7. If no path is available from a node to the sink node the node is marked as a disconnected node. On the other hand, if a path is found the node is marked as connected node. then we calculate the number of disconnected nodes due to the failure region. The above mentioned scenario is repeated by iterating all the possible combinations of the regions centers until the whole topology is visited by region-failures. As the number of disconnected nodes due to dual region-failures is usually large, we use a threshold such that we get the dual region-failures that lead to a number of disconnected nodes greater than the predefined threshold.

Finally, Equation 1 is applied to estimate the worst case region-failure.
