Research On Optimization of Energy Ecient Routing Protocol Based On LEACH

Aiming at the shortcomings of a typical Low Energy Adaptive Clustering Hierarchy (LEACH) routing protocol, which randomly selects cluster heads (CHs) and sends data to the base station (BS) by single-hop, an improved eﬃcient routing protocol, Leach-sub-muti, is proposed. In the process of electing CH, the protocol considers the energy of the node, the distance from the node to the BS, the density around the node, and so on. After the cluster is formed, the backup CHs in the cluster are selected according to the load of the CH nodes. In the data transmission stage, if there is a backup CH in the cluster, the nodes in the cluster send data to the CH ﬁrstly, and then when the energy of the CH node is lower than the average energy, the backup CH temporarily acts as the CH to forward data to the BS. This protocol allows normal nodes to forward data to the BS directly. When ordinary nodes forward data to the CH, the data can be forwarded by combining single-hop and multi-hop. Similarly, the data of the CH is also forwarded to the base station in the same way. MATLAB simulation experiments show that the optimized protocol sends more packets with less energy than the LEACH protocol, reducing the energy loss of nodes, and extending the life cycle of the entire network.


Introduction
Wireless Sensor Networks (WSNs) is an information transmission network composed of a large number of Sensor nodes with data acquisition, data processing, data storage, and communication functions in a self-organized manner. The network is widely used in the smart home, smart agriculture, smart mines, military defense, and other important fields [1]. Although sensor nodes have the advantages of small size and strong functionality, they usually require battery power with limited energy and the nodes are usually deployed in harsh environments. Therefore, when some nodes run out of energy, they will lose the ability of data collection and data forwarding, and the whole network will be seriously affected. Based on the above reasons, the core problem of the whole WSNs is how to reduce the energy loss and extend the life cycle of the WSN. To solve the above problems, scholars at home and abroad have proposed a large number of routing protocols, including planar routing protocol and hierarchical routing protocol. Due to the lack of data management in plane routing protocol, all nodes need to collect and transmit data to the BS, which causes great energy loss. However, hierarchical routing protocol can better integrate data, so it can reduce the energy consumption of nodes to a certain extent. The LEACH routing protocol is a typical hierarchical routing protocol. To reduce the energy consumption of nodes, this paper analyzes the shortcomings of the LEACH protocol and optimizes the clustering method and data transmission method, to balance the load of the whole network and extend the life cycle of the network [2].

Influencing factors of node energy
Many factors are affecting the energy of nodes in WSNs, including distance, data redundancy, inappropriate CH selection, improper data transmission, etc. All these factors will affect the energy of nodes more or less. Therefore, it is necessary to analyze the factors affecting the node energy as comprehensively as possible, so as to take effective measures to reduce unnecessary energy loss. Generally speaking, the working process of WSNs is mainly divided into two stages, one is the data acquisition stage, the other is the data transmission stage. The energy loss in the data acquisition stage is much smaller than that in the data transmission stage [3]. Energy loss in each stage of the WSNs working process is shown in Fig. 1:

Transmission distance
In WSNs, the energy loss of a node is proportional to the transmission distance. Under the premise of sending the same data packet, the longer the transmission distance, the more energy needs to be consumed. Therefore, when the source node sends data to the destination node, it is necessary to choose the path with less distance cost for data transmission.

Data redundancy
In WSNs, the similarity of the data collected by nodes is due to the overlapping of monitoring ranges caused by random distribution of nodes. Therefore, saving the similar data in multiple nodes will result in a waste of energy resources. Besides, nodes may receive the similar data at different times, but in the case of low real-time requirements, all the data collected by nodes are not necessary to be saved. These similar data are called redundant data. Redundant data will increase the amount of data transmission and raise the burden of nodes. Therefore, how to eliminate redundant data is also a major problem to be solved urgently for WSNs [4].

CH selection
Reasonable selection of cluster head can greatly improve the efficiency of the whole WSNs. CH plays an indispensable role as the hub of data forwarding in cluster routing protocol. If the cluster head is selected improperly, the data collected by the nodes in the cluster cannot be forwarded timely and effectively due to the premature death of the cluster head node, which will have a huge impact on WSNs.

