wsn platforms: hardware & software

60
WSN Platforms: Hardware & Software Murat Demirbas Lecture uses some slides from tutorials prepared by authors of these platforms

Upload: isabelle-burton

Post on 02-Jan-2016

65 views

Category:

Documents


10 download

DESCRIPTION

WSN Platforms: Hardware & Software. Murat Demirbas Lecture uses some slides from tutorials prepared by authors of these platforms. Why use a WSN?. Ease of deployment Wireless communication means no need for a communication infrastructure setup Drop and play Low-cost of deployment - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: WSN Platforms: Hardware & Software

WSN Platforms: Hardware & Software

Murat Demirbas

Lecture uses some slides from tutorials prepared by authors of these platforms

Page 2: WSN Platforms: Hardware & Software

2

Why use a WSN?

• Ease of deployment

Wireless communication means no need for a communication infrastructure setup

Drop and play

• Low-cost of deployment

Nodes are built using off-the-shelf cheap components

• Fine grain monitoring

Feasible to deploy nodes densely for fine grain monitoring

Page 3: WSN Platforms: Hardware & Software

3

Outline

• Hardware

RFID, Spec Mica2, XSM, Telos Stargate

• Software

TinyOS

• Simulation

TOSSIM Prowler

Page 4: WSN Platforms: Hardware & Software

4

Types of sensor platforms

1. RFID equipped sensors

2. Smart-dust tags

typically act as data-collectors or “trip-wires”

limited processing and communications

3. Mote/Stargate-scale nodes

• more flexible processing and communications

4. More powerful gateway nodes, potentially using wall power

Page 5: WSN Platforms: Hardware & Software

5

Popular Nodes Overview

Page 6: WSN Platforms: Hardware & Software

6

Grain-sized nodes

Powered by inductive coupling to a transmission from a reader device to transmit a message back

Available commercially at very low prices

× Computation power is severely limited

× Can only trasmit stored unique id and variable

× Hard to add any interesting sensing capability

Page 7: WSN Platforms: Hardware & Software

7

Spec Mote (3/6/2003)

• size: 2x2.5mm, AVR RISC core, 3KB memory, FSK radio (CC1000), encrypted communication hardware support, memory-mapped active messages

Page 8: WSN Platforms: Hardware & Software

8

Matchbox-sized nodes

• Mica series, XSM node, Telos

• 8-bit microprocessor, 4MHz CPU

ATMEGA 128, ATMEL 8535, or Motorola HCS08

• ~4Kb RAM

holds run-time state (values of the variables) of the program

• ~128Kb programmable Flash memory

holds the application program Downloaded via a programmer-board or wirelessly

• Additional Flash memory storage space up to 512Kb.

Page 9: WSN Platforms: Hardware & Software

9

Mica2 and Mica2Dot

• ATmega128 CPU– Self-programming

• Chipcon CC1000– FSK– Manchester encoding– Tunable frequency

• Low power consumption– 2 AA battery = 3V

1 inch

Page 10: WSN Platforms: Hardware & Software

10

Basic Sensor Board

• Light (Photo)• Temperature• Prototyping space for

new hardware designs

Page 11: WSN Platforms: Hardware & Software

11

Mica Sensor Board

• Light (Photo)• Temperature• Acceleration

– 2 axis– Resolution: ±2mg

• Magnetometer– Resolution: 134G

• Microphone• Tone Detector• Sounder

– 4.5kHz

Page 12: WSN Platforms: Hardware & Software

12

PNI Magnetometer/Compass

• Resolution: 400 Gauss

• Three axis, under $15 in large quantities

Page 13: WSN Platforms: Hardware & Software

13

Ultrasonic Transceiver

• Used for ranging• Up to 2.5m range• 6cm accuracy• Dedicated

microprocessor• 25kHz element

Page 14: WSN Platforms: Hardware & Software

14

Mica Weather Board

• Total Solar Radiation• Photosynthetically Active

Radiation– Resolution: 0.3A/W

