Communication requirements of smart grid technologies.

## Abstract

Creating cyber-physical systems (CPSs) based on wireless sensor and actuator networks (WSANs) has great potential to improve the performance of Smart Grid. In addition, IEEE802.15.4 has widely been regarded as an appropriate standard for WSANs, due to some striking and unique features. WSANs require provisioning strict quality of service (QoS) due to noisy harsh environments in Smart Grid applications. Although analytical models have been studied in the literature, they have not provided a full-fledged model for Smart Grid. In this paper, we have added a MAC-level buffer, and a novel Markov chain model has been also proposed. By comparison with previous studies, retransmission confines, acknowledgment, packet length variation, saturated traffic, and degenerate distribution of packet generation are accounted for. The algorithm has been experimentally implemented and appraised on a platform with self-designed WSAN. The analytical model predicts well our exhaustive experiments. Further, Monte Carlo simulations validate mathematical results.

### Keywords

- smart grid
- wireless sensor and actuator networks
- IEEE 802.15.4
- Markov chain
- periodic

## 1. Introduction

Cyber-physical systems (CPSs) are generally defined as integration of computing and communications technology in order to take control of physical elements [1]. Smart Grid, as an example of a CPS, is a modern power infrastructure to enhance efficiency, reliability, and security [2] along with stable renewable energy production and alternative energy resources. Smart Grid has been designed and implemented through modern communication technologies and automatic control systems [3, 4, 5]. Establishing such a complex and elaborate system needs the contribution of sundry technologies. Moreover, everyday life and power networks are inextricably intertwined nowadays. In that every failure, even small, imposes skyrocketing economic and human costs. Therefore, designing a stable and reliable system appears inevitable.

Recently, wireless sensor and actuator network (WSAN) applications have entered a new era of CPS developments like cyber transport system (CTS) and specifically Smart Grid as our research focus [6]. There are various factors which conspicuously impact upon the performance of Smart Grid. Among all the factors, online monitoring and reacting have great capabilities in improving reliability which can be provided by WSANs in every part of Smart Grid assemblage, from generation to consumption [7, 8].

Due to WSANs’ low costs, they can specifically affect the distributed generation and the production of renewable energy in generation part. Moreover, posts, overhead, and underground transmission lines are better to be online monitored through WSANs in transmission and distribution part. Eventually, WSANs can be employed in consumption part for substation and residential distribution networks, especially smart meters (AMI) [9] which are shown in Figure 1. Although WSANs provide numerous advantages, they encounter some challenges in issues such as real-time data delivery and high-rate data generation, since they have not been specifically designed for Smart Grid.

As often as not, WSAN applications utilize IEEE802.15.4 which take advantage of a low-power link leading to a low data rate transmission (250 kb/s) [10].

Impulsive and robust noises of a power system environment and IEEE802.15.4 standard’s intrinsic challenges force us to provide a minimum quality of service (QoS) level to control and monitor applications of Smart Grid [11].

The delay and reliability of WSAN are two prominent parameters in Smart Grid. In order to reach a required QoS level through optimizing network parameters, an elaborate analytical model is essential which is substantially similar to the reality. Table 1 depicts a summary of the most important applications in Smart Grid and their QoS levels in terms of data rate, latency, and reliability [2, 12]. As the table shows, in contrast to the reliabilities, the range of delays are relatively high.

Reliability | Latency | Bandwidth (Kbps) | Application |
---|---|---|---|

9–99.99% | 2–15 s | 10–100 | AMIa |

99–99.99% | 500 ms–several min | 14–100 | Demand response |

99–99.99% | 20 ms–15 s | 9.6–56 | Distribution energy Resources and storage |

99–99.999% | 100 ms–2 s | 9.6–100 | Distribution grid management |

99–99.99% | 2 sec–5 min | 9.6–56, 100 is a good target | Electric Transportation |

99–99.99% | 2–15 s | 10–100 | AMI Demand response |

In order to describe the performance of WSANs, several analytical models are introduced in the literature. Some of these models are complicated enough not to be able to be implemented. On the other hand, some others suffer from their low precision due to simplifying and ignoring some parameters such as retransmission and buffer.

