Virus Propagation in Wireless Sensor Networks with Media Access Control Mechanism

In wireless sensor networks, network security against virus propagation is one of the challenges with the applications. In severe cases, the network system may become paralyzed. In order to study the process of virus propagation in wireless sensor networks with the media access control mechanism, this paper uses the susceptible-infectious-removed (SIR) model to analyze the spreading process. It provides a theoretical basis for the development of virus immune mechanisms to solve network virus attack hidden dangers. The research shows that the media access control (MAC) mechanism in the wireless sensor network can inhibit the process of virus propagation, reduce the network virus propagating speed, and decrease the scale of infected nodes. The listen/ sleep duty cycle of this mechanism will aﬀect the suppression eﬀect of virus propagation. The smaller the listen/sleep duty cycle, the stronger the suppression eﬀect. Energy consumption has a peak value under speciﬁc infection probability. Meanwhile, it is also found that the spreading scale of the virus in wireless sensor networks can be eﬀectively inhibited by the MAC mechanism.


Introduction
Viruses and cyber-attacks frequently exposed to computer networks have caused significant losses to human society. A network virus refers to a group of computer instructions or programs that can damage data or destroy device functions and spread through computer networks such as the Internet or wireless communication networks [1]. Different from the so-called viruses in biology, a network virus is created artificially and implanted malignantly but does not occur naturally. A network virus can self-replicate and selftransmit without human intervention, can trigger and lurk, and at the same time can have strong destructive ability and great harm [2]. For example, the worm known as the "beauty killer" once caused a world-renowned Internet paralysis event [3].
e Chernobyl virus (also known as CIH or Spacefiller) damages the essential input and output system of the computer by infecting the executable file of the system, making the machine unable to start usually [4]. Wireless sensor networks, which are composed of a large number of low power consumption sensor nodes through wireless communication technology, are a kind of computer networks [5] and are also threatened by network virus. Some researchers have found that the topology of wireless sensor networks is relatively complex and vulnerable to virus attack [6], because wireless sensor networks are constrained by space, energy, channel bandwidth, and other conditions [7]. Furthermore, the resources and power of the nodes in the wireless sensor networks are limited. Once a large number of nodes are infected, it is easy to become invalid due to the exhaustion of resources or energy. e failure of a large number of nodes will increase the average path length of the network, reduce network performance, lead to disconnection of this network, and stop the service of the system. erefore, the threat of the viruses in the wireless sensor networks is more vulnerable than the traditional wired networks [8,9].
However, in essence, wireless sensor network virus propagation is similar to traditional virus propagation in other computer networks. Some studies have found that worms, malignant virus, and other viruses can use the vulnerability of the communication protocol or mechanism loopholes to expand communication by web pages, emails, Bluetooth, WIFI, etc. [10]. Besides, some studies have found that the virus can intensify the transmission process in mobile networks by the dynamic movement of devices [11].
ere are many existing pieces of research on the dynamic process of virus propagation in wireless sensor networks. But because the wireless access layer of wireless sensor networks (WSNs) has a relatively new view on the influence of virus propagation, there are few relevant studies and few references on the impact of wireless access layer in the relevant literature. So, it is necessary to do further research on this subject.
In this paper, we intend to study the virus propagation process in the wireless sensor networks by using the susceptible-infectious-removed (SIR) propagation model. We mainly consider the influence of the media access control (MAC) mechanism on virus propagation in wireless sensor networks with uniform random distribution and limited communication capacity. A random network topology model with a limited communication range is established based on the Waxman algorithm, and the SIR virus propagation model is developed on this basis. We considered the effect of the MAC mechanism on the virus infection process in wireless sensor networks. e research results reveal the pattern of virus propagation in wireless sensor networks, which can provide a basis for improving the security of wireless sensor networks. e rest of this paper is structured as follows: Section 2 introduces the current research on virus propagation in wireless sensor networks and the basic principle of the influence of MAC mechanism on virus propagation in wireless sensor networks. Section 3 proposes an improved SIR model. Section 4 conducts this improved SIR simulation. Section 5 analyzes the experimental results. Section 6 makes a conclusion and outlook.

