Full text
Universidade do Minho Escola de Engenharia Departamento de Inform´ atica Bruno Chianca Ferreira Energy-aware Gossip Protocol for Wireless Sensor Networks November 2019
Universidade do Minho Escola de Engenharia Departamento de Inform´ atica Bruno Chianca Ferreira Energy-aware Gossip Protocol for Wireless Sensor Networks Master Dissertation Master Degree in Informatics Engineering Dissertation supervised by Professor Jo˜ ao Marco C. Silva Professor Vitor Francisco Fonte November 2019
AUTHOR’S RIGHTS AND USE CONDITIONS BY THIRD PARTS This is an academic work that can be used by third parts as long as the rules and international good practices are respected concerning the author’s rights. Therefore, this work can be used according to the license stated below. If the user needs permission to use the work under the license conditions, they must contact the author through Universidade do Minho’s Reposit´ oriUM. i
ACKNOWLEDGEMENTS I would first like to thank my dissertation supervisors Professors Jo˜ ao Marco Silva and Vitor Francisco Fonte who have always been available to guide this work towards the goal and gave extremely valuable insights and research guidance. Thank you also to all other Professors from UMinho from whom I had the pleasure to learn and work with. I also would like to acknowledge my previous employees, specially my last two managers Øistein Martinsen and Miguel Gomes for being so comprehensive and supporting me on this new journey after so many years working with power systems. Finally, I would like to thank my family who have always been supportive despite the geographical distances and my partner Anna for all the support and patience during this journey. ii
STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. iii
ABSTRACT In Wireless Sensor Networks (WSNs), typically composed of nodes with resource constraints, leveraging efficient processes is crucial to enhance the network longevity and consequently the sustainability in ultra-dense and heterogeneous environments, such as smart cities. Epidemic algorithms are usually efficient in delivering packets to a sink or to all it’s peers but have poor energy efficiency due to the amount of packet redundancy. Directional algorithms, such as Minimum Cost Forward Algorithm (MCFA) or Directed Diffusion, yield high energy efficiency but fail to handle mobile environments, and have poor network coverage. This work proposes a new epidemic algorithm that uses the current energy state of the network to create a topology that is cyclically updated, fault tolerant, whilst being able to handle the challenges of a static or mobile heterogeneous network. Depending on the application, tuning in the protocol settings can be made to prioritise desired characteristics. The proposed protocol has a small computational footprint and the required memory is proportional not to the size of the network, but to the number of neighbours of a node, enabling high scalability. The proposed protocol was tested, using a ESP8266 as an energy model reference, in a simulated environment with ad-hoc wireless nodes. It was implemented at the application level with UDP sockets, and resulted in a highly energy efficient protocol, capable of leveraging extended network longevity with different static or mobile topologies, with results comparable to a static directional algorithm in delivery efficiency. Keywords—energy-aware, epidemic, IoT , routing, WSN iv
RESUMO Em Redes de Sensores sem Fios (RSF), tipicamente compostas por n´ os com recursos limitados, alavancar processos eficientes ´ e crucial para aumentar o tempo de vida da rede e consequentemente a sustentabilidade em ambientes heterogˆ eneos e ultra densos, como cidades inteligentes por exemplo. Algoritmos epidˆ emicos s˜ ao geralmente eficientes em entregar pacotes para um sink ou para todos os n´ os da rede, no entanto tˆ em baixa eficiˆ encia energ´ etica devido a alta taxa de duplicac¸˜ ao de pacotes. Algoritmos direcionais, como o MCFA ou de Difus˜ ao Direta, rendem alta eficiˆ encia energ´ etica mas n˜ ao conseguem lidar com ambientes m´ oveis, e alcanc¸am baixa cobertura da rede. Este trabalho prop˜ oe um novo protocolo epidˆ emico que faz uso do estado energ´ etico atual da rede para criar uma topologia que por sua vez atualizada ciclicamente, tolerante a falhas, ao mesmo tempo que ´ e capaz de lidar com os desafios de uma rede heterogˆ enea est´ atica ou m´ ovel. A depender da aplicac¸˜ ao, ajustes podem ser feitos ` as configurac¸ ˜ oes do protocolo para que o mesmo priorize determinadas caracter´ ısticas. O protocolo proposto tem um pequeno impacto computacional e a mem´ oria requerida ´ e proporcional somente ` a quantidade de vizinhos do n´ o, n˜ ao ao tamanho da rede inteira, permitindo assim alta escalabilidade. O algoritmo proposto foi testado fazendo uso do modelo energ´ etico de uma ESP8266, em um ambiente simulado com uma rede sem fios ad-hoc. Foi implementado ` a n´ ıvel aplicacional com sockets UDP, e resultou em um protocol energeticamente eficiente, capaz de disponibilizar alta longevidade da rede mesmo com diferentes topologias est´ aticas ou m´ oveis com resultados compar´ aveis ` a um protocolo direcional em termos de eficiˆ encia na entrega de pacotes. Palavras chave—energy-aware, epidˆ emico, IoT, RSF, roteamento v
CONTENTS 1 introduction 1 1.1Objective 2 1.2Methodology 3 1.3Summary 4 1.3.1Dissertation Outline 4 2 related work 5 2.1Theoretical Background 6 2.1.1Wireless Sensors 6 2.1.2Wireless Sensors Networks 8 2.1.3Energy Consumption in WSN 9 2.1.4Energy Conservation in WSN 9 2.2Flat-Based Routing 12 2.2.1Gossip / Epidemic Routing 12 2.2.2Sensor Protocols for Information via Negotiation 13 2.2.3Directed Diffusion 14 2.2.4Rumour Routing 15 2.2.5Minimum Cost Forwarding Algorithm 16 2.2.6Push-lazy-push Multicast Tree 17 2.3Hierarchical and Location Based Routing 18 2.3.1Low Energy Adaptive Clustering Hierarchy 19 2.3.2Power-Efficient Gathering in Sensor Information Systems 19 2.3.3Threshold-Sensitive Energy Efficient Sensor Network Protocol 19 2.3.4Minimum Energy Communication Network 20 2.4Overview 21 2.5Summary 22 3 energy-aware gossip protocol 23 3.1Design Goals 23 3.2Protocol Implementation Directives 24 3.2.1Algorithm 25 3.2.2Protocol Data Unit 27 3.2.3Timers Calculation 28 3.2.4Design Constrains 29 3.2.5Digest Variation 30 3.3Summary 30 vi
Contents vii 4 simulators and testing environments 32 4.1Wireless Networks Simulation and Emulation 32 4.1.1Mininet-Wifi 32 4.1.2CORE 34 4.1.3CupCarbon 36 4.1.4Cooja 37 4.1.5NS-338 4.2Testing Plantforms 39 4.2.1Devices Programming 40 4.2.2Hardware 42 4.2.3IoT Lab 46 4.3Summary 47 5 testing methodology 48 5.1Protocols 48 5.2Observed Metrics 49 5.3Test Scenarios 49 5.3.1Steady State Scenario 50 5.3.2End of Life Scenario 50 5.3.3Mobility Scenario 50 5.4Topologies 50 5.4.1Symmetrical 51 5.4.2Asymmetrical 52 5.4.3Random 53 5.5Implementation 54 5.5.1Requirements 54 5.5.2Simulations 54 5.5.3Energy model 55 5.6Summary 59 6 results and discussion 60 6.1General Configurations 60 6.1.1Test environment 60 6.1.2Fixed Configurations 61 6.1.3Energy Model 61 6.2Results 62 6.2.1Steady State 62 6.2.2End of Life Scenario 70 6.2.3Mobility 72 6.3Summary 74
Acronyms xiv TEEN Threshold-Sensitive Energy Efficient Sensor Network Protocol. TTL Time-to-Live. U UART Universal Asynchronous Receiver/Transmitter. W WSN Wireless Sensor Networks.
1 INTRODUCTION Wireless Sensor Networks (WSN) are composed of several nodes that have a specific purpose of monitoring and measuring diverse types of systems and physical phenomena. Each member of a WSN, called node, is usually very small and low cost equipment designed to run on limited energy source [Anastasi et al.,2009]. These nodes usually should not need maintenance for years, making it very important to find optimal ways to lower the required power to sense, store and forward the data to a central entity like a Base Station (BS). Connecting each node directly to the BS would add high energy cost to the network design, so, WSN are usually configured to relay data from one node to another until it reaches the final destination. The na¨ ıve way to solve this problem is to set each node to broadcast packets to each of its neighbours, and as a result each node would eventually receive all packets created by every node. That however would result in each node receiving the same packet several times coming from different paths. Many routing protocols have been designed to find ways of relaying packets without the need to sending all packets to every node, and thus saving resources. When energy resources are saved, the lifetime of the whole network is prolonged. Several routing protocols for WSN have been designed and an encompassing taxonomy of them is described in [Al-Karaki and Kamal,2004], which, regarding network structuredbased protocols, is mainly divided in three groups: flat-based routing, hierarchical-based routing and location-based routing. In the flat-based routing scheme [Schurgers and Srivastava, 2001;Braginsky and Estrin,2002;Al-Karaki and Kamal,2004], each node has the same function whilst in the hierarchical-based routing [Intanagonwiwat et al.,2000;Al-Karaki and Kamal,2004] some nodes acquire the role of cluster head and concentrate data before forwarding to another node and eventually the base station. Location-based protocols [Al-Karaki and Kamal,2004;Kumar et al.,2017] use the sensor’s geographical position to choose their role in the routing scheme. In some routing protocols, the nodes can assume a static role after being defined during a topology discovery stage. As a consequence, this might lead to energy depletion in specific nodes before others, creating an energy unbalance in the network, and even in some extreme cases completely isolating part of the network. Having this in mind, another approach should be also considered, adaptive protocols that take in consideration the current state of the network and automatically update the node’s role. 1
1.1. Objective 2 Routing protocols can also be divided regarding the data traffic model. In the continuous delivery flow model, the sensor nodes report newly sensed data to a sink periodically. In the event-driven model, the sensing nodes only report the occurrence of pre-defined events, and if the sink node is interested in data related to the event they issue a query. The query-based model is used when the sink node requests data from a previously known node, independently of an event. The definition of the model depends ultimately of the application and not every protocol is suitable for all situations. When controlling the node’s behaviour in the network is required, it is important that the state of all nodes are taken in consideration, requiring a high delivery rate of messages. In such cases, epidemic1approaches usually yield positive results [Al-Karaki and Kamal,2004; Leitao,2007]. An epidemic protocol can create a big communication overhead when nodes receive repeated messages, which makes them less energy efficient. So, for applications that require a specific direction for the data flow, epidemic protocols might not be the best option. Many different routing protocols have been studied to enhance WSN schemes, each one prioritising a required characteristic, like high throughput, high delivery rate or low latency[Al-Karaki and Kamal,2004]. Also, to increase network energy conservation, different approaches can be considered: duty cycling, data-driven schemes or mobilitybased schemes [Anastasi et al.,2009]. The main motivation for this work is to design a continuous delivery epidemic routing protocol that solves the issue with data redundancy while still keeping a high delivery rate and good network coverage. It shall aim at not only prolonging the lifetime of a WSN by using energy more efficiently, but also by exploiting the remaining energy level as a factor for the topology definition. Another important aspect is that this protocol shall enable the network to reconfigure automatically in case of topology changes without the need of intervention. 1.1 objective The objective of this dissertation is to design an energy-aware communication protocol capable of reducing and balancing energy consumption in WSNs. The main purpose of the proposed protocol is to create a new way of reducing traffic in an epidemic distribution with the following goals: 1. Lifetime of the network - Increasing the lifetime of the network is a main goal of the protocol, and since nodes in a WSN both create and forward sensed data, the algorithm complexity has direct impact in the computational and communication energy used by the nodes. The proposed protocol shall introduce a routing technique that 1Also called gossip routing
1.2. Methodology 3 can comply with all the goals while keeping computational complexity to a minimum in order to ensure the longevity of the network. 2. Delivery rate of packets - The proposed protocol must be able to ensure high delivery rate of packets. A trade-off between delivery rate and energy efficiency is acceptable as long as it is an application design choice. Other negative Quality of Service (QoS) aspects that are acceptable in order to ensure the lifetime of the network are high jitter and high latency. 3. Data redundancy - Duplication of delivered packets is an expected side effect of high coverage support, but it can have a negative impact in the network lifetime since nodes will eventually be relaying unnecessary duplicated data. The protocol shall implement features that can reduce data redundancy without affecting the delivery rate. 4. Fault tolerance - Nodes in a WSN can be deployed in a completely flexible and inconsistent distribution. Furthermore the nodes, even the sink, can also be mobile, and have the geographical position changed constantly. The protocol must ensure that this has no affect in the functionality, even if some nodes fail and stop participating in the network. 5. Data traffic - The time-driven continuous delivery data model shall be considered for this protocol. Meaning that nodes’ sensors are cyclically reading new data and relaying to the network. 6. Scalability - The network performance and longevity should not be affected by the scale of the network. Hence, the protocol shall avoid the maintenance of complex and long tables, buffers and lists unless when used for keeping a list of neighbours. 1.2 methodology In order to fulfil the objectives of this proposal, this work is divided in two main stages: study and experimentation. The study phase covers the existing literature about routing protocols for WSN, identifying the diverse aspects and characteristics of some of them concerning energy consumption and efficiency. Also, since there are many different network simulators available, some will be tested and one chosen for the experimentation stage. During the experimentation stage, the chosen simulators are used to implement the designed protocol and collect metrics about its behaviour, and later the best solutions are benchmarked. The protocols are tested in different scenarios and different topologies to explore characteristics under different well established conditions as described in details in Chapter 5. The main steps of them work are sumarized as:
1.3. Summary 4 •Study the existing routing protocols for WSN; •Study the existing simulation tools available for WSN and choose one or more to be used throughout the development and evaluation phases; •Define the main performance and efficiency metrics that will be chased as primary targets; •Fine tune the routing protocol parameters to deliver best results for the chosen metrics; •Measure and benchmark the protocol comparing to well established protocols described in literature. 1.3 summary This chapter briefly introduced the problem this work aims to solve, the objectives and methodology to be adopted. 1.3.1Dissertation Outline For the next chapters, Chapter 2presents presented basic concepts about wireless sensor and WSNs and related work in routing protocols for WSN, showing some of the protocols that are classified similarly to the proposed protocol. Chapter 3describes the proposed protocol, presenting the design goals and constrains considered. Chapter 4introduces the possible platforms for testing the implementation of the protocol while Chapter 5presents the methodology that shall be used for testing. Chapter 6presents the results obtained from testings and the considerations about the results. Finally, Chapter 7presents the final conclusions stemming from this work and possible future work related to this dissertation.
2 RELATED WORK This section will introduce related work in WSN routing protocols. An overall introduction about some protocols is presented and some aspects related to this work are highlighted. Since the number of existing protocols is too big, only the few that are more directly related to this work will be introduced. Other works have been made with the goal of classifying all the protocols and extensive lists and classifications can be found in [Al-Karaki and Kamal, 2004;Anastasi et al.,2009]. Routing protocols are vital to WSNs due to its distributed nature. Data created in one node need to be disseminated in the network to reach its final destination and the way this routing is implemented varies depending on specific applications and requirements. Some protocols are reactive, waiting for a data request in order to calculate the route towards the destination, others are proactive and maintain routing tables which are calculated in advance. The existing routing protocols for WSN are usually classified regarding their architecture as flat-based,hierarchical-based and location-based routing as introduced in [Al- Karaki and Kamal,2004] and shown in Figure 2.1. Location-based protocols are usually also classified as flat or hierarchical and therefore, examples of such protocols will be presented inside those classifications. Figure 2.1.: WSN Routing Protocols Taxonomy 5
2.1. Theoretical Background 6 2.1 theoretical background Before discussing related work regarding existing routing protocols, an introduction about the wireless sensors and WSN is presented in this section. 2.1.1Wireless Sensors Wireless sensors are a special type of sensor that does not require to be physically connected to any other device in order to transfer the data it has acquired. It is usually comprised of a compute, a sensing (usually associated with an analogue to digital converter), a memory and a communication (radio) units as shown in Figure 2.2. Since these sensors are not connected to any other device and are often deployed in remote areas, the sensor’s design often include energy harvesting from the environment, such as heat, solar, wind or vibration [Shaikh and Zeadally,2016]. These sources of energy are usually intermittent, so it is important to equip the sensor with an energy buffer unit, such as a battery. Figure 2.2.: Typical Wireless Sensor •Battery Unit - The battery unit is usually the main power source for wireless sensors. It is commonly comprised of a battery, mainly Lithium Polymer batteries in the most modern devices, a protection circuit and a battery charger. The function of the battery charger is to provide a stable voltage and a controlled current for charging it, since exceeding current could lead to a temperature increase and possibly a fire. Each type of battery has a required safe charging voltage and current; •Compute unit - The compute unit is where the main logic for controlling the other embedded hardware is located. It can be a micro-controller, a System on a Module (SoM) or a System on a Chip (SoC) for instance, but there are many other definitions sometimes created by manufacturers for marketing purposes. One important aspect when choosing the compute unit is to get enough computing power needed for the application, using as least power as possible [Malewski et al.,2018]. Hence, the system
2.1. Theoretical Background 7 should always aim to get just enough performance as it is needed, typically without any spare computing power, therefore saving more energy; – Micro-controllers are a category of small factor computers usually composed of a8or 16 bit microprocessor and sometimes equipped with some accessories, like Random Access Memory (RAM),Read-Only Memory (ROM), Universal Asynchronous Receiver/Transmitter (UART), Serial Peripheral Interface (SPI) or Inter-Integrated Circuit (I2C) interfaces. The modern versions of micro-controller are very energy efficient and depending of the manufacturer they can be equipped with wireless interfaces such as IEEE802. 11 [802.11,2016], IEEE802.15.4[802.15.4,2015] or Bluetooth [BluetoothCore,2019]; – System on a Chip are devices that can concentrate all the required modules to build a computer inside a chip. So the processor, RAM,ROM, and all the peripherals required for communication are housed in the same silicon chip; – System on a Module devices are small footprint systems that can fit on a module that shall or not be connected to a carrier board that make more IO ports available to the user. So, the SoM are one step ahead of the SoC since they install a SoC on a small board with some extra hardware, usually USB ports, video outputs, buttons and LEDs. These devices are more commonly used for prototyping. •Sensing Unit - The sensing unit is responsible for reading a physical phenomena and transforming into an eletrical signal that can be read by the computing unit. Most of the devices have built-in an analog to digital converter that can read the electrical signal and transform into a digital signal that the processor can understand. It is also possible that the sensing unit also has a embedded computer that can read the electrical signal, and provide the digital value to the computer via a communication protocol such as UART,SPI or I2C. •Memory Unit - The memory unit is a temporary or permanent storage where the sensor can store its measurements before they are routed out to the base station. This memory can be volatile RAM or non-volatile EEPROM1for applications that require permanent storage of data even after the measurements have been delivered. •Communication Unit - The communication unit contains the radio which is used for sending data to other nodes. This unit has one or more radios available for communication via modulation in pre-defined frequencies. Using the same radio, different protocols can be implemented in the MAC/PHY layer [Al-Sarawi et al.,2017] and, since some protocols share the same frequency, some devices, such as the nRF528402 1Electronically Erasable Read Only Memory (EEPROM) 2https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52840
2.1. Theoretical Background 8 for example, implement different protocols using the same radio simultaneously by using multiplexing. 2.1.2Wireless Sensors Networks Wireless sensors networks are made of nodes of wireless sensors distributed across an area and exchanging information. These nodes usually cannot reach a cloud or central server, so the data they collect is routed to a sink (or base station) on a multi-hop scheme. The sink on the other hand acts as border router and can be both in the WSN and in other network, being able to upload data collected by the sensing nodes to an external entity. Figure 2.3 shows a typical representation of a WSN. Figure 2.3.: Typical Wireless Sensor Network It is possible that a cluster of nodes cannot reach a sink but there is a particular node that can reach both an isolated cluster and the cluster where the sink is located. This bridge node therefore routes the data between the clusters enabling the data to reach the sink. A node that serves as a bridge will mostly always consume more energy than its surrounding counterparts, and if it gets depleted of energy before the isolated cluster, the whole cluster ends up losing connectivity with the sink. This serves as an example of the importance of energy-awareness when designing routing protocols for a WSN.
2.1. Theoretical Background 9 2.1.3Energy Consumption in WSN As previously mentioned, since wireless sensors are deployed on remote locations, it is imperative that they consume the least possible energy in order to prolong the network’s longevity. There are different ways that energy is consumed in a WSN. The sensor needs to read new data, which has to be processed and stored in memory and further transmitted. So basically, the main energy consumption topics are circuit power (sensing, computation and memory units), and radiated power (communication unit) [Niyazi,2017]. The way each sensor consumes energy depends on each node itself, as the sensing subsystem for instance, depends much on the type of measurement it samples. Some types of sensing devices require more energy than others, not only depending on the physical phenomena being measured (some require pre-heating of elements before sensing, such as gas sensors for example) but also because some applications require more frequent sensing than others. Typically, the communication on a wireless sensor consumes more energy than the computation part [Anastasi et al.,2009], but if a sensor reading demands filtering or other computation intensive processing, that could change the scenario. It could also happen that routing protocols can consume too much computation energy if they make use of a complex algorithm, or if they need to keep looping through routing tables in memory. The communication sub-system consumes power either when it is transmitting or receiving data. Most of the sensor nodes however have the ability to put the radio in sleep mode, reducing drastically the energy consumption and this option should be used as much as possible [Anastasi et al.,2009]. Since the communication in a WSN works mostly using a multi hop scheme, if one sensor node that is placed in a strategic position, as the bridge node in Figure 2.3, and for instance connect two local clusters runs out of battery, the whole network suffers a loss due to the loss of connection between the local clusters. A network that relies on a specific node for maintaining connectivity of a local cluster cannot afford the loss of such node. 2.1.4Energy Conservation in WSN In order to conserve energy, different techniques can be used depending on the application and design goals. As identified in Section 2.1.3, there are three main subsystems that consume energy, and different approaches can be used to reduce the power consumed in each subsystem or even in all of them simultaneously. As highlighted in [Anastasi et al.,2009], the main focus areas for power reduction in the communication sub-system are topology management,duty cycling,medium access control and data driven management.
2.2. Flat-Based Routing 16 geographical area, while in rumour routing the interest is expressed in terms of the event. In this particular situation the queries have to be injected in the entire network in a flooding manner. In addition, when the number of measuring events is small compared to the number of queries, the latter can be directed to particular nodes that have observed such events before, instead of flooding the whole network. To flood such events throughout the network the algorithm create agents, that are propagated in to other nodes and contain information about new local events to the far located nodes as seen in 2.6(a). Agents are special packets that have a high TTL when should cover the entire network. When a the agent reaches a node, this can update a table that relate events to routes towards them. In rumour routing the query packets follow a random walk through the network until it reaches a node that has that event in its event table as seen in Figure 2.6(b), it knows the exact route towards that event, reducing communication cost. (a) Agent Advertises Event (b) Node Request Event Figure 2.6.: Rumour Routing By reducing communication costs, this protocol can yield good energy saving results, but only when the number of events is small. When the number of events is large, the cost of maintaining large events and agents tables has a negative impact. This protocol require evenly distributed symmetrical topologies since its delivery efficiency relies on query packets finding nodes that have the been visited by the event’s agent. If it is required high delivery, the events would need to issue many agents with high TTL to flood the network, which would increase the energy use. 2.2.5Minimum Cost Forwarding Algorithm The Minimum Cost Forwarding Algorithm (MCFA) is a protocol that creates a flat topology by calculating the minimum cost path from each node to the sink or base station [Ye et al.,2001]. The protocol has two distinctive stages, the topology discovery and the running. When sending a message to the next hop, the receiving node tests if the message is
2.2. Flat-Based Routing 17 following the minimum cost route. If so, it forwards the message to its neighbours and the process is repeated until the message reaches the destination via the lowest cost path, since each node knows the shortest approximated path towards the sink. During the topology discovery stage, in order to estimate the shortest path, the sink starts as an advertiser and sends a broadcast message to all nodes and set the cost to zero, which is incremented at every hop. The nodes, on the other hand, start as listeners and set their current cost towards the sink to infinity. So, when a node receives the broadcast messages from the sink, it compares with its current estimation. If the new cost is smaller, the current cost is updated. All the nodes that received the message from the sink repeat the same process by becoming advertisers and sending a similar message to their neighbouring nodes. It can happen that each node has neighbours with different costs, so in order to avoid calculating its cost by using not the shortest path to the sink, a back-off timer is implemented. Every time the node receives a packet during the topology discovery phase, it resets a timer and waits for a possible other packet with smaller cost. When the timer expires, meaning that all the neighbours have sent their setup packet, the node can finally pass to the running stage. During the running stage, every new message is configured with the weigh5of the node which is creating the message, and a initial cost is set to zero. For every hop, the receiver adds the cost between the nodes to the initial cost and compares to its own weigh. If it is equal or smaller it means that the message is following the minimum cost path and it is forwarded, otherwise the message is dropped. The MCFA is energy efficient since it does not require maintenance of routing tables and adds small overhead for each message. One disadvantage is the lack of adaptability in case of topology change in the network due to mobile nodes or if the node assigned as sink changes, and the impossibility to self healing in case a node along the minimum cost path dies before the others. One possible solution for that would be to force the network to return to the topology discovery stage periodically, which would increase the energy consumption. 2.2.6Push-lazy-push Multicast Tree The Push-lazy-push Multicast Tree (PLUMTREE) Leitao [2007] protocol is a bi-modal protocol that makes use of the simplicity of a tree-based protocol but introduces an epidemic overlay to increase the resilience of the network. In this protocol the epidemic broadcast is performed in two different modes, eager push or lazy push. The tree-based dissemination is performed by the eager nodes, while the remaining nodes perform a lazy push broadcast, that serves as a backup purely gossip dissemination, useful in face of failures in 5The number of hops multiplied by the communication cost between the nodes.
2.3. Hierarchical and Location Based Routing 18 the broadcast tree and that guarantees high delivery rate and tree healing in case of node failure. In this protocol is assumed that nodes can keep a log of distributed packets, so that in case of repetition, those packets are dropped. To build the broadcast tree, the protocol needs a partial view of the neighbouring network, and in order to keep a partial view of the network, this protocol uses a membership service based in Peer Sampling Service. The main functions of the PLUMTREE are: •Tree Construction - module responsible to select the neighbouring nodes that will construct a link which will perform the eager pushes. The subset of nodes chosen for the eager pushes function in a similar way as pure gossip with fan-out. The remaining nodes will than operate using lazy pushes. •Tree Repair - module responsible to ensure that even on the occurrence of failure in some nodes, all nodes remain reachable by the spanning tree. In order for the protocol to ensure low latency in the network, it selects as eager nodes the peers from whom they receive the first messages. On a first moment the lazy nodes list is empty, and as the receiving node starts to received repeated messages, those nodes are moved to the lazy list. As soon as the network has lazy nodes, they start broadcasting digest messages with the list of available message IDs they have. If the eager broadcast tree fails, and a node has interest in a message received via the lazy push digest, it sends a crafted message requesting the desired message via the eager tree. This special message both broadcasts the interest in the message, but also heals the tree. The main goals of this protocol are therefore to ensure high delivery rate, network coverage and low latency. 2.3 hierarchical and location based routing Hierarchical or cluster based routing stands for a set of techniques where different nodes perform different tasks based in predefined characteristics. In hierarchical routing, a two layer scheme is introduced, in which one layer takes care of controlling how each node will behave and the other to actually perform data routing. The idea behind these protocols is to divide the network in clusters and define cluster heads that are responsible for the routing whilst the other nodes are responsible for sensing events. By performing data fusion and aggregation, hierarchical routing can reduce the energy burden within the clusters by reducing the overall number of messages to the sink. Most of the techniques in this category are more about how to choose the roles of each node and controlling adaptive features instead of routing itself [Al-Karaki and Kamal,2004]. Some hierarchical protocols use location to build the hierarchical topology, hence, are also classified as location-based protocols.
2.3. Hierarchical and Location Based Routing 19 2.3.1Low Energy Adaptive Clustering Hierarchy Low Energy Adaptive Clustering Hierarchy (LEACH) is a hierarchical-based protocol, in which a cluster head is randomly selected between the nodes. The protocol has two temporal stages: the first one deals with the topology discovery and control, and the second is the stead state. On the topology control stage, the cluster head is selected randomly based on a equation described in [Heinzelman et al.,2000]. During the stead state stage, nodes actually exchange data. Since it is a cluster based protocol, data can be aggregated, processed and compressed in the cluster before being forwarded towards the sink. Such processing is made by the current cluster head, that during this time will spend more energy than the other nodes. This action leads to energy unbalances, but since the cluster heads are chosen stochastically, given enough time it is expected that the unbalance disappears. 2.3.2Power-Efficient Gathering in Sensor Information Systems Power-Efficient Gathering in Sensor Information Systems (PEGASIS) is a chain-based protocol [Lindsey and Raghavendra,2002] developed as an enhancement of the LEACH protocol. The protocol works in a way that each node only needs to talk to its closest neighbours and in order to equalise power drain, in each round one node takes the role of talking to the BS, restarting when all nodes have taken this role. PEGASIS uses signal strength to find closest neighbours and also adjust it so that each neighbour can talk to only one node, thus avoiding the creation of clusters like in LEACH. Since this protocol uses the location in order to build the topology, it is also classified as a location-based protocol. It has the requirement that all nodes need to have enough radio range to reach the BS and that all nodes are capable of adjusting the radio power during run-time. 2.3.3Threshold-Sensitive Energy Efficient Sensor Network Protocol Threshold-Sensitive Energy Efficient Sensor Network Protocol (TEEN) is a hierarchical protocol introduced in [Manjeshwar and Agrawal,2001], where the node that is selected as cluster head with the same random criteria as LEACH, send two threshold values to the other nodes: •Hard threshold - Which is a range of values that govern when the sensor is allowed to transmit. Only when the sensed value is within the defined range, the node will transmit;
2.3. Hierarchical and Location Based Routing 20 •Soft threshold - Which is a percentage value, stating how much the new value should change compared to the previously measured value to justify a new transmission. Those threshold values are calculated based in a equation described in [Manjeshwar and Agrawal,2001]. A node configured with the TEEN protocol has the transmission radio always off, but is always listening to the medium, in order to receive new threshold values transmitted by the cluster head or by a newly attributed cluster head. Since the nodes never transmit anything unless the two threshold values are reached, the network saves energy. A possible negative effect is the possibility of never listening to the two threshold values, which would cause the nodes to never transmit, or to be too conservative in those values, which could harm the measurements accuracy. To find optimal values for the thresholds is therefore the same as finding the balance between accuracy and energy efficiency. Another negative side of TEEN is having the receiving radio always on, and consequently the microcontroller never in deep sleep. Other protocols have been created based on TEEN aiming for different enhancements depending on the application: •MODTEEN - Similar to TEEN but with a modified equation for calculating the threshold values [Pundir et al.,2018]; •APTEEN - Similar to TEEN but can issue warnings for critical value changes which can bypass the thresholds, enabling the protocol to be used in time critical applications [Manjeshwar and Agrawal,2002]; •DAPTEEN - Makes use of geographical parameters to try to reduce data redundancy [Anjali et al.,2016], so the protocol can also be classified as location-based. 2.3.4Minimum Energy Communication Network Minimum Energy Communication Network (MECN) is a routing protocol introduced in [Rodoplu and Meng,1999] that uses geographical data to build a hierarchical topology, and so can also be classified as location-based. The rational behind this protocol is to create local cluster or relay groups where nodes exchange data. A node, by knowing its surroundings, tune the transmission power to talk only to nodes closer to it by using low power GPS data. Which requires a hardware capable of doing so during run-time. The protocol also has the capability of self-configuring, so it can heal the topology if the network changes. A negative side of this protocol is that it always assume that all nodes can talk to each other, which is not always true since physical barriers can be between nodes even though they are geographically close. To solve this issue, an extension was added to the protocol called SMECN, where the letter Sstands for small.
2.4. Overview 21 2.4 overview Table 2.1presents an overview of the protocols introduced in this chapter. Two continuous delivery flat protocols were introduced and will later be used for comparison with the proposed protocol during the simulations. The na¨ ıve gossip with and without fan-out have as main characteristic the delivery efficiency and network coverage, with the disadvantage of wasting too much energy with packet duplication. The proposed protocol aims at keeping the same delivery efficiency whilst reducing the duplication, thus increasing the energy efficiency. The MCFA on the other hand, is very efficient when delivery messages to a sink, guarantying high delivery efficiency but with low network coverage. Also, the proposed protocol can handle mobile nodes by definition, mobile sink nodes and multiple sink nodes. While the PLUMTREE protocol has similar goals as the proposed protocol, meaning high delivery rate and good network coverage, it focus on low latency. Due to added complexity in the PLUMTREE algorithm, and the additional requirement of relying on other algorithms, it is expected that this adds an computational and energy footprint. It also has capacity of performing a slow tree healing, which enables limited mobility to the protocol. The query-based flat protocol SPIN has the advantage of saving energy with large payloads, since initially the nodes only advertise new metadata, and sends data only upon request. But, when the payload is small, the overhead of needing three packets for each data unit instead of one makes this protocol inefficient. Directed diffusion and rumour routing have a negative impact in energy efficiency during the initial moments of the network, when no gradient has been created in the directed diffusion and no agent has been issued in the rumour routing. After some time, all nodes will eventually have tables with gradients and routes to events, but keeping those add a negative footprint in computational cost for the protocols, cost that is limited in the proposed protocol. Table 2.1.: Protocols Summary Protocol Classification Data Model Routing Mobility Gossip Flat Continuous Delivery Reactive Yes PLUMTREE Flat Continuous Delivery Proactive Limited SPIN Flat Query Based Reactive Yes Directed Diffusion Flat Query Based Proactive Limited Rumour Flat Event Based Proactive Limited MCFA Flat Continuous Delivery Proactive No EAGP6Flat Continuous Delivery Reactive Yes LEACH Hierarchical Continuous Delivery Proactive Fixed sink PEGASIS Hierarchical / Location Continuous Delivery Proactive Fixed sink TEEN Hierarchical / Location7Event Based Proactive Fixed sink MECN Hierarchical / Location Continuous Delivery Proactive No
2.5. Summary 22 The main problem with the hierarchical protocol LEACH, the energy unbalance, is solved by the PEGASIS protocol with the cluster head rotation. PEGASIS however, has a requirement that nodes need to be able to change radio power properties during run-time and need to have a fixed sink. The TEEN family of protocols are energy efficient in the way that nodes create less packets, since they only transmit new data when the threshold values are satisfied. That however, reduces the flexibility of the applications since only values within a range are reported. The protocol proposed in this work, shall render flexibility for the application and the problem with excess sensing could be solved by an adaptive sensing protocol. Finally, the MECN has high energy efficiency since it uses less power to transmit data, but requires the nodes to be equipped with GPS radios and to be able to change radio power during run-time. Also, it has a disadvantage of not compensating for the nodes’ surroundings, relying solely on distances to set radio range. 2.5 summary This chapter introduced different protocols covering the main elements of the WSN routing protocols taxonomy, which are the flat-based, the hierarchical-based and location-based protocols. Since each has positive and negative aspects depending on the situation, choosing one depends much of the application where it will be used. As this work will later compare the proposed protocol to others by means of experimentation, some protocols were chosen to be simulated. It is important that the simulations’ results are comparable between protocols, so it was decided that all need be implementable following the same traffic model. Hence, it has been considered that they must follow the continuous delivery model, where the sensor data is updated constantly and propagated towards the sink immediately. Therefore, the gossip protocol will be implemented as a na¨ ıve baseline with both a simple version and a version with fan-out. Another protocol that can be implemented using the continuous delivery model is the MCFA, and since is not an epidemic protocol, will be a good comparison in terms energy efficiency and adaptability. None of the selected protocols is reactive, so they will also be comparable regarding the latency. 6Protocol introduced by this work 7DAPTEEN
3 ENERGY-AWARE GOSSIP PROTOCOL This chapter will introduce the Energy Aware Gossip Protocol (EAGP), which is the novel routing protocol proposed by this work, and its main goals, detailing the requirements and decisions considered for its design and implementation. The main goal of this protocol is to enable the extension of the lifetime of a WSN, ensure highly efficiency in data distribution whilst reducing data duplication. 3.1 design goals As discussed in Chapter 2, different communication protocols forward data by emitting a broadcast packet to all its neighbours or choosing a fan-out to reduce traffic and the probability of data duplication. In this way, the information is disseminated on an exponential rate, enabling quick and effective propagation of the information to all nodes. The side effect is the amount of duplicated packets which can lead to fast energy depletion due to excessive use of the radio as exemplified in Figure 3.1. Figure 3.1.: Epidemic Packet Diffusion Some protocols use an epidemic multicast or broadcast as a single stage on a multi-stage protocol. The rumour routing for instance, in order to reduce the amount of data during storms of epidemic dissemination, sends only meta-data about the events observed by the node. If the sink or another node is interested in such information, the node will receive 23
3.2. Protocol Implementation Directives 24 a request and will answer using a different routing mechanism, using a directional route for example. That makes sense on a network where each node has a big amount of data to be transmitted, but usually in a WSN, where the data collected by each sensing event might be just a few bytes, that is less efficient. Hence, depending on the amount of data to be disseminated, the cost of sending meta-data and later the actual data might add an overhead and affect the QoS, that cannot be afforded by a resource constrained network. The rational behind the proposed algorithm is to remain as an epidemic protocol, but also slow down the forwarding of the packets in some nodes proportionally to their current energy level. So, the idea is that nodes with high energy level will relay packets without delay, while the nodes with low energy level will hold the information longer, and relay data as a back-up path to ensure delivery efficiency. Details about the calculation of the timers will be presented in Section 3.2.3. Table 3.1illustrates the new terminology introduced by the protocol and some other terminology that will be used in this document. More details will be further given. Table 3.1.: EAGP Terminology Lazy A node behaviour in which it schedules the relay of packets with TMAX Eager A node behaviour in which it schedules the relay of packets with TNEXT TMAX The maximum time a node can wait to forward each packet in its buffer TNEXT The time an eager node waits to forward each packet in its buffer Node Each sensor in the network made of a radio, sensor, computation and battery modules Sink The node that can forward the disseminated information to another network, usually a border router Neighbour Node that is within radio reach Latency Time difference between packet creation and delivery at the sink node Storm High number of packet dissemination from different nodes simultaneously Implosion Delivery of several copies of the same packet simultaneously or not from different nodes 3.2 protocol implementation directives In order to define the protocol implementation, the Protocol Data Unit (PDU) and a pseudo algorithm are presented in this section. The algorithm was divided in two rounds: data creation and data propagation.
3.2. Protocol Implementation Directives 25 3.2.1Algorithm Data creation round Every time a node wakes up from sleep mode, a callback function is called that changes the state of the node and perform a few steps. To reduce excessive computations, the first two steps are performed only if there is a variation in the node’s own battery level. 1. Maintain the list of neighbours, removing nodes that are no longer visible; 2. After maintaining the neighbours list, each node can decide which mode it will assume thereafter, eager or lazy; 3. The node can now read a sensor for updated values and forward the information via multicast to all the neighbouring nodes, sending its own energy level, so that the others can refresh their list of neighbours. The data creation round is executed less frequently than the data propagation round. So, the update in node behaviour and the maintenance of the list of neighbours is performed in this step to reduce the protocol’s computational footprint. Figure 3.2illustrates each step of this round. Figure 3.2.: Data Creation Round Data propagation round This round is composed of the following stages: 1. The node receives a packet and verifies if the packet is an echo of its own sent packet. If so discards it; 2. Check if the sender is already in the neighbours list. If so, refresh battery level, if not add; 3. Verify the TTL value. If expired, discards the packet; 4. Check if the node id of the previous hop was the current receiving node. If so, the packet is discarded. This avoids local looping between two nodes;
4 SIMULATORS AND TESTING ENVIRONMENTS This chapter covers some of the available simulators, emulators, hardware, operating systems and test beds that can be used to research and prototype with WSN. The proposed protocol is further implemented based on one of the simulators presented here. 4.1 wireless networks simulation and emulation Implementing a routing protocol using a simulator enables the possibility of analysing behaviour and collecting metrics before a possible implementation in hardware. A few free network simulators are available [Helkey et al.,2016;Bhattacharya,2011] and some of them are introduced in this section. 4.1.1Mininet-Wifi Mininet-Wifi is a fork of a well know network simulator called Mininet. The Mininet simulator was created with the goal of studying Software Defined Networks (SDN), so its original version focuses only in wired networks. Mininet-Wifi was than forked from Mininet to add support to wireless networks. The program itself is a bundle of scripts programmed in Python allowing the creation of network topologies where each device can be accessed via its own virtual terminal [Fontes et al.,2015]. These topologies can be created manually via command line or can also be created via Python scripts to run different scenarios. The fact that the topology can be created and manipulated via Python scripts opens a large number of possibilities for simulations, since the script can be created with logics and automations to change the topology during execution. Mininet-Wifi also includes the possibility of changing the nodes position in three dimensions and the behaviour of the medium with different ways to simulating the wireless signal attenuation. Since users have access to a virtual Linux terminal running its own network devices, they can create applications in any programming language that is able to run in the chosen host operating system. Also, any application compatible with the host Operating System (OS) 32
4.1. Wireless Networks Simulation and Emulation 33 can run seamlessly, being possible to run tools useful for this research such as Wireshark. The network interfaces created in each virtual node use the Linux kernel driver mac80211 hwsim to create a virtual wireless network interface [Rethfeldt et al.,2016]. This network interface emulate the behaviour of an interface with perfect radio, therefore all packets created in one node will arrive in the destination node as long as it is in range. This behaviour is usually not desired for most of the simulations, so another software simulates the wireless medium between the virtual nodes. The wmediumd project was originally created by a company called CozyBit1to work on top of mac80211 hwsim implementing a probabilistic model that was originally statically configured during run-time via a configuration file [Silvano et al.,2017]. The final architecture when using wmediumd is presented in Figure 4.1. Figure 4.1.: Wmediumd Architecture The user would need to create beforehand a matrix with all the nodes and the probability that packets in each channel and each bandwidth would fail to be delivered. Therefore, mobility, obstacles, shadowing and other aspects of wireless communications were not considered in the original project. Since the project is open source, several additions were made by subsequent forks of the project, and the following propagation and mobility models 2 were added: •Propagation Models –Free Space –Log-Distance 1The company is currently out of business but the project is open source. 2https://github.com/ramonfontes/wmediumd/blob/mininet-wifi/wmediumd/config.c
4.1. Wireless Networks Simulation and Emulation 34 –Log-Normal Shadowing –International Telecommunication Union (ITU) –Tow-Ray Ground •Mobility –Random Walk –Truncated-Levy Walk –Random Direction –Random Waypoint –Gauss-Markov –Reference Point –GPS Route Even though Mininet-Wifi has the possibility of simulating software defined network components [Fontes et al.,2017], this feature will not be considered for this project since there will not be a need of switches in the topologies created for testing the protocol. It should be also taken into consideration that since it uses Linux drivers to emulate real network cards, and wmediumd also runs most of its software in kernel space, Mininet-Wifi is utterly dependent of the Linux scheduler and simulated applications that run in user space might have the performance affected by that. 4.1.2CORE CORE3stands for Common Open Research Emulator and is, in fact, an emulator, not a simulator. CORE works in a very similar manner as Mininet-Wifi, being a set of tools enabling the user to setup an emulated environment. When running a simulation on CORE, applications running on each node act as real network application. It is open source and was originally created by Boeing and released with BSD license. CORE has two main components, core-daemon and core-gui. The daemon is responsible for creating the virtual environments for each node by using Linux network namespaces (same as used by Mininet-Wifi). When spawning a node using namespaces, each node has its own network stack and acts as a lightweight virtual machine where all nodes share the same resources and the same kernel. Each node can therefore create its own network interface that communicates to the host via network bridges. Wireless networks are emulated with ebtables rules and the medium does not take in account simulated losses caused by signal attenuation or obstacles. Likewise Mininet, core-daemon is written mainly in Python, making 3Available at: https://github.com/coreemu/core
4.1. Wireless Networks Simulation and Emulation 35 it easy to create scenarios with Python scripts as shown in Annex C.1. As an alternative to create scenarios, core-gui can be used. The overall architecture of CORE is presented in Figure 4.2as seen on CORE’s documentation4. Figure 4.2.: CORE Architecture Core-gui is made in TCL/TK and has an intuitive interface, making it easy to configure scenarios. It is however not very practical for simulations that require open terminals in each node. CORE’s Python API enables the user to export a running scenario created in Python as XML file that can be open in core-gui, but not all configurations are exported. Figure 4.3exemplifies the interface with one simulation imported from a XML file which was exported from a previous simulation created with Python scripts. Figure 4.3.: CORE Gui 4http://coreemu.github.io/core/architecture.html
4.1. Wireless Networks Simulation and Emulation 36 When running different radio or propagation models is required, EMANE can be used with CORE. EMANE (Extendable Mobile Ad-hoc Network Emulator)5is a MANET(Mobile Ad-Hoc Network) emulator that can be used together with CORE to emulate the MAC/- PHY layers [Ahrenholz et al.,2011]. It enables higher fidelity for layers 1and 2when required. It relates to CORE the same way mac80211 hwsim and wmedium relate to Mininet- Wifi. EMANE offers different radio models to be used: •RFPipe •IEEE 802.11 a/b/g •TDMA •LTE •Bypass EMANE is open source and originally created by the US Navy. Both CORE and EMANE can be deployed in a distributed network to enhance the computing power for the scenario, thus enabling extensive scalability that is limited only by the available number of servers. 4.1.3CupCarbon CupCarbon [Bounceur et al.,2018;Mehdi et al.,2014;Lounis et al.,2017] is a smart city and IoT WSN simulator, open source and written in Java that has a user friendly interface. It allows the simulation of different types of nodes and protocols [Mehdi et al.,2014]. For the radio, the user can choose between 801.15.4(ZigBee or 6LoWPan), WiFi and LoRa radio protocols. In CupCarbon, the user has the option to create a route for the sensor node and save it as file with GPS coordinates. This file can be associated with one or more nodes and also be used in different simulations. The user has the option to use Open Street Maps (OSM) or Google Maps as background as shown in the Figure 4.4, so the GPS file with the route can be seen as an overlay layer on a real map representation. 5Available at: https://www.nrl.navy.mil/itd/ncs/products/emane
4.1. Wireless Networks Simulation and Emulation 37 Figure 4.4.: CupCarbon Main Window with OSM as background It is also possible to use energy models of the sensors in order to follow how the stored energy decay along simulations, providing graphics and reports. However it is not possible to emulate and control the different energy modes that each specific hardware can achieve, such as radio sleep or deep sleep. CupCarbon is a simulator that aims at simulating the behaviour of mobile nodes in a wireless environment but it does not give access for the user to different network layers, hampering the desig and test of routing protocols. In order to allow the user to simulate nodes different actions, CupCarbon has its own scripting language called SenScript. A script can be created to control how the nodes interact with each other by using a simple set of commands. Finally, one extra feature of CupCarbon that can be useful for prototyping is the possibility of exporting the script associated with the nodes as Arduino6compatible C++ code, allowing uploads to real WSN nodes and testing of algorithms. This scripting language is adequate to simulate simple node’s behaviour and access some variables, but it might however come short for prototyping different routing algorithms running at application level. 4.1.4Cooja Cooja is an open-source wireless network simulator usually bundled together with ContikiOS [Roussel et al.,2016]. It has a graphical interface somewhat similar but more simple 6https://www.arduino.cc/
4.1. Wireless Networks Simulation and Emulation 38 than CupCarbon, as seen in Figure 4.5. It also provides the possibility of changing the simulation speed, making it easier to simulate long lasting scenarios. It has also a packet dissector, where the developer can see the whole sequence of packet exchange. One feature is the ability of running simulations of binary code compiled with other OS than Contiki as long as the hardware is compatible with the platforms supported by Cooja. It is possible for example, to run binary code compiled with TinyOS and RiotOS [Roussel et al.,2016]. Figure 4.5.: Cooja Main Screen Cooja also provides extra modules that can be added to the simulations, being one of them an energy monitoring module. This module however is only usable if the code being simulated was bundled with Contiki OS and compiled with support to energy metering. Unfortunately, like ContikiOS, the project has not been very active lately. 4.1.5NS-3 The NS-3[Kodali and Sarma,2017] simulator was created as a successor to the NS-2simula- tor, which is a simulator that has been extensively used in both private sector and academic world. This software is a modular simulator, so when building a simulation script, the user instantiates objects with specific functions according to the application need. It has many features, specially for reporting and generating traces and debug data. It is written in C++, and the simulation scripts can be run both in C++ or Python.
4.2. Testing Plantforms 39 Figure 4.6.: NetAnim Interface There is also a tool called NetAnim for the NS-3that allows the user to have a Qt based graphical interface to visualise the simulation architecture. The interface of NetAnim is presented in the Figure 4.6from the NS-3website7. Besides being able to simulate WSN energy models [Wu et al.,2011], is also capable of handling large scale simulations with good performance [Weingartner et al.,2009]. Even though NS-3has an energy model included , this model is focused mainly in wireless network interfaces, and not in WSN nodes with different energy operating modes. 4.2 testing plantforms Nowadays, as presented in Section 4.1, there are many platforms that can be used to implement nodes for WSN. Another possibility is to simulate routing protocols for testing is to use test beds. Test beds are real hardware platforms that can be programmed directly with bare metal software, or with the help of an operating system depending on how much program memory is available and the software complexity. Some companies can also rent test beds for end users, and those can be remotely programmed. Choosing the platform depends mainly on the requirements of the project and its constrains such as connectivity, energy density and physical dimensions. 7https://www.nsnam.org/wiki/File:Properties panel.png/
4.2. Testing Plantforms 40 4.2.1Devices Programming For programming sensor nodes, depending on the platform, there can be a few different software available when the goal is to generate bare-metal8binaries. Some manufacturers distribute IDEs together with compilers for their platforms and others toolchains to be used on Linux. The most common programming language for uControllers for example is C/C++ and Assembly, but for some of them Python9can also be used. Some of the manufactures sometimes also release libraries in order to reduce the development costs. Another way of programming the nodes is by using special OS designed for embedded systems. RiotOS The RiotOS is an open-source operating system with focus in wireless sensor networks created based on a previous OS called FeuerWhere [Rasool et al.,2017;Roussel et al.,2015]. The system has as main focus delivering real-time capabilities, low energy consumption and prioritise modern wireless networks. Those characteristics makes the RiotOS a promising platform for wireless sensor networks. RiotOS is written in C and C++ and so are the applications intended to run on it, but a proper toolchain is required for each specific processor. It can use regular building tools such as gcc and gdb making it accessible to a bigger developer community. It is also compatible with a large hardware base, being compatible with 8,16 and 32bit processors. The overview of Riot is presented in Figure 4.7from the RiotOS website10. Figure 4.7.: RiotOS Overview One significant advantage of RiotOS is that when building an application, since the OS is modular, only the necessary modules for such application to function will be compiled 8Nodes executing instructions directly on logic hardware without an intervening operating system. 9https://micropython.org/ 10 https://riot-os.org/api/
4.2. Testing Plantforms 41 and loaded making it resource and energy efficient. The developer is allowed to deploy as many threads as needed, being limited by the RAM memory and thread stack sizes [Baccelli et al.,2013]. RiotOS, like most of the real-time operating systems, has its software based in events which are triggered by timers or other interrupts. Since it is designed with focus on constrained wireless devices, it gives priority to supporting energy efficient technologies. RiotOS allows the user to compile the same code to different target platforms as long as it is compatible with the resources available in the hardware. It also allows compiling the software using the host compiler, enabling part of the code to be tested and debugged in the host computer. In order to compile the code to different hardware, the user must before install the necessary cross-compiler. However, to make the development faster, a Docker11 container was created with the cross-compiler for every supported platform pre-installed. TinyOS The TinyOS operating system is also an open-sourced OS designed for small wireless devices [Gao et al.,2011]. Unlike the RiotOS, the project is currently not very active, and not so many devices are having support being added. TinyOS is written in nesC, a dialect of C written exclusively to be used with TinyOS and to comply with its execution model. The application software is structured around tasks, and each task can be fired based on events such as interrupts or timers. TinyOS applications can be compiled for a guest device on a host machine using a cross-compiler and simulated using a bundled simulator called TOSSIM, which is configured and set by means of a Python script. As many of the open-source simulators, TOSSIM has been forked to create variations. One is the PowerTOSSIM, which was a fork aimed to add the capability of measuring with high accuracy the energy consumption of a TelosB board during the simulation [Perla et al.,2008]. PowerTOSSIM, has a very accurate energy estimation model, but unfortunately cannot be found anymore for download. FreeRTOS Another real-time operating system that aim the embedded systems market is the FreeR- TOS. FreeRTOS12 is a mature project which unlike the previously described ones, does not necessarily aim WSN devices. This project has the support of a lot of big companies with implementations made by Amazon and Espressif for example. Applications are written in C and are also based in tasks that can be fired based on interrupts or timers. FreeRTOS is a full real-time OS and programmers can implement complex scheduling schemes if needed. 11 Available at: https://www.docker.com/ 12 Available at: https://www.freertos.org/
5 TESTING METHODOLOGY In order to test the proposed protocol and gather results data for analysis, it was implemented to run on Mininet-Wifi and CORE simulators. The analysis was made comparing EAGP to other well-established protocols. All the different protocols chosen for the tests were implemented independently so that it is easy to switch between them during the tests. All the software, constraints, models and scenarios described along this chapter were equally applied to all tested protocols, so the conditions were always the same. More details about the test software can be found in Annex A.1 5.1 protocols From the protocols presented in Section 2some were selected to be implemented and used as baseline for comparison with the proposed protocol: •Gossip - Since the proposed protocol is an epidemic protocol, a purely gossip protocol was implemented and used as the main baseline; •Gossip with fan-out - The gossip protocols are usually implemented with some sort of fan-out as an optimisation to reduce the packet duplication in the network, so a version with configurable fan-out was also implemented; •MCFA - This protocol was chosen since it can also be implemented with the continuous delivery traffic model and represents a good comparison since it is not a gossip protocol; •EAGPD - A different version of the proposed protocol was created based on the Plumtree protocol that had similar eager / lazy push behaviour described in [Leitao, 2007]. More details about this protocol can be found in Annex 3.2.5. 48
5.2. Observed Metrics 49 5.2 observed metrics Base on the protocol goals described in Section 3.1, some metrics were considered to be recorded and analysed during the simulations and used to compare the proposed protocol with other protocols [Yitayal et al.,2015]. •Network longevity - A WSN that implements an energy efficient protocol to distribute data is expected to live longer in the sense that it will take longer until the last node is able to deliver data to a sink. The idea is to record the time when the last packet was delivered at a sink. •Delivery rate - Depending on the application, it might be crucial that all packets created on a node are delivered to all nodes or to the sink. During the simulations, a node will always be chosen as a sink, and taken as reference for message delivery. All messages created on a node have a unique random ID, so that in the end of each simulation it is possible to verify which messages were able to be delivered to the sink. Furthermore, it will be also recorded the percentage of the packets created by each node that were delivered in relation to other nodes. •Data redundancy - Using the gossip dissemination process to send packets induce them to follow different paths towards the sink. Hence, the same packet might be received by the sink more than once. Redundancy can be good to ensure high reliability, but excess redundancy can lead to energy waste. Comparing the implosion with the reliability can indicate how efficient a routing algorithm really is. •Energy efficiency - At the end of each simulation, with all the metrics collected, it is possible to assess how much energy was used and how many packets were delivered. It is therefore possible to calculate how much energy was used by the network to deliver each packet to the sink. The least energy used, more energy efficient the routing algorithm is to deliver packets. •Latency - Even though low latency is not a design goal of the proposed algorithm, the time between the packet creation and delivery at the sink is also calculated to assess the latency impact of the protocol compared to other protocols. 5.3 test scenarios In all scenarios described in this section, every node’s software starts and wait from a signal from the host to start the simulation, ensuring they start simultaneously. Time in the nodes is calculated based on the host timer, and all tasks are performed by a scheduler that is also
5.4. Topologies 50 based on the host timer. By doing so, it is possible to have a global clock for all nodes and calculate delays between actions. 5.3.1Steady State Scenario The steady state scenario aims to view how the algorithms perform during a predefined slice of time from the network’s total lifetime. That represents how the protocol behave during the majority of the network’s lifetime, when the all the nodes are participating and none dies before the end of the simulation. So, it is configured in a way that the nodes have a large amount of remaining energy available and configured to stop the execution after a predefined amount of time. 5.3.2End of Life Scenario The end of life scenario is the opposite of the steady state. The nodes are configured with a small amount of remaining energy, so that it is possible to view the difference in longevity of the network when using exactly the same configurations listed in Section 6.1. Since in this scenario the nodes have a very small battery, the simulation ends fast and it is possible to evaluate the behaviour of the protocols in the end of life of the network, when some nodes start to die before others. 5.3.3Mobility Scenario The mobility scenario is configured in the same way as the steady state, however mobility is added to the nodes to observe how they adapt to topology changes during execution. Since some algorithms have a start-up phase, the mobility is only introduced after a predefined amount of time. The mobility used for the tests is a simple random walk model where after every second, the geographical coordinates of the nodes are changed by random steps. 5.4 topologies In order to evaluate the proposed protocol in different situations and conditions, different topologies were created. The main ones from whom results will be presented, are shown below. In order to speed up the topology creation, a graphical tool was created allowing the creation of topologies and to export them as a Mininet-Wifi or CORE python script, and aJavaScript Object Notation (JSON) object file. With the JSON file, the user can reopen the topology and make adjustments when needed. More information can be found in Annex
5.4. Topologies 51 B.1. The number of nodes in each topology was limited according to the capabilities of the testing environment used. 5.4.1Symmetrical The symmetrical topology has a sink node (red node in Figure 5.1) in the middle and nodes equally distributed around it. This topology is a best case scenario for the protocols to achieve maximum efficiency. All nodes are more or less equidistant, symmetrically distributed in a perfect square and there is no overlap in signal coverage. Grid1# of nodes Radio range 50m29 90m and 120m2 Figure 5.1.: Symmetric Topology 1Grid seen in the background to assist the reader in distance assessment. 2For the mobility scenario, the radius is increased to 120m. Since 90m is a borderline radio range considering the disposition of the nodes, when the nodes start moving they would immediately lose contact with each other.
5.4. Topologies 52 5.4.2Asymmetrical This asymmetrical topology has a sink node in the extreme left and nodes distributed to the right. Some nodes are obvious paths in the way to the sink, like the node mote5for instance, and it is expected that the energy depletion in those nodes could isolate the whole network from the sink. Grid # of nodes Radio range 50m19 120m Figure 5.2.: Asymmetrical Topology
5.4. Topologies 53 5.4.3Random This random topology was created using the random function of the scenario generator describe in Section B.2.2and has a sink node in the middle and nodes randomly distributed around it. Node mote3connects a whole cluster on the left side of the map to the sink, so this node is essential to all nodes in this cluster. This topology is closer to a real case since was randomly created, and the proposed protocol has as a requirement to perform good in any topology. It has nodes with different distances and overlapping signal coverage. Grid # of nodes Radio range 50m30 154m Figure 5.3.: Random Topology
5.5. Implementation 54 5.5 implementation For testing purposes, an implementation of the protocols presented in Section 5.1was created in Python, where they could be simulated using Mininet-Wifi or CORE. The idea is to simulate the routing protocol at the application level, using UDP network sockets as the network endpoints. For that, two main classes were defined to run the simulation, the main class and the Node class. Mode details can be found in Annex A.1. 5.5.1Requirements For the simulated implementation of the protocol some requirements have been defined: •SR01 - The user must be able to run the simulation in real time or accelerated; •SR02 - The user must be able to interact with each node to monitor activities, and consult status and parameters during the execution of the simulation via command prompt; •SR03 - The simulation must have real-time properties available via RESTful API endpoints. The developed API is described in Section B.2.1; •SR04 - The simulation results must be stored in Comma-separated Values (CSV) files, so that reports can be generated; •SR05 - The user must be able to see the topology in real-time via a graphical interface. The developed API is described in Section B.2.2. More information about the software can be found in Annex A.1. 5.5.2Simulations When running a simulation with Mininet or CORE the topology is set with help of a Python script. All the virtual wireless network interfaces are configured as ad-hoc, and receive an IP address corresponding to the node ID. Each spawned main class is than responsible to simulate each node in the network and each node has an open UDP socket listening the medium for packets. When a node wants to transmit, it creates a socket, binds to the ad-hoc network interface, and send data to the broadcast address and listening port. All nodes in range will receive the packet and the listening socket will handle it. The main classes overview is illustrated in Figure 5.4.
5.5. Implementation 55 Figure 5.4.: Scenario Overview 5.5.3Energy model One of the most important aspects in the simulation of an energy-aware protocol is to be able to simulate the energy depletion of each node during the simulation duration. For that, a model of the energy consumption was created based on [Shnayder et al.,2005] and [Zhou et al.,2011] and a battery implemented as a class so that each node can have access to the battery level during run-time, and a report about the energy use in the end of the simulation. As mentioned in Section 2.1.3, the energy consumption on a WSN node is divided in three categories and the total energy is the sum of those as shown in Equation 4. •Circuit Energy (ECircuit) - Energy consumed by the circuit board and main processor of a node; •Radio Energy (ERadio) - Energy consumed by the radio module of the node; •Sensor Energy (ESensor) - Energy consumed by the sensor installed on the node. ETotal =ECircuit +ERadio +ESensor, (4) Circuit Energy The circuit energy, or processor energy [Zhou et al.,2011] model is defined by the energy consumed by the processor during all possible cycles the processor can assume. Taking for instance a ESP8266 board3, which will be later used as reference for the tests, the energy states the processor can assume is represented in the Figure 5.5. 3This board is very cheap and accessible with plenty of information available, enabling easy verification
5.5. Implementation 56 Figure 5.5.: Possible Energy States on a ESP8266 So when a ESP8266 board is not sleeping (deep or light sleep) but the radios are OFF, it is considered to be in modem sleep. When a board is receiving or transmitting data, it will consume the modem sleep current in addition to the current associated to the radio. Each state consumes the equivalent to the time spent in that state multiplied by the power4 consumed in the state as show in Equations 5,6and 7. ELight =V∗ILight ∗tLight (5) EDeep =V∗IDeep ∗tDeep (6) EModem =V∗IModem ∗tModem (7) So, the total circuit energy is finally: ECircuit =ELight +EDeep +EModem (8) Several different types of boards have available a type of deep sleep or hibernation mode. On the particular case of the ESP8266 board and in most of the others, in this mode even the processor is de-energised, so there is not retention of data in volatile memory. Since no internal function is running in the processor, in order to wake up from a deep sleep cycle it needs an external interrupt. This interrupt can be triggered by a pulse generated by a RTC or by another hardware [Systems,2019]. When the board is in this mode, to be able to communicate with other nodes, they would need to be synchronised and wake up at the same time, or another external ultra low power receive only radio would need to be added to the node just to wake up the main board. Hence, this mode was not considered in the simulations. 4Voltage (V) multiplied by current (I)
5.5. Implementation 57 One important aspect of the circuit energy is that for the same algorithm, different processors will spend different amounts of energy for computational calculations. The only way to estimate how much energy would be spent on calculations, would be to cross-compile the code to machine code for a specific processor and count how many instructions each section of the code has. Knowing how much energy each instruction consumes, makes it possible to estimate how much energy in total each section of the code consumes. This work has been previously done for the TelosB boards [Prayati et al.,2010], and the Power- TOSSIM simulator would use tracing to make accurate estimations of energy consumption by the processor. Unfortunately this simulator can no longer be found for download and has the disadvantage of not simulating a virtual battery. In order to make an approximation of power consumption during computation, the execution time for each part of the code is measured and multiplied by a computational constant. The expected result is that for different host machines where the simulations can be performed, the results will be different. Hence, they are comparable only when different algorithms simulations are run in the same machine. So the reason to try to estimate consumption in computational time is to know how the algorithms compare between each other, and not to have an absolute estimate of power consumption. An example on how to estimate power consumption with high accuracy is to use an external hardware that can be connected to the prototype board during execution as with a Nordic Semi hardware5. Radio Energy The radio energy model is defined by the energy spent transmitting or receiving data. For most applications, the transmission radio can be constantly OFF until there is a need to transmit data. The receiving radio in the other hand, can be ON or OFF depending on the application or routing algorithm. In some applications, the radio can be turned ON and OFF rapidly in order to listen to the medium whilst saving energy, but this is usually taken care by the MAC protocol. The efficiency of the energy saving is proportional to how long the radio can be OFF without missing a peer calling. The total RX and TX energy can be than calculated by: ETX =V∗ITX ∗tTX (9) ERX =V∗IRX ∗tRX (10) As an approximation for the radio energy, the time spent for RX and TX have been set to a fixed value independent of how much data is being transmitted. 5http://www.nordicsemi.com/Software-and-Tools/Development-Kits/Power-Profiler-Kit
6.2. Results 64 The next lines of Table 6.5show the average maximum and minimum hops needed to deliver each packet to the sink. The minimum is dictated by the topology, and was closely the same for all protocols. For the maximum, EAGP achieved a reduction of 6% when compared to the pure gossip protocol, and when compared to the gossip with fan-out the reduction was of around 4%. The average maximum number of hops has a direct impact in the energy reduction of EAGP due to the energy cost that every hop represents. Table 6.5.: Symmetrical Summary GOSSIP GSP. FO EAGP 10 EAGP 20 EAGP 50 EAGP 100 EAGP 500 EAGPD 10 MCFA Energy (J) 23854.59 8978.86 8137.76 8134.75 8101.98 7983.99 7427.65 8904.34 2422.26 Duplication 8.26 3.04 2.29 2.27 2.29 2.26 2.22 2.71 1.88 Max Hops 5.00 4.79 4.69 4.68 4.68 4.66 4.56 5.08 3.79 Min Hops 2.80 2.68 2.80 2.79 2.78 2.78 2.69 2.76 2.79 Latency(s) 0.01 0.01 7.69 15.20 36.16 73.02 347.18 14.97 0.01 Efcy. (%) 99.73 84.96 99.04 98.89 97.98 97.95 91.81 91.00 99.73 Pck. Del. 9828 8372 9760 9745 9655 9652 9047 8968 9626 J / Pck. 2.43 1.07 0.83 0.83 0.83 0.82 0.82 0.99 0.25 The latency on Table 6.5is the average time measured from when the packet was sent by the sensing node to when it was delivered. As expected, the EAGP introduces a latency not present when using the other protocols, since the nodes schedule the forwarding of the packets with a timer value up to TMAX, while in the other protocols the packets are forwarded immediately. Increasing TMAX increases the latency proportionally, but in this topology it grows slower than the TMAX itself as seen in Figure 6.2, where the nominal curve represents the configured TMAX. After the latency, the tables shows the delivery efficiency of the protocols, which is the ratio of the created messages that reached the sink, and the total number of packets delivered. Figure 6.2.: EAGP Latency The proposed protocol achieved an efficiency close to the pure gossip protocol, which is higher than the gossip with fan-out, but using much less energy. A protocol that uses less energy to deliver each packet is more energy efficient, which is represented in the table by the Joules per unique packet measurement. Figure 6.3compares the energy efficiency of all protocols in relation to the efficiency in delivering packets. The more distant the two curves are the best, and the MCFA protocol has the best combination.
6.2. Results 65 Figure 6.3.: Efficiency per Protocol It is possible to see that both gossip protocols are in the worse position whilst the EAGP gets closer to the MCFA even tough it is a gossip protocol. In this particular scenario and topology there was no advantage in the EAGPD, since more packet exchange is added to the network, and it didn’t increase the efficiency in delivering packets. It also worth notice that increasing the TMAX in the EAGP, reduces the energy consumption but also the efficiency, that is because since packets will stay longer scheduled, there is a bigger chance that the same message will be received as duplicate and dropped. So, besides using less energy, the EAGP with TMAX of 500 seconds is ultimately less efficient in delivering packets. Previously the TTL was set to 5because the results were being evaluated regarding the delivery to a sink which was in the middle of the topology. When the goal is to cover packet distribution to the whole network, the value of TTL has to be set to at least 10. It was therefore measured the average network coverage considering each node as the starting point as shown in Figure 6.4. Figure 6.4.: Network Coverage by Node These results represent the average percentage of the nodes that were reached by each packet created by the nodes (excluding the sink node). Taking as reference the EAGP with
6.2. Results 66 TMAX of 10 seconds, when increasing the TTL from 5to 10 resulted in a network coverage better than the gossip with fan-out. For example, for the EAGP with TMAX of 10 seconds and TTL of 5, the packets created by mote25 where able to reach only 20% of the nodes. Increasing the TTL to 10, the packets created by the same node were able to reach in average 85% of the nodes, but with the gossip with fan-out, and the same TTL configuration, the packets created by the same node were able to reach only 60% of the nodes. That means that in order to achieve the same network coverage as the EAGP, the gossip always need higher TTL value, and as a consequence consume even more energy. The MCFA, since it is not an epidemic protocol, yielded very poor results in this regards, and packets created in the border of the topology reached more nodes as expected, which is exactly the opposite of when a epidemic protocol is used. Increasing TTL increases the coverage, but also increases packet redundancy and consequently energy consumption. Fine tuning TTL, yields optimal results for energy efficiency and is related to the application needs. Designing a routing protocol that is too complex can increase the energy use for general computation. The gossip protocol with fan-out choose random neighbours to forward the packets, while in the proposed algorithm there is an additional computational footprint of maintaining a list of neighbours4, updating the node’s state, calculating TNEXT and maintaining a scheduler for the message forwarding. It is than expected an addition in energy not related to communication or sensing. When plotting the energy profile of the nodes during the simulation, it is noticeable how similar the pure gossip with fan-out, in Figure 6.5(a), and the EAGP, in Figure 6.5(b), are regarding the overall energy consumption per node. Although the amount of energy used by each node is similar, the EAGP has a higher cost in computational energy than the two other protocols. The MCFA, in Figure 6.5(c), on the other hand has an overall lower cost and a profile in the shape of a slope, explained by the fact that nodes closer to the sink forward more packets than the others away from the sink, hence consume more energy. The MCFA uses more computational resources only during the topology discovery phase. In the running phase it only adds the node’s weight to the packet and when a packet is received, compares to its own weight. 4Also present in the gossip with fan-out.
6.2. Results 67 (a) Gossip With fan-out of 3(b) EAGP with TMAX=10s (c) MCFA Figure 6.5.: Energy Profile Asymmetrical This topology, presented in Figure 5.2, has a hop radius of 9, so TTL was set to 9in all simulations that use it. This asymmetrical topology has a common path before the sink where all packets must flow before reaching it. It is expected the nodes in this path will create a bottleneck, and since the TTL is higher than the topology before, more entropy is expected when using the gossip protocols. The results for this topology are presented in Table 6.6.
6.2. Results 68 Table 6.6.: Asymmetrical Summary GOSSIP GSP. FO EAGP 10 EAGP 20 EAGP 50 EAGP 100 EAGP 500 EAGPD 10 MCFA Energy (J) 771238.78 101212.79 17454.45 17716.52 17329.38 17359.56 15157.16 9297.59 5216.91 Duplication 139.82 11.68 2.33 2.29 1.91 2.03 2.06 1.76 4.35 Max Hops 8.99 8.65 7.22 7.24 6.95 7.07 6.66 6.44 6.06 Min Hops 4.40 4.44 5.08 5.12 5.07 5.13 4.70 4.76 5.06 Latency 0.01 0.01 21.53 42.88 105.00 211.61 920.37 23.28 0.01 Efcy. (%) 86.82 70.61 87.30 87.73 86.89 87.84 77.25 75.30 99.71 Pck. Del. 4771 4276 5431 5458 5406 5465 4806 4685 5954 J / Pck. 161.65 23.66 3.21 3.24 3.20 3.17 3.15 1.98 0.87 The results were similar to the previous topology, but this time the EAGP with the digest for lazy nodes had higher energy efficiency (lower Joules per delivered packet) than the base one. The reason is because more repeated packets are dropped from the buffer, and the expected negative side effect is lower efficiency in delivery. MCFA, for a static scenario, had again lower energy consumption since the packets flow only in one direction, towards the sink. (a) EAGP with TMAX=10s (b) MCFA Figure 6.6.: Packets Forwarded vs Discarded When comparing the number of packets forwarded and discarded per node in EAGP in Figure 6.6(a) and MCFA in Figure 6.6(b), the latter, as expected, had the nodes closer to the sink more active. The opposite is observed in the EAGP, where nodes closer to the sink, that is located in the less dense area of the network, handle less packets. It is important to recall that in a gossip network, the packets flow in a chaotic manner, so there is no way to induce the direction towards the sink, therefore most of the packets will live bouncing in the most dense area of the network. In a topology like this, it is expected that when using a directional protocol like MCFA, the nodes closer to the sink will work more, and as a consequence use more energy and run out of battery before. If nodes closer to the sink run out of battery earlier, the whole network will die, since no packets will ever reach the sink again. Previously, the TTL was set to 9because the results were being evaluated regarding the delivery to a sink, but for the network coverage tests it was set to 18. It was therefore
6.2. Results 69 measured the average network coverage considering each node as the starting point as shown in Figure 6.7. Figure 6.7.: Network Coverage by Node In this case, the coverage using the EAGP even with a very conservative TTL, had good results, and increasing the TTL brought the results closer to 100%. The results for EAGP with TTL of 9were even better than the gossip with fan-out configured with TTL of 18. Random This topology, presented in Figure 5.3, has a hop radius of 11, so TTL was set to 11 in all simulations that use it. In this topology there is a bottleneck in one node close to the sink that connects the whole left side of the network. In this topology the results presented on Table 6.7were similar to the asymmetric and the EAGP achieved a high delivery efficiency, but lower energy efficiency than the digest variation. The average latency also in this topology gets closer to the TMAX value defined. Regarding the delivery efficiency however, the Energy Aware Gossip Protocol Digest (EAGPD) protocol achieved a result similar to the EAGP while having an energy efficiency 46% better. The results for packet duplication were also in EAGPD close to the MCFA which is good considering it is an epidemic protocol.
6.2. Results 70 Table 6.7.: Random Summary GOSSIP GSP. FO EAGP 10 EAGP 20 EAGP 50 EAGP 100 EAGP 500 EAGPD 10 MCFA Energy (J) 1437968 186740.43 25209.64 25071.99 25108.65 24506.28 22015.26 12980.53 3971.89 Duplication 308.63 34.27 5.00 4.86 4.90 4.78 4.52 2.48 2.21 Max Hops 9.36 9.92 9.18 9.08 9.08 9.03 8.50 7.18 4.66 Min Hops 3.24 4.47 3.64 3.65 3.64 3.63 3.55 3.67 3.66 Latency 0.05 0.01 12.46 24.56 60.88 120.49 573.53 15.05 0.01 Efcy. (%) 70.66 96.88 94.82 94.83 94.43 94.03 89.88 90.55 99.72 Pck. Del. 6414 10084 9869 9870 9829 9787 9355 9425 10103 J / Pck. 224.19 18.51 2.55 2.54 2.55 2.50 2.35 1.37 0.39 The random topology, as the asymmetric topology, benefited more the EAGPD than the EAGP when the main goal is the energy efficiency. This topology is denser than the previous ones, and for that is expected that the gossip without fan-out will struggle more deliver the packets due to the high entropy in the network. Packets are excessively exchanged in chaotic directions, and using fan-out to reduce the amount of exchanged packets results in less packet duplication and consequently higher delivery rate as observed in the results. The excess in packet exchange in a denser network work can also penalise the EAGP due to the cancellation of packet scheduling when repeated packets are received, and that is partially solved by the EAGPD packet digest. This is shown in the results on Table 6.7, since the EAGPD in this topology resulted in half packet duplication and half energy use while keeping the delivery efficiency close to EAGP. A possible solution for the duplication in EAGP would be to implement an optional alternative of introducing an energetic fan-out for denser networks, where the nodes would choose from it’s neighbours list nodes with more energy to receive the packets, the ones with less energy would just discard the packets. This would not only reduce the overall energy use, but also help in balancing the nodes’ energy. 6.2.2End of Life Scenario In the end of life scenario the nodes are configured to have a very small battery with 50mAh of full capacity. The initial state of each node’s battery level is the same described before for the steady state scenario. The simulation runs until the network is dead, which is when the sink stops receiving packets. Symmetrical In Figure 6.8results for different protocols are presented. The pure gossip protocol had shortest lifetime as shown in Figure 6.8(a), in which the network totally collapsed around 3250s, and adding the fan-out as shown in Figure 6.8(b), increased the lifetime significantly allowing the network to run until around 4600s. The EAGP protocol with TMAX set to 10 seconds shown in Figure 6.8(c), achieved a lifetime similar to the gossip with fan-out
6.2. Results 71 without being penalised in delivery rate to the sink. For the MCFA, represented in Figure 6.8(d), it is noticeable that the received messages form a sudden drops in steps, that is because when certain nodes stop working due to battery depletion, a whole path is blocked, while with the epidemic protocols packets can find other ways around the dead node. (a) Gossip (b) Gossip with fan-out of 3 (c) EAGP with TMAX=10s (d) MCFA Figure 6.8.: Network Longevity - Symmetrical Asymmetrical The lifetime representation of the nodes configured with the asymmetric topology is shown in Figure 6.9. Having TTL set to 9increases the amount of exchanged messaged in the network when compared to the symmetric topology. For that reason, when configured with the same initial battery capacity of 50mAh, the gossip protocol in Figure 6.9(a) has a much shorter lifetime than when compared with the symmetric topology. However, the EAGP in Figure 6.9(c) protocol does not suffer equally due to ability of cancelling duplicated messages not present in the purely gossip protocol. With the MCFA in Figure 6.9(d) the loss of a key node had a big impact in the network as seen after 2500s of simulation.
6.2. Results 72 (a) Gossip (b) Gossip with fan-out of 3 (c) EAGP with TMAX=10s (d) MCFA Figure 6.9.: Network Longevity - Asymmetrical 6.2.3Mobility For the mobility scenario, the nodes are set to change position every second, ultimately creating always a random topology. The initial state was the symmetrical topology with TTL set to 5. Since the radius of 90m is too short for mobility, it was increased to 120m. Figure 6.10 represents a snapshot during the execution of the mobility scenario and symmetric topology. The nodes represented in green are the nodes that at a specific time were in eager behaviour, while the blue ones where in lazy behaviour.
6.2. Results 73 Figure 6.10.: Topology After Mobility Starts Table 6.8.: Mobility Summary GOSSIP GSP. FO EAGP 10 EAGP 20 EAGP 50 EAGP 100 EAGPD 10 EAGPD 20 MCFA Energy (J) 166525.10 23856.12 13592.17 15440.83 13460.21 12230.26 10850.25 10499.09 2120.80 Duplication 102.81 14.94 7.01 7.18 7.41 6.02 4.72 4.87 2.58 Max Hops 4.87 4.91 4.78 4.84 4.80 4.65 5.25 5.31 3.01 Min Hops 2.36 2.38 2.45 2.49 2.50 2.47 2.60 2.64 1.79 Latency 0.01 0.01 6.23 14.14 36.56 74.84 12.31 23.83 0.01 Efcy. (%) 56.40 65.80 67.89 74.76 60.81 63.38 67.93 70.83 46.50 Pck. Del. 5558 6484 6690 7368 5993 6246 6694 6980 4506 J / Pck. 29.96 3.67 2.03 2.09 2.24 1.95 1.62 1.50 0.47 The movement of each node during the mobility scenario is completely random, so one simulation is never equal or similar to another. The results presented are an average of five executions of each protocol, and even tough they do not provide an accurate forecast of how each protocol will behave for each possible random situation, it can provide a performance estimation. Most of the results were as expected, with the MCFA losing its previous outstanding delivery performance as shown in Figure 6.11(b), due to the fact that it doesn’t recalculate the optimal path during execution like the EAGP that is periodically updating the neighbours list. It might be even expected that given enough time, the delivery rate of the MCFA will tend to zero. It could however be implemented a mobility version of the MCFA that periodically rebuilds the topology, but even building the topology with the nodes moving could yield bad results, because during the topology rebuilding stage no packet could be delivered, and when the process would be finished the topology could be already different. However, for a scenario where the node’s position is static but the sink is alternated, it could be implemented that every sink rotation, the nodes would restart the topology discovery. The EAGPD on the other hand, made better use of energy besides having similar delivery rate to the EAGP, as shown in Figure 6.11(a). The EAGP
Bibliography 80 37th Chinese Control Conference (CCC), Control Conference (CCC), 2018 37th Chinese, P. 1915. Heinzelman, W. R., A. Chandrakasan, and H. Balakrishnan 2000. Energy-efficient communication protocol for wireless microsensor networks. -, Pp. 10 pp. vol.2–. Heinzelman, W. R., J. Kulik, and H. Balakrishnan 1999. Adaptive protocols for information dissemination in wireless sensor networks. In Proceedings of the 5th Annual ACM/IEEE International Conference on Mobile Computing and Networking, MobiCom ’99, Pp. 174–185, New York, NY, USA. ACM. Helkey, J., L. Holder, and B. Shirazi 2016. Comparison of simulators for assessing the ability to sustain wireless sensor networks using dynamic network reconfiguration. Sustainable Computing: Informatics and Systems. Intanagonwiwat, C., R. Govindan, and D. Estrin 2000. Directed diffusion: A scalable and robust communication paradigm for sensor networks. Proceedings of the 6th Annual International Conference on Mobile Computing and Networking, Pp. 56–67. Kodali, R. K. and N. V. Sarma 2017. Simulation analysis of multi-dimensional WSNs using NS-3. In IEEE Region 10 Annual International Conference, Proceedings/TENCON. Kumar, A., H. Shwe, K. Juan Wong, and P. Chong 2017. Location-based routing protocols for wireless sensor networks: A survey. Wireless Sensor Network, 9:25–72. Kuosmanen, P. 2000. Classification of Ad Hoc Routing Protocols. Structure. Lazarescu, M. T. 2013. Design of a WSN platform for long-term environmental monitoring for IoT applications. IEEE Journal on Emerging and Selected Topics in Circuits and Systems. Leitao, J. Pereira, J. R. L. 2007. Epidemic broadcast trees. 2007 26th IEEE International Symposium on Reliable Distributed Systems (SRDS 2007), Reliable Distributed Systems, 2007. SRDS 2007.26th IEEE International Symposium on, P. 301. Lindsey, S. and C. S. Raghavendra 2002. Pegasis: Power-efficient gathering in sensor information systems. -, 3:3–3.
Bibliography 81 Lounis, M., A. Bounceur, R. Euler, and B. Pottier 2017. Estimation of energy consumption through parallel computing in wireless sensor networks. Malewski, M., D. M. Cowell, and S. Freear 2018. Review of battery powered embedded systems design for mission-critical lowpower applications. International Journal of Electronics. Manjeshwar, A. and D. P. Agrawal 2001. TEEN: A routing protocol for enhanced efficiency in wireless sensor networks. In Proceedings - 15th International Parallel and Distributed Processing Symposium, IPDPS 2001. Manjeshwar, A. and D. P. Agrawal 2002. APTEEN: A hybrid protocol for efficient routing and comprehensive information retrieval in wireless. In Proceedings - International Parallel and Distributed Processing Symposium, IPDPS 2002. Mehdi, K., M. Lounis, A. Bounceur, and T. Kechadi 2014. Cupcarbon: A multi-agent and discrete event wireless sensor network design and simulation tool. Proceedings of the 7th International ICST Conference on Simulation Tools and Techniques. Niyazi, Lama B. Chaaban, A. D. H. A.-N. T. Y. A. M.-S. 2017. Energy-aware sensor networks via sensor selection and power allocation. 2017 IEEE 86th Vehicular Technology Conference (VTC-Fall), Vehicular Technology Conference (VTC-Fall), 2017 IEEE 86th, P. 1. Perla, E., A. ´ O. Cath´ ain, R. S. Carbajo, M. Huggard, and C. Mc Goldrick 2008. PowerTOSSIM z: Realistic Energy Modelling for Wireless Sensor Network Environments. -. Prayati, A., C. Antonopoulos, T. Stoyanova, C. Koulamas, and G. Papadopoulos 2010. A modeling approach on the telosb wsn platform power consumption. Journal of Systems and Software, 83(8):1355 –1363. Performance Evaluation and Optimization of Ubiquitous Computing and Networked Systems. Pundir, S., A. Bhalla, A. Bakshi, A. K. Singh, and D. P. Singh 2018. MODTEEN: Modified threshold sensitive energy efficient network in Wireless Sensor Network. In Proceedings - 2017 3rd International Conference on Advances in Computing, Communication and Automation (Fall), ICACCA 2017.
Bibliography 82 Rasool, I. U., Y. B. Zikria, A. Musaddiq, F. Amin, and S. W. Kim 2017. RIOT-OS: Firmware for futuristic internet of things. Far East Journal of Electronics and Communications. Rethfeldt, M., H. Raddatz, B. Beichler, B. Konieczek, D. Timmermann, C. Haubelt, and P. Danielis 2016. ViPMesh: A virtual prototyping framework for IEEE 802.11s wireless mesh networks. In International Conference on Wireless and Mobile Computing, Networking and Communications. Rodoplu, V. and T. H. Meng 1999. Minimum energy mobile wireless networks. IEEE Journal on Selected Areas in Communications. Roussel, K., Y.-Q. Song, and O. Zendra 2015. RIOT OS Paves the Way for Implementation of High-Performance MAC Protocols. -. Roussel, K., Y.-Q. Song, and O. Zendra 2016. Using Cooja for WSN Simulations: Some New Uses and Limits. EWSN 2016 — NextMote workshop. Schaefer, F. M., T. Gro??, and R. Kays 2013. Energy consumption of 6LoWPAN and Zigbee in home automation networks. In IFIP Wireless Days, Pp. 13–15. Schurgers, C. and M. B. Srivastava 2001. Energy efficient routing in wireless sensor networks. 2001 MILCOM Proceedings Communications for Network-Centric Operations: Creating the Information Force (Cat. No.01CH37277), 1:357–361 vol.1. Shaikh, F. K. and S. Zeadally 2016. Energy harvesting in wireless sensor networks: A comprehensive review. -. Shnayder, V., M. Hempstead, B.-r. Chen, G. W. Allen, and M. Welsh 2005. Simulating the power consumption of large-scale sensor network applications. -. Silva, J. M. C., K. A. Bispo, P. Carvalho, and S. R. Lima 2017. LiteSense: An adaptive sensing scheme for WSNs. Proceedings - IEEE Symposium on Computers and Communications, Pp. 1209–1212. Silvano, G., I. Silva, L. Oliveira, M. Pinheiro, and B. Ferreira 2017. A hybrid architecture for experimentation in wireless sensor networks. In Brazilian Symposium on Computing System Engineering, SBESC.
Bibliography 83 Systems, E. 2019. ESP8266EX Datasheet. Espressif Systems. Rev. 6.2. Thaker, T. 2016. Esp8266 based implementation of wireless sensor network with linux based webserver. 2016 Symposium on Colossal Data Analysis and Networking (CDAN), Pp. 1–5. Weingartner, E., H. vom Lehn, and K. Wehrle 2009. A performance comparison of recent network simulators. 2009 IEEE International Conference on Communications, Pp. 1–5. Wu, H., S. Nabar, and R. Poovendran 2011. An energy framework for the network simulator 3(ns-3). Proceedings of the 4th International ICST Conference on Simulation Tools and Techniques, Pp. 222–230. Ye, F., A. Chen, S. Lu, and L. Zhang 2001. A scalable solution to minimum cost forwarding in large sensor networks. -, Pp. 304–309. Yitayal, E., J. M. Pierson, and D. Ejigu 2015. Towards green networking: Gossip based balanced battery usage routing protocol to minimize energy consumption of MANETs. In IEEE AFRICON Conference. Zhou, H.-Y., D.-Y. Luo, Y. Gao, and D.-C. Zuo 2011. Modeling of Node Energy Consumption for Wireless Sensor Networks. Wireless Sensor Network.
A SIMULATION SOFTWARE a.1 simulation software The simulation, as show in Figure A.1, starts when a scenario python script is run. The script for Mininet or CORE is very similar, and the other scripts for the rest API, main, and node are the same independently if Mininet or CORE is being used. Figure A.1.: Simulation Overview The scenario script, after starting the simulator, opens a terminal in each node and starts the main.py script. This script instantiates the Node class and starts a main background scheduler the governs the whole simulation. Figure A.2shows the overview of the main.py script, while Figure A.3shows the overview of the node.py class. 84
A.1. Simulation Software 85 Figure A.2.: main.py Overview Figure A.3.: node.py Overview a.1.1main.py The classes instantiated by main.py are described as follow: •node.py - Main class related to the node itself •prompt.py - Class that enables the user to have a command prompt •nodedump.py - Class that dumps information about the nodes during the simulation that can be used by the rest API •log.py - Logging and tracing functions a.1.2node.py The classes instantiated by main.py are described as follow: •battery.py - Class the control the energy model •networkGossip.py - Class that implements a pure gossip routing protocol •networkGossipfan-out.py - Class that implements a pure gossip routing protocol with the option of using fan-out •networkEAGP.py - Class that implements the proposed protocol •networkEAGPDigest.py - Class that implements the proposed protocol with the digest modification
A.1. Simulation Software 86 •networkMCFA.py - Class that implements the MCFA routing protocol As shown before, some requirements were set for the simulation software: •SR01 - The user must be able to run the simulation in real time or accelerated •SR02 - The user must be able to interact with each node to monitor activities and consult status and parameters during the execution of the simulation via command prompt •SR03 - The simulation must have real-time properties available via a RESTapi endpoints •SR04 - The simulation results must be stored in CSV files •SR05 - The user must be able to see the topology in real-time via a graphical interface To comply with requirement SR-01 the user can send via command line argument a time multiplier value that is used in the scheduler to change the timer configuration. The idea is that for every second passed in the simulation, the corresponding time in real world will be 1second times the value of the multiplier. So for instance if the sleeping time is set to 240 seconds, and the multiplier is set to 0.05, the scheduler will set the timer for the main cycle to 12 seconds. The same is valid to all temporal tasks, as the tasks triggered by an interrupt are note changed. For being able to interact with each node during execution and comply with SR02, a prompt command was implemented to run in each node with as illustrated in Figure A.4. For coding organisation the prompt was implemented as a separated class.
A.1. Simulation Software 87 Figure A.4.: Command Prompt for an Agent In the command prompt the following commands are available: •help - Print help message •info - Display general information about the sensor –Node name –Node role (mote or sink) –Sleep time configured –Simulation elapsed time in virtual simulation time –Simulation elapsed time in real world time –Node position •visible - Display a table with the current visible neighbours –Neighbour IP address –Last time it was seen in simulated time –Neighbour battery level in 0-100% •monitor - Turns verbosity on displaying the received messages in real time •clear - Clears the display
A.1. Simulation Software 88 •buffer - Display the buffer scheduler •battery - Display information about the battery and energy use •network - Display information about the routing protocol •quit - Stops the simulation of the node and exits. In order to make more practical and enable the creation of more advanced graphical interfaces for the simulation, a restful API was implemented to read the current status of each node and make it available via endpoints assuring that requirement SR03 is fulfilled. The RESTapi was implemented using the Flask1Python library. For complying with SR04, two different types of logs were created. First during execution every predefined time, a task is run by the scheduler to save the current state of the node in aCSV file. For coding organisation the log creation is managed by a separate class. Below is a list of the information logged. •Simulation seconds - Simulation internal clock counted in seconds starting from 0 •Battery level in % •Neighbours average battery level in % •Node mode •Number of neighbours •TMAX •TNEXT •# of Created messages •# of Forwarded messages •# of Delivered messages •# of Discarded messages •Energy spent in computation (J) •Energy spent in communication (J) •Energy spent in sleep (J) 1http://flask.pocoo.org/
A.1. Simulation Software 89 •Energy spent in sensor reading (J) •Node X coordinate •Node Y coordinate CORE has a built-in graphical interface to display the nodes in real-time, and that should be enough to comply with SR05, but when running the simulations via python scripts that cannot be used. So, a replacement web application was developed using the Vue.JS2 framework. More information about this web application can be found in Annex B. 2https://vuejs.org/
B.2. Architecture 96 Figure B.12.: Network Config Figure B.13.: Import and Export
C CORE QUICK GUIDE c.1 core python scripts basics Here is a list of basic commands to be able to run a CORE simulation using Python scripts. There is not so much documentation on how to run CORE from Python scripts, so the best way is to look on existing examples. Import of basic libraries: 1import logging 2from builtins import range 3from core import load_logging_config 4from core . emulator . coreemu import CoreEmu 5from core . emulator . emudata import IpPrefixes , NodeOptions 6from core . emulator . enumerations import NodeTypes , EventTypes 7from core . location . mobility import BasicRangeModel 8from core import constants Load initial configuration for the logger library: 1load_logging_config() Set the network ip range: 1prefixes = IpPrefixes (" 10.0.0.0/24 ") Create emulator instance for creating sessions and utility methods: 1coreemu = CoreEmu() 2session = coreemu . create_session () 97
C.1. CORE Python Scripts Basics 98 Must be in configuration state for nodes to start 1session . set_state ( EventTypes . CONFIGURATION_STATE ) Create the wlan node. The settings for the medium can changed here 1wlan = session . add_node ( _type = NodeTypes . WIRELESS_LAN ) 2session . mobility . set_model ( wlan , BasicRangeModel , config ={ ’range ’:50 , ’ bandwidth ’: 54000000 , ’jitter ’:0, ’delay ’: 5000 , ’error ’: 0}) 3session . mobility . get_models ( wlan ) Create node options for a node 1node_opt = append ( NodeOptions ( name =’ mote0 ’)) Add the node to the session. 1mote = session . add_node ( node_options = node_opt )) Create a network interface and connect it to the wlan 1interface = prefixes . create_interface ( mote ) 2session . add_link ( mote .id , wlan .id , interface_one = interface ) Instantiate session 1session . instantiate () Opens a terminal in the node, and run commands with attributes 1sink = session . get_node (2) 2mote . client . term_cmd (" bash "," command " ,[’ attibutes ’])
C.1. CORE Python Scripts Basics 99 Shutdown simulation 1coreemu . shutdown ()