+ All Categories
Home > Documents > LoCal Embedded IPv6 Bootcamp

LoCal Embedded IPv6 Bootcamp

Date post: 25-Feb-2016
Category:
Upload: hedy
View: 41 times
Download: 0 times
Share this document with a friend
Description:
LoCal Embedded IPv6 Bootcamp. Stephen Dawson-Haggerty September 9, 2010. Bootcamp Objectives. Introduce key IPv6 and embedded networking concepts Overview of TinyOS and nesc Compile, install, interact with, and modify an embedded IPv6-based application. Save Resources. - PowerPoint PPT Presentation
20
LoCal Embedded IPv6 Bootcamp Stephen Dawson-Haggerty September 9, 2010
Transcript
Page 1: LoCal  Embedded IPv6  Bootcamp

LoCal Embedded IPv6 Bootcamp

Stephen Dawson-HaggertySeptember 9, 2010

Page 2: LoCal  Embedded IPv6  Bootcamp

Bootcamp Objectives

• Introduce key IPv6 and embedded networking concepts

• Overview of TinyOS and nesc• Compile, install, interact with, and modify an

embedded IPv6-based application

Page 3: LoCal  Embedded IPv6  Bootcamp

3

Why “Real” Information is so Important

Improve Productivity

Protect HealthHigh-Confidence Transport

Enhance Safety & Security

Improve Food & H20

Save Resources

Preventing Failures

IncreaseComfort

Enable New Knowledge

Page 4: LoCal  Embedded IPv6  Bootcamp

WEI Short Course - L1 Intero 4

Physical Information Streams

• Sensors are everywhere– But the data is mostly dropped on the floor

• Physical => Digital => Information• Each sensor becomes a network citizen

0 2 4 6 8 10 12 14 16 18

-1

-0.5

0

0.5

1

Low resolution Sensor, Test 4, Increasing frequency

Time (sec)

Acce

lera

tion

(g)

010010001…

<value> temp=35<\value>

Page 5: LoCal  Embedded IPv6  Bootcamp

5

Prefix IID

ICMPv6

IPv6 Base

HbH Opt Routing Fragme

nt Dst Opt

128 bits

A decade of progress

• Large uninterpreted addresses

• Autoconfiguration and management

• Layer 2 bootstrapping and discovery• Protocol options framework

IPv6 Is a Great Fit!

Page 6: LoCal  Embedded IPv6  Bootcamp

IP Link ⇒ Broadcast Domain

Structured DecompositionEmbedded IPv6 in Concept

IP Link ⇒ Always OnRetain illusion even when always off

Retain strict modularitySome key cross-layer visibility

IPv6 can support a semi-broadcast link with few changes

IP Link ⇒ “Reliable”Retain best-effort reliability over unreliable links

Page 7: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.07 09.14.05

nesC in a seashellC dialectComponent based• all interaction via interfaces• connections (“wiring”) specified at compile-time• generic components, interfaces for code reuse, simpler programming“External” types to simplify interoperable networkingReduced expressivity• no dynamic allocation• no function pointersSupports TinyOS’s concurrency model• must declare code that can run in interrupts• atomic statements to deal with data accessed by interrupts• data race detection to detect (some) concurrency bugs

Page 8: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.08 09.14.05

The Basics

Goal: write an anti-theft device. Let’s start simple.Two parts:• Detecting theft.

– Assume: thieves put the motes in their pockets.– So, a “dark” mote is a stolen mote.– Theft detection algorithm: every N ms check if light sensor is below some

threshold• Reporting theft.

– Assume: bright flashing lights deter thieves.– Theft reporting algorithm: light the red LED for a little while!

What we’ll see• Basic components, interfaces, wiring• Essential system interfaces for startup, timing, sensor sampling

Page 9: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.09 09.14.05

The Basics – Let’s Get Startedmodule AntiTheftC { uses interface Boot; uses interface Timer<TMilli> as Check; uses interface Read<uint16_t>;}implementation { event void Boot.booted() { call Check.startPeriodic(1000); } event void Check.fired() { call Read.read(); } event void Read.readDone(error_t ok, uint16_t val) { if (ok == SUCCESS && val < 200) theftLed(); }}

Programs are built out of named componentsA component provides and uses interfacesInterfaces contain commands and events,which are just functionsA module is a component implemented in C

interface Boot { /* Signaled when OS booted */ event void booted();}

interface Timer<tag> { command void startOneShot(uint32_t period); command void startPeriodic(uint32_t period); event void fired();}

Page 10: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.010 09.14.05

The Basics – Interfacesmodule AntiTheftC { uses interface Boot; uses interface Timer<TMilli> as Check; uses interface Read<uint16_t>;}implementation { event void Boot.booted() { call Check.startPeriodic(1000); } event void Check.fired() { call Read.read(); } event void Read.readDone(error_t ok, uint16_t val) { if (ok == SUCCESS && val < 200) theftLed(); }}

interface Boot { /* Signaled when OS booted */ event void booted();}

