Querying Sensor Networks - Massachusetts Institute of
Download
Report
Transcript Querying Sensor Networks - Massachusetts Institute of
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
1
TAG Introduction
• What is a sensor network?
• Programming sensor nets is hard!
• Declarative queries are easy
– Tiny Aggregation (TAG): In-network
processing via declarative queries
• Example:
» Vehicle tracking application: 2 weeks
for 2 students
SELECT MAX(mag)
» Vehicle tracking query: took 2 minutes FROM sensors
to write, worked just as well!
WHERE mag > thresh
EPOCH DURATION 64ms
2
Overview
• Sensor Networks
• Queries in Sensor Nets
• Tiny Aggregation
– Overview
– Simulation & Results
3
Overview
• Sensor Networks
• Queries in Sensor Nets
• Tiny Aggregation
– Overview
– Simulation & Results
4
Device Capabilities
• “Mica Motes”
– 8bit, 4Mhz processor
» Roughly a PC AT
– 40kbit CSMA radio
– 4KB RAM, 128KB flash, 512KB EEPROM
– TinyOS based
• Variety of other, similar platforms exist
– UCLA WINS, Medusa, Princeton ZebraNet,
SmartIts
5
Sensor Net Sample Apps
Habitat Monitoring: Storm
petrels on great duck island,
microclimates on James
Reserve.
Earthquake monitoring in shaketest sites.
Vehicle detection: sensors along a
road, collect data about passing
vehicles.
Traditional monitoring
apparatus. 6
Metric: Communication
• Lifetime from one
pair of AA batteries
• Communication
dominates cost
– < few mS to compute
– 30mS to send
message
20
15
Snoozing
Current (mA)
– 2-3 days at full
power
– 6 months at 2% duty
cycle
Time v. Current Draw During Query Processing
Processing
and Listening
10
Transmitting
5
Processing
0
• Our metric:
communication!
0
0.5
1
1.5
Time (s)
2
2.5
3
7
Communication In Sensor
Nets
• Radio communication
has high link-level
losses
A
– typically about 20% @
5m
B
• Ad-hoc neighbor
discovery
• Tree-based routing
C
D
F
E
8
Overview
• Sensor Networks
• Queries in Sensor Nets
• Tiny Aggregation
– Overview
– Optimizations & Results
9
Declarative Queries for
Sensor Networks
• Examples:
1 SELECT nodeid, light
FROM sensors
WHERE light > 400
EPOCH DURATION 1s
Sensors
Epoch Nodeid Light Temp Accel Sound
0
1
455
x
x
x
0
2
389
x
x
x
1
1
422
x
x
x
1
2
405
x
x
x
10
Aggregation Queries
2
SELECT AVG(sound)
FROM sensors
EPOCH DURATION 10s
3
Epoch
0
AVG(sound)
440
1
445
Epoch roomNo AVG(sound)
0
0
1
2
360
520
GROUP BY roomNo
1
1
370
HAVING AVG(sound) > 200
1
2
520
SELECT roomNo, AVG(sound)
FROM sensors
EPOCH DURATION 10s
Rooms w/ sound > 200
11
Overview
• Sensor Networks
• Queries in Sensor Nets
• Tiny Aggregation
– Overview
– Optimizations & Results
12
TAG
• In-network processing of aggregates
– Common data analysis operation
» Aka gather operation or reduction in || programming
– Communication reducing
» Operator dependent benefit
– Across nodes during same epoch
• Exploit semantics improve efficiency!
13
Query Propagation
SELECT
COUNT(*)…
Comm. Slot
1
Epoch
2
3
4
5
14
Basic Aggregation
• In each epoch:
– Each node samples local sensors once
– Generates partial state record (PSR)
» local readings
» readings from children
1
2
3
– Outputs PSR during its comm. slot.
• At end of epoch, PSR for whole
network output at root
• (In paper: pipelining, grouping)
4
5
15
Illustration: Aggregation
SELECT COUNT(*)
FROM sensors
Sensor #
1
1
2
3
Slot 1
1
4
5
1
2
3
Slot #
2
3
4
1
4
1
5
16
Illustration: Aggregation
SELECT COUNT(*)
FROM sensors
Sensor #
1
2
3
Slot #
3
1
4
1
2
Slot 2
5
1
2
3
2
2
4
4
1
5
17
Illustration: Aggregation
SELECT COUNT(*)
FROM sensors
Sensor #
1
2
3
1
5
1
2
Slot #
1
4
1
3
Slot 3
3
2
3
2
1
3
4
4
1
5
18
Illustration: Aggregation
SELECT COUNT(*)
FROM sensors
Sensor #
1
2
3
Slot #
2
3
2
3
1
5
1
2
Slot 4
1
4
1
4
5
1
3
4
5
5
19
Illustration: Aggregation
SELECT COUNT(*)
FROM sensors
Sensor #
1
2
3
Slot #
5
1
2
2
3
2
3
1
1
4
1
4
Slot 1
1
3
4
5
1
1
5
20
Aggregation Framework
• As in extensible databases, we support any
aggregation function conforming to:
Aggn={finit, fmerge, fevaluate}
finit{a0}
<a0>
Partial State Record (PSR)
Fmerge{<a1>,<a2>} <a12>
Fevaluate{<a1>}
aggregate value
(Merge associative, commutative!)
Example: Average
AVGinit
{v}
<v,1>
AVGmerge {<S1, C1>, <S2, C2>}
< S1 + S2 , C1 + C2>
AVGevaluate{<S, C>}
S/C
21
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
22
Taxonomy of Aggregates
• TAG insight: classify aggregates according to
various functional properties
– Yields a general set of optimizations that can
automatically be applied
Property
Partial State
Examples
MEDIAN : unbounded,
MAX : 1 record
Affects
Effectiveness of TAG
Duplicate
Sensitivity
MIN : dup. insensitive,
AVG : dup. sensitive
MAX : exemplary
COUNT: summary
COUNT : monotonic
AVG : non-monotonic
Routing Redundancy
Exemplary vs.
Summary
Monotonic
Applicability of Sampling,
Effect of Loss
Hypothesis Testing, Snooping
23
TAG Advantages
• Communication Reduction
– Important for power and contention
• Continuous stream of results
– Smooth transient faults across epochs
• Lots of optimizations
– Via operator semantics
24
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
25
Benefit of In-Network
Processing
Simulation Results
2500 Nodes
Total Bytes Xmitted vs. Aggregation Function
100000
Depth = ~10
90000
80000
Neighbors = ~20
Total Bytes Xmitted
50x50 Grid
Some aggregates
require dramatically
more state!
70000
60000
50000
40000
30000
20000
10000
0
EXTERNAL
MAX
AVERAGE
Aggregation Function
COUNT
MEDIAN
26
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
27
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
28
Experiment: Hypothesis
Testing
•Uniform Value
Distribution
•Dense Packing
•Ideal
Communication
Messages/ Epoch vs. Network Diameter
(SELECT MAX(attr), R(attr) = [0,100])
3000
No Guess
Messages / Epoch
2500
Guess = 50
Guess = 90
2000
Snooping
1500
1000
500
0
10
20
30
40
Network Diameter
50
29
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
B
C
1/2
1
1/2
A
30
Multiple Parents Results
• Better than
previous analysis
Critical
expected!
Link!
• Losses aren’t
independent!
• Insight: spreads
data over many
links
With Splitting
No Splitting
Benefit of Result Splitting
(COUNT query)
1400
Avg. COUNT
1200
1000
800
Splitting
No Splitting
600
400
200
0
(2500 nodes, lossy radio model, 6 parents per
node)
31
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
32
Questions?
TinyDB Demo After The Session…
33