01 WSNProgramming Lecture Intro

download 01 WSNProgramming Lecture Intro

of 40

Transcript of 01 WSNProgramming Lecture Intro

  • 8/3/2019 01 WSNProgramming Lecture Intro

    1/40

    A part of Swedish ICT

    Introduction to

    Wireless SensorNetworksLuca Mottola (www.sics.se/~luca)

    Networked Embedded Systems Group SICS

    Programming WSNs: A System Perspective

    KTH Graduate Course, Fall 2010

  • 8/3/2019 01 WSNProgramming Lecture Intro

    2/40

    Goals: understand the issues in building distributedsystems using wireless embedded devices

    gain insights into state-of-the art solutions tosolve these issues

    get practical hand-on experience at buildingsuch distributed systems

    Achieved by covering a range of topics operating systems, communication

    protocols, programming abstractions,

    Hands-on labs and real-world projects!

    About This Course

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    3/40

    Luca Mottola

    SICS

    About Us

    Olaf Landsiedel

    KTH

    Adam Dunkels

    SICS

    Antonio Gonga

    Ph.D. student at KTH,

    class TA

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    4/40

    Computing on the Internet

    Nodes are

    resource-rich

    #nodes #users

    Interaction between people and

    human-mediated data sources

    Communication

    among geographicallydistributed nodes

    Focus: human-centered

    interactive decision making

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    5/40

    Internet of Things

    Nodes are

    resource-scarce

    #nodes >> #usersInteraction between people

    and the instrumented world(e.g., sensors, actuators)

    Answers are obtained by

    fusing real-time informationfrom distributed nodes

    Focus: support human-supervised

    autonomous decision making

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    6/40

    Enabled by miniaturization ofprocessing, communication,sensing and actuating

    devices

    Many cheap devices withshort-range communication

    More coverage with lessenergy (and no wires!)

    Wireless Sensor Networks

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    7/40

  • 8/3/2019 01 WSNProgramming Lecture Intro

    8/40

    Example: Volcano Monitoring(adapted from M. Welsh)

  • 8/3/2019 01 WSNProgramming Lecture Intro

    9/40

    Anatomy of a WSN Node

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    10/40

    Anatomy of a WSN Node

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    11/40

    Example: TelosB/TMote Sky TI MSP 430 (16 bit RISC)

    8 MHz 10 KB RAM 48 KB code, 1MB flash

    Chipcon CC2420 radio IEEE 802.15.4 compliant 50 m. range indoor,

    250 m. range outdoor

    bandwidth 250 kbits/s On-board antenna Temperature, light, and

    humidity sensors built-in

  • 8/3/2019 01 WSNProgramming Lecture Intro

    12/40

    Turns the green led on ifhumidity is below 50%

    If humidity goes above50%, turns the red led on

    Hello World Sensing DemosHumidity

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    13/40

    Hello World Sensing DemosAcceleration

    Shake the mote to

    turn the leds on!

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    14/40

    CrossBow

    MICA2

    MoteIV

    TMote Sky

    Intel iMote2 Sun SPOT

    CPU and clock ATmega128L

    16 MHz

    TI MSP 430

    8 MHz

    Intel PXA271

    416 MHz

    ARM 920T

    180 MHz

    Memory

    (RAM, code, flash)

    4 KB, 128 KB,

    512 KB

    10 KB, 48 KB,

    1 MB

    256 KB, 32 MB,

    32 MB

    512 KB

    (data+code),4 MB

    Radio chip Chipcon 1000 Chipcon 2420 Chipcon 2420 Chipcon 2420

    Power 2 AA 2 AA 3 AAA 3.7Vrechargeable

    Language C-based C-based C-based Java2ME

    Some Mote Platforms

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    15/40

    WSN Challenges: Power

    Power consumption devices are battery-powered, meant to

    operate unmanned for a long period of time

    communication is typically the biggest energy drain duty cycle is critical: nodes sleep for most of the time

    communication ~mA, stand-by ~A TMote mote always on: ~8 days;

    2% duty cycle (1.2s/min): 9 months

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    16/40

    No radio

    duty-cycleRadio

    duty-cycle

    Speaking of Radio..

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    17/40

    WSN Challenges: Reliability

    Reliabilitywireless link quality fluctuates based on

    environment

    topology changes as the WSN operates!nodes are often deployed in a hostile

    environment and may fail

    the application/networkmust self-organize!

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    18/40

    Non-isotropic range, asymmetric links Collisions, hidden terminal problem What-you-see-is-not-what-you-get topologies

    e.g., good connection to far nodes and bad to close ones

    The Woes of Wireless

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    19/40

    Changing Topologies

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    20/40

    A Reference Architecture

  • 8/3/2019 01 WSNProgramming Lecture Intro

    21/40

    Operating Systems

    OSs for WSNs differentfrom mainstream ones-basic run-time support for application programs- little or no support for user interaction

    Programs are cross-compiled and linked withthe OS library- the resulting binary is deployed on the WSN node

    Most popular: Contiki and TinyOS-alternatives: Mantis, LiteOS,

    Main differences: model of concurrency,support for dynamic linking,

    Adam and Luca to

    tell more in Lecture2, 4, 5, and 7

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    22/40

    Medium Access Control (MAC)

    Goals: avoid packet collisions and turn off the radiowhenever possible Much simpler than conventional MACs

    some features are demanded to application code CSMA (Carrier Sense) and TDMA (Time Division)are dominant

    CSMA good for changing topologies, may suffer underheavy load

    TDMA guarantees predictableperformance, needs time synch

    Olaf talks in

    Lecture 3

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    23/40

    Hello World Comm DemoSteal the Light!(adapted from M. Lunden)

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    24/40

    Routing Concern: energy consumption WSN routing is different:

    conventional protocols based onaddresses identifying the target(e.g., unicast or multicast IP addresses)

    WSN nodes may not be relevant per se:it is their (individual or collective) features that matter

    many-to-one, one-to-many, andmany-to-many vs. one-to-one

    Attribute-based routing is also used message forwarding based on the nature of data similar to content-based routing

    Plethora of protocols available a small subset used for real

    sink

    sourcesource

    Olaf

    discusses in

    Lecture 6

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    25/40

    IP Networking Interoperability and integration with

    the Internet motivate using IP Issues:

    network overhead size of stack implementations address assignment routing

    Several activities 6LowPan

    header compression, ROLL

    routing, ISA100

    Adam talks in

    Lecture 10

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    26/40

    Time Synchronization

    Often necessary to correlatethe data to the time it was sampled

    e.g., structural monitoring, earthquake detection Nodes have different times

    differences in clock quartzes and in their drifts

    well-known problem in distributed systems (NTP):peculiarity here is wireless and energy-awareness

    Several protocols availableprecision down to milliseconds require periodic network-wide message exchanges

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    27/40

    Node Localization

    It is often necessary to know the physicallocation of a node

    interpret sensed data, determine span of actuationoften determined at deployment time and known to

    both nodes and gateway

    What if location is not known?assume nodes are GPS-equipped

    easy and precise but energy hungry

    use radio-based localization e.g., based on RSSI

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    28/40

    In Practice, However

    Each component is often built separately The programmer is forced to deal with low-level details

    instead of the application logic

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    29/40

    Wide variety ofapplicationrequirements

    Inherent tension between: the desire to shield programmers

    from complexity

    the need to enable cross-layer design

    January 28th, 2008

    centralized

    decentralized

    homogeneous heterogeneous

    Habitat

    monitoring

    Wildlife

    monitoring

    Healthcare

    Smart

    ambient

    Wireless

    Sensor and

    Actor Networks

    WSN Challenges: ProgrammingLuca tells more in

    Lecture 8 and 9

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    30/40

    Putting All Togheter:

    The Torre Aquila Deployment(Trento, Italy)

    M. Ceriotti, L. Mottola, G. P. Picco, A. L. Murphy, S. Guna, M. Corr, M. Pozzi, D. Zonta, and P. Zanon.

    "Monitoring Heritage Buildings with Wireless Sensor Networks: The Torre Aquila Deployment.

    In IPSN/SPOTS, 2009. Best paper award.

  • 8/3/2019 01 WSNProgramming Lecture Intro

    31/40

    Heritage buildings requiremaintenance and carefulassessment

    Typically achieved withwired data loggers cumbersome and invasive especially in the presence of

    works of art

    WSNs as a viable alternative untethered monitoring minimum invasiveness high sensing granularity flexibility and ease of relocation

    Traditional data logger

    WSN node

    Motivation

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    32/40

    Torre Aquila 31-meter tall medieval tower

    part of the complex of Castellodel Buonconsiglio in Trento, Italy The 2nd floor contains the

    Ciclo dei 12 mesi internationally-renowned

    frescoes, attracting thousands of

    visitors each year Originally the Eastern gate to

    the city today, surrounded by high volume

    of vehicular traffic

    Concerns due to the plan ofdiverting traffic into a roadtunnel near the tower

  • 8/3/2019 01 WSNProgramming Lecture Intro

    33/40

    Deployment in Torre Aquila

    FIRST FLOORNORTH SECTION

    SECOND FLOOR

    THIRD FLOOR

    0

    141

    144

    145

    148

    149

    150

    151

    152

    153

    154

    160

    161

    162

    142

    143

    144

    149

    151

    152

    161

    162

    0 160

    146

    146

    150

    141

    153

    148 154

    142

    143

    145

    Environmental

    Acceleration

    !!

    * * * * *2* * * ** * * * * * * * *

    *!

    * *

    *

    !%! % ! ! ! 6!

    ! ! ! 9 ! !*

    *!

    %! % ! ! ! ! !

    FOS

    FOS

    joint

    Deformation

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    34/40

    Software

    Functionality fully decoupled, asynchronousinteractions through a middleware layer

    Sampling and Taskingto drive sensing basedon user parametersData Collection to report sensed data reliablyData Dissemination to distribute user

    parametersTime Synchronization to correlate readings

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    35/40

    SoftwareSampling & Data Collection

    Different classesof trafficBursty, high-rate

    w/ strong reliability (compressed)

    vibration data

    Low-rate w/ weak reliability environmental, deformation data

    Best effort system monitoring

    Node type Operatingparameters

    Typicalvalues

    Environmental Sampling period P

    # of sampling sessions N

    10 min

    infinite

    Deformation # of samples averaged A

    Sampling period P

    # of sampling sessions N

    10

    10 min

    infinite

    Acceleration Sampling frequency F

    Sampling duration D

    # of sampling sessions N

    200 Hz

    20 s

    infinite

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    36/40

    Sampling & Data CollectionRouting Details

    Hop-by-hop reliabilityscheme

    Child

    send(tuple 6)

    Parent

    retrieve(tuple 7)

    4 5 6

    cache

    send(tuple 7)

    send(tuple 8)

    5 6 7

    cache

    6 7 8

    cache

    send(tuple 9)

    7 8 9

    cache

  • 8/3/2019 01 WSNProgramming Lecture Intro

    37/40

    Torre Aquila Demo

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    38/40

    Monitoring Heritage Buildings with WSNs: The Torre Aquila Deployment2009 Matteo Ceriotti and Luca Mottola

    Vibration

    !

    Vibrational Modes

    D. Zonta et al. Real-Time Health Monitoring of of Historic Buildings with Wireless Sensor Networks

    In Proc. of the 7th Int. Conf. On Structural Health Monitoring, 2009.

    Deformation

    !

    !

    !

    The breath of

    the structure

    (Preliminary) Data Analysis

  • 8/3/2019 01 WSNProgramming Lecture Intro

    39/40

    Lessons Learned Thick walls drastically affect wireless propagation

    small changes in node placement modify the topology

    motes are tempting Moved the sink

    node by 1 meter!0

    0.2

    0.4

    0.6

    0.8

    1

    #142

    #143

    #146

    #148

    #151

    #152

    Percentageoftime

    04 Sept - 09 Sept

    #142

    #143

    #146

    #148

    #151

    #152

    09 Sept - 14 Sept

    1 Hop2 Hops3 Hops4 Hops5 Hops6 Hops

    Introduction to Wireless Sensor Networks 2010 Luca Mottola

  • 8/3/2019 01 WSNProgramming Lecture Intro

    40/40

    Questions?

    Introduction to Wireless Sensor Networks 2010 Luca Mottola