An Invulnerability Algorithm for Wireless Sensor Network's Topology Based on Distance and Energy

: To improve the topological stability of wireless sensor networks, an anti-destructive algorithm based on energy-aware weighting is proposed. The algorithm takes the Weighted Dynamic Topology Control (WDTC) algorithm as a reference, and calculates the weight of nodes by using the distance between nodes and the residual energy of nodes. Then chooses optimal weights and constructs a stable balanced topological network with multiple-connectivity paths using the K-connection idea. The simulation results show that the proposed algorithm improves the average connectivity of the topological network, enhances the robustness of the network, ensures the stable transmission of network information, and optimizes the betweenness centrality of the network nodes, making the network has a good invulnerability.


NTRODUCTION
Today, the fifth-generation (5G) technology is booming and growing rapidly. 5G technology promotes the application of sensor nodes to the narrowband Internet of Things (NB-IoT) deployment scheme with low latency and high rate transmission [1]. Through the combination of 5G technology and wireless sensor nodes, a large amount of information such as location, image, and weather can be collected and injected into the network, so that it can be more widely and effectively utilized. At the same time, 5G mobile networks will enable wireless communication devices such as wireless sensor nodes to achieve more efficient applications in military communication systems [2].
As one of the important application areas of 5G technology, wireless sensor networks are widely used in military, security, and other complex scenarios due to their lightweight, low cost, low power consumption, easy selforganization, and information collection which is an important part and a hot research topic of the current Internet of Things [3,4]. Wireless sensor nodes have the characteristics of limited energy and are susceptible to external complex factors. Using topology control to improve the invulnerability of the network and ensure the ability to perform various complex tasks is important for wireless sensing network applications [5,6].
Topology control is the process of selecting neighbour nodes with certain rules and forming an optimal network structure, which is the basis of network implementation protocol, and the topological structure is the foundation of network survival. To extend the life of the sensor nodes in the topology, Barabási et al. [7] proposed a scale-free network model to characterize the large scale properties of complex networks, which has the characteristics of a power-law distribution. For increasing the number of available channels and prolonging the life of the node, Fujii S et al. [8] proposed the theory of cluster head selection and rotation. Zebbane, Chenait, and Badache [9] proposed a group-based energy conservation protocol (GECP) to extend the network life cycle through sleep scheduling between sensor nodes to ensure network connectivity. In order to improve the efficiency and reliability of data communication, Gupta et al. [10] studied the n-dimensional hypercube network on the chip topology. Wang et al. [11] proposed a network topology optimization strategy based on wolf pack algorithm to solve the optimization problem of wireless sensor networks in complex industrial application environments. Li et al. [12] proposed a scheduling algorithm based on energy balance, which can extend the life of the entire network while ensuring energy balance. Aiming at the topology control problem of three-dimensional wireless sensor networks, Wang et al. [13] proposed an optimal topology rapid generation algorithm based on minimum spanning tree and edge addition operation. In order to improve the accuracy of distributed node importance measurement, Zheng et al. [14] researched distributed node measurement methods and methods based on multiple attributes in wireless sensor networks. Aşçı, Ileri, and Dağdeviren [15] presented a design based on the Esau-Williams (E-W) algorithm to solve the Capacitated Minimum Spanning Tree (CMST) problem in wireless sensor networks and reduce the energy consumption of the algorithm. To prolong the lifetime of the networks, Zhu [16] proposed two energy evolution models. For the goal of extending the lifetime of the network by a certain degree of energy conservation, Dorogovtsev, and Mendes [17] proposed a topology construction model with fault-tolerant capability. Wattenhofer and Zollinger [18] proposed a topology control algorithm (XTC), which was based on neighbor link quality. The main characteristics of the XTC algorithm are the properties related to TC (symmetry, connectivity, sparsity, and planarity), and faster than any previous algorithm. To achieve good robustness in the harsh environment, Zheng and Liu [19] constructed a scale-free network model, but they did not consider the influence of communication radius on node energy consumption, resulting in a shorter network lifetime. To improve the network's survivability and maintain energy balance, Hu and Li [20] proposed a scale-free topology evolution mechanism (SFTEM). To achieve the goal of reducing energy consumption, Jemal et al. [21] proposed a clusterbased wireless sensor network energy efficient router layout scheme, which adopts K-means algorithm to select the initial cluster head, then selects the cluster head with sufficient battery energy and selects the spare cluster head. For balancing the energy consumption of nodes, Sun et al. [22] proposed an energy-aware weighted dynamic topology control (WDTC) algorithm based on MST to consider residual energy information in connected topology construction. WDTC works based on link weight function. All of the above algorithms in the topology control considered the network topology from the perspective of energy saving and extending the network lifetime. A lot of work only focused on the balanced energy consumption of the nodes and the survival time of the nodes, but not considering the invulnerability of the entire network. In this paper, from the perspective of the antidestruction of wireless sensor networks, an energyweighted topological invulnerability control algorithm (EWTIC) is proposed to construct the network and is further verified by simulation.

