Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 TAG: A Tiny Aggregation Service for Ad-Hoc Sensor Networks Samuel Madden UC Berkeley with Michael Franklin, Joseph Hellerstein, and Wei Hong December.

Similar presentations


Presentation on theme: "1 TAG: A Tiny Aggregation Service for Ad-Hoc Sensor Networks Samuel Madden UC Berkeley with Michael Franklin, Joseph Hellerstein, and Wei Hong December."— Presentation transcript:

1 1 TAG: A Tiny Aggregation Service for Ad-Hoc Sensor Networks Samuel Madden UC Berkeley with Michael Franklin, Joseph Hellerstein, and Wei Hong December 9th, 2002 @ OSDI

2 2 TAG Introduction What is a sensor network? Programming Sensor Networks Is Hard Declarative Queries Are Easy –Tiny Aggregation (TAG) : In-network processing via declarative queries! Example: »Vehicle tracking application: 2 weeks for 2 students »Vehicle tracking query: took 2 minutes to write, worked just as well! SELECT MAX(mag) FROM sensors WHERE mag > thresh EPOCH DURATION 64ms

3 3 Overview Sensor Networks Queries in Sensor Nets Tiny Aggregation –Overview –Simulation & Results

4 4 Overview Sensor Networks Queries in Sensor Nets Tiny Aggregation –Overview –Simulation & Results

5 5 Device Capabilities “Mica Motes” –8bit, 4Mhz processor »Roughly a PC AT –40kbit CSMA radio –4KB RAM, 128K flash, 512K EEPROM –TinyOS based Variety of other, similar platforms exist –UCLA WINS, Medusa, Princeton ZebraNet, MIT Cricket

6 6 Sensor Net Sample Apps Habitat Monitoring: Storm petrels on great duck island, microclimates on James Reserve. Traditional monitoring apparatus. Earthquake monitoring in shake- test sites. Vehicle detection: sensors along a road, collect data about passing vehicles.

7 7 Metric: Communication Lifetime from one pair of AA batteries –2-3 days at full power –6 months at 2% duty cycle Communication dominates cost –100s of uS to compute –30mS to send message Our metric: communication!

8 8 Communication In Sensor Nets Radio communication has high link-level losses –typically about 20% @ 5m Ad-hoc neighbor discovery Tree-based routing A B C D F E

9 9 Overview Sensor Networks Queries in Sensor Nets Tiny Aggregation –Overview –Optimizations & Results

10 10 Declarative Queries for Sensor Networks Examples: SELECT nodeid, light FROM sensors WHERE light > 400 EPOCH DURATION 1s 1 EpochNodeidLightTempAccelSound 01455xxx 02389xxx 11422xxx 12405xxx 2 SELECT AVG(sound) FROM sensors EPOCH DURATION 10s 2 SELECT AVG(sound) FROM sensors EPOCH DURATION 10s roomNo, GROUP BY roomNo HAVING AVG(sound) > 200 Rooms w/ sound > 200 Sensors

11 11 Overview Sensor Networks Queries in Sensor Nets Tiny Aggregation –Overview –Optimizations & Results

12 12 TAG In-network processing of aggregates –Common data analysis operation »Aka gather operation or reduction in || programming –Communication reducing »Benefit operation dependent –Across nodes during same epoch Exploit semantics improve efficiency!

13 13 Query Propagation SELECT COUNT(*)… 1 2 3 4 5

14 14 Pipelined Aggregates In each epoch: –Each node samples local sensors once –Generates partial state record (PSR) »local readings »readings from children –Outputs PSR from previous epoch. After (depth-1) epochs, PSR for the whole tree output at root 1 23 4 5 Value from 5 produced at time t arrives at 1 at time (t+3) Value from 2 produced at time t arrives at 1 at time (t+1) To avoid combining PSRs from different epochs, sensors must cache values from children

15 15 Illustration: Pipelined Aggregation 1 2 3 4 5 SELECT COUNT(*) FROM sensors Depth = d

16 16 Illustration: Pipelined Aggregation 12345 111111 1 2 3 4 5 1 1 1 1 1 Sensor # Epoch # Epoch 1 SELECT COUNT(*) FROM sensors

17 17 Illustration: Pipelined Aggregation 12345 111111 231221 1 2 3 4 5 1 2 2 1 3 Sensor # Epoch # Epoch 2 SELECT COUNT(*) FROM sensors