Most significantly, a vast majority of the models reach a consensus on using Poisson traffic pattern as the distribution of network input traffic [13, 14, 15, 16, 17]. However, delving further into the issue reveals that applications like remote monitoring and Smart Grid generate data with deterministic distribution. In other words, in these applications, each node produces data in a periodic pattern. To illustrate the concept, consider an AMI connected in a consumer side for monitoring and controlling. Based on AMI type and its protocol, the node sends data to the control center every second or minute which this fact shows that AMI data generation is periodic [18, 19, 20, 21, 22, 23].

The main contribution of this paper is designing a novel analytical model for IEEE802.15.4 standard. The proposed model is specifically appropriate for applications in which the data is periodically generated such as in industry applications and Smart Grid. In these applications, on the one hand, packets are being produced based on a certain periodic time pattern. On the other hand, service time is always a random variable with general distribution. Therefore, service time might temporarily exceed the period time which, as an inevitable consequence, some packets might encounter a busy channel and be dropped. We solve this problem by proposing our MAC-level queue. We demonstrate that the proposed MAC-level queue not only increases the throughput, but also the direct connection between the generation (sensors) and communication packet systems is eliminated which makes the system far more stable.

Moreover, in order to enhance the proposed model, we have employed retransmission scheme, variable packet length, and saturated traffic condition.

### 1.1 Cybersecurity

As stated by the Electric Power Research Institute (EPRI), one of the most challenges facing Smart Grid deployment is related to cyber security, and due to the increasing potential of cyberattacks and incidents against this critical sector, it becomes more and more interconnected. A large part of research of many organizations working on the development of Smart Grid such as NIST, NERC-CIP, ISA, IEEE 1402, and NIPP are devoted to security programs. In this paper we suggested a well-known standard, IEEE802.15.4, which the wireless link will be secured in different layers. For example, regarding secure communications, the MAC sublayer offers facilities which can be harnessed by upper layers to achieve the desired level of security. Higher-layer processes may specify keys to perform symmetric cryptography to protect the payload and restrict it to nodes or just a point-to-point link; these nodes can be specified in access control lists. Furthermore, MAC computes freshness checks between successive receptions to ensure that presumably old frames, or data which is no longer considered valid, do not transcend to higher layers. In addition, there is another insecure MAC mode, which allows access control lists merely as a means to decide on the acceptance of frames according to their (presumed) source.

The rest of the paper is organized as follows. In Section 2, we summarize related work. Section 3 lists the main contributions of the paper and their relation with literature. In this section we proposed an extended Markov. Reliability is analyzed accurately in Section 4. In addition, an accurate analysis of packet service time and end-to-end delay is investigated in Section 5. Numerical and simulation results are presented in Section 6. In this section we validate our analysis by experimental results and Monte Carlo simulations. Finally, Section 7 concludes the paper.

## 2. Related works

The performance of the MAC sublayer in IEEE802.15.4 standard has been evaluated in the literature. The crowd of earlier investigations was based upon MAC sublayer simulation. Lu et al., [24] and Zheng and Lee [25] performed their research based upon simulation.

Gradually, analytical models emerged in this research area where Cao et al., [26] presented an analytical model which was only able to calculate the throughput. Some other models were only able to calculate the energy like [27]. Furthermore, with the passage of time, Markov chain analytical models were proposed, the majority of which are based on [28]‘s results.

It should be also pointed out that Bianchi’s model [28] was not proper for IEEE802.15.4 standard due to the different functionalities of CSMA/CA mechanism in IEEE 802.11 and IEEE802.15.4 standards.

In [14], although the authors presented an analytical Markov model to evaluate MAC sublayer in the presence of uplink and downlink saturated traffic, the model suffers from the lack of retransmission.

In 2009, despite Yung’s efforts to consider retransmission in their proposed model, packet length and acknowledgment were ignored.

In more developed models, Faridi et al., [29] employed retransmission, packet length, and acknowledgment in their advanced model.

In [30], a Markov model is provided to evaluate MAC sublayer and calculate the delay, energy, and throughput which suffers from some drawbacks. Not only did they assume unsaturated data, but they also considered predetermined length for the idle state. In our work, we demonstrate that the duration of the idle states depends on the instantaneous network conditions which might obviously change by passing of time.

Owing to this point, we have considered a variable duration of idle states in our proposed model to deal with the changes in network condition.

