Modeling of Duty-Cycled MAC Protocols for Heterogeneous WSN with Priorities

Wireless Sensor Networks (WSN) have experienced an important revitalization, particularly with the arrival of Internet of Things applications. In a general sense, a WSN can be composed of different classes of nodes, having different characteristics or requirements (heterogeneity). Duty-cycling is a popular technique used in WSN, that allows nodes to sleep and wake up periodically in order to save energy. We believe that the modeling and performance evaluation of heterogeneous WSN with priorities operating in duty-cycling, being of capital importance for their correct design and successful deployment, have not been sufficiently explored. The present work presents a performance evaluation study of a WSN with these features. For a scenario with two classes of nodes composing the network, each with a different channel access priority, an approximate analytical model is developed with a pair of two-dimensional discrete-time Markov chains. Note that the same modeling approach can be used to analyze networks with a larger number of classes. Performance parameters such as average packet delay, throughput and average energy consumption are obtained. Analytical results are validated by simulation, showing accurate results. Furthermore, a new procedure to determine the energy consumption of nodes is proposed that significantly improves the accuracy of previous proposals. We provide quantitative evidence showing that the energy consumption accuracy improvement can be up to two orders of magnitude.

outperforms previous ones in terms of accuracy when results are compared with those obtained by simulation.
The rest of the article is organized as follows. In Section 2, the network scenario is presented, and the model assumptions are defined. The mathematical model of the system is presented in Section 3. The analysis to determine the performance parameters is developed in Section 4. The results and their discussion is presented in Section 5. Finally, the conclusions are presented in Section 6.

PSA-MAC Protocol
As in most MAC protocols operating in DC, in PSA-MAC, the time is divided into cycles of equal duration T, and each cycle consists of an active and sleep period, as in Figure 1. The active period is subdivided in two parts: the sync period of fixed duration T sync , where SYNC packets are exchanged; and the data period, where DATA packets are exchanged. During a sync period, nodes choose a sleep-awake schedule and exchange it with their neighbors using SYNC packets. These packets include the transmitter node address and the start time of their next active period. With this information, nodes coordinate to wake up simultaneously at the beginning of each sync period. SYNC and DATA packets are transmitted using the CSMA/CA contention mechanism in order to access the channel. In CSMA/CA active nodes generate a random backoff time and perform a channel carrier sensing procedure. A node is considered active when it has packets to transmit. If the channel is idle when the backoff timer expires, then nodes transmit a packet using the RTS/CTS/DATA/ACK handshake. When a winning node receives a CTS in response to its previous RTS, it transmits the SYNC or DATA packet and waits for the ACK.
During the data period, nodes transmit DATA packets. Active nodes generate a new backoff time at each data period initiation and perform carrier sensing before accessing the channel. In PSA-MAC, during the data period a node goes to sleep mode until the beginning of the next sync or data period when: (i) it loses the contention (hears a busy medium before its backoff time expires); (ii) it encounters a RTS collision; (iii) after a successful transmission (only one packet per cycle is transmitted).