Related Work
With the continuous expansion of wireless sensor networks in the fields of industry, agriculture, military, etc., the importance of security issues has become increasingly prominent, among which the wireless sensor network virus attack has attracted much attention. Many researchers have participated in the study of virus propagation in wireless sensor networks. In the research process, some researchers will consider the network application scenarios or the environment. Some researchers will consider network constraints, such as communication range, node energy, etc. Some researchers have also enhanced the security and robustness of the network by establishing devices and data trust system in networks [12,13] and proposed trust evaluation mechanisms [14]. Some researchers will pay attention to the applicable model of virus propagation in wireless sensor networks, such as the susceptible-infectious (SI) model, SIR model, etc.
e SIR model is one of these typical virus propagation models. Due to the moderate complexity of the SIR model, it can better characterize the dynamical state of nodes in virus propagation, so it has a specific model reference value. Besides, there are many versions of improved SIR models in wireless networks, which are modified or extended based on the SIR model. Hu et al. [15] analyzed the dynamic propagation characteristics of wireless sensor networks with regional detection mechanisms using a two-dimensional cellular automata-based SIR model. ey found that the regional detection mechanism can not only regionalize the wireless sensor network but also prevent the malware propagation in the wireless sensor network by implementing the detection strategy. e regional detection mechanism can reduce the risk of virus outbreaks. Tang et al. [16] used the susceptibility-infection-recovery-maintenance (SIR-M) model to describe the dynamic process of the malicious viruses spreading from a single node to the entire network in WSN. Zhou et al. [17] modified the traditional SIR model according to low energy adaptive clustering hierarchy (LEACH) protocol communication rules, formed a new SIR model, and used it to describe the virus propagation dynamics in IPv6 wireless sensor networks. Feng et al. [18] used a SIRS model as considering the communication radius and node distribution density to capture the space-time dynamics of the worm propagation process. Wang et al. [19] analyzed the propagating dynamics of worms in wireless sensor networks by introducing the death node state and susceptible-infectious-removed-susceptible (SIRS) mechanism that cannot normally work due to energy depletion based on the traditional SIR model. Srivastava et al. [20] used the susceptibility-infection-dead-recovery (SIDR) propagation model that introduced the concept of death node to discuss the propagating dynamics of digital worms in wireless sensor networks with limited node energy. Singh et al. [21] introduced exposure state and inoculation state based on the SIR model to study the transmission behavior of a digital worm virus. By considering the sleep mechanism of WSN, Upadhyay et al. [22] developed an e-epidemic energy-efficient susceptible-infected-terminally infected-recovered (SITR) model to study and analyze worm attack behavior in wireless sensor networks using cyrtoid-type functional response. ey obtain the stability and directionality of the Hopf bifurcation of the local equilibrium point by using the central accessible theorem analysis.
As far as we know, the original model and improved version of SIR are applicable to not only WSN networks, but also other complex networks, and the scope of application is quite extensive. For example, Xiang et al. [23] used SIR model to simulate emotion contagion in dynamic crowd aggregation process, and they found that the SIR model can effectively improve the fidelity of emotional interaction processes and crowd aggregation. Lamb et al. [24] described the SIR stochastic epidemic model of computer virus by combining the time-Markov chain of the minimum traffic model and the control of virus propagation. ey applied the model to the scale-free networks to determine how the free flow and traffic flow in the crowded phase affect virus propagation. Androulidakis et al. [25] used the susceptibleexposed-infectious-removed (SEIR) model to simulate the infection of malware in the Private Branch eXchanges (PBX) network and monitor their development. And the results show that two days are sufficient for the malware diffusion. No matter which researchers use virus propagation model, this model is selected according to the principle of optimal and most suitable, which can adequately reflect the characteristics of virus propagation in a specific wireless sensor network structure.
In the existing studies on virus propagation in wireless sensor networks, most researches concern the influence of network structure or node state changes on virus propagation. Some other researchers will also pay attention to the impact of the MAC, and they will add MAC mechanisms to the study on virus propagation in wireless sensor networks. MAC mechanism, also known as the media access mechanism, is applied to the data link layer. In wireless sensor networks, it is mainly used to solve network channel disputes and allocate channel access, and wireless communication resources [26]. However, in wireless sensor networks, viruses generally function in the application layer, so virus propagation is restricted by the MAC layer, the same as other standard data transmissions [27]. Li et al. [28] pointed out that MAC protocol is a very complicated protocol, which can control the entry channel of nodes and influence the number of infected nodes at the time of t to influence the spread of network virus. Wang et al. [29] showed that the channel monitoring of the MAC mechanism can limit the communication between nodes and inhibit the propagation of network virus by reducing the density of network infected nodes. Research shows that the smaller the duty cycle of sleep/listening, the better the suppression effect of network virus propagation. Also, the network structure will affect virus propagation. For example, the network node distribution strategy with local clustering features will increase the virus propagation speed. From the current research status, few studies consider the influence of the MAC mechanism in the study of wireless sensor network virus propagation. However, the MAC mechanism is often used in wireless sensor network communication and has a far-reaching influence on network virus propagation. erefore, it is necessary to consider the MAC mechanism in the study of wireless sensor network virus propagation.
In this paper, wireless sensor networks with uniform and random distribution of network nodes are established by using the Waxman model. It is assumed that the sensor nodes in the network have a limited communication radius, and an improved version of the SIR model is used to study the propagation of viruses in these networks. At the same time, we use the MAC mechanism to avoid channel disputes in wireless sensor networks in the process of virus propagation. In the wireless sensor network, the MAC mechanism can reasonably allocate the right to use the channel, reducing and avoiding channel collision and channel interference. Meanwhile, the role of the MAC mechanism will also have an impact on the network virus propagation process, which increases the difficulty and complexity of virus propagation research to some extent. Energy consumption in the process of virus propagation is also analyzed in this paper.