• Relative Humidity– Accuracy: ±2%

• Barometric Pressure– Accuracy: ±1.5mbar

• Temperature– Accuracy: ±0.01oC

• Acceleration– 2 axis– Resolution: ±2mg

• Designed by UCB w/ Crossbow and UCLA

Revision 1.5

Revision 1.0

Page 15: WSN Platforms: Hardware & Software

15

MicaDot Sensor Boards

“Dot” sensorboards (1”diameter)HoneyDot: Magnetometer

Resolution: 134 mGaussUltrasonic TransceiverWeather Station

Page 16: WSN Platforms: Hardware & Software

16

XSM node platform

• Derived from Mica2 mote

• Better sensor & actuator range– 4 Passive Infrared: ~ 25m for SUV– Sounder: ~10m– Microphone: ~ 50m for ATV– Magnetometer: ~ 7m for SUV

• Better radio range ~30m

• Other features:

– Grenade timer

– Wakeup circuits (Mic, PIR)

– Adjustable frequency sounder

– Integrated Mag Set/Reset

Page 17: WSN Platforms: Hardware & Software

17

Telos Platform

• Low Power

Minimal port leakage

Hardware isolation and buffering

• Robust

Hardware flash write protection

Integrated antenna (50m-125m)

Standard IDC connectors

• Standards Based

USB

IEEE 802.15.4 (CC2420 radio)

• High Performance

10kB RAM, 16-bit core, extensive double buffering

12-bit ADC and DAC (200ksamples/sec)

DMA transfers while CPU off

Page 18: WSN Platforms: Hardware & Software

18

TelosMeeting the Low Power Goal

All values measured at room temperature (approximately 25oC) at 3V supply voltageSource: “Telos: Enabling Low Power Wireless Sensor Network Research”

To appear, IPSN/SPOTS, April 2005

Page 19: WSN Platforms: Hardware & Software

19

Telos Performance

• 200ksamples/sec sampling rate, DMA transfers, DAC– Increased performance & functionality over existing designs

• New “link quality indicator” predicts average packet loss

Distance (ft) Distance (ft) Distance (ft)

Pac

ket

Suc

cess

Ave

rage

LQ

I

RS

SI

Flat field range test @ 4” off ground (125m @ 1m elevation)

Page 20: WSN Platforms: Hardware & Software

20

Brick-sized node: Stargate

• Mini Linux computers communicating via 802.11 radios

Computationally powerful High bandwidth Requires more energy (AA infeasible)

• Used as a gateway between the Internet and WSN

Page 21: WSN Platforms: Hardware & Software

21

Stargate

Page 22: WSN Platforms: Hardware & Software

22

Manufacturers of Sensor Nodes

• Crossbow (www.xbow.com)

Mica2 mote, Micaz, Dot mote and Stargate Platform

• Intel Research

Stargate, iMote

• Moteiv – Telos Mote

• Dust Inc

Smart Dust

• Cogent Computer (www.cogcomp.com)

XYZ Node (CSB502) in collaboration with ENALAB@Yale

• Sensoria Corporation (www.sensoria.com)

WINS NG Nodes

• Millenial Net (www.millenial.com)

iBean sensor nodes

• Ember (www.ember.com)

Integrated IEEE 802.15.4 stack and radio on a single chip

Page 23: WSN Platforms: Hardware & Software

23

Challenges in sensor networks

• Energy constraint

• Unreliable communication

• Unreliable sensors

• Ad hoc deployment

• Large scale networks

• Limited computation power

• Distributed execution

: Nodes are battery powered

: Radio broadcast, limited bandwidth, bursty traffic

: False positives

: Pre-configuration inapplicable

: Algorithms should scale well

: Centralized algorithms inapplicable

: Difficult to debug & get it right

Page 24: WSN Platforms: Hardware & Software

24

Opportunities in sensor networks

• Precise clock at each node

• Atomic broadcast primitive

• Geometry

• New applications

