Académique Documents
Professionnel Documents
Culture Documents
Sensor Networks
Matt Welsh
Harvard University
Division of Engineering and Applied Sciences
mdw@eecs.harvard.edu
WeC (1999)
Ren (2000)
DOT (2001)
MICA (2002)
Matt Welsh, Harvard University
Speck (2003)
2
Outline
Sensor network applications and challenges
nesC: A component-oriented dialect of C for embedded systems
nesC concurrency model and static race detection
Macroprogramming: High-level programming for entire sensor nets
Abstract regions: A communication primitive for macroprogramming
Application examples and evaluation
Conclusion
Typical applications
Object tracking
Sensors take magentometer readings, locate object using centroid of readings
Communicate using geographic routing to base station
Robust against node and link failures
TinyOS
Very small operating system for sensor networks
Core OS requires 396 bytes of memory
Component-oriented architecture
Set of reusable system components: sensing, communication, timers, etc.
No binary kernel - build app specific OS from components
Split-phase operations
No blocking operations
Long-latency ops (sensing, comm, etc.) are split phase
Request to execute an operation returns immediatety
Event signals completion of operation
Important restrictions
No function pointers (makes whole-program analysis difficult)
No dynamic memory allocation
No dynamic component instantiation/destruction
. These static requirements enable analysis and optimization
nesC interfaces
nesC interfaces are bidirectional
Command: Function call from one component requesting service from another
Event: Function call indicating completion of service by a component
Grouping commands/events together makes inter-component protocols clear
interface Timer {
command result_t start(char type, uint32_t interval);
command result_t stop();
event result_t fired();
}
interface SendMsg {
command result_t send(TOS_Msg *msg, uint16_t length);
event result_t sendDone(TOS_Msg *msg, result_t success);
}
10
nesC components
Two types of components
Modules contain implementation code
Configurations wire other components together
An application is defined with a single top-level configuration
module TimerM {
provides {
interface StdControl;
interface Timer;
}
uses interface Clock;
StdControl
Timer
TimerM
Clock
} implementation {
command result_t Timer.start(char type, uint32_t interval) { ... }
command result_t Timer.stop() { ... }
event void Clock.tick() { ... }
}
11
Configuration example
Allow aggregation of components into supercomponents
StdControl
configuration TimerC {
provides {
interface StdControl;
interface Timer;
}
StdControl
Timer
Timer
TimerM
Clock
Clock
} implementation {
HWClock
TimerC
12
Concurrency model
Tasks used as deferred computation mechanism
// Signaled by interrupt handler
event void Receive.receiveMsg(TOS_Msg *msg) {
if (recv_task_busy) {
return; // Drop!
}
recv_task_busy = TRUE;
curmsg = msg;
post recv_task();
}
task void recv_task() {
// Process curmsg ...
recv_task_busy = FALSE;
}
Commands and events cannot block
Tasks run to completion, scheduled non-preemptively
Scheduler may be FIFO, EDF, etc.
13
14
Size
optimized unoptimized
396
646
1081
1091
11415
19181
14794
20645
23525
37195
23741
25907
63726
71269
Reduction
41%
1%
40%
22%
36%
8%
10%
Cycles
Work
Boundary crossing
Total
optimized
371
109
480
unoptimized
520
258
778
Reduction
29%
57%
38%
Inlining and dead code elimination saves both space and time
Elimination of module crossing code (function calls)
Cross-module optimization, e.g., common subexpression elim
15
Macroprogramming
How do you program a system composed of a large number of
distributed, volatile, error-prone systems?
Initial focus is on sensor networks
Approach applies to many other domains:
Distributed systems, protocol design, and P2P to name a few
16
Macroprogramming goals
Develop a set of communication and coordination primitives
Goals somewhat akin to MPI
Abstract the details of underlying communication
Provide enough structure to permit optimizations
17
18
19
Contour finding
20
180
160
0.9
140
0.8
0.7
120
0.6
100
0.5
80
0.4
60
0.3
40
0.2
20
0
Yield
0.1
4
5
6
Retransmit count
10
21
Adaptive Reduction
12
11
10
0.9
0.8
0.7
8
7
0.6
0.5
0.4
Yield
Retransmission count
0.3
0.2
2
1
0.1
0.2
0.3
0.4
0.5
0.6
Target yield
0.7
0.8
0.9
22
Mean error
Fraction of crossed edges
0.6
0.4
0.55
Error, feet
0.5
0.3
0.45
0.4
0.2
0.35
0.3
0.1
0.65
0.25
0.2
4
5
6
7
Number of broadcasts
10
23
0.7
200
175
150
0.6
125
Error, feet
0.8
100
75
0.5
50
25
0
8
10
12
Size of k-nearest neighborhood
14
16
0.4
24
Future Work
Ongoing work on abstract regions
Generic region constructors
. Supply membership primtive and communication strategy
Feedback control for tuning resource usage for desired loss level or energy budget
Exploirng language design based on region primitive
25
Conclusion
Sensor networks raise a number of programming challenges
Much more restrictive than typical embedded systems
Reactive, concurrent programming model
26