Abstract
Aiming at the problem that the current algorithm cannot effectively complete the optimal energy allocation in wireless sensor networks, a method of optimal energy allocation in wireless sensor networks based on a symmetric algorithm is proposed. The structural characteristics of wireless sensor networks are analyzed, and the constraints of sensor nodes are completed according to the structural characteristics of wireless sensor network nodes. The application scenarios of wireless sensor networks are described, the energy distribution of the network is analyzed, and an optimal energy allocation model is established. The energy consumption per unit time of wireless sensor networks is calculated by the energy consumption of data collection and reception. Calculate the optimal routing hops and minimum transmit power in the model. Combined with the number of network keys, the optimal energy distribution of the wireless sensor network can be completed. Experimental results show that the algorithm is effective by testing the time and energy allocation efficiency of network optimization, and it also guarantees the security of wireless sensor network communication.
Introduction
Wireless sensor networks (WSNs) have limited energy and the efficiency of energy use has a direct impact on the life cycle of the network. Energy problem has become the core issue in this field. The energy optimization deployment of wireless sensor network has penetrated all the research hotspots in the field. With the development of science and technology and the improvement of production requirements of all walks of life, wireless sensor network have made rapid development. At the same time, with the reduction of hardware production costs and the development of chip technology, more powerful and cheaper sensors are everywhere [10, 14]. These internal and external conditions promote the rapid development of wireless sensor networks. But in the development of wireless sensor, energy consumption has become a crucial link in restricting its development. This paper mainly studies the application of symmetric algorithm in optimal energy allocation of wireless sensor network, and finds the best encryption method in wireless sensor network. In practical wireless sensor network applications, isomorphism and isomerism are the two most classical structures. The structure that collects and processes the nodes and important data in the monitoring area and routes the collected information to the base station through the master node is called typical isomorphic structure [6]. Sensor nodes can be conveniently configured in areas that need to be detected, and can be used in some special conditions of the environment, abandoning the high cost of wire network distribution, maintenance of tedious many drawbacks. Wireless network can be designed according to the network infrastructure and field requirements [15–17]. But in wireless sensor networks, an important and difficult problem is that the energy consumption of wireless sensor nodes greatly limits the network life. Therefore, it needs to study the optimal allocation of wireless sensor networks.
Reference [13] proposed a network coding algorithm for optimal energy allocation in wireless sensor network, in which some nodes in the bottleneck region were coded by network and then forwarded to the sink node. By calculating the probability of node buffer, the influence of this probability on the survival time of wireless sensor networks was analyzed. The optimal energy allocation of wireless sensor networks was achieved. However, the algorithm took a long time to optimize and the communication security of wireless sensor networks was ensured. The overall performance is poor, which cannot effectively complete the wireless sensor network energy optimization configuration. Reference [5] proposed an optimal energy allocation algorithm for wireless sensor network based on flow control algorithm. If the network was stable, the minimum data forwarding rate was calculated when the upper bound of data volume was aggregated by nodes. The maximum gradient of data delay weight function was forwarded to the base station. The data would not be aggregated continuously at nodes and links, and the nodes did not need to locate branches. Moreover, the topology of the whole wireless sensor network were needed to consider. The algorithm achieves optimal energy allocation in wireless sensor network with linear complexity, but it also has the problems of long optimization time and poor communication security. Reference [11] proposed a chaotic particle algorithm based optimal energy allocation for wireless sensor network, which evaluated the reliability of network nodes, introduced adaptive chaotic particles, made virtual mapping of nodes, and dynamically updated nodes, so as to establish an update matching function, and achieve optimal energy allocation for wireless sensor networks. However, the energy allocation efficiency the algorithm in wireless sensor networks is low. Reference [12] proposed an improved ant colony algorithm for optimal energy allocation in wireless sensor network. Firstly, the wireless sensor network model and constraints were established, and then the node transmission capacity was predicted by energy consumption, and the fitness functions were composed of residual energy, overload area and coverage redundancy, including the target function value pheromone. In the allocation strategy, the two-point crossover operator optimized the sequence of any two network nodes corresponding to the pheromone allocation strategy, and finally completed the optimal allocation of energy in wireless sensor network. This algorithm also has the problem of low efficiency of energy allocation in wireless sensor networks.
The energy allocation optimization of wireless sensor networks based on symmetric algorithm is proposed. The research frame is as follows:
The structure of wireless sensor network, the characteristics of wireless sensor network, the structure of wireless sensor network nodes and the constraints of sensor nodes are analyzed, respectively.
The scene of wireless sensor network is described, the energy distribution of the network is analyzed, and the energy optimization configuration model is completed.
The validity of the proposed algorithm is verified by testing the time-consuming of optimization, energy allocation efficiency and communication security of network.
The research contents are summarized.
Basic definitions
Wireless sensor network
Wireless sensor network is a communication network composed of a large number of sensor nodes through the application of wireless communication technology. Data processing, data acquisition, quantization and transmission can be carried out in sensor networks [20]. The emergence and development of wireless sensor network have opened up a new field for information technology. It has a very wide range of application value and application prospects in civil and military fields. Wireless sensor network is a further extension of sensor to intellectualization, wireless communication and miniaturization. Wireless sensor networks can be divided into two types: dynamic network and static network.
Structure of wireless sensor network
The structure of wireless sensor network is shown in Fig. 1. The wireless sensor network system is mainly composed of sensor nodes, task management nodes and sink nodes [1]. Sensor nodes are deployed in the monitoring area according to certain needs, and the sensor network is constructed by self-organization. The monitoring data obtained by sensor nodes can be transmitted along other nodes, and the information can be transmitted to the sink node through multi-hop routing. Wireless sensor network data transmission can also use a single hop cluster structure, wireless sensor network nodes will monitor data transmission to the cluster head node, and then by the cluster head node to the convergence node, and finally through satellite or Internet transmission to the management node.