RELEVANT KNOWLEDGE AND RELATED DEFINITIONS
The paper uses the diagram to represent the structure of the wireless sensor network, involving the knowledge of Graph Theory [6], so this chapter introduces some basic knowledge of Graph Theory and some related definitions [23][24][25].

Graph Theory
As one of the frameworks in algorithms and data structures, graphs can be used to represent all existing systems or structures.

Figure 1 Undirected graph
According to whether the nodes can communicate with each other or not, the graphs can be divided into directed graphs and undirected graphs. Fig. 1 is a diagram of undirected graph. Here, a single node is represented by a point, and an edge is used to represent the interconnection between the nodes. If the nodes meet the transmission distance conditions, they can communicate with each other. And this kind of graph can be represented by an undirected graph. Graph In the figure, the degree of a node refers to the number of edges connected to it, or the number of adjacent nodes thereof. The degree of the node u can be denoted as   d u .

Related Definitions
 is the edge set, V is the node-set, d max is the maximum transmission range of each node, that is, the communication radius R. The edge (u, v) in graph G = (V, E) is disordered, then graph G is called undirected graph. The undirected graph is used to represent the topology structure of sensor nodes in the network. Two-way communication and information transmission can be carried out between connected nodes. Definition 2: For any two nodes u, v in the undirected graph G = (V, E), if the distance d(u, v) between the two nodes is less than or equal to the communication radius R, that is, d(u, v) ≤ R, and satisfies d uv = 1, then the node v is called the 1-hop neighbor node of node u, which is recorded as

Definition 3:
In the undirected graph G, if there are two paths between the vertices u and v, except for the two vertices u and v, the two paths do not pass through the same vertex, then the two paths are called Vertex disjoint paths.

Definition 4:
If there is at least one connection path between any two nodes in an undirected graph, the graph is defined as single-connected.

Definition 5:
The network is composed of n nodes. If any k−1   k n  nodes are removed and the connected component is not increased, that is, any two nodes have at least k disjoint paths, then the network is defined as k connected.
Definition 6: is defined as the visible neighborhood of the node, and is represented as the generated subgraph of G.

SYSTEM MODEL AND ENERGY MODEL 3.1 System Model
Suppose sensor nodes of n are randomly spread in a rectangular region with an area of l * l m 2 . Assuming that each node obtains its location information through the Global Positioning System (GPS) or other distance-based positioning techniques, each node is a static node and has a unique ID. The transmission range of the sensor node is limited. Its communication radius R is the maximum Euclidean distance that radio propagation can reach. The radio range is equal and limited, and the communication link is symmetrical. Here suppose that the power of the node is adjustable. If any two nodes u, v can communicate with each other, the distance between these two nodes d(u, v) ≤ R is recorded as d uv = 1, otherwise d uv = 0.