Improper data transmission method
In the data forwarding stage of WSNs, if the CH node has low energy and is far from the BS, the remaining energy may not be enough to forward a large amount of data to the BS. If the node dies during the forwarding process, data will be lost, which will affect the normal operation of WSNs. Therefore, to ensure the reliability and stability of data in WSNs, it is necessary to introduce multi-hop mechanism in the process of data transmission.

Algorithm description
3.1 Overview of LEACH protocol LEACH protocol is a low-power adaptive clustering routing protocol proposed by Heinzelman et al. of MIT for wireless sensor networks. The protocol randomly selects CH nodes in a cyclic manner, and distributes the energy load of the whole network to each sensor node, so as to reduce the energy consumption of the network and improve the overall network lifetime. The working process of LEACH protocol is mainly divided into two stages: cluster establishment stage and stable operation stage. The total duration of the two phases is one round. To reduce the protocol overhead, the duration of stable operation phase is longer than that of cluster establishment phase.

Cluster establishment phase
In the cluster establishment phase, each node randomly generates a random number between 0-1. When the random number is less than the threshold T (n), the node is elected as the CH. Next, the CH nodes broadcast the message that they become the CH to the ordinary nodes. The ordinary nodes select the CH node with the strongest signal and the closest distance to join according to the strength of the message signal received from the CH. The calculation method of the threshold is shown in formula 1: Where, p is the probability of a node becoming a CH node, r is the current round, and G is the set of nodes that have not been CHs in the last 1/p rounds.

Stable data transmission stage
In the data transmission stage, the LEACH protocol adopts the method of TDMA(Time Division Multiple Access) to forward data. The nodes selected as CHs send a TDMA slot table to the ordinary nodes in the cluster. In a specific time slot, the nodes in the cluster continue to send data to the CH node, otherwise, the node stops sending data and enters the dormant state. Data forwarding in TDMA mode avoids data collision and reduces packet loss rate. At the same time, nodes switch back and forth between working state and sleeping state, which prevents the node from continuously listening to the channel.

LEACH protocol analysis
The LEACH protocol uses a clustered approach to forwarding data, which reduces energy consumption to a certain extent and extends the network life cycle. However, But this protocol also has many shortcomings. On the one hand, the remaining energy of the node, the distance between the node and the BS, and the density around the node are not considered in the process of selecting the cluster head CH. On the other hand, the CH forwards data to the BS in a single-hop. Therefore, WSNs using this protocol will have a large energy gap between nodes after running for a period of time. Since the CH has to undertake more data forwarding tasks, it needs to consume more energy. When a node with less energy is elected as a cluster head, it will speed up the death of the node, thereby shortening the life cycle of the entire network.
Aiming at the deficiencies of LEACH protocol, literature [5] proposed an improved protocol LEACH-C, which introduced the concept of average energy based on LEACH protocol. Only when the current energy of the node is greater than the average energy, can the node has a chance to become a CH. It avoids nodes with low energy being elected as CHs. The simulation results show that compared with LEACH protocol, this protocol balances energy loss and prolongs the life cycle of WSNs.
In the LEACH protocol, the CH can only forward data to the BS in a singlehop mode. When the CH node is far from the BS, it will cause a lot of energy loss. Therefore, the multi-hop mechanism is introduced in literature [6,7]. When the energy of the node is low, the multi-hop mechanism is used to forward the data to the neighbor node closer to itself, and then the neighbor node forwards the data to the BS. The advantage of introducing the multihop mechanism is that it can reduce the packet loss rate and reduce energy consumption to a certain extent.
Literature [8] made further improvements to the LEACH protocol. The paper pointed out that energy and distance are the main factors that limit the entire WSN. Therefore, the protocol considers the remaining energy of nodes and the distance between the CH and BS when selecting CHs. This protocol makes more advantageous nodes become cluster heads, which improves the overall performance of the network to a certain extent and prolongs the life cycle of the network.
Reference [9] also considers the remaining energy of the node when selecting CH nodes, like LEACH-C, but the difference is that the method in reference [9] is to make the node with the most remaining energy become the CH. In addition, in the process of data transmission, the CH node finds the node closest to the sink node as its next hop to transmit data. This method realizes data transmission between multiple clusters.
In recent years, although the LEACH protocol has been continuously improved and perfected, there are still shortcomings. This paper has made further improvements based on the optimized LEACH protocol. The simulation results show that the improved LEACH protocol has further reduced the energy consumption of nodes and balanced the load of the entire network.

