Secure Clustering Strategy Based on Improved Particle Swarm Optimization Algorithm in Internet of Things

This paper proposes a secure clustering strategy based on improved particle swarm optimization (PSO) in the environment of the Internet of Things (IoT). First, in the process of cluster head election, by considering the residual energy and load balance of nodes, a new fitness function is established to evaluate and select better candidate cluster head nodes. Second, the optimized adaptive learning factor is used to adjust the location update speed of candidate cluster head nodes, expand the local search, and accelerate the convergence speed of global search. Finally, in the stage of forwarding node election and data transmission, in order to reduce the energy consumption of forwarding nodes, each cluster head node elects a forwarding node among the ordinary nodes in its cluster, so that the elected forwarding nodes have the optimal energy and location relationship. Experiments show that the proposed method effectively prolongs the network lifetime compared with the comparison methods. The average node degree of the proposed method is less than 2.5.


Introduction
With the development of information society, the information industry is more and more vigorous, and the scope of information application is more and more extensive [1]. Especially in the process of the big data era, the acquisition of information has attracted more and more attention, and become one of the important hotspots of scientific research and value-added industry [2][3][4]. Effective information acquisition is the basis of information transmission, processing, mining, and application. Sensors connect the physical world and the digital world by capturing and revealing the physical phenomena of the world and transforming them [5]. Wireless sensor network (WSN) is a self-organized network composed of a large number of sensor nodes with information collection, processing, and transmission functions. Each sensor node can realize the data collection, processing, and transmission of the sensing area, and the whole network can cooperate to complete the information collection in the target area [6][7][8]. rough the deployment and use of the network, the ability of human society to obtain information can be enhanced. It has changed the situation that people only rely on their own feelings and simple tools to perceive information since ancient times and greatly improved the accuracy and sensitivity of human access to data and information [9,10].
WSN is often used to monitor events of interest in the surrounding environment. A typical WSN monitoring system consists of sensor nodes, base stations, and monitoring centers [11][12][13]. e remote user or monitoring center can send data acquisition, processing, and transmission commands to the sensor nodes in the network through the base station, and finally, receive the interested data through the base station [14][15][16].
In the environment of IoT, aiming at the problems of large node energy consumption and short network life cycle caused by the unbalanced location distribution of cluster head nodes screened by clustering routing protocol of wireless sensor networks and unreasonable data transmission path of forwarding nodes, a secure clustering strategy based on improved PSO algorithm in the IoT environment is proposed. e innovations of the proposed method lie in the following: (1) In the process of cluster head election, considering the residual energy and load balance of nodes, a new fitness function is established to evaluate and select better candidate cluster head nodes, which effectively shortens the communication distance. (2) e optimized adaptive learning factor is used to adjust the position update speed of candidate cluster head nodes, and the concave function nonlinear decreasing strategy is used to improve the inertia weight, which speeds up the convergence speed of global search. (3) For each cluster head node, a forwarding node is selected from the ordinary nodes in its cluster, so that the selected forwarding node has the optimal energy and location relationship, and the node communication overhead is reduced.
e remaining chapters of this paper are arranged as follows. Section 2 introduces the related research in this field; Section 3 introduces the system model; Section 4 introduces the proposed clustering routing algorithm based on improved PSO algorithm; Section 5 is the experiment, and Section 6 summarizes this study.

