DEGREE PROJECT IN ELECTRICAL ENGINEERING, SECOND CYCLE, 30 CREDITS STOCKHOLM, SWEDEN 2016

Battery Lifetime Modelling and Validation of Wireless Building Automation Devices in Thread

EVA AZOIDOU

KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF ELECTRICAL ENGINEERING Abstract

The need for energy efficiency in wireless communication is prevalent in all areas, but to an even greater extent in low-power and lossy networks that rely on resource- constrained devices. This degree project seeks to address the problem of modelling the battery lifetime of a duty-cycled node, participating in a wireless sensor net- work that is typically used in smart home and building applications. Modelling in MATLAB combined with experimentation are employed to predict the life expect- ancy and to validate using a hardware implementation. Various scenarios including sleepy end devices in a wireless sensor network are modelled and validated; these range from variable wake-up frequency and packet payload transmission to in- creasing network contention with the addition of network load. A comprehensive analysis of the main factors contributing to wasteful energy usage is provided in this thesis project, and it can be concluded that the model can estimate the battery lifetime under different testing scenarios with an error less than 5 %.

Keywords: of Things (IoT), battery lifetime, wireless sensor networks, energy efficiency, IEEE 802.15.4 MAC, power consumption model, Thread. Sammanfattning

Det finns ett stort behov av energieffektivitet inom tr˚adl¨oskommunikation, s¨arskilt inom n¨atverk med bortfall och l˚agstr¨omf¨orbrukningd¨arresursbegr¨ansadeenheter nyttjas. Det h¨arexamensarbetet efterstr¨avar att l¨osaproblemet med att modellera batterilivsl¨angdenhos en sensoranordning med en l˚agdriftcykel, som en del av ett tr˚adl¨ostsensorn¨atverk avsett f¨or att till¨ampasi smarta hus och byggnader. Model- lering i MATLAB kombinerat med experimentering anv¨andsf¨oratt f¨oruts¨agaden f¨orv¨antade livsl¨angdensamt f¨oratt validera en h˚ardvaruimplementering. Flertalet scenarier med sovande noder modelleras och valideras, med allt fr˚anvariabel up- pvakningsfrekvens och paket¨overf¨oringtill ¨okande resurskonflikter med ytterligare belastning p¨an¨atverket. I detta examensprojekt inkluderas en helt¨ackande ana- lys av huvudorsakerna till energisl¨oseriethos enheterna och slutsatsen kan dras att modellen kan ber¨aknabatterilivsl¨angdenf¨orolika testscenarier med mindre ¨an 5 % fel.

Nyckelord: Sakernas internet, batterilivsl¨angd,tr˚adl¨osasensorn¨atverk, ener- gieffektivitet, IEEE 802.15.4 MAC, energif¨orbrukningsmodell, Thread. Table of Contents

1 Introduction 1 1.1 Background ...... 1 1.2 Problem Definition ...... 2 1.3 Research Methodology ...... 3 1.4 Contributions ...... 3 1.5 Delimitations ...... 4 1.6 Thesis Structure ...... 4

2 Background 5 2.1 Thread - a new IoT technology ...... 5 2.2 CoAP ...... 7 2.3 IPv6 ...... 8 2.4 6LoWPAN ...... 9 2.5 IEEE 802.15.4 ...... 10 2.5.1 Carrier sense multiple access with collision avoidance ..... 10 2.5.2 Busy channel and collision probability ...... 12 2.5.3 Duty cycling mechanism ...... 12 2.6 Related Work ...... 13 2.6.1 Battery lifetime models ...... 13 2.6.2 Markov chain modelling of CSMA-CA ...... 14

3 Battery Lifetime Model 16 3.1 CSMA-CA in IEEE 802.15.4 ...... 16

1 3.2 SED operations in Thread ...... 20 3.3 Basic model ...... 25 3.4 Data collection methods for the model parameters ...... 28

4 Experimental Setup 31 4.1 Experimental design ...... 31 4.2 Hardware/Software ...... 32 4.3 Validation environment ...... 35

5 Performance Evaluation 36 5.1 Test Cases ...... 36 5.2 Validation metric ...... 37 5.3 Applicability of the model ...... 37 5.3.1 Wake-up frequency ...... 38 5.3.2 Packet Length ...... 39 5.3.3 Network size and traffic ...... 41 5.3.4 Accuracy of the model ...... 42 5.4 Battery Lifetime Improvement ...... 42 5.5 Summary ...... 44

6 Concluding Remarks 45 6.1 Conclusions ...... 45 6.2 Future Work ...... 45 6.3 Reflections ...... 46

2 List of Figures

2.1 Thread communication stack and wireless mesh network...... 6 2.2 Flowchart for the channel access in the unslotted case of CSMA- CA considering packet transmissions and retransmissions, adapted from [20]...... 11

3.1 Three-dimensional Markov chain model of the CSMA-CA algorithm in IEEE 802.15.4, adapted from [32]...... 18 3.2 Markov chain for the main events taking place in a Thread network as regards SED operations...... 22 3.3 Stages of current consumption during a no-data polling event of a sleepy end device...... 23 3.4 Stages of current consumption during a data polling event of a sleepy end device...... 24

4.1 Illustration of the experimental setup...... 32 4.2 FRDM-KW24D512 evaluation boards from NXP...... 33 4.3 Measurement and testing equipment...... 34 4.4 Oscilloscope capture of the averaging operation over 32 waveforms for the case of no-data polling event in Thread...... 35

5.1 Proportionate current consumption of the sensor node with respect to operations per hour and polling intervals...... 38 5.2 Predicted battery lifetime from the model and its proximity to the experimentally acquired average battery lifetime...... 39 5.3 Battery lifetime for transmission of different packet payload lengths. 40 5.4 Decrease in battery lifetime compared to a 10-byte payload trans- mission...... 40 5.5 Battery lifetime of a sleepy end device under the influence of variable network contention...... 41

3 List of Tables

2.1 Comparison of Thread with existing protocols ...... 6

3.1 Exchanged packets between child and parent device ...... 21 3.2 Main symbols used in the battery lifetime model ...... 26

5.1 Validation with normalised mean absolute error (NMAE) for differ- ent polling periods ...... 42 5.2 Validation with NMAE for different test cases ...... 42

4 List of Acronyms and Abbreviations

6LoWPAN IPv6 over Low power Wireless Personal Area Networks

AC/DC alternating current/direct current ACK acknowledgement ADC analog-to-digital converter APP application

BE backoff exponent BR border

CCA clear channel assessment CoAP constrained application protocol CON confirmable CSMA-CA carrier sense multiple access with collision avoidance dBm decibel-milliwatt DCF distributed coordination function DVR distance vector routing

ED end device

HBA home and building automation HTTP hypertext transfer protocol

IoT Internet of Things IP IPv6 Internet Protocol version 6

5 LLN low-power and lossy network

M2M machine-to-machine MAC media access control mAh milliampere hour MCU microcontroller unit MLE mesh link establishment MPDU MAC protocol data unit MTU maximum transmission unit

NB number of backoffs NIP native IP NMAE normalised mean absolute error NON non-confirmable

OTA over-the-air

PAN personal area network PCM power consumption model PD parent device PHY physical PSDU PHY service data unit

QoS quality-of-service

RF radio frequency Rx receive

SED sleepy end device

Tx transmit

UDP user datagram protocol

WPAN wireless personal area network WSN wireless sensor network

6 Chapter 1

Introduction

The first chapter briefly introduces the wide realm of the Internet of Things (IoT), with focus on the sensing and wireless communication side of it. The problem addressed by the thesis is defined and the goals are identified, while mentioning the aspects that fall within and outside the scope of this thesis.

1.1 Background

As the number of things being connected to the Internet has already surpassed the world’s population, soon things will generate more data than people, thus leading to the migration from the “Internet of people” towards IoT [1]. The term IoT was conceived by Kevin Ashton in 1999, and he described the notion as things being able to “see, hear and smell the world for themselves” in all its randomness without the need for human intervention [2]. Intelligent buildings, iHomes or Domotics are just simply different ways of referring to the concept of the smart home and building, which is one application area of the multifaceted IoT. The intended vision with the smart commercial and residential establishments is to create a vast dynamic information space where identities and virtual personalities are assigned to physical objects. These things function in unison while being incorporated into the physical world, rendering people oblivious to their existence. The smart objects connect to the Internet and operate in a manner that gives rise to ambient intelligence. The ultimate intention is to enhance the world by transforming it into a pervasive and immersive ‘supernetwork’ [3–5]. The required infrastructure to support and enable such a vision starts with the deployment of wireless sensor networks (WSNs), which monitor the environment around them and forward any essential information to base stations or deliver commands to actuators. The continuous monitoring and reporting capabilities of sensors are hindered by several factors, for instance, interference, node failures,

1 delays, and lack of infinite power source. This raises the question of whether and to what extent this kind of limitations affect both the design and performance of WSNs.

1.2 Problem Definition

Arguably, a trade-off needs to be attained among some of the design features. The most critical issue of them all is the energy efficiency of the resource-constrained sensors, which is controlled by their power consumption. Sensors are compact nodes that are equipped with tiny batteries having limited capacity and are re- quired to be operable for long periods of time [6]. Hence, low power consumption has a significant impact on the longevity of sensors, and it leads to the extension of the WSN life expectancy. The efficiency of a WSN design or lack thereof has a broad effect, which extends from the radio level up to the various high-level applications being developed on top of it. This dependence highlights the urgency to comprehend and analyse the power consumption properties of sensors and examine different factors in order to identify the culprits that cause the increased consumption of power resources [7]. Taking into account that the aspect of energy efficiency constitutes a main concern regarding the WSN design and performance, a methodology is proposed to model the power consumption of duty-cycled and battery-powered devices intended for applications in the field of home and building automation (HBA). In particular, the main objectives of conducting this degree project are described below: • Investigate the power consumption of a communication protocol, named Thread, with specific hardware devices and software configuration;

• Derive a mathematical model for the power consumption of the sleepy end device (low duty-cycled sensor node) in a Thread network and implement the model in MATLAB;

• Validate the model and evaluate the estimated battery lifetime using an experimental test bed;

• Identify the primary sources of battery depletion for sensor nodes in Thread. The benefit that stems from the successful implementation of the proposed model is evaluating the effect of the protocol parameters on the battery lifetime of the resource-constrained wireless building automation devices in Thread. Further- more, different levels of network size and traffic load can be assessed to infer the magnitude of their influence on the longevity of the sensor device.

2 1.3 Research Methodology

Scientific research deals with the systematic quest for knowledge in all pertinent areas. For the purpose of this project, a quantitative approach has been taken to construct a model that can sufficiently describe the behaviour of the phenomenon and then employ experimentation to validate the efficiency of the model in rep- resenting the operations that take place. Specifically, there are two methods that were used in order to reach the final objectives. The first involved creating a the- oretical model with the aid of MATLAB that would represent the behaviour of a duty-cycled node in Thread as regards its current consumption, while the second method included the experimental validation of the theoretical model by utilizing various test cases and deploying the scenarios in real networks. It has been established that the conducted degree project is of quantitative type. Hence, the research method, strategy, data collection and analysis techniques are to be germane to the quantitative type according to [8]. In particular, for the math- ematical model it is necessary to identify all the steps of operation of a battery- powered sensor device. The aspects that remain the same, such as the duration and current consumption of certain processes, led to their values being acquired using precise multiple measurements and then substituting the mean value in the model. However, there exist specific relationships among several variables that are related to the theory of wireless networks. In order for these variabilities to be taken into consideration by the model, a statistical model accounting for the real-world processes is constructed. As regards the validation using the experimental test bed, a WSN is deployed and various network scenarios are tested. The average duration and current consump- tion are obtained using precise measuring instruments under controlled conditions to the extent possible. After all the data for the implementation of the math- ematical model, and the experimental validation is collected, the data analysis stage follows, which involves statistics and computational mathematics. Further detailed information is provided in Chapters 3, 4, and 5.