Energy Model
In wireless sensor networks, the death time of the first node is defined as the lifetime of a network. Network lifetime is one of the important indicators for its performance evaluation. It is closely related to the energy consumption of the nodes. In this section, the energy model of the network topology is established, and the relationship between energy consumption and communication distance is determined.
The energy consumption of a network mainly comes from the data sending and receiving between nodes. Therefore, the energy model can be constructed based on the sending and receiving of node data. When the node transmits the data, the energy loss is divided into two parts: transmission circuit loss and power amplification loss. Assume that the transmission distance threshold is d0. When the transmission distance between the two nodes is shorter than d0, the power amplification loss is free space loss, otherwise, it is attenuated spatial loss. The free space model is a signal transmission model under ideal conditions, that is, the environment is usually set to an ideal channel without occlusion, attenuation, and timeinvariance. The attenuated spatial loss is usually multipath.

Figure 2 Free Space Loss Model
The gain G r at the receiving end is related to the effective are a A c and the wavelength λ of the signal electromagnetic wave.
The formula of the receiver power P r at the receiving end is: where, P r is the transmitter power, G t is the transmit gain, then: where E fs is the free space loss coefficient. Signal transmission is mostly reflected by the ground or other objects.

Figure 3 Attenuated Spatial Loss Model
D is the straight-line distance between transmitter and receiver, and ht and hr are the antenna heights at both ends in Fig. 3. Under this model, the received power formula can be expressed as follows: The energy consumption of packets with a data length of l bit sent by a node can be expressed as follows: When a node receives a packet with a data length of l bit, the energy loss only contains circuit consumption, and the loss can be expressed as follows: where d and l are the distance between nodes and the packet length, separately. E elec is the energy consumed by the data transmitting and receiving per-unit-bit length. E da is multi-path attenuation. Energy consumption of any node in the network is the sum of energy consumption of sending and receiving data, so the average energy consumption per l bit data of any node u is: It can be inferred from the Eq. (4) and Eq. (5) that energy consumption of the nodes is mainly dependent on the communication distance between them. The longer the communication distance of the node, the faster the energy attenuated. When the distance between the nodes of the communication is smaller than the threshold value, the energy is consumed in direct proportion to the second square of the distance. Otherwise, the energy consumption is directly proportional to the four times the of the distance, thus the lower the residual energy of the node.

AN ENERGY-WEIGHTED TOPOLOGY INVULNERABILITY ALGORITHM
The energy-weighted topology invulnerability algorithm proposed in this paper is different from the local minimum spanning tree (LMST) algorithm and the WDTC algorithm. The main idea is to select the nodes under the energy-weighted weight value and construct the Kconnected topology to achieve the anti-destructive effect.

LMST Algorithm
The energy-aware WDTC algorithm is based on the LMST algorithm. The LMST algorithm can be implemented by four steps: (1) information collection; (2) each node constructs a local MST of its geometry; (3) each node adjusts its transmission power so that it can reach the furthest neighbour; (4) only two-way edge topology construction. The LMST has three remarkable features: (1) the topology of the network maintains the connectivity of the network; (2) the logic of the nodes in the constructed network topology does not exceed 6; (3) the topology only has two-way links.
However, in the MST class topology built by LMST, the load and transmission power distribution of each node are very unbalanced. Therefore, the energy consumption of nodes is seriously out of balance, which leads to the shortening of the network's lifetime. Because of these shortcomings, topology constructed by the LMST algorithm will not change as long as the node position remains unchanged. To prolong the network's lifetime and make the residual energy of each node tend to be balanced, the WDTC algorithm is proposed.

WDTC Algorithm
In reference [22], the WDTC algorithm adds the residual energy information of the node to the topology construction based on the geometric information only used by the LMST algorithm. The geometric graph is transformed into a weighted graph by edge weight function, and each node uses the new weighted graph to construct MST topological network. The edge weight reflects the communication cost on the edge. At each stage, with the consumption of residual energy of each node in the network, the weight of the edge is different, so the MST's production is also different.
The steps of the WDTC algorithm are presented as follows: Step 1：Each node periodically broadcasts a "Hello" message with its maximum transmission power, which contains the node's ID, location, and remaining energy.
Step 2：Node assigns a value to each edge associated with node u by weight function W, defining as   . α uv d is the energy consumption of the data packet transmitted between u and v with uv d as the distance. Weight function is symmetrical, that is, can guarantee a topology with only twoway links. The definition of ( , ) W u v satisfies the requirement that the remaining energy of the smaller node has a higher weight.
Step 3：At the angle of weighted ( , ) W u v , the MST weighting graph of G u is calculated by the Kruskal algorithm. MST weighting graph not only reflects the edge length but also reflects the energy consumption information of the node. Therefore, the neighborhood set of node u can change periodically with the change of distance and energy consumption. As a result, the final energy consumption tends to be balanced.

