#### Abstract

Wireless sensor network technology is widely used in various modern scenarios, and various industries have higher and higher requirements for the performance indicators of wireless sensor networks. A reasonable and effective layout of wireless sensor networks is conducive to the monitoring of environmental quality, various transactions, and status and transmits a large number of sensing data to the data aggregation center for processing and analysis. However, the operation and development of traditional wireless sensor networks are extremely dependent on the energy supply of the network. When the corresponding supply energy is limited, the operation life of the corresponding wireless sensor network will be greatly reduced. Based on the above situation, this paper proposes a nonuniform clustering routing protocol optimization algorithm from the energy loss of cluster head and clustering form algorithm in wireless sensor networks. At the level of cluster head calculation in wireless sensor networks, firstly, based on the adaptive estimation clustering algorithm, the core density is used as the estimation element to calculate the cluster head radius of wireless sensor networks. At the same time, this paper creatively proposes a fuzzy logic algorithm to further solve the uncertainty of cluster head selection, integrate the residual energy of cluster head nodes, and finally complete the reasonable distribution of cluster heads and realize the balance of node energy consumption. In order to further reduce the algorithm overhead of transmission between cluster heads and realize energy optimization, an intercluster routing optimization algorithm based on the ant colony algorithm is proposed. The pheromone is updated and disturbed by introducing chaotic mapping to ensure the optimal solution of the algorithm, and the optimal path is selected from the perspective of energy dispersion coefficient and distance coefficient, so as to optimize the energy consumption between cluster heads. The experimental results show that compared with the traditional algorithm, the proposed nonuniform clustering routing protocol optimization algorithm prolongs the corresponding life cycle by 75% and reduces the total network energy consumption by about 20%. Therefore, the algorithm achieves the purpose of optimizing network energy consumption and prolonging network life to a certain extent and has certain practical value.

#### 1. Introduction

A wireless sensor network is formed by a large number of wireless sensors through reasonable layout. It is widely used in national defense, military, industrial production, and other activities. The traditional wireless sensor network communication protocol mainly includes an application layer, transmission layer, network layer, data link layer, physical layer, energy management layer, mobile management layer, and task management layer. In the corresponding energy management layer, the wireless sensor network realizes the management of system energy and prolongs the service life of the system as much as possible. A wireless sensor is a small unit constituting wireless sensor network, which is mainly used for specific data acquisition, data processing, data storage, and transmission of the monitored environment. Its corresponding structure is usually small, so its corresponding power supply part often uses small battery for power supply [1–3]. When the corresponding wireless sensor network is arranged in a harsh environment, the timeliness of the corresponding battery replacement is weak, resulting in the downtime of the wireless sensor network once the battery energy in the environment is exhausted, so the wireless sensor will not be able to collect, compress, and transmit data in a specific area; therefore, it will seriously affect the whole wireless sensor network [4, 5]. Therefore, based on the above analysis, the energy balance of wireless sensor networks, the optimization of energy nodes, and the maximization of network life cycle are important problems that need to be solved urgently in wireless sensor networks for the Internet of things [6]. How to optimize the energy consumption of each node from the whole wireless sensor network, so as to optimize the energy consumption of the whole network, realize the balance of energy consumption of wireless sensor network, and avoid the problem of excessive energy consumption of individual nodes, so as to prolong the service life of the network, is very important and meaningful.

From the routing protocol algorithm level of wireless sensor networks, its main research contents focus on two levels: hierarchical routing protocol and planar routing protocol [7]. The corresponding plane routing protocol mainly takes the data as the center and continuously sends the corresponding data to the corresponding adjacent data nodes in the form of broadcasting. Generally speaking, the plane routing protocol is relatively simple, and its corresponding application scenarios are mostly concentrated in the case of a small number of nodes. It has no advantages in network scalability, network delay, and energy consumption balance [8, 9]. The corresponding hierarchical routing protocol is mainly based on the idea of clustering. It divides the nodes into cluster head nodes and conventional nodes. The corresponding conventional nodes are mainly used to collect sensing data and send it to the corresponding cluster head nodes. The cluster head nodes are responsible for transmitting the corresponding merged data to the base station for processing [10]. Based on this conventional hierarchical routing protocol, the corresponding data transmission modes are divided into two modes: intracluster transmission and intercluster transmission. On the problem of corresponding cluster formation, the current main strategies include clustering algorithm, uniform clustering algorithm, and nonuniform clustering algorithm. The main purpose of the corresponding clustering algorithm and uniform clustering algorithm is to effectively balance the corresponding load among clusters, so as to balance the energy consumption of each cluster head. The corresponding nonuniform clustering algorithm is mainly used to deal with the uneven location distribution and energy distribution of network nodes. Its classical nonuniform clustering algorithm includes distributed competitive nonuniform clustering algorithm and fuzzy logic nonuniform algorithm [11, 12]. However, the above traditional wireless sensor network routing protocol algorithms have more or less the randomness of cluster head selection, the subjectivity of cluster head size selection, and the corresponding routes between cluster heads fall into the dilemma of local optimization rather than global optimization. Therefore, the routing protocol algorithm of wireless sensor networks with excellent performance is very meaningful.