Virus Propagation Model for Wireless Sensor Networks with MAC Mechanism
In this part, according to the Waxman algorithm and the Warshall algorithm, we build a wireless sensor network topology model with a limited communication range of nodes. On this basis, we develop an SIR virus propagation model. Because WSNs have a wireless access layer, we consider the influence of the MAC mechanism in every step of virus propagation from infected nodes to neighboring nodes.

Wireless Sensor Network Structure Model.
Wireless sensor networks are generated on the Waxman algorithm [30] in our study, which is a typical random network topology generation algorithm. Considering the limited communication capacity of sensor nodes, when setting up the network environment, the probability of the existence of links between two nodes within the communication radius R c is P e , as in where the parameters of equation (1) are shown in Table 1. e network topology is generated by adding relationships between all pairs of nodes in the network with probability P e . However, since the Waxman algorithm cannot guarantee the network connectivity, the Warshall algorithm [31] is needed to verify the connectivity of network.

SIR Virus Propagation Model with MAC Mechanism.
e SIR propagation model is used to study the dynamics of virus propagation in wireless sensor networks under the MAC mechanism. e interaction between data transmission and virus propagation in wireless sensor networks is also considered in this model. It is assumed that N nodes are uniformly and randomly distributed in the wireless sensor network, each node has a limited communication radius R c , and at each moment, n nodes in the wireless sensor network have data sending requests, and these n nodes are called active nodes. According to the SIR model, each node in the wireless sensor network has three different states; namely, the susceptible state (S-state) node can be infected easily by viruses, the infectious state (I-state) node can infect S-state node, and the removed state (R-state) node is invalid after virus infection. In these three states, only the node in the Rstate could not work correctly; that is, it could not send data or transmit the viruses. At time t, the number of S-state, Istate, and R-state nodes are denoted as S(t), I(t), and R(t), respectively, and N � S(t) + I(t) + R(t) at each time step t. At the beginning moment of virus propagation, an arbitrary node is set as the infected node and begins to transmit the viruses outwards.
In wireless sensor networks, virus propagation between nodes or other conventional data transmission is constrained by the MAC mechanism. With the MAC mechanism, a node needs to listen to the channel before data transmission or virus propagation. It is only allowed to transmit data or virus outward when the channel is idle. Two dynamic processes of data transmission and virus propagation are performed simultaneously in wireless sensor networks. To describe the problem more clearly and concisely, we regard the listen/sleep mechanism in the MAC mechanism of sensor networks as periodic and discretize time [32][33][34]. e specific process is as follows: during the monitoring (listening) period of each unit time t, the active node publishes a data reception request in the broadcast form to all working nodes in the R c communication range. To meet the requirements of the MAC mechanism, the monitor channel is idle. And the data sent by the active node is received by an idle node. An active node cannot send data to its neighbor node if this neighbor is busy. en, this active node needs to wait unit time to re-enable channel monitoring. After the monitoring period ends, the working nodes in the network will enter the dormant period, while the nodes in the dormant period cannot work. However, since the active node issues the receiving request in a broadcast form, the information-receiving channels of all nodes (except the data receiving node) within the communication range are overwhelmed and interfered by the receiving request of the active node, and the active node can no longer receive communication requests from other nodes except the active node. Such a node with limited receiving function is called an interfered node, and the viruses cannot infect it.
Assume the active node to send very little data that is a virus. After the active node sends the virus data, each I node infects the S node whose normal operation and the channel is idle in the communication range R c with the infection probability λ. And at each unit time step t, each I-state node turns to an R-state node that cannot normally work with probability c. Without loss of generality, let c � 1 [35].