18 18 Illustration: Pipelined Aggregation 12345 111111 231221 341321 1 2 3 4 5 1 2 3 1 4 Sensor # Epoch # Epoch 3 SELECT COUNT(*) FROM sensors

19 19 Illustration: Pipelined Aggregation 12345 111111 231221 341321 451321 1 2 3 4 5 1 2 3 1 5 Sensor # Epoch # Epoch 4 SELECT COUNT(*) FROM sensors

20 20 Illustration: Pipelined Aggregation 12345 111111 231221 341321 451321 551321 1 2 3 4 5 1 2 3 1 5 Sensor # Epoch # Epoch 5 SELECT COUNT(*) FROM sensors

21 21 Aggregation Framework As in extensible databases, we support any aggregation function conforming to: Agg n ={f init, f merge, f evaluate } f init {a 0 }  F merge {, }  F evaluate { }  aggregate value (Merge associative, commutative!) Example: Average AVG init {v}  AVG merge {, }  AVG evaluate { }  S/C Partial State Record (PSR)

22 22 Types of Aggregates SQL supports MIN, MAX, SUM, COUNT, AVERAGE Any function can be computed via TAG In network benefit for many operations –E.g. Standard deviation, top/bottom N, spatial union/intersection, histograms, etc. –Compactness of PSR

23 23 Taxonomy of Aggregates TAG insight: classify aggregates according to various functional properties –Yields a general set of optimizations that can automatically be applied PropertyExamplesAffects Partial State MEDIAN : unbounded, MAX : 1 record Effectiveness of TAG Duplicate Sensitivity MIN : dup. insensitive, AVG : dup. sensitive Routing Redundancy Exemplary vs. Summary MAX : exemplary COUNT: summary Applicability of Sampling, Effect of Loss MonotonicCOUNT : monotonic AVG : non-monotonic Hypothesis Testing, Snooping

24 24 TAG Advantages Communication Reduction –Important for power and contention Continuous stream of results –In the absence of faults, will converge to right answer Lots of optimizations –Based on shared radio channel –Semantics of operators

25 25 Simulation Environment Evaluated via simulation Coarse grained event based simulator –Sensors arranged on a grid –Two communication models »Lossless: All neighbors hear all messages »Lossy: Messages lost with probability that increases with distance

26 26 Simulation Result Simulation Results 2500 Nodes 50x50 Grid Depth = ~10 Neighbors = ~20 Some aggregates require dramatically more state!

27 27 Optimization: Channel Sharing (“Snooping”) Insight: Shared channel enables optimizations Suppress messages that won’t affect aggregate –E.g., MAX –Applies to all exemplary, monotonic aggregates

28 28 Optimization: Hypothesis Testing Insight: Guess from root can be used for suppression –E.g. ‘MIN < 50’ –Works for monotonic & exemplary aggregates »Also summary, if imprecision allowed How is hypothesis computed? –Blind or statistically informed guess –Observation over network subset

29 29 Experiment: Hypothesis Testing Uniform Value Distribution, Dense Packing, Ideal Communication

30 30 Optimization: Use Multiple Parents For duplicate insensitive aggregates Or aggregates that can be expressed as a linear combination of parts –Send (part of) aggregate to all parents »In just one message, via broadcast –Decreases variance A BC A BC A BC 1 A BC A BC 1/2

31 31 Multiple Parents Results Better than previous analysis expected! Losses aren’t independent! Insight: spreads data over many links Critical Link! No Splitting With Splitting

32 32 Summary TAG enables in-network declarative query processing –State dependent communication benefit –Transparent optimization via taxonomy »Hypothesis Testing »Parent Sharing Declarative queries are the right interface for data collection in sensor nets! –Easier to program and more efficient for vast majority of users TinyDB Release Available - http://telegraph.cs.berkeley.edu/tinydb http://telegraph.cs.berkeley.edu/tinydb

33 33 Questions? TinyDB Demo After The Session…

34 34 TinyOS Operating system from David Culler’s group at Berkeley C-like programming environment Provides messaging layer, abstractions for major hardware components –Split phase highly asynchronous, interrupt- driven programming model Hill, Szewczyk, Woo, Culler, & Pister. “Systems Architecture Directions for Networked Sensors.” ASPLOS 2000. See http://webs.cs.berkeley.edu/tos

35 35 In-Network Processing in TinyDB SELECT AVG(light) EPOCH DURATION 4s Cost metric = #msgs 16 nodes 150 Epochs In-net loss rates: 5% External loss: 15% Network depth: 4