Based on the above analysis, the current wireless sensor networks still have unreasonable energy consumption allocation at the level of energy management. At the same time, the traditional nonuniform clustering routing protocol algorithm can not solve the current problem of reasonable energy consumption allocation. Based on this, this paper will start with the cluster head energy consumption and clustering algorithm of wireless sensor networks and propose a nonuniform clustering routing protocol optimization algorithm. Firstly, based on the adaptive estimation clustering algorithm, the core density is used as the estimation element to calculate the cluster head radius of wireless sensor networks. At the same time, a fuzzy logic algorithm is innovatively proposed to further solve the uncertain problem of cluster head selection and integrate the residual energy of cluster head nodes, The comprehensive factors such as node density and corresponding node energy consumption finally complete the reasonable allocation of cluster heads and realize the balance of node energy consumption. In order to further reduce the algorithm overhead of transmission between cluster heads and realize energy optimization, this paper proposes an intercluster routing optimization algorithm based on the ant colony algorithm, which updates and perturbs the pheromone by introducing chaotic mapping, so as to ensure the optimal solution of the algorithm, and selects the optimal path from the perspective of energy dispersion coefficient and distance coefficient, so as to optimize the energy consumption between cluster heads. The experimental results show that the proposed nonuniform clustering routing protocol optimization algorithm for wireless sensor networks extends its corresponding life cycle by 75% compared with the traditional algorithm, and its corresponding total network energy consumption speed is improved. Therefore, the algorithm achieves the purpose of optimizing network energy consumption and prolonging network life to a certain extent and has certain practical value.

The chapters of this paper are arranged as follows: Section 2 mainly analyzes the current research status of clustering routing protocol algorithm for wireless sensor networks for the Internet of things and points out the existing problems. In Section 3, the cluster head allocation problem will be analyzed and studied based on adaptive estimation clustering algorithm and fuzzy logic algorithm. At the same time, the intercluster head routing optimization algorithm will be optimized based on the ant colony algorithm, so as to optimize the energy consumption between cluster heads, and finally realize the optimization of nonuniform clustering routing protocol algorithm in wireless sensor networks. Section 4 will verify the algorithm and analyze the experimental results. Finally, a summary of this paper is made.

#### 2. Related Research Work: Analysis of the Research Status of Clustering Routing Protocol Algorithm for Wireless Sensor Networks for the Internet of Things

In order to solve the energy consumption problem of traditional wireless sensor networks, the current mainstream energy management algorithms include random clustering routing protocol algorithm, uniform clustering routing protocol algorithm, and nonuniform clustering routing protocol algorithm [13–15]. Based on the above three algorithms, a large number of research institutions and researchers have studied and analyzed them. This paper only discusses uniform clustering algorithm and nonuniform clustering algorithm. For the uniform clustering algorithm, relevant Japanese scientists first proposed a hybrid energy-efficient clustering protocol, which fully considers not only the residual energy but also the average value of the minimum achievable energy consumption. The cluster heads with large energy will compete to select clusters. The cluster heads corresponding to the algorithm are evenly distributed and support scalable data fusion, thus effectively prolonging the data life cycle [16]. Relevant European researchers have proposed a hybrid energy efficient clustering protocol with fuzzy energy consumption characteristics based on the hybrid energy-efficient clustering protocol. The corresponding fuzzy energy consumption depends on the node density and node centripetality. The cluster head can be determined by comparing the corresponding fuzzy energy consumption. The corresponding clustering speed of the algorithm is fast, and the corresponding clustering is relatively uniform, Therefore, the corresponding energy consumption is also relatively uniform [17]. However, the uniform clustering routing protocol algorithm has the phenomenon of large energy consumption of nodes near the base station and premature downtime of nodes. Therefore, relevant researchers proposed a nonuniform clustering routing protocol algorithm to prolong the life cycle of wireless sensor networks in the form of nonuniform clustering [18]. Relevant Asian researchers have proposed an improved nonuniform clustering routing protocol algorithm based on the traditional nonuniform clustering routing protocol algorithm. The algorithm randomly selects candidate shots, competes for the final cluster head within its own cluster radius by comparing the residual energy, and carries out adaptive calculation based on the calculation formula of nonuniform clustering radius; the algorithm avoids the energy waste caused by long-distance data transmission and further improves the hot spot problem caused by excessive forwarding energy consumption of cluster heads [19]. Based on the above analysis, the above algorithms have more or less problems, such as unreasonable selection of cluster heads and excessive energy consumption during transmission between cluster heads.