Energy model
The energy calculation model used in this article is consistent with LEACH. The energy loss in the data transmission stage is generated by the data transmission circuit and the power amplifier circuit. The energy model used by the protocol depends on the distance between the transmitter and the receiver. If the distance is less than d 0 , the free space model is adopted, and if the distance is greater than d 0 , the multi-path attenuation model is adopted [10][11][12][13][14].The free space model and the multi-path attenuation model are shown in Fig. 2 and Fig. 3 respectively: Example: If you want to send k bit data between two nodes, the distance between the nodes is d, and the energy consumed for sending and receiving k bit data is E T X (k, d) ,E RX (k, d) as shown in formula 2 and formula 3: Among them, E elec is the energy consumed by the receiving or transmitting circuit to process data, ε f s is the parameter of the free space model, ε amp is the parameter of the multi-path attenuation model, and d 0 is the distance threshold.
It can be seen from the above energy calculation model that the amount of energy consumption mainly depends on the amount of data forwarding and the distance between the nodes. The CH far away from the BS will consume more energy when forwarding data. As a result, the energy of nodes in the entire network will become unbalanced. To balance the energy loss and prolong the network life cycle, on the one hand, this paper improves the cluster head election threshold. On the other hand, in the data forwarding phase, ordinary nodes are allowed to reach BS by single-hop, and the mechanism of coexistence of single-hop and multi-hop is introduced to reduce the load of cluster head nodes.

LEACH protocol optimization and improvement
Through the above analysis, the deficiencies of LEACH protocol have been summarized and corresponding optimizations have been made. First of all, the CH election method avoids the shortcomings of randomly electing CHs in LEACH protocol, and considers node energy, distance from the BS, and node density to select the CH. Next, on the one hand, it is judged in each cluster whether it is necessary to generate a spare CH to reduce the load of the CH. On the other hand, the node's data is forwarded by the coexistence of single-hop and multi-hop mechanisms, while allowing ordinary nodes to send data to the BS directly.
In the election of CHs, this paper introduces two thresholds T 1 (n) and T sub (n), which are used to elect the CHs and the backup CHs respectively. In the process of selecting the CH, since the energy of the node, the distance from the BS, and the node density are comprehensively considered, the energy factor, distance factor, and density factor are correspondingly introduced to calculate the threshold T 1 (n). After the CH selection is completed, the threshold T sub (n) is calculated to determine whether a spare CH needs to be generated.

Energy factor
The energy of the node is the basis for the normal operation of the entire WSNs. Therefore, energy must be taken as the primary consideration for the entire network under any circumstances. When a node is selected as the CH, it will consume more energy because it has to forward more data packets. Therefore, this paper introduces an energy factor E to avoid nodes with lower energy being selected as CHs [15][16][17].
Where E curr is the current remaining energy of the node, and E 0 is the initial energy of the node.

Distance factor
The strength of the received signal of a node is inversely proportional to the distance. The closer the distance between nodes, the stronger the received signal. According to the above principle, this paper defines a distance factor D to measure the distance between the CH and the sink node [18].
Where d max is the farthest distance between the node and the sink node. d min is the closest distance between the node and the sink node. d i is the distance between the current node and the sink node.

Density factor
The density factor of the node is used to measure the density around the node. If the density near the node is too small, it is not suitable to be elected as a CH. Each node has a maximum communication range R. The density factor ρ refers to the ratio of the number of nodes in R to the number of nodes in the standard cluster. The calculation method of the maximum communication range R and the density factor ρ of the node is: Where S is the area of the monitoring range, N is the number of nodes in the monitoring range, N ij is the number of neighbor nodes within the standard communication radius, p is the probability of being elected cluster head, 1 p − 1 is the number of nodes in the standard cluster.