36 36 Grouping Recall: GROUP BY expression partitions sensors into distinct logical groups –E.g. “partition sensors by room number” If query is grouped, sensors apply expression on each epoch PSRs tagged with group When a PSR (with group) is received: –If it belongs to a stored group, merge with existing PSR –If not, just store it At the end of each epoch, transmit one PSR per group Need to evict if storage overflows.

37 37 Group Eviction Problem: Number of groups in any one iteration may exceed available storage on sensor Solution: Evict! (Partial Preaggregation*) –Choose one or more groups to forward up tree –Rely on nodes further up tree, or root, to recombine groups properly –What policy to choose? »Intuitively: least popular group, since don’t want to evict a group that will receive more values this epoch. »Experiments suggest: Policy matters very little Evicting as many groups as will fit into a single message is good * Per-Åke Larson. Data Reduction by Partial Preaggregation. ICDE 2002.

38 38 Declarative Benefits In Sensor Networks Vastly simplifies execution for large networks –Since locations are described by predicates –Operations are over groups Enables tolerance to faults –Since system is free to choose where and when operations happen Data independence –System is free to choose where data lives, how it is represented

39 39 Simulation Screenshot

40 40 Hypothesis Testing For Average AVERAGE: each node suppresses readings within some ∆ of a approximate average µ*. –Parents assume children who don’t report have value µ* Computed average cannot be off by more than ∆.

41 41 TinyAlloc Handle Based Compacting Memory Allocator For Catalog, Queries Free Bitmap Heap Master Pointer Table Handle h; call MemAlloc.alloc(&h,10); … (*h)[0] = “Sam”; call MemAlloc.lock(h); tweakString(*h); call MemAlloc.unlock(h); call MemAlloc.free(h); User Program Free Bitmap Heap Master Pointer Table Free Bitmap Heap Master Pointer Table Free Bitmap Heap Master Pointer Table Compaction

42 42 Schema Attribute & Command IF –At INIT(), components register attributes and commands they support »Commands implemented via wiring »Attributes fetched via accessor command –Catalog API allows local and remote queries over known attributes / commands. Demo of adding an attribute, executing a command.

43 43 Q1: Expressiveness Simple data collection satisfies most users How much of what people want to do is just simple aggregates? –Anecdotally, most of it –EE people want filters + simple statistics (unless they can have signal processing) However, we’d like to satisfy everyone!

44 44 Query Language New Features: –Joins –Event-based triggers »Via extensible catalog –In network & nested queries –Split-phase (offline) delivery »Via buffers

45 45 Sample Query 1 Bird counter: CREATE BUFFER birds(uint16 cnt) SIZE 1 ON EVENT bird-enter(…) SELECT b.cnt+1 FROM birds AS b OUTPUT INTO b ONCE

46 46 Sample Query 2 Birds that entered and left within time t of each other: ON EVENT bird-leave AND bird-enter WITHIN t SELECT bird-leave.time, bird-leave.nest WHERE bird-leave.nest = bird-enter.nest ONCE

47 47 Sample Query 3 Delta compression: SELECT light FROM buf, sensors WHERE | s.light – buf.light | > t OUTPUT INTO buf SAMPLE PERIOD 1s

48 48 Sample Query 4 Offline Delivery + Event Chaining CREATE BUFFER equake_data( uint16 loc, uint16 xAccel, uint16 yAccel) SIZE 1000 PARTITION BY NODE SELECT xAccel, yAccel FROM SENSORS WHERE xAccel > t OR yAccel > t SIGNAL shake_start(…) SAMPLE PERIOD 1s ON EVENT shake_start(…) SELECT loc, xAccel, yAccel FROM sensors OUTPUT INTO BUFFER equake_data(loc, xAccel, yAccel) SAMPLE PERIOD 10ms

49 49 Event Based Processing Enables internal and chained actions Language Semantics –Events are inter-node –Buffers can be global Implementation plan –Events and buffers must be local –Since n-to-n communication not (well) supported Next: operator expressiveness

50 50 Attribute Driven Topology Selection Observation: internal queries often over local area* –Or some other subset of the network »E.g. regions with light value in [10,20] Idea: build topology for those queries based on values of range-selected attributes –Requires range attributes, connectivity to be relatively static * Heideman et. Al, Building Efficient Wireless Sensor Networks With Low Level Naming. SOSP, 2001.

51 51 Attribute Driven Query Propagation 123 4 [1,10] [7,15] [20,40] SELECT … WHERE a > 5 AND a < 12 Precomputed intervals == “Query Dissemination Index”

