1 / 47

David E. Culler University of California, Berkeley

Wireless Embedded Inter-Networking Foundations of Ubiquitous Sensor Networks Operating Systems for WEI Devices TinyOS – Design and Philosophy. David E. Culler University of California, Berkeley. Client Tier: (desk,lap,PDA,MP3, phone) Windows, Wince, Symbian, Linux/Java. Server Tier:

africa
Download Presentation

David E. Culler University of California, Berkeley

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. Wireless Embedded Inter-NetworkingFoundations of Ubiquitous Sensor NetworksOperating Systems for WEI DevicesTinyOS – Design and Philosophy David E. Culler University of California, Berkeley WEI L3 - TinyOS

  2. Client Tier: (desk,lap,PDA,MP3, phone) • Windows, Wince, Symbian, Linux/Java • Server Tier: • Unix (Linux, Solaris, AIX, HPux), Windows • App Servers (Axis, J2EE, Weblogic, SAP, Oracle, …) • Router/Gateway Tier: • Linux, Linux, Linux internet tier3 Routers, APs, Gateways embedded net tier4 Mote • Embedded Tier: (mote) Sensor Technology Perspective Client tier1 IT Enterprise Server tier2 Physical World WEI L3 - TinyOS

  3. Computer Systems • Traditional systems: separate chips • Microcontroller: integrate on single chip Mote MCU CPU Timer Network Peripherals Memory Storage WEI L3 - TinyOS

  4. 48K ROM 10K RAM 250 kbps Microcontrollers WEI L3 - TinyOS

  5. Mote Characteristics • Limited resources • RAM, ROM, Computation, Energy  Wakeup, do work as quickly as possible, sleep • Hardware modules operate concurrently • No parallel execution of code (not Core 2 Duos!)  Asynchronous operation is first class • Diverse application requirements  Efficient modularity • Robust operation • Numerous, unattended, critical  Predictable operation WEI L3 - TinyOS

  6. Web Server Link TinyOS Basics • What is an OS? • Manages sharing of resources (hardware and software) • Interface to access those resources • TinyOS Basics • System  Graph of components • Components • Provides interfaces • Uses interfaces • Interfaces • Commands • Events Network WEI L3 - TinyOS

  7. Traditional Systems • Well established layers of abstractions • Strict boundaries • Ample resources • Independent Applications at endpoints communicate pt-pt through routers • Well attended Application Application User System Network Stack Transport Threads Network Address Space Data Link Files Physical Layer Drivers Routers WEI L3 - TinyOS

  8. by comparison, WSNs ... • Highly Constrained resources • processing, storage, bandwidth, power • Applications spread over many small nodes • self-organizing Collectives • highly integrated with changing environment and network • communication is fundamental • Concurrency intensive in bursts • streams of sensor data and network traffic • Robust • inaccessible, critical operation • Unclear where the boundaries belong • even HW/SW will move • => Provide a framework for: • Resource-constrained concurrency • Defining boundaries • Appl’n-specific processing and power management • allow abstractions to emerge WEI L3 - TinyOS

  9. Applications and Services Over-the-air Programming Network Protocols Blocks, Logs, Files Streaming drivers Scheduling, Management Link Radio Serial Flash MCU, Timers, Bus,… ADC, Sensor I/F Sensors Wireless Processing Storage Abstractions Emerge from Experience TinyOS 2.0 WSN mote platform Communication Centric Resource-Constrained Event-driven Execution WEI L3 - TinyOS

  10. Route map router sensor appln application Active Messages packet Serial Packet Radio Packet Temp photo SW HW byte UART Radio byte ADC bit clocks CC2420 TinyOS • New operating system built specifically for wireless sensor networks • Small, robust, communication centric design • Resource-constrained concurrency • Structured Event-driven SW architecture • Tool for protocols and dist. Algorithms • Designed for synthesis and verification • Eg. Ptolemy, Metropolis, … • Whole-system compile-time analysis • Rich set of services and development environment • World-wide adoption • Open source, lead by UCB / Intel • Corporate and academic (1000s) • Dozen of platforms • de facto sensor net standard WEI L3 - TinyOS

  11. NEST SmartDust Wireless Sensor Networks Sensors Storage Wireless Processing A worldwide community WEI L3 - TinyOS

  12. Stack Library Alternative • Link & networks protocols buried in block-box library • Ember, Figure8, . . . • No execution model or storage model • Arbitrary system/user code must TICKle it “sufficiently often” • Undefined call duration • No system services • Difficult to validate • Same hardware, but a very different approach send start stop Proprietary Network Stack (zigbee spec or other) OEM / Developer Custom Code, RTOS, or other TICK Software cmds cmds interrupts interrupts MicroController Hardware OEM/Dev Hardware 802.15.4 Radio WEI L3 - TinyOS

  13. tier3 SensorNet GW/Proxy physical info net Embedded Application tier4 “mote” Sensors Modern Mote Tier TinyOS Architecture • Embedded applications built on a rich set of node services. • Timing, sensor streams, storage • Local processing • Reliable, low-power communication • Platform independent + extensions client tier1 server tier2 Networking Protocols Management Common Link Abstraction TinyOS Runtime Services Physical World Hardware Abstraction Layer MCU Radio Sensors WEI L3 - TinyOS

  14. TinyOS from First Principles WEI L3 - TinyOS

  15. sensors actuators storage network Characteristics of Network Sensors • Small physical size and low power consumption • Concurrency-intensive operation • multiple flows, not wait-command-respond • Limited Physical Parallelism and Controller Hierarchy • primitive direct-to-device interface • Asynchronous and synchronous devices • Diversity in Design and Usage • application specific, not general purpose • huge device variation => efficient modularity => migration across HW/SW boundary • Robust Operation • numerous, unattended, critical => narrow interfaces WEI L3 - TinyOS

  16. Classical RTOS approaches • Responsiveness => Provide some form of user-specified interrupt handler • User threads in kernel, user-level interrupts • Guarantees? • Deadlines / Controlled Scheduling • Static set of tasks with prespecified constraints • Generate overall schedule => Doesn’t deal with unpredictable events, especially communication • Threads + synchronization operations => Complex scheduler to coerce into meeting constraints • Priorities, earliest deadline first, rate monotonic • Priority inversion, load shedding, live lock, deadlock • Sophisticated mutex and signal operations • Communication among parallel entities • Shared (global) variables: ultimate unstructured programming • Mail boxes (msg passing) => external communication considered harmful • Fold in as RPC • Requires multiple (sparse) stacks • Preemption or yield WEI L3 - TinyOS

  17. Alternative Starting Points • Event-driven models • Easy to schedule handfuls of small, roughly uniform things • State transitions (but what storage and comm model?) • Usually results in brittle monolithic dispatch structures • Structured event-driven models • Logical chunks of computation and state that service events via execution of internal threads • Threaded Abstract machine • Developed as compilation target of inherently parallel languages • vast dynamic parallelism • Hide long-latency operations • Simple two-level scheduling hierarchy • Dynamic tree of code- block activations with internal inlets and threads • Active Messages • Both parties in communication know format of the message • Fine-grain dispatch and consume without parsing • Concurrent Data-structures • Non-blocking, lock-free (Herlihy) WEI L3 - TinyOS

  18. TinyOS design goals • Simple framework for resource constrained concurrency • Single stack • Flexible hardware/software and system boundary • Expressive enough to build sophisticated, application specific system structures • Avoid arbitrary constraints on optimization • Communication is integral to execution • Asynchrony is first class • Promote robustness • Modular • Static allocation • Explicit success/fail at all interfaces • Reuse • Ease of interpositioning WEI L3 - TinyOS

  19. Embedded System Design: Hardware Abstraction • Abstract a hardware unit for convenient software access. • Datasheet describes set of interfaces (pins, wires, busses) and operations • Commands that can be asserted or issued to it • Events that it will signal or raise • Interfaces to other hardware units that it is attached to • Internally the unit has state and computational processes that operate in parallel with other units. state WEI L3 - TinyOS

  20. Embedded System Design: Data Acquisition • Configure and command ADC to sample external I/O attached to sensor. • Either directly or over a bus protocol • Obtain readings upon notification by polling or handling interrupts • One short or periodic • Perform processing on the readings (smoothing, thresholding, transformation) and possibly signal higher level notification • Similar for DAC to actuator Digital Signal Processing Software storage threads Bus Digital sensor ADC Analog sensor WEI L3 - TinyOS

  21. Higher Level of stack Communication Protocol Logical Peer Comm. State processing Lower Level of stack Embedded System Design: Protocol Implementation • For • Bus Protocols within a node, • Link Protocols between two nodes in direct communication, • Network Protocols between possibly widely separate node. • Each has • Set of operations that it issues • Set responses that it receives • synchronous or asynchronous, • state it maintains, • state-transition diagram that it implements • And various commands and events that define its interface above and below • Exceptions, etc. WEI L3 - TinyOS

  22. interface Tiny OS Concepts • System = Scheduler + graph of Components • Hierarchical • Component: • Set of bidirectional Command/Event Interfaces • Commands Handlers • Event Handlers • Frame (storage) • Tasks (concurrency) • Constrained two-level scheduling model • tasks + events • Constrained Storage Model • frame per component, • Single shared stack, • no heap • Structured event-driven processing • Very lean multithreading • Efficient Layering • Events can signal events • Extremely modular construction • Separates creation and composition of functional elements Commands Events Component Internal State Task WEI L3 - TinyOS

  23. Application = Graph of Components Route map router sensor appln application Modular construction of Protocols. Active Messages Serial Packet Radio Packet packet Temp photo SW HW UART Radio byte ADC byte Graph of cooperating state machines on shared stack Execution driven by interrupts clocks RFM bit * Early TinyOS 0.x component graph going all the way down to modulating the RF channel in software. WEI L3 - TinyOS

  24. Radio Packet packet Radio byte byte RFM bit TOS Execution Model • commands request action • ack/nack at every boundary • call cmd or post task • events notify occurrence • HW intrpt at lowest level • may signal events • call cmds • post tasks • Tasks provide logical concurrency • preempted by events • Migration of HW/SW boundary data processing application comp message-event driven active message event-driven packet-pump crc event-driven byte-pump encode/decode event-driven bit-pump WEI L3 - TinyOS

  25. Tasks events commands Interrupts Hardware TinyOS Execution Contexts • Events generated by interrupts preempt tasks • Tasks do not preempt tasks • Both essential process state transitions WEI L3 - TinyOS

  26. Dynamics of Events and Threads bit event => end of byte => end of packet => end of msg send thread posted to start send next message bit event filtered at byte layer radio takes clock events to detect recv WEI L3 - TinyOS

  27. Programming TinyOS - nesC • TinyOS 1.x and TinyOS 2.x are written in an extension of C, called nesC • Applications are too! • just additional components composed with the OS components • Provides syntax for TinyOS concurrency and storage model • commands, events, tasks • local frame variables • Rich Compositional Support • separation of definition and linkage • robustness through narrow interfaces and reuse • interpositioning • Whole system analysis and optimization • Platform independent data types and structure • because packets are sent between different kinds of processors! WEI L3 - TinyOS

  28. Composition • A component specifies a set of interfaces by which it is connected to other components • provides a set of interfaces to other components • uses a set of interfaces provided by other components • Interfaces are bi-directional • include commands and events • Interface methods form the external namespace of the component • Composition by “wiring” provides StdControl Timer provides interface StdControl; interface Timer: uses interface Clock Timer Component Clock uses WEI L3 - TinyOS

  29. Split-phase abstraction of HW • Command synchronously initiates action • Device operates concurrently • Signals event(s) in response • ADC • Clock • Send (UART, Radio, …) • Recv – depending on model • Coprocessor • Higher level (SW) processes don’t wait or poll • Allows automated power management • Higher level components behave the same way • Tasks provide internal concurrency where there is no explicit hardware concurrency • Components (even subtrees) replaced by HW and vice versa WEI L3 - TinyOS

  30. TASKS • provide concurrency internal to a component • longer running operations • are preempted by events • able to perform operations beyond event context • may call commands • may signal events • not preempted by tasks • Simple (pluggable) Scheduler • Composition exercises substantial control over scheduling { ... post TskName(); ... } task void TskName { ... } WEI L3 - TinyOS

  31. Typical application use of tasks • event driven data acquisition • schedule task to do computational portion event result_t sensor.dataReady(uint16_t data) { putdata(data); post processData(); return SUCCESS; } task void processData() { int16_t i, sum=0; for (i=0; i ‹ maxdata; i++) sum += (rdata[i] ›› 7); display(sum ›› shiftdata); } • 128 Hz sampling rate • simple FIR filter • dynamic software tuning for centering the magnetometer signal (1208 bytes) • digital control of analog, not DSP • ADC (196 bytes) WEI L3 - TinyOS

  32. Tasks in low-level operation • transmit packet • send command schedules task to calculate CRC • task initiated byte-level data pump • events keep the pump flowing • receive packet • receive event schedules task to check CRC • task signals packet ready if OK • i2c component • i2c bus has long suspensive operations • tasks used to create split-phase interface • events can procede during bus transactions • Timer • Post task in-critical section, signal event when current task complete Make SW look like HW WEI L3 - TinyOS

  33. Structured Events vs Multi-tasking • Storage • Control Paradigm • Always block/yield – rely on thread switching • Never block – rely on event signaling • Communication & Coordination among potentially parallel activities • Threads: global variables/mailboxes, mutex, signaling • Preemptive – handle many potential races • Non-premptive • All interactions protected by costs system synch ops • Events: signaling • Scheduling: • Complex threads require sophisticating scheduling • Collections of simple events ?? WEI L3 - TinyOS

  34. Domain-Specific Application Components Management & Power ServiceInterface Blocks Persistent Attributes & Event Streams Init/Boot Messages Commands Attributes Events Discovery DeviceAttributes &Event Streams OS & Net Interface Files Logs Net Prog Network Collection, Dissemination, & Routing Vibration Light Motor Domain-SpecificDevice Drivers Links Device Abstraction Interface Flash Radio / Serial Sensor / Actuator Microcontroller Abstraction Interface Hardware Microcontroller Core, Timers, Buses, Onboard ADCs TelosB Intel Mote2 MicaZ Modern TinyOS Service Architecture WEI L3 - TinyOS

  35. TinyOS 2.0 – abstraction architecture Flexible Hardware Abstraction for Wireless Sensor Networks, Vlado Handziski, Joseph Polastre, Jan-Hinrich Hauer, Cory Sharp, Adam Wolisz, David Culler,In Proceedings of the Second European Workshop on Wireless Sensor Networks (EWSN '05), January 31-February 2, 2005. WEI L3 - TinyOS

  36. Sample of TinyOS Platforms WEI L3 - TinyOS

  37. Network Protocols Radio Serial Flash MCU, Timers, Bus,… WSN mote platform Silicon World Sensors Wireless Processing Storage Wireless Embedded Networks Applications and Services Over-the-air Programming Blocks, Logs, Files Streaming drivers Scheduling, Management Digital World Link ADC, Sensor I/F Physical World WEI L3 - TinyOS

  38. Embedded Networking Requirements • Reliable Dissemination • Data Collection and Aggregation • Point-to-point Transfers • Reliably over lossy links • At low power • Idle listening, management, monitoring • Adapting to changing conditions • Scalar and Bulk Versions WEI L3 - TinyOS

  39. TEP 1: TEP Structure and Key Words [HTML] TEP 2: Hardware Abstraction Architecture [HTML] TEP 3: Coding Standards [HTML] TEP 101: ADC [HTML] TEP 102: Timers [HTML] TEP 103: Storage [HTML] TEP 106: Schedulers and Tasks [HTML] TEP 107: Boot Sequence [HTML] TEP 108: Resource Arbitration [HTML] TEP 109: Sensorboards [HTML] TEP 111: message_t [HTML] TEP 112: Microcontroller Power Management [HTML] TEP 113: Serial Communication [HTML] TEP 114: SIDs: Source and Sink Independent Drivers [HTML] TEP 115: Power Management of Non-Virtualized Devices [HTML] TEP 116: Packet Protocols [HTML] TEP 117: Low-Level I/O [HTML] TEP 118: Dissemination [HTML] TEP 119: Collection [HTML] TEP 123: Collection Tree Protocol (CTP) [HTML] TEP 124: Link Estimation Exchange Protocol (LEEP) [HTML] TEP 125: TinyOS 802.15.4 Frames [HTML] TEP 126: CC2420 Radio Stack [HTML] TEP - TinyOS Enhancement Proposals WEI L3 - TinyOS

  40. Application IPv6 Network Kernel Driver Driver Driver Driver Driver Driver Sensors Actuator Sensors Actuator Radio Timer Flash Sensor Actuator TinyOS IPv6 Network Kernel • Network Kernel • Manages communication and storage • Scheduler (decides when to signal events) WEI L3 - TinyOS

  41. Event-Based Execution • All execution occurs in event handlers • Events do not preempt each other • Commands • Get information from underlying components • Get current time • Configure underlying components • Start timer (will cause a future event) • Bind socket to a port • Helper functions • Format an IPv6 address WEI L3 - TinyOS

  42. Event: Boot Command: Start timer Event: Timer fired Command: Send message Event: Message received Command: Toggle an LED event void Boot.booted() { call Timer.startPeriodic(100); } event void Timer.fired() { call Udp.sendto(buf, len, &to); } event void Udp.recvfrom(void *buf, uint16_t len, sockaddr_in6_t *from) { call Leds.led0Toggle(); } Example Flow Start Timer Send Msg Toggle LED System Init Radio Transmit Radio Receive … Sleep … … Sleep … WEI L3 - TinyOS

  43. = HW Timer Overflow What’s Happening Underneath? • MCU hardware modules operate concurrently  Must handle events in a timely manner • Hardware events preempt application events • Allows system to operate asynchronously from app • Tasks are used to signal application events • Kernel scheduler executes tasks one-by-one Start Timer Send Msg Toggle LED System Init Radio Transmit Radio Receive … Sleep … … Sleep … WEI L3 - TinyOS

  44. Intranet/Internet (IP) Client Data Browsing and Processing Canonical SensorNet Network Architecture Patch Network Sensor Node Sensor Node Sensor Patch Gateway Gateway Transit Network (IP or not) Access point - Base station - Proxy Verification links Other information sources Data Service WEI L3 - TinyOS

  45. OTA IP 6LowPAN L2 UDP/TCP L4 IP route L3 TinyOS 2x Embedded IP Architecture Higher Level Embedded Web Services Basic Health & Mgmt Services Basic Configuration Services Low-Power 802.15.4 Flash Storage Sensor Drivers Virtual ms Timer Pwr Mgr Scheduler Ext. INT GPIO Pins s Timer SPI, i2c, UART ADC RTC arbiters WEI L3 - TinyOS

  46. TinyOS Execution Philosophy • Sleep almost all the time. • Wake-up (quickly) when there is something to do. • Process it and all other concurrent or serial activities as rapidly as possible. • Structured, event driven concurrency • Never wait!!! • Automatically go back to sleep WEI L3 - TinyOS

  47. TinyOS Structured Design Philosophy • Think hard about components • Well-define behavior, well-define interfaces • Compose components into larger components • Flexible structured design of entire system • And application • Dealing with distributed system of many resource-constrained devices embedded in hard to reach places and coping with noise, uncertainty and variation. • Make the node, the network, and the system as robust as possible. • KEEP IT SIMPLE! WEI L3 - TinyOS

More Related