Introduction
Proximity service (ProSe) exploits proximity of the mobile devices by utilizing information such as geographic location and physical devices data, changing the way we interact with people and things [1]. ProSe has been considered having a good potential usage in mobile social networks in proximity (MSNP). MSNP is a wireless peer-to-peer (P2P) opportunistic network using geo-proximity in addition to nowadays mobile social networks such as Facebook a and Linkedin [2]. However, ProSe is also playing an important role in other areas, such as smart home and BA, containing the interacting services between people and people, people and things and things and things [3]. In smart home and BA, ProSe has become increasingly prosperous with the advancement of new technologies such as big data, artificial intelligence and wireless networks. For examples, Apple Homepod, Amazon Echo and Google Home utilize the above technologies to provide seamless proximity services for users by using geographic location, physical devices data and other information. Importantly, these ProSe and application scenarios need stable support from network protocols and communication infrastructures with different requirements, like latency, reliability, bandwidth and so on.
To ensure a satisfactory user experience of ProSe, one important factor is network latency [4]. ProSe generally uses IP-based networks, which introduce extra latency due to the IP stack. However, users need to have smooth user experience without long waiting time when interacting with other people or things. Also, some other services in smart home and BA require quality of service (QoS) guarantees [5]. Safety-critical applications in smart home and BA, such as healthcare systems for elderly people, fire alarms, require reliability and time predictability. Google Home fully utilizes Thread protocol as network protocol and communication infrastructure to provides various use scenarios and products such as thermostats, cameras, and alarm systems. Thread protocol, mainly introduced for smart homes and BAs [6], is a new WSN protocol developed by Thread Group to connect and control IoT products. To better understand and develop ProSe, it is crucial to investigate wireless network protocols with improved responsiveness for ProSe such as the Thread protocol.
To the best of our knowledge, this paper is the first work that investigates the latency of the Thread protocol through an experimental study, though security [7] and energy [8] respectively, have been investigated. We propose practical methods and guidelines to study the latency of Thread as an IoT protocol used in ProSe of smart home and BA. The deep understanding of the latency of Thread protocol facilitates designing and developing ProSe because developers can precisely analyze and guarantee QoS in smart home and BA systems. To this end, we propose a Markov chain-based system-level model to theoretically analyze the latency of the Thread mesh network and verify the model results through an experimental study. Based on the proposed analytical model, we developed a software tool for ProSe developers to estimate the latency of the Thread mesh network. The evaluation of the model in the multi-hop Thread mesh network shows that the model results match well with the experimental results.
The rest of the paper is organized as follows. In Section II, related work on latency of WSNs and mathematical models for WSNs are presented. In Section III, an overview of the Thread protocol is introduced. In Section IV, a system level model for the latency of the Thread mesh network is proposed considering the latency introduced at different network layers, from the application layer to the physical layer. The accuracy of the model is experimentally validated in Section V. Section VI concludes the paper and proposes our future-work.
Related Work
A. Latency of WSNs
Latency of WSNs is critical in many applications such as industrial automation, healthcare systems and safety-critical applications in BA, such as fire alarm detections [9]. Many works have investigated the latency of WSNs in these areas. In [10], the latency of asynchronous MAC protocols has been surveyed in delay-sensitive wireless sensor networks. The work [11] pointed out that it is hard to predict the accurate latency introduced by WSNs when the MAC implements CSMA/CA. Instead, the work applied a Time-Division Multiple Access (TDMA)-based protocol to a slightly modified IEEE 802.15.4 to assure that the transmission latency of sensors is not more than 10 ms. Sahoo et al. [12] proposed a new channel access mechanism for IEEE 802.15.4e-based low latency deterministic network shared slots. Also based on 802.15.4e, Daneels et al. [13] came up with recurrent low-latency scheduling in Time-Slotted Channel Hopping networks. However, when modeling the latency of WSNs, practical hardware limitations may cause significant differences between theoretical models and real tests [14]. In fact, the work [15] mentioned that the latency of multi-hop networks is increased significantly by packet relaying. Despaux [16] proposed an approach for modeling and estimating the end-to-end delay for WSNs considering the protocol implementation and hardware limitations. In [17], a blue probability generation function (PGF) was proposed to derive the delay of successfully received packets. However, in practice, understanding the latency of WSNs requires experimental studies combined with the theoretical analysis. Deep understanding of the distribution latency of WSNs together with experimental studies can guarantee the QoS in smart home and BA. It also provides practical guidelines for developers to design user-friendly ProSe when developing applications.
B. Mathematical Models of WSN MAC
Recently, several analytical studies for the latency of IEEE 802.15.4 have been proposed, e.g., [18]–[21], inspired by Bianchi’s work [22]. Due to the stochastic nature of MAC protocols, these models are mainly based on Markov Chains. Park et al. [17] and [19] have proposed a model with the Markov chains considering the retry limit, acknowledgments and unsaturated traffic. Effective and simple approximation of delay, reliability and energy consumption have been proposed in these works. Furthermore, in [17], based on [19] and [23], a PGF method has been applied to estimate the delay introduced in packet delivery. However, only the star topology was considered in these works. Hence, delay is estimated in a one-hop fashion, whereas the analysis verification is based on simulation rather than experimental results. According to the work in [14], the gap between mathematical modeling and measurement of WSNs cannot be neglected. Although the hardware factors related to delay and experiment results were considered in [19], a more comprehensive statistical characterization of latency has not been provided. Marco et al. [24] have proposed an analytical model considering a multi-hop IEEE 802.15.4 network with hidden terminals. Wang et al. [25] have worked with multi-hop networks and estimated the end-to-end delay. The work considered the carrier sense multiple access with the collision avoidance (CSMA/CA) protocol for nodes running the TinyOS operating system. However, both of the works above only focused on modeling MAC protocol logic, without considering the implementation factors in the network, i.e., the impact of hardware delay between processors and transceivers in WSNs. Yan et al. [26] proposed a mathematical model for MAC access delay. The model was based on the queuing theory and an easy-to-use tool in package level simulation was developed. Nevertheless, that work only focused on the slotted MAC. The unslotted MAC, multi-hop communication and experimental validation were not considered in that work.
In [20], a Markov chain model was proposed to analyze the slotted CSMA/CA in both saturated and unsaturated conditions in the ACK mode. However, the proposed model did not consider retransmissions. Faridi et al. [21] proposed a modified Markov model in an attempt to model the slotted CSMA/CA mechanism in the ACK mode. The model also includes retransmissions with finite retry limits.
The packet delay, throughput and power consumption about IEEE 802.15.4 MAC have been analyzed in [27]. However, none of the papers mentioned above considered the following aspects altogether: the unslotted or beaconless MAC, multi-hop scenarios, implementation factors, system level models and software tools for latency estimation. These characteristics make the modeling and validation of the latency of the Thread mesh network different from the results available in the literature.
The contributions of this paper are the following:
A thoroughly study of the latency of a new IoT protocol, Thread stack, theoretically based on the model in [18], adding real measurement factors and multi-hop communication.
An experimental study of the Thread mesh network through real testbed in BA and validating the proposed analytical model.
The specification and implementation of an easy-to-use software tool, which gives clear guidelines to the ProSe developers to guarantee a certain level of QoS and develop user-friendly applications.
Overview of the Thread Protocol
In this section, we describe the protocol stack of Thread as the delay generated by each layer needs to be considered. Specifically, we describe the mechanism of non-beacon enabled IEEE 802.15.4 CSMA/CA with the backoff process. Understanding the Thread protocol and the non-beacon enabled IEEE 802.15.4 CSMA/CA backoff process helps us to propose the system level model in the subsequent sections.
A. Protocol Stack
Thread is a new IP-based wireless networking protocol established in July 2014 by companies such as Google Nest, ARM, and Samsung [6]. The Thread protocol combines the solutions of several standards to fit the needs of typical BA applications. As Fig. 1 shows, Thread does not standardize the application layer. This provides the supplier with the freedom to use proper application layers according to their needs. In our paper, the constrained application protocol (CoAP) is used, which is a constrained web transfer protocol (similar to HTTP) intended for resource-constrained devices. The feature that supports IP networking allows Thread to easily interconnect with other IP-based mobile devices. At the network layer and transport layers, Thread uses User Datagram Protocol (UDP) on top of IP routing and IPv6 over Low power WPAN (6LoWPAN). In MAC and PHY layers, Thread uses the IEEE 802.15.4 wireless specifications, supporting mesh network with a maximum speed of 250 kb/s over the 2.4 GHz band [6]. IEEE 802.15.4 wireless specification has been used in many other protocols such as WirelssHART, Zigbee and Internet Engineering Task Force (IETF) IoT stack.
There are five types of devices in the Thread network: border routers (BR), routers, router-eligible end device, end devices, and sleepy end devices. The Thread stack supports full mesh connectivity between all routers in the Thread network. The number of routers will decide which kind of topology it will form. If there is only one router or border router, then a basic star topology is formed. If there is more than one router then a mesh topology is automatically formed. The details can be found in [6].
B. IEEE 802.15.4 MAC
In this section, the non-beacon enabled IEEE 802.15.4 CSMA/ CA used in the Thread protocol is summarized. Fig. 2 depicts the flowchart of the non-beacon enabled IEEE 802.15.4 CSMA/CA channel access mechanism. We denote the MAC parameters by
Before sending the packets, wait for a random period of time in the range
backoff time unit[{0, 2^{BE} -1 }] to avoid collisions. The backoff time unitS_{b} isS_{b} with20~T_{s} =T_{s} .16~ \mu s Perform Clear Channel Assessment (CCA) to check if the channel is busy or idle. If channel is idle, go to Step 4, else go to Step 3.
Busy channel: increase the value NB and BE by one. However, the maximum value of BE is
. At this time, if NB is less than the value ofmacMaxBE , the process returns to step one (Otherwise, the process ends with the channel access failure).macMaxCSMABackoffs Idle channel: the MAC layer sends out the packet and waits for the ACK. If the ACK is received within maximum
, the packet is successfully sent. Otherwise, the packet has collided and needs to be retransmitted with retry counter incrementation (macAckWaitDuration ). If R exceedsR = R + 1 , the algorithm terminates with collision fail and the packet is discarded (otherwise the algorithm initializes the NB and BE again and returns to Step 1).macMaxFrameRetries
Mathematical Model of the Thread Mesh Network
In this section, we propose a system level model for the latency of the Thread mesh network. We analyze the system model considering the implementation of the Thread protocol, from the application layer to the physical layer. In a WSN for BA, we define the round trip time (RTT) as the time duration from the node (border router) sending out a message from the application layer (e.g., CoAP request) until receiving the response from the destination (e.g., CoAP ACK). The parameters used in this paper and a short description of each parameter are provided in Table 1.
A. System Model of Latency of Multi-Hop Thread Mesh Network
The system level model is based on the packet transmission path in the Thread mesh network. Without loss of generality, in Fig. 3, the three-hop round trip procedures are reported. The source node is the border router while the destination node is the end device. The RTT can be separated into two parts: the sending route and the receiving route. The sending route begins at the border router’s application layer and then goes through the network layer, the MAC layer and the physical layer where the transceiver transmits the message. Then the packet will be in the routing path which consists of the over-the-air (OTA) time and the relay nodes’ processing time. When the packet reaches the physical layer of the destination, the destination node starts processing the packet and sending this packet from the physical layer to the application layer. At this point, the sending route is finished while the receiving route begins. The destination node sends back the ACK command following the same route as the sending route.
Based on the description above, RTT is the sum of three terms: the first is the propagation time from the application layer to the physical layer, denoted as \begin{equation*} T_{\text {RTT}} = 2 \times T_{0} + T_{1} + 2 \times T_{2}\,.\tag{1}\end{equation*}
\begin{equation*} T_{0} = T_{\text {IPS0}} + T_{\text {MAC0}} + T_{\text {PHY0}}.\tag{2}\end{equation*}
\begin{equation*} T_{\text {ROUTE}} = T_{\text {MAC2}} + T_{\text {PHY2}} + T_{\text {PHY0}} + T_{\text {MAC0}}.\tag{3}\end{equation*}
\begin{equation*} T_{1} = 2 \times (h-1) \times T_{\text {ROUTE}}.\tag{4}\end{equation*}
\begin{equation*} T_{2} = T_{\text {IPS2}} + T_{\text {MAC2}} + T_{\text {PHY2}}.\tag{5}\end{equation*}
In conclusion, the
B. Busy Channel and Collision Probability
In Fig. 2, two probabilities are involved in the channel access and data transmission process, the probability of busy channel assessment (
According to the stochastic process mechanism, the Markov chain model is described by a three dimensional (3D) {s(t), c(t), r(t)} process as depicted in Fig. 4. {s(t), c(t), r(t)} respectively represent the back-off stage, the state of the back-off counter and the state of the retransmission counter at time
With the help of derived transition probabilities and stationary probability in the Markov chain model, \begin{align*} \alpha _{busy}=&\alpha _{1} + \alpha _{2}. \tag{6}\\ \alpha _{1}=&L(1-(1-\tau )^{N-1})(1-\alpha _{busy}). \tag{7}\\ \alpha _{2}=&L_{ack} \times \frac {N \tau (1-\tau )^{N-1}}{1-(1-\tau )^{N}} \times \frac {\alpha _{1}}{L}.\tag{8}\end{align*}
\begin{equation*} p_{col} = 1 - (1-\tau )^{N-1}.\tag{9}\end{equation*}
C. Delay Analysis of CSMA/CA Mechanism
In this section, we derive the distribution of MAC layer service time \begin{align*} E(T_{MAC0})=&B'(1). \tag{10}\\[4pt] E[(T_{MAC0}-E[T_{MAC0}])^{2}]=&B''(1) + B'(1) - \{{B'(1)}\}^{2}. \\ {}\tag{11}\end{align*}
First, we give some definitions as follows:
We denote \begin{align*} S_{t}(Z)=&Z^{L_{s}}. \tag{12}\\[4pt] C_{t}(Z)=&Z^{L_{c}}.\tag{13}\end{align*}
From Fig. 4, the PGF of the random back-off process \begin{equation*} H_{i}(Z) = \prod _{k=0}^{i}W_{k}(Z).\tag{14}\end{equation*}
\begin{align*} W_{k}(Z)=&\begin{cases} \Sigma _{l=0}^{2^{i}W_{0}-1} \dfrac {M_{d}(Z)^{l}}{2^{i}W_{0}} & \text {if $ i\leq m_{b} - m_{0} $}\\[7pt] \Sigma _{l=0}^{2_{m_{b}}-1} \dfrac {M_{d}(Z)^{l}}{2^{m_{b}}} & \text {otherwise}. \end{cases} \tag{15}\\[4pt]=&\begin{cases} \dfrac {1-Z^{2^{i}W_{0}}}{2^{i}W_{0}(1-Z)} &\text {if $ i\leq m_{b} - m_{0} $}\\[7pt] \dfrac {1-Z^{2^{m_{b}}}}{2^{m_{b}}(1-Z)} & \text {otherwise}. \end{cases}\tag{16}\end{align*}
It is assumed that \begin{equation*} G_{i}(Z) = \sum _{k=1}^{i}S_{c}(Z)^{i}.\tag{17}\end{equation*}
Proposition 1:
Let \begin{align*} B(Z)=&S_{t}(Z) \sum _{j=0}^{n}\Pr (\mathcal {S}_{j} | \mathcal {U}_{t})C_{t}(Z)^{j} \\&\times \left ({S_{c}(Z) \times \sum _{i=0}^{m}C_{i}(Z)H_{i}(Z) }\right )^{j+1} + \sum _{j=0}^{n}\Pr (\mathcal {C}_{j} | \mathcal {U}_{t}) \\&\times \left ({\! C_{j}(Z)S_{c}(Z)\sum _{i=0}^{m}G_{i}(Z)H_{i}(Z)\!}\right ) ^{j} G_{m+1}(Z)H_{m+1}(Z) \\&+\, \Pr (\mathcal {F}_{j} | \mathcal {U}_{t}) \left ({C_{t}(Z) \times S_{c}(Z)\sum _{i=0}^{m}G_{i}(Z)H_{i}(Z)}\right )^{n+1}. \\ {}\tag{18}\end{align*}
\begin{align*} \Pr (\mathcal {S}_{j} | \mathcal {U}_{t})=&\frac {P_{c}^{j}(1-P_{c})(1-\alpha _{busy}^{m+1})^{j+1}}{Pr(\mathcal {U}_{t})}. \tag{19}\\ \Pr (\mathcal {C}_{j} | \mathcal {U}_{t})=&\frac {P_{c}^{j}(1-\alpha _{busy}^{m+1})^{j}\alpha _{busy}^{m+1}}{Pr(\mathcal {U}_{t})}. \tag{20}\\ \Pr (\mathcal {F}_{j} | \mathcal {U}_{t})=&\frac {P_{c}^{n+1}(1-\alpha _{busy}^{m+1})^{n+1}}{Pr(\mathcal {U}_{t})}.\tag{21}\end{align*}
\begin{align*}&\hspace {-0.5pc}Pr(\mathcal {U}_{t}) = \frac {1-(P_{c}(1-\alpha _{busy}^{m+1}))^{n+1}}{1-P_{c}(1-\alpha _{busy}^{m+1})} (1-P_{c}+P_{c}\alpha _{busy}^{m+1}) \\& \qquad \qquad \qquad \qquad \qquad \qquad{ +\,P_{c}^{n+1}(1-\alpha _{busy}^{m+1})^{n+1}.} \tag{22}\end{align*}
Proof:
The PGF of MAC layer service time is derived from the Markov chain model shown in Fig. 4. A transmission commences whenever the node performs CCA successfully. When a packet transmits in the channel, it has the probability
As B(Z) is a smooth function of \begin{equation*} B(Z) = \sum _{i=0}^{\infty }\Pr (T_{MAC0} = i)Z^{i}.\tag{23}\end{equation*}
Once
Numerical Results and Experimental Validation
First, we present the numerical results of the distribution of MAC service time we derived in the previous section by observing the number of nodes in the network and the effect of traffic conditions. Then, to quantify the system level model, the hardware related latencies are further considered in the experimental results. Finally, to validate the system level model we presented in the previous section in Eq. (1), we perform experiments which allow us to confirm the analysis. Details are described in the following.
A. Statistical Probability Distribution of MAC Service Time
By calculating the analytical equations of the model above, the distribution of MAC service time is presented with respect to the node number
Numerical results of MAC layer service time distribution. (a) shows the relationship between the probability distributions and the node number N with
B. Latency Related to Hardware and Software Implementation
In this section, the latency of other layers besides the MAC layer is experimentally investigated, which is closely related to the hardware aspects and implementation of the software stack. First, the hardware platform and the software stack for experimental study are introduced. Second, the experimental tests are presented to understand the latency introduced by hardware and software implementation.
In the experimental study, the hardware board FRDM-KW24D512 and Thread 1.0.0 preview software stack from NXP are used. FreeRTOS is used as the operating system, which may introduce extra latency. Reminding the equation
In the software stack, the time stamps are added to get the time interval of each layer as shown in Fig. 6. At first, the packet length of 10 Bytes is applied in the test. The results are shown in Table 2. Then the packet length with the varying application layer loads of 20 Bytes, 30 Bytes, 40 Bytes, 50 Bytes, and 60 Bytes are tested in turns. The results show that delays of IPS TX and PHY TX are proportional to packet length. Therefore, linear regression is used to estimate latency in IPS TX and PHY TX states, as shown in Fig 7. Here the data length counts only the payload of the application layer, e.g., CoAP’s payload. The linear regression model fits well with the testing data both in the physical and IPS TX layers. For the physical layer, the delay comes from the packet copying between the micro-controller and radio transceivers through the serial peripheral interface (SPI), where \begin{equation*} T_{\text {PHY0}} = \bigg \lceil \dfrac {L}{vS_{b}}\bigg \rceil.\tag{24}\end{equation*}
C. Experimental Validation of Thread Mesh Network
In this section, we experimentally implement a testbed in a real building environment to test the latency of the Thread mesh network and compare experimental results with analytical results.
To establish the Thread multi-hop mesh network, 23 nodes are deployed in four floors, as shown in Fig. 8. The top left side of the figure shows the experimental parameters settings in the test bed. Each node has the ID from 0 to 22. Node 0 is the BR which sends the RTT packets. Nodes 1 to 12 are the active routers while nodes 13 to 22 are the end nodes (ED). In the graph, the red circle in the third floor denotes Thread BR, the root of mesh networks, connecting to our desktop computer. Other nodes are spreading in the building from the base floor to the third floor, mainly in the meeting rooms, lounges and corridors. When the test begins, BR starts sending CoAP GET messages to each node from node 1 to 22. The BR uses its hardware clock to calculate the time interval between sending the message and receiving the ACK. BR sends 300 packets to each node and also records how many hops to reach that node. All the RTT data are divided into six groups according to the hops. For each hop, the cumulative distribution function (CDF) curves are drawn to represent the RTT based on hop counts.
Fig. 9 shows the experimental CDF results of the latency of six hops in the Thread mesh network. The probabilities of RTT within 200 ms from one to six hops are near 0.99. In general, RTT increases with the number of hops. The CDF curve interval between their neighbors are close to each other. As the red square shapes note, there exists stair effects in the CDF curve because of CoAP retransmissions. When the first packet drops, CoAP retransmissions are trigged after roughly two seconds and can be trigged up to four times. Fig. 9 shows a small number of packets that experience very long latency once CoAP retransmission is triggered due to packet loss in the lower layers (caused by the negative factors like fading, interference, and path loss). There are more CoAP retransmissions for high number of hops, such as six hops. These long latency packets count less than one percent in the total experiment packets. Note that our proposed analytical model does not consider the application layer retransmission. Thus, we regard these long latency packets as dropout packets.
Experimental results on Cumulative Distributed Function versus Round Trip Time for Thread mesh network.
Recall that the latency of the Thread mesh network can be calculated using the Eq. (1). For
Analytical and experimental results on the probability distribution of the latency of Thread mesh network.
D. Software Tool to Estimate the Latency of Thread Mesh Network
In this section, a software tool to estimate the latency of the Thread mesh network is implemented using MATLAB R2015B. As Fig. 11 shows, the parameters
Software tool to estimate the latency of Thread mesh network. Left side is used to configure the parameters and the right side shows the analytical results.
Characterizing latency in smart home and BA applications is an essential aspect of a sound engineering design. Therefore, one important goal is to guarantee QoS in terms of message latency, such as switching the lights or door control within 200 milliseconds (ms). ProSe developers generally lack the information of network delays when developing services, which significantly increases the cost of development and time to market [29]. This tool can solve the issue above. First, this tool reveals the relationships between MAC parameters setting and the latency of the Thread mesh network. Second, this tool gives guidelines for developers to design high quality services and develop user-friendly ProSe.
Conclusion and Future Works
In this paper, we investigated the wireless network protocol called Thread for ProSe in smart home and BA, and proposed a theoretical system level model to investigate its latency. Markov chain process and generating functions are used to model the behavior of backoff process in CSMA/CA and to derive the probability distribution of the MAC layer service time. In addition, an experimental validation of the model is carried out showing a good match with the system level model. Based on system level model, we have developed a friendly software tool for estimating latency of Thread mesh network so that the developers can have more information about the communication infrastructures, especially latency, when developing user-friendly ProSe.
However, the system model and experiment results have some limitations. The model does not consider the application layer retransmissions. The future work will include considering this factor in the model. Investigating latency of the multicast communication will also be part of the future work. Also, more complete survey about wireless networks with improved responsiveness for ProSe will also be the future job.