# Design and Analysis of an Efficient Energy Algorithm in Wireless Social Sensor Networks
## 6 Checkpointing and Recovery Algorithms
### Algorithm for Failure Recovery
The size of one checkpoint and one message log are set to 2 KB and 50 B, respectively. Table 1 shows the parameters of this experiment. This experiment plans to compare the proposed hybrid checkpointing protocol (HCP) with the pure Synchronous Checkpointing Protocol (SCP) and the pure Asynchronous Checkpointing Protocol (ACP). In the pure synchronous checkpointing strategy, a process sends the coordination request to the related processes in same cluster and different clusters after received \(K\) messages. The process firstly takes an uncertain checkpoint, and then turns the uncertain one to certain one after the coordination is successful. In the pure asynchronous checkpointing strategy, a process takes a checkpoint independently after received \(K\) messages. According to the characteristics of ad hoc networks, this experiment adopts the following performance indexes:

1. Average Checkpoint Time (ACT): average time for finishing the checkpointing procedure;
2. Average Recovery Time (ART): average time for finishing the rollback recovery operation;
3. Average Storage Size (ASS): average disk space that is occupied by the checkpoints of \(MH\);
4. Average Additional Messages (AAM): average number of messages for checkpoints coordination and rollback recovery despite the normal communication messages;
5. Average Cluster head Forwarded Messages (ACFM): average number of messages forwarded by the cluster head. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Description** & **Value** \\ \hline \(F\) & Failure probability & 5–20\% \\ \(M\) & Average hops between MHs & 2–4 \\ \(K\) & Message threshold for checkpoint & 10 \\ \(SCN\) & Successive checkpoints number & 4–16 \\ \(R\) & Ratio of SM number to DM number & 0.25–4 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parameters for Experiments. ### Experiment Results and Analysis

This experiment divides to two parts. The first part is to test the message threshold for checkpoint \(K\) in the experiment environment. The second part is to test the _ACT_, _ART_, _ASS_, _AAM_ and _ACFM_ of the three protocols under different conditions. #### 8.2.1 Experiment 1 Selection of \(K\)

The checkpoint frequency of a process is decided by the message threshold \(K\) in HCP. If \(K\) enlarges, then the number of checkpoints deceases and the _ART_ increases. What is more, if \(K\) increases, then the logs between checkpoints increase. Because the storage overhead of checkpoints is much larger than the average storage overhead of message logs, so the storage overhead will reduce as \(K\) increases. For the additional messages, the checkpoint frequency deceases as \(K\) increases and so the additional messages for checkpoint coordination reduce, but the additional messages for rollback recovery augment, so the _AAM_ does not maintain an absolute downtrend as \(K\) augments. Hence, this experiment takes the lower of _AAM_ as the main parameter for selection of \(K\). Figure 9 shows the _AAM_ for varying values of \(K\) under different failure probabilities. It can be seen that the _AAM_ under different failure probabilities is the least when \(K\) is 10. Therefore, the follow-up experiments choose this value of \(K\) to analyze and compare. #### 8.2.2 Experiment 2 Test of _Acct_

Figure 10 shows the _ACT_ for varying ratios of SM number to DM number (\(R\)). It can be seen that because the checkpoints in ACP do not remain coordinated with other processes and the processes just need to store the current states of processes, so the _ACT_ does not change at all. However, the _ACT_ of HCP and SCP reduces as \(R\) augments. For the HCP, the number of processes that participate in the coordination decreases when the processes satisfy the checkpoint condition as \(R\) increases, so the _ACT_ reduces as \(R\) augments. For the SCP, the number of DM\({}_{\text{s}}\) diminishes as \(R\) increases and it means that the processes in different clusters which also have to join the coordination reduction. Hence, the _ACT_ decreases as \(R\) augments.