Model eory Analysis.
It is assumed that N nodes are uniformly and randomly distributed in the 2-dimensional square area X 2 of the wireless sensor network with length X. Initially, most of the nodes are S-state nodes, and very few nodes are I-state nodes. e average node degree adjustment parameter in the network is β, and the proportion of active nodes that need to send data is δ, where δ � (N a /N), where N a is the number of active nodes, and the size of the area where the signal is disturbed is (NaπR 2 c /X 2 ). In a unit time, an arbitrary node v of an I-state infects a normal working Sstate node in the idle state within the communication radius R c of the node v with probability λ. en, the node v is transformed into the R-state node with a probability of c � 1. e listen/sleep duty cycle of the MAC mechanism is τ. Based on the above description, we propose a relatively reasonable and applicable virus propagation model. is model is as follows: And at each time step t, S(t), I(t), and R(t) satisfy the following equation: , ρ � (c/λ), and φ is the inhibitor of virus propagation, that is, the inhibition of viral transmission by the number of active nodes. Since the proportion of active nodes in the network will affect the inhibitory effect of the MAC mechanism, the more active nodes there are, the more obvious the inhibitory effect of the MAC mechanism will be, and the fewer nodes the viruses can infect. erefore, we regard the relationship between the number of active nodes and virus propagation rate as inversely proportional, and regard constant φ as a constraint constant. According to equations (2)-(4), the following equations can be obtained: Assume that the initial S-state node number is S(0) � S 0 and the initial R-state node number is R(0) � 0. en, we have the following results about S(t) and I(t) from equations (6) and (7):

Basic Regeneration Number
is monotonically decreasing and has a lower bound, the limit of exists. It can be known from equations (2), (3), (6) that when S(t) � (ρ/A), I(t) reaches a maximum value. From equation (6), when the number of susceptible nodes S(0) � S 0 > (ρ/A) at the beginning moment, with the increase of time, the number of infected nodes I(t) will first increase to the maximum, then gradually decrease, and eventually die. is phenomenon shows that as long as S 0 > (ρ/A), that is, S 0 Aλ(1/c) > 1, the viruses will spread in wireless sensor When R 0 > 1, the viruses can spread exponentially on a large scale, and when R 0 < 1, the viruses will not spread, and the number of infected nodes will decrease monotonically to zero. e spreading of viruses meets a critical state if R 0 � 1. In this critical moment, viruses may spread only in a small area and die locally. To prevent the viruses from spreading in wireless sensor networks, reduce R 0 to less than 1 to achieve the purpose of hindering the spread of the viruses. From equation (10) and the definition of A, we can know that the virus infection ability λ can be reduced or the disease period (1/c) can be reduced through virus killing and other means. In addition, R 0 can be reduced by reducing the MAC mechanism listen/sleep duty cycle τ, node communication radius R c , and network average node adjustment parameters β.

Stability Analysis.
From the perspective of virus propagation dynamics, the behavior of removed state (R) nodes in the mathematical model of virus propagation is independent of susceptible state (S) nodes and infected state (I) nodes. erefore, from equations (2) and (3), the SIR model has an infinite number of non-negative equilibrium points S � S 0 , I � I 0 � 0, where S 0 is any non-negative real number, and because these equilibrium points satisfy I � I 0 � 0, it is also called disease-free equilibrium. When R 0 ≤ 1, the virus cannot spread out or die in a local area; therefore, the disease-free equilibrium point (S 0 , 0) is stable. But on the contrary, if R 0 > 1, the disease-free equilibrium point (S 0 , 0) is unstable. e proof is as follows: Defining function (11), Find the partial derivatives of S and I for the formulas f 1 and f 2 , respectively, e linear parts of the Taylor expansions in equations (11) and (12) at S � S 0 and I � I 0 � 0 are So, the linear equation at S � S 0 and I � I 0 � 0 is e matrix of its linear equation is e characteristic equation of equation (16) is e eigenvalues of equation (17) are λ E1 � 0 and λ E2 � λAS 0 − c. From R 0 > 1, know λAS 0 > c, λ E2 > 0 and from the theory of ordinary differential equations, this disease-free equilibrium point (S 0 , 0) is unstable.

