Improvement of LEACH Algorithm Based on Inter-Cluster Ring Routing Strategy

Wireless Sensor Network (Wireless Sensor Network, WSN) is a self-organizing network formed by a large number of wireless sensor nodes through radio communication [1]. The sensor nodes in the network cooperate with each other to monitor and collect the object information in the observation area, and the information is transmitted to the users who need this information after data fusion processing. It is often deployed in harsh environments, such as oceans, deep forests, and deserts. At the same time, the sensor nodes in the network are powered by batteries [2]. These external factors make it impossible to replace batteries manually. Therefore, energy is an important resource for wireless sensor networks [3]. In this paper, aiming at the problems of LEACH inter-cluster communication, from the perspective of energy saving, an improved strategy using inter-cluster ring routing is proposed. This strategy first abstracts all sensor nodes into a ring system model during the network topology formation stage. In the data transmission stage, a ring transmission strategy is adopted, and nodes on the ring are used to randomly and evenly undertake data transmission tasks, so the imbalance of energy consumption of sensor nodes can be effectively reduced. Simulation experiments show that this strategy can extend the network life cycle to a certain extent.

cluster establishment and data transmission. In the cluster establishment phase, all sensor nodes randomly generate cluster heads through autonomous cluster head elections, and the sensor nodes that become cluster heads randomly broadcast information to the surroundings [6]. The surrounding sensor nodes judge the cluster to join based on the strength of the received signal. In the data transmission stage, the sensor nodes in the monitoring area collect monitoring information [7]. After obtaining the time slot allocated by the cluster head, the information is sent to the cluster head, and the cluster head performs data fusion processing and transmits it to the base station [8]. After one round of the Leach algorithm, it enters the next round, and Leach algorithm re-selects cluster heads and divides clusters according to the same method described above, so as to achieve the effect of balancing the load of network nodes.
In the stable working phase, the cluster head mainly completes the transmission of the data collected by the member nodes in the cluster [9]. When the allocated time slot arrives, the sensor nodes in the cluster get an opportunity to transmit data to the cluster head and begin to transmit data. The time required for a sensor node to successfully send a data frame depends largely on the number of sensor nodes in the cluster.
In the data transmission stage, the cluster head close to the sink has a large amount of sending tasks, which not only needs to send the data collected by the nodes in the cluster, but also forward the data from other nodes. After the communication continues for a period of time, the nodes close to the BS will die the earliest, and the nodes close to the BS cannot forward the data sent by other nodes after death, thus forming a "hot spot effect" [10].

Inter-Cluster Ring Routing Strategy System Model
In the algorithm that adopts the inter-cluster ring routing strategy, the cluster head node is identified as a key node, and the ordinary sensor node is only responsible for data collection and is defined as a blind node. The system model consists of a batch of key node cluster heads and ordinary nodes covering the cluster head. The sensor consists of blind nodes, and the sink is at the center of the network. The system model is shown in Figure 1. In the model, the black five-pointed star, square and triangle nodes represent the cluster head nodes on the first, second, and third layers, respectively, and the remaining circular nodes distributed around are general sensor nodes. For a node located in the nth ring, its ring number is counted as Layer n = . Hop number from node to sink is an important parameter of the model. Define the Hop value of the center sink as 0, and the Hop number of other nodes as: Among them, Ω represents the width of the ring and Layer is the ring number. As the network scale expands, the number of rings gradually increases.
The adjustment factor i is used to adjust the hop count change caused by the change of the cluster head node, where The parameter σ is used to identify whether it is a normal node or a cluster head node. The cluster heads and cluster head nodes of each adjacent ring are in a many-to-many relationship, and each cluster head maintains multiple neighbor node addresses and selects the optimal path to reach the sink. Figure 2 shows the sector model constructed by the sink node at the edge of the network. But Figure 1 can represent the generality of the network topology, so the model in Figure 1 is still used in the following discussion.

Topology Formation Stage
The inter-cluster energy dichotomy algorithm is an improved algorithm of LEACH algorithm for inter-cluster communication, and other parts generally use LEACH algorithm. In the cluster head selection stage, each sensor node randomly generates a random number between [0, 1]. If the random number is less than the set threshold ( ) n T t , it becomes a cluster head, otherwise it becomes a non-cluster head node. In order to build the ring system model, the cluster head broadcasts the information frame to the entire network. The frame format is shown in Figure 3.
Among them, the flag is used to distinguish other information in the network; Ω represents the width of the ring; the number of hops CNT records the number of hops that the information has reached the sink in the network, ID  represents the address of the node, and Eava is the remaining energy of the node. In the initialization phase, after the node receives the networking information, the first step: the node i checks the CNT item in the frame. If CNT > Local CNT, it means that the information comes from the outer node, and the node i directly discards the frame. If, CNT = Local CNT, it means it is from the same layer, and the node directly discards the frame. If CNT = Local CNT, then update the local CNT to CNT.
Step 2: After the node i updates the local CNT, it obtains the number of hops to sink, takes out the Eava value and ID address in the networking information frame, writes this information into the routing table of the node, and then the node forwards the information.
Finally, the cluster head nodes in the network can form a system topology similar to that shown in Figure 1. Each cluster head node can confirm the ring number Layer in the network and the information of other nodes in the ring.

