mate: a tiny virtual machine for sensor networks

50
Mate: A Tiny Virtual Machine for Sensor Networks Philip Levis and David Culler Presented by: Damon Jo

Upload: dani

Post on 22-Jan-2016

71 views

Category:

Documents


0 download

DESCRIPTION

Mate: A Tiny Virtual Machine for Sensor Networks. Philip Levis and David Culler Presented by: Damon Jo. Mate(mah-tay): A tea like beverage consumed mainly in Argentina, Uruguay, Paraguay and southern Brazil…. The Origin of MATE. Outline. Problem Statement Sensor Network TinyOS Mate - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mate: A Tiny Virtual Machine for Sensor Networks

Mate: A Tiny Virtual Machine for Sensor Networks

Philip Levis and David CullerPresented by: Damon Jo

Page 2: Mate: A Tiny Virtual Machine for Sensor Networks

The Origin of MATE

Mate(mah-tay): A tea like beverage consumed mainly in Argentina, Uruguay, Paraguay and southern Brazi

l…

Page 3: Mate: A Tiny Virtual Machine for Sensor Networks

Outline Problem Statement Sensor Network TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 4: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 5: Mate: A Tiny Virtual Machine for Sensor Networks

Why Do We Need VM in WSN?

Large number (100’s to 1000’s) of nodes in a coverage area

Some nodes will fail during operation Change of function during the mission Almost impossible to manually recollect

and reprogram Need for viral program

Page 6: Mate: A Tiny Virtual Machine for Sensor Networks

Sensor Network in Operation(Great Duck Island?)

Page 7: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 8: Mate: A Tiny Virtual Machine for Sensor Networks

Berkley TOS Motes

2850

Alk/ 2AA

225

Li/ CR2032

Battery Power

Alk/ 2AALi/ CR2450Type/ Size

2850575Capacity (mAh)

OOK/ ASKOOKModulation Type

10/ 4010Rate (Kbps)

RFM TR1000Radio

Communication

410.5RAM (KB)

128168Prog. mem. (KB)

ATMega103/ 128ATMega163AT90LS8535Type

Microcontroller (4MHz)

Feb-02Aug-01Jun-01Oct-00Sep-99Date

MicaDotRene2ReneWeCMote Type

2850

Alk/ 2AA

225

Li/ CR2032

Battery Power

Alk/ 2AALi/ CR2450Type/ Size

2850575Capacity (mAh)

OOK/ ASKOOKModulation Type

10/ 4010Rate (Kbps)

RFM TR1000Radio

Communication

410.5RAM (KB)

128168Prog. mem. (KB)

ATMega103/ 128ATMega163AT90LS8535Type

Microcontroller (4MHz)

Feb-02Aug-01Jun-01Oct-00Sep-99Date

MicaDotRene2ReneWeCMote Type

Page 9: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 10: Mate: A Tiny Virtual Machine for Sensor Networks

TinyOS – Software Architecture

Component based programming model Three computational abstraction:

• commands(down), events(up)• non-blocking • split phase• asynchronous(hardware interrupt)

• tasks• blocking • FIFO queue

Page 11: Mate: A Tiny Virtual Machine for Sensor Networks

TinyOS – Network

Active message in TOS handles MAC single hop communication unreliable data link protocol 30 byte payload 16-bit mote ID, 0xffff: broadcast 8-bit type; selects software handler 8-bit AM group; logical network separation

Page 12: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 13: Mate: A Tiny Virtual Machine for Sensor Networks

Related Works PicoJava

Java bytecode execution hardware K Virtual Machine

requires 160 – 512 KB of memory XML

too complex and not enough RAM Scylla

VM for mobile embedded system

Suggested solutionMate: A Tiny Virtual Machine for Sensor Network

Page 14: Mate: A Tiny Virtual Machine for Sensor Networks

System Requirements Small(16KB inst mem, 1KB RAM) Expressive(versatile) Concise(limited memory & bandwidth) Resilience(memory protection) Efficient(bandwidth) Tailorable(user defined instructions) Simple(viral programming)

Page 15: Mate: A Tiny Virtual Machine for Sensor Networks