Selection of cluster head and backup cluster head
1) The threshold T 1 (n) selected as the cluster head Considering the above three factors, the LEACH protocol threshold T (n) is updated to T 1 (n): Among them, α 1 , α 2 , and α 3 are the weights of energy factor, distance factor and density factor respectively, and α 1 +α 2 +α 3 =1.
According to formula 9, when the energy factor E of node will become smaller and smaller as the number of rounds increases, the corresponding threshold T 1 (n) will become smaller and smaller, which reduces the probability of low-energy nodes becoming CHs. The farther the node is from the sink node, the larger the D, and the smaller the corresponding threshold T 1 (n). Similarly, the larger the node density, the larger the ρ, and the larger the corresponding T 1 (n). Therefore, the formula meets the expectations of selecting CHs and ensures the rationality of CHs.
2) Determine whether a backup cluster head needs to be generated Because the CH will receive the data from all the nodes in the cluster, the energy of the CH node will be exhausted quickly. Therefore, it is necessary to select a backup CH. But we can't choose the backup CH for all clusters. Only when the load of the CH is large, the backup CH will be generated. The threshold T sub (n) for electing a backup CH is: Where k is the control parameter, 0 < k < 1, E re is the current remaining energy of the cluster head, E max is the initial energy of the CH, d max is the farthest distance between the node and the BS in the entire network, and d i is the distance between the CH node and the BS, N total is the number of nodes in the entire network, and N i is the number of nodes in the cluster. After the CH selection is completed, if the random number is greater than the threshold T sub (n), then a backup CH needs to be allocated for the CH. When the cluster is successfully constructed, select an optimal node from the ordinary nodes as the backup CH.
3)Backup CHs are selected from ordinary nodes When the CH node needs a backup CH, it can be seen from formula 2 that under the premise of sending the same data packet, the longer the distance between nodes, the more energy is consumed. In addition, it needs to have enough energy as a backup CH [19]. Therefore, we can select the optimal backup CH according to formula 12: Where E re (i) is the energy of the current node, E T X (i, k, d) is the energy consumed by node i to send k bit data to the BS with distance d.
According to formula 12, the more the current energy of the node, the greater the T s (i). Under the premise of sending the same bit of data, the closer the distance, the greater the T s (i). Therefore, traverse all ordinary nodes in the cluster and select the node with the largest T s (i) value as backup CH, which ensures that the elected backup CH is reasonable.

LEACH-SUB-MUTI protocol process description
LEACH-SUB-MUTI protocol adopts the clustering method of LEACH protocol. But the LEACH-SUB-MUTI protocol is optimized in CH election and data forwarding. Besides, a backup CH is introduced to reduce the load of the CH and balance the energy consumption of the entire network. In the cluster construction stage, the node selects the CH according to the energy factor, distance factor, and density factor. After the CH is selected successfully, it is judged whether it needs to generate a backup CH. In the data transmission stage, ordinary nodes and CHs both use single-hop and multi-hop coexistence mechanisms to forward data, while allowing ordinary nodes to forward data to the BS directly. The protocol has reduced energy consumption and further extended the network life cycle. The flow chart of cluster establishment phase and data transmission in LEACH-SUB-MUTI protocol are shown in Fig.4 and

