Presentation is loading. Please wait.

Presentation is loading. Please wait.

LoCal Embedded IPv6 Bootcamp Stephen Dawson-Haggerty September 9, 2010.

Similar presentations


Presentation on theme: "LoCal Embedded IPv6 Bootcamp Stephen Dawson-Haggerty September 9, 2010."— Presentation transcript:

1 LoCal Embedded IPv6 Bootcamp Stephen Dawson-Haggerty September 9, 2010

2 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

3 3 Why “Real” Information is so Important Improve Productivity Protect Health High-Confidence Transport Enhance Safety & Security Improve Food & H20 Save Resources Preventing Failures Increase Comfort Enable New Knowledge

4 WEI Short Course - L1 Intero4 Physical Information Streams Sensors are everywhere – But the data is mostly dropped on the floor Physical => Digital => Information Each sensor becomes a network citizen 010010001… temp=35

5 5 PrefixIID ICMPv6ICMPv6 IPv6 Base HbH Opt RoutingRouting Fragmen t 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!

6 IP Link ⇒ Broadcast Domain Structured Decomposition Embedded IPv6 in Concept IP Link ⇒ Always On Retain illusion even when always off Retain strict modularity Some key cross-layer visibility IPv6 can support a semi-broadcast link with few changes IP Link ⇒ “Reliable” Retain best-effort reliability over unreliable links

7 09.14.05TinyOS 2.07 nesC in a seashell C dialect Component based all interaction via interfaces connections (“wiring”) specified at compile-time generic components, interfaces for code reuse, simpler programming “External” types to simplify interoperable networking Reduced expressivity no dynamic allocation no function pointers Supports 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

8 09.14.05TinyOS 2.08 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

9 09.14.05TinyOS 2.09 The Basics – Let’s Get Started module AntiTheftC { uses interface Boot; uses interface Timer as Check; uses interface Read ; } 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 components A component provides and uses interfaces Interfaces contain commands and events, which are just functions A module is a component implemented in C interface Boot { /* Signaled when OS booted */ event void booted(); } interface Timer { command void startOneShot(uint32_t period); command void startPeriodic(uint32_t period); event void fired(); }

10 09.14.05TinyOS 2.010 The Basics – Interfaces module AntiTheftC { uses interface Boot; uses interface Timer as Check; uses interface Read ; } 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 provider events are calls from provider to user interface Timer { command void startOneShot(uint32_t period); command void startPeriodic(uint32_t period); event void fired(); }

11 09.14.05TinyOS 2.011 The Basics – Interfaces and Split-Phase Ops module AntiTheftC { uses interface Boot; uses interface Timer as Check; uses interface Read ; } 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 { command error_t read(); event void readDone(error_t ok, val_t val); }

12 09.14.05TinyOS 2.012 The Basics – Interfaces and Split-Phase Ops module AntiTheftC { uses interface Boot; uses interface Timer as Check; uses interface Read ; } 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 Errors are signalled using the error_t type, typically Commands only allow one outstanding request Events report any problems occurring in the op interface Read { command error_t read(); event void readDone(error_t ok, val_t val); }

13 09.14.05TinyOS 2.013 The Basics – Configurations configuration 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 components It can itself provide and use interfaces generic configuration TimerMilliC() { provides interface Timer ; } implementation {... } generic configuration PhotoC() { provides interface Read; } implementation {... }

14 09.14.05TinyOS 2.014 The Basics MainC TinySchedulerC

15 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

16 An IP Network “sensor network” ≈ “IP subnet” “TOS_NODE_ID” ≈ “IP address” “base station” ≈ “edge router” “application gateway” no longer exists internet backhaul links edge routers node routers 16

17 Addressing 128-bit address space Lots of IPv6 RFCs deal with this: RFC2461, RFC4862 Address typeExampleTinyOS usage Link-local unicastfe80::beefL2 Mapped Link-local multicastff02::1Radio local broadcast Global unicast2001::64Routable address Network ID/64Interface ID/64 17

18 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); } UDPSocketC ICMPResponderC 18

19 Address Structures A lot like linux: ip.h struct sockaddr_in6 { uint16_t sin6_port; struct in6_addr sin6_addr; }; 19

20 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


Download ppt "LoCal Embedded IPv6 Bootcamp Stephen Dawson-Haggerty September 9, 2010."

Similar presentations


Ads by Google