Abstract
Wireless sensor network (WSN) is a new type of wireless network. It has many advantages, but there are some problems. These problems make it easier for attackers to analyze network security holes and attack and destroy entire networks. This article designs a security wireless sensor network model. It can resist most known network attacks without significantly reducing the energy power of sensor nodes. First, we cluster the network organization to reduce energy consumption. It also protects the network based on the calculation of trust levels and the establishment of trust relationships between trusted nodes and operates the trust management system based on a centralized method, secondly, on the basis of LEACH agreement, draws lessons from the principle of biological immune system, optimizes the wireless sensor network, and further proposes a new immune system structure suitable for wireless sensor networks. The experimental results show that the wireless sensor network model designed in this paper solves the high-efficiency and energy-saving design task, and the trust management system has satisfactory results in defending against attacks.
1. Introduction
After four generations of development, wireless sensor network integrates communication technology, embedded computing technology, distributed information processing technology, and sensor technology, so that people can obtain detailed and reliable information and realize the dream of “ubiquitous computing” [1, 2]. It has huge vitality in the fields of national defence and military, environmental monitoring, medical, and health [3]. Wireless sensor network (WSN) is a basic new type of wireless network, which is based on an infinite number of microsensors powered by a limited amount of batteries, designed to collect information and monitor objects [4, 5]. WSN has many advantages, such as wireless communication channels and dynamically changing topological structures. But there are also shortcomings, such as insufficient infrastructure, big data flow and unlimited nodes, limited battery power supply, and node mobility. These problems allow attackers to more easily analyze network security vulnerabilities to attack and destroy the entire network or a certain controlled object [6].
Generally speaking, the vast majority of attacks focus on disabling sensor nodes, routing protocol disorientation, and destroying the entire network. At present, there are generally two methods to prevent attacks—encrypted measures and nonencrypted measures [7]. The main purpose of encryption measures is to defend against external intrusions and prevent intruders from infiltrating the network. In this case, if a node is broken or captured by an attacker, as a whole network, other nodes will also be threatened. Encryption measures require a large amount of memory and high power consumption in processing and communication, which makes it unsuitable for WSN with limited resources. Therefore, it is necessary to use other security measures. The purpose of the nonencrypted method is to protect the network from internal attacks. Attack analysis shows that most attacks can be called active attacks [8]. In WSN, active attacks present different methods, and data packets can freely enter the wireless channel through internal attackers.
Since the application-oriented domain is one of the main characteristics of wireless sensor networks, it is difficult to have a general specific reference structure to follow [9]. The lack of a unified architecture standard will increase the difficulty of coordination between different systems, cause a waste of research resources, and even restrict the further development of wireless sensor networks. Therefore, this paper proposes an optimized WSN architecture and strives to integrate the advantages of various architectures to improve the module reusability and overall performance of wireless sensor networks. This article first clusters network organizations to reduce energy consumption. It also protects the network based on the calculation of trust levels and the establishment of trust relationships between trusted nodes and operates the trust management system based on a centralized method. Secondly, on the basis of the LEACH protocol, drawing on the basic ideas of biological immunity, a new immune system structure suitable for wireless sensor networks is proposed. The immune response strategy effectively resists attacks from malicious nodes and reduces and eliminates the impact of malicious data, thereby ensuring data security.
The structure of the paper is as follows: Section 2 provides related works. Section 3 discusses our approach. Results are presented in Sections 4. Section 5 concludes the paper.
2. Related Knowledge
2.1. The Development Status of Wireless Sensor Networks
Research on wireless sensor networks began in the late 1990s. Since the 21st century, sensor networks have attracted great attention from academia, military, and industry. The United States and Europe have successively launched many research projects on sensor networks [10, 11]. In particular, the United States has invested heavily in support of sensor network technology research through various channels such as the National Natural Science Foundation of China and the Department of Defence. In 1995, the US Department of Transportation proposed the “National Intelligent Transportation System Project Plan,” which is expected to be fully operational by 2025 [12, 13]. The plan attempts to effectively integrate advanced information technology, data communication technology, sensor technology, control technology, and computer processing technology for the entire ground transportation management and establish a real-time, accurate, and efficient integrated transportation management system. This new system will effectively use the sensor network for traffic management. It can not only make the car drive at a certain speed and automatically maintain a certain distance between the front and rear cars, but it can also provide the latest news about road congestion and recommend the best driving route and remind the driver to avoid traffic accidents, etc. [14]. Because the system will use a large number of sensors to keep in touch with various vehicles, people can use computers to monitor the operating conditions of each car. According to the specific situation, the computer can automatically adjust to keep the vehicle in the best operating state with high efficiency and low consumption and issue warnings about potential failures or directly contact the accident rescue centre [15].
Due to the great application value of wireless sensor networks, it has attracted great attention from the industrial, military, and academic circles in many countries around the world [16]. Information industry giants have also begun research on sensor networks. The technologically developed countries in Japan, Britain, Germany, and Italy have also shown great interest in wireless sensor network technology and have launched research in this field. However, most of the work is still in its infancy. The few commercial products put into use are still far from actual demand. There is very little research work on wireless sensor networks in our country. At present, some domestic colleges and universities and scientific research institutions have actively carried out relevant research work on wireless sensor networks.
At present, domestic research hotspots are mainly concentrated in areas such as wearable computing, context-aware environments, and smart classrooms. The application of wireless sensor network technology in environmental safety monitoring is still rare. Generally speaking, domestic research on sensor networks is still in its infancy. However, because sensor network is an emerging technology, the gap between domestic and international levels is not very large. Promptly carrying out research on this cutting-edge technology that has a far-reaching impact on the future life of mankind will have great strategic significance for the society and economy of the entire country [17–19].
2.2. Protocols in Wireless Sensor Networks
There are many routing protocols in wireless sensor networks, which can be mainly divided into three categories. They are data-centric routing protocols represented by directed diffusion [20], hierarchical routing protocols represented by LEACH [21], and location-based routing protocol represented by GEAR [22].
However, these routing algorithms proposed for wireless sensor networks only improve the application of the network as much as possible but do not fully consider security issues. In recent years, the academic community has conducted research on the security of wireless sensor networks from different levels and angles. Literature [23] and literature [24] research on routing security in wireless sensor networks. The work in this area mainly uses encryption and authentication technology; the purpose is to establish a reliable and energy-efficient multihop routing path for data transmission. Literature [25] and literature [26], respectively, proposed new broadcast authentication protocols based on the μTESLA protocol. Literature [27] proposed a sensor network security protocol SPIN to solve the problems of sensor network node key agreement, point-to-point authentication, and data freshness. Literature [28, 29] proposed a secure LEACH protocol (SecLEACH) on the basis of random key distribution, SPIN, and μTESLA. Literature [30] introduces a security authentication scheme between nodes and proposes a secure LEACH protocol to contain abnormal nodes, namely, SLEACH.
Although many results have been achieved, there are still many security issues and security protocols that need to be further studied.
The use of encryption and authentication technology can effectively resist external forged routing information and improve the security of the routing protocol. But it affects the efficiency of the system. In wireless sensor networks, public key cryptography cannot be used. Therefore, the μTESLA mechanism is less efficient when the number of sensor nodes is large.
Biological immune system is a highly distributed, parallel, and adaptive system. The system has good robustness and high complexity. This provides important clues to building a robust computer security system. The wireless sensor network is a typical distributed, self-organizing environment, which can learn from the working principle of the biological immune system. Literature [31] first proposed a wireless sensor network security architecture based on biological immunity, mainly using the idea of an intrusion detection system, but did not give a specific implementation plan. The processing of malicious nodes is only a kind of simple intrusion isolation.
3. Method
3.1. Wireless Communication Network Hierarchical Trust Management Model
Although in the literature [32], a wireless communication network hierarchical trust management model is proposed. However, the network model does not consider the decision-making role of the base station (BS). In addition, it does not provide a security protocol to implement network security mechanisms and related algorithms. The cluster head of this model is relatively fixed. The cluster heads in our system are dynamic and changeable. For this reason, we designed an algorithm for cluster head reselection. In this way, our system is abler to adapt to the complexity and variability of the real environment.
Our main purpose of designing the trust management system is to protect WSN from malicious actions of attackers. We combine reliability with the ability to resist attacks for as long as possible. Energy efficiency refers to the ability to maintain the operability of the network for as long as possible using less energy. To reduce energy consumption, we adopt the following measures: (1)One way to reduce the power consumption of a sensor is to change it from an active state to a “sleep” state to minimize its energy consumption. This can be achieved by reducing packet forwarding between nodes. Under this model, WSN is divided into multiple clusters(2)Reduce the amount of calculation of sensor node (SN)(3)Use the method of data aggregation to minimize the energy consumption in WSN(4)The aggregator is used to collect information from other nodes, calculate the aggregation function, and transmit its value to the network coordinator. Compared with the situation without aggregator, the total cost of information transmission is significantly reduced
The architecture of this model is shown in Figure 1. The information collection module obtains information from the SN and uses it to calculate the trust level. Then, according to the node type, the results are analyzed. SN does not trust the connection management module. This module processes information about node . If node successfully passes the test, the data associated with goes into the trusted node table. Therefore, all nodes in the same cluster will receive messages about node . If node detects that there is an abnormality in node , node will send a message to CH, and CH will make a decision about node . (1)Information collection module