Network Operation and Assumptions
We consider a heterogeneous WSN with N nodes of different classes, where all nodes listen to each other and send packets to a common sink node, as, for example, in Figure 2. The scenario consists of a single cell cluster, but multiple clusters together may configure a larger network. In this work, the scenario of a single cluster is studied. Two classes of nodes are considered, and we assume that class 1 nodes have medium access priority over class 2 nodes. Other assumptions considered in this study are: (i) the sink node only receives packets, never transmits; (ii) for realistic scenarios, it has been shown that one or two retransmissions are enough to transmit a packet successfully [21]. Then, for simplicity, we consider an infinite retransmissions model, as a simpler modeling alternative to the more complex model of finite retransmissions; (iii) from the MAC perspective, the channel is ideal (error-free); (iv) packets arrive to the buffer (queue) of a node following a renewal process, and the number of packets that arrive in each cycle is characterized by independent and identically distributed random variables.
In the evaluated scenario, as expected, the sink responds to each received data packet with the corresponding CTS and ACK. In some scenarios, the sink might also send data to nodes, either configuration or data packets. However, in most applications, the desired information is typically collected by the sensor nodes and aggregated at the sink before being forwarded upstream. For example, health monitoring applications [26]. As the load of configuration traffic, if present, should be typically small and sporadic, we have not included it in the model. Nevertheless, sink traffic can be included in the network, associating it to one or both of the two considered classes. For scenarios where the traffic offered by the sink to the nodes of a class is similar to the one offered by the rest of nodes of the same class (homogeneous load case), please refer to [21]. There, a single class is considered, the sink is considered as another class member node, and all class member nodes exchange packets among themselves.
The modeling approach can also be extended to scenarios with a non-ideal channel. For example, in [27], a DTMC model is proposed to investigate the impact of channel impairments on the performance of a single class WSN with no priorities, where the packet error probability depends on the packet length. The model in [27] can be readily adapted to a scenario with priorities as the one studied in this paper. Please refer to Section 3.3 for further details.
Each node has a finite buffer with a storage capacity of Q packets that are served according to a FIFO discipline. For simplicity, we assume that the number of packets arriving to a buffer per cycle follows a discrete Poisson distribution of mean λT, where λ is the packet arrival rate, and T is the cycle duration. However, the proposed analytical model is generic enough to support any other distribution. For class 1 nodes, the nodes with the highest channel access priority, we consider low traffic loads, since in realistic application, for instance, emergencies, the high priority information to transmit is small and sporadic. Nerveless, the proposed model supports any load for class 1 nodes.

Assignment of Medium Access Priorities
A way to prioritize the medium access for class 1 nodes over the class 2 nodes is to assure that class 1 devices complete the medium access procedure before class 2 devices. Figure 3 shows the medium access procedure for both classes along time, where the sync period for both classes of nodes has been omitted.  In the proposed WSN operation, the medium access priority is granted to class 1 nodes by following the next access procedure. At the beginning of a cycle, only active class 1 nodes trigger the medium access and contend for medium access among themselves. Active class 2 nodes wake up just after the class 1 contention window (W 1 ) has ended, and if they detect an idle medium, they will proceed to transmit, activating their own contention mechanism. If class 2 nodes detect the medium occupied at that instant, they return to sleep mode and wake up again at the next cycle. We assume that the duration of a packet transmitted by a class 1 node is longer than W 1 .

System Model
The expressions developed in Sections 3 and 4 are equally applicable to both classes of nodes. We use a generic notation to define the model parameters associated with any of the two node classes, unless otherwise specified. For description convenience, one node of each class is selected arbitrarily as reference node, RN 1 and RN 2 .

Access to the Medium
Active nodes generate random backoff times selected from the interval [0, W − 1]. When the RN is active, it transmits a packet successfully if the other contending nodes choose backoff times larger than the one chosen by the RN. The packet transmitted by the RN will collide (fail) when the RN and one or more of the other contending nodes choose the same backoff time, and this backoff time is the smallest of those generated in the current cycle. If the backoff time generated by the RN is not the smallest one, two outcomes are possible: (i) another node is able to transmit successfully; (ii) other nodes will collide when transmitting. Nodes that lose the contention (because they hear a busy medium before their backoff time expires), or find an RTS packet collision, go to sleep mode and remain in that mode until the active period of the next cycle.
For notation simplicity, N denotes the number of nodes of a given class. Considering a cycle where the RN is active, k denotes the number of nodes that are also active in the same cycle, besides the Let P s,k , P s f ,k and P f ,k , be the probabilities that the RN transmits a packet successfully, transmits a packet (successfully or with collision), and transmits with failure (collision), respectively, when the RN contends with other k nodes. Then, Note that P s,k is the probability that the RN chooses a backoff value from the interval [0, W − 1], and the other k nodes choose a larger value. Probabilities P s f ,k and P f ,k can be described in similar terms.
Conditioned on a successful or unsuccessful packet transmission by the RN, when contending with other k nodes, the average backoff times are given by,