1.4 Contributions

In this report, a thorough power consumption model (PCM) is proposed that is validated using experimental means. The contribution of this degree project is threefold: • The model can predict with a small forecasting error the battery lifetime of a sleepy end device that performs a certain number of operations per hour; • Several parameters of the model can be modified and adjusted appropriately to observe their effect on battery lifetime. These parameters can be, for

3 instance, packet size and polling interval; • Channel access failures and collisions due to increased network size and higher contention levels are represented in the model and their influence on battery lifetime is substantiated.

1.5 Delimitations

It should be noted that the main objectives of this project is the battery life- time modelling and its experimental validation. The proposal of novel adaptive algorithms to optimise the network operation with respect to power consumption as well as the implementation of the proposed improvements are not considered as part of this project. There are some recommendations about the optimisation of certain features, such as, sleeping polling intervals, transmission of application layer acknowledgements, time-out counter value for retransmissions, but they re- main plain suggestions and no verification is provided as to their efficiency.

1.6 Thesis Structure

The remainder of this report is structured as follows: Chapter 2 is an introduc- tion to the Thread protocol, providing some pertinent terminology and few details about the layers of which Thread is composed, with focus on the mechanisms of the MAC sublayer. Furthermore, the chapter presents the related work within the topic of battery lifetime modelling. Chapter 3 delves into the low-power aspect of Thread, concentrating on, and modelling the most common operations that draw current. In Chapter 4, the experimental setup, and the validation environment employed for the purpose of this degree project are described. A comprehensive evaluation of the results, and their significance within the context of energy effi- ciency in HBA systems is provided in Chapter 5. The final chapter concludes the report, states the delimitations of this degree project and provides alternative ways with which the battery lifetime could have been investigated as future directions for research.

4 Chapter 2

Background

This section provides a general introduction to the primary terms and notions that lay the foundations for the understanding of the subsequent chapters.

2.1 Thread - a new IoT technology

A plethora of communication technologies have been developed that facilitate the deployment of IoT. Few examples of such technologies are Zigbee, Bluetooth Low Energy, and Z-Wave. Thread is a relatively new wireless networking protocol with founder members stemming from big companies such as Nest Labs of Google, ARM, NXP, and Samsung, to name a few. With the specific application area of HBA in mind, Thread is considered to be the best-suited technology thanks to a mixture of features that provide a great deal of benefits. To begin with, Thread supports interoperability in the application layer by enabling multiple 3rd party options to be employed on top of it. Furthermore, low power operation is provided using duty-cycled nodes based on the power efficient IEEE 802.15.4 standard, and the support of mesh topologies allows self-healing in the network with no single point of failure. By bringing the flexible and pervasive Internet Protocol (IP) into the field of constrained embedded devices, Thread enables device-to-device, device-to-cloud, and device-to-application or backend service communication. Table 2.1 provides a comparison of various networking protocols with respect to important features necessary for the new phase of IoT [9][10]. It is apparent that Thread meets the requirements of a low power, IP-based, mesh supporting, interoperable, and open standard that is highly sought after within IoT. In Fig. 2.1a, the stack that constitutes the Thread communication protocol is il- lustrated. Thread employs the IEEE 802.15.4 standard for the physical (PHY) layer and the media access control (MAC) sublayer, while providing Internet Pro- tocol version 6 (IPv6) connectivity with the aid of IPv6 over Low power Wireless

5 Table 2.1: Comparison of Thread with existing protocols

Feature WiFi Zigbee Pro Bluetooth LE 4.x Z-Wave Plus Thread Low power      Mesh network      IPv6 support      Interoperability      Open standard     

Personal Area Networks (6LoWPAN) [11]. For the routing in the network layer, Thread uses distance vector routing (DVR), and in the transport layer, the stack supports the user datagram protocol (UDP) in order to enable device messaging. The application (APP) layer is open for developers to make use of as they deem fit, with Thread being able to support several low bandwidth APP layer protocols that run over IPv6. An example of a wireless mesh network with IP connectivity in Thread is shown in Fig. 2.1b.

(a) Thread communication stack (b) Thread wireless mesh network

Figure 2.1: Thread - a new wireless networking protocol, adapted from [11].

There can be four types of devices in a Thread network: border routers (BRs), routers, router-eligible end devices and sleepy end devices (SEDs). Out of the four, it is only SEDs that are battery-operated while the rest are mains-powered. As a result, the focus of this thesis is on the operations performed by a SED that have impact on its battery lifetime. In the presence of more than one router, the Thread stack supports mesh topologies. The mesh is reduced to a star topology

6 when there is only one router in the network, which provides connection to the end devices. In the studied implementation of Thread [12], which is used in the devices through- out the degree project, the constrained application protocol (CoAP) is employed in the APP layer. CoAP is a compact web transfer protocol, similar in nature to the hypertext transfer protocol (HTTP), intended for resource-constrained devices participating in low-power and lossy networks (LLNs) [13]. Additional information about CoAP is provided in Section 2.2; it describes the types of messages that are usually exchanged among nodes participating in a Thread network. Moreover, the mesh link establishment (MLE) protocol is used in Thread [12], which is respons- ible for the establishment and dynamic configuration of secure radio links in IEEE 802.15.4 networks with mesh topologies [14]. A duty-cycled sensor node, which in the context of Thread is a SED, is a host device that can communicate with the rest of the mesh network solely via its parent (active router), which is responsible for holding packets destined for it and for forwarding messages to/from the mesh network [15]. Such a device is in a deep sleep mode for the majority of its operational cycle. Otherwise, an active mode is resumed, which can occur at regular intervals of different duration. During a polling event that is repeated once every χ milliseconds (ms), battery-operated devices wake and check their parent’s status about incoming packets. Depending on whether there are any further transactions that need to take place or not, the duration of this polling event is extended or shortened. In the subsequent sections (2.2 - 2.5), a short overview of the protocols and stand- ards that are employed in each layer of the Thread stack is provided. By using a top-to-bottom approach, CoAP is introduced in the beginning to start with the application layer, and the parts of the IEEE 802.15.4 standard (MAC and PHY layer) pertinent to Thread are described at the end.

2.2 CoAP

The resource-restricted nature of low-power and lossy networks is in need of a protocol that can provide generic web services suited for the demands of devices participating in machine-to-machine (M2M) applications in the field of HBA as well as other related fields [13]. CoAP is a compact protocol that is characterised by an interaction process between entities resembling the one that is encountered in HTTP, namely the client/server model. The communicating parties in a CoAP implementation interact by assuming the role of either a client or a server, and in various occasions these roles are interchanged.

7 There are certain type of messages that are commonly exchanged in a request/re- sponse manner between the client-node and the server-node. The request messages or methods as defined by CoAP are: • CoAP GET: with the GET method the client acquires a representation for the information that it is interested in. For instance, it might wish to retrieve the temperature or humidity data from the node that is currently monitoring the corresponding phenomena. • CoAP POST: the POST method entails that the information included in the request be processed by the server’s side. For example, the client requests the recipient to turn their LED switch on/off, and in order for that to happen the message needs to be processed. • CoAP PUT: the PUT method involves the update or creation of a resource based on the enclosed information in the message. The resource can be an old address in need of modification or a new multicast group address. • CoAP DELETE: the DELETE method requests the removal of the resource identified by the request. The request messages can be either acknowledged or left unacknowledged; these messages are called confirmable (CON), and non-confirmable (NON) respectively. In the confirmable case, the response of the recipient is usually piggybacked in the acknowledgement.

2.3 IPv6

IoT promotes a vision of information ubiquity that is achieved by the collaboration of many heterogeneous elements and their respective networks. The size of IoT is escalating at a high rate, thus necessitating a sufficiently large addressing space that can sustain the need for unique identification and addressing of a plethora of smart things. To address the vast amount of things that will populate the IoT market, IPv6 is an indispensable and integral part. It is common knowledge that the IPv4 address space has already been depleted; it has been exhausted since February 2001 [16]. With IPv4 no longer a viable op- tion, the addressing constraints have been alleviated with the introduction of IPv6, which can provide up to 2128 addresses. IPv6 includes a subspace of addresses that should be sufficiently large to uniquely identify all the emerging devices of IoT for many years to come. For that reason, IPv6 is considered to be a pivotal enabler of IoT, thus rendering it imperative for IoT devices to have IPv6 functionalities that facilitate smooth and transparent Internet communication. Thus far, incor- porating IP connectivity capabilities in WSN devices has been a difficult task for a handful of reasons. However, a general direction towards establishing native

8 support for IP in the field of WSNs has been recently identified as a prosperous step for the future of communication technologies with respect to home and build- ing automation systems [17]. As a result of the transition from non-IP, a new term arises - native IP (NIP) - that entails a novel form of connectivity for the resource-constrained devices with multifold benefits. These benefits range from in- teroperability facilitation up to expedited access to the assets that the fast-paced evolution of the Internet domain involves.

2.4 6LoWPAN

Sensor devices are proliferating in various IoT implementation scenarios and a great deal of these devices are equipped with IEEE 802.15.4 radios. The commu- nication among them is facilitated due to the use of the common radio frequency (RF) connectivity protocol. However, the growing demands of the HBA field ne- cessitate a universal form of connectivity that can be achieved with the adoption of IPv6, which can provide not only device communication but also cloud access services, and user interaction through mobile applications. This need is covered by the 6LoWPAN layer, which is considered an adaptation layer that lies between the IPv6 network layer and the IEEE 802.15.4 link layer [18,19]. The transmission of IPv6 packets over IEEE 802.15.4 links, if not properly handled by 6LoWPAN, faces certain challenges. IPv6 requires that a maximum transmis- sion unit (MTU) of 1280 bytes is satisfied as regards packet sizes. On the other hand, IEEE 802.15.4 has set the value of 127 bytes as the maximum size for the PHY service data unit (PSDU), which is the PHY payload carrying the MAC frame to the PHY layer. The MAC payload is further reduced in available size depending on the communication overhead. The 6LoWPAN adaptation layer implements some mechanisms in order to resolve the issues involved with the interoperability between IPv6 and IEEE 802.15.4. These mechanisms are: • IPv6 packet fragmentation and reassembly: the large IPv6 packets are frag- mented at the transmitter’s side and reassembled at the receiver’s side; • IPv6 header compression: compression of IPv6 and UDP headers are also handled by 6LoWPAN to reduce the size of frames being transmitted over- the-air (OTA), which also assists in energy conservation; • Link layer packet forwarding: for the purpose of forwarding packets in a multihop mesh network, Thread employs the link layer forwarding capability of 6LoWPAN by employing IP layer routing without sending the packets up to the network layer.

9 2.5 IEEE 802.15.4

As already mentioned, the IEEE 802.15.4 specification is used for the two un- derlying layers of the Thread stack. Specifically, the 2006 version [20] of it is employed for its channel access and congestion control mechanisms as well as for the fundamental command and data frame management. There are mainly three packet formats that are exchanged for the communication among the chil- dren (end devices) and the parent (border or active router): a MAC command frame for polling the parent, a data frame for transmitting messages along with acknowledgement (ACK) frames for confirmation of successful receptions.