Two nodes in the same wireless transmission and reception range are called neighbours. Due to the broadcast characteristics of the wireless medium, a given node can collect first-hand information about data packets. By listening to all frames received by the MAC layer and recording the transmission data of the data packet, the behavior of its neighbouring nodes is forwarded. If it is a cluster-based WSN, a condition must be added. The condition is that the nodes must be in the same cluster. (2)Trust level calculation module
We have given a formula for calculating the trust level.
Here, is the trust value of node with respect to node , is the number of successful events of measured by , and is the number of failed events of measured by . And , , , and represent the weight/importance of successful events relative to the weight/importance of failure events. Each network event will calculate the trustworthiness value. The trust values associated with these behaviors are then multiplied by the weight factor to reflect their importance in the security level. Add them together to get the reliability of the entire node. The specific calculation formula is shown in formula (2). Further, we can obtain the level of stability.
Among them, refers to the remaining energy level; refers to the mobility level of the node; refers to the distance from the base station; refers to the stability level; (3)Trusted connection management module
The module works according to the following algorithm to determine the confidence level: (1)CH gets the parameters from the analyzer(2)CH requests sensor node to provide and (3)CH uses formula (2) to calculate according to the received parameters(4)CH compares the values: if , continue the algorithm; otherwise, the incorrect value of will become untrusted(5)CH compares with the number of packets sent
The following conditions should be maintained: (6)If these conditions can be maintained, then is credible; otherwise, it is necessary to analyze the type of data packet sent
If most packets are managed, is untrusted. If most packets are routed, is untrusted. If most packets are of data type, then is indeterminate. So let us do the analysis under this condition.
3.2. Security Protocol for Managing Mobile Clustered Wireless Sensor Network
This article provides a protocol to protect mobile sensor networks from all major types of network attacks, while not significantly reducing the power consumption of nodes and the life expectancy of their networks.
The base station sends the initialization message to all network nodes. All nodes therefore receive the information and send a response message to the BS in the same way according to the timeout definition. The BS receives the information about the node and checks the ratio of serial numbers. The last step in the initialization process is a message from the base station. This message will be sent to all configured nodes, and if any node does not receive the message, the BS will consider it suspicious or malicious. Nodes that have been initialized are marked as trusted.
On the other hand, the BS will also add these nodes to the list of trusted nodes, and future cluster heads will be selected from these nodes. The initialization process has two purposes. First, establish a trusted connection between the base station and the node. Second, the base station can store the preloaded list of trusted nodes in the network and compare the data it obtains with its own dynamic list.
The BS announces the start of CH selection and sends a special message to each node. The BS executes the node initialization algorithm to determine the confidence level of the network node. If a node has been successfully verified, the base station will indicate that the node can become a CH. BS requests verified nodes to provide . BS grades the value of and calculates the average value. If the value of of is greater than or equal to the average value, it will be selected as a temporary CH. The base station sends a cluster head election to each node finished message.
In addition, the BS sends a message that it may become a CH to each potential cluster head CH_temp.
When the BS completes the selection of potential cluster heads, it starts the network clustering algorithm. The idea of the algorithm is that each temporary cluster head must calculate the distance between CH_temp and BS. After that, CH_temp sends the value of together with the proposal to join the cluster to neighbouring nodes. Next, each node determines the minimum value it receives and confirms the corresponding CH_temp. On the other hand, each CH_temp compares its value with the neighbour’s value. If its own value is the smallest, CH_temp can be self-styled as a cluster head and notify all its neighbours and BS. Figure 2 shows the network clustering algorithm.