52 52 Attribute Driven Parent Selection 123 4 [1,10] [7,15] [20,40] [3,6] [3,6]  [1,10] = [3,6] [3,7]  [7,15] = ø [3,7]  [20,40] = ø Even without intervals, expect that sending to parent with closest value will help

53 53 Hot off the press…

54 54 Grouping GROUP BY expr –expr is an expression over one or more attributes »Evaluation of expr yields a group number »Each reading is a member of exactly one group Example: SELECT max(light) FROM sensors GROUP BY TRUNC(temp/10) Sensor IDLightTempGroup 145252 227282 366343 468373 Groupmax(light) 245 368 Result:

55 55 Having HAVING preds –preds filters out groups that do not satisfy predicate –versus WHERE, which filters out tuples that do not satisfy predicate –Example: SELECT max(temp) FROM sensors GROUP BY light HAVING max(temp) < 100 Yields all groups with temperature under 100

56 56 Group Eviction Problem: Number of groups in any one iteration may exceed available storage on sensor Solution: Evict! –Choose one or more groups to forward up tree –Rely on nodes further up tree, or root, to recombine groups properly –What policy to choose? »Intuitively: least popular group, since don’t want to evict a group that will receive more values this epoch. »Experiments suggest: Policy matters very little Evicting as many groups as will fit into a single message is good

57 57 Experiment: Basic TAG Dense Packing, Ideal Communication

58 58 Experiment: Hypothesis Testing Uniform Value Distribution, Dense Packing, Ideal Communication

59 59 Experiment: Effects of Loss

60 60 Experiment: Benefit of Cache

61 61 Pipelined Aggregates After query propagates, during each epoch: –Each sensor samples local sensors once –Combines them with PSRs from children –Outputs PSR representing aggregate state in the previous epoch. After (d-1) epochs, PSR for the whole tree output at root –d = Depth of the routing tree –If desired, partial state from top k levels could be output in k th epoch To avoid combining PSRs from different epochs, sensors must cache values from children 1 23 4 5 Value from 5 produced at time t arrives at 1 at time (t+3) Value from 2 produced at time t arrives at 1 at time (t+1)

62 62 Pipelining Example 1 2 43 5 SI D EpochAgg. SIDEpochAgg. SIDEpochAgg.

63 63 Pipelining Example 1 2 43 5 SI D EpochAgg. 201 401 SI D EpochAgg. 101 SIDEpochAgg. 301 501 Epoch 0

64 64 Pipelining Example 1 2 43 5 SIDEpochAgg. 201 401 211 411 302 SI D EpochAgg. 101 111 202 SIDEpochAgg. 301 501 311 511 Epoch 1

65 65 Pipelining Example 1 2 43 5 SIDEpochAgg. 201 401 211 411 302 221 421 312 SI D EpochAgg. 101 111 202 121 204 SIDEpochAgg. 301 501 311 511 321 521 Epoch 2

66 66 Pipelining Example 1 2 43 5 SIDEpoc h Agg. 201 401 211 411 302 221 421 312 SIDEpochAgg. 101 111 202 121 204 SIDEpochAgg. 301 501 311 511 321 521 Epoch 3

67 67 Pipelining Example 1 2 43 5 Epoch 4

68 68 Our Stream Semantics One stream, ‘sensors’ We control data rates Joins between that stream and buffers are allowed Joins are always landmark, forward in time, one tuple at a time –Result of queries over ‘sensors’ either a single tuple (at time of query) or a stream Easy to interface to more sophisticated systems Temporal aggregates enable fancy window operations

69 69 Formal Spec. ON EVENT [... WITHIN ] [SELECT { |agg( )|temporalagg( )} FROM [sensors | | events]] [WHERE { }] [GROUP BY { }] [HAVING { }] [ACTION [ [WHERE ] | BUFFER SIGNAL ({ }) | (SELECT... ) [INTO BUFFER ]]] [SAMPLE PERIOD [FOR ] [INTERPOLATE ] [COMBINE {temporal_agg( )}] | ONCE]

70 70 Buffer Commands [AT :] CREATE [ ] BUFFER ({ }) PARTITION BY [ ] SIZE [, ] [AS SELECT... [SAMPLE PERIOD ]] DROP BUFFER


Download ppt "1 TAG: A Tiny Aggregation Service for Ad-Hoc Sensor Networks Samuel Madden UC Berkeley with Michael Franklin, Joseph Hellerstein, and Wei Hong December."

Similar presentations


Ads by Google