# Efficient Actor Recovery Paradigm for Wireless Sensor and Actor Networks
## 4 Problem Statement and Optimized Deterministic Actor Recovery System Model
### Optimized Deterministic Actor Recovery System Model
```
\(\{\)\(F_{pr}\): Pre-Failure; \(F_{po}\): Post-Failure; \(R_{pr}\): Recovery process; \(N_{c}\): Critical node; \(N_{b}\): Backup node; \(A_{p}\): Primary actor; \(M_{hb}\): Message heartbeat; \(N_{s}\): Sink node\(\}\)
1.Input (\(N_{c}\); \(N_{b}\); \(A_{p}\))
2.Output (\(R_{pr}\); \(F_{pr}\); \(F_{po}\))
3.Set \(A_{p}//\)Number of actor nodes are set as primary actors in the network
4.\(N_{s}\)broadcasts \(M_{hb}//\)Sink node broadcasts the message to all primary actor nodes
5.If\(A_{p}\
eq F_{pr}\)then//
6.Determine \(N_{c}//\)Initiate critical node discovery process
7.If\(\forall\ A_{p}\): \(A_{p}\in N_{c}\)then
8.\(N_{b}\)assigns \(N_{c}\)
9.Set \(N_{c}=M_{hb}\)
10.endif
11.If\(M_{hb}\)NotDelivered \(N_{c}\)then
12.Set \(N_{b}\)for data delivery
13.endif
14.Process \(A_{p}\ \exists\ R_{pr}//\)Primary actor node recovery process is conducted
15.endif
```  
**Algorithm 2**Node Monitoring and Critical Node Detection (NMCND) Process  
We use node monitoring process to monitor the node pre-failure causes, the post-failure causes and allocates the recovery options. Once each critical actor node picks a suitable backup, then it is informed through regular heartbeat messages (Special signals are sent to neighbor node to play a role as backup node for critical node). Furthermore, the pre-designated backup initiates monitoring its primary actor node through heartbeats. If a number of consecutive heartbeats are missed from the primary actor, then it notifies that the primary actor failed. Thus, a backup node replacement process is started as given in algorithm 1. Before substantiating the post failure process, we must ensure that connection is not interrupted because of the network. In addition, any redundant action of the network must be controlled to avoid any possible increase of the network overhead. The pre-failure backup node process is given in Algorithm 2. As shown in Algorithm 2, \(A_{p}\) represents the number of actor nodes in the network. Then, the sink node \(N_{s}\) broadcasts the message to all primary actor nodes to determine pre-failure actor nodes. If primary actor is not identified as pre-failure, then the process of determining the critical actor node will be started in order to choose the backup node. Next, the critical node discovery process is initiated. For each primary node, if the primary node is found as critical node then this node will be defined as critical node \(N_{c}\) and a backup node \(N_{c}\) selection is assigned. The critical node will broadcast a message to its neighbors which includes the information of its backup node. This information is stored by the neighbors and it is used when starting the network recovery process in case the neighbors detect the failure of their critical actor neighbor. If consecutive heartbeat messages are not received from the critical node, then back node starts replacing the critical node to avoid any kind of packet-forwarding delay. In addition, neighbors of the critical node will use stored information to communicate with the backup node in order to restore connectivity. In conclusion, the recovery process is conducted. After the node monitoring process is executed, we proceed further with checking the backup assignment and the critical back up assignment of the nodes. This allows to maintain the network connectivity without generating any disjoint procedure of the network. The possibility of the recovery depends on the cut vertex node. If the backup is a non-critical node, then it simply substitutes the primary actor node, and the recovery process is initiated to confirm the backup actor node. If the backup is also a critical node, then a cut vertex node replacement is completed. The pre-assigned backup actor node instantly activates a recovery process once it senses the failure of its primary actor node. The complete node monitoring including failure, recovery and replacement processes are depicted in Figure 4. In complete node monitoring process, first, the node identification process is initiated.