Related Works
Compared with plane routing, cluster routing saves the energy consumption of the network to the greatest extent, facilitates data fusion, and is easier to expand [17][18][19]. As a simple and effective random search algorithm, intelligent algorithm has good application prospects in finding the optimal solution of function and neural network recognition [20]. In the late 19th century, James Kennedy of the United States proposed PSO for the first time. It is famous for its simplicity and effectiveness. erefore, scholars at home and abroad choose PSO algorithm in cluster head selection. Reference [21] defined a new cost function to minimize the communication distance between cluster members and cluster heads and used the PSO to select cluster heads with higher energy to optimize network clustering. Reference [22] proposed a new clustering mode EECS for wireless sensor networks, which specified the size of clusters in the network. Clusters far from the base station have a larger radius, and clusters close to the base station have a smaller radius, so as to balance the energy consumption of cluster heads. Reference [23] proposed a new hierarchical clustering protocol PSO-HC, which balanced the network energy consumption by reducing the number of cluster heads and transmitted the information collected by cluster heads to the base station by multihop. Based on the clustering of the LEACH protocol, reference [24] used the ant colony algorithm to optimize the distance location between each node and the base station and obtained the best path. rough this path, the cluster head transmitted the information to the next cluster head in sequence until the information was transmitted to the base station.
Reference [25] proposed an improved PSO algorithm to optimize the running time of the network. e algorithm comprehensively considered the factors of energy and distance to realize the selection of target nodes and proposed the introduction of relay nodes to share the transmission work of cluster head nodes. Reference [26] combined harmony search (HS) algorithm and PSO to select cluster head nodes. e algorithm not only had the efficient search efficiency of harmony search algorithm but also had the dynamic ability of the PSO algorithm, which could better improve the performance of the network. According to the uneven clustering algorithm, reference [27] used ant colony optimization algorithm to calculate the optimal distance between the node and the base station and transmitted the data of each cluster head node to the base station through the selected optimal path. e disadvantage of this algorithm is that the path from each cluster head to the base station needs to be calculated, so it will lead to excessive energy consumption. Reference [28] proposed a clustering strategy based on FBECS (fuzzy based enhanced cluster head selection). In the clustering stage, fuzzy logic algorithm was used to calculate the qualification index of each node according to the residual energy of the node and the distance between the node density and the base station. e node generated the cluster head by comparing the randomly generated random number with the qualification index. Reference [29] proposed a clustering method based on energy center search using PSO (EC-PSO), which used geometric method to select CHs and searched energy centers in CHs selection.

Network Model.
In order to better optimize the algorithm, this model makes the following assumptions.
(1) e nodes are randomly deployed in the target area.
After deployment, the nodes will no longer move, and each node has a unique ID. (2) All nodes have the same initial energy, computing power, and communication ability and can automatically adjust the transmission power. (3) Each node can communicate with the base station independently, and the location of the base station is known. (4) e node can calculate its relative position according to the angle of arrival and signal strength.

Energy
Model. e same energy model as LEACH is used for communication between nodes. According to the distance d ij � ������������������ � (x i − x j ) 2 + (y i − y j ) 2 between node i and node j, the channel model is selected. e energy consumed by a node to send k bit data to the node with a distance of d is e energy consumed by the node to receive and fuse k bit data is 2 Computational Intelligence and Neuroscience where E elec is the energy consumed to receive or send 1 bit data and E da is the energy consumed by the node to fuse 1 bit data. e transmission model selected by the node for communication is determined by d 0 . α fs and α mp are the energy required for power amplification of free space channel model and multipath fading model. When the distance between nodes d < d 0 , choose the free space channel model; otherwise, choose the multipath fading model.

Cluster Head Initialization.
Because the calculation of the PSO algorithm is relatively complex, in order to avoid increasing the energy consumption of nodes in election calculation, the clustering and routing calculation based on the PSO algorithm will be completed by the base station with unlimited energy. In the initialization process, all nodes send their residual energy, location, and number information to the base station, and the base station receives and saves the information of each node. After the base station completes the clustering calculation based on the PSO algorithm, the base station broadcasts the calculation results. Each surviving node obtains the specific location information of the elected node and routing node according to the received broadcast information. PSO algorithm selects particles randomly, which is easy to fall into local optimization, resulting in uneven distribution of nodes in the cluster. To solve this problem, the energy of nodes participating in cluster head node election is limited. Suppose there is N surviving nodes in the WSN, the energy of node i is E(i), and the base station calculates the average residual energy of all nodes in the WSN as In order to ensure that the selected cluster head nodes have sufficient energy to process the data in the cluster, the base station forms a set EA of all nodes with energy greater than or equal to E a , then randomly selects K nodes from the EA, and stores them in the candidate cluster head node set to form a particle. After initially determining a group of candidate cluster head nodes, other noncluster head nodes join the cluster head nodes closest to them, respectively, to complete the establishment of initial clustering. en, continue to select K nodes in EA in a random way, conduct a total of M times of screening, and finally generate the M groups of initial cluster head node set; that is, M particles, and form the M groups of clusters.