In [31], the authors used a model focused on CAP (contention access period), to calculate the throughput and energy and evaluate the effects of a finite length buffer on network performance.

In spite of some drawbacks such as the lack of any queues and some problems in the modeling of the idle states, Park [16, 32] developed the model proposed in [14] through adding retransmission in several investigations. In effect, in Park’s model, before passing the whole period of idle states’ duration, no node is allowed to leave the idle state, when a new packet is generated. In addition, Park [32] used a backoff with duration of 305 μs instead of the 320 μs, which leads to inaccuracy in his experimental tests. In our experiment, a 1 MHz hardware timer is utilized, to enhance timer resolution up to 1 μs and applying 320 μs to aUnitBackoffPeriod.

In [33], the authors provided different services in Smart Grid by introducing of delay-responsive cross layer (DRX) and also prioritizing input data. DRX classifies information into two categories in the application layer. Potential delay is calculated for every input packet regarding the network history. Then, the best decision was taken at the MAC sublayer to achieve minimum delay to send the packet.

## 3. The analytical model

In this section, an accurate analytical model is proposed for industrial applications as well as Smart Grids.

IEEE802.15.4 specifies physical and MAC layers, a low-rate and low-energy consumption solution [10]. This standard provides two channel access types: slotted CSMA/CA and unslotted CSMA/CA [34, 35]. Further information concerning the standard for enthusiastic readers is in [36, 37, 38].

In order not to get involved in useless elaborate calculations, we consider a star topology with a PAN coordinator, N nodes, and the slotted beacon-enabled CSMA/CA mechanism. Acknowledgment is enabled, and a MAC sublayer buffer has also been designed. The input traffic can be saturated, but its distribution is deterministic. We also assume that the arrival rates for all nodes are the same, and nodes start sensing the medium independently. Table 2 shows the summary of notations we use in our equations and diagrams.

Symbol | Definition |
---|---|

b_{i,j,k} | State probability |

W_{i} | Maximum number of random backoffs in stage i |

m | MacMaxCSMABackoffs |

m_{0} | MacMinBE |

n | MacMaxFrameRetries |

α | Probability that channel is busy in CCA1 |

β | Probability that channel is busy in CCA2 |

τ | Probability of starting CCA1 |

L_{p} | Length of data packet |

L_{s} | Duration of successful transmission |

L_{c} | Duration of failure transmission due to collision |

L_{ack} | Duration of acknowledgment packet |

L_{w,ack} | Acknowledgment waiting time |

L_{m,ack} | Acknowledgment maximum waiting time (ACK time out) |

P_{c} | Probability of collision |

λ | Packet arrival rate at the MAC sublayer |

ρ | Applied load to the queue |

Average service time for uplink data block | |

Average service time for backoff stage | |

Average service time of carrier sensing | |

W | Packet waiting time in the queue |

W_{0} | The mean remaining service time |

Q | Number of packet in the queue |

### 3.1 Deterministic traffic model

In this section, we present a novel model inspired by the Park’s model in [16]. There are several deficiencies in Park’s model where the author has not considered any buffers; consequently, it was not an accurate and appropriate model for saturated networks. Another problem is that a node remained in idle states for a definite period of L_{0}, even if a new packet is ready for transmission. Despite of a solution proposed in [33], it is not thorough enough to solve the problem precisely. By modifying the queue as well as idle states and obviating the aforementioned downsides, we have accomplished a perfect model, namely, deterministic traffic model (DTM), illustrated in Figure 2.

DTM provides two main blocks: transmission and waiting blocks. Packets can experience success or failure in the transmission block. Failure of packets occurs on the account of channel access failure or lack of receiving acknowledgment. The possibility of every event depends on various parameters, such as the number of nodes in the network, packet length, data generation time period, and MAC parameters.

In our proposed model, waiting block, including idle and queue states, has been added to resolve the weak points of the previous models.

As mentioned before, a wide range of models has been designed based on Poisson traffic distribution. While in monitoring applications like Smart Grid, data are generated in a deterministic manner, persuading us to develop DTM.

#### 3.1.1 Waiting block

