programming abstractions in wireless sensor networks
DESCRIPTION
Programming Abstractions in Wireless Sensor Networks. Professor Jack Stankovic Department of Computer Science University of Virginia. Importance. Raise the level of abstraction Move out of the domain of HW and embedded systems programmer - PowerPoint PPT PresentationTRANSCRIPT
Programming Abstractionsin
Wireless Sensor Networks
Professor Jack StankovicDepartment of Computer
ScienceUniversity of Virginia
ImportanceImportance
• Raise the level of abstraction• Move out of the domain of HW and
embedded systems programmer• Amplify the applications addressed –
programmed by domain experts• More reliable
• One of the most important areas of research to make WSN widely used
ContextContext
System DevelopmentEnvironment
Analysis/Tools
Use of SystemSQL/Queries
Actual ProgrammingApplications prog.
Systems prog.
Programming Models (9)
Programming Models (9)• Environmental (domain specific ->
tracking, monitoring environment, medical…)– EnviroSuite
• Data/Database Centric - Queries– SQL, TinyBD, Cougar– Statistical and range queries
• Middleware APIs and Services– Group Management, Token machine language
(Regiment), Milan (QoS based), Agilla– Support for other models
• Components• Database• Event • Agent
Programming Models (9)
Programming Models (9)
• Components– nesC
• Virtual Machines– Mate
• Functional Macro-programming– Regiment (regions, streams)
• (Mobile) Scripts– SensorWare
• Extend TCL interpreter with support for commands such as query, send, wait, replicate, …
• Provides execution environment for Scripts
• Events– Publish/subscribe– DSWare, SNEDL, Impala
Programming Models (9)
Programming Models (9)
• Networks of Networks– Across the Internet
AbstractionsAbstractions
• Program as a whole – not individual nodes
• Hide details (which ones, expose what)– Single node decisions– Asynchrony– Race conditions– False alarms– Retries– Physical details (e.g., location, sensor characteristics,
…)– Faults– Scale– Storage locations
Environmental Paradigm
Environmental Paradigm
• Current Paradigms– Single node abstractions– Explicit interactions between nodes– Read sensor data; fuse data; move data– Set actuators
• Environmental Paradigm– Reflect the physical world directly– Virtual world of entities (fire, people, vehicles,
pesticide, velocity, location, areas, …)
EnviroSuiteEnviroSuite
• Way to think– Events – measurable environmental activities– Events mapped to programming objects– Computation is attached to these objects
• Report location, compute velocity, …
• Library provides protocols for sensor data processing, object maintenance, inter-object coordination, aggregation mechanisms, etc.
personevent
Base Station
vehicleevent
object type: VEHICLE object ID: vehicle01
method:report location to thebase station every 5seconds
attribute: location
object type: PERSON object ID: person01
method:turn on a nearby micro-phone if current locationis less than 1 mile awayfrom the base station
attribute: location
mapping
EnviroSuite
EnviroSuiteEnviroSuite
event-object VEHICLE { object_creation_condition = ferrous object && background sound object_resolution = 6; // minimal distance between // two events object_function = report.Location; object_function = report.Speed;}
ferrous object && background sound
This statement is supported by drivers in a library:
Level of Knowledge Required
Level of Knowledge Required
• Ferrous object– Which signal processing module?– What parameter specifications need to
be made?
– We are programming in an application that interacts with the environment – how divorced from that fact can the programmer be?
Programming ModelProgramming Model
TrackingObjects
Context Type: CarContext Label
Aggregate State
Variables
TrackingObjects
Context Type: PersonContext Label
Aggregate State
Variables
Network Abstraction Layer
ExternalEntity
Contexts and ObjectsContexts and Objects
• Contexts: Encapsulate entity state and tracking objects
• Tracking objects: Perform entity-specific computation, communication and sensing
HistoryEntity
ID
State
ContextAttached Tracking Objects
Programmer’sView
CommunicationCommunication
State
Context
Programmer’sView
Context
Attached Tracking Objects
Attached Tracking Objects
Objects may export methods for remote invocation
Attaching ObjectsAttaching Objects
HistoryEntity
ID
Programmer’sView
Sensee( ) = TRUELeader
Members
Statee( ) = average position
begin context tracker sense: magnetic() + motion(); state: location = avg (position,3,2);end
begin object reporter send (state, home);end
Attach
begin object mic turn-on microphone send (sound, home);end
SummarySummary
• Program in C++ or Java – like language
• Library supports domain specific abstractions– E.g., Java Swing supports programming
GUIs
• Pre-compiler maps programming abstractions to underlying “system”– E.g., could map to nesC and TinyOS
MiddlewareMiddleware
Middleware APIsMiddleware APIs
• Group Management– Create– Terminate– Merge– Join/Leave– Assign function
• Track target• Classify target• Map temperature region
– Consensus
Group ManagementGroup Management
IR Camera
Group ManagementGroup Management
IR Camera
Examples: Tracking and
Map Regions
Examples: Tracking and
Map Regions
Base Station
Group Management - APIGroup Management - API
– Create_Group(name,function,criterion,atleast,accuracy) - implicit and explicit
– Destroy_Group(name)– Join()– Leave()– Merge()– Move_COG()– Expand() -- to gain sensing confidence– Shrink() -- to save power– Commit(grp_ID) - to synchronize group re-
configurations
API for Other ServicesAPI for Other Services
• Naming• Directory• Location• Monitor• Configure• …
Virtual Machine - Mate Virtual Machine - Mate
TinyOS
Mate VM(interprets)
24 Instruction ProgramsEach instructionexecutes as task(slow)
Code capsules
Code CapsulesCode Capsules
• One capsule = 24 instructions• Fits into single TOS packet
– Energy efficient
• Atomic reception• Code Capsule
– Type and version information– Types: send, receive, timer, subroutine
• Larger programs – use several capsules
ValueValue
• Re-programmability– Re-task a network
• Parameter adjustment
• Self-replication– One of the special instructions on the
VM is forward (which supports a viral-like infection of the entire network)
• Incremental addition of new nodes
Propagation ExamplePropagation Example
Node Enters the NetworkNode Enters the Network
Instruction SetInstruction Set
One byte per instruction Three classes: basic, s-type, x-type
•basic: arithmetic, halting, LED operation•s-type: messaging system•x-type: pushc, blez
8 instructions reserved for users to define Instruction polymorphism
•Example: add(data, message, sensing)
User Defined Instructions User Defined Instructions
TinyOS
Mate VM(interprets)
24 Instruction Programs
Code capsules InstructionsUnderstood byMate
User defined
1 2 3 4
1 3
3
1
- Sound alarm
- Write to flash
Mate ArchitectureMate Architecture
0 1 2 3
Subroutines
Clock
Send
Receive
Events
gets/sets
0 1 2 3
Subroutines
Clock
Send
Receive
Events
gets/sets
Code
OperandStack
ReturnStack
PC
Code
OperandStack
ReturnStack
PC
Stack based architecture Operand stack Return address stack
Three events/execution contexts:•Clock timer•Message reception•Message send
Code Example(1)Code Example(1)
• Display Counter to LEDgets # Push heap variable on stackpushc 1 # Push 1 on stackadd # Pop twice, add, push resultcopy # Copy top of stacksets # Pop, set heappushc 7 # Push 0x0007 onto stackand # Take bottom 3 bits of valueputled # Pop, set LEDs to bit patternhalt #
Code Example(2)Code Example(2)
• Sense and Sendpushc 1 # Light is sensor 1sense # Push light reading on stackpushm # Push message buffer on stackclear # Clear message bufferadd # Append reading to buffersend # Send message using built-inhalt # ad-hoc routing system
TinyOS Sense and Send
TinyOS Sense and Sendevent result_t Timer.fired() {
if (state == IDLE && call Photo.sense()) {state = SENSE;}return SUCCESS;
}event result_t Photo.dataReady(uint16_t data) {
if (state == SENSE) {packet->reading = data;if (call SendMsg.send(packet, sizeof(DataBuf)) {
state = SENDING;} else {state = IDLE;}
}return SUCCESS;
}event result_t SendMsg.sendDone(TOS_MsgPtr msg) {
if (state == SENDING) {state = IDLE;}return SUCCESS;
}
Component BreakdownComponent Breakdown
• 7286 bytes code, 603 bytes RAM
SummarySummary
• Layer of software that can interpret programs
• Easy to download new programs• Power of VM will relate to ease of
programming– E.g., Java versus Mate
Networks of NetworksNetworks of Networks
BodyNetworks
Road and Street Networks
Battlefield Networks
VehicleNetworks
IndustrialNetworks
BuildingNetworks
Environmental Networks Heterogeneous
Networks withSensors and Actuators
(HNSAs)
Motivating ApplicationsMotivating Applications
Home
Home Application 1:Musical TrackingHome Application 2:
Alarm System
Motivating ApplicationsMotivating Applications
HomeForest
Forest Application 1:Temperature MonitoringForest Application 2:
Animal Tracking
Motivating ApplicationsMotivating Applications
Road
HomeForest
MESSAGE
Road Application 1:Traffic MonitoringRoad Application 2:
Traffic Law Enforcement
Motivating ApplicationsMotivating Applications
Road
HomeForest
Cross Network Application 1:Protection Against Wild Animals
Motivating ApplicationsMotivating Applications
Road
HomeForest
MESSAGECross Network Application 2:Wild Animal & Automobile Protection
System ArchitectureSystem Architecture
Internet
LocalTransportProtocol
LocalTransportProtocol
ProgrammingStation
Server Server
Nodes Nodes
System ArchitectureSystem Architecture
Internet
LocalTransportProtocol
LocalTransportProtocol
ProgrammingStation
Server Server
Nodes NodesInformation about
Services, InterfacesLocation
System ArchitectureSystem Architecture
Internet
ProgrammingStation
Server Server
Nodes Nodes
LocalTransportProtocol
LocalTransportProtocol
High levelProgramming
Language
EXE
High LevelVirtual Machine
High LevelVirtual Machine
Low LevelVirtual Machine
Low LevelVirtual Machine
System ArchitectureSystem Architecture
Internet
LocalTransportProtocol
LocalTransportProtocol
ProgrammingStation
Server Server
Nodes Nodes
Responsible forResource management
User access rights
System ArchitectureSystem Architecture
Internet
LocalTransportProtocol
LocalTransportProtocol
ProgrammingStation
Server Server
Nodes Nodes
Omnix PhysicalNetwork
Omnix PhysicalNetwork
The Physicalnet
SummarySummary
• Future Problem• Java-like language with different
levels of VMs
QuestionsQuestions
• What should a programmer see?– New language– New middleware– Services– Components– Abstract models– All the above– None of the above
QuestionsQuestions
• What would have made your life easier in doing the programming assignments?
• What makes it easier to get the system to work?– Debugging tools
• Initially (in programming environment)• On real platform
SummarySummary
• Very active area– It must be
• Solutions can have large impact– Applications programmers rather than
system experts
• Standard?– Analogy to real-time computing and
programming languages?• WSN-Java?