2.5.1 Carrier sense multiple access with collision avoidance

In Thread, all nodes employ the unslotted, nonbeacon-enabled and contention- based medium access method of carrier sense multiple access with collision avoid- ance (CSMA-CA). The CSMA-CA algorithm is used prior to the transmission of MAC command or data frames with the exception of ACK frames. Fig. 2.2 is a flowchart representing the procedure for channel access and frame (re)transmission that is encountered in CSMA-CA. In preparation for a frame transmission, the source node is required to follow the CSMA-CA mechanism. The process involves initializing certain parameters: the number of backoffs (NB) in CSMA-CA, the value of the backoff exponent (BE), which is set equal to macMinBE, and the number of retransmissions (R). The algorithm proceeds by selecting a random number of unit backoff periods in the range (0, 2BE-1] to delay the channel sensing using clear channel assessment (CCA). If the channel is sensed idle, it continues with the data transmission. Otherwise, NB increments and the range of random backoff period increases as well because the new BE value is de- termined by min(BE+1, macMaxBE). The channel access attempts are repeated every time the channel is sensed busy until NB exceeds the maximum number of CSMA backoffs, which ultimately leads to channel access failure. The secondary part of the flowchart involves the data transmission stage. After transmitting a frame, the sender waits up to a maximum (macAckWaitDuration) amount of time (the attribute is defined by IEEE 802.15.4) in order to receive the link layer ACK. The lack of ACK arrival within the specified time signifies the occurrence of frame collision, which triggers link layer retransmissions. With every retransmission, NB and BE are initialized and follow the CSMA-CA algorithm until successful packet transmission. If the same frame is retransmitted for more than macMaxFrameRetries, a data transfer failure is declared and the frame is discarded. The most pertinent MAC attributes for the understanding of the CSMA-CA al- gorithm are listed below and they have the following default values, which are

10 Figure 2.2: Flowchart for the channel access in the unslotted case of CSMA-CA consid- ering packet transmissions and retransmissions, adapted from [20]. obtained from the 2006 version of [20]: • minimum backoff exponent: macMinBE = 3 • maximum backoff exponent: macMaxBE = 5 • maximum CSMA backoffs: macMaxCSMABackoffs = 4 • maximum MAC retransmissions: macMaxFrameRetries = 3 Let β be the number of backoff periods that a node has to wait before performing a CCA. The value of β is equal to 2BE −1, where BE ranges from one to macMaxBE.

11 A unit backoff period duration in symbols is 20 and the following equation converts the backoff delay from symbols to milliseconds (ms).

20 ⋅ β 20 ⋅ β tbackoff = = ms (2.1) 62.5 ⋅ 103 62.5 where 62.5 is the symbol rate measured in ksymbol/s associated with the 2450 MHz PHY in IEEE 802.15.4 and β is the amount of 20-symbol unit backoff periods. For instance, BE values equal to 1 and 5 result in tbackoff equal to 0.32 ms and 9.92 ms respectively. It has been studied in [21] that the selected MAC attributes can have a big impact on energy efficiency, latency, and reliability. According to the paper, a larger minimum backoff exponent (default macMinBE = 3) leads to fewer collisions in the initial backoff stages as well as it reduces the per-packet energy consumption, while an increased amount of backoffs improves general reliability.

2.5.2 Busy channel and collision probability

It can be seen in Fig. 2.2 that there are two probabilities involved in the channel access and data transmission process; these are the busy channel and collision probability that are denoted by αbusy and pcol respectively. Each time a net- work node wishes to access the channel, there is an inherent uncertainty regarding its success. This is expressed by the busy channel probability, which essentially controls the incidence rate of CSMA backoffs. As regards retransmissions, they are caused either because the transmitted frame collided and it never arrived at the destination, or the ACK frame was not received by the source. The related probability is pcol, which regulates the occurrence of collisions and the need for retransmissions.

2.5.3 Duty cycling mechanism

Periodic wake-ups have been used in various wireless protocols to achieve energy efficiency because it has been observed that idle listening to incoming packets in a wireless medium leads to energy waste [22]. In order to alleviate this issue, numerous duty cycling MAC protocols have been proposed, which can be separ- ated into a number of categories and sub-categories. There exist synchronous and asynchronous duty cycling mechanisms depending on the need for synchroniza- tion among the neighbouring sleepy devices or lack thereof. Furthermore, these techniques can be divided into contention-based or contention-free MAC, which is determined by the method for accessing and utilizing the medium resources. The last classification is according to the side that instigates the communication, thus leading to transmitter-initiated or receiver-initiated MAC protocols. A detailed discussion of these categories is presented in [22].

12 The sleepy end devices in Thread employ an asynchronous, contention-based duty cycling mechanism that is receiver-initiated. The SEDs in a Thread network wake up periodically using a fixed wake-up period and they are not required to syn- chronize their schedules with one another to avoid collisions. Instead, in order for them to access the medium and transmit the required MAC command frame to the parent, they contend with their neighbouring devices using the CSMA-CA mechanism. Furthermore, the communication is always commenced by the side of the duty-cycled node. In any subsequent data transaction with the parent device (PD), the SED acts as a receiver awaiting for data to be transmitted by the par- ent. More details about these transactions between SED - PD are provided in the following chapter.

2.6 Related Work

In this section, previous work in generic and specific battery lifetime models is reviewed, and literature regarding the modelling of CSMA-CA using Markov chains is briefly discussed.

2.6.1 Battery lifetime models

As the fundamental topic of this thesis is to perform a battery lifetime analysis on a sensor node by identifying and modelling the operations that take place during a communication session, and to quantify their impact on energy consumption, there are several research papers that tackled with similar issues before this current at- tempt. A few generic energy models are proposed in [23] and [24] for diverse cyber- physical systems. Wang et al. [23] identify the wireless communication module as the primary energy squanderer and therefore employ an alternative sampling tech- nique, called compressed sensing, which disregards the notable Nyquist sampling theorem, to provide a considerably lower power consumption. Their novel proposal is intended for applications within wireless body sensor networks and the energy model is the result of the multiplication of three parameters: the sampling rate, bit resolution, and energy per bit of the communicated data - hence it mainly evaluates the units of a sensor node concerning the aspects of data acquisition and communication. For the purpose of a smart parking application, the work in [24] presents an energy consumption model in which the estimated lifetime derived from the device is intended to be predetermined and fixed. Ultimately, the goal is not to maximize the longevity of the battery-powered sensors but to prioritize the sensing accuracy. The basic energy expenditures that are considered stem from the collection of the samples and the single-hop communication. The proposed energy dimensioning in neither paper is adopted to a specific wireless technology, which leads to lack of detailed communication parameter estimations.

13 In [25], energy profiling schemes introduced by others are assessed and their ef- fectiveness put to the test by deploying off-the-shelf sensors, and by acquiring both short and long-term measurements. A case study involving a low-data rate WSN application is described, in which the long-term energy monitoring resulted in identifying the severe impact of sink node failures on the lifetime of battery- powered nodes that led to extreme battery depletion in cases of sink node outages. In [26], Ren et al. put forward an energy consumption and total network lifetime model in which they consider a multi-hop WSN environment where sensors that rely on batteries for their operation, collect measurements and use data periods to transmit the information to a sink employing a collision-free MAC protocol. The total network lifetime is estimated with a small error rate, and they have addition- ally considered the emergence and effect of energy holes in WSNs. The efficiency of the model is verified using simulations in OMNET++, but no experimental validation using real hardware and real-life network conditions is provided. Martinez et al. in [27] and [28] view the issue of energy dimensioning for IoT devices from a system-wide standpoint, covering all aspects from data acquisition, and processing to data communication, and system management. Their model covers point-to-point communications for sensor nodes with a fixed or variable data update periods. It is based on a simplified version of MAC (ideal channel conditions, no interference, no congestion) with the addition of opportunistic re- transmissions. The model estimation of various factors affecting energy efficiency is obtained through simulations and validation is provided using real hardware.

2.6.2 Markov chain modelling of CSMA-CA

There is a great deal of papers with topics related to analytical models of the CSMA-CA scheme as a channel access mechanism for nodes in wireless networks. On account of that both IEEE 802.11 and IEEE 802.15.4 employ a similar MAC technique for carrier sensing and frame transmission, the modelling of the network traffic in either case can be applied to the other by using few adjustments. In par- ticular, [29] presents an analytical model of the distributed coordination function (DCF) scheme in IEEE 802.11 under the assumption of saturated traffic and ideal channel conditions. Bianchi is the original contributor of the Markov chain model for the CSMA-CA scheme in IEEE 802.11, which led to numerous extensions of this work with respect to various quality-of-service (QoS) metrics for networks that employ either the IEEE 802.11 or the 802.15.4 CSMA-CA algorithm. As energy efficiency is of the essence in this degree project, the following work studied the CSMA-CA considering also the power consumption of 802.15.4 nodes in the network. The authors in [30] provide a three-dimensional Markov model of the slotted CSMA-CA reviewing only saturated traffic conditions. They propose modifications in order to achieve optimal design. For instance, it is argued that

14 the double carrier sensing is redundant because a single CCA can have the same effect on collision avoidance while the energy consumption is decreased. Sahoo and Sheu in [31] study the same topic as [30] but for unsaturated traffic conditions, as is the norm for the low data rate wireless personal area networks (WPANs) that operate customarily under light or medium network load conditions. However, the analytical results acquired from the three-dimensional discrete time Markov chain model and the ones obtained from simulation exhibit a poor match quality. An aperiodic traffic pattern in a single-hop star network is studied in [32] from a power consumption perspective. The study is based on the IEEE 802.15.4 MAC and it examines the effect of the MAC parameters, such as CSMA backoffs, and retransmissions, on energy consumption. The adaptive parameter setting of IEEE 802.15.4 is implemented and validated on a hardware platform. The authors claim that the power consumption of a sensor is not substantially influenced by the MAC retransmissions and the amount of backoffs needed to access the channel. In this work, the processes that occur in the IEEE 802.15.4 MAC are examined with respect to the operation of a duty-cycled end device in Thread, which employs child polling and exchanges request/response messages with its parent device using CoAP in the APP layer. The ultimate objective is to provide a viable energy dimensioning of battery-operated devices in Thread.

15 Chapter 3

Battery Lifetime Model

In this chapter, an analytical model for the battery lifetime of a duty-cycled node in Thread is presented, followed by the introduction of the implementation process in MATLAB and the experimental validation.

3.1 CSMA-CA in IEEE 802.15.4

If the small network consisting of the active router - being the parent - and all the connected end devices - acting as children - is isolated from the rest of the Thread mesh network, it is evident that the created sub-network forms a star topology. In such a topology, all nodes have a 1-hop distance from the PD that assumes the role of a central point providing the sole means for connectivity to the rest of the mesh network. This observation proves helpful to model the busy channel and collision instances that might transpire in a star network. It can be argued that the mesh network topology of Thread can be approximated with a star topology under the assumption that the end devices are detached from the mesh network, if no link to it is provided by the parent device. For that reason, the work introduced in [32] and the derived equations prove helpful in supplying the groundwork for the battery lifetime modelling as regards the mechanism the nodes employ to access the channel and contend with one another. In [32], a generalized Markov chain is proposed that serves as a model for the MAC traffic in a single-hop IEEE 802.15.4 network consisting of N devices that communicate with a personal area network (PAN) coordinator. The N devices contend to transmit data to the PAN coordinator that serves as a data sink in a star network and it is also assumed that no hidden terminals exist. The nodes generate packets in an asynchronous manner with a probability 1-ρ after a successful packet transmission, or data transfer failure due to packet collision, or channel access failure. If there is no packet generation, the nodes stay in idle state

