# An Enhanced Mechanism for Fault Tolerance in Agricultural Wireless Sensor Networks
## 5 Fault-Tolerant Scheme for WSN in Precision Agriculture
### Fault-Tolerant Clusters
#### 5.1.2 Fault-Tolerant CH
Let us assume a second function, \(g(\alpha,\beta,\gamma)\), which refers to the transmitted messages in a fault-tolerant WSN. Therefore, \(g(\alpha,\beta,\gamma)=1+2\alpha(1+\beta)+2\gamma(1+\alpha)\) (i.e., \(\gamma\): the Backup's component number). In such a case, the different types of transmitted messages can be _requests_, _data_, _checkpoint_, and _alive messages_. As we can see in Figures 14 and 15, it is evident that the densities of exchanged messages were similar between the regular WSN and the fault-tolerant WSN. In fact, the fault-tolerant WSN had two additional types of messages: the first one is related to checkpoints whereas the second type concerns the Heartbeat message. Despite that, we can observe that it did not have any significant impact on the message density of the network (see Figure 15). It is clear that the highest percentage was for request and data messages while the lowest percentage was for the checkpoint and Heartbeat messages. Based on what has been mentioned before, we can conclude that the proposed scheme does not have a major effect on the load of the communication link due to synchronization messages. Subsequently, we attempted to estimate the response time. ### Estimation of Response Time

In this section, we attempt to estimate the delay required to send data to the final user (i.e., the farmer). For this, the fault-tolerant WSN model was simulated in various

Figure 14: Message exchange density in the fault-tolerant WSN (\(\alpha\in[5-15],\ \beta\in[5-60],\gamma=1\)). Figure 15: The percentage distribution of the exchanged messages in the fault-tolerant WSN (here, delay = 13,511 s). situations with a constant number of sensor nodes (i.e., 10 sensor nodes) and a different number of CHs in order to increase the WSN scalability. The primary CH is supposed to exhaust its energy at time 50; after that, the backup CH takes over the role. The BS energy depletion time is supposed to be at 100 units of time; after that, the backup BS starts operating. Both the backup CH and backup BS operate for 80 units of time and after that, the repaired primary component (i.e., CH, BS) takes over (see Table 2). In order to simulate the component energy depletion, we used variables in decremented loops. In each simulation cycle, the delay required for the end user to receive data was recorded; the collected data are summarized as plots in Figure 16. On the other hand, a regular WSN (i.e., a non-fault-tolerant WSN) was simulated with the same conditions. For this case, the WSN's lifetime measures are presented in Figure 17.

In Figure 16, we can see that the response time did not have a consistent pattern; we can observe that in the case of 20 CHs, the response time delay was larger than that of 30 CHs. It should be noted here that the scenario of fault detection and role reversal between failed and healthy components result in this delay and we can say that the system goes through a non-stabilization state before the backup components take over the role and this requires some time that will certainly impact the overall response time. Considering this point, a well-designed WSN, with a well-studied number of components, can minimize this effect. We can also observe that the response time increased with the scale of the WSN; in fact, this situation is common for all WSNs. Generally, we can say that the response time delays are reasonable and the use of the fault tolerance strategy does not lead to any drastic decrease in the WSN's service quality. In Figure 17, we can observe that the non-fault-tolerant WSN's lifetime was very short (i.e., between 10 and 50). Furthermore, sometimes the WSN stopped operating before sending data to the final user. Hence, the availability of the WSN was not guaranteed. This can cause irreparable damage in the agricultural field due to the data loss. Regarding Figures 16 and 17, it can be noticed that even though the response time was sometimes long in the case of the fault-tolerant WSN, the availability was still guaranteed.