#### 3. Analysis of Nonuniform Clustering Routing Protocol Optimization Algorithm in Wireless Sensor Networks

This section mainly starts with the cluster head energy consumption and clustering algorithm of wireless sensor networks and proposes a nonuniform clustering routing protocol optimization algorithm. At the level of clustering algorithm, it is mainly based on the adaptive estimation clustering algorithm and takes the kernel density as the estimation element to calculate the cluster head radius of wireless sensor networks. At the same time, it further solves the uncertain problem of cluster head selection based on fuzzy logic algorithm and integrates the residual energy of cluster head nodes; the comprehensive factors such as node density and corresponding node energy consumption finally complete the reasonable allocation of cluster heads and realize the balance of node energy consumption. In order to further reduce the algorithm overhead of transmission between cluster heads and realize energy optimization, this section proposes an intercluster routing optimization algorithm based on ant colony algorithm, which updates and perturbs the pheromone by introducing chaotic mapping, so as to ensure the optimal solution of the algorithm, and selects the optimal path from the perspective of energy dispersion coefficient and distance coefficient, so as to optimize the energy consumption between cluster heads. The principle block diagram corresponding to the nonuniform clustering routing protocol optimization algorithm of wireless sensor networks analyzed in this section is shown in Figure 1:

##### 3.1. Cluster Head Selection Optimization Algorithm Analysis

Before the algorithm runs, three models of the algorithm are established, which correspond to the network model, data aggregation model, and node energy consumption model. The corresponding network model is mainly the assumption of wireless sensor network algorithm. The corresponding data model is mainly to reduce the corresponding node data redundancy. The corresponding model is an *Ia* model mechanism. The length of the data packet after the aggregation of the corresponding model is shown in Formula (1), where the corresponding represents the length of the data packet after the data aggregation and the corresponding represents the packet length received by the corresponding node.

At the level of corresponding energy consumption model, the model used by this algorithm is the first-order wireless communication model, and the corresponding model principle block diagram is shown in Figure 2. From the principle block diagram, it can be seen that the corresponding node energy consumption includes transmission energy consumption and reception energy consumption, the corresponding transmission energy consumption includes a transmission circuit and transmission amplifier, and the corresponding reception energy consumption includes a signal receiving circuit. The corresponding mathematical calculation output energy consumption and receiving energy consumption is shown

Based on this calculation formula, the energy consumption distribution formula corresponding to the cluster head node can be further obtained. The calculation formula is shown in

When calculating the cluster head radius of the system network, it is mainly estimated based on the kernel density. The corresponding cluster head size mainly depends on the density of node distribution, the dispersion of node distribution, and the relative residual energy of nodes. At the node distribution density level, when the corresponding nodes are densely distributed, the corresponding load of the cluster head can be reduced by reducing the cluster head radius, so as to avoid the rapid failure of the system cluster head. On the contrary, for the local area with sparse node distribution, the corresponding cluster head radius can be appropriately increased; the dispersion of the corresponding cluster head node will affect the radius of the cluster head node. When the corresponding wireless sensor network system transmits data to the cluster head node, the corresponding energy loss is positively correlated with the distance to the cluster head node. When the distribution of the corresponding cluster head nodes is relatively discrete, the wireless sensor network needs to consume a lot of energy to transmit to the cluster head node, at this time, the cluster head radius can be appropriately reduced to realize the energy consumption of data transmission in the cluster head. The amount of residual energy of the corresponding cluster head node is related to the cluster head radius. The larger the corresponding residual energy is, the larger the corresponding cluster head radius is. However, with the continuous consumption of energy of wireless sensor network nodes, the corresponding cluster head radius is decreasing. Therefore, based on the analysis of the above influencing factors, the corresponding node adaptive cluster head radius algorithm steps are as follows:

Step1: the kernel density estimation is calculated based on the above influencing factors. The corresponding estimation function is shown in formula (5), where the corresponding represents data nodes in the wireless sensor network and the corresponding represents the normal kernel function, which reflects the dispersion of the distribution of data nodes.

Step 2: estimate the local bandwidth of the wireless sensor network. The local bandwidth is still estimated by using the relevant factors analyzed above. Adaptive bandwidth estimation is performed after local bandwidth estimation. The corresponding calculation formula of adaptive bandwidth estimation is shown in formula (6), where the corresponding represents the sensitive factor factor. The larger the corresponding sensitive factor, the more sensitive the function estimated based on kernel density is.

Step3: fit and estimate the cluster head radius based on the adaptive bandwidth. At this time, the calculation formula of the corresponding cluster head radius is shown in formula (7). Control the corresponding cluster head radius between the minimum cluster head radius and the maximum cluster head radius. It can be seen from the function that the cluster head radius is inversely correlated with the kernel density estimation function.

Based on the above determination of cluster head radius, this paper reconfirms the uncertain cluster head based on fuzzy algorithm. The core algorithm is as follows: firstly, we calculate the distance between each node of the sensor network and the base station. The closer the corresponding node is to the base station, the greater the probability that it will become an important cluster head node. At the same time, it is proved that the competitiveness of this cluster head is strong. Therefore, based on this characteristic, fuzzy rules are used to further deal with the uncertainty of competition between cluster heads. The fuzzy inputs used in this paper correspond to the residual energy of cluster heads and the distance from nodes to base stations, and the corresponding fuzzy output variables are only limited to the ability of competing cluster heads. The logic block diagram of the corresponding cluster head deterministic algorithm based on fuzzy logic is shown in Figure 3. It can be seen from the figure that the main two core mechanisms of the fuzzy logic algorithm are fuzzification processor and defuzzification processor, respectively, and the corresponding core analysis module is fuzzy reasoning module.

Based on the above, we can further determine the cluster head of wireless sensor network and optimize the selection of cluster head.

##### 3.2. Analysis of Energy Consumption Optimization Algorithm among Cluster Heads

In order to further optimize the energy optimization between cluster heads of wireless sensor networks, this section optimizes the routing algorithm between cluster heads of wireless sensor networks based on ant colony algorithm, so as to reduce the output transmission energy consumption between cluster heads. This paper mainly optimizes the transition probability formula in the traditional ant colony algorithm. In the traditional algorithm, only a single distance index is used as the heuristic factor, which will essentially lead to the excessive consumption of node energy between cluster heads. Therefore, this section considers the transfer probability formula of the ant colony algorithm from the front-end and back-end levels. At the corresponding front-end level, the pheromone heuristic factor and distance factor between cluster heads are mainly considered. At the back-end, the balance degree of cluster heads between nodes and the tolerance of the balance degree are mainly considered. Combined with the factors of the front-end and back-end, the corresponding transfer probability formula of the improved ant colony algorithm is shown in formula (8), in which the corresponding represents the concentration heuristic factor of information elements, the corresponding represents the path heuristic factor of cluster head transmission, and the corresponding represents the importance of the above two heuristic factors.

Based on this, the principle and steps of the intercluster energy consumption optimization algorithm based on the improved ant colony algorithm are shown in Figure 4 below. It can be seen from the figure that the details of the corresponding algorithm are as follows:

Step 1: initialize the parameters of the wireless sensor system. The corresponding initialization information includes initialization pheromone, node initial energy, heuristic factor, and other parameters.

Step 2: perform iterative processing based on ant colony algorithm on the corresponding source cluster head and update it in time.

Step 3: constantly check whether there is a next hop node to be selected in the adjacency table. If it does not exist at this time, continuously expand the search radius and update the adjacency status in time until it is found.

Step4: select the next hop node of the wireless sensor network based on the improved transition probability formula, record the corresponding update node and path information, and update the local information.

Step 5: judge whether the number of iterations has been reached. If not, repeat steps 2-4 until the algorithm is terminated.

#### 4. Experiment and Data Analysis

In order to verify the algorithm proposed in this paper, it is simulated and verified based on MATLAB. The corresponding verification experiments mainly include two cases: the base station of wireless sensor network is located in the middle of the network and the base station of wireless sensor network is not located in the middle of the network. In order to further control the variables, the corresponding simulation sensor is set to 200, and the traditional cluster head selection mechanism is introduced into the cluster head selection mechanism for comparative experiments. In the algorithm evaluation index, this paper selects the wireless sensor network life and energy consumption efficiency as the evaluation index.