: Timers, synchronized clocks

: All recipients hear the same message at the same time

: Dense nodes over 2D plane

: Tracking, spatial querying, geographic routing, localization, network reprogramming, etc.

Page 25: WSN Platforms: Hardware & Software

25

Outline

• Hardware

RFID, Spec Mica2, XSM, Telos Stargate

• Software

TinyOS

• Simulation

TOSSIM Prowler

Page 26: WSN Platforms: Hardware & Software

26

TinyOS

• most popular operating system for WSN

developed by UC Berkeley

• features a component-based architecture

software is written in modular pieces called components Each component denotes the interfaces that it provides

An interface declares a set of functions called commands that the interface provider implements and another set of functions called events that the interface user should be ready to handle

• Easy to link components together by “wiring” their interfaces to form larger components

similar to using Lego blocks

Page 27: WSN Platforms: Hardware & Software

27

TinyOS

• provides a component library that includes network protocols, services, and sensor drivers

• An application consists of

a component written by the application developer and the library components that are used by the components in (1)

• An application developer writes only the application component that describes the sensors used in the application, the middleware services configured with the appropriate parameters based on the needs of the application

Page 28: WSN Platforms: Hardware & Software

28

Benefits of using TinyOS

• Separation of concerns

TinyOS provides a proper networking stack for wireless communicationthat abstracts away the underlying problems and complexity of message transfer from the application developer

E.g., MAC layer

• Concurrency control

TinyOS provides a scheduler that achieves efficient concurrency control An interrupt-driven execution model is needed to achieve a quick

response time for the events and capture the data

For example, a message transmission may take up to 100msec, and without an interrupt-driven approach the node would miss sensing and processing of interesting data in this period

Scheduler takes care of the intricacies of interrupt-driven execution and provides concurrency in a safe manner by scheduling the execution in small threads.

Page 29: WSN Platforms: Hardware & Software

29

Benefits of TinyOS

• Modularity

TinyOS’s component model facilitates reuse and reconfigurability since software is written in small functional modules. Several middleware services are available as well-documented components

Over 500 research groups and companies are using TinyOS and numerous groups are actively contributing code to the public domain

Page 30: WSN Platforms: Hardware & Software

30

TinyOS

• Microthreaded OS (lightweight thread support) and efficient

network interfaces

• Two level scheduling structure

Long running tasks that can be interrupted by hardware events

• Small, tightly integrated design that allows crossover of

software components into hardware

Page 31: WSN Platforms: Hardware & Software

31

TinyOS Concepts

• Scheduler + Graph of Components

constrained two-level scheduling model: threads + events

• Component:

Commands Event Handlers Frame (storage) Tasks (concurrency)

• Constrained Storage Model

frame per component, shared stack, no heap

• Very lean multithreading

• Efficient Layering

Messaging Component

init

Po

we

r(m

od

e)

TX

_p

ack

et(

bu

f)

TX

_p

ack

et_

do

ne

(s

ucc

ess

)

RX

_p

ack

et_

do

ne

(b

uff

er)

Internal

State

init

po

we

r(m

od

e)

sen

d_

msg

(ad

dr,

ty

pe

, d

ata

)

msg

_re

c(ty

pe

, d

ata

)

msg

_se

nd

_d

on

e)

internal thread

Commands Events

Page 32: WSN Platforms: Hardware & Software

32

Application = Graph of Components

RFM

Radio byte

Radio Packet

UART

Serial Packet

ADC

Temp Photo

Active Messages

clock

bit

by

tep

ac

ke

t

Route map Router Sensor Appln

ap

pli

ca

tio

n

HW

SW

Example: ad hoc, multi-hop routing of photo sensor readings

3450 B code 226 B data

Graph of cooperatingstate machines on shared stack

Page 33: WSN Platforms: Hardware & Software

33

TOS Execution Model

• commands request action

ack/nack at every boundary call command or post task

• events notify occurrence

HW interrupt at lowest level may signal events call commands post tasks

