actinium: a restful runtime container for scriptable ... · actinium: a restful runtime container...

19
Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter, and Simon Duquennoy [email protected] Friday, 26 Oct 2012 Internet of Things 2012, Wuxi, China

Upload: others

Post on 20-May-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for

Scriptable Internet of Things Applications

Matthias Kovatsch, Martin Lanter, and Simon Duquennoy [email protected]

Friday, 26 Oct 2012 Internet of Things 2012, Wuxi, China

Page 2: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Wireless Sensor Networks for the IoT

2

Environmental Monitoring

Smart Energy

Structural Health

Context-Awareness

Ambient Assisted Living

Real-time City

Information

Logistics

Page 3: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Problem: Application Development

3

Class 1 devices ~100kB ROM

~10kB RAM

Embedded OS

programming? Experts!

Macro-

programming? Islands!

Page 4: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Web of Things for Class 1 Devices

4

6LoWPAN

End-to-end RESTful interaction

Web scripting

/actuators/leds

/debug/channel

/debug/neighbors

/debug/observers

/debug/routes

/sensors/battery

/sensors/button

/sensors/humidity

/sensors/light

/sensors/temperature

Web server / REST API

CoAP

I-D: draft-ietf-core-coap-12

Page 5: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Example: Smart Home

5

if ( occupied ) { heatRoom( COMFORT_TEMP ); }

Heating Script

http://weather.com

Page 6: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Actinium RESTful Runtime Container

6

Script POST

2.01 Created

Config

POST

2.01 Created

/instance/my-instance PUT

2.04 Changed Sandbox /running/my-instance REST API

/installed/my-app

/install

DELETE

2.02 Deleted

Server-side

JavaScript

Page 7: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Actinium Apps Are REST Resources

7

// handler for GET requests to "/" app.root.onget = function(request) { // returns CoAP's "2.05 Content" with payload request.respond(2.05, "Hello world"); }; // sub-resource "/config" var sub = new AppResource("config"); sub.onput = function(request) { variable = request.payloadText; request.respond(2.04); // "2.04 Changed" }; app.root.add(sub);

Page 8: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Mashups

8

Ac App

Ac App

Ac App

Page 9: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Mashups with Classic Web Services

9

// Usual AJAX var xhr = new XMLHttpRequest(); // GET weather conditions from Web service xhr.open("GET", "http://api.wunderground.com/…", false); xhr.send(); // Parse the retrieved JSON data and mash it up var condition = JSON.parse(xhr.responseText);

Page 10: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Mashups with Devices and other Apps

10

var req = new CoapRequest(); // Request the temperature sensor reading via CoAP req.open("GET", "coap://mote1.example.com/sensors/temp", false /*synchronous*/); // Set Accept header to application/json req.setRequestHeader("Accept", "application/json"); req.send(); // blocking // Use IoT data just like Web data var roomTemperature = JSON.parse(req.responseText);

Page 11: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

CoapRequest with CoAP-specific Features

11

req.open("GET", "coap://app-server.example.com/ running/occ-room1/occupancy”, true /*asynchronous*/); // Register for CoAP Observe push notifications req.setRequestHeader("Observe", "0"); // define the callback for push notifications req.onprogess = function() { switchLights(this.responseText=="true"); }; // define the callback for normal/final response req.onload = function() { handleNonObservable(this); }; req.send(); // non-blocking

Page 12: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Implementation: https://github.com/mkovatsc

12

Mozilla Rhino

JavaScript Engine

Actinium (Ac)

App-server

Californium

CoAP framework

+ =

Page 13: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Ac Round-Trip Time Overhead

1000 Requests Minimum Maximum Average Overhead

Ping 32ms 77ms 46ms

CoAP (Cf) 34ms 78ms 48ms +2ms

Actinium 33ms 97ms 49ms +1ms

13

Subnet A Subnet B

SLIP

802.15.4CH 21

Mote 1..10Border router

App server Router

LLN

Page 14: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Ac Performance: Quicksort (Memory-intensive)

Act

iniu

m e

xecu

tio

n t

ime

[m

s]

0

200

400

600

800

1000

1200

1400

Pe

rfo

rman

ce f

acto

rs

Array size

1

6

11

16

21

Java

node.js

Actinium

0 1E+5 2E+5 3E+5 4E+5 5E+5

14

Page 15: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Ac Performance: Newton (Arithmetic-intensive)

15

Pe

rfo

rma

nce

fa

cto

rs

1

6

11

16

21

Java

node.js

Actinium

Act

iniu

m e

xecu

tio

n t

ime

[m

s]

0

200

400

600

800

1000

1200

1400

0 1E+6 2E+6 3E+6 4E+6 5E+6

Number of computations

Page 16: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Conclusion

Applications for Class 1 devices can easily be scripted

Web-like IoT application development

Seamless Web integration

Performance governed by low-power networking

Scripting well-suited for application logic

Native implementations for memory-intensive tasks

Security considerations (in the paper)

Get Actinium from GitHub https://github.com/mkovatsc

16

Page 17: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

THANK YOU

Questions?

17

Page 18: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

Publicly Available Resources

Open Source Software under 3-Clause BSD on GitHub:

https://github.com/mkovatsc

Maven repository:

http://maven.thingml.org/

Copper (Cu) Firefox add-on:

https://addons.mozilla.org/en-US/firefox/addon/copper-270430/

CoAP test server:

http://vs0.inf.ethz.ch/ for detailed information

18

Page 19: Actinium: A RESTful Runtime Container for Scriptable ... · Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch, Martin Lanter,

Actinium: A RESTful Runtime Container for Scriptable Internet of Things Applications Matthias Kovatsch

The CoAP Universe

IETF working group «Constrained RESTful Environments»

Constrained Application Protocol (CoAP) RESTful Web services for mote-class devices

Transparent mapping to HTTP

Observing Resources in CoAP

Group Communication for CoAP

Blockwise Transfers in CoAP

CoRE Link Format

CoRE Resource Directory

19