## 3 WSN Protocols
### LEACH (Low Energy Adaptive Clustering Hierarchy)  
The Low Energy Adaptive Clustering Hierarchy (LEACH) protocol is one of the primary routing protocols for Wireless Sensor Networks. The LEACH protocol is a Time Division Multiple Access (TDMA)-based Media Access Control (MAC) protocol. The main idea of this protocol is to expand the energy or battery lifetime of WSNs through a distribution of the energy load among the sensors or nodes in the network [3; 10].  
The network will be divided into several rounds using the LEACH protocol. Each round contains two stages: the set-up phase and the steady phase. In the set-up phase, all nodes in the network randomly generate the number 0 or 1. One of these nodes in every cluster area will be chosen as cluster head (CH) depending on the threshold \(T(s_{i})\) value. This value is calculated using Equation (4) [3; 4; 10].  
\[T(s_{i})=\left\{\begin{array}{cc}\frac{P_{i}}{1-P_{i}\left(r\;mod\;\frac{1}{P_{ i}}\right)},&if\;s_{i}\in G\\ 0&,\;\;otherwise\end{array}\right. \tag{4}\]  
where \(T(s_{i})\) is the threshold, \(P_{i}\) is the probability of change of node to become a CH, \(r\) is the current round number, and \(G\) is the set of nodes that will be chosen as CHs at each round \(r\).  
If the random number is less than threshold T(n), the node will be the cluster head of the current round \(r\). Then, these nodes in the network act as a CH and send short messages to all other remaining sensors. The nodes will choose to join these regions, called cluster areas, depending on the signal strength of the message sent by the cluster head. Then, every CH will create Time Division Multiple Access (TDMA) schedules according to the number of nodes in the cluster because TDMA puts reminder nodes in sleep mode and protects nodes from network data collision [4]. The last step in this phase is that all nodes belonging to the cluster area will send a message to the CH, which will then be sent towards the base station. In the steady state phase, all nodes in each region will send the collected data in their allotted TDMA slots to CH. Then, every CH in each cluster area will transmit these data in a compressed format to the network's base station.  
Figure 3 shows the implementation of the standard LEACH protocol using MATLAB. A standard LEACH protocol was implemented using MATLAB simulation; this figure shows how this protocol needs to provide more explicit information about the position of CHs because it depends only on the probability model. Therefore, some of the CHs are at the edge of the network. Also, some CHs are nearby, and some nodes are not connected to any CH [10; 14]. These are the main drawbacks of this protocol: the modified version will not have these drawbacks, and all nodes in the network will choose the nearest CH in the network. As mentioned, all nodes in this protocol will organise themselves in local clusters, with one node acting as cluster head, and run a demised rotation of CH to balance energy consumption in the network.  
As seen in the previous figure, some nodes might not be close to the cluster head; therefore, the energy level utilised by the farther sensor does not equal the amount of energy the nearest node uses. These CHs will forward the data to the base station in compressed  
Figure 3: Results of implementing standard LEACH protocol using MATLAB: cluster heads are marked as bold plus signs, other nodes are marked as coloured rhombuses, and the base station is marked as a red circle in the centre.  
format. Not all CHs are close to the base station, so they pass these compressed data to neighbouring CHs, which is a multi-hop routing network.