Structure of wireless sensor network.
Sensor nodes are generally composed of micro-embedded systems. Their storage capacity, communication capacity and processing capacity are relatively weak. Generally speaking, they are powered by carrying batteries. From the perspective of network function, for multi-hop routing network, each sensor node must take into account the dual functions of terminal and router. Besides collecting environmental information, it also needs to store and re-transmit the data forwarded by other nodes. For a single hop network, the cluster head node acts as the terminal and router of the network node, and other sub-nodes transmit the collected data to the corresponding cluster head node. Cluster head nodes converge the data and transmit data to the sink node.
In wireless sensor networks, the communication, storage and processing capabilities of sink nodes are relatively strong. Sensor networks and external networks are connected by sink nodes to realize the communication protocol conversion between sensor networks and external network stacks. At the same time, the detection task of the management node is published, and the function of forwarding the collected data to the external network is realized. Usually, an enhanced sensor node can act as a sink node, have sufficient resources for simple calculation, and have sufficient energy supply, or can be a special gateway device with only wireless communication interface but without detection function.
Wireless sensor networks and mobile ad hoc networks have many similarities, some of the advantages of mobile ad hoc networks are absorbed by wireless sensor networks, such as variable rate coding technology, good communication quality; code division multiple access spread spectrum technology which can effectively use channel energy; spread spectrum broadband technology with frequency diversity effect; the use of error correction and interwoven coding, with time diversity effect, which can improve anti-jamming capability; spatial diversity utility, flexible networking, and high investment efficiency.
Compared with other traditional networks, wireless sensor network has the following unique characteristics:
The network scale is large: flexible networking and dynamic networking can be carried out flexibly. Generally, a large number of sensor nodes are deployed in the monitoring area [8], the number of nodes can reach tens of thousands, or even more. Sensor nodes entering the normal working state will automatically join the wireless network, because the wireless sensor network is composed of a large number of sensor nodes. Thus, the network has a very strong fault-tolerant performance. The blind area of time communication has also been reduced correspondingly. In terms of network size, the number of nodes in wireless sensor networks is several orders of magnitude larger than that in traditional networks.
Single-hop, multi-hop, self-organization: generally, the information transmission distance of sensor nodes is limited. When the communication distance is long, the nodes will automatically form a cluster structure to aggregate information to the cluster head, and then the cluster head communicates with the sink node or automatically searches for routing information. Finally, the information is transmitted to the sink node by multi-hop mode.
Low-power: in wireless sensor networks, sensor node processors are usually composed of micro-embedded devices, which have limited processing capacity, carrying energy, communication bandwidth and storage capacity. Because the large number of sensor nodes in the network are in the harsh detection environment, it is very difficult to replace the battery for sensor nodes. Generally, the sensor nodes used in wireless sensor network must be low power consumption.
Data-centric: In traditional networks, each working node must have a unique number in the whole network as its communication address, data forwarding is to determine a node by the communication address, and then through transmission to the final convergence node. In wireless sensor network, sensor nodes do not set specific communication addresses, the network is data-centric. Accessing to the required data is the first priority of the network, the data collected from which sensor node is not unnoticed.
Communication coverage is small: wireless sensor network communications, generally can only cover a range of tens to hundreds of meters. Communication between sensor nodes will be frequently connected, and communication anomalies or failures will occur frequently. Because sensor networks are often used in relatively harsh environments, they are vulnerable to high mountains, buildings, obstacles, landforms, storms, thunderbolts and other natural environments. Sometimes sensor nodes will be long time away from wireless sensor networks [9].
Data processing: data transmission is the main responsibility of traditional network, and all data related to functions are processed on the terminal system. The intermediate node is only responsible for data packet and forwarding; but the intermediate node of wireless sensor network has dual functions of data forwarding and data processing.
Low cost: In wireless sensor networks, a large number of sensor nodes are usually deployed, each node should be low cost.
Node structure of wireless sensor networks
When wireless sensor networks are applied in different environments, the sensor network nodes usually consist of four parts: processor module, sensor module, energy supply module and wireless communication module, as shown in Fig. 2.