In the proposed waiting block, idle states consist of variable number of states. The number of the states is determined by the service time, data generation period, and the previous status of buffer. The details of this model come under scrutiny in the following. The queue system is modeled on the D/G/1 FIFO queue. In Kendall notation, D/G/1 FIFO denotes that data packets are generated through a deterministic distribution, while the service time distribution is general [39, 40].

Monte Carlo algorithm and experimental results demonstrate that the service time distribution consists in the MAC parameters such as *MacMinBE*, *MacMaxCSMABackoffs*, and *MacMaxFrameRetries*, *Lp* and *TP*. Changing these parameters effects a change in the shape of service time distribution, in a way that the resulting distribution is similar to none of common probability distributions. Therefore, to be more precise and albeit complicated, general distribution is considered for service time.

In order to derivate waiting block equations such as the idle mode probabilities and waiting time in the queue, we consider a scenario illustrated in Figure 3. Assume a periodic sequence of arriving packets with C_{n} notation. Its probability density function (pdf) is simple impulsive (with the x-intercept = the time period (*Tp*) and the y-intercept = 1).

*un* is a (key) random variable, defined as

In a stable network, the expectation value of *un* needs to be negative. Also consider *Wn* as waiting time:

The term *wn + un* is the sum of unfinished work (*wn*) found by *Cn* plus the service time (*Tservice,n*) less than *Tp*. The negative value of this term represents that *Tp* has elapsed since the arrival of *Cn* and the node must enter idle mode by the time *Cn + 1* arrives.

We may write Eq. (2) as

So as to clarify the subject matter, the time diagram for the scenario is illustrated in Figure 3. Six packets are generated in determined intervals, and each one takes a different service time to be transmitted. The first packet’s service time is less than the time period. But it is more for the second. So, before the second packet departs from its node, the third packet is generated and enters the queue directly. Though the third packet’s service time is smaller than *Tp*, the fourth packet’s waiting time is not zero because of the high second packet’s unfinished work (*w2*) or

This may affect several subsequent packets when *w* = 0 for a packet. We define W(y) as cumulative distribution function (CDF) for *wn*:

Before proceeding with the theory, to calculate *W(y)*, *Cn (u)* is defined as the CDF for random variable *un*:

In which *B(x)* and *δ(t-Tp)* are the distributions of service time and time period, respectively.

Combining Eqs. (2), (4), and (5), we have Lindley’s integral Equation [41] which is seen to be a Wiener-Hopf-type integral Equation [42]:

The node must go to idle mode if waiting time equals zero, as illustrated in Figure 2:

And the probability of existing at least one packet in the queue is

The mean queue length

And the mean number of packets in the buffer

In which

As regards the next packet’s arrival time is specified, the time that nodes spend on idle mode is conspicuous. As a result, idle mode constitutes several states in DTM. The number of idle states (i), which represents maximum idle mode’s waiting time, is obtained from minimum service time in transmission block:

The minimum service time and its probability are

Waiting time in idle mode for the next packet will decline if the service time for the current packet rises, until service time and time period become equal. Thus, it is required to derivate PDF of *un* which is obtained by Eq. (5):

The smallest time unit in the DTM is equal to *aUnitBackoffPeriod*, but the packet generation period can take continuous values which may not be divisible by *aUnitBackoffPeriod*; consequently *cn(u)*:

There is always minor inaccuracy imposed to calculation, with a maximum value of approximately aUnitBackoffPeriod. ξ represents the error in Figure 3. Accordingly, the probability of entering idle mode is as follows:

The maximum time that a node remains in idle mode occurs when the packet does not enter the queue and it is transmitted in minimum possible time (minimum service time) as well:

The expected number of idle states is

And idle states probabilities are

And sum of idle states probabilities is

Furthermore, there is a MAC-level buffer in waiting block that has not been considered in [16], which is completely separated from the idle mode. If a node generates a packet and also has a packet in transmission block, the new packet is directed toward the buffer until its turn. In other words, when service time becomes far more than the time period, the queue starts to fill. The Markov chain model for a FIFO queue buffer is illustrated in Figure 4.

According to Figure 4

The total probability of queue states is

According to Eq. (23) and (25), the total probability of waiting block is

#### 3.1.2 Transmission block