Mate in a Nutshell Built on TinyOS, runs on rene and mica Stack Architecture Three concurrent execution contexts Execution triggered by predefined events Tiny code capsules; self-propagate into networ

k Built in communication and sensing instructio

ns

Page 16: Mate: A Tiny Virtual Machine for Sensor Networks

Component Breakdown Mate runs on rene2 and mica 7286 bytes code, 603 bytes RAM

Page 17: Mate: A Tiny Virtual Machine for Sensor Networks

Mate Architecture

0 1 2 3

Subroutines

Clock

Send

Receive

Events

gets/sets

0 1 2 3

Subroutines

Clock

Send

Receive

Events

gets/sets

Code

OperandStack

ReturnStack

PC

Code

OperandStack

ReturnStack

PC

Stack based architecture Single shared variable

•gets/sets Three events:

•Clock timer•Message reception•Message send

Hides asynchrony•Simplifies programming•Less prone to bugs

Page 18: Mate: A Tiny Virtual Machine for Sensor Networks

Instruction Set

One byte per instruction Three classes: basic, s-type, x-type

•basic: arithematic, halting, LED operation•s-type: messaging system•x-type: pushc, blez

8 instructions reserved for users to define Instruction polymorphism

•ex) add(data, message, sensing)

Page 19: Mate: A Tiny Virtual Machine for Sensor Networks

Code Example(1) Display Counter to LED

gets # Push heap variable on stackpushc 1 # Push 1 on stackadd # Pop twice, add, push resultcopy # Copy top of stacksets # Pop, set heappushc 7 # Push 0x0007 onto stackand # Take bottom 3 bits of valueputled # Pop, set LEDs to bit patternhalt #

Page 20: Mate: A Tiny Virtual Machine for Sensor Networks

Code Example(2) Sense and Send

pushc 1 # Light is sensor 1sense # Push light reading on stackpushm # Push message buffer on stackclear # Clear message bufferadd # Append reading to buffersend # Send message using built-inhalt # ad-hoc routing system

Page 21: Mate: A Tiny Virtual Machine for Sensor Networks

