# Energy Saving in Wireless Sensor Networks via LEACH-Based, Energy-Efficient Routing Protocols
## 2 LEACH Protocol  
Low-energy adaptive clustering hierarchy (LEACH) [32] is one of the first and most well-known hierarchical protocols. Its main objective is to extend the lifetime of the sensor nodes that are disseminated within clusters in WSNs. Specifically, given that, within every cluster, the cluster head consumes much more energy than the other cluster nodes, LEACH aims to perform the selection of the cluster heads among the cluster nodes evenly. LEACH adopts a two-phase cycle consisting of the setup phase and the steady-state phase in order to achieve efficient distribution and the coordination of the cluster sensor nodes in a WSN. In the setup phase, the key goals are the creation of clusters, the selection of the cluster heads, and the creation of a TDMA (time division multiple access) schedule for the communication of the cluster head with its cluster nodes. Within every cluster, all nodes participate in a procedure to elect the appropriate cluster head. This procedure is initiated by generating a random priority value ranging from 0 to 1. If this value does not exceed the randomly generated number \(T(n)\), the node is selected to be the cluster head. The value of \(T(n)\) is calculated via the following formula:  
\[T(n)= \begin{cases}\frac{P}{1-P\cdot\left(r\cdot\text{{mod}}-\left(\frac{1}{P} \right)\right)}\text{ for }n\in\text{G},\\ 0\end{cases} \]  
where \(P\) denotes the percentage of the cluster nodes to become cluster heads, \(r\) represents the number of current round, and \(G\) stands for the total number of the cluster nodes that have not been elected as cluster heads during the \(1/P\) previous rounds. According to this formula, once a node has been elected as a cluster head in a given round, it cannot be selected as a cluster head again in the subsequent \(1/P\) rounds. This technique ensures an equitable selection of cluster heads and a better uniform distribution of energy consumption for the network nodes. The ideal proportion of cluster heads has been experimentally found to be equal to 5%. Whenever a node becomes a cluster head, it transmits an advertising (ADV) message to the rest of the nodes in the network. Each node that receives this message and wants to participate in the specific cluster sends a replying (RPL) message back to the designated cluster head. This sequence of actions results in the establishment of clusters with their respective cluster heads. The cluster head then proceeds to create a TDMA schedule, which is subsequently shared with the nodes that are members of its cluster. This TDMA schedule determines the specific time that each node is both prompted and allowed to transmit data. As soon as the TDMA schedule has been defined, the setup phase is finalized. During the steady-state phase, data propagation occurs among nodes and their respective cluster heads, as well as amid cluster heads and the base station. The nodes send their data to the relative cluster heads based on the designated timeslots specified in the TDMA schedule. During the time slot of every node, all of the rest nodes that belong to the same cluster reduce their energy consumption by being inserted into a low-power state. This approach not only effectively prevents congestion but also conserves the energy stored in the nodes' batteries. After the cluster head has gathered the data from its cluster nodes, it utilizes the TDMA schedule to send these aggregated data to the base station, ensuring efficient data transmission. As highlighted earlier, LEACH effectively balances the cluster head election process across network nodes, thereby extending the overall network lifespan. Notably, it does so without necessitating global network knowledge. Additionally, by enabling a TDMA schedule, the network avoids data collisions during transmissions, enhancing network efficiency. However, it is worth noting that LEACH does not consider the remaining energy levels of nodes when electing cluster heads.