Simulation
In the simulation experiment using MATLAB, we randomly distribute N � 1000 nodes in an X 2 � 100 × 100 square area and set the ratio between the number of long links and the number of short links in the network topology with α � 0.87. We set all nodes as S-state nodes at the beginning and then randomly set a node as infected I-state to spread the viruses. us, at t � 0, we have S(0) � 999, I(0) � 1, R(0) � 0. As shown in Figure 1, at each time step, an I-state node infects each of the idle S-state neighbor nodes in its communication range with probability λ; then, the I-state node immediately transforms to the R-state with probability c � 1. e newly infected node will turn to I-state in the next time step.
With the MAC mechanism, the energy consumption during the spread of virus in wireless sensor networks is considered. In a typical wireless sensor network, the energy consumed by data transmission and reception is much greater than that of other stages such as information processing, storage, and sleep [36,37]. erefore, we assume the initial energy of each node is E 0 , and the remaining energy of Security and Communication Networks the node i at time step t is E i (t), and the energy consumed by the node to transmit or receive a packet of data is en, according to the simulation results, we analyze the virus propagation process with node communication radius R c , average node degree 〈k〉, virus infection probability λ, number of active nodes N a , etc. For each influencing parameter, the result is based on an average of 50 simulations independently. If there is no data sending request in the network, we regard the number of active nodes as 0, and the MAC mechanism is considered as not working in this situation. Otherwise, it will be regarded as the case that the MAC mechanism works. Figure 2 shows the effect of the number of active nodes N a on virus propagation under different infection probabilities λ. In this simulation, in addition to the default value, other parameters are set as follows: node communication radius R c � 7, average node degree <k > � 0, active node number N a � 0, 5, 10, 15, 20, respectively, network average degree adjustment parameter β � 0.7, the listen/sleep duty cycle of the MAC mechanism τ � 0.6. It can be observed from Figure 2 that the infection ability of the viruses increases with the increase of infection probability λ. But the more active nodes in the network, the fewer nodes the viruses can infect with the same infection rate λ. Figure 2 also shows that when there are many active nodes, even if the infection probability λ is large, the viruses cannot spread to the entire network. rough the analysis of the experimental results, it is found that there are two reasons for this phenomenon:

Effect of Active Nodes Number in Virus Propagation.
Firstly, the influence of a number of active nodes: the more active nodes, the fewer nodes the viruses infect, and the active nodes will affect the speed of network failure. e more active nodes, the faster the network failure rate, the faster the network failure, and the more nodes retained to work, so that even if the infection probability is large, the viruses cannot spread to the entire network.
Secondly, the influence of the infection probability: the higher the infection probability is, the stronger the ability of the viruses is, and the more nodes are infected.  Figure 3 reflects that, in the same network environment, the number of active nodes can directly affect the scale of infected nodes, which is roughly inversely proportional. e more active nodes, the slower the virus infects the node and the fewer infected nodes. Figure 4 shows the effect of listen/sleep duty cycle τ on virus propagation under different infection probabilities λ. In this simulation, in addition to the default value, other parameters are set as follows: node communication radius R c � 7, average node degree <k > � 10, active node number N a � 20, respectively, network average degree adjustment parameter β � 0.7, the listen/sleep duty cycle of the MAC mechanism τ � 0, 0.2, 0.4, 0.6, 0.8, 1. e curve change in the figure intuitively reflects that the listen/sleep duty cycle on the MAC mechanism is proportional to the size of the infected node. e larger the listen/sleep duty cycle is, the more nodes infected by the viruses, and the smaller the listen/sleep duty cycle is, the fewer nodes. e listen/sleep duty cycle represents the ratio of the listening period to the length of the sleeping period within a period of time. When the listen/ sleep duty cycle approaches zero, it indicates that the network is always in a dormant state, so the viruses cannot spread on the network in this state. e τ � 0 curve in Figure 4 confirms this statement. eoretically, to prevent the viruses from spreading in the network, it is better to set the listen/sleep duty cycle as short as possible. But this is not the case. e listen/sleep duty cycle of the MAC mechanism not only affects the virus propagation process but also affects the flow of normal data, causing latency issues. For networks with higher real-time requirements, a lower listen/sleep duty cycle is fatal. erefore, considering the delay and energy-saving issues, the listen/sleep duty cycle used in this study is 0.6.