Figure 4 WDTC Topology diagram
The simple topology diagram is shown in Fig. 4. According to the steps of the WDTC algorithm, the weighted graph is obtained based on the weight. Based on the Kruskal algorithm, node 1 is used as the starting point, and the topological results are obtained by selecting the weights in the order of 1, 4, 5, 6, 2, 3, 1.
The number of neighbor nodes connected by each node in the network is small, and there is only one disjoint path between some nodes. As shown in Fig. 1, once the critical link is damaged, the data transmission will be affected, and the network will show vulnerability. In the face of random failure or enclosure failure, the damage degree of the network will increase, and the ability to resist risks will be low, thus affecting the normal operation of the network. At the same time, in the face of the network composed of static nodes, the position information of the nodes is unchanged, and the residual energy of each node is changed in the network.
The WDTC algorithm reconfigures the topology with the following features: (1) The topological structure reconstruction frequency of the WDTC and the LMST is the same. As a result, the WDTC will not generate any additional energy consumption and computational overheads. (2) When the node is in a stable state, the topological reconstruction frequency under the WDTC is much higher than the LMST. (3) In the WDTC and the LMST, each node constructs the local MST of the graph with the same vertex and edge. Therefore, the WDTC and the LMST have the same time complexity O( log ) e e , where e is the number of edges. (4) The computational overheads of WDTC will be M times that of LMST.

An Energy-weighted Topology Invulnerability Algorithm
The WDTC algorithm of constructing the network topology according to the energy information achieves the effect of energy consumption balance. However, in order to further improve the stability and invulnerability of the network and improve its ability to resist risks, this study presents a corresponding improved scheme: a topology invulnerability algorithm based on energy weighting (EWTIC algorithm).

EWITC Algorithm
In the algorithm, each node periodically broadcasts a "Hello" message with the maximum transmission energy to collect the location and energy information of its visible neighbors. According to the residual energy information of the node, the EWITC algorithm has characteristics similar to WDTC, when the reconstruction frequency of WDTC topology structure is the same. Since the remaining energy information can be carried by exchanging the position information in the message, there will not be any additional energy consumption and computational overhead. When the reconstruction frequency is higher than WDTC, the energy consumption and computational overhead of EWITC are increased compared to that of WDTC.
According to the work of Sun [22], the energy information is added to the topological structure, and the geometric graph is transformed into a weighted graph by edge weight function. According to reference, the weight function is , where d uv is the Euclidean distance between u and v, and E u , E v is the residual energy of u and v, respectively. The function W is the increasing function of the variable d uv , which is the decreasing function of the variables E u and E v . The proposed algorithm is connected according to the idea of the K-connected network based on the different edge weights. The single-node performs the weight value search between the neighbor nodes for up to K times. The nodes that meet the preset conditions (including the energy threshold, the distance threshold, the weight value, etc) are topologically connected until all the nodes in the network repeat the same operation steps. As a result, the topological construction of the network is completed.

Algorithm Steps
The steps of the EWTIC algorithm are as follows: Step 1: Initialize the network. Nodes are randomly arranged in a certain area. And the initial value, the node ID, the coordinate information, and node energy are initialized according to the actual situation.
Step 2: Each node periodically broadcasts "Hello" messages with its maximum power. The message contains the ID, coordinates of the nodes, and the remaining energy information to complete the information interaction.
Step 3: Calculate the distance d uv to limit the range, and then use the weight formula ( , ) calculate the weight value. Under the remaining energy of the smaller node, it has a higher weight.
Step 4: Under the condition of weighted W, each node is based on the idea of a K-connected network. Referring to the distance threshold and energy threshold, each node repeats K times to find the minimum weight value and connects the eligible neighbor nodes topologically. At the same time, mark the node neighbor matrix, until all the nodes in the network complete the search and connection. Then the topology construction is completed. With the operation of the network, the energy consumption is constantly consumed. The neighbor matrix of the node will also change periodically with the change of energy in consumption. As a result, the final energy consumption will be balanced and the invulnerability will be furthermore improved.

