sesena 2012

22

Upload: alessandro-sivieri

Post on 13-May-2015

344 views

Category:

Technology


0 download

DESCRIPTION

Presentation of my PhD research at SESENA 2012

TRANSCRIPT

Page 1: Sesena 2012

Drop the Phone and Talk to the Physical World:

Programming the Internet of Things with Erlang

Alessandro Sivieri Luca Mottola Gianpaolo Cugola

DEEPSE GroupDipartimento di Elettronica e Informazione

Politecnico di Milano

Third International Workshop on

Software Engineering for Sensor Network Applications

June 2nd, 2012

Page 2: Sesena 2012

Scenario

Internet of Things

I Sensing and actuation systems

I Massively decentralized

I Heterogeneous devices

Wireless Sensor Networks

I Forerunner and key component of IoT

I WSN community was the �rst to tackle the IoT issues

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 2

Page 3: Sesena 2012

Motivation

Current approaches

I Low-level frameworks (i.e., TinyOS, Contiki): full control of

resources vs. di�culties in testing and maintaining applications

I High-level frameworks (i.e., Regiment, Flask): ease of

programming vs. generality and performance

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 3

Page 4: Sesena 2012

ErLang meets IoT

Why Erlang

I Actor-like concurrency

model

I Declarative programming

I . . .

ELIoT

I Dedicated libraries and customized syntax for many-to-many

IPC

I Reduced hardware requirements for the run-time system

I Dedicated simulator (full and mixed con�gurations)

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 4

Page 5: Sesena 2012

Outline

Erlang

ELIoT

Preliminary results

Conclusions

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 5

Page 6: Sesena 2012

Erlang

Main characteristics

I Concurrent execution without shared memory, side-e�ects free

computation

I Transparency of the network distribution

I Single-assignment semantics, improving testing and debugging

I Libraries for fault detection

I Code hot-swap

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 6

Page 7: Sesena 2012

Erlang - A Brief Example

Creating processes

1 start(X) ->2 Pid = spawn(fun operations/0),3 Pid ! {self(), X},4 receive5 {Sender , Result} ->6 Result7 end.89 operations () ->

10 receive11 {Sender , Number} ->12 Sender ! {self(), Number * Number};13 {Sender , Number1 , Number2} ->14 Sender ! {self(), Number1 * Number2}15 end.

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 7

Page 8: Sesena 2012

Erlang - A Brief Example

Sending messages

1 start(X) ->2 Pid = spawn(fun operations /0),3 Pid ! {self(), X},4 receive5 {Sender , Result} ->6 Result7 end.89 operations () ->

10 receive11 {Sender , Number} ->12 Sender ! {self(), Number * Number};13 {Sender , Number1 , Number2} ->14 Sender ! {self(), Number1 * Number2}15 end.

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 7

Page 9: Sesena 2012

Erlang - A Brief Example

Receiving messages using pattern matching

1 start(X) ->2 Pid = spawn(fun operations /0),3 Pid ! {self(), X},4 receive5 {Sender , Result} ->6 Result7 end.89 operations () ->

10 receive11 {Sender, Number} ->12 Sender ! {self(), Number * Number};13 {Sender , Number1 , Number2} ->14 Sender ! {self(), Number1 * Number2}15 end.

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 7

Page 10: Sesena 2012

Outline

Erlang

ELIoT

Preliminary results

Conclusions

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 8

Page 11: Sesena 2012

ELIoTThe library

I Processes must be explicitly allowed to receive messages from

other devices

I The send operator (!) also supports broadcast operations

1 myprocess () ->2 erlang:register(somename , self()),3 erlang:export(somename),4 Data = eliot_gpio:get(? TEMPERATURE),5 {somename , all} ! {temperature , Data}.

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 9

Page 12: Sesena 2012

ELIoTThe library

I Processes can be spawned on other nodes of the network,

nodes can specify properties that can be used to choose on

which of them these processes will be executed

mysensor_init() ->eliot:put(room, 301).

mysink_update () ->Cnd = fun() ->

eliot:get(room) == 301end ,eliot:spawn(fun newfunction /0, Cnd).

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 10

Page 13: Sesena 2012

ELIoTThe library

I Processes can be spawned on other nodes of the network,

nodes can specify properties that can be used to choose on

which of them these processes will be executed

mysensor_init () ->eliot:put(room , 301).

mysink_update() ->Cnd = fun() ->

eliot:get(room) == 301end,eliot:spawn(fun newfunction/0, Cnd).

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 10

Page 14: Sesena 2012

ELIoTThe interpreter

I Removed all functionalities integrated in the platform but not

required for IoT applications

I Support for sensing and actuation devices

I Support for broadcast operations directly integrated in the

interpreter

Microprocessor Ralink RT3050RAM 32 MBROM 8 MBFreq. 320 MHzNetworking Ethernet, WiFiInterfaces GPIO/SPI/I2C/Serial

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 11

Page 15: Sesena 2012

ELIoTThe simulator

I Leverage Erlang native transparency of the network distribution

I Full simulation using virtual nodes and unmodi�ed code,

model the virtual communication using di�erent techniques

I Mixed simulation using virtual and real nodes at the same time

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 12

Page 16: Sesena 2012

ELIoTThe simulator

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 13

Page 17: Sesena 2012

Outline

Erlang

ELIoT

Preliminary results

Conclusions

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 14

Page 18: Sesena 2012

Preliminary results

Example applications

I Trickle, a propagation algorithm

I Opportunistic �ooder, another propagation algorithm

I Collection Tree Protocol, a data collection algorithm

Some numbers

Algorithm TinyOS Contiki ELIoT % gained

Opportunistic �ooder 495 187 178 5-64%Trickle 219 194 148 24-32%CTP 2169 1470 450 70-80%

Lines of code

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 15

Page 19: Sesena 2012

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 16

Page 20: Sesena 2012

Outline

Erlang

ELIoT

Preliminary results

Conclusions

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 17

Page 21: Sesena 2012

Conclusions

I Leverage Erlang native characteristics, introduce new

mechanisms required by IoT

I Single node programming, reprogramming of the entire

network

I Testing and simulation in full or mixed con�gurations

Future Works

I Integration of IoT idioms into the language

I Further customization of the interpreter

I Formal veri�cation (correctness) of applications

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 18

Page 22: Sesena 2012

Thank You

Questions?

A. Sivieri, L. Mottola, G. Cugola ErLang for the Internet of Things 19