• tasks provide logical concurrency

preempted by events

RFM

Radio byte

Radio Packet

bit

by

tep

ac

ke

t

event-driven bit-pump

event-driven byte-pump

event-driven packet-pump

message-event driven

active message

application comp

encode/decode

crc

data processing

Page 34: WSN Platforms: Hardware & Software

34

Event-Driven Sensor Access Pattern

• clock event handler initiates data collection

• sensor signals data ready event

• data event handler calls output command

• device sleeps or handles other activity while waiting

• conservative send/ack at component boundary

command result_t StdControl.start() {

return call Timer.start(TIMER_REPEAT, 200);

}

event result_t Timer.fired() {

return call sensor.getData();

}

event result_t sensor.dataReady(uint16_t data) {

display(data)

return SUCCESS;

}

SENSE

Timer Photo LED

Page 35: WSN Platforms: Hardware & Software

35

TinyOS Commands and Events

{... status = call CmdName(args)...}

command CmdName(args) {...return status;}

{... status = signal EvtName(args)...}

event EvtName(args) {...return status;}

Page 36: WSN Platforms: Hardware & Software

36

TinyOS Execution Contexts

• Events generated by interrupts preempt tasks

• Tasks do not preempt tasks

• Both essential process state transitions

Hardware

Interrupts

eve

nts

commands

Tasks

Page 37: WSN Platforms: Hardware & Software

37

Tasks

• provide concurrency internal to a component

longer running operations

• are preempted by events

• able to perform operations beyond event context

• may call commands

• may signal events

• not preempted by tasks

{...post TskName();...}

task void TskName {...}

Page 38: WSN Platforms: Hardware & Software

38

Typical Application Use of Tasks

• event driven data acquisition

• schedule task to do computational portion

event result_t sensor.dataReady(uint16_t data) {

putdata(data);

post processData();

return SUCCESS;

}

task void processData() {

int16_t i, sum=0;

for (i=0; i ‹ maxdata; i++)

sum += (rdata[i] ›› 7);

display(sum ›› shiftdata);

}

Page 39: WSN Platforms: Hardware & Software

39

Task Scheduling

• Currently simple fifo scheduler

• Bounded number of pending tasks

• When idle, shuts down node except clock

• Uses non-blocking task queue data structure

• Simple event-driven structure + control over complete

application/system graph

instead of complex task priorities

Page 40: WSN Platforms: Hardware & Software

40

Maintaining Scheduling Agility

• Need logical concurrency at many levels of the graph

• While meeting hard timing constraints

sample the radio in every bit window

Retain event-driven structure throughout application

Tasks extend processing outside event window

All operations are non-blocking

Page 41: WSN Platforms: Hardware & Software

41

RadioTimingSecDedEncode

The Complete Application

RadioCRCPacket

UART

UARTnoCRCPacket

ADC

phototemp

AMStandard

ClockC

bit

by

tep

ac

ke

t

SenseToRfm

HW

SW

IntToRfm

MicaHighSpeedRadioM

RandomLFSRSPIByteFIFO

SlavePin

noCRCPacket

Timer photo

ChannelMon

generic comm

CRCfilter

Page 42: WSN Platforms: Hardware & Software

42

Programming Syntax

• TinyOS 2.0 is written in an extension of C, called nesC

• Applications are too

just additional components composed with OS components

• Provides syntax for TinyOS concurrency and storage model

commands, events, tasks local frame variable

• Compositional support separation of definition and linkage robustness through narrow interfaces and reuse Interpositioning

• Whole system analysis and optimization

Page 43: WSN Platforms: Hardware & Software

43

Components

• A component specifies a set of interfaces by which it is connected to other components

provides a set of interfaces to others uses a set of interfaces provided by others

• Interfaces are bidirectional

include commands and events

• Interface methods are the external namespace of the

component

Timer Component

StdControl Timer

Clock

provides

uses

provides

interface StdControl;

interface Timer:

uses

interface Clock

Page 44: WSN Platforms: Hardware & Software

44

Component Interface

• logically related set of commands and events

StdControl.nc

interface StdControl {

command result_t init();

command result_t start();

command result_t stop();

}

Clock.nc

interface Clock {

command result_t setRate(char interval, char scale);

event result_t fire();

}

Page 45: WSN Platforms: Hardware & Software

45

Component Types

• Configurations

link together components to compose new component

configurations can be nested

complete “main” application is always a configuration

• Modules

provides code that implements one or more interfaces and

internal behavior

Page 46: WSN Platforms: Hardware & Software

46

Example1

• Blink application

configuration Blink {}

implementation { components Main, BlinkM, TimerC, LedsC;

Main.StdControl -> TimerC.StdControl; Main.StdControl -> BlinkM.StdControl;

BlinkM.Timer -> TimerC.Timer[unique("Timer")];

BlinkM.Leds -> LedsC;}

TimerC LedsC

Main

Blink

BlinkM

Blink.nc

Page 47: WSN Platforms: Hardware & Software

47

Example1

• BlinkM module:

module BlinkM { provides interface StdControl; uses interface Timer; uses interface Leds;}

implementation {

command result_t StdControl.init() {call Leds.init();

return SUCCESS; }

Blink.nc

command result_t StdControl.start() { return call Timer.start(TIMER_REPEAT,

1000); }

command result_t StdControl.stop() { return call Timer.stop(); }

event result_t Clock.fire() { call Leds.redToggle(); return SUCCESS; }} Blink.nc

Page 48: WSN Platforms: Hardware & Software

48

Example2

configuration SenseToRfm {

}

implementation

{

components Main, SenseToInt, IntToRfm, TimerC, Photo as Sensor;

Main.StdControl -> SenseToInt;

Main.StdControl -> IntToRfm;

SenseToInt.Timer -> TimerC.Timer[unique”Timer”];

SenseToInt.ADC -> Sensor;

SenseToInt.ADCControl -> Sensor;

SenseToInt.IntOutput -> IntToRfm;

} SenseToInt

TimerC Photo

Main

StdControl

ADCControl IntOutputTimer ADC

IntToRfm

Page 49: WSN Platforms: Hardware & Software

49

Nested Configuration

includes IntMsg;

configuration IntToRfm{

provides {

interface IntOutput;

interface StdControl;

}

}

implementation

{

components IntToRfmM, GenericComm as Comm;

IntOutput = IntToRfmM;

StdControl = IntToRfmM;

IntToRfmM.Send -> Comm.SendMsg[AM_INTMSG];

IntToRfmM.SubControl -> Comm;

}

IntToRfmM

GenericComm

StdControl IntOutput

SubControl SendMsg[AM_INTMSG];

Page 50: WSN Platforms: Hardware & Software

50

IntToRfm Module

includes IntMsg;

module IntToRfmM

{

uses {

interface StdControl as SubControl;

interface SendMsg as Send;

}

provides {

interface IntOutput;

interface StdControl;

}

}

implementation