Fitness Function.
e cluster head node is responsible for most activities and needs to consume more energy, which may lead to premature failure due to excessive energy consumption and reduce the performance of the whole network. erefore, when selecting the cluster head node, it should consider the following two aspects: select the cluster head node with large residual energy and balance the load of the cluster head node at the same time.
First, consider selecting the cluster head node set with large residual total energy. Suppose that K is the number of cluster head nodes selected by the current particle. CH represents the cluster head set and CH k represents the cluster head node of k cluster. e ratio f 1 of the current residual energy of all nodes to the residual energy of the cluster head node set is where E(i) represents the residual energy of the sensor node i in the particle. After the current particle selects the cluster head node, the set CS k is used to represent the member node set of the cluster k. C k is used to count the number of member nodes in the cluster k. If the node j joins the cluster k, it can be expressed as j ∈ CS k , and the C k plus 1.
After clustering the current particles, it should further consider the load of the current cluster. e load of the cluster mainly includes the load in the cluster and the load between clusters. For the load balancing in the cluster, it is considered from two aspects: the number of member nodes in the cluster and the distance from the member nodes in the cluster to the cluster head.
Let f 2 represent the average of the deviation between s and the maximum distance between each cluster head node and its nodes in the cluster.
Let f 3 represent the difference between the number of member nodes in each cluster and the average number of members in the cluster. e smaller the difference, the closer the number of members between clusters, and the more effective it is to balance the energy consumption between cluster heads, so as to prolong the life cycle of the network: where d(x, y) refers to the distance between node x and node y. r is the radius of clusters when the whole network area can be covered. Ideally, the area of each cluster is evenly distributed in the network area, and there is no coverage area between each cluster. e area of each cluster should be A/(pro × N), where A is the area of the whole network area, pro is the preset proportion of cluster heads and pro × N is the number of cluster heads, so the ideal r value is ���������� � A/(pro × N). f 4 represents the average distance between cluster heads. e smaller the average distance between cluster heads, the smaller the load between clusters, which can reduce the communication energy consumption of the network.
Computational Intelligence and Neuroscience 3 In the fitness function, the node residual energy and load balance are comprehensively considered, and the multiobjective optimization problem is transformed into a single objective optimization problem by means of weighted sum: where α, β, χ, and δ are weighting factors.

Update Method of Speed and Position.
According to the initial fitness calculation and the initially generated local optimal location and global optimal location, start a round of iterative calculation. First, update the location of the candidate cluster head node set, and then calculate the fitness of the candidate cluster head node after location update. In order to complete the location update of the candidate cluster head node set and obtain the optimization results, let the velocity components of the candidate cluster head nodes in the x and y directions be v x and v y , respectively, and the position components be x x and x y , respectively. e calculation of the two velocity components is initially generated randomly, but in each subsequent iteration, it is determined according to the change relationship between the velocity component of the previous round of the candidate cluster head node set and the local optimal position (p xi , p yi ) and the global optimal position (p xg , p yg ). e specific calculation is as follows: where w is the inertia weight, which indicates the influence of the speed of the previous t − 1 iteration of the candidate cluster head node set on the speed of the candidate cluster head node set in this t iteration. c 1 is a cognitive learning factor and c 2 is a social learning factor, which, respectively, represent the acceleration weight of the candidate cluster head node set close to the local optimal position and the global optimal position. l 1 , l 2 ∈ (0, 1) are the random numbers. Based on the two velocity components, the calculation method of the position components x xi (t) and x yi (t) of the candidate cluster head node in the direction x and y is as follows: 4.1.4. Improved Inertia Weight. Among the parameters that can be adjusted by the PSO algorithm, researchers often improve the important parameter of inertia weight. A larger inertia weight value is conducive to improve the global search ability of the PSO algorithm, and a smaller weight value will enhance the motion ability of particles. Under the same convergence accuracy, the concave function decreasing strategy greatly improves the convergence speed of PSO compared with other improved strategies, and can more effectively control the balance between global search and local search. e rule for improving inertia weight by using concave function nonlinear decreasing strategy is as follows: where w ∈ [0.5, 0.9] and C Cur represent the number of rounds of the current iteration and C Loop represents the total number of iterations.

