wsn_NesC

download wsn_NesC

of 54

Transcript of wsn_NesC

  • 8/8/2019 wsn_NesC

    1/54

    Wireless Sensor Networks:Motes, NesC, and TinyOS

    Jurgen Schonwalder, Matus Harvan

    Jacobs University BremenBremen, Germany

    EECS Seminar, 24 April 2007

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 1

    http://find/http://goback/
  • 8/8/2019 wsn_NesC

    2/54

    25 Years of Development. . .

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 2

    http://find/
  • 8/8/2019 wsn_NesC

    3/54

    25 Years of Development. . .

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 2

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    4/54

    Outline

    1 Wireless Sensor Networks

    Definition and ApplicationsHardware (Processors, Boards, Radios, . . . )Constraints and Challenges

    2 NesC and TinyOSNesC Language OverviewTinyOS: Operating System for WSNsDemonstration

    3 Internet and Wireless Sensor NetworksTranslating Gateway/ProxyuIP, 6lowpanDemonstration

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 3

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    5/54

    Outline

    1 Wireless Sensor Networks

    Definition and ApplicationsHardware (Processors, Boards, Radios, . . . )Constraints and Challenges

    2 NesC and TinyOSNesC Language OverviewTinyOS: Operating System for WSNsDemonstration

    3 Internet and Wireless Sensor NetworksTranslating Gateway/ProxyuIP, 6lowpanDemonstration

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 4

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    6/54

    Wireless Sensor Networks

    DefinitionA wireless sensor network (WSN) is a wirelessnetwork consisting of spatially distributedautonomous devices using sensors tocooperatively monitor physical or environmentalconditions, such as temperature, sound, vibration,pressure, motion or pollutants.

    Small computers with a wireless interface

    Smart alternatives to dumb RFID tags

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 5

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    7/54

    Wireless Sensor Networks

    DefinitionA wireless sensor network (WSN) is a wirelessnetwork consisting of spatially distributedautonomous devices using sensors tocooperatively monitor physical or environmentalconditions, such as temperature, sound, vibration,pressure, motion or pollutants.

    Small computers with a wireless interface

    Smart alternatives to dumb RFID tags

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 5

    A l

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    8/54

    Applications

    Environmental monitoring

    Seismic detection

    Disaster situation monitoring and recovery

    Health and medical monitoring

    Inventory tracking and logistics

    Smart spaces (home/office scenarios)

    Military surveillance

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 6

    P A l / TI / I l

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    9/54

    Processors Atmel / TI / Intel

    Atmel AVR ATmega 128

    8 bit RISC at XX MHz, 32 registers

    4kB RAM, 128kB Flash, 4kB EEPROM

    TI MSP43016 bit RISC at 8 MHz, 16 registers

    10kB RAM, 48kB Flash, 16kB EEPROM

    Intel PXA271 XScale32 bit RISC at 13-416MHz, 16 registers

    256kB SRAM, 32MB SDRAM, 32MB Flash

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 7

    P A l / TI / I l

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    10/54

    Processors Atmel / TI / Intel

    Atmel AVR ATmega 128

    8 bit RISC at XX MHz, 32 registers

    4kB RAM, 128kB Flash, 4kB EEPROM

    TI MSP43016 bit RISC at 8 MHz, 16 registers

    10kB RAM, 48kB Flash, 16kB EEPROM

    Intel PXA271 XScale32 bit RISC at 13-416MHz, 16 registers

    256kB SRAM, 32MB SDRAM, 32MB Flash

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 7

    P A l / TI / I l

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    11/54

    Processors Atmel / TI / Intel

    Atmel AVR ATmega 128

    8 bit RISC at XX MHz, 32 registers

    4kB RAM, 128kB Flash, 4kB EEPROM

    TI MSP43016 bit RISC at 8 MHz, 16 registers

    10kB RAM, 48kB Flash, 16kB EEPROM

    Intel PXA271 XScale32 bit RISC at 13-416MHz, 16 registers

    256kB SRAM, 32MB SDRAM, 32MB Flash

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 7

    B d T l B

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    12/54

    Boards Telos-B

    TPR2400CA Block Diagram

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 8

    B d Mi Z

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    13/54

    Boards Mica-Z

    -

    MPR2400CA Block Diagram

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 9

    S Mi S B d MTS310

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    14/54

    Sensors Mica Sensor Board MTS310

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 10

    B ds I t 2

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    15/54

    Boards Imote2

    GPIOs

    2x SPI3x UART

    I2S

    SDIOUSB host

    USB clientAC97

    Camera

    I2S

    SMA

    Supply Battery Changer

    RTC

    32MBFLASH

    32MBSDRAM

    XScaleCPU core

    802.15.4radio

    XScaleDSP

    256kB SRAM

    PowerMgt.

    Antenna

    Block Diagram

    JTAG

    I/O

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 11

    Power Consumption

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    16/54

    Power Consumption

    mote processor voltage active sleep

    Telos-B IT MSP430 1.8V min 1.8 mA 5.1 uAMica-Z Atmel AVR 2.5V min 8 mA < 15 uAImote2 Intel PXA271 1.3V min 44-66 mA 390 uA

    Imote2 is computationally powerful enough torun an embedded Linux kernel.

    Imote2 requires a relatively decent powersupply (or a short usage period).

    Xscale sold to Marvell Technologies in 2006

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 12

    Radio IEEE 802 15 4

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    17/54

    Radio IEEE 802.15.4

    IEEE 802.15.4 (Zigbee)

    250 kbps (16 channels, 2.4 GHz ISM band)

    personal area networks (few meters range)

    PHY and MAC layer covered

    Link encryption (AES) (no key management)

    Full / Reduced function devices

    ChipCon CC2420popular 802.15.4 air interface

    128byte TX/RX buffer

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 13

    Radio IEEE 802 15 4

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    18/54

    Radio IEEE 802.15.4

    IEEE 802.15.4 (Zigbee)

    250 kbps (16 channels, 2.4 GHz ISM band)

    personal area networks (few meters range)

    PHY and MAC layer covered

    Link encryption (AES) (no key management)

    Full / Reduced function devices

    ChipCon CC2420popular 802.15.4 air interface

    128byte TX/RX buffer

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 13

    Design Goals

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    19/54

    Design Goals

    cheapideally less than 1 Euro

    manylots of devices, economies of scale

    robustunattended operation (no repair)

    smallimportance depends on the circumstances

    low-powerdifficult/impossible to replace batteries

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 14

    Design Goals

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    20/54

    Design Goals

    cheapideally less than 1 Euro

    manylots of devices, economies of scale

    robustunattended operation (no repair)

    smallimportance depends on the circumstances

    low-powerdifficult/impossible to replace batteries

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 14

    Design Goals

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    21/54

    Design Goals

    cheapideally less than 1 Euro

    manylots of devices, economies of scale

    robustunattended operation (no repair)

    smallimportance depends on the circumstances

    low-powerdifficult/impossible to replace batteries

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 14

    Design Goals

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    22/54

    Design Goals

    cheapideally less than 1 Euro

    manylots of devices, economies of scale

    robustunattended operation (no repair)

    smallimportance depends on the circumstances

    low-powerdifficult/impossible to replace batteries

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 14

    Design Goals

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    23/54

    Design Goals

    cheapideally less than 1 Euro

    manylots of devices, economies of scale

    robustunattended operation (no repair)

    smallimportance depends on the circumstances

    low-powerdifficult/impossible to replace batteries

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 14

    Research Topics

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    24/54

    Research Topics

    Embedded systems and languagesEnergy-aware resource management

    Cross-layer design and optimization

    (Ad-hoc) mesh routing protocolsInternetworking

    Middleware for wireless sensor networks

    Localization, time synchronization, . . .

    Data fusion, control, actuation, . . .

    Security and Applications

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 15

    Outline

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    25/54

    Outline

    1 Wireless Sensor Networks

    Definition and ApplicationsHardware (Processors, Boards, Radios, . . . )Constraints and Challenges

    2 NesC and TinyOS

    NesC Language OverviewTinyOS: Operating System for WSNsDemonstration

    3 Internet and Wireless Sensor NetworksTranslating Gateway/ProxyuIP, 6lowpanDemonstration

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 16

    NesC and TinyOS History

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    26/54

    NesC and TinyOS History

    developed by a consortium led by UC Berkeleytwo versions

    TinyOS 1.1TinyOS 2.0

    2.0 not backwards compatible with 1.1

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 17

    NesC: Programming Language for

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    27/54

    NesC: Programming Language forEmbedded Systems

    Programming language:a dialect/extension of Cstatic memory allocation only (no malloc/free)

    whole-program analysis, efficient optimizationrace condition detection

    Implementation:pre-processor output is a C-program, that is

    compiled using gcc for the specific platformstatically linking functions

    For more details, see [3]

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 18

    NesC Interfaces

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    28/54

    NesC Interfaces

    commands

    can be called by other modulesthink functions

    eventssignalled by other modules

    have to be handled by this module

    Interface Exampleinterface Send {

    command error_t send(message_t* msg, uint8_t len);event void sendDone(message_t* msg, error_t error);...

    }

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 20

    NesC Components

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    29/54

    NesC Components

    a NesC application consists of components

    components provide and use interfacescomponents can be accessed only via interfaces(cannot call an arbitrary C-function fromanother module)

    Figure: NesC Interface

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 21

    NesC Components

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    30/54

    NesC Components

    modules implement interfaces

    configurations connect modules together viatheir interfaces (wiring)

    Figure: NesC Configuration

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 22

    NesC Concurrency Tasks

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    31/54

    NesC Concurrency Tasks

    Define a Task

    task void task_name() { ... }

    Post a Taskpost task_name();

    posting a task the task is placed on aninternal task queue which is processed in FIFOorder

    a task runs to completion before the next taskis run, i.e. tasks do not preempt each other

    tasks can be preempted by hardware events

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 24

    TinyOS

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    32/54

    yOS

    written in nesCevent-driven architecture

    no kernel/user space differentiation

    single shared stackno process or memory management

    no virtual memory

    multi-layer abstractionscomponents statically linked together

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 25

    TinyOS Functionality

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    33/54

    y y

    hardware abstractionaccess to sensors

    access to actuators

    scheduler (tasks, hardware interrupts)timer

    radio interface

    Active Messages (networking)

    storage (using flash memory on the motes)

    . . .

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 26

    TinyOS Demo Blink

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    34/54

    y

    no screen on which we could print

    Hello World

    lets blink an led insteadusing a timer to blink an led2 source files

    BlinkC.nc

    BlinkAppC.nc

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 27

    BlinkC.nc

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    35/54

    module BlinkC{

    uses interface Timer as Timer0;

    uses interface Leds;uses interface Boot;

    }implementation

    { event void Boot.booted(){

    call Timer0.startPeriodic(250);}

    event void Timer0.fired(){

    call Leds.led0Toggle();}

    }Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 29

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    36/54

    BlinkAppC.ncconfiguration BlinkAppC

    {}implementation{

    components MainC, BlinkC, LedsC;components new TimerMilliC() as Timer0;

    BlinkC -> MainC.Boot;BlinkC.Timer0 -> Timer0;

    BlinkC.Leds -> LedsC;}

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 31

    TinyOS Demo Blink

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    37/54

    y

    in reality using 3 timers250 ms500 ms1000 ms

    each timer toggling one led

    the result is a 3-bit counter

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 32

    TinyOS Demo Oscilloscope

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    38/54

    y p

    motes periodically get a sensor reading and

    broadcast over the radioBaseStation mote forward packets betweenthe radio and the serial interfacePC - java application reading packets from the

    serial interface and plotting sensor readings

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 33

    TinyOS Demo Oscilloscope

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    39/54

    y p

    node ID sensor7 light

    8 light18 temperature

    temperature = 38.4 + 0.0098 data

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 34

    Outline

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    40/54

    1 Wireless Sensor Networks

    Definition and ApplicationsHardware (Processors, Boards, Radios, . . . )Constraints and Challenges

    2 NesC and TinyOS

    NesC Language OverviewTinyOS: Operating System for WSNsDemonstration

    3

    Internet and Wireless Sensor NetworksTranslating Gateway/ProxyuIP, 6lowpanDemonstration

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 35

    Why connect WSNs via the Internet?

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    41/54

    Internet: IPubiquitousde-facto standard

    already deployedplethora of applications available

    TinyOS notion of networkingActive Messages

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 36

    Connecting WSNs to the Internet

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    42/54

    translating using gateway/proxy(motes use Active Messages)

    Serial Forwarder

    Sensor Internet Protocol

    make motes IP-awareuIP6lowpan

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 37

    Serial Forwarder

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    43/54

    Active Messages tunneled inside TCP to agateway

    gateway: PC attached to a BaseStation mote

    BaseStation mote forwarding messagesbetween the radio and the serial interface(BaseStation application)

    drawback: application on the PC has to beActive Message-aware

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 38

    Serial Forwarder

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    44/54

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 39

    uIP

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    45/54

    TCP/IPv4 stack implementation by AdamDunkels (KTH)

    very small code size and memory footprint

    written in Cusing gotos, global variables and few functionsfor efficiency

    ported to TinyOS 1.x by Andrew Christianfrom Hewlett-Packard

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 40

    uIP

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    46/54

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 41

    6lowpan IPv6 over 802.15.4

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    47/54

    IETF working group (IPv6 over low-power

    wireless personal area networks)6lowpan header/dispatch value before the IPheader

    layer 2 header (802.15.4)optional mesh addressing header (6lowpan)optional broadcast header (6lowpan)optional fragmentation header (6lowpan)IPv6 header (6lowpan-compressed)

    layer 4 header (i.e. 6lowpan compressed UDP header)layer 4/application payload

    Table: 802.15.4 frame with 6lowpan payload

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 42

    6lowpan Details

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    48/54

    header compressionIPv6 and UDP headers can ideally be compressedfrom 40 + 8 to 2 + 4 bytesno prior communication for context estabilishmentnecessary

    fragmentation below the IP layerIPv6 requires a minimum MTU of 1280 bytes, but802.15.4 can at best provide 102 bytes

    mesh networking supportrouting algorithms and further details out of scopeof the 6lowpan working group

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 43

    6lowpan Jacobs University

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    49/54

    motes IP-aware and communicate via radiowith the BaseStation mote

    BaseStation mote forwards packets betweenthe radio and the serial interface

    PC IP-aware, running serial tunnelapplication for exchanging packets between theserial interface and the networking stack

    serial tunnel is doing 6lowpanen-/decapsulation

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 44

    6lowpan Jacobs University

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    50/54

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 45

    6lowpan Challenges

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    51/54

    compressionfragmentationefficiency

    end-to-end retransmissions (i.e. TCP, caching on

    intermediate nodes)

    energy-consumption an issueways to save energy

    sleep (duty-cycling)do not use the radiominimize the amount of data sent over the radio

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 46

    6lowpan Demonstration

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    52/54

    Ping (IPv6)

    cli (telnet over IPv6/UDP)

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 47

    References

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    53/54

    K. Romer and F. Mattern.

    The Design Space of Wireless Sensor NetworksIEEE Wireless Communications 11(6), December 2004.

    J. Polastre, R. Szewczyk and David Culler.

    Telos: Enabling Ultra-Low Power Wireless ResearchIEEE IPSN, April 2005.

    D. Gay, P. Levis, R. von Behren, M. Welsh, E. Brewer and D. Culler.

    The nesC Language: A Holistic Approach to Networked Embedded SystemsACM PLDI, June 2003.

    A. Dunkels.

    Full TCP/IP for 8-Bit ArchitecturesACM MOBISYS 2003, May 2003.

    G. Montenegro, N. Kushalnagar, J. Hui and D. Culler.

    Transmission of IPv6 Packets over IEEE 802.14.4 NetworksInternet-Draft draft-ietf-6lowpan-format-13 (work in progress), April 2007.

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 48

    http://goforward/http://find/http://goback/
  • 8/8/2019 wsn_NesC

    54/54

    Questions?

    Jurgen Schonwalder, Matus Harvan Motes, NesC, and TinyOS 49

    http://goforward/http://find/http://goback/