Intelligent on Demand Clustering Routing Protocol for Wireless Sensor Networks

WSNs have become one of the most widely used approaches in a range of applications, including agriculture, smoke detectors, health care, and factory monitoring. WSN provides a number of bene ﬁ ts, including low cost, compact size, multifunctionality, self-organization, and the ability to be routed via WSN protocols. WSN is being used in more practical applications than ever before. Nonetheless, one of the most critical problems is energy shortage. It limits WSN technology from being fully utilized. Sensors are typically powered by batteries, which have a short lifespan. Even if renewable energy sources (such as solar or piezoelectric devices) are used as additional energy in wireless sensor networks, there is still room for e ﬃ cient energy consumption. In our research, we identify the shortcomings of the existing LEACH protocol, suggest a novel methodology that improves the LEACH protocol, and compare it to the basic LEACH approach. Our research aims to increase network lifespan by reducing energy consumption, primarily based on limitations of the LEACH and its related algorithms.


Introduction
A wireless sensor network comprises low-power, low-cost, and multipurpose wireless sensor nodes that can perform sensing, wireless communication, and computing. These sensor nodes are deployed randomly. These nodes must configure themselves into a wireless network and fulfill a certain task after they have been deployed. Because sensor nodes have finite batteries, power is the most important resource in WSN. In this research, we provide a hierarchical routing protocol based on the LEACH protocol. Environmental monitoring, security and surveillance home intelligence, health care application, military uses, battlefield monitoring, object protection, intelligent guiding, and more applications of the LEACH protocol exist. The main challenge in WSN technology is extending the network's life and minimizing the sensor network's energy consumption. To monitor earthquakes, battlefields, industrial environments, residential monitoring [1], agricultural fields [2], physical atmospheric conditions, and smart houses, wireless sensor nodes are often spread throughout the sensing region. Sensor nodes sense their surroundings, collect data, and transfer it to the base station through a wireless network. Because of the dense deployment of WSN, charging node batteries is problematic. As a result, a primary focus of WSN technology is to reduce sensor node power consumption to extend the network's life. Many clustering-based algorithms have been proposed. Some of them are given in Literature Survey.
Clustering is a method that efficiently regulates network energy consumption by reducing sensor transmission range. The CH controls group communication with the BS in this mode of operation. Sensor nodes do not transfer data to the BS directly; instead, the cluster head gets the data in its entirety, aggregates it, and passes it to the BS. The related cluster head receives the data from all of the member nodes in the cluster. The cluster head releases TDMA schedule to all the nodes to avoid conflicts. Every node of the cluster handovers its data to the cluster head exclusively according to the stated distribution mechanism. Hence, if there is no time interval, the sensor node will switch off its transceiver. TDMA scheduling favors preserving the energy of sensor nodes, so these member nodes can also last for a long time. Usually, each member node transfers the data to the neighboring cluster head; sensor nodes use the least energy to transfer data. CH performs computations on the collected information and filters out unnecessary bits, which decrease the amount of data that must be provided to the BS. So, the transmission energy of the sensor is considerably lowered. WSN is considered to be a very resource-limited form of the network where energy consumption is one of the key issues. Data are transmitted to the whole network instead of the target point, which is known as flooding. CH is unstable in the LEACH protocol; it is based primarily on round principles, with each round having two phases: setup and steady state. In this research paper, we propose an energyaware multihop routing protocol based on gateways. The major objective of this study is to minimize sensor node energy consumption by logically dividing the network into various portions.
When it comes to wireless sensor networks, the way power is distributed across sensor nodes determining whether they are homogenous or heterogenous networks. Homogenous protocols include LEACH, HEED, and PEGASIS, while heterogenous protocols include DEEC and SEP [1]. Network structure, reliable routing, topology based, and communication model are the four types of protocols that are used for routing. Based on the distribution of hierarchical routing and flat nodes, the system is divided into two protocols [1,2]. SNs (sensor nodes) conduct their detecting duties concurrently in a flat network, where all nodes have the same function. There are two types of sensors in a hierarchical network: those that have a lot of energy and those that have a low amount of energy.
Clustering is used in wireless sensor networks to build energy-efficient protocols. LEACH [1] was the first hierarchical routing protocol presented by Heintzelman et al. The first most common protocol is based on the clustering process [1]. SNs are divided into clusters to reduce latency and battery consumption in wireless sensor networks. Clustering is an effective method for organizing wireless sensor networks [1]. In a wireless sensor network, LEACH is an adaptive, self-organizing clustering technique that uses an equal amount of energy load divided among sensor nodes. A cluster head (CH) is a node that acts as a chief, whereas other nodes are known as common nodes. A CH gathers data from the common nodes and forwards it to the BS. The collection of data from numerous nodes, on the other hand, required more energy. CHs are used to assign time slots to each node and prepare them to transfer data using time-division multiplexing (TDMA). To reduce power usage and data redundancy, TDMA is used [2].
In this paper, the following contributions are made: (1) Suggest direct communication of nodes that are near to base station, to expand the performance of root cluster (2) Every cluster contains vice cluster head along with the cluster head which reduce the data loss (3) The proposed approach is powerful and improved version; it reduces the energy consumption of sensor nodes and extends the WSN's lifetime