Location Mapping Strategy.
After each round of iteration, the location of the candidate cluster head node set will be updated, and the updated node location may not find a matching surviving node in the WSN. At this time, location mapping is needed. e basic idea is to adopt the proximity principle to map the updated location to the location of the nearest surviving node. Take x xi and x yi as the updated node coordinates and CM nx and CM ny as the coordinates of the surviving node CM n in the network. e location mapping process is as follows: e location mapping strategy solves the mismatch between the updated location and the actual surviving node location caused by the discrete distribution of network nodes. When the updated position coordinates of multiple nodes are the same, it is necessary to set a flag while updating the node. When updating and mapping the positions of other nodes, first check whether the flag has been identified as the cluster head node. If so, select the next closest node position in turn for mapping.
After completing the location mapping, take the candidate cluster head node set after the location update as the optimization result, and calculate the fitness value of each candidate cluster head node set. According to the calculation results, the local optimal location of each group of candidate cluster head node set and the global optimal location of M groups of cluster head node sets in this round are updated. If the iteration is not finished, continue to update and map the location of candidate cluster head nodes. Otherwise, the candidate cluster head node set of the global optimal position is calculated as the optimal cluster head node set, and the cluster head election is completed.
After completing the cluster head election, the base station further calculates the distance from the noncluster head node to each cluster head node and adds the noncluster head node to the nearest cluster head node to complete clustering. Ordinary nodes only send data. After receiving the data from ordinary nodes, the cluster head node performs data fusion and then sends it to the corresponding forwarding node. e forwarding node needs to be further selected from ordinary nodes. It receives the data from the cluster head, selects the optimal path to the base station, and sends the data to the base station.

Election of Forwarding Nodes.
After the cluster head node election is completed, the corresponding forwarding node will be selected for the cluster head node. If there are too few forwarding nodes in the network, multiple cluster head nodes send data to the base station through a small number of forwarding nodes, which will increase the energy consumption of forwarding nodes. To solve this problem, the existing WSN routing protocol adopts the way that one cluster head node corresponds to one forwarding node to increase the number of forwarding nodes, but it selects all nodes randomly without considering whether the residual energy and location of the selected nodes are balanced.
In the forwarding node election, the improved PSO algorithm of the above cluster head node election is adopted to elect a forwarding node for each cluster head node among the ordinary nodes in its cluster, so that the elected forwarding node has the optimal energy and location relationship, and avoid speeding up its energy consumption due to too few forwarding nodes in WSN. In the calculation and evaluation of forwarding nodes, because forwarding nodes can only be elected in one cluster, the calculation methods of energy factor and location balance factor are different from those of cluster head node election. Similarly, N represents the number of surviving nodes in the WSN. After selecting K cluster head nodes, the WSN is divided into K clusters. During initialization, according to the cluster head node screening method, candidate forwarding nodes with high residual energy are screened out in each cluster to form a set of candidate forwarding nodes. Each candidate set contains K nodes. After initialization, the number of ordinary nodes is N − 2K. Let E r RN (i) represent the residual energy of candidate forwarding node RN i in round r, and E r CN (i) represent the residual energy of ordinary node CN j in round r. e calculation formula of energy factor fit 1 is Let d(CN k , CH j ) represent the distance between the ordinary node CN k and the corresponding cluster head node CH j , d(RN i , BS) represent the distance between the forwarding node RN i and the base station BS, d(RN i , CH j ) represent the distance between the forwarding node RN i and the corresponding cluster head node CH j , and d(RN i , RN m ) represent the distance between the forwarding nodes RN i and RN m . e calculation method of the location equalization factor fit 2 of the forwarding node is as follows: where the ordinary node CN k is located in the cluster where the cluster head node CN k is located and the candidate forwarding node RN i corresponds to the cluster head node CH j . e closer the candidate forwarding node set is to the base station, the smaller the distance between the cluster head node and the forwarding node in each cluster; the smaller the distance between the forwarding nodes in the candidate forwarding node set, the more balanced the location distribution of the candidate forwarding node set, and the greater the fit 2 value. Based on the ability factor and location balance factor of candidate forwarding node election, the fitness function F2 for the evaluation of candidate forwarding node set constructed by weighting method is as follows: where b ∈ (0, 1] is the weight. e higher the residual energy of the candidate forwarding node set and the more balanced the location, the greater the fitness value of the candidate forwarding node set, indicating that the candidate forwarding node set is better. In the iterative election process of candidate forwarding node set, the speed update and location mapping method similar to cluster head node election is used to select the optimal forwarding node set.