Architecture of sensor node system.
The data acquisition unit is composed of sensors, which is mainly responsible for information acquisition and data conversion in the monitoring area.
The data processing unit is mainly responsible for controlling the operation of sensor nodes in the whole network, processing and storing the data collected by itself or the data sent by other nodes.
The data transfer unit is mainly responsible for wireless communication between sensors in the network, exchanging control information and transmitting and receiving data.
The power supply unit is mainly responsible for providing the required operating energy for the sensor nodes in the network. In general, it uses a micro battery to supply power.
According to the specific application environment and requirements, the precise location of sensor nodes can also be determined by the positioning system. Some sensor nodes may use solar panels to supply energy, but in most cases the battery energy of sensor nodes is not supplementary [7]. In addition, it is necessary to take into account the relevant parts of some applications, for example, some sensor nodes may be in the deep sea or the seabed, and may also appear in chemical or biological pollution, which requires special protection measures in the design of sensor nodes.
Limited power supply: The energy-consuming modules of sensor nodes mainly include processing module, sensor module and wireless communication module. With the rapid development and gradual maturity of low-power technology, the power consumption of the processor module and sensor module of the node has been greatly reduced. Wireless communication module occupies the majority of the energy consumption [3, 4]. The amount of energy consumed by the sensor node to transmit information compared to the energy consumed to perform the calculation is obvious. The energy required to transmit lbt information over a distance of 100 m can execute about 3000 instructions. The wireless communication module has four working states of sending, receiving, idling and sleeping, and the transmitting includes multiple power transmission states.
Limited communication capability: The energy loss of sensor nodes limits the coverage area of the whole network, so it is reasonable to adopt multi-hop transmission routing mechanism in the network. However, due to the change of node energy and the influence of natural environment such as mountain, building, obstacle, wind and rain, communication interruption may occur frequently, the single hop cluster structure is more suitable.
Energy optimization deployment model for wireless sensor network
Scene description
The research scenario is a static wireless sensor network composed of sensor node set N and communication link set L. Assuming that the capacity of each link l is C
l
, it is assumed that there is a communication link between nodes i and j if and only if they are within each other’s transmission range. Assuming that x
s
represents the rate at which data flows are sent from sensor node s (s ∈ N), x
s
satisfies m
s
⩽ x
s
⩽ M
s
, where m
s
and M
s
represent the minimum and maximum transmission rates of node s, respectively. All nodes n are used as a set of data forwarding nodes at definition S (n), and all nodes forwarding data for node n at definition R (n). Assuming the transmission capacity of each node is C
n
, and the transmission capacity is estimable, for each node s, the total forwarding rate value cannot exceed its transmission capacity, there are the following expressions:
The energy consumption of wireless sensor network needs to consider the energy allocation of multi-hop nodes along the transmission path, including the energy consumed by the source node when sending each message and the energy consumed by other nodes when forwarding the message [19]. A simple example is given to illustrate the linear topology of a sensor network consisting of three sensor nodes {1, 2, 3} and one destination node d. Each sensor node is assigned to transmit its collected data to the destination node d, as shown in Fig. 3.