16 for a duration of L0Sb seconds with probability ρ, where Sb is the unit backoff period and it is equal to 20 symbols while L0 is an integer multiple of the unit backoff period. The frame transmission is considered to be completed if a MAC ACK is received, otherwise it is assumed that a collision has occurred. The duration of the successful frame transmission and the one of the collided frame have the following forms respectively:

Ls = L + tack + Lack + LIFS (3.1) Lc = L + tmacAckWaitDuration (3.2) where L is the length of the data packet, tack is the acknowledgement waiting time between aTurnaroundTime ≤ tack ≤ aTurnaroundTime+aUnitBackoffPeriod [20], Lack is the length of the ACK frame, LIFS is the long interframe spacing (minimum value of 40 symbols), and tmacAckWaitDuration is the ACK timeout. Ls and Lc are defined as multiples of Sb. The long interframe spacing is used instead of the short one because the frames being exchanged have a length above 18 bytes, which is the limit of SIFS according to the standard in [20]. The notations L0,Ls, and Lc are of importance for the understanding of the equations that are presented subsequently. The slotted version of CSMA-CA with retransmissions and ACKs is considered in [32], resulting in a three-dimensional Markov chain. A modified and simplified version of the chain is presented in Fig. 3.1 for the unslotted case of CSMA-CA with single carrier sensing instead of double CCAs. The Markov chain is characterized by three stochastic processes s(t), c(t) and r(t), which represent the CSMA backoff stage (i), the random backoff period selection (k), and the retransmission counter (j). In Fig. 3.1, the triad (i,k,j) describes the state of a node when attempting channel access and frame transmission. The following notations are used for the most pertinent MAC attributes, which are also mentioned in subsection 2.5.1:

• minimum backoff exponent: m0 = macMinBE

• maximum backoff exponent: mb = macMaxBE • maximum CSMA backoffs: m = macMaxCSMABackoffs • maximum MAC retransmissions: n = macMaxFrameRetries

The states (i,W0-1,j) and (i,Wm-1,j) correspond to the maximum backoff period m min(m +m,m ) per backoff stage i, where W0 and Wm are equal to 2 0 and 2 0 b . For instance, if the state (i,W0-1,j) is selected by the contending node, its backoff counter is going to decrement until it reaches the state (i,0,j), at which point a CCA is performed to sense the channel idle/busy. The same procedure is followed by the nodes that sense the channel busy and have to backoff again; the value of the backoff stage i is the one that increments until it reaches m. As regards retransmissions, which are triggered when the channel is sensed idle (1−abusy) but a collision occurs (pcol), the CSMA-CA algorithm is repeated for each retransmission until the nth + 1 time.

17 Figure 3.1: Three-dimensional Markov chain model of the CSMA-CA algorithm in IEEE 802.15.4, adapted from [32].

18 For 0 ≤ i ≤ m, 0 ≤ k ≤ Wi − 1 , and 0 ≤ n ≤ n, the stationary probability with the expression bi,k,j = limt→∞ P (s(t) = i, c(t) = k, r(t) = j) is reduced to Eq. 3.3 by taking into consideration the state transition probabilities that are associated with the Markov chain. A comprehensive list of the equations linked to the state trans- ition probabilities is given in [33] for the slotted CSMA-CA. By replacing β, which is the second carrier sensing, with zero and adjusting accordingly all necessary equations, it is possible to acquire the busy channel and collision probabilities for the unslotted CSMA-CA. Detailed proofs of the equations that follow are provided in [33].

Wi − k bi,k,j = bi,0,j (3.3) Wi

⎧ m +i ⎪2 0 , 0 ≤ i ≤ mb − m0 Wi = ⎨ ⎪2mb , otherwise ⎩⎪ m j i i bi,0,j = (1 − αbusy) ⋅ pcol Q αbusy αbusy ⋅ b0,0,0 i=0

With the aid of the normalization condition ∑i ∑k ∑j bi,k,j = 1 and the derivation of the constituent terms in the expression, b 0,0,0 is obtained from Eq. 3.4.

−1 b0,0,0 = (y1 + y2) (3.4) m+1 1 αm+1 1 − (2αbusy) − busy m+1 y1 =  ⋅ W0 + + (1 − αbusy)(1 + Ls(1 − pcol) + Lc ⋅ pcol) ⋅ y0 2(1 − 2αbusy) 2(1 − αbusy)

L0 ⋅ ρ n+1 y2 = ⋅ (1 − y) ⋅ y0 + y  1 − ρ n+1 m+1 n+1 1 − pcol (1 − αbusy) y0 = m+1 1 − pcol(1 − αbusy)

m+1 y = pcol(1 − αbusy)

The probability that a node attempts CCA at a random time unit is given by Eq. 3.5, and it is assumed that the sensing probability is independent of other nodes.

m n 1 αm+1 n+1 − busy 1 − y τ = Q Q bi,0,j = Œ ‘ ‹  b0,0,0 (3.5) i=0 j=0 1 − αbusy 1 − y

It can be observed that τ depends on the collision probability pcol and busy channel probability αbusy. These are essential aspects for the battery lifetime model because they determine the likelihood of retransmissions and CSMA backoffs in a similar network setup such as the one modelled by the Markov chain in Fig. 3.1. The collision probability can take two forms depending on whether packets are lost

19 solely because of collisions with other transmitted packets (see Eq. 3.6) or bad channel conditions can also contribute to the need for retransmissions (see Eq. 3.7). The bad channel probability p is added as a new term to the collision probability plus the probability of a transmitted packet to collide in the good channel (1-p) with a packet transmitted by the N-1 remaining devices in the network. Eq. 3.7 defines the alternative version for the collision probability that is denoted by the subscript alt. In spite of introducing the alternative version, it is not used in the battery lifetime model that is proposed in this degree project.

N−1 pcol = 1 − (1 − τ) (3.6) N−1 palt = (1 − (1 − τ(1 − p)) )(1 − p) + p (3.7)

The term αbusy is composed of the probabilities for busy channel during CCA due to data transmission (α1), and due to ACK transmission (α2). On account of two versions of the collision probability, there are two different forms for the busy channel probability as well.

αbusy = α1 + α2 or αbusy = α1alt + α2alt (3.8) N−1 α1 = L(1 − (1 − τ) )(1 − αbusy) (3.9) N−1 N ⋅ τ(1 − τ) α1 α2 = Lack ⋅ ⋅ (3.10) 1 − (1 − τ)N L N−1 α1alt = L(1 − (1 − τ(1 − p)) )(1 − αbusy) (3.11) N−1 N ⋅ τ(1 − p)(1 − τ(1 − p)) α1 α2alt = Lack ⋅ ⋅ (3.12) 1 − (1 − τ)N L

This part brings to completion the description of the necessary parameters to account for the considerable variability in time that stems from the random backoff delay, and the occurrence rate of CSMA backoffs as well as retransmissions in an IEEE 802.15.4 network. For further details about the terms and the derivation of the equations, please refer to [32–34].

3.2 SED operations in Thread

In this section, the application of CSMA-CA in Thread is presented by describing all the aspects of SED operations in which the algorithm appears. Furthermore, by observing the current consumption waveforms, it is possible to identify the way the CSMA-CA scheme affects the duration and current consumption of these operations. Let us recap the fundamental functionality of the sleepy device in Thread. Due to the fact that SEDs run on batteries, they remain in dormant state for the

20 majority of their deployment cycle. In a periodic manner, the SEDs wake up from their dormant state and perform certain operations; such an incident is called a polling event. This event is repeated once every Tpoll milliseconds and its duration varies determined by the need for further transactions between the communicating parties, namely the SED and PD, or lack thereof. Every time a sleepy end device wakes up, it transmits a Data Request MAC command frame to the parent awaiting a link layer acknowledgement. If the frame pending bit in the ACK is set to true, then there is data to be followed. Otherwise, this indicates the lack of upcoming frames. With the distinction of the frame pending bit, the main SED events that take place are categorised into data polling and no-data polling events respectively. Table 3.1 illustrates the packets that are exchanged between child and parent device with detailed information about the type of packets and their sizes along with source and destination addresses; this information is acquired with the aid of a packet sniffer and its captured packets. The short MAC address of the PD is 0x0000 and the address of the SED is 0x0001. The previously mentioned Data Request MAC command frame and its corresponding ACK (ID: Aa) have the fixed lengths of 22 and 5 bytes respectively. These exchanged frames appear in every wake-up cycle no matter the type of the polling event. The frame sequence with the ID Aa can be followed by a confirmable or non-confirmable CoAP com- mand (see Section 2.2). For the sake of demonstrating a typical case, Table 3.1 outlines a complete transaction between SED and PD - the so-called data polling event. The CoAP GET CON and the CoAP ACK packets are always followed by link layer acknowledgements (IDs Bb and Dd), and they can have variable sizes. The application layer packet lengths used in this example, that is ID B with 73 bytes and ID D with 68 bytes, correspond to a payload of approximately 10 bytes.

Table 3.1: Exchanged packets between child and parent device

id stack layer length packet src dst A thread MAC 22 bytes data request 0x0001 0x0000 a thread MAC 5 bytes link layer ack B thread CoAP 73 bytes get con 0x0000 0x0001 b thread MAC 5 bytes link layer ack C thread MAC 22 bytes data request 0x0001 0x0000 c thread MAC 5 bytes link layer ack D thread CoAP 68 bytes app layer ack 0x0001 0x0000 d thread MAC 5 bytes link layer ack

21 In Fig. 3.2, the Markov chain represents the governing (sequence of) events that transpire in a Thread network with respect to usual SED operations. To be more specific, the chain is regarded as a semi-Markov process because the inter-arrival and service times do not follow an exponential distribution. The packet IDs and the packet exchange order, which are shown in Table 3.1, are also indicated in the generalized Markov chain to facilitate the understanding of the content of each state. The no-data polling event, which constitutes the vertical part of the chain with ID Aa and arrival rate /service time λ0~µ0, is straightforward and the same pattern is repeated with respect to length and sequence of MAC frames, if we disregard the randomness of CSMA-CA. The data polling events, however, can take many forms. For instance, if the CoAP packet that is received in Bb is not confirmable and there is no need for a response, then the event will stop at Cc. Another example is the case when fragmentation is needed either for the reception or transmission of a packet. In such a case, Bb with different packet lengths and Cc are repeated until the whole message from the parent device is received, or Dd with different packet lengths is repeated until the full response of the SED is transmitted. A representative case of a data polling event is depicted in the horizontal part of the Markov chain with IDs Aa - Dd, and it takes into consideration all essential features for the derivation of the battery lifetime model.

Figure 3.2: Markov chain for the main events taking place in a Thread network as regards SED operations.

Regarding the arrival rates and service times, it is evident that the value of λi at each stage differs and µi is also variable depending on the size of the packets being transmitted and received. For reasons of associating each λ and µ to the respective state, different notations are used. However, certain arrival rates in states remain the same. For example, λ0 and λ1α are the same because no matter what event is about to follow, when the SED wakes-up, it always transmits the Data Request awaiting for a link layer ACK. The service times, on the other hand differ, due to larger packet lengths in the data polling case. The arrival rate of the second MAC Poll (ID Cc) has a higher value than λ1α. The reason for this is because once