Topology Diagram
As shown in Fig. 5, taking the simple network of 6 nodes as an example, the idea of the algorithm is briefly described. The weighted value has been calculated by using the edge weight function, and the weight is represented by the length of the line segment in the figure above.

Figure 5 Topology Diagram
The topology construction is started from node 1. The neighboring node of node 1 is node 2, 3, 4, 5. After searching, the weighted value between node 1 and node 4 is the smallest, so nodes 1 and 4 are connected. Then, the minimum weighting value between nodes 1 and 3 is searched by using 1 as the starting point. Also, the nodes 1 and 3 are connected. The above-mentioned finding is repeated, the nodes 1 and 2 are connected. The example completes the link connection of node 1 with 3 as the degree of connectivity. Repeat the search with node 2 as the first, and connect node 6 to node 4 in turn. The remaining nodes are also connected according to this idea.
It should be noted that the information of its remaining energy can be carried when the location information is exchanged. So, compared with LMST and WDTC, the proposed algorithm does not generate additional energy consumption and computational overheads when constructing the same frequency topology. Also, the reconstruction frequency of the EWITC algorithm is higher than that of the LMST. In addition, the computational cost of the EWITC is similar to that of the WDTC algorithm and is proportional to the number of reconstructions M.

SIMULATION AND ANALYSIS
In this research, the performance of the EWITC algorithm is verified by simulation. The performance of the EWITC algorithm is compared with that of the WDTC algorithm. The differences of the average connectivity, robustness, and the number of intermediate centers between the WDTC algorithm and the EWITC algorithm are analyzed comprehensively by simulation.

Simulation Result
In order to improve the invulnerability of the network topology, the EWTIC algorithm is proposed based on WDTC. Firstly, the work of the EWITC algorithm is demonstrated. A network model is set up, 50 nodes are randomly arranged in a square area of 200 m × 200 m. The transmission radius of the nodes is set to be 80 m. Multipath propagation is used for data transmission in the experiment. For fairness, One-half of the nodes are randomly assigned to the source node and the other half as the destination node. Each source node sends a data packet to the destination at a rate of 2 packets/s. The initial energy capacity of the node is randomly allocated within J, which is close to the energy capacity distribution of the actual node. r is the number of times the data packet is transmitted, and the maximum operation time r max is set as 40. Set each packet size l as 4000 bit. The topological evolution of the EWITC algorithm is given by Fig. 6. Compared with the maximum power transmission, the connection path of each node is reduced. The complexity of network topology is reduced. The number of nodes that need to communicate with each node is reduced. The number of cycles is used to represent the time.
Set the upper limit of node degree as 4. Take node 31 as an example, which is initially connected to node 4, 20, 28, 39. After a while, due to energy consumption, the original weight value changes. Topology is rebuilt and the reconstructed topology changes. The nodes connected to node 31 are nodes 39, 28, 50, and 43. The degree of the node is maintained at 4. After the same time interval, the communicating neighboring node is node 10, 20, 28, and 39. The degree of the node is still 4. With the change of running times, it can be observed that the topology evolves with the change in energy distribution. According to the topology results, the number of links in the network is average, and the topology is more balanced and reasonable.

Performance Evolution
In this part, three indicators, robustness, average connectivity, and betweenness centrality are used to evaluate the anti-destruction performance of the EWITC algorithm. The WDTC and the LEECH algorithm are set as the references of EWITC algorithm. The n nodes are distributed in the 500 m × 500 m area. The transmission range of each node is 100 m. In the experiment, the connectivity of the node is 4 as the upper bound of the connection, which leads to the excessive energy consumption of the network due to too much connection. Other simulated parameters are shown in Tab. 1. Here, the number of nodes n is between 50 and 150. An average of 30 simulation runs is conducted for each datapoint. Where, is the index of d uv ，E is the initial energy, E fs is free space loss, E mp is attenuation space loss, E da is multipath attenuation energy，E elec is unit data transmission loss.

