# An Enhanced Mechanism for Fault Tolerance in Agricultural Wireless Sensor Networks
## 4 Theoretical Model for Our Fault-Tolerant WSN  
In this section, we present the theory behind our fault-tolerant wireless sensor network. **Definition 1**. : _A node is defined as a tuple \(n(ID,\ p)\), such that \(ID\) is the node identity and \(p\) is the energy level, \(p\in[p_{Min},\ p_{Max}]\)._  
**Definition 2**. : _A cluster is defined as a tuple \(C=\{N,\ L,\ T,\ CH\}\), such that_  
\(N\)_: the set of nodes \(\{n^{0},\ n^{1},\ \ldots,n^{m}\}\);_  
\(L\)_: the set of communication links \(\{l_{0},l_{1},\ \ldots,l_{n}\}\) between the sensor nodes and the CH;_  
\(T\)_: a set of transitions \(t\), and each transition is a tuple of the form \(t=\left(n^{i},\ l^{i},p^{i},\ d^{i},CH\right)\), \((i=0\ldots m)\), where_  
\(n^{i}\)_: the sensor node;_  
\(l^{i}\)_: the communication link associated with the transition;_  
\(p^{i}:\in[p_{Min},\ p_{Max}]\)_, the transmit power of the sender node;_  
\(d^{i}\)_: the set of transmitted data;_  
\(CH\)_: the Cluster Head._  
**Definition 3**. : _A fault-tolerant cluster \(C=\{N,\ L,\ T,\ CH\}\) is a cluster that contains a primary CH and a backup CH, \(FT_{C}=\left(Primary_{CH},\ Backup_{CH},\ N,\ L,T\right)\), such that_  
* \(Primary_{CH}\left(ID_{pr},\ p_{r}\right)\) _is the main_ \(CH\) _in the cluster group. It is characterized by its proper_ \(ID_{pr}\)_, and its energy level_ \(p_{r}\)  
Figure 3: CH and BS communication protocol: (a) initialization; (b) data transfer. \(Backup_{CH}(ID_{Bk},\,p_{Bk})\) is the backup \(CH\); it has an \(ID_{Bk}\) and an energy level such that \(p_{Bk}=p_{r}\). Here, \(L\) is the set of communication links \(L=\cup_{l=1}^{m}\cup_{j=1}^{m}l_{i}l^{\prime}_{j}\); there are two types of communication links: the communication links between the sensor nodes and the \(Primary_{CH}(l_{1},l_{2},\,\ldots,\,l_{m})\) and those between the sensor nodes and the \(Backup_{CH}\) (\(l^{\prime}_{1},l^{\prime}_{2},\,\ldots,\,l^{\prime}_{m}\)). **Lemma 1**. : _A fault-tolerant cluster, \(FT_{C}=(Primary_{CH},\ Backup_{CH},\ N,\ L,T)\), is able to ensure the safety and liveness of the cluster group._  
Proof. : In order to prove Lemma 1, we will use reductio ad absurdum. Let us consider the following scenarios. Let \(C=\{N,\ L,\ T,\ CH\}\) be a non-fault-tolerant cluster, which has no backup CH. At moment \(t\), the initial power level of the CH is \(p=P_{Max}\). At moment \(t\prime\), the CH receives data from all the sensor nodes in the cluster (i.e., each data transaction needs \(\delta\)_power_); at that time, \(p=P_{Max}-m\delta\). At moment \(t^{\prime\prime}\), the CH aggregates and transmits data to the BS that needs \(\epsilon\)_energy_; thus, \(p=P_{Max}-(m\times\delta+\epsilon)\). At moment \(t^{\prime\prime}\), the CH repeats the tasks \(\theta\)_times_: \(P_{Min}\leq p(\theta\times(m\times\delta+\epsilon))\leq P_{Max}\). After \(\theta\) times, the CH exhausts its energy: \(p\leq P_{Min}\). At that time, the CH has completely stopped functioning, the field data of the \(m\) sensor nodes have been lost and the sensor group is currently disconnected from the rest of the network. In fact, this disconnection could lead to significant damage in the agricultural field. Hence, we conclude that the cluster is neither _safe_ nor _live_. However, in the case of using a backup Cluster Head, at moment \(t^{\prime\prime}\), the failure of the primary CH will be detected and the backup CH will immediately take the role. **Definition 4**. : _A Base Station is defined as a tuple \(BS(ID_{BS},\ \mu)\), such that \(1D\) is the Base Station identity and \(\mu\) is the residual energy of the BS, \(\mu\in\left[\mu^{Max},\mu^{Min}\right]\)._  
**Definition 5**. : _A fault-tolerant Base Station BS, \(FT_{BS}=(Primary_{BS},\ Backup_{BS})\), is composed of a primary Base Station (i.e., \(Primary_{BS}\)) and a backup Base Station (i.e., \(Primary_{BS}\)). Here, \(Primary_{BS}(ID_{PBS},\,\mu_{pr})\) is the main BS in the WSN whereas \(Backup_{CH}(ID_{BS},\,\mu_{BS})\) is the backup BS._  
**Lemma 2**.