System with Two Classes and Priorities
In this subsection, we model the time evolution of the number of packets in the queue of RN 1 and RN 2 , and the number of active nodes in the network, by a pair of 2D-DTMC, one chain for each node class. The state of each node class is represented by the tuple (i, m), where i, i ≤ Q, is the number of packets in the queue of the RN, and m, m ≤ K = N − 1, is the number of active nodes of the corresponding class other than the RN.
Let P (i,m),(j,n) be the transition probability from state (i, m) to state (j, n). The first 2D-DTMC is adapted from [21], and is proposed to describe the time evolution of the state of class 1 nodes. The second 2D-DTMC is taken from [25] and is proposed to describe the time evolution of the state of class 2 nodes. For clarity and paper length limitations, the transition probabilities of both 2D-DTMC are presented in detail in [28].
Note that the representation of the network state is an approximation. For each class, the state of the set of nodes other than the RN is approximated using only the m parameter [21,22]. As it will be justified later, this approximation provides very accurate results.

Solution of the Pair of 2D-DTMC
The solution of each of these 2D-DTMC can be obtained by solving the following system of linear equations, where π = [π(i, k)] is the stationary distribution, P is the transition probability matrix, the elements of which are defined in [28] (the referred technical report includes two tables: Table 1 for class 1 nodes, and Table 2 for class 2 nodes), and e is a column vector of ones. The probability P s that the RN transmits a packet successfully in a random cycle, conditioned on the RN being active in that cycle, is given by, As observed in [28], to determine the stationary distribution, P s is required, i.e., the stationary distribution is a function of P s , π(P s ). By solving the set of Equations (6), π(P s ) can be determined for a given P s . Then, a new P s can be obtained from Equation (7). We follow a fixed-point iteration procedure and denote its solution by π.
To determine the solution of the second 2D-DTMC, the solution of the first 2D-DTMC is required. In particular, one of the parameters of the second 2D-DTMC is the fraction of time (cycles) that the channel remains idle due to the inactivity of the high priority nodes (class 1 nodes), R 1,0 = π 1 (0, 0), where π 1 is the stationary distribution of the first 2D-DTMC.
For a system with a larger number of priorities, the solution of the stationary distribution of any priority class would previously require the solution of stationary distributions of all higher priority classes. Please refer to [28] for additional details.

Performance Parameters
In this section, we define different expressions to determine the throughput, average packet delay and average energy consumption per cycle. The following expressions are applicable to both classes of nodes.

Throughput
The node throughput η is defined as the average number of packets successfully transmitted by a node in a cycle, and it is determined by, In a network of N nodes, the aggregated throughput, Th, expressed in packets per cycle is obtained as,

Average Packet Delay
Let D be the average delay (in cycles) that a packet experiences from its arrival until its successful transmission. Then, D can be determined by applying Little's law, Note that π i is the stationary probability of finding i packets in the queue of the RN, and N av is the average number of packets in the RN queue.