22 the SED has received the CoAP packet, on all occasions, it proceeds by double- checking whether there is more data to receive from the PD. The service times µ0 and µ1β are alike due to identical frame lengths. Last but not least, the arrival rate λ2 and service time µ2 can vary depending on the need for application layer acknowledgement or not, and the packet size of the SED response. The following text sheds more light on the transitions from the sleeping state into the no-data or data polling states, and what they entail. Next, the attention is turned to the aspect of the current consumption during the wake-sleep cycle of a SED. The stages through which the SED goes, starting from the instance it wakes up from deep sleep until it returns to the same state, after having completed some sort of operation, are depicted in Fig. 3.4. In order to be CurrentCurrent waveform consumption of no-data- Data polling polling able60 to draw a comparison between data and no-data polling events, the current waveform in Fig. 3.3 refers to the latter case. The stages of the data polling event are listed and briefly explained in the following text. Current waveform of no-data polling 50 Current waveform of no-data polling 3 40

30 2 10

20 Current consumption in mA

Current consumption in mA in consumption Current 10 1 11 12 0 -15 -105 10 -515 020 525 1030 15 TimeTime in msms Figure 3.3: Stages of current consumption during a no-data polling event of a sleepy end device. stage 1: In the first stage, a start-up sequence is activated that stops the low- power timers, which control the sleeping and waking process of the SED, and wakes up the microcontroller unit (MCU) to start the analog-to-digital converter (ADC) and acquire some measurements.

23 Current waveform of data polling by a sleepy end device 45 3 4 5 7 9

40

35

30

2 8 25 6 10

20

15

10 Current Consumption in mA 1 11 5 12 0 0 10 20 30 40 50 60 Time in ms

Figure 3.4: Stages of current consumption during a data polling event of a sleepy end device. stage 2: Stage 2 is initiated with the inrush current, which is followed by the sleepy end device deferring for a random period of time when it performs step 1 in the CSMA-CA flowchart (see Fig. 2.2). stage 3: Stage 3 contains the radio initialization, which is followed by the device going into receive (Rx) mode and performing a CCA (step 2 in the CSMA-CA scheme). Then, the sensor device switches to transmit (Tx) mode to transmit a Data Request IEEE 802.15.4 MAC command frame to the PD and goes back to Rx mode to wait and receive the link layer acknowledgement. The reception of the MAC ACK (link layer ACK) indicates whether there is data being held in the buffer of the parent to be retrieved by the SED or not. If PD replies with ACK frame pending set to false, no further data follows. stage 4: If the frame pending bit in the corresponding field of the ACK frame is set to true (1), the PD has data to transmit, which leads to the CoAP packet reception that is shown in stage 4. stage 5: In 5, the child sends a link layer ACK to the parent to acknowledge the 1-hop successful reception of the foregoing packet. stage 6: The stages that follow include a series of actions that have as purpose the transmission of the SED’s response, which is piggybacked in a CoAP ACK. Before sending the reply, the sleepy node performs another session of MAC polling, which starts with the random backoff delay and is followed by a CCA, as shown in stage 6.

24 stage 7: A Data Request frame and a MAC ACK are exchanged to ensure no further data is to be received from the parent device. stage 8: The node performs CSMA-CA one last time and delays for random unit backoff periods before sensing the channel. stage 9: After the channel is sensed idle, the CoAP ACK packet transmission commences, which is concluded with a 1-hop link layer acknowledgement. stage 10: The application layer ACK is processed and the buffer is released. Meanwhile the transceiver changes from active state back to doze. stage 11: While awaiting all tasks to be in idle state, the SED goes gradually to deep sleep mode. stage 12: This stage refers to the deep sleep state, during which the MCU is in deep sleep mode and the transceiver is in a so-called hibernation mode. It can be noted that the current levels and waveform vary based on the task that is being handled during each time instance. Furthermore, it is apparent that the wireless transceiver operation has the highest current consumption.

3.3 Basic model

In this section, the intricacies of the SED battery lifetime model in the studied implementation of Thread are discussed, and a set of equations is provided to describe the primary SED tasks that take place during a full operational cycle.

During a SED operational cycle, there exist currents (Ii) associated to the most prevalent activities being executed by the battery-powered sensor devices. These are the following:

• Isleep: the sleeping current refers to the current consumption of a duty-cycled node during its deep sleep mode when only the low-power timers for wake-up scheduling are running while the rest of the circuitry is off.

• Inhk: the network housekeeping current is associated with the current con- sumption of no-data polling events, meaning that the node wakes up and sends a Data Request MAC command but no further data follows. These periodical frames serve as keep-alive messages by the child device to PD, which are necessary for parent-child connection maintenance.

• Iopt: the operational current corresponds to the data polling events during which application layer packets of variable size along with their acknowledge- ments are exchanged.

25 For the purpose of modelling the battery lifetime, it is essential to express the current consumption and time duration of all the implicated tasks relevant to the acquisition, communication, and processing aspects of the SED wake-sleep cycle. The following equations provide a condensed version of the model with respect to the current consumption expressions encountered in no-data polling and data polling events according to the Markov chain presented in Fig. 3.2. The notations that are used and a short description is provided in Table 3.2.

IMCP refers to the current consumption of stages 3 and 7, during which a Data Request frame is transmitted by the SED and a MAC ACK is received to indicate a successful frame transmission. The current consumption of the stages 1 (I1a), 10 (I1b), and 11 (I1c) are fixed and repeated every time at the beginning and end of the SED wake-up cycle. Inhk in Eq. 3.14 refers to the current consumption of the whole waveform depicted in Fig. 3.3. Finally, IOPT in Eq. 3.17 is the final expression of the current consumption of all stages portrayed in Fig. 3.4, which are described in detail in Section 3.2.

Table 3.2: Main symbols used in the battery lifetime model

Symbol Description NB number of CSMA backoffs R number of MAC retransmissions

IMCP MAC polling current

IDRQS Data Request transmission current

IMACK MAC ACK reception current

IRCH random channel access current

ICCA clear channel assessment current

I1a current consumption of stage 1 in Fig. 3.4

I1b current consumption of stage 10 in Fig. 3.4

I1c current consumption of stage 11 in Fig. 3.4

IpktRx current consumption of the CoAP packet reception process

IRx representation of CoAP packet Rx current and MAC ACK

IpktTx current consumption of the CoAP ACK transmission process

ITx representation of CoAP packet Tx current and MAC ACK

Tcycle full operational cycle = 1h

Nnhk amount of network housekeeping events per full cycle

Nopt amount of useful operations per full cycle

26 IDRQS ⋅ tDRQS + IMACK ⋅ tMACK IMCP = (3.13) tMCP

I1a ⋅ t1a + I1b ⋅ t1b + I1c ⋅ t1c INHK0 = tNHK0

[(NB + 1) ⋅ (ICCA ⋅ tCCA) + IRCH ⋅ tRCH + IMCP ⋅ tMCP] ⋅ (R + 1) INHK1 = tNHK1

INHK0 ⋅ tNHK0 + INHK1 ⋅ tNHK1 INHK = (3.14) tNHK

(NB + 1) ⋅ (ICCA ⋅ tCCA) + IRCH ⋅ tRCH + IMCP ⋅ tMCP IpktRx0 = tpktRx0

IpktRx0 ⋅ tpktRx0 + ITx ⋅ tTx IpktRx = (3.15) tpktRx

2(NB + 1) ⋅ (ICCA ⋅ tCCA) + 2(IRCH ⋅ tRCH) + IMCP ⋅ tMCP IpktTx0 = tpktTx0

IpktTx0 ⋅ tpktTx0 + ITx ⋅ tTx IpktTx = (3.16) tpktTx

I1a ⋅ t1a + I1b ⋅ t1b + I1c ⋅ t1c IOPT0 = tOPT0

(R + 1)(IpktTx ⋅ tpktTx + IpktRx ⋅ tpktRx) + IOPT0 ⋅ tOPT0 IOPT = (3.17) tOPT

Isleep = 1 µA, value obtained from chipset datasheet [35] tsleep = Tcycle − (topt ⋅ Nopt + tnhk ⋅ Nnhk) (3.18)

The current level and state duration acquired from Eqs. 3.14, 3.17 in combination with the value of Isleep are substituted in Eq. 3.19 for the sake of obtaining the overall average current consumption. The average current consumption is calcu- lated by multiplying the current and time with the amount of instances that each type of event has occurred. For instance, with an operational cycle of 3600000 ms and a polling interval of 3000 ms, the amount of wake-ups is calculated using

27 W Tcycle , which is equal to 1200. Out of the 1200 SED wake-ups, a portion = Tpoll of them includes network housekeeping events (Nnhk) and the remaining part in- volves operational events (Nopt). If the node is not awake, then it remains in deep sleep mode, hence (tsleep) is determined using Eq. 3.18. The battery lifetime in days with respect to useful operations per hour (q) is derived by applying Eq. 3.20 for every useful operation x from 0 to q.

q q tx tx Iavg = Q( × Ix) + (1 − Q( )) × Isleep (3.19) x=0 Tcycle x=0 Tcycle

Inhk ⋅ tnhk ⋅ Nnhk + Iopt ⋅ topt ⋅ Nopt + Isleep ⋅ tsleep Iavg = (3.20) Tcycle

Battery Capacity [mAh] Battery Lifetime [days] Iavg [mA] (3.21) = 24

3.4 Data collection methods for the model para- meters

In the last section of this chapter, the different techniques, which are employed in order to acquire the necessary parameter values for the construction of the mathematical model representing the battery lifetime of a sleepy end device in Thread, are described.

Theoretical method

As regards the modelling in MATLAB, there are a number of aspects that need to be dealt with. Starting with the CSMA-CA mechanism, the random nature of it is modelled by using the command datasample, which is an efficient method to sample data from a defined data set with or without replacement and it provides optional weighted sampling. For instance, in order to acquire the appearance frequency of each CSMA backoff stage and assuming that macMaxCSMABackoffs = 2, the following syntax is employed:

NB = datasample (NBKF, κ, ‘Weights’, [(1-αbusy) αbusy αbusy]) which samples κ times out of NBKF = [0, 1, 2] using replacement and with prob- ability proportional to the elements of Weights. It can be noted that the sample weights are acquired from the busy channel probability because it is the factor that dictates the channel access retries. In a similar manner, the occurrence rate of retransmissions is modeled as follows:

28 R = datasample (NMAC reTx, κ, ‘Weights’, [(1-pcol) pcol pcol]) where NMAC reTx = [0,..., macMaxFrameRetries] and the weights are proportional to the collision probability due to collisions being the trigger of retransmissions. For reasons of simplicity in illustration, macMaxFrameRetries is also set to 2. Lastly, the duration of the random backoff delay is adjusted to the backoff stage and is initialized to the minimum range with every retransmission. According to the model, the current consumption in one operation per hour and every additional operation is the average of κ code runs. The term κ refers to the amount of samples randomly acquired for the channel access, backoff stage and retransmissions; it lies in the range [100000, 200000] in order to get consistent results. It is worth mentioning that because of the variable arrival rates and service times of the Markov chain in Fig. 3.2, which represents the primary events that occur in a Thread network related to SED operations, the NB and R values are different for each transition with different λi and µi. This observation entails that the network housekeeping events and the operational events have different NB and R values, and the same applies to the different stages during an operational event that require the performance of CSMA.

