## 3 SENDI: System for Detecting and Forecasting Natural Disasters Based on IoT
### Fault Tolerance Scheme
If there is a lack of communication with the _Cloud_, it processes this data and carries out the disaster forecasting. The natural leader of a sensing node in the described architecture is one of the sink nodes of Tier 2. However, if the local sink node fails, the sensing nodes are capable of selecting one of themselves as a new leader and continue the operation of the system. It should also be underlined that unlike the case in other works [20; 21; 22], the nodes only select their leaders on the basis of their own information. They do not need to know the total amount of energy in the system or any other information about the other nodes in the system. With regard to the clustering protocol based on LEACH [23], we employ the simplified model for the radio hardware energy dissipation shown in Figure 5 and use probability to determine whether or not a node will be a leader of a cluster and become part of Tier 2. However, unlike the case of the LEACH protocol, we suppose that: i. initially the nodes may not have the same amount of energy; ii. it is feasible for one node to be the leader on repeated occasions; iii. there is no lower or upper limit for the number of leaders; iv. the process of selection can occur many times in the same round until all the nodes have a leader; v. there is a limit for how many times the selection process can occur for a given node during a round, after this limit has been reached the node is forced to become a leader;  
Figure 4: Flowchart representing the rounds of a sensor. and vi. a node can only be accepted as leader of a given node \(n\) if it belongs to the neighborhood of the node \(n\), which reduces the need for hops and for communication with very distant nodes. According to the radio energy dissipation model, energy consumption caused by the dispatch of a message containing an \(l\)-bit to a receptor at a distance \(d\), for the streaming to have an acceptable Signal-to-Noise Ratio (SNR) is [23]:  
\[E_{Tx}(l,d)= \begin{cases}1\cdot E_{elect}+l\cdot\varepsilon_{fs}\cdot d^{2}& \text{if }d<d_{0}\\ 1\cdot E_{elect}+l.\varepsilon_{mp}\cdot d^{4}&\text{if }d\geq d_{0}\end{cases}  \tag{1}\]  
where \(\varepsilon_{fs}\) and \(\varepsilon_{mp}\) depend on the model of the transmitter amplifier for free space (\(fs\)) and multipath (\(mp\)) and \(E_{elect}\) is the consumption of energy of each transmitted bit. The equation used by the LEACH model to reach the optimal probability of a node and thus become the leader of a cluster, is described in Equation (2) [23]. This probability is used in Equation (4) [23], which defines a threshold. At this moment, given a node \(s\), a random number is generated and, if this is smaller than the calculated threshold, the node \(s\) becomes a leader of a cluster. The details of how to get to this probability can be seen in [PERSON] [23]. \[p_{opt}=\frac{k_{opt}}{n} \tag{2}\]  
where \(p_{opt}\) is the optimal probability of a node to be a leader, \(n\) is the number of nodes and \(k_{opt}\) is defined as the optimal quantity of clusters and calculated as [23]:  
\[k_{opt}=\sqrt{\frac{n}{2\pi}}\frac{2}{0.765} \tag{3}\]  
\[T(s)= \begin{cases}\frac{p_{opt}}{1-p_{opt}\cdot(rmd(\frac{1}{p_{opt}}))}& \text{if }s\in G\\ 0&\text{otherwise}\end{cases}  \tag{4}\]  
As previously stated, the LEACH does not allow a node to be a leader repeatedly. For a node to be a leader again, it must be in set \(G\) of Equation (4) [23]. This set only contains the nodes which had not been leaders in the most recent \((r*mod(n/k))\) rounds, where \(k\) is the number of expected leaders and \(r\) is the number of rounds in which the node \(s\) was not determined as the leader. In this work, the threshold defined by LEACH was altered to take account of the remaining energy in the node.