New Improved Method to Determine the Average Energy Consumption
As observed in Figure 1, the active period of a cycle is subdivided into sync and data periods. The energy consumed during the active period represents the most significant contribution to the total energy consumption. In this section, we compute the average energy consumed by the RN in the data period. Note that only the energy consumed by the radio frequency transceiver is considered. The energy consumed by sensor nodes due to events related to specific sensing tasks is dependent on the specific application. Then, as it does not depend on the MAC, it is not included in this study.
Let E tx s , E tx f and E oh , be the average energy consumption per cycle terms, when the RN transmits successfully, it transmits with failure (collision), and when it overhears other node transmissions, respectively. Then, the average energy consumed by the RN per cycle is given by, E tx s is obtained as, π(i, k)P s,k (P tx s,1 + P tx s,2 + P rx s + BT s,k P rx ), P tx s,1 = t RTS P tx , P tx s,2 = t DATA P tx , where t RTS , t DATA , t CTS and t ACK , are the transmission times for the RTS, DATA, CTS and ACK packets, respectively. P tx and P rx are the transmission and reception power levels, and D p is the one-way propagation delay. The term E tx f is determined by, Finally, E oh is obtained by, whereP f ,k is the probability that two or more of the other k nodes differ from the RN chosen with the smallest backoff value and, therefore, smaller than the backoff value chosen by the RN. In this case, the RN will lose the contention, and the other two or more k nodes will transmit with collision. In summary, an active RN overhears the channel when: i) one of the other k nodes transmits successfully (with probability kP s,k ); or ii) two or more of the other k nodes collide (with probabilitŷ P f ,k ). Note that if the RN is not active, it will not listen to the channel, as we assume that the sink only receives and never transmits.
For class 2 nodes, the same expressions are applied to obtain the energy consumed during the active period E d2 . However, an additional term must be added to account for the energy consumed by class 2 nodes to sense the channel when they wake up but they sense a busy channel. We denote this term as E 0 = ts · P rx , where ts is the duration of one time slot.
Let E 1 and E 2 be the average energy consumed by class 1 and class 2 nodes per cycle, respectively. The final expressions to determine the energy consumption for both classes of nodes are given by, where R 1,0 is the stationary probability of finding no active class 1 nodes in a cycle (fraction of cycles where all class 1 nodes are inactive). As E 0 ≈ 0, we approximate E 2 ≈ R 1,0 · E d2 . The proposed model to determine the energy consumed by a node allows to accurately predict the lifetime of a node of any priority class in the network. When nodes start operating with different battery levels, as nodes deplete their batteries, they can be removed from the network, and then a new stationary distribution must be computed.

Performance Evaluation of the Improved Method to Determine Energy Consumption
The new procedure to determine the energy consumed by a node per cycle was described in Subsection 4.3. In this subsection, we highlight its advantage in terms of accuracy improvement, particularly for class 2 nodes, with respect to the energy consumption computation method proposed in [19][20][21][22]25].
As a summary, we will say that previous procedures required the computation of additional intermediate terms (see Section IV.C, from [25]), in addition to the stationary distribution π(i, k). However, the new procedure described by Equations (14) to (20), only requires π(i, k).
As an example, Table 1 shows the relative error of the energy consumption of class 2 nodes computed into two specific scenarios defined in Section 5. To highlight the difference with the previous computation method in [25], we have chosen two operating points where the worst accuracy is obtained. Note that relative values are obtained as |x − y|/y, where x is the value obtained by the corresponding analytical computation procedure, and y is the value obtained by simulation.
As shown, on average, the new computation method considerably outperforms the previous one, by up to two orders of magnitude. In addition, it is more systematic and intuitive than the previous one, as it uses the stationary probability distribution more efficiently in the computation process.

2D-DTMC Model Validation
Results obtained from the proposed 2D-DTMC analytical model are validated by simulation. We have developed a discrete event simulator in C language that implements the physical transmission scheme and describes the time evolution of the sensor network state. At each cycle, each sensor receives packets according to a given discrete distribution. If a sensor has packets in its buffer, it contends with other nodes for channel access, and if it wins, it then transmits a DATA packet according to the described transmission scheme.
Simulation results are completely independent of those obtained by the analytical model. That is, the computation of the performance metrics by simulation does not use the system state representation, nor its stationary distribution, nor the mathematical expressions developed for the analytical model. The simulation results presented later are average values of measurements carried out along 10 8 cycles. We have obtained confidence intervals with a 95 % confidence level. However, as they are very small, for clarity they have been mostly omitted. For illustration purposes and as examples, confidence intervals are drawn for the top curves of Figures 4,[7][8][9] In the following subsections, we show performance results obtained by the analytical model and by simulation. Simulation results are represented with red confidence intervals or red markers. Analytical results are represented with lines, or lines and markers. In many cases, the markers of analytical and simulation results totally overlap, and they are difficult to distinguish. In particular, red markers (simulation results) overlap and hide markers depicted with other colors (analytical results), which are the ones shown in the legends of the corresponding figures. As an example, in Figure 4, the average delay of the successfully transmitted packets is shown for both classes of nodes. Clearly, analytical and simulation results perfectly match, confirming that the analytical model is very accurate.