Interfaces specify the interaction between two components, the provider and the user.This interaction is just a function call.commands are calls from user to providerevents are calls from provider to user

interface Timer<tag> { command void startOneShot(uint32_t period); command void startPeriodic(uint32_t period); event void fired();}

Page 11: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.011 09.14.05

The Basics – Interfaces and Split-Phase Opsmodule AntiTheftC { uses interface Boot; uses interface Timer<TMilli> as Check; uses interface Read<uint16_t>;}implementation { event void Boot.booted() { call Check.startPeriodic(1000); } event void Check.fired() { call Read.read(); } event void Read.readDone(error_t ok, uint16_t val) { if (ok == SUCCESS && val < 200) theftLed(); }}

All long-running operations are split-phase:• A command starts the op: read• An event signals op completion: readDone

interface Read<val_t> { command error_t read(); event void readDone(error_t ok, val_t val);}

Page 12: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.012 09.14.05

The Basics – Interfaces and Split-Phase Opsmodule AntiTheftC { uses interface Boot; uses interface Timer<TMilli> as Check; uses interface Read<uint16_t>;}implementation { event void Boot.booted() { call Check.startPeriodic(1000); } event void Check.fired() { call Read.read(); } event void Read.readDone(error_t ok, uint16_t val) { if (ok == SUCCESS && val < 200) theftLed(); }}

All long-running operations are split-phase:• A command starts the op: read• An event signals op completion: readDoneErrors are signalled using the error_t type, typically• Commands only allow one outstanding request• Events report any problems occurring in the op

interface Read<val_t> { command error_t read(); event void readDone(error_t ok, val_t val);}

Page 13: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.013 09.14.05

The Basics – Configurationsconfiguration AntiTheftAppC { }implementation{ components AntiTheftC, MainC, LedsC;

AntiTheftC.Boot -> MainC.Boot; AntiTheftC.Leds -> LedsC;

components new TimerMilliC() as MyTimer; AntiTheftC.Check -> MyTimer;

components new PhotoC(); AntiTheftC.Read -> PhotoC;}

A configuration is a component built out of other components.It wires “used” to “provided” interfaces.It can instantiate generic componentsIt can itself provide and use interfaces

generic configuration TimerMilliC() { provides interface Timer<TMilli>;}implementation { ... }generic configuration PhotoC() {

provides interface Read;}implementation { ... }

Page 14: LoCal  Embedded IPv6  Bootcamp

TinyOS 2.014 09.14.05

The Basics

Page 15: LoCal  Embedded IPv6  Bootcamp

IPv6• BLIP: IPv6 for TinyOS• Useful basic feature set

– Mesh routing– TCP/UDP

• Lots of tools, libraries for building apps– Shell, network reprogramming, RPC, …

15

Page 16: LoCal  Embedded IPv6  Bootcamp

An IP Network

• “sensor network” ≈ “IP subnet”• “TOS_NODE_ID” ≈ “IP address”• “base station” ≈ “edge router”• “application gateway” no longer exists

internet

backhaul linksedge routers

node routers

16

Page 17: LoCal  Embedded IPv6  Bootcamp

Addressing

• 128-bit address space

• Lots of IPv6 RFCs deal with this: RFC2461, RFC4862

Address type Example TinyOS usage

Link-local unicast fe80::beef L2 Mapped

Link-local multicast ff02::1 Radio local broadcast

Global unicast 2001::64 Routable address

Network ID/64 Interface ID/64

17

Page 18: LoCal  Embedded IPv6  Bootcamp

Useful Interfaces

interface UDP {command error_t bind(uint16_t port);command error_t sendto(struct sockaddr_in6 *dest,

void *payload, uint16_t len);event void recvfrom(struct sockaddr_in6 *src, void *payload,

uint16_t len, struct ip_metadata *meta);

}interface ICMPPing { command error_t ping(struct in6_addr *target, uint16_t period, uint16_t n);

event void pingReply(struct in6_addr *source, struct icmp_stats *stats);

event void pingDone(uint16_t ping_rcv, uint16_t ping_n);}

UDPS

ocke

tCIC

MPR

espo

nder

C

18

Page 19: LoCal  Embedded IPv6  Bootcamp

Address Structures

• A lot like linux: ip.hstruct sockaddr_in6 { uint16_t sin6_port; struct in6_addr sin6_addr;};

19

Page 20: LoCal  Embedded IPv6  Bootcamp

Example App: Sense & Send

event Timer.fired() {call Read.read();

}Read.readDone(error_t result, uint16_t val) {

struct sockaddr_in6 dest;nx_struct report r;r.reading = val;inet_pton6(“2001::64”, &dest.sin6_addr);dest.sin6_port = htons(REPORT_PORT);call UDP.sendto(dest, &r, sizeof(r));

}

Configuration MyAppC{} implementation {

components MyAppP, new UdpSocketC();MyAppP.UDP -> UdpSocketC;...

}

20


Recommended