{

bool pending;

struct TOS_Msg data;

command result_t StdControl.init() {

pending = FALSE;

return call SubControl.init();

}

command result_t StdControl.start()

{ return call SubControl.start(); }

command result_t StdControl.stop()

{ return call SubControl.stop(); }

command result_t IntOutput.output(uint16_t value)

{

...

if (call Send.send(TOS_BCAST_ADDR,sizeof(IntMsg), &data)

return SUCCESS;

...

}

event result_t Send.sendDone(TOS_MsgPtr msg, result_t success)

{

...

}

}

Page 51: WSN Platforms: Hardware & Software

51

Atomicity Support in nesC

• Split phase operations require care to deal with pending operations

• Race conditions may occur when shared state is accessed by premptible executions, e.g. when an event accesses a shared state, or when a task updates state (premptible by an event which then uses that state)

• nesC supports atomic block

implemented by turning of interrupts for efficiency, no calls are allowed in block access to shared variable outside atomic block is not allowed

Page 52: WSN Platforms: Hardware & Software

52

Supporting HW Evolution

• Distribution broken into

apps: top-level applications tos:

lib: shared application components

system: hardware independent system components

platform: hardware dependent system components includes HPLs and hardware.h

interfaces

tools: development support tools

contrib

beta

• Component design so HW and SW look the same

example: temp component

may abstract particular channel of ADC on the microcontroller

may be a SW I2C protocol to a sensor board with digital sensor or ADC

• HW/SW boundary can move up and down with minimal changes

Page 53: WSN Platforms: Hardware & Software

53

Sending a Message

bool pending;

struct TOS_Msg data;

command result_t IntOutput.output(uint16_t value) {

IntMsg *message = (IntMsg *)data.data;

if (!pending) {

pending = TRUE;

message->val = value;

message->src = TOS_LOCAL_ADDRESS;if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data))

return SUCCESS;

pending = FALSE;

}

return FAIL;

}destination length

• Refuses to accept command if buffer is still full or network refuses to accept send command

• User component provide structured msg storage

Page 54: WSN Platforms: Hardware & Software

54

Send done Event

• Send done event fans out to all potential senders

• Originator determined by match

free buffer on success, retry or fail on failure

• Others use the event to schedule pending communication

event result_t IntOutput.sendDone(TOS_MsgPtr msg, result_t success)

{

if (pending && msg == &data) {

pending = FALSE;

signal IntOutput.outputComplete(success);

}

return SUCCESS;

}

}

Page 55: WSN Platforms: Hardware & Software

55

Receive Event

• Active message automatically dispatched to associated handler

knows format, no run-time parsing

performs action on message event

• Must return free buffer to the system

typically the incoming buffer if processing complete

event TOS_MsgPtr ReceiveIntMsg.receive(TOS_MsgPtr m) {

IntMsg *message = (IntMsg *)m->data;

call IntOutput.output(message->val);

return m;

}

Page 56: WSN Platforms: Hardware & Software

56

Tiny Active Messages

• Sending

declare buffer storage in a frame request transmission name a handler handle completion signal

• Receiving

declare a handler

firing a handler: automatic

• Buffer management

strict ownership exchange

tx: send done event reuse

rx: must return a buffer

Page 57: WSN Platforms: Hardware & Software

57

Tasks in Low-level Operation

• transmit packet

send command schedules task to calculate CRC task initiates byte-level data pump events keep the pump flowing

• receive packet

receive event schedules task to check CRC task signals packet ready if OK

• byte-level tx/rx

task scheduled to encode/decode each complete byte

must take less time that byte data transfer

Page 58: WSN Platforms: Hardware & Software

58

TinyOS tools

• TOSSIM: a simulator for tinyos programs

• ListenRaw, SerialForwarder: java tools to receive raw packets on PC from base node

• Oscilloscope: java tool to visualize (sensor) data in real time

• Memory usage: breaks down memory usage per component (in contrib)

• Peacekeeper: detect RAM corruption due to stack overflows (in lib)

• Stopwatch: tool to measure execution time of code block by timestamping at entry and exit (in osu CVS server)

• Makedoc and graphviz: generate and visualize component hierarchy

• Surge, Deluge, SNMS, TinyDB

Page 59: WSN Platforms: Hardware & Software

59

TinyOS Limitations

• Static allocation allows for compile-time analysis, but can make programming harder

• No support for heterogeneity

Support for other platforms (e.g. stargate)

Support for high data rate apps (e.g. acoustic beamforming)

Interoperability with other software frameworks and languages

• Limited visibility

Debugging

Intra-node fault tolerance

• Robustness solved in the details of implementation

nesC offers only some types of checking

Page 60: WSN Platforms: Hardware & Software

60

Outline

• Hardware

Mica2 XSM Telos

• Software

TinyOS

• Simulation

TOSSIM Prowler