Robustness
The robustness of the network refers to the average influence that the remaining nodes in the network can still maintain connectivity after any node in the network is removed. It is defined as the mean value of the ratio of the number of remaining connected node pairs in the network to the total number in the network after any node is removed.
Assuming that the node-set of the network after node removal is G k , the robust n R formula is presented as follows: where, n represents the total number of nodes in the network, l uv indicates the number of nodes that are still connected after removing a node. If there is a connection path between nodes u and v, l uv = 1, otherwise l uv = 0.

Figure 7 Robustness
As can be seen from Fig. 7, the robustness of the EWTIC algorithm increases obviously with the number of nodes increasing, and the growth rate is obviously higher than that of other algorithms. This shows that the network constructed by the EWITC algorithm is less affected than the network constructed by other algorithms. The removal of a node has less influence on the network. Because of the idea of the minimum spanning tree, the failure of some nodes in the WDTC algorithm can directly lead to the fracture of the network. The robustness is low, and the influence on the network is greater, so the EWITC algorithm is better in the evaluation of robustness.

Average Connectivity
The degree of a node is usually the number of edges directly connected to a node, reflecting the size of the effect on network connectivity. The calculation formula for the degree K u of the node u is as follows: where, if node u and node v are directly connected, then a uv = 1, otherwise a uv = 0. The average degree (average connectivity) D of the network is the average of all the nodes in the network, and can be expressed as follows: As can be seen from Fig. 8, the average connectivity of the EWITC algorithm is better than that of the WDTC and the LEECH. With the increase in the number of nodes, the curve has an obvious increase, and the proposed algorithm is always higher than the WDTC in the communication degree. This indicates that the communication path of the node in the network is more than that of the WDTC. Therefore, the transmission of information is more assured. The stability of the network is increased, and the network is consistent with the actual topology.

Betweenness Centrality
The betweenness of nodes reflects the influence of nodes in the whole system and is defined as the ratio of the shortest paths of nodes to all the shortest paths in the network. B p can be presented as follows: ( , ) , , where represents the number of shortest paths between nodes u and v passing through node p. A larger value of B p indicates that node p is more influential and important in the system.
where, n is the total number of nodes in the network, then the number of shortest paths between nodes in the network is n(n−1)/2. For the comparison of the betweenness centrality, to show the simulation results more clearly, the experiment selected the betweenness centrality diagrams under 50 nodes to compare the WDTC algorithm with the EWITC algorithm. As shown in Fig. 9, in the network constructed by WDTC algorithm, the betweenness centrality of each node is small. The betweenness of most nodes is relatively small, and some nodes such as 3, 15, and other nodes fail. So the betweenness of nodes is small and less than 0.05. In the EWITC algorithm, because the connectivity is higher than that of WDTC, and more nodes share the task of communication path under multi-path communication, the betweenness of node increases. It is obviously consistent with the actual situation.
In conclusion, the topology constructed by the EWITC algorithm is more invulnerable from the point of view of average connectivity, robustness, and betweenness centrality.

CONCLUSION
In this paper, an effective energy-weighted invulnerability topology algorithm (EWTIC) is proposed to enhance the invulnerability of the network. In this algorithm, the residual energy information of nodes is added to the calculation of weight value, and the idea of Kconnected and the minimum weight of cyclic search are added to construct the topological structure. The energy consumption leads to the change of the weighted graph and then leads to the adjustment of the topological structure. The energy consumption is reallocated between nodes, the connection path between nodes is changed, and the invulnerability of the network is improved. The simulation results show that compared with WDTC and LEECH algorithms, the average connectivity, robustness, and node betweenness centrality of the proposed algorithm are 1.75, 0.17, and 0.057, respectively. Under the comparison of these evaluating indicators, the EWITC algorithm effectively maintains a good topological balance and enhances the anti-destruction ability of the network topology.