The waiting block’s probabilities were described in the previous section, and we depict the transmission block details in the following. In this section, some modifications to Park’s model [16] are provided. The transmission block accounts for a three-dimensional Markov chain using three stochastic processes, including S(t), backoff stage; *C(t)*, the state of backoff counter; and *r(t)*, the state of retransmission counter. These states are linked to BE, NB, and RT in MAC parameter in IEEE802.15.4 standard, respectively.

The stationary probability of the Markov chain can be written as

In which *iϵ(−2,m)*, *kϵ(−1,max{Wi-1,Ls-1,Lc-1})*, and *jϵ(0,n)*. Figure 5 presents Markov chain model for the transmission block. As shown in the figure, the number of retransmissions is considered to have finite values, giving rise to the packet drop. Packets are discarded due to two events:

Channel access failure, working out when one of CCAs within the (m + 1)th backoff fails.

Lack of receiving acknowledgment (ACK), turning out if collision occurs after n + 1 attempts.

Transmission block features three major parts:

State notations from (*i, Wm-1, j*) to (*i, W0-1, j*) denote backoff states. The states (*i, 0, j*) and (*i, -1, j*) are connected to the first and second clear channel assessment (CCA), respectively. States (*−1, k, j*) and (*−2, k, j*) correspond to successful and unsuccessful (due to lack of ACK) transmission, respectively. So as to appraise the performance of the network, *τ*, *Pc*, *α*, and *β* are derived as follows. Interested readers are referred to [16] for more details.

The probability that a device attempts to CCA1 is

where *x = α + (1-α)β* and *y = Pc(1-xm + 1)*.

τ depends on *α*, *β*, and *Pc*. The term *Pc* is the probability that at least one of the *N-1* remaining nodes transmits a packet when the channel is occupied:

In which *N* is the number of nodes in the network.

α represents the probability that a node senses the channel and finds it busy in CCA1, (due to data and ACK transmission of other nodes or noise):

When the channel is free in CCA1, it can be busy in CCA2 with the probability of *β*:

In this model

*Ls* and *Lc* is the successful transmission time and NO_ACK interval, respectively. *Lp* represents the total packet length including overhead and payload. *Lw,ack* denotes the ACK waiting time. Lack indicates the length of ACK frame, while LIFS is the interframe spacing (IFS) time, and *Lm,ack* represents ACK packet timeout, determined by *macAckWaitDuration*.

We outline below the final derived transmission block’s equations and ignore details:

Probability of attempting to sense the channel for the second time (CCA2)

Finally, the successful and unsuccessful packet transmission (due to NO_ACK)

According to (33), (34), (36), and (37), the total probability transmission block is

According to the transmission block’s equations, we are in a position to calculate the failure events and successful probabilities for waiting block:

Obviously speaking, all equations in transmission and waiting blocks depend on *b0,0,0*. So another equation is required to solve these equations. The sum of all states’ probability in these two blocks must be equal to one:

*b0,0,0* can be calculated by Eq. (42).

Solving nonlinear equations in terms of *α*, *β*, and *τ* leads to find the network quiescent points and also models the behavior of the medium.

In the following, reliability, end-to-end delay, and throughput, as the most critical parameters, are scrutinized.

## 4. Reliability

The probability of successful packet reception is defined as reliability. In cyber-physical systems, particularly Smart Grid, wireless links may experience a great deal of challenges such as strong noise with heavy-tailed distributions. This means that reliability is a crucial parameter. There are three events in the transmission block, only one of which leads to successful transmission and others are failure events. As mentioned formerly, channel access failure and NO_ACK in the last retransmission are responsible for the failure event.

In which *Pdc* and *Pdr* are the probability of discarded packet (owing to channel access failure) and NO_ACK in the last retransmission, respectively. Following the Markov model illustrated in Figure 5

## 5. Packet service time and end-to-end delay

The average delay for successful transmission is defined as the time interval between a packet arrival and the reception of corresponded ACK. It features the waiting time in queue and the service time in the transmission block. In previous works [16, 33], however, the queue delay is overlooked, and the average delay was defined as the time interval from the instant that packet is at the head of its MAC queue until receiving the corresponding ACK. In industrial applications, especially in power grid, delay plays a vitally important role. A delayed command or notification may give rise to chain errors, thereby calculating the precise amount of delay that appears essential.