Measurement-based method

A specific chipset, which is set up as a SED node in Thread, is utilized as a target platform. Accurate and repetitive measurements of a single task, such as the one identified in stage 1 of Fig. 3.4, are performed to establish the time and the current use. The current drawn from the specific process is measured with the aid of a precise current probe connected to an oscilloscope. After a set of measurements is obtained, the average values for time and current consumption are calculated and inserted in the model.

Fixed-value method

The third method includes the fixed values that are obtained from datasheets and specifications. For instance, the value for the sleeping current is directly taken from the NXP MKW2xDxxx datasheet [35]. The Isleep value is substantially smaller compared to the majority of the currents involved; thus, a precise measurement of it is hindered.

Other values

The operational cycle Tcycle in the model is 1 hour and the polling period Tpoll can be adjusted to different values ranging from 125 ms to 3000 ms. The amount of

29 SED wake-ups is determined by Tcycle , and the maximum number of useful oper- Tpoll ations per hour is fixed at 1000 in order to be able to compare the different test cases. Furthermore, in the application layer, CoAP packets of variable payload length can be exchanged up to the value representing the boundary of fragmenta- tion in IEEE 802.15.4 networks. A common battery capacity for WSN applications is in the range of couple thousands milliampere hour (mAh). In this model, the selected capacity is 2200 mAh. After all the values for the average current consumption and duration of each phase in no-data polling or data polling scenarios are collected, the equations describing the processes that take place in the MAC sublayer and APP layer are derived and inserted in the model. The average aggregate cost in time and current is obtained for all executed tasks, and the average battery lifetime with respect to useful operations per hour is attained with the aid of Eqs. 3.19 and 3.21.

30 Chapter 4

Experimental Setup

The purpose of this chapter is to present the experimental design employed in order to collect all data necessary for the implementation and validation of the PCM. In the pages that follow, a thorough description of the experimental setup including both hardware and software is provided, along with details about the data collection techniques.

4.1 Experimental design

Fig. 4.1 illustrates the experimental setup that is employed to perform the tests. The border router is positioned on a desk and a mix of SEDs and end devices (EDs) (exact number is dependent on the test case) are spread around it in an open-plan space in the ABB Corporate Research offices, 1-hop away from the BR. With a Tx power of 0 decibel-milliwatt (dBm), the maximum 1-hop distance for nodes placed on the same floor is approximately 35 meters in Thread. In the deployed network, the 1-hop ranges from a distance of 2 meters up to 15 meters. The end devices are not equidistant from the border router, but they are randomly placed around the office where power sockets are present and within the maximum 1-hop distance. The nodes communicate using channel 11 of the 2450 MHz ISM band.

31 Figure 4.1: Illustration of the experimental setup.

4.2 Hardware/Software The hardware platform for the sensor nodes is realized with FRDM-KW24D512 evaluation boards from NXP. The outline of the board is portrayed in Fig. 4.2 with information about the components and the Input/Output (I/O) headers. The FRDM-KW24D512 boards belong to the KW2xD family and their MCUs are based on the ARM Cortex-M4 CPU core. They have reliable, secure, low-power and high- performance 2.4GHz IEEE 802.15.4 compliant radio transceivers with support for various 802.15.4 protocol stacks, such as Thread, ZigBee, WirelessHART, and ISA 100.11a [35]. As regards the current consumption measurements, the required equipment in- cludes a MDO4104-6 mixed domain oscilloscope and a TCP0030A alternating current/direct current (AC/DC) current probe from Tektronix. The current from the board is measured using the probe that is attached to the oscilloscope; the configuration is depicted in Fig. 4.3a.

32 Kinetis Thread Development Boards (a)

Figure 7.(b) FRDM [35] -KW24D512

6.2 USB-KW24D512 Figure 4.2: FRDM-KW24D512 boards The USB-KW24D512 board is a USB dongle format board based on the KW2xD family device MKW24D512. It uses the on-chip USB port on the33 MKW24D512 to communicate directly to USB host

Kinetis Thread Stack Demo Applications User’s Guide, Rev. 1, 03/2016

16 Freescale Semiconductor, Inc. Freescale Confidential Proprietary. Non-disclosure Agreement Required. (a) (b)

Figure 4.3: Measurement and testing equipment (a) oscilloscope and current probe at- tached to the SED (b) the router, namely the parent device, being controlled from the shell.

The source code for each device role in Thread is implemented in IAR Embedded Workbench for ARM (version 7.60.2) and once compiled, it can be downloaded to the NXP boards using a USB port. All Thread devices, apart from SEDs, can be connected via one of their USB ports to a PC using a shell command line interface (see Fig. 4.3b). The shell interface is used to send different commands, such as create or join a network, send CoAP commands, and configure simple parameters.

34 4.3 Validation environment

The validation set is created by means of oscilloscope measurements, which has an acquisition mode that performs waveform averaging over multiple sequences of the same executed operation. With a stable oscilloscope trigger, the duration and the mean current consumption are measured from the average waveform capture. As can be seen in Fig. 4.4 that provides a demonstration of the way average measurements are obtained, the mean duration of the no-data polling event is 53.87 ms and the average current consumption is the mean measurement between the linked cursors (141.6 mA) divided by 30. The current probe is attached to a copper wire that is connected to the J40 cut- trace header of the FRDM-KW24D512 evaluation board (see Fig. 4.2a). The wire has 30 windings in order to amplify the involved currents by the same amount, with the ultimate objective of acquiring more precise measurements with respect to very low current levels (below 1 mA). For that reason, the current levels in the oscilloscope screen are in the range of hundreds mA.

Figure 4.4: Oscilloscope capture of the averaging operation over 32 waveforms for the case of no-data polling event in Thread.

35 Chapter 5

Performance Evaluation

The test cases for the evaluation of the model are described in this chapter, fol- lowed by the verification of the model. The efficiency of the proposed model in predicting the battery lifetime of a SED in Thread is validated using the valida- tion environment and a specific metric to acquire the error rates. Finally, a concise summary of the acquired results is provided.

5.1 Test Cases

In order to evaluate the robustness of the model under various network conditions, different test cases are employed, which are listed below: • Network scenario 1 (NS1) with N nodes (small network): low traffic with burst mode on during which packets are transmitted at every wake-up in- stance for SED0 and the remaining N-1 end devices perform no-data polling asynchronously compared to the schedule of SED0. • Network scenario 2 (NS2) with X > N nodes to realize a large network: low traffic with burst mode on and a setup similar to NS1. • Network scenario 3 (NS3) with N nodes (small network): high traffic with burst mode on during which packets are transmitted at every wake-up in- stance for SED0, and half of the remaining N-1 end devices perform no-data polling while the other half receive and acknowledge CoAP packets every 100 ms.

• Network scenario 4 (NS4) with X > N nodes to realize a large network: high traffic with burst mode on and a setup similar to NS2. The same amount of end devices as NS3 receive and acknowledge CoAP packets every 100 ms. The selected values for N, and X are five, and ten respectively. The amount of end devices added to create additional load in test cases NS3 and NS4 are two.

36 Furthermore, different polling intervals are tested and validated to identify the effect the wake-up frequency has on the average current consumption and hence battery lifetime. Apart from variable Tpoll, scenarios with increasing CoAP pay- load size are studied as well.

5.2 Validation metric

For the purpose of computing the prediction errors, and validating the efficiency of the model with respect to battery lifetime estimation, the evaluation metric normalized mean absolute error (NMAE) is employed, which is equal to:

q 1000 1 1 (i) (i) 1 1 (i) (i) NMAE = ( Q Syosci − ymodelS) = ( Q Syosci − ymodelS) (5.1) y¯osci q i=1 y¯osci 1000 i=1 where ymodel contains the model-predicted values, whereas yosci andy ¯osci contain the values from the validation set. The absolute difference of the model-predicted, and the oscilloscope-measured value is calculated for increasing amount of use- ful operations/hour i until the maximum value q=1000. Then, the mean value of the absolute difference is obtained and normalized with respect to the mean oscilloscope-measured battery lifetime. The MATLAB code for the calculation of NMAE is run 250 times. Afterwards, the mean (µ) and standard deviation (σ) values of NMAE are acquired in order to present the validation results in percentage form.

5.3 Applicability of the model

The model has been applied using various scenarios, which include variable wake- up frequency, packet length and increasing network size and traffic load with the implementation of the four test cases. Unless the polling interval is variable, the graphs have been plotted using as polling period the value Tpoll=3000 ms, which is considered the default wake-up frequency of SEDs in the studied implementation of Thread. In addition, the useful oper- ations per hour have the maximum value of 1000. If the battery lifetime is not a function of the operations/hour, then the graphs portray the obtained battery lifetime after 1000 operations/hour have been performed by the SED. As regards the length of the packets being transmitted and received, the following packet payloads are assumed for Tx and Rx in cases of non-variable packet sizes: • Rx payload length = 10 bytes and 20 bytes • Tx payload length = 10 bytes

37 5.3.1 Wake-up frequency

Fig. 5.1 portrays a three-dimensional bar plot, which indicates the proportion of the operational, housekeeping, and sleeping current as a function of polling interval (1000-3000 ms) and useful operations/hour (0-1000). The depicted results in the plot are acquired from the model. The figure demonstrates that for smaller polling intervals, the network housekeeping current dominates the current consumption and the proportion of the operational current has no substantial effect on battery lifetime. The battery lifetime versus the useful operations/hour for six different polling intervals is shown in Fig. 5.2. It can be noted that the plotted data include both the model predictions, which are represented by solid lines, and the experimentally acquired battery lifetime, which is denoted by dashed lines. As can be seen in the figure, there is a decline in sensor longevity as the polling interval decreases because the number of wake-ups (W) grows drastically. For instance, with Tpoll=3000 ms and Tpoll=125 ms, W is equal to 1200 and 28800 wake-up instances respectively, which shows the intensity in the difference of the wake-up frequency. For polling intervals below 1000 ms, the data points seem to follow a straight line, which is not the case. This is simply further proof that the operational current, which varies with the amount of operations per hour, ceases to have as strong influence on battery lifetime as the network housekeeping current.

Figure 5.1: Proportionate current consumption of the sensor node with respect to oper- ations per hour and polling intervals.

38 T =3000 ms poll 1000 T =2000 ms poll 900 T =1000 ms poll T =500 ms 800 poll T =250 ms poll 700 T =125 ms poll

600

500

400 Battery Lifetime in days 300

200

100

0 0 100 200 300 400 500 600 700 800 900 1000 Operations per hour

Figure 5.2: Predicted battery lifetime from the model and its proximity to the experi- mentally acquired average battery lifetime.

5.3.2 Packet Length

