# A Model-Based Approach for Resource Constrained Devices Energy Test and Simulation

Edgar M. Silva, Luis Gomes, João Rodrigues, Pedro Maló

► To cite this version:

Edgar M. Silva, Luis Gomes, João Rodrigues, Pedro Maló. A Model-Based Approach for Resource Constrained Devices Energy Test and Simulation. 6th Doctoral Conference on Computing, Electrical and Industrial Systems (DoCEIS), Apr 2015, Costa de Caparica, Portugal. pp.345-354, 10.1007/978-3-319-16766-4_37. hal-01343502

HAL Id: hal-01343502

https://inria.hal.science/hal-01343502

Submitted on 8 Jul 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A Model-based Approach for Resource Constrained Devices Energy Test and Simulation

Edgar M. Silva¹,⁸, Luís Gomes¹,²,†, João Rodrigues¹,‡, Pedro Maló¹,²,⁻

¹Universidade Nova de Lisboa, Faculdade de Ciências e Tecnologia, Portugal

²UNINOVA, Centro de Tecnologia e Sistemas, Portugal

§ems, ‡jf.rodrigues}@campus.fct.unl.pt

⁻pmm, †lugo}@fct.unl.pt

**Abstract.** The constant evolution in communication technologies, has improved during the last decades the interaction between systems/devices/things/etc. Internet-of-Things (IoT) has become the last trend pushing forward in this direction, connecting all ‘things’, creating a sensing world around all of us. Although, IoT technologies, solutions, systems have to be proven/tested before deployment in the real settings. These decentralized systems normally use low power devices with small processing and storage capabilities, with roles mainly of sensing and data transmission. Until now, tests and energy simulation focus on wireless communications, since it has been identified as the main energy consuming module. This paper presents the acquisition and simulation of energy consumption by a single device, focused on all hardware components and not only in the communication, due to the new adopted solutions that do not rely so much in the communication (e.g. subscription). In this sense, a methodology capable of retrieving real and simulated energy consumption results from/for a single device is presented, relying on a model based approach (software, hardware, energy and simulation models) and on a precise energy consumption assessment system. It is also presented a Resource Constrained Device Model, capable of representing the available hardware in a device, and a circuit to retrieve more accurate energy consumption readings.

**Keywords:** Internet of Things (IoT), Wireless Sensor Networks (WSN), Power Consumption, Simulation, Model Driven Engineering (MDE).

## 1 Introduction

Advances in microelectronic technologies have brought small and cheap devices, leading to highly heterogeneous environments. Manufacturers are engaged in developing devices for different purposes addressing different application domains and services to target different Internet-of-Things (IoT) deployments [1].

These deployments, such as Smart Cities, Domotics (Smart Buildings), etc., follow standards from Internet-of-Things (IoT), a global infrastructure for a more aware society, through advance services by interconnecting things, physical and virtually, based on existing and evolving interoperable information and communication technologies [2].
These systems normally use low power devices with small processing and storage
capabilities, with roles mainly of sensing and data transmission, making full use of
services to all kinds of applications, whilst ensuring fulfillment of all its requirements.

The major requirement for these devices is low-power operation, an extended lifetime, which leads to the actual problem, energy consumption. This work aims to understand in which ways is possible to estimate the power consumption, going through some existent solutions performing both acquisition and simulation of energy consumption by a single device. Looking forward to improve these methods, a methodology capable of retrieving real and simulated energy consumption results from/for a single device is presented, relying on a model based approach.

## 2 Cloud-based Engineering solutions for Internet-of-Things

Nowadays, it is possible to produce small and cheap devices, with computation, sensing and wireless communication capabilities. Thanks to advances made, Wireless Sensor Networks (WSN) offer technology support for a wide range of potential applications [3].

The relation with Cloud-based Engineering Systems can be established with base on the typical topology adopted in these systems. Considering a large number of nodes, and according to the type of sensing equipment, each device performs its task, collecting information and then, via subscription or periodically transmitting data, through a route to one or more collection points, called sink nodes. This unit gathers all data, making it available outside the WSN, exactly as other well-known Cloud-based systems [4].

One possibility is the paradigm expansion to a collaborative online platform, positioning itself on the cloud's information layer where all data is available to all interested entities. This will allow, for example, resource allocation strategies to reduce computational requirements for each user and also models exchange, creating a remote platform for energy testing [5].

<figure><img src="image_2.png" /><figcaption>Fig. 1. Example of Cloud-based platform for collaborative simulation.</figcaption></figure>