Schematic diagram of linear topology sensor network.
For node 1, the energy consumed by the data it collects to the destination node d consists of two parts: one is the energy it consumes to perceive and transmit data, the other is the energy consumption of forwarding node 1 by node 2 and node 3. When the data consumption of node n forwarding node 1 is represented by pn1, the energy consumption of the whole network is
For node 2 and node 3, there are:
From the above analysis, the energy consumed by each node s in a sensor network can be represented by ∑n∈R(s)p
ns
, where p
ns
represents the energy consumed by node n to forward data from node s. The case in Fig. 3 generalizes a sensor network with N nodes. It is assumed that each sensor node continuously collects or forwards data until its energy exhaustion position, and σ
s
denotes the ratio of energy allocation of node s for forwarding other node data, σ
s
satisfies 0 ⩽ σ
s
⩽ 1, and for node s, the energy used to forward data should not exceed σ
s
e
s
, and the energy used to sense and transmit its own data should not exceed (1-σ
s
) e
s
. Therefore, for each node s, the collection is carried out. The energy consumed by the whole network in the process of data arrival to the destination node should satisfy the following constraints:
In this paper, the problem of optimal energy allocation for data collection and transmission in sensor networks is studied. The utility function of each node s is defined as U s · (x s ∑n∈R(s)p ns ), where x s and ∑n∈R(s)p ns represent the transmission rate and total energy consumption of each node respectively. Assuming that utility function U s is a concave continuous function of 6 and ∑n∈R(s)p ns and increases with the increase of x s and decreases with the increase of ∑n∈R(s)p ns , an optimal model can be obtained with the constraint conditions (1) and (5):
Equation (6) is a general optimization model. With the different definition of utility function U s , it can be transformed into optimization problem of sensor networks in different scenarios. Different design methods can be selected according to the requirements and objectives of the application to determine the specific form of utility function. Regardless of the definition of utility function U s , since the independent variables include node s and all the information forwarded to the node, it is necessary to understand the energy consumption and rate information of each node in WSN. The analysis of optimization model of energy allocation lays a foundation for the study of symmetry algorithm in energy allocation in wireless sensor network.
Symmetric algorithms use a single-key cryptosystem, that is, both encryption and decryption use the same set of keys, symmetric algorithms are divided into: grouping algorithm and sequential algorithm. Symmetric algorithm is relatively asymmetric algorithm. The algorithm is simple, running less resources, and unlike asymmetric algorithm is based on mathematical models that the algorithm structure of large integer decomposition and elliptic curve requires long key, long operation time, high resource occupation and weak anti-attack force. The symmetric algorithm is simple in structure, needs shorter key length, and encrypts and decrypts faster. In order to make the optimal configuration model of wireless sensor network energy achieve more secure wireless communication [2], it needs to use symmetric algorithm. In wireless sensor networks, symmetric algorithms are mainly considered in terms of the size of computing space and encryption speed. Because of the structural characteristics of wireless sensor network, there will be a large number of keys to be managed in the process of communication encryption. It is necessary to randomly deploy the nodes in the sensor network, the layout of the nodes and the topology of the wireless sensor network are unknown. When building a network, nodes can communicate with each other to obtain each other’s topology and flag information. The existence of these problems puts forward corresponding requirements for encryption routing algorithm and node’s hardware configuration [18]. In order to apply the symmetry algorithm to wireless sensor networks, the flag information of nodes and the topology information between nodes need to be stored in the nodes before the sensor network is arranged. The simpler method is to store the same key in the node in advance, and use the key to communicate in the wireless sensor network node.
The main idea of symmetric algorithm encryption is:
Given 64-bit plaintext, the plaintext is first replaced by an initial permutation IP transform, and then rearranged according to the IP permutation. The first 32-bit plaintext is
The 56-bit key is then subjected to a symmetric algorithm to obtain 16 48-bit subkeys, denoted by kl, k2, k3, …, k16, used for 16 iterations.
After 16 rounds of identical algorithm transformation, two 32 bits of L′ 16 and R′ 16 are obtained.
Finally, R′16 and L′16 are replaced by IP-1 (inverse transformation of IP transform) to get 64-bit ciphertext, that is, the ciphertext result is IP-1 R′16 L′16.
The decryption process of symmetric algorithm is the opposite process of encryption. The key is used in reverse order and encrypted, i.e. represented by k16, k15, . . . , k1, and the algorithmic programs of of encryption and decryption are the same (that is, algorithmic of encryption and decryption occupies the same). In a wireless sensor network with n′ nodes, the number of keys in the whole network using symmetric algorithm is
In Equation (7), η denotes the power of channel noise in wireless sensor network, and the constraints are substituted in Equation (7):
Assuming that the position of the head and tail of the chain is fixed and the transmission rate of the data stream is fixed, the energy consumption of the wireless sensor network can be minimized by the transmission power of each hop between the head and tail of the chain. Because the data transmission rate is fixed, the optimal transmission power of the chain head is also fixed, the energy consumption of wireless sensor network can be optimized only in the nodes between the chain head and tail (except the chain head). The derivation can be obtained:
The optimal routing hops in wireless sensor networks are:
The minimum RF radius per hop is
Equation (12) is used to obtain the minimum transmit power of the optimal energy allocation model for wireless sensor networks. Combined with the above analysis, the optimal energy allocation for wireless sensor networks is completed.
The ɛ represents the energy dissipation coefficient, and the Equation (16) can be used to optimize the energy allocation of wireless sensor network. At the same time, the nodes of wireless sensor network are also configured. Each node sends its own key to its neighboring nodes, and the key sent to the neighboring nodes is randomly selected from a key subspace. The neighboring node discovers the transmitted key, and the key conforms to the encryption condition, so that the received key is used as the encryption key of the wireless sensor network to transmit the message thereafter. It can ensure that the encryption keys of both nodes are the same, which greatly improves the communication security of both sides in the energy optimization configuration model of wireless sensor network.
In order to verify the effectiveness of the symmetric algorithm in optimal energy allocation of wireless sensor networks, symmetric algorithm, the algorithm in reference [5], the algorithm in reference [6] are used to test the energy optimization of wireless sensor network. The effectiveness of the time consuming test results of energy optimization in wireless sensor network are shown in Fig. 4.