Figs. 5.3 and 5.4 depict the effect of increased packet payload transmission on the battery lifetime of a SED in Thread. The estimated battery lifetime with respect to useful operations per hour for variable CoAP payloads can be seen in Fig. 5.3. Due to the need for a greater amount of time required to handle the packet transmission and processing in all related layers, it is expected that the increased length of the packet would have the opposite effect on lifetime, thus leading to less battery running time because of prolonged current consumption. Furthermore, the effect of fragmentation can be observed in the transmission of a packet having a payload of L=80 bytes (red solid line plot with asterisk markers in Fig. 5.3), which exhibits the drastic decrease in battery lifetime in comparison with the other packet payloads. The bar plot in Fig. 5.4 illustrates the battery lifetime decrease in days compared to the case of the 10-byte payload transmission for four different payloads: L=30, 50, 70, and 80 bytes. The 10-byte payload transmission (blue dash-dot line with circle markers in Fig. 5.3) is used as a reference battery lifetime for the plotting of the additional decrease in lifetime as a result of the transmission of larger packets. A MAC frame in an IEEE 802.15.4 network (such as the one realised by Thread) consists of the payload, which is prefixed with a variable-sized header and appended with a variable-sized footer. In Thread, a packet with a payload of 80 bytes exceeds the maximum size (127 bytes) of a MAC protocol data unit (MPDU), thus necessitating fragmentation. If compared to the case with the 70-byte payload transmission, it can be noted that with the addition

39 of just 10 bytes in the packet payload, the SED drains the battery faster, which causes the battery to last for a shorter amount of time (approximately 80 days less).

900 L=10 bytes L=30 bytes 800 L=50 bytes L=70 bytes L=80 bytes 700

600

500

400 Battery Lifetime in days 300

200

100

0 0 100 200 300 400 500 600 700 800 900 1000 Operations per hour

Figure 5.3: Battery lifetime for transmission of different packet payload lengths.

Figure 5.4: Decrease in battery lifetime compared to a 10-byte payload transmission.

40 5.3.3 Network size and traffic

After the implementation of the four test cases using the model, the obtained results are illustrated in Fig. 5.5. A benefit that stems from the model is substan- tiating the effect that the number of sleepy devices attached to the same parent has on the battery lifetime. As portrayed in Fig. 5.5, the increase in the amount of children indicates a decrease in sensor life expectancy, which is an anticipated be- haviour. As the network contention rises with the addition of end devices and the introduction of network load, more frequent CSMA backoffs and retransmissions are encountered as a result. The unexpected behaviour, however, is the intensity in lifetime decrease as the nodes increase in amount from 5 to 10 in both cases of load off and load on. The added network load in network scenarios three and four had a substantial effect on battery lifetime, if NS1 and NS2 are used as reference points. On the other hand, the network handled the insertion of additional 5 SEDs without the occurrence of highly frequent CSMA backoffs and retransmissions. This difference can be observed in the predicted battery lifetime of the pairs NS1-NS2 and NS3-NS4. A

1100

1000

900

800

700

600

500 Battery Lifetime in days 400

300

200 N=5 Load Off (NS1) N=10 Load Off (NS2) N=5 Load On (NS3) N=10 Load On (NS4) Test Cases

Figure 5.5: Battery lifetime of a sleepy end device under the influence of variable network contention. possible explanation for the observed behaviour can be the selected IEEE 802.15.4 MAC attributes used in this implementation, which due to confidentiality reasons cannot be disclosed. The specific values of these attributes can influence energy efficiency, latency, and reliability in a different manner. In this case, the value of one attribute or a combination of them leads to fewer collisions in the initial backoff stages as well as it reduces the per-operation energy consumption.

41 5.3.4 Accuracy of the model

The numerical validation of the model is presented in Table 5.1 and 5.2, where the NMAE is employed to prove the validity of the model, and to further support the graphical results presented in Fig. 5.2. Polling intervals from 3000 to 125 ms are validated and the NMAE lies in all cases below 5 %. The wake-up frequency of SEDs is not meant to be high in Thread, so generally Tpoll of 1000 and above are used in current implementations of Thread. The model exhibits an adequate capability to predict the battery lifetime in occasions of variable polling periods, as can be observed in Table 5.1. Furthermore, the implementation of the four test cases, which involved a small and large network set-up with load off and load on, using experimental means indicates a validation error rate less than 4 %. The validation results shown in Table 5.2 prove that the model can effectively represent network contention.

Table 5.1: Validation with NMAE for different polling periods

Polling Period [ms] NMAE [µ ± σ]

Tpoll = 3000 2.83% ± 0.54%

Tpoll = 2000 2.78% ± 0.05%

Tpoll = 1000 3.95% ± 0.02%

Tpoll = 500 4.33% ± 0.09%

Tpoll = 250 1.42% ± 0.03%

Tpoll = 125 3.79% ± 0.12%

Table 5.2: Validation with NMAE for different test cases

Test Case NMAE [µ ± σ] NS1 1.56% ± 0.31% NS2 2.82% ± 0.60% NS3 2.65% ± 0.53% NS4 3.81% ± 0.81%

5.4 Battery Lifetime Improvement

In this section, a few instructive observations regarding the optimisation of the SED current consumption are presented.

42 Starting with the topic of polling periods and their influence on the radio duty cycle and ultimately the battery lifetime, it is clear that since the radio activity duration is up to a certain extent fixed with every type of operation, the duty cycle within the operational cycle is going to be high with small polling intervals (in the range of hundreds ms), which is an undesirable feature for SEDs. Furthermore, the number of devices and the amount of children are generally large because the redundancy is added to deal with the nature of low-power and lossy networks, such as the networks in Thread. For that reason, there is no critical need for the sleepy devices to wake-up frequently to observe a phenomenon because there can be multiple nodes monitoring the same phenomenon, so it is important to decide on the balance between battery consumption and message latency related to the larger polling periods.

From the previous sections, it is evident that different types of current (Inhk, Iopt, Isleep) influence the overall battery lifetime depending on the polling period. Determined by the specific measure of Tpoll, it is advisable to further reduce the current and/or duration for the transmission of the MAC Data Request for small polling periods in network housekeeping events. Furthermore, it is advantageous to decrease the current consumption and/or duration of the packet transmission and reception in data polling events. The MAC sublayer of IEEE 802.15.4 implements its own retry mechanism by re- transmitting a frame, if the 1-hop link layer acknowledgement has not arrived. The retransmission is repeated a specific amount of times. Due to the star net- work topology of the implementation studied in this project that contains nodes positioned 1-hop away from the parent device, it is apparent that the MAC re- transmissions are adequate to ensure reliability within the network. However, if there are strict requirements as regards packet delivery success, one can employ retransmission mechanisms in the application layer. With this in mind, the CoAP protocol implements a retransmission mechanism suited for constrained networks and triggers the retransmission of a packet 2 seconds after the time indicated in the packet departure timestamp contained in the source node. However, it is det- rimental to the battery lifetime of a SED to stay awake for 2 seconds in an idle state, awaiting the successful reception of the CoAP ACK by the parent device. Finally, the need for application layer acknowledgements is superfluous in some cases during which the sleepy device is not required to reply to the message by piggybacking its reply in the CoAP ACK. The link layer acknowledgements are sufficient to ensure successful packet transactions in the majority of cases. Con- sidering the process of transmitting a CoAP ACK, which entails a second MAC polling requiring the CSMA-CA algorithm to be performed twice before finally transmitting the ACK packet, it is prudent to bypass this step when there are no strict performance requirements in place.

43 5.5 Summary

The proposed model in this thesis report has addressed a number of points; the key ones can be summarized as follows: • The model can predict with a small forecasting error (below 5%) the battery lifetime of a SED and various parameters can be altered and tuned accord- ingly to infer the magnitude of the effect on network lifetime. Few of these parameters are: the polling interval of SED, the total number of useful op- erations being performed per hour, and the MAC attributes related to the CSMA-CA algorithm in the IEEE 802.15.4 standard. • The model takes into consideration different packet sizes that are being trans- mitted and received up to the fragmentation threshold in IEEE 802.15.4 networks. However, the model can easily be adjusted to account for frag- mentation in cases the application is in need of exchanging larger packet sizes. Such an example is provided in the model applicability section. • The attachment of additional children nodes to the same parent as well as the increased network size and traffic are represented in the model, which evaluates the new network conditions and adjusts the probability of channel access failures and collisions that consequentially affect the battery lifetime. • The proposed model along with the obtained results can prove to be inform- ative as well as beneficial not only to researchers and device developers but also to installers and system integrators. • If the results acquired from the experimental validation are considered, the model together with the methods that are employed are accurate judging from a perspective of applicability. That is to say, the PCM can serve as a tool to facilitate installers and provide them with instructions for taking appropriate measures in order to extend the battery lifetime of sensor devices.

44 Chapter 6

Concluding Remarks

6.1 Conclusions

In this degree project, several features of a battery-powered sensor node are con- sidered in order to implement a model that can profile the current consumption of a WSN node with a prediction error within a satisfactory range (less than 5 %). The performance of the model is assessed with the aid of MATLAB and validated by employing a hardware test bed as means to reach the thesis objectives. As the summary in the preceding section makes clear, the proposed model provides a sufficient estimation of the expected battery lifetime under numerous condi- tions. Nevertheless, one can argue that since the analysis is performed on certain hardware devices, this approach generates non-universal results as it is hardware- specific and the reproducibility of the experimental environment poses also further difficulties. A single model, however, cannot cover the needs of the vast hetero- geneity that exists within IoT as regards battery-operated nodes. In spite of that, there is one ubiquitous communication standard for low-power and lossy networks, namely IEEE 802.15.4, that is the common denominator of plenty communication protocols. This suggests that while the results cannot be applied to all sensor devices running on battery, they are still applicable to a number of cases in the field of WSNs.

6.2 Future Work

Concerning future work, alternative perspectives from which the battery lifetime could have been studied involve the topic of fragmentation in WSNs that employ IEEE 802.15.4 for the underlying layers and provide IP connectivity. Up to this point, there was no identified need to send larger MAC frames than the max- imum size of 127 bytes. The reason is that, in the majority of cases, the sensor

45 nodes employ the sense-and-send mechanism instead of collecting samples, storing them and then transmitting them to a gateway, which is the so-called batch-and- send method. However, as more advanced applications are being developed, larger packet sizes are required and along with the batch-and-send mechanism and firm- ware upgrades, fragmentation is going to take a prevalent position in sensor node operations. Packet fragmentation can take a toll on battery lifetime, so it is es- sential that its effects are studied sufficiently. Due to memory limitations in the parent device, the network size was restricted to 10 children devices. Another possible topic for future work can be a large-scale deployment up to 50 children devices to monitor the way CSMA-CA can deal with this amount of network contention, and to discover the impact on the battery lifetime of individual sensor devices. Furthermore, a long-term validation test, ranging from several hours to days, can prove more reliable in establishing the efficiency of the model. Due to the longer duration, any hidden sources of energy waste can manifest themselves and be identified.

6.3 Reflections

IoT advocates a form of connectivity that takes place anywhere, any time and spans anything instead of just anyone. This vision of information ubiquity that is being promoted creates an omnipresent intelligence that is indistinguishable to the human eye. A direct benefit that stems from such a new reality is that it revolutionises in a good way for the most part the way people live, work, com- municate and commute; IoT has become an indispensable part of our existence, whether people realise it or not. Specifically, smart homes and buildings have been a feature of science fiction writing for many years, but only after the beginning of 20th century, they started being implemented. Currently, this field has countless applications, which create intelligent environments able to “think” for themselves and co-operate with other parts to perform various functions. IoT can be considered as an immense blessing, however, there are numerous issues that can arise, if the evolving landscape introduced by IoT is not handled with caution. For instance, violation of privacy, and security matters related to the vast amount of information being “seamlessly” circulated pose serious ethical issues. The transparency of IoT blurs the lines between the physical and virtual world, excluding the human element from the interaction of the physical objects, as if this interaction occurs in a parallel universe. Questions, such as, who are the owners of the information that is propagated and how much control can the owner have over the dissemination of the IoT-collected data, need to be contemplated. As regards the specific topic of this degree project, which is modelling the battery lifetime of a sensor device that utilizes a new communication technology, namely Thread, it is essential to test the technology before implementing it in commercial