The BS periodically sends requests to the CH regarding the following:
3.3. Based on LEACH Wireless Sensor Network Immune System
There are many architectures of WSN, such as hierarchy architecture and clustering architecture. The protocol of hierarchical architecture consists of three operations, namely, network initialization and maintenance protocol, MAC protocol, and routing protocol. The receiver-oriented distributed time division multiple access (TDMA) channel allocation protocol is adopted in the data transmission phase, and the “hidden” and “exposed” problems can be avoided by appropriate channel allocation algorithm. The clustering architecture consists of clusters of sensor nodes, each of which is controlled by a cluster head. The performance of stability is sacrificed to reduce protocol overhead. The architecture based on LEACH has good stability and cost performance. Therefore, this paper chooses leach-based architecture.
The LEACH protocol divides all nodes into several clusters. Each cluster elects a leader. Cluster leaders can also form higher-level clusters. The cluster leader receives the data sent by the nodes in the cluster, realizes the data fusion function, and sends data to the base station. Since sending data to the base station consumes a lot of power, the leader needs to be reelected at regular intervals to ensure that the power consumption is evenly distributed among all nodes.
The protocol has two operating phases: cluster establishment phase and stable operation phase. In order to reduce the protocol overhead, the duration of the stable operation phase is longer than the cluster establishment phase.
The basic idea of LEACH is to randomly select cluster head nodes in a circular manner and evenly distribute the energy load of the entire network to each sensor node, so as to achieve the purpose of reducing network energy consumption and improving the overall survival time of the network. The protocol defines the concept of “round.” Each round can be divided into two phases: the cluster establishment phase and the stable phase of data transmission.
In order to save resource overhead, the duration of the stable phase is greater than the duration of the setup phase. In the cluster establishment stage, the cluster head is selected first, and the selection of the cluster head node is based on the total number of cluster head nodes required in the network and the number of times each node has become a cluster head so far.
The specific selection method is each sensor node selects a value belong to [0, 1]; if the selected value is less than a certain threshold Tre, then this node becomes the cluster head node. The threshold Tre is calculated as formula (6):
Among them, is the percentage of cluster head nodes to the total number of nodes, is the current round number, is the set of nodes that have not acted as cluster heads in the past rounds, and the symbol mod is the modulus operator (as shown in Figure 3).

