On using continuations in wireless sensor networks Teemu Leppänen, Pauli Närhi, Jani Ylioja, Jukka Riekki, Yoshito Tobe and Timo Ojala
Abstract—We demonstrate deploying continuations dynamically into heterogeneous wireless sensor networks. Continuations include the computation code, collected sensor-based data and a partial view of the sensor network nodes, where the continuation travels. Here, continuations are considered resources in a sensor network and can be exposed to the world by means of the Computational REST. Services in the network can be dynamically composed from these continuations. This method has many uses in sensing and integrating sensor network’s resources with the Web. We also provide simple mapping of the continuation structure to Constrained Application Protocol message structure. We demonstrate this method in IP-based resource constrained wireless sensor network. Index Terms— distributed systems, wireless sensor networks, Web services, Representational state transfer
I. INTRODUCTION
I
n highly-distributed systems, it is possible to deploy components and compose services dynamically in runtime. This way, systems are able to adapt to runtime changes in environment and evolve when applications or requirements change. [1] Resource-oriented architectures are integrated with the Web in RESTful manner, provide loosely coupled services and consist of resources, resource names, representations of resources and links between them [2]. Proxies or intermediates can be used to abstract RESTful behavior for non-RESTful services. Using basic HTTP methods to provide programming abstractions for resources and for cooperating services has been previously demonstrated in [3].The sensors in resource-constrained WSN can be considered resources in REST architecture, integrated with the Web and accessed by Web services [4, 5]. A recent extension to the REST architectural style is the Computational REST (CREST) [6]. The goals being restructuring the Web by distributing services away from the server and composing higher-order services from established lower level services, where peers
Manuscript received January 16, 2012. This work was conducted in MAMMotH project in University of Oulu, Finland, and in OSOITE project in Tokyo Denki University, Japan. T. Leppänen, P. Närhi, J. Ylioja, J. Riekki and T. Ojala are with the Department of Computer Science and Engineering, University of Oulu, Finland (email: {teemu.leppanen, pauli.narhi, jani.ylioja, jukka.riekki, timo.ojala}@ee.oulu.fi) Y. Tobe is with the Ubiquitous Networking Laboratory, Tokyo Denki University, Japan (email:
[email protected])
are both clients and servers. In CREST, resources are represented by computations and interactions between peers are conducted as computational exchanges in the form of messages, closures or continuations. We demonstrate the use of continuations in resource-constrained WSN to dynamically configure sensor network for a task and to compose sensorbased services, which can then be exposed to the Web by means of CREST [4]. II. METHOD A continuation [7] is an abstract representation of the state of a computation as a data structure, which contains the following: code for the computation, the current state of the computation and data. We extend the continuation with a list of resources from the WSN, where the data are retrieved and where the actual computation is carried out in an execution environment. This list can, for example, consist of resource URLs. The included computation code can be of any programming language, even multiple for heterogeneous environments, for example bytecode, C or JavaScript. The data can also be any type or multiple types. To utilize the continuation, i.e. the current state of the computation, as a service, the clients need to be able to locate the continuation. This can be done by having a resource directory [8] in the WSN, which maintains the current location of the continuations. Clients can then access the service, for example, by means of REST or CREST. Additionally, the locations can be added to the resource lists in other continuations. This enables composing services dynamically from the continuation or sets of continuations. Multiple simultaneous services can be provided by multiple simultaneous continuations or sets of continuations. Here, we can achieve three things [4]: 1) easy task and service deployment by disseminating continuations in the WSN, 2) context switching in the WSN is a matter of the continuations by itself and 3) distributing computational load in the WSN in the form of continuations. Next, we provide mapping of continuation to the message structure in Constrained Application Protocol (CoAP) [8], see Table 1. As the CoAP method, we use GET to request data, and PUT to install computation code into the nodes. The code can be transmitted in two ways: 1) in the payload, taking content type into account or 2) use a new CoAP option in the message, which can be ignored by non-participating nodes and passed onwards. We tested disseminating continuations in IP-based WSN
978-1-4673-1786-3/12/$31.00 ©2012 IEEE
TABLE 1. MAPPING CONTINUATION INTO COAP MESSAGE STRUCTURE
Continuation (CREST URL)
CoAP Message
Method GET / PUT Computation code 1) Resource Name
Method GET / PUT Content-Type: Code in payload Uri-Path
Computation code 2) Continuation Id Next node address Original sender address Computation code 1) and Data
New CoAP option number Token Uri-Query (0..n) Uri-Query Payload Figure 1. CoAP and CoRE Link format messaging in the example.
atop 6LoWPAN with three sensor nodes. We used ATmega microcontrollers (164P and 1284) with minimum RAM (1, 4 and 16 Kb) and built-in self-programming capability. The sensor runtime was implemented in C. The Web service and the resource directory both run in remote PC in the network. The Web service provides URL //WS/power/ to access the WSN and could also work as a proxy or gateway. See Figure 1 and Table 2 for illustration. We also estimated the binary footprint size of two common filters: median with Quicksort and Kalman, being 1320 and 552 bytes respectively, with AVR-GCC compiler and code optimized for size. III. DISCUSSION In related work, examples include an agent-based system to disseminate tasks in the network [9, 10], with additional network setup phase [11]. High-level macroprogramming languages were used to describe tasks and interpreted in runtime in [10, 11, 12, 13]. Using high-level policies to describe actions was presented in [14]. Example of utilizing a partial view of WSN resources, with preprogrammed nodes was given in [9]. A map and reduce -based approach was presented in [15]. Continuations or similar programming abstractions were used in [10, 12]. We extend this work by demonstrating the CREST principles with CoAP in heterogeneous resource-constrained WSN, this being a hybrid method with possible features from all of the above, moving computations to the edges of the network with a uniform interface and inherent integration to the Web. The benefits to using continuations include: a minimal set of WSN resources are utilized, locality can be exploited and computational load
is distributed. Additionally, this method is possible in both push- and pull-type sensor networks. REFERENCES [1] [2] [3] [4] [5]
[6]
[7]
[8] [9]
[10]
[11]
[12]
TABLE 2. MESSAGING SEQUENCE IN THE EXAMPLE 1. Nodes register resource descriptions to the resource directory (RD) with CoRE Link format [8] messages. The Web Service WS abstracts the sensor network. 2. The nodes providing resource /power are located from the RD and their addresses included in the continuation message. The message includes additional token as the continuation id and method PUT is used to install the code. The message is sent to the first node S1. 3. First node computes intermediate result, adds it to the message and passes it to the next node (next=S2). 4. The last node executes the computation and returns the result to the WS (origin=WS) as response message, which in turn returns the response to the client.
[13]
[14]
[15]
M. Caporuscio, M. Funaro, and C. Ghezzi, "Architectural Issues of Adaptive Pervasive Systems," LNCS, vol. 5765, pp. 492-511, 2010. L. Richardson and S. Ruby, RESTful Web Services. O'Reilly, 2007. D. De Roure, “Towards Computational abstractions over a RESTful Architecture,” in: 4th IEEE International conference on eScience, 2008. T. Leppänen and J. Riekki, "Dynamic data processing middleware for sensor networks," LNCS, vol. 7096, pp. 141-147, 2011. W. Colitti, K. Steenhaut, and N. De Caro, “Integrating Wireless Sensor Networks with the Web,” in: Extending the Internet to Low power and Lossy Networks (IP+SN 2011), 2011. J. Erenkrantz, M. Gorlick, G. Suryanarayana, and R. Taylor, "From representations to computations: The evolution of web architectures," in: 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering, 2007, pp. 255–264. A. van Wijngaarden, “Recursive definition of syntax and semantics,” in: Formal Language Description. Languages for Computer Programming, T. Steel, Ed., North-Holland, Amsterdam, 1966, pp. 13-24. Constrained RESTful Environments (core) - Charter. Available: http://datatracker.ietf.org/wg/core/charter/. A. Majeed and T. Zia, "Multi-set Architecture for Multi-applications Running on Wireless Sensor Networks," in: 24th International Conference on Advanced Information Networking and Applications Workshops, IEEE, 2010, pp. 299-304. Y. Kwon, S. Sundresh, K. Mechitov, and G. Agha, “ActorNet: an actor platform for wireless sensor networks,” in: 5th International Joint Conference on Autonomous Agents and Multiagent Systems, 2006, pp. 1297-1300. T. Heimfarth, E. de Freitas, C. Pereira, A. Ferreira, F. Wagner, and T. Larsson, "Experimental Analysis of a Wireless Sensor Network Setup Strategy Provided by an Agent-Oriented Middleware," in: 24th International Conference on Advanced Information Networking and Applications Workshops, IEEE, 2010, pp. 820-826. R. Newton, Arvind, and M. Welsh, "Building up to macroprogramming: an intermediate language for sensor networks," in: 4th International Symposium on Information Processing in Sensor Networks, 2005, pp. 37-44. L. Evers, P. Havinga, and J. Kuper, "Dynamic Sensor Network Reprogramming using Sensorscheme," in: IEEE 18th International Symposium on Personal, Indoor and Mobile Radio Communications, 2007, pp.1-5. R. Sharrock, A. Cherbal, L. Gurgen, T. Monteil, and S. Honiden, "Thinking Autonomic for Sensing Devices," in: 6th International Conference on Autonomic and Autonomous Systems, 2010, pp. 20-23. V. Gupta, E. Tovar, L. Pinho, J. Kim, K. Lakshmanan, and R. Rajkumar, "sMapReduce: a programming pattern for wireless sensor networks," in: SESENA ’11 2nd Workshop on Software Engineering for Sensor Network Applications, 2011, pp. 37-42.