Data
Transmission. WSN forward routing mainly selects relay nodes for cluster heads far away from the base station, and relay nodes reduce the load of cluster heads by forwarding data packets from cluster heads. Assuming that the data packet needs to be sent to the base station through n hop; that is, through n − 1 relay nodes, the optimal relay node should have the following characteristics: (1) e distance between relay nodes should be as balanced as possible. Computational Intelligence and Neuroscience 5 (5) e load of relay nodes should be as small as possible to avoid over development.
According to the above requirements, the corresponding fitness function is designed, which can be expressed as where E min is the node with the smallest energy among the relay nodes; the load of the node is determined by the number of data packets received by the node. load max is the node with the largest load in the relay nodes; d min and d max are the minimum and maximum distance between adjacent nodes in the forward routing path, respectively; d init and d total are the sum of the distance between the cluster head and the base station and the sum of distance of the whole forward routing path; ε � 0.5 + 0.5E loss /E total ; ϕ � 1 − ε. e total energy consumption of the nodes in the cluster is changed into the energy consumed by the cluster head that needs to plan the route, and the total energy in the cluster is changed into the initial energy of the cluster head. With the operation of the network, the parameter weight ratio is dynamically adjusted.

Experimental Setup.
Simulating the generation of WSN in MATLAB and setting the base station outside the network, in this environment, the secure clustering strategy based on improved PSO algorithm is tested. e experimental computer is configured with 2.3 GHz, Intel Core I7, 8 GB RAM, and 64 bit Windows10. e experimental environment and parameter settings related to WSN initialization, cluster head node, forwarding node election, and data processing are shown in Table 1.

Performance Index Comparison of Topology Generated by Different Schemes.
In order to prove the performance of the proposed method under the same experimental conditions, the proposed method is compared with the methods in references [28,29], and the comparison results are shown in Figure 1. In order to compare the algorithms effectively without losing generality, it is assumed that n sensor nodes are randomly deployed in the target monitoring area of 200 × 200.
As can be seen from Figure 1(a), the average link length of the three methods continues to decrease with the growth of n. e proposed method can maintain the global connectivity of the network with a short average link length and has strong advantages in reducing the overall energy consumption of the network. Figure 1(b) shows the comparison results of the average node degree of the three control schemes. It can be seen from the figure that the average node degree of the other two methods tends to rise with the increase of the network scale, while the topology obtained by the proposed method has a low average node degree, which is basically maintained below 2.5, and the average node degree is relatively stable and will not change greatly with the change of the network scale. It shows that this method has good stability and low interference.
As can be seen from Figure 1(c), when the network size is 70, the average number of joint points of the methods in references [28,29] is 3.0 and 2.3, respectively, and the number of joint points of the proposed method is 0. e number of joint points of the methods in references [28,29] decreases with the continuous growth of the network size, but the method in this paper has better stability and can ensure that there are basically no joint points under different network sizes. is is because the proposed method comprehensively considers the residual energy and load balance of nodes, establishes a new fitness function, and can select better candidate cluster head nodes. erefore, compared with the other two methods, the proposed method can better ensure the connectivity of topology when clusters are connected.