Time consuming test results of optimization in wireless sensor network.
As shown in Fig. 4, during the 7 iterative tests, the maximum energy consumption time of the wireless sensor network in [5] algorithm is 4μs, and the maximum time consumption of the algorithm in [6] is 5μs. It takes only 2μs. The comparison of experimental results shows that the energy optimization in the wireless sensor network of this algorithm takes less time.
The encryption time of the network node is used to test the energy allocation efficiency. The test result is shown in Fig. 6.
From Fig. 5(a), we can see that in 30 iterations, the energy allocation efficiency of wireless sensor networks by using Algorithm 1 is higher, the highest point is close to 100%. Analysis of Fig. 5(b) shows that the energy allocation efficiency of wireless sensor networks with 30 iterations by using Algorithm 4 is under 60%, the highest point is close to 60%. From Fig. 5(c), it can be seen that the efficiency of energy allocation of wireless sensor networks in 30 iterations by using Algorithm 5 varies from 0% to 80%, mainly from 0% to 40%. The comparison shows that the energy efficiency of wireless sensor networks based on symmetric algorithm is higher.

Test results of energy allocation efficiency in wireless sensor network.
On the basis of testing the time-consuming of energy optimization and energy allocation efficiency of wireless sensor network, the security of wireless sensor network communication is tested by using the encryption time of network nodes. The shorter the encryption time is, the faster the encryption speed is, and the higher the security of wireless sensor network communication is. The test results are shown in Fig. 6.

Security comparison of wireless sensor network communication.
Figure 6 shows that the encryption time is 0.6 ms when the number of wireless sensor network nodes is 200, and the encryption time of 600 sensor network nodes is 0.7 ms. When the number of network nodes is 200, the corresponding encryption time is 0.7 ms, the encryption time of 600 sensor network nodes is 0.9 ms. In Fig. 6(c), when the number of sensor network nodes is 200, the corresponding encryption time is 0.8 ms, and the encryption time of 600 sensor network nodes is 1 ms. The shorter encryption time of nodes indicates that the encryption speed of the proposed algorithm is faster and the security of wireless sensor network communication is better.
By testing the energy optimization time-consuming and energy allocation efficiency of wireless sensor networks, the effectiveness of the symmetric algorithm is verified. On this basis, the security of wireless sensor network communication is tested by using the node encryption time. The test results show that the proposed symmetric algorithm takes less time, has higher energy allocation efficiency, and shorter encryption time in the process of optimal energy allocation in wireless sensor networks. The symmetric algorithm can make wireless sensor network communication more reliable and secure. The test results show that the symmetric algorithm can make the communication of wireless sensor networks have better security. The above three experiments not only verify the effectiveness of the symmetric algorithm, but also ensure the security of wireless sensor network communication.
Conclusions
Based on symmetrical algorithm, the application of symmetrical algorithm in optimal energy allocation of wireless sensor networks is studied.
The effectiveness of optimal energy allocation in wireless sensor networks by using optimization time-consuming and energy allocation efficiency is tested, the results of shorter time-consuming of optimization and high energy allocation efficiency are obtained, which verify the effectiveness of the proposed algorithm.
Finally, the encryption time is used to test the security of wireless sensor network communication. The experimental results show that the proposed algorithm has better security in wireless sensor network communication.
Footnotes
Acknowledgments
This work is supported in part by 2016 Key base of tourism and scientific research of Sichuan Provincial Tourism Administration (No. ZHZ16-02), and 2017, 2018 Artificial Intelligence Key Laboratory of Sichuan Province (No. 2017RYY05, No. 2018RYJ03); The first batch of key science and technology projects in Zigong in 2019 (No. 2019YYJC16).