A Model-based approach which allows users to share tailored models for each System Under Test and to request a remote simulation of such system is illustrated in
Fig. 1. As simulations require high computational resources, remote effort allocation is the major advantage, saving local execution time while waiting for results.

# 3 Background Research

Over the last years Internet-of-Things (IoT) has moved from being a futuristic vision, to an increasing reality. It is a dynamic global network infrastructure, with self-configuring capabilities based on standards and interoperable communication protocols, where physical and virtual 'things' have identities, physical attributes and virtual personalities [1].

In order to realize the vision of the IoT, Wireless Sensor Networks (WSN) position themselves as a virtual layer where the information about the physical world can be accessed by any computational system [6]. On the physical side, WSN are formed by a number of devices, spatially distributed, in autonomous and cooperative monitoring of physical or environmental conditions [7].

One of the main challenges is to take into account the energy constraints of such devices, which aim to have a low-power operation, something that is difficult to predict during applications development [8]. For such task, power consumption analysis is a vital step to evaluate the performance of these devices. The following sections present a brief review of such approaches.

## 3.1 Power Consumption Analysis

The distributed nature of WSN, based on the interaction between software and hardware components, makes it less easy to correctly design and develop such systems. Power consumption is the main concern at this stage, with several methods proposed in a while, which aim to investigate this phenomenon. As a result, these strategies may help the prediction of the expected lifetime, just before deployment, providing to application developers useful recommendations to optimize energy consumption [7].

The two most common approaches for power consumption analysis are based on direct measurement, and on usage of simulation models. While measurement is a more accurate strategy for power consumption evaluation, it is known to have some limitations, as it turns to be very costly, tedious or even not practical, considering the typical topology of a network, with a large number of devices [4]. Due to this complexity, measurements taken on a single node are often generalized to the entire network when considering similar tasks and performed by homogeneous platforms. A common solution is measuring and monitoring the absorbed current, using a single resistor setup, placed between the power supply unit and the Device Under Test (DUT). Applying Ohm's law for the voltage drop across the resistor, current is measured. As this is an indirect measuring method, some of its accuracy limitations may put the process results at risk. Moreover, this also restricts the general consumption measurement on the device, making impossible to understand which components are draining current [3].
It is known that in comparison with other peripherals, radio modules are the source for greatest usage of energy so a way to understand the current drainage is by running applications that make use of a single component at a time, in order to generate its own energy profile. Combining the data collected for each application, simulation models may be generated for future testing, turning the scenario a little less complex.

## 3.2 Simulators