Literature Survey
LEACH protocol was suggested by W. Heinzelman and Balakrishnan for WSN [3]. A LEACH is an algorithm that organizes the network nodes into small clusters and chooses a CH from each cluster. At first, the node senses its destination and then transmits the pertinent message to the CH. Then, the CH transmits the gathered information to the BS. LEACH protocol's main objective is to enhance energy efficiency by employing a random integer to implement a rotation-based CH selection technique. The LEACH procedures are designed to work in many rounds. There are two phases in each round. A unique LEACH protocol in a heterogeneous network that matched the simulated outcomes to those of the LEACH homogeneous system was introduced in [4]; they simulated the protocol across a100 × 100-meter region. Sharma discovered that 10 nodes contain more energy than the other 90, extending the lifespan of the system and improving the performance of the wireless sensor network. Dynamic K value protocol (DK-LEACH) [5] proposes an optimum clustering. Within the unequal energy distribution, this strategy minimizes energy consumption. The same cluster and different cluster distances are both relevant elements in this case.
The authors looked at route cost and feasible connections between sensor nodes and cluster head of each cluster in node-ranked-LEACH (NR-LEACH) [6]. CH selection is heavily influenced by the current weight. However, it can sometimes raise network overhead. In LEACH-VA [7], according to the total energy consumed in a round, the optimum number of CHs is estimated. This method reduces intercluster communication by employing the Voronoi diagram concept, as well as ant colony optimization for efficient routing. With the exception of higher overhead, this technique outperforms existing LEACH protocols.
In [8], the authors presented BRE-LEACH, an updated LEACH protocol that improved the energy consumption cost, network life cycle, and stability period. The BRE-LEACH technique contains three factors: the first one is the distance to the BS, the second is residual energy, and the third is the multihop transmission. The fundamental factor in the cluster head selection technique is residual energy, which is used to avoid low-energy nodes serving as a cluster head since they require additional energy than regular nodes. This technique increases the life of the network. The selection of CH is based on the remaining energy. Clusters, on the other hand, do not have the same number of 2 Wireless Communications and Mobile Computing nodes. In IB-LEACH protocol, to expand the energy efficiency of the system, clustering is divided into two parts: intracluster and intercluster. The results of the estimation show that using the IB-LEACH protocol extends the network lifespan. However, because of the additional computation required, the traffic load is increased to some level.
The field observation instrument, FOI-LEACH [9], is a more advanced protocol based on LEACH. By selecting the appropriate CH, this strategy prevents the premature mortality of the cluster head and extends the life of the network. To address the hotspot problem, this technique additionally focuses on the distance between the sensors and base station. However, the scalability problem is not taken into account, which makes it unsuitable for smaller sensing fields.
The routing technique for optimization is proposed by [10] on multiconstraints and multiobjective. For estimation of the quality of routing protocol, the link quality, parameter of residual energy, and traffic load are considered performance parameters. It helps in the fast delivery of packets.
SHE is the protocol of real time represented by [11]. In this traffic, packets followed different paths after the formation of clusters. QoS is acquired by aging tag.
Contributing to this is a clustering technique [12] called energy-aware QoS routing protocol. It made prominent throughput, decreases retransmission of excessive packets, improves the delivery ratio of packets, and most important for WSNs reduces end-to-end delay.
The routing protocol called bihop neighborhood information-dependent is presented in [13]. This one paradigm contains both the two-hop velocity concept and energy balancing. Its suitability in real time is shown through QoS parameters. LEACH extension called PEGASIS is presented in [14] for network lifetime improvement by decreasing the distance of transmission between sensor chain techniques modified for lifetime enhancing of the network, but it represented more enhancement than PEGASIS by placing the leader of the cluster near the base station.
DEEC and EDDEEC protocols were developed [15,16], respectively. In DEEC, the average network energy and node probability function based on initial energy are formulated. The drawback is that it does not notice the energy of network in every round. EDDEEC represented the threshold function based on three nodes, i.e., advanced nodes, a normal node, and super node.