The immune system of wireless sensor network based on LEACH can be expressed as a 4-tuple .
Among them, is the self-individual collection. is the collection of antigens to be detected. is the set of discriminant functions.
In order to design a data security immune system structure, it is necessary to combine the characteristics of wireless sensor networks and add some new functional nodes. In order to make the wireless sensor network have immune function, a kind of node with immune function will be added, which is called immune node. Consider the possible attacks of wireless sensor networks that cause malicious nodes to become cluster heads. In this case, if it is not stopped, the work of the entire cluster will not be completed normally.
In order to deal with this situation, the article uses a backup cluster head strategy and introduces a fifth type of node, that is, the backup cluster head.
This article puts the immunoassay step in the data fusion process and introduces the self-gene bank . Since the computing power and energy performance of the base station are much higher than that of ordinary sensor nodes, it can be assumed that the effectiveness of the base station in identifying malicious data is quite high. The majority voting mechanism of immune nodes makes its overall credibility relatively high.
4. Results and Discussion
4.1. Conspiracy Attack Experiment
Figure 4 shows the accuracy of the wireless communication network hierarchical trust management model and other models designed in this paper under collusion attacks when the percentage of malicious servers in WSNs ranges from 10% to 90%.

As can be seen in the figure, the results of BTRM [33], Eigen [34], and the model in this paper are basically similar; until the percentage of malicious servers is less than 70, the result of BTRM is better. When the percentage of malicious servers is greater than 80, the accuracy of TMS [35] is between 60 and 50%, indicating that there are certain security flaws. But the results of other simulation models are basically the same or worse, and our model can deal with 70% of malicious nodes, which is satisfactory to us.
4.2. Oscillation Attack Experiment
In the oscillatory network, our accuracy is higher. Figure 5 shows that all models except BTRM have an accuracy higher than 50%. Therefore, although the model in this paper does not achieve the best results in the selection percentage of credible servers, despite this, its accuracy is still higher than 70%, and the model in this paper has the lowest energy consumption value in all experiments.

4.3. Collusion and Oscillation Attack Experiment
When conducting collusion and oscillation attacks, the performance of the BTRM model is the least satisfactory. As shown in Figure 6, when the number of malicious servers exceeds 40%, the accuracy of the model is less than 70%. It can be said that the model has some shortcomings, while other models can last up to 60% of malicious servers. When the malicious server exceeds 70%, the accuracy is about 50%; this result is acceptable. After testing, it can be seen that our model performs well, and the energy consumption level is lower than other models.