As mentioned in previous parts, in the transmission process, two consecutive successful CCAs mean that the node is allowed to send its packet. If the node finds the channel busy in each of CCAs, it tries the next backoff stage. This proceeds until m reaches macMaxBE. The service time varies if a node finds the channel busy in each CCA. Attempting to seize the channel for various times is responsible for the different combinations of service time. Let *Cαβ (i)* be the set comprising all the combination of choosing i element out of a set of busy channel probability *Sαβ* = {α, β (1-α)}. Normalized average service time is as follows:

where *kth* combination out of a set of *Sαβ* in *i*^{th} backoff attempt. In addition, *Sαβ* in *k*^{th} combination, respectively. The delay in backoff stages is presented in (47) (note that the midpoint of the uniform distribution indicates the average value):

The average time for success and failure transmissions can be calculated according to (46) and (47). The success occurs after *j* failures (due to NO_ACK):

The average time for failures due to limitation of backoff attempt is

The average time for failures due to the retransmission limit is

Accordingly, the average service is

Finally, according to Eqs. (51), (39), (40), and (41), the service time is

The end-to-end delay consists of the service time and the waiting time:

In which

## 6. Simulation and analysis

In this section, we have validated our model by drawing a comparison between mathematical results, Monte Carlo simulations, and experimental tests in terms of delay, reliability, and throughput. All experiments are conducted with self-designed motes, each of which features an AT86RF233 amplified ZigBit wireless module and a SAM3S2B microcontroller, both by Atmel. In IEEE802.15.4 standard, aUnitBackoffPeriod is defined as 10 bytes, each of which equals 2 symbols, corresponding to 320 μs in 250 kbps. Ten nodes are positioned in a star topology with beacon-enabled mode. Each node is at the distance of around 20 m from the coordinator, and all nodes are distributed in an area of 1000 m^{2}.

The impact of the packet generation rate, MAC parameters, and the number of nodes on delay are then evaluated. So as to enhance the reliability of the system, ACK mechanism is activated. The MAC parameters are set according to the standard document [10].

Figure 6 compares the service time, given in the Eq. (52), as a function of various MAC parameters m0, m, and n, obtained from the tagged node (i.e., a node which we perform our evaluations on). The DTM results and Monte Carlo simulations perfectly coincide, and they both predict well the experimental results. As expected, the service time is more sensitive to m0 than m and n. The network becomes unstable, and the buffers are filled if, for a long time, service time is more than 20 ms (horizontal dotted line). Curve fittings are also performed in order to set the optimum parameters in Eqs. (54)–(56):

Figure 7 shows the service time’s composition as a function of the MAC parameter m and the time period (T_{P}). When T_{P} and m are reduced and increased, respectively, the contribution of failure events in the service time will be highlighted. This leads to the reduction of reliability. In T_{P} = 100 ms, the majority of failure events is due to lack of the ACK packet, but if T_{P} declines to 10 ms, the channel access failure also appears. In Figure 7(c), raising m up to 4 and 5 makes the network unstable (green dashed line).

Figure 8 illustrates reliability which is obtained by Eq. (43) as a function of m0, m, and n. Like service time, DTM and Monte Carlo simulations perfectly coincide, and both of them predict well the experimental results.

Figure 9 depicts the packet transmission service time against the number of nodes for different data generation time periods (note that the waiting time in the queue is ignored in this figure, and it will be evaluated in the following). Changing the input data rate causes large differences in average delay in Park’s model [32] (Poisson distribution is considered in Park’s model), whereas in DTM model, the average delay does not fluctuate by changing data rate, so it shows a stable behavior which is necessary for Smart Grid. In fact, DTM model is independent of the traffic rate.

Now, the analysis of DTM using probability density function (PDF) of the service time is taken into account. As mentioned in previous sections, whether a node enters the queue or idle states, and also how many states the idle mode has, depends on the PDF’s shape. Figure 10 shows changes in PDF against m0. A rise in m0 contributes to an increase in average service time, reliability, and maximum value of service time.

The maximum value of the service time, which is a critical factor for the average and peak of the queue length, is specified by PDF’s variance. The head area in PDF (the range of values where the PDF is relatively high) has a direct relationship with m_{0}. It is also notable that the number of probabilities in the head of PDF equals