Network Model and Assumption
Two models are discussed in the proposed method, i.e., network model and energy dissipated network model used for microsensor formation, the election of CH, circulation of data to BS, and data aggregation. The second model is used for dissipation of energy that occurs due to transmission and reception of sensed data. The proposed method considers the following assumption while applying the network.
(I) After deployment, each node is nonmovable and it is identified by separate ID (II) Node's capabilities are similar when considering communication and processing, but when talking about battery energy, it is heterogeneous (III) The property of data aggregation is used in which multiple data is compressed into one packet (IV) Depending on distance power, control mode is used to operate all node (V) The nodes' initial energy is heterogeneous and nonchargeable (VI) A communication link between nodes is symmetric, so consumption of energy of transmission of packets and rate of data from node A to B and B to A is the same (VII) The central position is assigned to BS and it is free from memory, consumption capability, and energy constraints (VIII) In-network area nodes are distributed on the elliptical Gaussian distribution model By considering the effects of the three parameters, i.e., security, energy, and routing, the position of nodes is a complicated issue in the network.
The lifespan of network depends on the installation method. So, nodes that are near to the base station drain their energy of battery much faster than the one which is away from the BS. To solve this problem, a distribution function called 2D Gaussian is used to control the problem of energy hole in WSN.
For network lifespan and energy balancing, the standard deviation plays a vital role in this function. All area, i.e., M × Mm 2 , is occupied by the N nodes. The distribution for this function is given below: The (u o v o Þ is used to represent the positional coordinates and σ u and σ v represent standard deviation. Figure 1 shows energy model. It is up to the distance that both models, i.e., multipath fading and free space model, are included.

Radio Energy Model.
The following is the formula for radio energy which is included for transmitting data x (bit) from distance at the rate of bit/s.

Wireless Communications and Mobile Computing
For transmission of a single packet, E Tx ðx, d, rÞ represent the total dissipation of energy, E Tx−elec ðx, rÞ represent electronic digital count, E Tx−amp ðx, d, rÞ represent the power amplifier energy consumption model designed for free space, ε mp is used to represent the multipath model, E Rx−elec ðx, d, rÞ represent single packet reception for total dissipation of energy, and E rx−elec represent the dissipation of energy for the receiver circuit.

Proposed Protocol
In this research, we present a new hybrid energy-efficient protocol with the goal of reducing energy consumption, extending network stability, increasing network lifetime, and increasing throughput. The suggested method is an improved hybrid EEE-LEACH clustering procedure with round phases for each cycle. Instead of the two stages of the LEACH algorithm, the proposed protocol comprises four phases for each round, as shown below. The steps of algorithms for different cases are given in Table 1.

First Phase. The proposed approach involves selecting
CHs based on the residual energy of nodes to avoid nodes with low energy being scheduled to become CHs and to save energy. Each node chooses a random number Rn (0 < Rn < 1 ) at the start of each turn, based on the working procedure of LEACH and their upgraded protocols. If the value of R is less than the threshold function defined in equation (3), this node becomes a CH in the current round. However, it reverts to a normal node (NN).
where the ratio of total cluster heads to sensor nodes is denoted with P and indicates the likelihood of each node becoming the cluster head during round 0, G is the set of nodes that will not be elected as a CH in the most recent 1/p round, I is the current number of rounds, and mod(•) is the modulus operator. Following the selection of CHs, each CH sets a TDMA scheduled to receive data from cluster members during their assigned time intervals. They then send an announcement message to the network, which includes each CH's ID and coordinates. When NNs get these messages, they generate a distance table to CHs. The NN sends a JOIN demand to the CH with the lowest distance in its table and less than the threshold distance to determine which CH it belongs to. This CH will be the equivalent CH if this CH still has a vacant time slot in the TDMA program and the number of nodes in its cluster is less than Ncl. The NN, on the other hand, sends a second JOIN demand to the next CH with the shortest distance in its table and a distance smaller than the threshold distance and so on. According to the IBRE-LEACH method, the distance between NNs and their CHs should be less than the threshold in order to avoid multipath propagation, which consumes more space than the free space provided in Section 4.5. The Euclidean distance is determined between two devices using the coordinates (X, Y) as indicated in (equation (4)): Furthermore, the suggested technique equalizes the residual energy of CHs in the network by limiting the number of nodes in each cluster. NNs that cannot join any cluster will be ignored once clusters have been created. Abandoned nodes are the name given to these nodes (ANs). These abandoned nodes have the opportunity to route their data to BS, such as NNs and CHs.

Second Phase.
After the CHs and ANs have been fixed, clusters are formed, and all CHs send out an announcement message to all other CHs. Each CH's ID and location are included in this message (or AN). Following that, the proposed protocol selects a root node. This root will be a CH or AN with remaining energy more than or equal to the average current energy of all CHs and ANs and a distance to the BS that is less than or equal to the average distance of all CHs and ANs from the BS.
The root node combines its data with that received from other CHs and ANs before sending it to the BS directly. Its

Energy consumption during transmission
Energy consumption during reception Transmit data processing Transmitter amplifier x-bit data packet x-bit data packet Rx electronics   AN) can use its routing table to determine the best method for sending its data to the BS, which includes distances to all CHs, ANs, the root, and the BS. The proposed protocol's architecture is depicted in Figure 2.
The workings of our proposed method are depicted in this diagram. Each CH (or AN) creates its own routing table, which includes distances between other CHs, ANs, the root, and the BS. The distances are then ordered from nearest to farthest. The proposed method then offers a set of conditions for selecting the best route for each CH and AN to reach the BS. Consider CH1, which has the closest distance to CH2, then the root, the BS, and so on.
The proposed approach compares dCH2toBS (the distance of the first element in the routing table with the BS) and dCHltoBS (distance between CH1 and the BS). In this case, dcHitoBs is less than dCH2toBs. So, CH2 will not be the next hop of CH1. It then moves on to the next item in its routing table. When it compares dRoot-ToBs (the distance between the root and the BS) to dCHitoBS, it discovers that dCHitoBs is smaller than dRoot-ToBs and the BS is the routing table's third element. As a result, the CH1 decides to send directly to the BS because it is the most efficient path.  If we want to expand the network to 400 nodes, the value of L will be doubled. We must set a chance of nodes being picked as CH in any LEACH. For each round, we set P = 0:1 the probability of getting picked as the cluster head. In a network of 200 nodes, P = 0:1 suggests that 20 nodes can be CH. For each sensor node in the network, we establish the initial energy. The energy of a node at the start of the simulation is referred to as initial energy. As a result, Ei = 0:5 is assigned as the initial energy value. As a result of conducting the simulation in MATLAB, we now have the following result: A MATLAB simulation was used to generate the results, which were averaged over 20 trials. The parameters utilized in simulations are summarized in Table 2.