Data Transmission Stage
Assuming that the outermost ring is the nth ring, the inward ring is 2) Since there are multiple cluster heads nn CH in each ring, in the process of transmitting information to a ring, the node with the largest energy is selected as the next hop node. If the remaining energy of multiple cluster heads is the same, the nearest cluster head is selected as the next hop routing node.
The algorithm flow of the inter-cluster ring routing strategy is as follows:  Figure 4 shows the energy dichotomy model where n is an even number of 8 nodes.
The data is transmitted from the 8th ring to the 8 2 4 ÷ = ring, the 4th ring is transmitted to the sink, the data on the 7th ring is transmitted to the 8 2 1 3 − = ring first, and the 3rd ring is transmitted to the sink; the data on the 6th ring is transmitted to the 8 2 2 2 − = ring, and the second ring Transfer to the sink; and so on, the data on the fifth ring is transferred to the 8 2 3 1 − = ring, and the first ring is transferred to the sink. Figure 5 shows the ring routing strategy model between clusters of 7 nodes where n is an odd number.
Data is transmitted from ring 7 to ring ( ) Aiming at the problem of "hot zone effect" produced by LEACH algorithm. In the inter-cluster ring routing strategy algorithm, taking 4 ordinary nodes and a

Establishment of Simulation Environment
In order to avoid interference from other factors, it is much clearer to verify that the inter-cluster ring routing strategy is more effective than single-hop communication and multi-hop communication between clusters. The experiment only observes the communication mode between the cluster head and the cluster head, and the intra-cluster node communication is ignored. The network simulation topology is shown in Figure 6.
Among them, n0 is set as the sink node, the initial energy is large and energy consumption is not considered. n1, n2, n3 and n4 are the cluster head nodes. Set the energy model value to Energy Model, the initial energy value of the sensor is 2J; the energy consumption per unit time for sending and receiving data is 2.0mw; the energy consumption per unit time during sleep is 0.001mw, between clusters. The routing mode is static routing, and the value is NOAH.
The source node n1, n2, n3, and n4 set up an Agent to send messages, and the destination n0 set a SinkAgent to receive messages. Then, the source node uses the CBR traffic generator to generate a service flow at a fixed rate and send a 500 Byte message to the sink node. At the same time, the data packet size transmitted by the network layer is set to 1500 Byte. The fixed transmission rate CBR is built on UDP. The transmission rate of CBR is 1 Mps, and the size of each packet is 500 Byte. CBR starts transmission in 1 s and ends in 50 s. In Figure 7 NAM animation scene, all sensor nodes have the same initial energy. When the remaining energy of the sensor node is sufficient, the color of the node is displayed in green; when the energy of the sensor node enters the warning zone, the color of the node changes to orange; when the remaining energy of the sensor node is 0, the color of the node is displayed in red. When node n1, n2, n3, n4 communicate with node n0 for a period of time, as shown in Figure 8, the node on the fourth ring that is farthest from the sink at about 12.911467 s will die first and other nodes still have a lot of energy. It can be seen that when single-hop communication between clusters is used, the farther away the sensor node is from the sink, the greater the energy consumption, the farthest node from the sink is likely to die first, and the energy of the entire system is extremely uneven. Even if the nodes on the first ring have greater energy, the death of the nodes on the fourth ring leads to the end of the network life cycle, and the running time of the system is rapidly reduced.

1) NAM analysis and comparison
In Figure 8 inter-cluster multi-hop communication, the situation is opposite to inter-cluster single-hop communication. The node closest to the sink dies first. The node close to the sink not only consumes energy to send data, but also forwards data from other rings. Therefore, the n1 node first died and turned red at 16.915288 s. In this way, even if the node far away from the sink has a lot of energy, the information cannot be transmitted to the sink due to the failure of the next hop node, forming a hot spot effect. Therefore, the life cycle of a multi-hop communication network is closely related to the energy consumption of the first ring nodes. The nodes far away from the sink consume less energy, and the nodes near the sink consume more energy.  In the ring routing strategy communication between clusters in Figure 9, the communication mode is carried out in an ideal state, and the data on the , 1, , 2 1 n n n − +  -th ring is transferred to the 2 , 2 1, ,1 n n −  ring respectively, and then the information is directly transferred to the sink node. The energy consumption of the nodes on the first, second, and third rings closest to the sink is relatively average. At 22.284872 s, node 1 enters a low energy consumption state, and node 2 died. From the animation view, it can be seen that several sensor nodes close to the sink in the inter-cluster ring routing strategy communica- 2) Trace file data analysis A screenshot of the data part of the Trace file is shown in Figure 10.
Each record of Wireless Trace has 21 columns. In the first column, s means packet sending data; r means packet receiving event; d means packet discarding event; f means packet forwarding event. The second column indicates the time when the event was generated, the third column indicates the ID of the processing event node, the fourth column indicates different types of Trace, the fifth and sixth columns are separators, the seventh column is the ID number of the transmission packet, and the eighth The column indicates the type of the packet, the ninth column indicates the size of the packet transmitted at the transport layer, the 10th column is the expected value of the sending node to send the packet on the wireless channel, the 11th column is the MAC address of the receiving node, and the 12th column is the sending node The 13th column is