# Energy-Efficient Clustering Scheme for Flying Ad-Hoc Networks Using an Optimized LEACH Protocol
## 4 Proposed Methodology
### Setup Phase  
#### 4.1.1 Cluster Formulation and Cluster Head Selection  
In our recommended protocol, all nodes are presumed as a separate cluster, and all nodes instituting a cluster are candidates for CH selection shown in Figure 4. In the process of selecting CH, all CH applicant nodes also require their current energy and residual energy information in addition to the existing LEACH protocol threshold \(T(n)\)[22]. This is done to reduce the chance of selecting a node with low energy and to match the network's overall energy load distribution. If a low energy node is selected as a CH, it might induce the imbalanced use of the overall energy of the network. By picking a random number between 0 and 1 for all regular nodes, if the selected number is less or equal to the \(T(n)\) value, which Equation (1) can obtain, then the node becomes a cluster head for the current round' otherwise, a node will remain as an ordinary node in a cluster.  
\[T(n)=\frac{p}{1-p(r)mod\Big{(}\frac{1}{p}\Big{)}}*Dx\ \ n\in\text{G0},\ \ \ Otherwise \tag{2}\]  
In this equation, \(p\) refers to the proportion of sensor nodes required to become CHs among all sensor nodes, \(r\) is the current round, and G is the set of candidate nodes for the cluster head that has not been picked as a CH in the past \(1/p\) rounds.  
\[Dx=\left[\frac{Re-Dr}{ARe-ADr}\right]\]  
\(Re\) is the residual energy of the node in the network calculated by Equation (3), \(Dr\) is the drain rate of the node (the method to report the rate at which energy is degenerated at a specified node)m and \(ARe\) and \(ADr\) are the average residual energy and average drain rate.  
The function to compute the residual energy of the nodes in the network is as follows:  
\[Re_{i}=(INT_{i}-CET_{i}) \tag{3}\]  
where \(INT_{i}\) is the Initial energy of a node and \(CET_{i}\) is the current energy.  
A node selects a CH nearest to it rather than choosing a CH that is closest to the base station. The distance between the node to every CH and further every CH to the Base station is calculated. To calculate the distance between each node and the CH, and the CH and the BS, we calculated the Euclidean distance.  
The minimum distance formula between two locations in the xyz-space is stated as the square root of the sum of the squares of the differences between corresponding coordinates.  
When a node has chosen a cluster head with a minimum distance, the cluster head receives a message stating that the distance is minimal and that it will be part of the cluster. This procedure is repeated for all of the nodes, or for the number of rounds necessary, before choosing the right cluster head for them as shown in below mentioned Algorithm 1.  
```
Some Notations used in algorithm: NN: Numbers of nodes BS: Base station N: For Every node START All N in NN has probability to be selected as CH For Every Node (N), where N \(\in\) NN For every N select random number between 0 and 1 If (Select random number \(<=T(n)\)) Then N is selected as CH and N broadcast a message of its CH status Else N become Ordinary Node N receive Message by other about their CH status End of if End of for loop For Every CH (Procedure to Select Min Distance between N and CH and CH to BS) Each node Select CH with Min distance to reach BS After previous step Node become a part of selected CH End of for loop For Every CH TDMA Schedule is constructed for each node(N) to Transfer data CH send information about the TDMA schedule to each Node(N) End of for loop
```  
Figure 4: Basic structure of the proposed protocol.