1 / 20

LoCal Embedded IPv6 Bootcamp

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.

hedy
Download Presentation

LoCal Embedded IPv6 Bootcamp

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Save Resources Improve Productivity Protect Health Improve Food & H20 Why “Real” Information is so Important Enable New Knowledge Increase Comfort Enhance Safety & Security Preventing Failures High-Confidence Transport

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

  5. 128 bits Prefix IID ICMPv6 IPv6 Base HbH Opt Routing Fragment Dst Opt 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 Retain strict modularity Some key cross-layer visibility IPv6 can support a semi-broadcast link with few changes Retain illusion even when always off Retain best-effort reliability over unreliable links Embedded IPv6 in Concept IP Link ⇒ Always On IP Link ⇒ “Reliable”

  7. 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 nesC in a seashell TinyOS 2.0

  8. 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 TinyOS 2.0

  9. 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(); } The Basics – Let’s Get Started • module 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 components A component provides and uses interfaces Interfaces contain commands and events, which are just functions A module is a component implemented in C TinyOS 2.0

  10. The Basics – Interfaces 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 • module 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(); } interface Timer<tag> { command void startOneShot(uint32_t period); command void startPeriodic(uint32_t period); event void fired(); } TinyOS 2.0

  11. The Basics – Interfaces and Split-Phase Ops • module 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); } TinyOS 2.0

  12. The Basics – Interfaces and Split-Phase Ops • module 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 • 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<val_t> { command error_t read(); event void readDone(error_t ok, val_t val); } TinyOS 2.0

  13. 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; • } generic configuration TimerMilliC() { provides interface Timer<TMilli>; } implementation { ... } generic configuration PhotoC() { provides interface Read; } implementation { ... } 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 TinyOS 2.0

  14. MainC TinySchedulerC The Basics TinyOS 2.0

  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, …

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

  17. Addressing • 128-bit address space • Lots of IPv6 RFCs deal with this: RFC2461, RFC4862 Network ID/64 Interface ID/64

  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); } UDPSocketC interface ICMPPing { command error_t ping(struct in6_addr *target, uint16_t period, uint16_t n); event void pingReply(struct in6_addr *source, structicmp_stats *stats); event void pingDone(uint16_t ping_rcv, uint16_t ping_n); } ICMPResponderC

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

  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; ... }

More Related