On the other hand, most of PDF’s area is in its head, and due to high reliability, it can be deduced that most of successful transmissions are located in the head area:

The dotted vertical lines, which correspond to average service time, show the expected value of the corresponding PDF. As this line approaches the head of PDF, the reliability goes up.

On the other hand, average service time increases, while the line moves to the right of the diagram.

As Figure 11 shows, a reduction in *TP* translates into a slight rise in average service time, making the average service time line (dotted red line) far away from PDF’s head. As mentioned before, this causes a drop in the reliability. On the other hand, a fall in *TP* leads to a slight growth of variance. Change in variance causes fluctuation in the queue average and peak.

As inferred from Figure 11, the transition variance from 2.326 to 6.999 makes the queue length and queue peak change from 6.35 × 10^{−8} and 1 to 2.2451 and 23, respectively.

The more distance between the average service time line and PDF’s head we have, the less reliability would occur. As long as the average service time approaches *TP* (the dotted red line approaches the dashed black line), the average queue length and peak will exponentially increase. So as to fulfill a stable condition, the dashed line must be on the right side of the dotted line. The less area on the right side of *TP* will cause the less queue length average. Hence, *TP* must be more than the maximum service time to design a system with zero queue length.

Figure 12 illustrates that the velocity of the increase in the average queue length depends heavily on the number of nodes.

Up to this point, the waiting and transmission blocks were evaluated separately. It is also essential to appraise the effects of both blocks simultaneously. Figure 13 shows service time, waiting time, and total delay against *TP* and *N*.

A drop in *TP* does not affect greatly the total delay in a sparse network (i.e., *N* = 5) but in a dense network does. The straight black line in Figure 14 determines the stability boundary, so that all network quiescent points upper this line leads the network to an unstable state.

The diagram of throughput against *TP* and *N* is shown in Figure 14. To specify the contribution of the queue in throughput, this figure draws a comparison between DTM and IEEE802.15.4 (without buffer). The maximum throughput in DTM (442 packet/s) has considerably increased compared to IEEE802.15.4 (353 packet/s). Furthermore, the way in which throughput rises has changed in DTM. In this simulation, the lower value of throughput corresponds to a network with *N* = 5 and *TP* = 27.2 ms for IEEE 802.15.4. An increase in *N* and *TP* is responsible for a rise in throughput until a maximum value, in *N* = 15 and *TP* = 27.2. The reduction in throughput starts following this point. Nevertheless, the throughput in DTM changes in a dissimilar way, so that the maximum throughput is acquired in *N* = 15 and *TP* = 19.2.

Two factors prove contributing to design a buffer, the average length and peak of the queue. Figure 15 illustrates the corresponding queue average length and peak of Figure 14. Deducing from Figure 15, so as to reach the maximum throughput (*N* = 15, *TP* = 19.2), a 10 packet length buffer is required in order not to lose any packets.

## 7. Conclusion

CPSs, developing rapidly and covering eclectic domains, constitute thriving solutions for Smart Grid, the next-generation power grid systems. In this paper, we proposed a novel analytical model based on Markov chain for the MAC sublayer of IEEE802.15.4 standard. This model can provide a precise QoS to applications in which data generation proves periodic, such as AMI in Smart Grid. This is achieved by supplying the model with a MAC-level buffer and the reconsideration of idle mode. The model can provide QoS by reducing the impact of traffic rate fluctuation and the variation of the number of nodes. We incorporated variable idle state lengths so as to makes our study more pragmatic, and then the overall performance in terms of the end-to-end delay and reliability was evaluated. In this paper, the end-to-end delay refers to the interval between when a packet is generated and when a packet service is accomplished, including the time when in the queue as well as transmission time. We observed that the delay distribution of IEEE802.15.4 depends mainly on the MAC parameters and the collision probability.

Furthermore, using the probability density function of transmission time, we designed an optimum network meeting our QoS requirements. We analyzed the impact of MAC parameters and packet generation rate on the shape of the PDFs. In order to make our view more general and feasible, both saturated and unsaturated traffic has been applied, and no limitation is imposed on the queue length.

Besides Monte Carlo simulations, we performed a field test on the protocol by building a WSN with self-designed motes, validating our model. Future work includes investigating the performance of our analytical model with a downlink stream.