Virus Propagation with MAC Mechanism under Different
Values of Infection Probability. e dynamics of virus propagation under different values of infection probabilities λ considering the impact of the MAC mechanism are shown in Figure 5. Node communication radius R c � 7, average node degree <k> � 10, virus infection probability λ � 0.4, 0.8, active node number N a � 0, 20, network average degree adjustment parameter β � 0.7, and the listen/sleep duty cycle of the MAC mechanism τ � 0.6. e probability of virus infection indicates the infectivity of the viruses. e stronger the infectivity, the more nodes the viruses infect. From the comparison in Figure 5, the higher the infection probability of the same MAC scheme is, the faster the virus propagation speed is, and the larger the infection scale is after it tends to be stable. We also find that using the MAC mechanism can well suppress the speed of network virus propagation and the scale of infection.
Furthermore, the smaller the probability of viral infection, the more obvious the inhibition of viral transmission by MAC mechanism, the slower the viruses spread, and the fewer infected nodes. It indicates that the probability of virus infection or MAC mechanism will have an impact on the spread of the viruses, but the combined effect of the two will be better. What is more, the smaller the probability of viral infection, the more obvious the inhibition of viral transmission by MAC mechanism, the slower the viruses spread, and the fewer infected nodes. It indicates that the probability of virus infection or MAC mechanism will have an impact on the spread of the viruses, but the combined effect of the two will be better. Figure 6 shows the influence of node averaging degree 〈k〉 on virus propagation speed. e node communication radius R c � 7, the average node degree <k> � 7, 10, 13, the virus infection probability λ � 0.6, the number of active nodes N a � 0, 20, the listen/sleep duty cycle of the MAC mechanism τ � 0.6, and the regulating parameters of network average degree β � 0.53, 0.7, 0.9, respectively. It can be observed from Figure 6 that, without considering the MAC mechanism, the greater the average node degree, the faster the viruses spread. Eventually, the viruses infect the entire network. Considering the MAC mechanism, the speed of virus propagation increases with the average node degree, but in the end, it can only infect some nodes, and the number of virus-infected nodes increases as the average node degree increases. rough comprehensive analysis, it is found that the average node degree would affect the speed and scale of virus propagation. At the same time, the MAC mechanism will hinder the propagating speed of viruses and will also inhibit the influence of the average node degree on virus propagation. e effect of communication radius R c on virus propagation is shown in Figure 7. e research in this part mainly  Figure 7 that, under the same communication radius, the influence of the presence or absence of the MAC mechanism on virus propagation is the opposite. Without considering the impact of the MAC mechanism, the larger the communication radius of the node, the faster the virus propagation will be, and the viruses will eventually infect the whole network. However, under the influence of the MAC mechanism, the larger the node communication radius, the slower the virus propagation speed, and the fewer infected nodes. e experimental results show that whether the MAC mechanism works or not will affect the impact of communication radius on virus propagation. As can be seen from the above, if you want to suppress the spread of network virus better, you can use the MAC mechanism and the network average to work together. Figure 8 shows the energy consumption in virus propagation under different infection probabilities λ. In this simulation, the parameters are set as follows: R c � 7, <k> � 10, β � 0.7, τ � 0.6, and N a � 0, 5, 10, 15, 20, respectively. Figure 8 shows the energy consumption in virus propagation has a peak value as λ increases. When 0 < λ < λ peak , with the increasing of λ, the scale of virus infection in the network increases, so energy consumption also increases. On the contrary, when λ > λ peak , as λ increases, the energy consumption decreases slowly. e interaction combined with the infection scale of network and spreading speed of virus leads to the existence of peak value of energy consumption. We assume that, when λ � λ peak (N a � 0,λ peak � 0.32;N a � 5,λ peak � 0.36;N a � 10, λ peak � 0.42;N a � 15,λ peak � 0.6; N a � 20,λ peak � 0.75), the energy consumption reaches its largest value. ere are two factors influencing the energy consumption of virus propagation: the infection scale and the speed of virus propagation. When the virus can spread out in the network, the larger infection scale will cause the faster propagation speed. A larger infection scale consumes more energy. But the faster propagation speed  Security and Communication Networks reduces the time for the virus to spread out and reduces the energy consumption relatively. erefore, peak value of energy consumption is the result of the combined effect of the infection scale and propagation speed.