4.4. Energy Difference between Nodes
In wireless sensor networks, the energy difference between nodes reflects the balance of energy consumption between nodes. The energy difference is defined as the difference between the maximum residual energy and the minimum residual energy of the nodes in the network. The smaller the energy difference between nodes, the more uniform the energy consumption of the network, and the longer the life of the network. In this experiment, we compare the energy difference between several algorithms.
Figure 7 compares the energy difference of several algorithms. In Figure 7, the abscissa represents the number of nodes in the network, and the ordinate represents the magnitude of the energy difference.

It can be seen from the figure that the energy difference of the L-PEDAP algorithm is the largest. The reason is that in L-PEDAP, each node needs to periodically establish a local minimum spanning tree. Because L-PEDAP has an energy sensing function, the weights of edges in the established network graph are always changing. L-PEDAP can locally balance the energy consumption of nodes, and the more neighbours, the higher the energy consumption of nodes. This is because when the node density is high, when establishing a local minimum spanning tree, each node needs to communicate with neighbour nodes to obtain the remaining energy information of the neighbour nodes. Therefore, nodes with many neighbours will consume a lot of energy when building a local minimum spanning tree. Conversely, nodes with fewer neighbours will not consume much energy. Due to the random distribution of the network and the unevenness of the node density, both types of nodes will exist in the network. Therefore, there will be a large energy difference in L-PEDAP. The energy difference of this system is the smallest. The more uniform the energy consumption of the network, the longer the life of the network.
4.5. Immune Function
In the case of not being attacked, the network architecture system after the immune function is added in the life cycle and the number of data packets received by the BS; the simulation results are shown in Figure 8. The result proves that after adding immune function, it has little effect on LEACH performance.

Corresponding to the network life cycle, it can be seen that in the four methods in Figure 8, the data packets received by the base station show a linear upward trend during their respective life cycles. The three security policies and LEACH without security policies are received at the base station. There is not much difference in the number of data packets received. However, due to the different network life cycles, the final received data packets are also quite different.
Because the immune system proposed in this article is embedded with digital genes. Therefore, when a malicious node sends malicious data to the cluster head, in the data fusion stage, the cluster head can find the malicious node and invoke an immune response to it. After that, the malicious node will not have an impact on the entire network. The simulation results of SecLEACH’s and SLEACH’s ability to resist malicious nodes joining the cluster are compared with the method in the paper as shown in Figure 9. SecLEACH has poor performance in this respect, almost the same as LEACH without safety functions. This is because it does not solve the authentication problem when the member nodes enter the cluster. Because SLEACH adopts node authentication, its resistance in this respect has the same effect as the method in this paper.

The damage of Hello flooding attack to LEACH is considerable. When a malicious node becomes the cluster head, the function of the entire cluster will be invalid, which is equivalent to false death. A similar Hello flooding attack is used to verify the performance of the algorithm. Here, 60 common malicious nodes that become cluster heads are used to compare the antiattack ability of each scheme. The simulation results are shown in Figure 9. Although the performance of SecLEACH in this respect is slightly higher than the method in the text, but SecLEACH is a centralized strategy, and the validity of the cluster head needs to be verified by the base station. The sensor nodes in the network have no energy consumption in this respect. And as a result, the base station can easily expose its own private data, which creates new problems. The method in this paper does not rely on the distributed strategy of the base station at all.
It can be seen from the above analysis that the performance of the network architecture system designed in this paper is generally optimal. Under the premise of not relying on the base station, the influence of malicious data on the final result is excluded, and the loss of the malicious node as a cluster head is minimized.
5. Conclusion
Under the premise of considering information security, this paper first developed a trust management system based on clustered wireless sensor network. It can resist most known network attacks without significantly reducing the energy power of sensor nodes. And for the efficient and energy-saving operation of the system, on the basis of LEACH protocol, the principle of biological immune system is used for reference to optimize the wireless sensor network and further proposed a new immune system structure suitable for wireless sensor networks. The experimental results show that the wireless sensor network model designed in this paper solves the high-efficiency and energy-saving design task and has ideal robustness on the basis of a small amount of energy overhead, and the system has good practicability.
The research on data security immunity in wireless sensor networks is still a relatively new field. Due to the limitation of network resources, energy consumption, algorithm efficiency, and overall performance need to be considered comprehensively. Further research is needed to design an optimal immune system.
Data Availability
The data used to support the findings of this study are available from the corresponding author upon request.
Conflicts of Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.