When the Sensors Hit the Road The CarTel Project Sam Madden MIT CSAIL http://cartel.csail.mit.edu With Hari Balakrishnan, Vladimir Bychkovsky, Jakob Eriksson, Bret Hull, Yang Zhang, Kevin Chen, Waseem Daher, Michel Goraczko, Hongyi Hu, Sejoon Lim, Allen Miu, Daniela Rus, Eugene Shih, Arvind Thiagarajan, Sivan Toledo Stanford Database Group 1st Generation Sensor Networks Periodic monitoring – Wake up and sense – Sleep for Minutes Event-based monitoring – Transmit on external event Low data rates, duty cyles Static, small area Extremely underpowered devices “Mote” ~= Participatory Sensing “Crowd-sourced” sensing – Individuals contribute their data – Rather than relying on fixed deployments Examples: – Personalized Environmental Impact Report – Microsoft SensorMap – Dartmouth BikeNet – MapMyRun, etc. CarTel Cars as a Vehicle for Participatory Sensing Observation: – Static sensing infeasible over very wide areas – Some apps do not need high temporal fidelity Real-world problems: – Civil infrastructure monitoring – Road-surface conditions – Visual mapping – Commute optimization – Carpool finding – Speed trap mapping Opportunistic Mobility Rather than deploy new mobile nodes, take advantage of existing mobility Example: cellphones w/ sensors – 1.5 billion phones worldwide – High spatial coverage – High-performance processor Cars equipped with sensors – 650 million cars on the road – Abundance of power and space – Have >100 embedded sensors What system architecture is best suited for mobile, wide-area sensing? CarTel System Overview Visualize Portal Clients Data collection servers Int ernet Cabernet / QuickWifi Deliver (Carry & Forward Network) Per-node sensing & computation hardware Open Wi-Fi ICEDB Collect / Process (Intermittently Connected & Embedded DB) GPRS Roadmap Overview CarTel Components – Portal – IceDB – Cabernet Managing missing and uncertain data Case Studies – Traffic Analysis – WiFi Mapping – Potholes Portal Web-based visualization framework Apps retrieve sensor data by issuing queries to ICEDB Visualize sensor data using map overlays Continuous queries to direct sensing Web server Portal Applications Traffic Rel. DB ICEDB server – Pushed to remote nodes using Cabernet Local ad-hoc queries read streaming results Wi-Fi Portal Data Viz. CQ Cabernet Streaming sensor data Visualize / Analyze Cont. queries Data Collection Demo Visualize / Analyze ICEDB: Intermittently Connected Embedded DB Relational model is a convenient abstraction for data collection ICEDB: – – – Queries written in extended SQL Continuous query processor Distributed SELECT img FROM camera, gps WHERE gps.pos in [x,y] AND camera.time= gps.time SAMPLE 1s Bandwidth is variable 1. 2. 3. 4. Buffer query and DDL commands Buffer query results Support “drill down” queries Prioritize results Collect / Process ICEDB Query Processing Remote Node CQ queries Server Output Buffers results Ad-hoc Query ICEDB Remote DB Processor 2 data paths to cope with limited BW Collect / Process Cabernet A D A P sensor T E ICEDB R sensor S sensor Inter-query Prioritization Remote node Portal Portal Portal SELECT lat, lon FROM gps WHERE insert_time > cqtime – 5 EVERY 5 seconds BUFFER IN gpsbuf DELIVERY ORDER fifo(gpsbuf) FIFO t=1 t=2 t=3 BISECT Remote node Portal Portal Portal Collect / Process SELECT lat, lon FROM gps WHERE insert_time > cqtime – 5 EVERY 5 seconds BUFFER IN gpsbuf DELIVERY ORDER bisect(gpsbuf) Global Prioritization SELECT lat, lon, image FROM camera WHERE insert_time > cqtime – 5 EVERY 5 seconds BUFFER IN cambuf SUMMARIZE AS SELECT floor(lat/100), floor(lon/100) FROM cambuf GROUP BY floor(lat/100), floor(lon/100) to ICEDB Server to ICEDB Server Collect / Process Global Prioritization 1 1 2 2 2 1 ICEDB Server Collect / Process Specifying Priorities Three SQL language extensions: 1. Global prioritization: SUMMARIZE AS 2. Inter-query prioritization: PRIORITY 3. Intra-query prioritization: DELIVERY ORDER BY For more details: ICDE ’06 Collect / Process Cabernet Disconnection-tolerant transport layer Buffer data until connectivity becomes available QuickWifi – Not connection oriented QuickWifi: Fast connection establishment CTP: Unlike TCP, wireless losses ≠ congestion losses Jakob Eriksson et al – Mobicom 08 Deliver Challenge: Connection Establishment is Slow Process – – – – – – Scan 11 channels (600 ms average), receive beacon Authenticate (1 round trip, 3s timeout) Associate (1 round trip, 3s timeout) DHCP Discovery (1 round trip, 3s timeout) DHCP Request (1 round trip, 3s timeout) ARP Request (1 round trip, 2s timeout) Many messages, loss rates high, retries often needed Default Linux stack took 13s to associate, on average (whole connection lasts only 19s avg!) Deliver Connection Optimizations Scan more popular channels first (1,6,11) Since authentication in open networks always succeeds, do it in parallel with association Set timeouts to 100 ms Mean conn. time: 370 ms DHCP via broadcast addr Roadmap Overview CarTel Components – Portal – Cabernet – Cabernet Managing missing and uncertain data Case Studies – Traffic Analysis – WiFi Mapping – Potholes Noisy Data Challenge Challenge: how to store and query all of this data? Discrete points don’t work well Most apps don’t actually want raw data! – Prefer trajectories, fields, fit functions – Idea: support these as first class objects inside the DBMS Model-Based Views Proposed in MauveDB [SIGMOD 06] – Models can be queried like database views – Basic idea: • • • • compute model grid modeled area use model to compute values at each cell of grid answer queries using grid FunctionDB: efficient implementation for an important class of models – Continuous functions of one or more variables Benefits Declarative Queries – No need to write procedures to manipulate models, or re-implement or re-optimize each new query View provides intuitive SQL-like interface If data is already in database, do not need to move data to/from math package like MATLAB FunctionDB: Key Idea Database system that fits continuous functions to data MauveDB-like query Interface (SQL + Grids) Algebraic query processor temp Regression Function temp(t) Raw data (temp readings) Solve equation temp(t) = thresh Query: Report when temp crosses threshold SELECT time WHERE temp = thresh time FunctionDB: System Architecture User Query Query Result Algebraic Query Processor (Operates on algebraic representation) Raw Data X Y 1 1.1 3 3.1 4 3.9 … … User fits or imports functions “Function Table” (Storing Piecewise Model) Start End Slop e Intercep t 1 8 1 0 8 12 2 -8 Query Results • Grid semantics: all queries yield discrete points sampled at user-specified interval (“grid size”) SELECT x,y WHERE temp < 20 GRID x 8, y 8 temp < 20 8 8 Algebraic Execution: Overview • FunctionDB supports efficient algebraic execution for piecewise polynomial functions • Restriction helps achieve grid semantics even when no closed form solutions are available • E.g., Non-linear polynomials, multi-variate polynomials, complex constraints X^2 + Y^3 < 25 SELECT * WHERE Temp < 20 GRID X 8, Y 8 Efficient Algebraic Implementation Gridded Result X+Y < 20 User Hypercubes+Boundary Points Grid X+Y < 20 Approx X:[0,20) , Y:[0,20) , Temp = X+Y , X+Y-20 < 0 Substitute X:[0,20) , Y:[0,20) , Temp = X+Y , Temp < 20 Symbolic Filter (Temp < 20) X:[0,20) , Y:[0,20) , Temp = X+Y Function Table Temp = F(X,Y) Hypercube Approximation • Use technique from graphics rasterization (Taubin’s test) • Tests if polynomial F(X,Y, …) can have zeros within a given hypercube on boundary of H) ZeroHof(i.e., F F lies Z = F(X,Y) Y Z=0 X Hypercube H • Allows efficient pruning by testing corners of hypercube Subdivision Algorithm - Bounding Box Predicate + + + - Check centers of all grid cells smaller than grid size + + - More Algebraic Operators • Solver for single-variable equations • Function Inference • E.g., X+Y = 20 X = 20-Y • (Eliminates independent variables) • Continuous aggregates • E.g., Average Integration Evaluation: Temperature Data • Data: <Sensor ID, X, Y, time, temp> • 54 sensors, 10 days of data, 1 million raw data points • Fit regression model temp = F(X,Y,time) • Degree-2 piecewise polynomial with 22 pieces • Evaluation queries: • Find regions where temp < threshold (Filter) • Area of region where temp < threshold (Aggregate) • Compared algebraic approach to two baselines: • Evaluating all grid points • Pruning search using a precomputed B-Tree Result 1: Benefits Of Algebraic Execution Depend On Selectivity Wider grid size is faster, Result 2: Algebraic Execution Winsbut too a grid size results in low Significantly Forwide Aggregate Queries accuracy owing to discretization error Roadmap Overview CarTel Components – Portal – Cabernet – Cabernet Managing missing and uncertain data Case Studies – Traffic Analysis – WiFi Mapping – Potholes Route Planning Match traces to map Compute Gaussian delay for each segment – Assume independence Minimize 3 Objectives – Distance • Google Maps – Expected delay – Pr(missing time goal) Max. Probability Planning Travel time of each edge is a Gaussian – If indepdendent, travel time of a path is also Gaussian Goal: find path with max. probability of reaching destination by deadline Unlike standard shortest paths, no optimal substructure – If AxCyB is best path from A to B, AxC is not necessarily the best path from A to C Implies cannot use A* or Dijkstra 1 Lim et al. “Stochastic Motion Planning and 3 Applications to A C B Traffic.” To Appear, Workshop on Algorithmic Foundations of Robotics, 2008 2 WiFi As A Sensor Is WiFi feasible as an uplink from cars? – Study with taxis; 30,000 distinct APs Answer: – Significant connectivity “in the wild” • ~ 200 kB / minute • Even at normal driving speeds – Connections last about 20 seconds – See an access point about every 20 seconds! See MOBICOM 2006 Conclusion Mobile and participatory sensornets can sense at much higher scale over larger areas than static networks Applications: traffic, fleet management, automotive diagnostics, wireless network monitoring, civil/environmental monitoring, traffic planning,… CarTel technologies: Portal, IceDB, Cabernet/QuickWifi, FunctionDB Platform enabled research results: Pothole Patrol, Traffic, WiFi as Uplink For more info: http://cartel.csail.mit.edu