Analysis of Results
In the context of the wireless sensor networks, this paper established a random network topology model based on the characteristics of limited node communication radius and wireless access MAC layer. It improved the classical SIR virus propagation model on this basis, to study the virus propagation dynamics in the network environment and find the characteristics of virus propagation. We mainly studied the characteristics of virus propagation process with the number of active nodes N a , the listen/sleep duty cycle τ, the virus infection probability λ, the average node degree 〈k〉, the communication radius of nodes R c , etc. And we verified the conclusion that the MAC mechanism affects virus propagation by comparing the research results with or without the MAC mechanism. Compared with the experimental results, it is found that wireless access to the MAC mechanism does affect the process of virus propagation and has an inhibitory effect. Moreover, it can be known from the propagation model that the listen/sleep duty cycle of the MAC mechanism directly affects the virus suppression effect. e smaller the listen/sleep duty cycle, the smaller the change amount of the infected node per unit moment, and vice versa. e results of the research on the listen/sleep duty cycle also confirm this conclusion. Besides, we also found that factors such as virus infection probability, average node degree, and node communication radius would promote virus propagation. In contrast, the number of active nodes would hinder virus propagation. e probability of virus infection λ and the average node degree 〈k〉 have similar effects on the virus propagation procedure. Increasing the probability of virus infection λ or the average node degree 〈k〉 can accelerate the speed of the virus propagation process and increase the scale of virus infection. e number of active nodes N a will restrain the virus propagation procedure. e more active the node, the larger the range of signal interference, the smaller the virus spread, and the better the suppression effect. e influence of node communication radius R c on virus propagation is more complicated. Without considering the MAC mechanism, the larger the communication radius R c is, the faster the viruses spread, and the more nodes the viruses infect. On the contrary, if the MAC mechanism is considered, the virus propagation process is opposite to the previous situation. Increasing the communication radius R c of nodes can increase the range of signal interference. e larger the range of signal interference, the smaller the range of virus propagation and the fewer nodes infected by viruses. erefore, in wireless sensor networks with the MAC mechanism, the traditional virus propagation models do not consider the impact of the MAC mechanism and cannot be directly applied. Because the MAC mechanism has played a significant inhibitory effect on virus propagation, the MAC mechanism can not only slow down the virus propagation rate but also reduce the number of infected nodes. In terms of energy consumption, when λ � λ peak , energy consumption reaches the peak value. When λ > λ peak , energy consumption reduces with the increasing of λ, because the spread of the virus stops prematurely. is situation is the result of the combined effect of the infection scale and speed of the virus spreading. e results have important reference significance for the study of virus propagation procedure in wireless sensor networks.

Conclusion
Aiming at the characteristics of wireless sensor networks with space constraints and the MAC communication mechanism, we explore the virus propagation process wireless sensor networks by using the SIR model. e analysis of the mathematical model of virus propagation shows that the number of active nodes, the probability of virus infection, the average node degree, the communication radius of the nodes, and the listen/sleep duty cycle of the MAC mechanism will affect the virus propagation in the wireless sensor network. Reasoning and qualitative analysis: the increase in the probability of virus infection and the increase in the average node degree will promote the spread of the viruses; the number of active nodes will suppress the spread of the viruses; the larger the number of active nodes, the slower the viruses spread, and the node communication radius is relatively complicated. Under the MAC mechanism, the increase in the phase of the node communication radius will inhibit the viruses from spreading. Still, the opposite is true without the MAC mechanism. e effect of the MAC mechanism on virus suppression depends on the listen/sleep duty cycle. e smaller the listen/sleep duty cycle, the better the virus propagation suppression effect. With the MAC mechanism in wireless sensor networks, the  traditional virus propagation models cannot be applied directly. In addition, with the change of λ, the peak value of energy consumption in the process of virus propagation appears at a specific infection probability λ value. is situation is the result of the combined effect of the infection scale and speed of the virus spreading. is paper relatively comprehensively and systematically studies the specific influence of various factors of wireless sensor networks on the process of virus propagation. To a certain extent, it can provide corresponding theoretical support for solving the security risks of wireless sensor networks and formulating effective virus immunity mechanism of wireless sensor networks.
Data Availability e simulation data and results used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare no conflicts of interest.