46 products to ensure that it is indeed capable of delivering the promised benefits that the proprietors claim. One dimension of the evaluation is the study of its energy efficiency. Furthermore, after the suitability for commercial products has been verified, the model presented in this thesis and the acquired results can serve as a tool for device manufacturers and system integrators to select the appropriate hardware, battery capacity and optimize the communication protocol parameters in order to achieve the desired device battery lifetime for the intended application. With respect to the disposal methods of the IoT devices, which constitute the last stage of the life-cycle analysis of a product/technology, focus needs to be put on the end-of-life practices for such devices. Irresponsible recycling due to e-waste can lead to dramatic impacts on the health of humans and on the environment. Electronic waste can give rise to major pollutants that are caused by the emissions from the decomposition or combustion of circuit boards and wiring, among other things. The sensor devices, the required batteries, and the need for battery replacement or the option of energy harvesting in the power management unit of the device are all important decisions that can be made in advance in order to avoid unnecessary energy waste and additional burden on the environment and its natural resources. Being able to take proactive decisions and enforcing some of the application-specific and energy-efficient improvements can boost the economy and guard Earth’s sus- tainability. Considering that the IoT envisions billions of connected devices, im- proving the energy efficiency of the ones that are battery-operated and extending their life expectancy is of utmost importance and can have a meaningful impact on Earth’s natural resources that are diminishing day by day.

47 Bibliography

[1] N. Khalil, M. Abid, D. Benhaddou, and M. Gerndt, “Wireless sensors net- works for Internet of Things,” in Intelligent Sensors, Sensor Networks and Information Processing (ISSNIP), 2014 IEEE Ninth International Confer- ence on, April 2014, pp. 1–6. [2] K. Ashton, “That ‘Internet of Things’ Thing,” RFID Journal, June 2009. [3] R. Van Kranenburg, The Internet of Things: A Critique of Ambient Tech- nology and the All-Seeing Network of RFID. Insitute of Network Cultures, Amsterdam, September 2008. [4] L. D. Xu, W. He, and S. Li, “Internet of Things in Industries: A Survey,” Industrial Informatics, IEEE Transactions on, vol. 10, no. 4, pp. 2233–2243, Nov 2014. [5] “Internet of Things in 2020: A Roadmap for the Future,” INFSO D.4 Net- worked Enterprise & RFID INFSO G.2 Micro & Nanosystems in cooperation with RFID Working Group of the European Technology Platform on Smart Systems Integration (EPOSS), Sep. 2008. [6] G. Y. Li, Z. Xu, C. Xiong, C. Yang, S. Zhang, Y. Chen, and S. Xu, “Energy-Efficient Wireless Communications:,” IEEE Wireless Communica- tions, vol. 18, no. 6, pp. 28–35, December 2011. [7] Q. Wang, M. Hempstead, and W. Yang, “A Realistic Power Consumption Model for Wireless Sensor Network Devices,” in Sensor and Ad Hoc Commu- nications and Networks, 2006. SECON ’06. 2006 3rd Annual IEEE Commu- nications Society on, vol. 1, September 2006, pp. 286–295. [8] A. H˚akansson, “Portal of research methods and methodologies for research projects and degree projects,” in Proceedings of the International Conference on Frontiers in Education : Computer Science and Computer Engineering FECS’13. CSREA Press U.S.A, 2013, pp. 67–73, qC 20131210. [9] “Getting started with Thread Webinar,” Available online: https://threadgroup.org/portals/0/documents/resources/Webinar NavigatingTheEcosystem.pdf, [Date accessed: 19th-October-2016].

48 [10] A. Al-Fuqaha, M. Guizani, M. Mohammadi, M. Aledhari, and M. Ayyash, “Internet of Things: A Survey on Enabling Technologies, Protocols, and Applications,” Communications Surveys Tutorials, IEEE, vol. 17, no. 4, pp. 2347–2376, 2015. [11] “Thread Overview - White Papers,” Available online: https://www. threadgroup.org/ourresources, [Date accessed: 12th-August-2016]. [12] “OpenThread: open-source implementation of the Thread networking pro- tocol,” Available online: https://github.com/openthread/openthread/wiki, [Date accessed: 9th-October-2016]. [13] Z. Shelby, K. Hartke, and C. Bormann, “The constrained application protocol (coap),” Internet Requests for Comments, RFC Editor, RFC 7252, June 2014, http://www.rfc-editor.org/rfc/rfc7252.txt. [Online]. Available: http://www.rfc-editor.org/rfc/rfc7252.txt [14] R. Kelsey, “Mesh Link Establishment,” Internet Engineering Task Force, Internet-Draft draft-kelsey-6lo-mesh-link-establishment-00, Jul. 2015, work in Progress. [Online]. Available: https://tools.ietf.org/html/ draft-kelsey-6lo-mesh-link-establishment-00 [15] “Battery-Operated Devices - White Papers,” Available online: https://www.threadgroup.org/Portals/0/documents/whitepapers/Thread% 20Battery-Operated%20Devices%20white%20paper v1 public.pdf, [Date accessed: 9th-October-2016]. [16] S. Ziegler, P. Kirstein, L. Ladid, A. Skarmeta, and A. Jara, “The Case for IPv6 as an Enabler of the Internet of Things,” IEEE Internet of Things, 2016. [Online]. Available: http://iot.ieee.org/newsletter/july-2015/ the-case-for-ipv6-as-an-enabler-of-the-internet-of-things.html [17] Z. Pang, Y. Cheng, M. E. Johansson, and G. Bag, “Work-in-progress: Industry-friendly and native-IP wireless communications for building auto- mation,” in Industrial Networks and Intelligent Systems (INISCom), 2015 1st International Conference on, March 2015, pp. 163–167. [18] G. Montenegro, C. Schumacher, and N. Kushalnagar, “IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs): Overview, Assumptions, Problem Statement, and Goals,” IETF RFC 4919, Feb. 2016. [Online]. Available: https://rfc-editor.org/rfc/rfc4919.txt [19] G. Montenegro, J. Hui, D. Culler, and N. Kushalnagar, “Transmission of IPv6 Packets over IEEE 802.15.4 Networks,” IETF RFC 4944, Oct. 2015. [Online]. Available: https://rfc-editor.org/rfc/rfc4944.txt [20] “IEEE Standard for Information technology– Local and metropolitan area networks– Specific requirements– Part 15.4: Wireless Medium Access Con- trol (MAC) and Physical Layer (PHY) Specifications for Low Rate Wireless

49 Personal Area Networks (WPANs),” IEEE Std 802.15.4-2006 (Revision of IEEE Std 802.15.4-2003), pp. 1–320, Sept 2006. [21] G. Anastasi, M. Conti, and M. D. Francesco, “A Comprehensive Analysis of the MAC Unreliability Problem in IEEE 802.15.4 Wireless Sensor Networks,” IEEE Transactions on Industrial Informatics, vol. 7, no. 1, pp. 52–65, Feb 2011. [22] T. Kim, I. H. Kim, Y. Sun, and Z. Jin, “Physical Layer and Medium Access Control Design in Energy Efficient Sensor Networks: An Overview,” IEEE Transactions on Industrial Informatics, vol. 11, no. 1, pp. 2–15, Feb 2015. [23] A. Wang, F. Lin, Z. Jin, and W. Xu, “A Configurable Energy-Efficient Com- pressed Sensing Architecture With Its Application on Body Sensor Networks,” IEEE Transactions on Industrial Informatics, vol. 12, no. 1, pp. 15–27, Feb 2016. [24] B. Martinez, X. Vilajosana, I. Vilajosana, and M. Dohler, “Lean Sensing: Exploiting Contextual Information for Most Energy-Efficient Sensing,” IEEE Transactions on Industrial Informatics, vol. 11, no. 5, pp. 1156–1165, Oct 2015. [25] J. Brusey, J. Kemp, E. Gaura, R. Wilkins, and M. Allen, “Energy profiling in practical sensor networks: Identifying hidden consumers,” IEEE Sensors Journal, vol. PP, no. 99, pp. 1–1, 2016. [26] J. Ren, Y. Zhang, K. Zhang, A. Liu, J. Chen, and X. S. Shen, “Lifetime and Energy Hole Evolution Analysis in Data-Gathering Wireless Sensor Net- works,” IEEE Transactions on Industrial Informatics, vol. 12, no. 2, pp. 788–800, April 2016. [27] B. Martinez, M. Montn, I. Vilajosana, and X. Vilajosana, “Early Scavenger Dimensioning in Wireless Industrial Monitoring Applications,” IEEE Internet of Things Journal, vol. 3, no. 2, pp. 170–178, April 2016. [28] B. Martinez, M. Montn, I. Vilajosana, and J. D. Prades, “The power of models: Modeling power consumption for iot devices,” IEEE Sensors Journal, vol. 15, no. 10, pp. 5777–5789, Oct 2015. [29] G. Bianchi, “Performance Analysis of the IEEE 802.11 Distributed Coordina- tion Function,” IEEE Journal on Selected Areas in Communications, vol. 18, no. 3, pp. 535–547, March 2000. [30] Z. Tao, S. Panwar, D. Gu, and J. Zhang, “Performance Analysis and a Pro- posed Improvement for the IEEE 802.15.4 Contention Access Period,” in IEEE Wireless Communications and Networking Conference, 2006. WCNC 2006., vol. 4, April 2006, pp. 1811–1818. [31] P. K. Sahoo and J.-P. Sheu, “Modeling IEEE 802.15.4 Based Wireless Sensor Network with Packet Retry Limits,” in Proceedings of the 5th ACM

50 Symposium on Performance Evaluation of Wireless Ad Hoc, Sensor, and Ubiquitous Networks, ser. PE-WASUN ’08. New York, NY, USA: ACM, 2008, pp. 63–70. [Online]. Available: http://doi.acm.org/10.1145/1454609.1454624 [32] P. Park, P. Di Marco, C. Fischione, and K. H. Johansson, “Modeling and optimization of the IEEE 802.15.4 protocol for reliable and timely commu- nications,” IEEE Transactions on Parallel and Distributed Systems, vol. 24, no. 3, pp. 550–564, 2013. [33] P. Park, P. Di Marco, P. Soldati, C. Fischione, and K. H. Johansson, “A generalized markov chain model for effective analysis of slotted ieee 802.15. 4,” in 2009 IEEE 6th International Conference on Mobile Adhoc and Sensor Systems. IEEE, 2009, pp. 130–139. [34] P. Park, C. Fischione, and K. H. Johansson, “Adaptive IEEE 802.15. 4 Me- dium Access Control Protocol for Control and Monitoring Applications,” in Wireless Networking Based Control. Springer New York, 2011, pp. 271–300. [35] “FRDM-KW24D512 Freedom Development Platform Users Guide,” Available online: http://www.nxp.com/files/32bit/doc/user guide/ FRDMKW24DUG.pdf?fasp=1&WT TYPE=Users%20Guides& WT VENDOR=FREESCALE&WT FILE FORMAT=pdf&WT ASSET= Documentation&fileExt=.pdf, [Date accessed: 3rd-November-2016].

51 TRITA EE 2016:187

www.kth.se