Simulation environment
This paper uses MATLAB simulation software to carry out simulation experiments. The protocol proposed in this paper is compared with the LEACH protocol and the protocol in literature [5]. The experiment shows that the improved protocol has a large degree of improvement in the life cycle and throughput. 200 nodes are randomly deployed in a simulation area of 200m*200m, and the specific parameters of the experiment are shown in Table 1:  The simulation experiment results show that compared with the LEACH protocol and LEACH-C protocol, the improved protocol in this paper has achieved more significant effects in reducing energy consumption and extending the network life cycle. The energy consumption comparison of the three protocols is shown in Fig. 6 and Fig. 7. Fig. 6 shows the LEACH protocol, LEACH-C protocol, LEACH-SUB-MUTI protocol, the number of rounds in which the first node die, a percentage of ten nodes die and all nodes die. It can be seen from the figure that the LEACH protocol has a node death phenomenon in about 70 rounds. The LEACH-C protocol introduces the concept of average energy when selecting CHs, and the node death phenomenon occurs in about 250 rounds. In the improved LEACH-SUB-MUTI protocol in this paper, the first node of death will be about 300 rounds. Besides, when ten percent of the nodes die, the LEACH protocol runs to 100 rounds at this time, but the LEACH-C protocol and the LEACH-SUB-MUTI protocol have reached the 400 rounds. Finally, when all the nodes die, the LEACH protocol and LEACH-C protocol work for about 1100 rounds. In the LEACH-SUB-MUTI protocol in this article, the entire network will work until about 1750 rounds before the node will all die. Similarly, Fig. 7 is a graph showing the number of dead nodes of different protocols in the entire network life cycle. Comparing the death process of the three protocol nodes, the nodes of LEACH protocol and LEACH-C protocol are dying faster than LEACH-SUB-MUTI protocol. Besides, the life cycle of LEACH-SUB-MUTI protocol is relatively long. It can be obtained from Fig.  6 and Fig. 7 that the energy consumption of nodes in the LEACH-SUB-MUTI protocol is more balanced, which reduces energy consumption and extends the life cycle of the network.  Fig. 8 shows the data forwarding capabilities of different protocols in the network. As we can see, when the WSN using LEACH protocol and leach-C protocol runs to about 1000 rounds, the data will not be forwarded because there are few surviving nodes. However, the WSN data using LEACH-SUB-MUTI protocol is continuously forwarded until the whole network loses the communication ability. Compared with the early stage of network operation, LEACH-SUB-MUTI protocol can guarantee the normal operation of WSN even though the amount of data forwarding is less in the later stage of network operation. In addition, the total amount of data forwarded by the LEACH-SUB-MUTI protocol is far more than the other two protocols. The improved routing protocol in this paper consumes less energy under the premise of sending more data packets, which is enough to show that the protocol has achieved significant effects in terms of low power consumption.

Comparison of the total energy of the network in different protocols
When the network is initialized, each node is given the same energy 0.5J, so the total energy of the entire network is 100J. Fig. 9 shows that the LEACH protocol has the most serious energy attenuation. However, LEACH-C considers the average energy of nodes when selecting CHs, so clustering is more reasonable. Besides, compared with the LEACH protocol, the LEACH-C protocol has relatively slow energy attenuation in the initial stage of network operation. In the later stage of the network operation of the WSN using LEACH-C protocol, because the energy of the nodes in the network is generally low, the clustering model has changed, so the energy attenuation is relatively serious. However, the energy consumption of LEACH-SUB-MUTI is very stable in the whole network running process. To sum up, the improved protocol in this paper can consume less energy under the premise of forwarding more data packets. Besides, the protocol has balanced network energy consumption and guaranteed data reliability. Therefore, the performance of this protocol is superior to the other two protocols in many aspects, and the goal of low power consumption is achieved.

Summary and prospect
Compared with flat routing protocols, LEACH hierarchical routing protocol can effectively reduce node energy loss and improve the network life cycle. However, LEACH protocol also has problems such as uneven node energy consumption and excessive load on some nodes. Therefore, this paper has proposed an improved protocol based on LEACH. The improved protocol has balanced the energy consumption of the network and prolonged the life cycle of the network. However, in this paper, TDMA is used to forward data. Because each node sends data in its time slot, when a large amount of data needs to be forwarded, the data may not be effectively forwarded in a short time slot. In this way, the protocol will cause the data transmission delay. In WSN with high real-time requirements, the disadvantages of this protocol will be further amplified. To sum up, our next work will focus on reducing the delay of data transmission and ensuring the reliability of data. Under the premise of low power consumption, the data can be transmitted efficiently.

Authors' contributions
This paper makes some improvements in both the setup phase and the steady phase to address the shortcomings of the LEACH protocol. In the process of electing CH, the protocol considers the energy of the node, the distance from the node to the BS, the density around the node, and so on. After the cluster is formed, the backup CHs in the cluster are selected according to the load of the CH nodes. In the data transmission stage, if there is a backup CH in the cluster, the nodes in the cluster send data to the CH firstly, and then when the energy of the CH node is lower than the average energy, the backup CH temporarily acts as the CH to forward data to the BS. This protocol allows normal nodes to forward data to the BS directly. When ordinary nodes forward data to the CH, the data can be forwarded by combining single-hop and multi-hop. Similarly, the data of the CH is also forwarded to the base station in the same way.