TinyOS Sense and Sendevent result_t Timer.fired() {

if (state == IDLE && call Photo.sense()) {state = SENSE;}return SUCCESS;

}event result_t Photo.dataReady(uint16_t data) {

if (state == SENSE) {packet->reading = data;if (call SendMsg.send(packet, sizeof(DataBuf)) {

state = SENDING;} else {state = IDLE;}

}return SUCCESS;

}event result_t SendMsg.sendDone(TOS_MsgPtr msg) {

if (state == SENDING) {state = IDLE;}return SUCCESS;

}

Page 22: Mate: A Tiny Virtual Machine for Sensor Networks

Code Capsules

One capsule = 24 instructions Fits into single TOS packet Atomic reception Code Capsule

Type and version information Type: send, receive, timer, subroutine

Page 23: Mate: A Tiny Virtual Machine for Sensor Networks

Viral Code Capsule transmission: forw Forwarding other installed capsule: forwo(use

within clock capsule) Mate checks on version number on reception

of a capsule-> if it is newer, install it

Versioning: 32bit counter(lasts a long time, centuries)

Easily disseminates new code over the network

Page 24: Mate: A Tiny Virtual Machine for Sensor Networks

Propagation Example

Page 25: Mate: A Tiny Virtual Machine for Sensor Networks

Node Enters the Network

Page 26: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 27: Mate: A Tiny Virtual Machine for Sensor Networks

Evaluation Metrics

- CPU cycles- Bandwidth- Energy- Infection rate- Propagation time

Page 28: Mate: A Tiny Virtual Machine for Sensor Networks

Bytecodes vs. Native Code Mate IPS: ~10,000 Mate overhead: Every instruction is

executed as separate TOS task

Page 29: Mate: A Tiny Virtual Machine for Sensor Networks

Installation Costs Bytecodes have computational overhead But this can be compensated by using small pack

ets on upload(to some extent)

Page 30: Mate: A Tiny Virtual Machine for Sensor Networks

When is Mate Preferable?

For small number of executions GDI example:

Bytecode version is preferable for a program running less than 5 days

In energy constrained domains Use Mate capsule as a general RPC eng

ine

Page 31: Mate: A Tiny Virtual Machine for Sensor Networks

Code Propagation Evaluation Environment

42 node network in 3 by 14 grid Radio transmission: 3 hop network Cell size: 15 to 30 motes

Page 32: Mate: A Tiny Virtual Machine for Sensor Networks

Network Infection Rate Every mote runs

its clock capsule every 20 seconds

Self-forwarding clock capsule

Page 33: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 34: Mate: A Tiny Virtual Machine for Sensor Networks

Customizing Mate

We have already discussed usefulness of VM in the beginning

Mate is general architecture; user can build customized VM

User can select bytecodes and execution events

Page 35: Mate: A Tiny Virtual Machine for Sensor Networks

Customizing Issues Flexibility vs. Efficiency

Customizing increases efficiency on the cost of changing the requirements

Java’s solution:General computational VM + class libraries

Mate’s approach:More customizable solution

-> let user decide

Page 36: Mate: A Tiny Virtual Machine for Sensor Networks

Howto Select a language

-> defines VM bytecodes Select execution events

-> execution context, code image Select primitives

-> beyond language functionality

Page 37: Mate: A Tiny Virtual Machine for Sensor Networks

Constructing a Mate VM

This generatesa set of files-> which are used to buildTOS applicationandto configure script program

Page 38: Mate: A Tiny Virtual Machine for Sensor Networks

Compiling and Running a Program

Write programs in the scripter

VM-specific binary code

Send it over the network to a VM

Page 39: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 40: Mate: A Tiny Virtual Machine for Sensor Networks

Bombilla Next version of Mate?

Page 41: Mate: A Tiny Virtual Machine for Sensor Networks

Bombilla Architecture

Once context: perform operations that only need single execution

16 word heap sharing among the context; setvar, getvar

Buffer holds up to ten values;bhead, byank, bsorta

Page 42: Mate: A Tiny Virtual Machine for Sensor Networks

Bombilla Instruction Set

basic: arithmetic, halt, sensing m-class: access message header v-class: 16 word heap access j-class: two jump instructions x-class: pushc

Page 43: Mate: A Tiny Virtual Machine for Sensor Networks

Enhanced Features of Bombilla Capsule Injector: programming environment Synchronization: 16-word shared heap; locking

scheme Provide synchronization model: handler,

invocations, resources, scheduling points, sequences

Resource management: prevent deadlock Random and selective capsule forwarding Error State

Page 44: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 45: Mate: A Tiny Virtual Machine for Sensor Networks

Summary Mate is a context based, event

driven Virtual Machine Stack architecture Three instruction type Instructions are kept in capsules Viral program Prefer short CPU tasks

Page 46: Mate: A Tiny Virtual Machine for Sensor Networks

Roadmap Problem Statement Sensor Networks TinyOS Mate Evaluation Mate Customization Bombilla Summary Discussion

Page 47: Mate: A Tiny Virtual Machine for Sensor Networks

Discussion Comparing to traditional VM concept, is

Mate platform independent? Can we have it run on heterogeneous hardware?

Security issues.How can we trust the received capsule? Is there a way to prevent version number race with adversary?

Page 48: Mate: A Tiny Virtual Machine for Sensor Networks

Cont. In viral programming, is there a way to forward

messages other than flooding? After a certain number of nodes are infected by new version capsule, can we forward based on need?

Bombilla has some sophisticated OS features. What is the size of the program? Does sensor node need all those features?

Page 49: Mate: A Tiny Virtual Machine for Sensor Networks

References P. Levis and D. Culler. Mate: A Virtual Machine for Sensor Netwo

rks. ASPLOS, Oct. 2002 P. Levis and D. Culler. A Case for Infectious Virtual Programs in

Sensor Networks P. Levis. Bombilla: A Tiny Virtual Machine for TinyOS P. Stanley-Marbell and L. Lftode. Scylla: A Smart Virtual Machine

for Mobile Embedded Systems http://www.cs.berkeley.edu/~pal/research/mate.html http://www.cs.berkeley.edu/~pal/pubs/asplos02.pdf http://webs.cs.berkeley.edu/

Page 50: Mate: A Tiny Virtual Machine for Sensor Networks

Thank You