CrimeSPOT: Language Support for Programming Interactions among Wireless Sensor Network Nodes
1. Coen De Roover Christophe Scholliers
Wouter Amerijckx
Software Languages Lab, Brussels Theo D’Hondt
Wolfgang De Meuter
CrimeSPOT: Language Support for
Programming Interactions among
Wireless Sensor Network Nodes
2. Context
... active WSN applications
event handlers
enabled by event-driven middleware
composed
cannot be
task nodes with sensing & reacting
routes events over a decentralized event bus
invokes event handler of individual nodes
dispatching, storing, matching
specific to WSN applications
error-prone and lead to
ad-hoc solutions are
events carry sensor readings
code duplication
expiration, subsumption
specific to active WSN applications
reactions might no longer be warranted
compensation
3. Motivating Example
... problems associated with event-based programming
Tent C
Tent B
Tent A
Component:
subscribed to single event
TemperatureSensor
Component:
HumiditySensor
Component:
receiveEvent(Event e) {
online
HeatingController // invoke application logic
online // publish new event
humidityReading
temperatureReading online
}
adjustHeating
difficult to compose event handlers
Decentralized Event Bus
online
adjustHeating
humidityReading subscribed to multiple events
temperatureReading
dispatch over received events
Component:
store received events
ComfortLevelMonitor
relate new and stored events through matching
4. Motivating Example
... problems inherent to active WSN applications
Tent C
Tent B
Tent A
Component:
compensate reactions
Component: TemperatureSensor
HumiditySensor
Component:
if no longer warranted
HeatingController
online
online
temperatureReading online
humidityReading
adjustHeating
events carry sensor readings
Decentralized Event Bus
online readings expire at different rates
humidityReading
adjustHeating
readings subsume previous readings
temperatureReading
application-specific!
Component:
ComfortLevelMonitor
e.g., a new reading subsumes
older from same tent
5. CrimeSPOT in a Nutshell
... a domain-specific language for programming active
WSN applications on top of event-based middleware
minimize accidental complexity so developers can
focus on essential complexity
node-centric perspective
CrimeSPOT
specify interactions declaratively through rules
network-centric perspective
specify which rules govern which nodes
reuse rules within and among WSN apps
tailored towards active WSN applications
readings: polling intervals, expiration, subsumption
reactions: tracked so that they can be compensated
6. The CrimeSPOT runtime
... architectural overview
Node-specific Application Logic
CrimeSPOT runtime
inference engine
Inference Layer
Fact Inference Rule
evaluates rules against facts
Base Engine Base
Reification Layer
reification engine
Reification Configuration
Engine Base reifies events as facts
Infrastructure Layer
Middleware Bridge
Middleware Bridge middleware bridge
Event-based Middleware
WSN Node
7. Problem: composability of event handlers
... overcome through interaction rules
fact in fact base: FUNCTOR(ATTRIBUTES)@[METADATA]
requestForTemperature()@[from(MAC=1234:1234:1234:1234),
factExpires(Seconds=600)]
rules in rule base: HEAD ← BODY
temperatureReading(Celcius=?c)@[to(MAC=?mac)]
← requestForTemperature()@[from(MAC=?mac)],
?c is this.getTemperature()
humidityReading(Percent=?p)@[to(MAC=*),factExpires(Seconds=600)]
← ?p is this.getHumidity()@[renewEvery(Seconds = 600)]
8. Problem: events readings in WSN apps
... overcome through configurable reification engine
control effect of event on fact base
e.g., a new humidity reading subsumes older from same tent
incoming humidityReading(Percent=?new)@[from(MAC=?mac)]
subsumes humidityReading(Percent=?old)@[from(MAC=?othermac)]
provided online(Tent=?tent)@[from(MAC=?mac)],
online(Tent=?tent)@[from(MAC=?othermac)]
9. Problem: unwarranted reactions in active WSN apps
... overcome by distributed causality tracking
which conclusions no longer hold when a
fact is removed from the fact base?
this.adjustHeater
← adjustHeating(Level=?h)
class HeatingController
private CSAction adjustHeater = new CSAction() {
public void activated(CSVariableBindings bindings) { //adjust heating }
public void deactivate(CSVariableBindings bindings) { //reset heating }
};
}
10. Problem: no view of application as a whole
... overcome through quantified code blocks
control which code
governs which node
e.g., tent-related code shared by all nodes
*{
online(Tent=?tnt)@[to(MAC=*),factExpires(Seconds=3600)]
← ?tnt is this.getTentBasedOnGPSReading()@[renewEvery(Seconds=3600)].
}
*.java {
private CSValue getTentBasedOnGPSReading() { return ... }
}
11. Problem: reusing code within and among WSN apps
... overcome through macro definition and application
ComfortLevelMonitor {
subsumesOlderFromSameTent(humidityReading,Percent).
subsumesOlderFromSameTent(temperatureReading,Celsius).
}
* { defmacro subsumesOlderFromSameTent($reading,$type):
incoming $reading($type =?new)@[from(MAC=?mac)]
subsumes $reading($type =?old)@[from(MAC=?othermac)]
provided online(Tent=?tent)@[from(MAC=?mac)],
online(Tent=?tent)@[from(MAC=?othermac)]
}
14. Evaluation
... using CrimeSPOT on top of LooCI on SunSPOT motes
+-55 lines of code for motivating example
LooCI event-based middleware: component deployment, wiring
event routing, service discovery
CrimeSPOT: event dispatching, storage, matching
expiration, subsumption, causality, exceptions
validated expressiveness using several representative WSN applications
temperature monitoring, fire detection, flood monitoring, range coverage
very concise implementations
overhead
∆ROM: +460kB ∆RAM: 3kB / fact, 30kB / worst-case rule with 6 conditions
latency: 80ms (fact assertion), 140ms (rule activation assertion)
reasonable price to pay for software engineering benefits
15. Conclusions
... and future work
domain-specific language for programming active WSN apps
minimizes accidental complexity so developer can focus on essential complexity
node-centric: declarative rules specify interactions
network-centric: which rules govern which components
domain-specific: specify handling of events that carry sensor readings
specify compensations for reactions
future work
offer developers fine-grained control over causality tracking, rule activation precedence, ..
support n-hop neighborhoods, have a fact change at each hop
analyze node interactions w.r.t. network and memory usage
explicit in CrimeSPOT code: expirations, intervals