Scenarios and Parameter Configuration
In this section, the performance of a WSN, such as the one illustrated in Figure 2, is evaluated. We have considered two classes of nodes (1 and 2), with N 1 and N 2 populations. We have studied two scenarios (SC1 and SC2) with different configurations for each class of nodes, in terms of load and population. Configuration parameters are summarized in Table 2 [29]. The performance parameters of interest are: average packet delay, throughput and average energy consumption.
For simplicity, in the evaluation scenario defined in this section, we have considered that nodes have sufficient energy so that the stationary regime is achieved before the battery of any node is depleted. When appropriately configured, the stationary regime is achieved after a small number of cycles. When nodes do not have the same initial energy, nodes that deplete their batteries stop operating, and, for modeling purposes, can be removed from the network. The proposed energy consumption procedure allows to predict with excellent accuracy the lifetime of a node with a given initial energy. Once the population of nodes of each class is readjusted, the model can be solved again until the next node stops operating. Figure 4 shows the average packet delay expressed in cycles, for both classes of nodes in SC1, and for two packet arrival rates for class 1 nodes (λ 1 ).  We denote by D 1 and D 2 the average delay of packets transmitted successfully by nodes of class 1 and class 2, respectively. Observe in Figure 4 that D 1 is constant for the load range studied, as class 1 packets have access priority, and λ 1 and N 1 are both constant. In addition, it takes a very low value as we study realistic scenarios where class 1 nodes generate a small and sporadic load.