Location Balance Test of Cluster Head Nodes.
e location balance factor reflects the distribution balance of cluster head node set and forwarding node set in WSN. e more balanced the node distribution is, the smaller the total communication distance in WSN communication is, and the lower the node energy consumption will be. Based on the above experimental environment, the total distance from all ordinary nodes to cluster heads and the total distance from all cluster head nodes to base stations in multiple iterations of the methods proposed in this paper, references [28,29] are tested, respectively. e experimental results are shown in Figures 2 and 3, respectively.
As can be seen from Figures 2 and 3, with the increase of the number of iterations, the total distance from all ordinary nodes to cluster heads and the total distance from all cluster heads to base stations in the three methods become smaller and smaller. In the method of reference [28], the energy and location of nodes are not considered in cluster head election. Initially, the two distances in Figures 2 and 3 are the largest, but the two distances drop rapidly after 2600 rounds. is is because their communication distance is large, energy consumption is large and unbalanced, and node death is fast.  Ref. [28] Ref. [29] Proposed method Ref. [28] Ref. [29] Proposed method Ref. [28] Ref. [29] Proposed method (c) Ref. [28] Ref. [29] Proposed method Ref. [28] Ref. [29] Proposed method distance (m)

Computational Intelligence and Neuroscience
With the large reduction of surviving nodes, their communication distance decreases, and the life cycle of WSN is greatly shortened. is is because, the proposed method elects a forwarding node for each cluster head node among the ordinary nodes in its cluster so that the selected forwarding node has the optimal energy and location relationship, which effectively reduces and balances the node energy consumption. e number of dead nodes decreases linearly and slowly, the change is relatively stable and prolongs the life cycle of WSN. e method in reference [29] considers the location information. At the beginning, the two distances are relatively reduced, the energy consumption is reduced, and the life cycle of WSN is prolonged. e optimization of the inertia weight in the method of reference [29] makes the elected cluster head nodes close to the global optimization. e two distances measured at the beginning are lower than those in the method of reference [28], the node energy consumption is reduced, and the life cycle of WSN is longer than that in the method of reference [28]. e methods in references [28,29] have fewer surviving nodes due to the proliferation of dead nodes in the later stage of iteration. e measured two distances are smaller than the proposed method, but the life cycle is smaller.

Conclusion
A secure clustering strategy based on improved PSO algorithm in the environment of IoT is proposed. Considering the residual energy and load balance of nodes, a new fitness function is established, the better candidate cluster head nodes are evaluated and selected. e location update speed of candidate cluster head nodes is adjusted through the optimized adaptive learning factor, so as to elect a forwarding node for each cluster head node among the ordinary nodes in its cluster for reducing the energy consumption of forwarding nodes. Experiments show that under the same conditions, the average node degree of the proposed method is less than 2.5, which is better than the comparison methods. Compared with the comparison methods, the proposed method can significantly improve the network life cycle of clustering method and optimize node energy consumption.
In WSN clustering routing protocol, the selected cluster head nodes usually accounts for only a small part of the total nodes, so it has sparse characteristics. In future research work, sparse theory can be introduced to solve the problem of cluster head node selection in WSN clustering routing. In addition, in practical applications, the location of sensor nodes is not fixed, so energy optimization can be studied for large-scale dynamic networks.

Data Availability
e data used to support the findings of this study are included within the article.

Conflicts of Interest
e author declares that there are no conflicts of interest regarding the publication of this paper.