Simulation is the quickest way to test code and systems, before running it on the target hardware. Some simulation tools provide power consumption estimation, becoming a useful resource for performance analysis, when coupled with proper measurement techniques, keeping into account possible limitations on data acquisition [3]. There are several simulators, each with its own features and limitations. Avrora is widely used for WSN specific simulation, providing discrete-event simulation up to thousands of nodes. Although, it does not provide extensions besides from AVRMCU cores [8]. With the addition of an energy model, power profiling and lifetime prediction are enabled [9]. Bundled with Contiki OS, Cooja (http://contiki-os.org) is a useful tool to simulate such architecture, supporting emulation of platforms with TI-MSP430 or AtmelAVR micro-controllers, allowing heterogeneous networks emulation, supporting power consumption estimation [10]. MSPSim [11] can emulate TI-MSP430 micro-controller based devices from the instruction level, optimizing applications debugging process, and offering power consumption estimation, compatible with Contiki OS and TinyOS (http://tinyos.net). NS-2, from Network Simulator (http://nsnam.org), is a discrete-event simulator for general purpose, running up to 100 nodes. However, NS-2 cannot simulate power consumption in WSN [8]. PowerTossim (http://eecs.harvard.edu) is an extension to TOSSIM, which is a simulation environment included in TinyOS's framework. However, as TOSSIM only supports MICAz (http://moog-crossbow.net) hardware platform, the applying scope is reduced. Somov is the less tailored simulator as it offers power estimation of WSN applications for arbitrary hardware platforms, by separately defining the possible states of each component, having its performance and energy consumption data associated [4].

## 3.3 Model Driven Engineering (MDE) Approaches

With the sustained increase of technology, models are becoming more and more attractive to manage systems complexity, by simplifying design processes and formalization [12]. MDE's vision follows a unification principle, "everything is a model" (i.e. all can be modelled, programs, services, etc.), similar to the object technology basic principle, "everything is an object".

Another key initiative in MDE approaches is the Model Driven Architecture (MDA), an Object Management Group (OMG) initiative, which offers modelling support at different levels of abstraction [13]. MDA specifies a standard-based architecture for models, organized around three different abstraction levels, providing
guidelines to structure the specifications [13][14]: Computation Independent Model (CIM), Platform Independent Model (PIM) and Platform Specific Model (PSM).

The CIM is a level for the domain practitioners, in which systems requirements as well as the environment are specified with specific domain vocabulary, bridging the gap between domain experts and the development experts [13].

The PIM level deals with system formal specification, structural as functional. Abstracts technical details, focusing on system operation itself rather on how operations will be carried out. PSM level gathers technical and engineering details from a specific platform, combining it with the system specification from PIM level.

## 4 Hypothesis

From the early background research, some of the most important features and constraints of WSN devices were identified. It was possible to understand some weaknesses in existent solutions for behavior emulation and power consumption analysis (via simulation and direct measuring). As a result, the main question of this paper is: *Would a model-based approach, combined with precise measuring and simulation, provide more accurate results, being able to solve the known weaknesses on other previous attempts to assess the power consumption?*

This is the starting point for the proposed solution, which will make use of the presented concepts, such as simulation, direct measuring and model driven engineering.

## 5 Proposed Solution

Starting with an overview of the developed architecture, in terms of direct measuring, a fine tuned reading circuit coupled to a processing unit aiming to output reliable data will be use. The circuit supplies the processing unit with the voltage and current readings, while this block, through oversampling [15], outputs what we call real lab tests. This approach leads to a precise result, since the oversampling method adds bits of resolution to the typical 12bit result.

<figure><img src="image_3.png" /><figcaption>Fig. 2. Complete Architecture for Model-based Energy Testing/Simulation.</figcaption></figure>

With the precise feedback result, a model-based simulator can emulate the device behavior by using its meta-models, representing the hardware, software and energy
specifications. In the end, is argued that this architecture will generate accurate
results, since it is supplied with reliable information.

**5.1 Energy Analysis**

To perform realistic tests (real laboratory tests) a circuit was designed to simultaneous
retrieve the current and power consumed by the Device Under Test (DUT). This
circuit (in principle) is not much different from other proposals found in the scientific
community, as presented previously in Chapter 3.3.

Although, some changes were added to allow a more precise analysis of the current
and power consumed. When looking to the power ranges needed to maintain an IoT
device running (battery case) is possible to guarantee that a device will not work with
half of the maximum supplied power, i.e. if the maximum power is 3.3V the device
will not work with less than 1.65V, normally the range is between 3.3V and 2.6V. In
the case of the DUT has an infinite capacity power supply, power provided to the
device is almost constant with small fluctuations. Therefore the capability to change
the power value passed to the processing unit was added, allowing the analysis of the
total power supplied (maintaining the Uref equals to zero) or, for instance, half of the
power supplied (maintaining Uref = U/2) which increases the precision in one bit (by
hardware).

In the current case a very common Rsense arrangement is used (built with very
small resistors in terms of value to not interfere with current consumed), but with two
particularities. First, is possible to change Rsense resistor value (through a jumper's
settlement to a better Rsense accommodation regarding the current consumed by the
DUT). Second, the analyzed Rsense current is divided into two different signals that
then will go to the processing unit. The first signal called CurrentDown is the current
with a gain of two, and the second called CurrentTop is the current minus a Uref also
with a gain of two. This separation increases the current signal precision in one more
bit (by hardware).

<figure><img src="image_4.png" /><figcaption>Fig. 3. Energy Measuring Circuit.</figcaption></figure>

**5.2 Resource Constrained Device Meta-Model**

As previously seen, the presented architecture follows a model based approach, in
which a set of models (software, hardware and real lab energy consumption) is
provided to the simulation module, so an automatic simulation can be performed based on all the information provided. Regarding the software Meta-Model which defines the software model, is basically dependent of the programming language used. At this point the architecture uses the C and nesC Meta-Model since they are the more common programming languages used by the IoT development community [16].

Unlike the programming languages, that presents well defined Meta-Models or grammars, a hardware Meta-Model capable of representing a device is still missing. In this sense, and based in the work developed in [17] a Resource Constrained Device Meta-Model (RCDM) is proposed to describe the hardware components available in a device, see Fig 4.

<figure><img src="image_5.png" /><figcaption>Fig. 4. Resource Constrained Device Meta-Model (RCDM).</figcaption></figure>

RCDM provides a way to formally describe a device in terms of its hardware components. A device is composed by at least one module, that module can contain one or several components, e.g. a microcontroller as a processing unit, memory, AD/DA converters, etc. Each component is defined by one or more properties, identified by a name and with a type. The property type can be of two kinds, single or an aggregation of properties. A single property is used for instance when referring to a microcontroller architecture type (e.g. RISC, CISC). An aggregation property is used when referring to a combination of several properties, for example a radio transmission range which can be defined through, out or indoor environment, maximum range, distance unit.

# 6 Experiments (Definition)

The experiment definition starts with a selection of the devices to be tested. As most of the available products on the market share the same operating specifications, in
terms of power supply, we were able to design and build a printed circuit board with the measuring circuit, capable of measure and monitor the power consumption.

Following the architecture presented in section 5, each system under test will be coupled with this circuit for data collection and analysis. By running a series of tests, we expect to achieve solid results to validate the supporting theory of this approach.

## 6.1 Device Selection

By reviewing the market share for IoT solutions, a survey was accomplished regarding complete devices specifications, identifying a set of hardware platforms as a good starting point for energy testing.

Being compatible with both TinyOS and Contiki operating systems, the adopted designs are TelosB (http://tinyos.stanford.edu) based devices by AdvanticSYS (http://advanticsys.com) and IRIS based devices by MEMSIC (http://memsic.com). The main goal of this survey is to gather multiple combinations of the most relevant parts, such as microcontrollers, memory, transceivers and sensing units. Including devices with similar features, we aim to set a solid platform for further comparison, as it will include results from a wider group of hardware.

The following table presents the first devices to be tested.

<table><caption>**Table 1.** Selected Devices for Energy Test/Simulation.</caption><thead><tr><th rowspan="2"></th><th colspan="2">Platform</th><th colspan="2">Microcontroller</th><th colspan="2">Memory</th><th rowspan="2">Radio</th><th rowspan="2">Sensors</th></tr><tr><th>Design</th><th>OS's</th><th>Ref.</th><th>Prog. Flash</th><th>Data RAM</th><th>Ext. Flash</th><th>RF Chip</th><th>Light Temp. & Hum.</th></tr></thead><tbody><tr><td>XM1000</td><td rowspan="3">TelosB</td><td rowspan="3">TinyOS Contiki</td><td>MSP430 @16MHz</td><td>116KB</td><td>8KB</td><td>1MB</td><td rowspan="3">TI-CC2420</td><td>S1087 SHT11</td></tr><tr><td>CM5000</td><td>MSP430 @8MHz</td><td>48KB</td><td>10KB</td><td>1MB</td><td>S1087 SHT11</td></tr><tr><td>CM3300</td><td>MSP430 @8MHz</td><td>48KB</td><td>10KB</td><td>1MB</td><td>External</td></tr><tr><td>XM2110CA</td><td>IRIS</td><td></td><td>ATmega1281 @8MHz</td><td>128KB</td><td>8KB</td><td>-</td><td>Atmel-RF230</td><td>External</td></tr></tbody></table>

Similar tasks will be performed on each device, as tailored applications will run on them. This will allow tracing the energy consumption, helping to confirm the effects of different clock speeds, program flash, memory, and radio units in the final consumption. Devices featuring external sensing units will be coupled with sensor boards in order to perform the tests. The selection consists in AdvanticSYS EM1000, SE1000 and MEMSIC MTS400. We decided to include this hardware in order to estimate a wider range of hardware and to study the external sensing power consumption phenomena.

## 6.2 Device Testing

With the previous devices selection, is completed the System Under Test definition to be tested by developing a group of simple applications with a common objective – collect and analyze, at each time, the energy consumption from a single component.
The combination of these applications with the chosen platforms is expected to allow the creation of the respective energy models for each device, improving the further model-based approaches for energy testing on the proposed solution.

<figure><img src="image_6.png" /><figcaption>Fig. 5. Energy Measuring Board.</figcaption></figure>

## 7 Conclusion

The Internet-of-Things is here to stay: IoT deployments abound, more IoT-related technologies appear and new IoT centralized apps are launched each day. With this new paradigm, decentralized systems benefit from resource constrained devices sensing capabilities, improving the overall system with environment awareness.

To engineer such systems, some concerns should be considered regarding energy consumption. The hardware selection has to be made wisely but also the applications code development has to be analyzed to achieve better efficiency results, locally (device/system) as well as globally (network/overall system).

This work proposes an architecture capable of retrieving real and simulated energy consumption results from/for a single device, relying on a model based approach (software, hardware, energy and simulation models) and on a precise energy consumption assessment system. It is also presented a Resource Constrained Device Model, capable of representing the available hardware in a device, and a circuit to retrieve more precise energy consumption readings.

With this methodology is possible to analyze the performance of a certain application in several hardware platforms and using different programming language. Provides important information regarding energy consumption, and consequently allows the developer to make a more conscious choice on how to implement his solution and/or improvements.

As future work, exhaustive energy consumption tests will be carried out on the selected devices, using different applications to allow the development of precise simulation models.
References

1. Silva, E. M. and Maló, P. "IoT Testbed Business Model", Advances in Internet of Things, 4, 37-45. doi: 10.4236/ait.2014.44006, (2014).

2. Vermesan, O., Friess, P.: Internet of Things - From Research and Innovation to Market Deployment. ISBN: 978-87-93102-94-1 (2014)

3. Moschitta, A., Neri, I.: Power Consumption Assessment in Wireless Sensor Networks. In: ICT - Energy - Concepts Towards Zero - Power Information and Communication Technology, Dr. Giorgos Fagas (Ed.), ISBN: 978-953-51-1218-1 (2014)

4. Dâmaso, A., Freitas, D., Rosa, N., Silva, B., Maciel, P.: Evaluating the Power Consumption of Wireless Sensor Network Applications Using Models. In: Sensors, 13, 3473-3500 (2013)

5. Wei, G., Vasilakos, A. V., Zheng, Y., Xiong, N.: A game-theoretic method of fair resource allocation for cloud computing services. In: The Journal of Supercomputing (2010)

6. Alcaraz, C., Najera, P., Lopez, J., Roman, R.: Wireless Sensor Networks and the Internet of Things: Do We Need a Complete Integration? In: 1st International Workshop on the Security of the Internet of Things, Malaga (2010)

7. Asorey-Cacheda, R., García-Sánchez, A. J., Garcia-Sánchez, F., García-Haro, J., González-Castaño, F. J.: On Maximizing the Lifetime of Wireless Sensor Networks by Optimally Assigning Energy Supplies. In: Sensors 2013, 13, 10219-10244 (2013)

8. Somov, A., Minakov, I., Simalatsar, A., Fontana, G., Passerone, R.: A Methodology for Power Consumption Evaluation of Wireless Sensor Networks. In: Emerging Technologies & Factory Automation, IEEE (Ed.), ISBN: 978-1-4244-2728-4 (2009)

9. Landsiedel, O., Wehrle, K., Rieche, S., Gotz, S., Petrak, L.: Accurate prediction of power consumption in sensor networks (2004)

10. Eriksson, J., Osterlind, F., Finne, N., Tsiftes, N., Dunkels, A., Voigt, T.: Cooja/MSPSim: Interoperability Testing for Wireless Sensor Networks. In: Proceedings of the 2nd International Conference on Simulation Tools and Techniques (2009).

11. Eriksson, J., Dunkels, A., Finne, N., Osterlind, F., Voigt, T.: MSPSim - an Extensible Simulator for MSP430-equipped Sensor Boards. In: European Conference on Wireless Sensor Networks, Delft (2007).

12. J. H. Hausmann, R. Heckel, and M. Lohmann, "Model-based discovery of Web services," Proceedings. IEEE Int. Conf. Web Serv. 2004.

13. OBJECT MANAGEMENT GROUP, M. D. A. G. Version, A. Kennedy, K. Carter, and W. F. X. Technologies, "MDA Guide Version 1.0.1," Object Manag. Gr., vol. 234, p. 51, 2003.

14. A.-J. Berre, F. L. F. Liu, J. X. J. Xu, and B. Elvesaeter, "Model Driven Service Interoperability through Use of Semantic Annotations," 2009 Int. Conf. Interoperability Enterp. Softw. Appl. China, 2009.

15. Atmel Corporation, Enhancing ADC resolution by oversampling. In: 8-bit AVR Microcontrollers Application Note, http://www.atmel.com.

16. R. Lajara, J. Pelegrí-Sebastiá, and P. Solano, "Power Consumption Analysis of Operating Systems for Wireless Sensor Networks," Sensors, vol. 10. pp. 5809-5826, 2010.

17. Cuteloop Consortium, Deliverable D1.3.2 Cuteloop Concept, FP7-216420 Cuteloop "Customer in the Loop: Using Networked Devices enabled Intelligence for Proactive Customers Integration as Drivers of Integrated Enterprise", 2009.