TinyOS and Low Power Wireless Networking – A Study in Realistic Abstraction David E.
Download ReportTranscript TinyOS and Low Power Wireless Networking – A Study in Realistic Abstraction David E.
TinyOS and Low Power Wireless Networking – A Study in Realistic Abstraction David E. Culler* Mobicom / Mobihoc Lunch Sept 12, 2007 * with thanks to a generation of students, NSF, DARPA, Micro, Intel, Microsoft, HP, Sun SigMobile 7/12/2007 1 Abstraction … • … the process of generalization by reducing the information content of a concept or an observable phenomenon, typically in order to retain only information which is relevant for a particular purpose. SigMobile 7/12/2007 2 In Math and Science … • … to focus on essential aspects of a problem SigMobile 7/12/2007 3 In Computer Science … • …forming boundaries that decouple complex systems and limit dependence on implementation artifacts. SigMobile 7/12/2007 4 Today • We’re going to talk about the interplay of abstractions and innovation in system design • But first, to set context … SigMobile 7/12/2007 5 The Internet Today SigMobile 7/12/2007 6 The Internet Tomorrow Low resolution Sensor, Test4, Increasing frequency 1 Acceleration (g) 0.5 0 -0.5 -1 0 2 4 6 8 10 12 14 16 18 Time (sec) SigMobile 7/12/2007 7 Why “Real” Information is so Important Save Resources Improve Productivity Enable New Knowledge Increase Comfort Enhance Safety & Security Preventing Failures High-Confidence Transport Improve Food & H20 Protect Health SigMobile 7/12/2007 8 Enabling Technology Network Microcontroller Flash Storage Radio Communication IEEE 802.15.4 SigMobile Sensors 7/12/2007 9 The Systems Challenge Monitoring & Managing Spaces and Things applications data mgmt service network system architecture Comm. sensing Store Proc actuate technology Power Miniature, low-power connections to the physical world SigMobile 7/12/2007 10 Circa 97 Inspirations • Post-PC age arrived – The Palm Pilot in hand and massive computing clusters in the infrastructure! • Smart Dust vision thing – complete (albeit very limit) mm3 computing system expected in 10 – 15 years => Only 10 years to get the systems & networking right! • Estrin PC104-WiFi Testbed – None of the beautiful networking ideas mattered because ALL the energy went into idle listening of 802.11 MAC. • Growing community Solving Imaginary Problems Need a platform to “rub our noses” in the real problems Necessity IS the mother of invention SigMobile 7/12/2007 11 Traditional Systems… Application Application User System Network Stack Transport Threads Network Address Space Data Link Files Physical Layer Drivers • Well established layers of abstractions • Strict boundaries • Ample resources • Independent Applications at endpoints communicate pt-pt through routers • Well attended Routers SigMobile 7/12/2007 12 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 SigMobile 7/12/2007 13 Starting Points • Classical RTOS – Focused on scheduling predictable loads, load shedding, and deadlines – Communication inherently asynchronous • Threads in their many forms – Many stacks, unstructured interactions through shared variables, coordination through complex schedulers • 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 “spaghetti” • Threaded Abstract machine – compilation target of inherently parallel languages – Simple two-level scheduling hierarchy • 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) SigMobile 7/12/2007 14 Embedded System Reality => Hardware • 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 SigMobile 7/12/2007 15 Embedded System Reality=> 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 SigMobile Digital Signal Processing Software storage threads Bus ADC Digital sensor Analog sensor 7/12/2007 16 Embedded System Reality=> 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 Higher Level of stack Communication Protocol State processing Logical Peer Comm. – Exceptions, etc. Lower Level of stack SigMobile 7/12/2007 17 Tiny OS “Abstraction Builder” • Component: – – – – – Set of bidirectional Command/Event Interfaces Commands Handlers Event Handlers Frame (storage) Tasks (concurrency) • Constrained two-level scheduling model – tasks + events Events – Hierarchical Commands • System = Scheduler + graph of Components interface Component • Constrained Storage Model – frame per component, – Single shared stack, – no heap Task Internal State • Structured event-driven processing • Very lean multithreading • Efficient Layering – Events can signal events • Extremely modular construction – Separates creation and composition of functional elements SigMobile 7/12/2007 18 application System = Graph of Components Route map router sensor appln Modular construction of Protocols. - layers and layers. packet Radio byte bit Radio Packet byte Active Messages Serial Packet UART Temp photo SW HW ADC clocks RFM Graph of cooperating state machines on shared stack Execution driven by interrupts * Early TinyOS 0.x component graph going all the way down to modulating the RF channel in software. SigMobile 7/12/2007 19 Reality Gap narrowed, but … Monitoring & Managing Spaces and Things Applications system Wireless Storage Processing Sensors Technology Miniature, low-power connections to the physical world SigMobile 7/12/2007 20 Architecture of a Mote Storage Flash Processing microcontroller proc data logs pgm images I/O Data SRAM timers pgm EPROM WD Low-power Standby & Wakeup • • • • • • Sensor Interface ADC analog sensors digital sensors Wireless Net Interface RF transceiver Wired Net Interface serial link USB,EN,… antenna Efficient wireless protocol primitives Flexible sensor interface Ultra-low power standby Very Fast wakeup Watchdog and Monitoring Data SRAM is critical limiting resource System Architecture Directions for Networked Sensors, Hill,. Szewcyk, Woo, Culler, Hollar, Pister, ASPLOS 2000 SigMobile 7/12/2007 21 Abstraction of a whole industry • Microcontroller window? SigMobile 7/12/2007 22 Microcontroller Reality Check • Memory starved – Far from Amdahl-Case 3M rule – 4x improvement in 2005 • Fairly uniform active inst per nJ – Faster MCUs generally a bit better • Min operating voltage – 1.8 volts => most of alkaline battery – 2.7 volts => half of alkaline battery • Standby power – – – – Recently a 10x improvement Probably due to design focus Fundamentally SRAM leakage Wake-up time is key • Trade sleep power for wake-up time – Memory restore 2004: Microcontroller market responded substantially to WSN requirements 2005/6: Radio integration • DMA Support 2006/7: Proliferation and solidification – permits ADC sampling while processor is sleeping ? - Complete SoC SigMobile 7/12/2007 23 Memory $s – its different down there MSP430x1xx Price per Flash x RAM • Regression – RAM: – FLASH: 9 8 7 $0.397 per kB $0.074 per kB • standard SRAM/DRAM 6 – 1M SRAM: $0.002 per kB – 256M DRAM ~ $10-5 per kB 5 Approx $ 4 3 2 10240 1 2048 RAM 61440 128 56320 49152 24576 32768 Flash 16384 512 8192 4096 2048 1024 0 SigMobile 7/12/2007 24 The Mote Explosion WINS (UCLA/ROckwell) Intel rene’ LWIM-III (UCLA) SmartDust WeC zeevo BT Intel/UCB dot Rene BTNodeEyes Intel cf-mica trio Mica Telos XBOW mica XBOW rene2 Intel MOTE2 Intel iMOTE XBOW cc-dot Bosch cc-mica XBOW mica2 XBOW micaZ digital sun rain-mica Dust Inc blue cc-TI SigMobile 04 05 06 07 CyberPhysical 03 NETS/ NOSS 02 CENS STC 01 NSF 00 NEST Expedition 99 SENSIT LWIM DARPA 97 98 7/12/2007 25 A worldwide community Wireless Sensor Networks SmartDust Wireless NEST Sensors Storage Processing SigMobile 7/12/2007 26 Grounded Foundation – with some constraints Applications system architecture Technology Wireless Storage Processing SigMobile Sensors 7/12/2007 27 A Set of Stacks Emerge Applications Over-the-air Programming Network Protocols Link Radio Serial Applications and Services Blocks, Logs, Files Flash Scheduling, Management Streaming drivers MCU,Timers, Bus,… ADC, Sensor I/F system architecture Technology Wireless Storage Processing SigMobile Sensors 7/12/2007 28 A Hardware Abstraction Architecture Over-the-air Programming Network Protocols Link Applications and Services Blocks, Logs, Files Hardware Independence Streaming Scheduling, Management drivers (HIL) Hardware Abstraction (HAL) Radio Serial Flash Wireless Storage MCU,Timers, Bus,… ADC, Sensor I/F Processin g Sensors Hardware Presentation (HPL) SigMobile 7/12/2007 29 TinyOS 2.0 Execution Model Over-the-air Programming Network Protocols Link Radio Serial Applications and Services Blocks, Logs, Files Flash Scheduling, Management Streaming drivers MCU, Timers, Bus,… ADC, Sensor I/F WSN mote platform Wireless Storage Processing Communication Centric Resource-Constrained Event-driven Execution SigMobile Sensors 7/12/2007 30 Low Power Networking in the Real World Applications Network system architecture Technology Wireless Storage Processing SigMobile Sensors 7/12/2007 31 Why Multihop Routing • Power! 140 – to transmit D grows as D3 or worse – to route distance D grows linearly 120 • Bandwidth (spatial multiplexing) 100 – With n nodes in a single cell, each gets at most 1/n bandwidth – Many small cells => many simultaneous transmissions. 80 60 • Reliability (spatial diversity) 40 20 0 0 1 2 3 4 5 SigMobile – Individual links experience interference, obstacles, and multipath effects – Even short-range “wireless wires” require human nurturing » IRDA, Bluetooth, WiFi, Cell – Provides spatial diversity and receiver diversity » rather than antenna diversity – Protocol level reliability 7/12/2007 32 What we mean by “Low Power” • 2 AA => 1.5 amp hours (~4 watt hours) • Cell => 1 amp hour (3.5 watt hours) Cell: 500 -1000 mW WiFi: 300 - 500 mW GPS: 50 – 100 mW => few hours active => several hours => couple days WSN: 50 mW active, 20 uW passive 450 uW => one year 45 uW => ~10 years * System design * Leakage (~RAM) * Nobody fools mother nature Ave Power = fact * Pact + fsleep * Psleep + fwaking * Pwaking SigMobile 7/12/2007 33 Routing Mechanism • Upon each transmission, one of the recipients retransmits. • Which one? • What determines a link? SigMobile 7/12/2007 34 Classical Routing Abstraction • Connectivity between nodes defines the network graph. • A Routing algorithm determines the sub-graph that is used for communication between nodes. – Route formation, path selection • Packets are forwarded from source to destination over the routing subgraph – At each node in the path, determine the recipient of the next hop • The selection at each hop is made based on the information at hand – Sender address, current address, destination address, information in the packet, information on the node. – Table-driven, source based, algorithmic, … – Who knows the route? Do you determine it as you go? SigMobile 7/12/2007 35 What’s different in WSN? • There is no a priori network graph – It is discovered by sending packets and seeing who receives them. • The embedding of the “network” in space is important. – Need to get information to travel between particular physical places. • addressing & naming – Flat EUID? Hierarchical? Topologically meaningful? Spatially meaningful? SigMobile 7/12/2007 36 Grasping for a Connectivity Abstraction • Unit Disk model – Link(A,B) iff dist(A,B) ≤ R • Assumed by much work on wireless network protocols R – Routing, clustering, scheduling, coverage, … • With no accounting of traffic, etc. – Collisions, … SigMobile 7/12/2007 37 Self-Organized Mesh Routing is easy 2 2 2 2 1 1 2 0 SigMobile 7/12/2007 38 Complexity of Connectivity • Direct Reception “Neighborhood” • Non-isotropic • Large variation in affinity – Asymmetric links – Long, stable high quality links – Short bad ones • Varies with traffic load – Collisions – Distant nodes raise noise floor • Many poor “neighbors” • Good ones mostly near, some far • Capture-effect SigMobile 7/12/2007 39 Abstracting Uncertainty Signal Noise Distance SigMobile 7/12/2007 40 Which node do you route through? SigMobile 7/12/2007 41 What does this mean? • Always routing through nodes “at the hairy edge” – Wherever you set the threshold, the most useful node will be close to it • Topology determination is a continuous process of discovery and validation – and it must be done politely • Connectivity is determined by communication – If B receives packet reasonably reliably from A, then A B – If A receives packet reasonably reliably from B, then A B – And if both are true, A B SigMobile 7/12/2007 42 Trickle, don’t Flood 2 2 2 2 1 1 2 0 SigMobile 7/12/2007 43 Mesh Protocols that Work • Polite, continuous observation – Passive probing wherever possible • Adjust communication rate to node density • Link level retransmission and rerouting • Maintain at least two (preferably three) candidate next hops (e.g., parents) – Use acks to determine quality of the link – Throw in a new candidate from time to time. • Cope with transients locally • Never record a list of children, list of neighbors, … – Insufficient memory to build the table. • With the nodes (almost) never listening SigMobile 7/12/2007 44 Communication Power – Passive Vigilance Sleep Transmit ~10 uA ~20 mA x 1-5 ms [20 - 100 uAs] I Time I Time Listen Receive ~20 mA ~20 mA x 2-6 ms SigMobile 7/12/2007 45 3 Basic Solution Techniques Goal: listen only when there is likely to be something useful to hear. • Listen during scheduled time slots – – – – Arrange a schedule of possible communication opportunities Maintain appropriately coordinated clocks and schedule Only listen during specific “slots” Many variants: Token-Ring, TDMA, Beacons, Bluetooth piconets, … TSMP, … • Sampled Listening – Listen for very short intervals to detect eminent transmissions – On detection, listen actively to receive • Listen after send (with powered infrastructure) – Generally, device is not listening and will not receive. – After it transmits to a receptive device, it listens for a time window – Many variants: 802.11 AMAT, Key fobs, remote modems, … SigMobile 7/12/2007 46 A Systems Challenge Monitoring & Managing Spaces and Things applications data mgmt service network system architecture Comm. MEMS sensing Store Proc uRobots actuate technology Power Miniature, low-power connections to the physical world SigMobile 7/12/2007 47 Thinking about the Physical World as “Signals” • What is the bandwidth of the weather? • What is the nyquist of the soil? • What is the placement noise? • What is the sampling jitter error? SigMobile 7/12/2007 48 Realistic Abstraction • The Right Abstractions can be Tremendously Empowering – Reveal essential elements without all the contextual artifacts – Allow innovation within a portion of a complex and important system • The Wrong ones can seriously disenfranchise – Become a distorted reality of their own – Surrounding constraints prevent useful innovation SigMobile 7/12/2007 49 Let Chaos Reign, Rein in Chaos • TinyOS was invented to provided a framework for defining important abstractions for wireless intelligent devices embedded in the physical world. – Allow the right abstractions to emerge from experience – Structured events great for protocols, natural to put simple threads on top for application logic • TinyOS as an operating system design & platform is essentially done – Good set of hardened abstractions in TinyOS 2.0 – Many platforms & Broad international community • Opportunities are also enabled by the presence of structure • We have the BSD of wsn, it is time for TCP/IP and the rest. SigMobile 7/12/2007 50 THE Question If Wireless Sensor Networks represent a future of “billions of information devices embedded in the physical world,… why don’t they run THE standard internetworking protocol? Web Services XML / RPC / REST / SOAP / OSGI HTTP / FTP / SNMP TCP / UDP IP Ethernet Sonet Enet 10M Enet 100M Enet 1G10G Enet GPRS Serial 802.11 802.11a 802.11b 802.11g Plugs and People SigMobile RFM,CC10k,…,802.15.4 Self-Contained 7/12/2007 51 Sensor Network “Networking” Appln Hood EnviroTrack FTSP Transport Routing Scheduling SPIN TTDD Phy Ascent GPSR SPAN ReORg PC Drip Arrive MintRoute GRAD GAF FPS Yao SMAC PAMAS Link Trickle Deluge MMRP TORA CGSR AODVDSR ARA GSR DBF DSDV TBRPF Resynch Topology TinyDB Diffusion Regions WooMac TMAC Pico WiseMAC Bluetooth RadioMetrix RFM CC1000 SigMobile eyes BMAC 802.15.4 nordic 7/12/2007 52 The Answer They should • Substantially advances the state-of-the-art in both domains. • Implementing IP requires tackling the general case, not just a specific operational slice – Interoperability with all other potential IP network links – Potential to name and route to any IP-enabled device within security domain – Robust operation despite external factors » Coexistence, interference, errant devices, ... • While meeting the critical embedded wireless requirements – – – – High reliability and adaptability Long lifetime on limited energy Manageability of many devices Within highly constrained resources SigMobile 7/12/2007 53 Web Services XML / RPC / REST / SOAP / OSGI HTTP / FTP / SNMP Proxy / Gateway Making sensor nets make sense LoWPAN – 802.15.4 • 1% of 802.11 power, easier to embed, as easy to use. • 8-16 bit MCUs with KBs, not MBs. • Off 99% of the time TCP / UDP IP Ethernet Sonet 802.11 802.15.4, … IETF 6lowpan SigMobile 7/12/2007 54 6LoWPAN: IPv6 over IEEE 802.15.4 IEEE 802.15.4 Frame Format D pan S pan Dst EUID 64 Src EUID 64 Dst16 Src16 Fchk dsp FCF DSN Len preamble SFD 127 bytes Network Header Application Data IETF 6LoWPAN Format 01 0 0 0 0 0 1 01 0 0 0 0 1 0 Uncompressed IPv6 address [RFC2460] HC1 40 bytes Fully compressed: 1 byte Source address Destination address Traffic Class & Flow Label Next header : derived from link address : derived from link address : zero : UDP, TCP, or ICMP • Deep compression by breaking the layering abstraction and putting it all back together again. SigMobile 7/12/2007 55 Non-Traditional Directions Ahead • Testing – for application specific, platform specific embedded distributed systems – that are very long lived and low power in the face of adversarial factors. • Synthesis – Whole System and Platform from application declaration • Performance & Reliability analysis – Interactions and trade-offs SigMobile 7/12/2007 56 Reliability SigMobile 7/12/2007 57 Traditional Analysis Delivered Performance Offered Load SigMobile 7/12/2007 58 Analysis that really matters Mobility Reliability Changes in network population Environmental variability Bandwidth Energy Expended Delay Traffic Load Traffic Variability SigMobile 7/12/2007 59 Directions Ahead • • • • Testing Synthesis Performance & Reliability analysis THE NETWORK REALLY – TCP & UCP / IP / 6LoWPAN is a given [ soon RFC4944 ] – all the other aspects of internet services for broad-based physical information – Time to define the equivalent of Sockets API – How to collect, categorize, search? – Which MAC(s) below? Channel Hopping? Power Mgmt? – Mesh Under or Router Over? – Routing into, out of, within? [ RL2N BoF in BC ] SigMobile 7/12/2007 60 A new tier… Routers / Gateways Classical IP Network and its overlays SensorNet Patch SigMobile 7/12/2007 61 The Internet of Things has Arrived LoWPAN-Extended IP Network IP Network (powered) IP/LoWPAN Router IP Device IP/LoWPAN Sensor Router SigMobile 7/12/2007 62 An(other) inconvenient truth Many critical issues facing science, government, and the public call for high fidelity and real time observations of the physical world But an inconvenient truth is that the field does not lend itself to familiar abstractions and research practices… Networks of smart, wireless sensors, forming the Front-Tier of the Internet can help reveal the previously unobservable SigMobile 7/12/2007 63