Results
The homogeneous network of 200 nodes, spread randomly in 200 * 200, is analyzed in our Hybrid-LEACH. The BS coordinates are 150 and 150. The comparison of dead nodes over time in EEE-LEACH, LEACH, and Hybrid-LEACH protocols are illustrated in Figure 3. In comparison to other protocols, our proposed Hybrid-LEACH delivers a better performance in terms of dead nodes over time as seen in the figure. The network lifetime and total energy consumption are depicted in Figure 4. These findings indicate that the suggested technique outperforms the compared proto-cols in terms of network lifetime. Figure 5 shows how Hybrid-LEACH improves the stability area (number of rounds where all nodes are alive) when compared to LEACH and EEE-LEACH. Energy consumption is the second crucial statistic. Figure 6 depicts the total residual energy in the entire network. The proposed technique uses less energy than LEACH and its upgraded protocol EEE-LEACH, according to the results of this curve. Throughput is the third major statistic considered in this study. Figure 7 shows the number of packets transmitted to the BS for all three protocols. Based on these findings, it is clear that increased amount of packets is transmitted to the BS in Hybrid-LEACH than LEACH and EEE-LEACH.

Summary of the Simulations and Results
We tried to compare LEACH and our newly suggested Hybrid-LEACH algorithm after conducting three successive

Conclusion
We attempted to compare different forms of LEACH protocols, their implementation, limitations, and obstacles in this study. Many researchers have proposed numerous modified LEACH procedures. We attempted to learn about the difficulties they encountered as well as the method they employed to conduct their investigation. WSN's most used protocol is LEACH. It does, however, have several flaws. As a result, we devised a plan to address a problem with the LEACH protocol. The LEACH protocol's cluster head election mechanism has been updated, and the new altered LEACH is known as Hybrid-LEACH. We discovered that the new modified algorithm achieved our goal and performed better than the existing LEACH protocol after its successful deployment. As a result, our research's goal has been accomplished.

Data Availability
No data were used to support this study. We have conducted the simulations to evaluate the performance of the proposed protocol. However, any query about the research conducted in this paper is highly appreciated and can be asked from the principal author (Muhammad Amir Khan) upon request.

Conflicts of Interest
The authors declare that there are no conflicts of interest regarding the publication of this paper.