*Experiment 1. *The base station of wireless sensor network is located in the middle of the network.

Based on the comparative experiment between the algorithm proposed in this paper and the traditional algorithm, the corresponding node survival number experimental results are shown in Figure 5. It can be seen from the figure that the corresponding node failure rate of the algorithm proposed in this paper is low, and the corresponding node failure rate continues to slow down with the passage of time, while the traditional algorithm is still relatively steep, so the overall network life becomes longer.

The corresponding Figure 6 shows the corresponding network average energy residual curve under the two algorithms. From the figure, it can be seen that the algorithm proposed in this paper has more residual energy than the traditional algorithm. At the same time, the gap between the residual energy is further widened with the passage of time, which further highlights the advantages of this algorithm at the level of node energy consumption balance.

*Experiment 2. *The base station of wireless sensor network is not located in the middle of the network.

Based on the comparison experiment between the proposed algorithm and the traditional algorithm, the corresponding node survival number experimental results are shown in Figure 7. It can be seen from the figure that in this case, the corresponding node failure rate of the proposed algorithm and the traditional algorithm is not different, but on the whole, the failure rate of the proposed algorithm is still slightly lower, At the same time, its corresponding node failure rate decreases with the passage of time, so the overall network lifetime still has advantages over traditional algorithms.

The corresponding Figure 8 shows the corresponding network average energy residual curve under the two algorithms. It can be seen from the figure that the algorithm proposed in this paper still has advantages over the traditional algorithm in terms of the corresponding node residual energy. At the same time, the gap between the residual energy and the traditional algorithm is further widened with the passage of time. Therefore, it further highlights the advantages of this algorithm in node energy consumption balance.

In the verification of the corresponding intercluster head routing algorithm, this paper makes an experimental analysis on the energy efficiency between cluster heads based on scenario 2. The experimental results also verify that the clustering routing optimization algorithm under this algorithm consumes less energy than the traditional algorithm in data transmission between cluster heads, so the corresponding wireless sensor network has better stability at this time. According to the above experimental results, it can be further analyzed that the corresponding uniform algorithm and the traditional nonuniform algorithm have the problem of excessive energy consumption. At the same time, it also further proves the disadvantages of the uniform algorithm in the nonuniform scene and the uncertainty problem of the traditional nonuniform algorithm.

Based on the above experimental results, it can be seen that the proposed algorithm has obvious advantages over the traditional algorithm.

#### 5. Conclusion

This paper mainly analyzes and studies the current research status of clustering routing protocol algorithms for wireless sensor networks for the Internet of things, focuses on the problems existing in nonuniform cluster routing protocol algorithms, and optimizes and improves the traditional algorithms for the corresponding energy management problems. This paper uses the adaptive estimation clustering algorithm and takes the kernel density as the estimation element to realize the optimal selection of cluster heads and the establishment of cluster head mechanism in wireless sensor networks. At the same time, a fuzzy logic algorithm is innovatively proposed to further solve the uncertain problem of cluster head selection and integrate the residual energy of cluster head nodes, and the comprehensive factors such as node density and corresponding node energy consumption finally complete the reasonable allocation of cluster heads and realize the balance of node energy consumption. In order to further reduce the algorithm overhead of transmission between cluster heads and realize energy optimization, a routing optimization algorithm between cluster heads is proposed based on the ant colony algorithm. The pheromone is updated and disturbed by introducing chaotic mapping, so as to ensure the optimal solution of the algorithm, and the optimal path is selected from the perspective of energy dispersion coefficient and distance coefficient; thus, the energy consumption between cluster heads is minimized. The experimental results show that compared with the traditional algorithm, the corresponding life cycle of the proposed nonuniform clustering routing protocol optimization algorithm for wireless sensor networks is prolonged by 75%, and the total energy consumption speed of the corresponding network is improved. In the follow-up research, this paper will focus on more factors affecting the selection of cluster heads, control and deal with their factors, and study the corresponding processing algorithms to realize the global optimization of system network parameters, so as to further reduce the energy consumption of wireless sensor networks and prolong the life cycle of the system.

#### Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

#### Conflicts of Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

#### Acknowledgments

The work was supported by the Hunan Provincial Research Foundation of Education Bureau of China (Grant Nos. 18B529 and 18A481).