Average Packet Delay
However, for nodes of class 2, the packet arrival rate takes values in the range λ 2 ∈ [0.5, 4.5]. Note that the fraction of class 2 packets that collide increases with λ 2 . As the number of retransmissions increase, D 2 also increases. Note also that as class 1 traffic load increases, class 2 nodes perceive the channel as busy for longer periods. Therefore, class 2 nodes take longer to transmit their packets, and their delay increases.
Note that D 1 does not increase when λ 1 increases from 0.5 to 1 packets/s, as for both load values, the queues of class 1 nodes remain almost empty most of the time, i.e., nodes remain idle and access the channel rarely. Then, when a packet arrives, it is transmitted immediately, without neither delay nor collision. Figure 5 shows the evolution of the average delay for class 2 nodes with λ 1 in both scenarios, and with different λ 1 values. Note that for SC1, N 2 = 3N 1 , and for SC2, N 2 = 4N 1 . Curves show that D 2 increases rapidly with λ 2 , until approximately λ 2 = 1. For higher loads, D 2 increases slowly. As expected in SC2, where the number of nodes is larger, D 2 takes values higher than in SC1. When the number of nodes increases, contention also increases, and it takes longer to access the channel. Therefore, packets wait longer in the queue before being transmitted. In addition, more collisions and, hence, more retransmissions occur. Observe also that D 2 increases with λ 1 . This can be explained in the same terms as those used to explain the results of Figure 4.  Figure 6 shows the evolution of the average delay for class 2 nodes with λ 2 with different contention window sizes W 2 in SC1. Results for Figure 6 (and Figure 10, shown later) have been obtained with the following configuration changes: W 1 = 16 and W 2 = {16, 64, 128, 256}. Note that in our model, the priority assignment is not affected by the contention window size, as explained in Section 2.3. The changes for W 1 and W 2 do not modify the defined priority but influence the delay. W 1 = 16 has been chosen because being N 1 small, the collision probability does not significantly change for the larger W 1 values. Recall that the collision probability was defined in Equation (3). In addition, it has been observed that D 1 does not significantly change when W 1 > 16. However, for class 2 nodes, there is a significant impact when the value of W 2 changes. The probability that two or more backoff timer values for class 2 nodes coincide increases as W 2 decreases. Figure 6 clearly shows the effect of W 2 in D 2 . For a fixed load, when W 2 increases, the probability of collision decreases and, therefore, D 2 decreases. Figure 7 shows the throughput per class 2 node for both scenarios. In both scenarios, η 2 reaches the saturation level for loads of approximately λ 2 = 1, observing a relatively constant behavior for higher loads. In addition, note that η 2 is higher in SC1 than in SC2. This is because in SC1 the number of nodes is smaller and, therefore, there is less channel contention.  Figure 8 shows the aggregated throughput for both classes of nodes as a function of N 2 . Results are obtained with the following general configuration changes: N 2 = [5, 30], λ 2 = 1.5 . Observe that Th 2 reaches a maximum for N 2 = 10, and for higher N 2 values, it decreases gradually. Clearly, Th 2 decreases because as N 2 increases, the contention increases, collisions increase, retransmissions increase, and the average packet delay increases. However, Th 1 remains constant as N 1 is kept constant, and class 2 nodes have no influence on the perception that class 1 nodes have of the state of the channel.   Figure 9 shows the average energy consumption per node and per cycle for both classes of nodes, expressed in millijoules (mJ). Note that the energy consumption of class 2 nodes is higher in SC1 than in SC2. This scenario of higher energy consumption corresponds to the scenario where a higher throughput per node is achieved (Figure 7). Larger throughput values imply that more transmissions occur, leading to a higher activity of nodes and, therefore, to a greater energy consumption. Figure 9 also shows that E 1 is lower than E 2 , and constant with λ 2 . This is due to the fact that class 1 nodes have priority over class 2 nodes. For class 2 nodes, the packet arrival rate takes values in the interval λ 2 ∈ [0. 5, 4.5], and the number of nodes in the network is different for each scenario. Observe in Figure 9 an initial linear increase of the energy consumption for class 2 nodes in both scenarios. At approximately λ 2 = 1 packets/s, the saturation load is reached and the activity of nodes, as well as their energy consumption, also reaches its limit.   Figure 10 shows the average energy consumption for class 2 nodes in SC1, when W 1 = 16 and W 2 = {16, 64, 128, 256}. Note that E 2 increases with W 2 . As the contention window W 2 increases, the collision probability decreases, and E 2 increases. With larger window sizes, on average, the carrier sense mechanism remains active longer listening to the channel, the throughput of nodes increases and the energy consumption increases. On the other hand, if W 2 decreases, the energy consumption per node also decreases. However, when W 2 decreases, D 2 increases, as discussed in Figure 6.  As an example, note that the proposed model can be used to appropriately set W 2 . As observed, W 2 = 64 might be a good compromise, as the energy consumption increases moderately when compared to W 2 = 16 (by a factor of two), and the delay is almost halved, as shown in Figure 6. However, by increasing W 2 beyond 64, the delay decreases only slightly, but the energy consumption drastically increases.

Conclusions
We have developed a novel approximate analytical model to evaluate the performance of a wireless sensor network that operates with a synchronous duty-cycle mechanism. The network is composed of different node classes with different traffic requirements and channel access priorities.
As an example, for a scenario with two classes of nodes, each with a different access priority, the analytical model is based on two two-dimensional DTMC, and it is solved for different scenarios.
Multiple performance parameters are obtained such as the average packet delay, throughput and average energy consumption.
The model is quite flexible and can be extended to a number of different scenarios. For example, when more than two priorities are deployed, when the channel is error-prone, when the sink not only receives data packets but also transmits, or when the battery level of nodes is not equal.
A novel procedure has been proposed to determine the average energy consumed by the network nodes. Its most remarkable features are that it is simpler and more systematic than other alternative methods found in literature. In addition, results obtained with the new energy computation procedure are more accurate than those obtained by previous proposals. We provide evidence showing that the accuracy improvement can be between one and two orders of magnitude.
The results of the study show the impact that the incorporation of priorities has on the performance parameters. As expected, for two node classes, the performance of nodes with channel access priority is not affected by the low priority traffic load. In addition, for moderately low loads of high priority traffic, the delay obtained by the high priority packets is negligible. The obtained results confirm the suitability of the proposed model for the performance evaluation of WSN deployed in emergency scenarios.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: