A Graphical Development and Simulation Environment for TinyOS-based Wireless Sensor Networks
description
Transcript of A Graphical Development and Simulation Environment for TinyOS-based Wireless Sensor Networks
A Graphical Development and Simulation Environment for TinyOS-based Wireless Sensor NetworksElaine Cheong
February 13, 2007Seventh Biennial Ptolemy MiniconferenceBerkeley, California
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
2
Wireless Sensor Networks
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
3
TinyOS and nesCconfiguration SenseToLeds {} implementation { components Main, SenseToInt, IntToLeds, TimerC, DemoSensorC as Sensor;
Main.StdControl -> SenseToInt; Main.StdControl -> IntToLeds;
SenseToInt.Timer -> TimerC.Timer[unique("Timer")];
SenseToInt.TimerControl -> TimerC;
SenseToInt.ADC -> Sensor;
SenseToInt.ADCControl -> Sensor;
SenseToInt.IntOutput -> IntToLeds;}
module SenseToInt { provides { interface StdControl; } uses { interface Timer; interface StdControl as TimerControl; interface ADC; interface StdControl as ADCControl; interface IntOutput; }} implementation { ...}
configuration TimerC { provides interface Timer[uint8_t id]; provides interface StdControl;} implementation { components TimerM, ClockC, NoLeds, HPLPowerManagementM; TimerM.Leds -> NoLeds; TimerM.Clock -> ClockC; TimerM.PowerManagement -> HPLPowerManagementM; StdControl = TimerM; Timer = TimerM;}
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
4
SenseToLeds in Viptos
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
5
Converting between nesC and MoML nc2moml
nesC component code MoML class (Ptolemy actor)
ncapp2moml nesC application code MoML entity (Ptolemy model)
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
6
Generating MoML for TimerC.nc – nc2moml
<?xml version="1.0"?><!DOCTYPE plot PUBLIC "-//UC Berkeley//DTD MoML 1//EN" "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">
<class name="TimerC" extends="ptolemy.domains.ptinyos.lib.NCComponent"> <property name="source" value="$CLASSPATH/tos/system/TimerC.nc" /> <port name="StdControl" class="ptolemy.actor.IOPort"> <property name="input" /> <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute" /> </port> <port name="Timer" class="ptolemy.actor.IOPort"> <property name="input" /> <property name="multiport" /> <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute" /> </port></class>
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
7
Generating MoML for SenseToLeds.nc – ncapp2moml...<entity name="MicaCompositeActor" class="ptolemy.domains.ptinyos.lib.MicaCompositeActor"> <entity name="Main" class="tos.system.Main" /> <entity name="TimerC" class="tos.system.TimerC" /> <entity name="SenseToInt" class="tos.lib.Counters.SenseToInt" /> <entity name="IntToLeds" class="tos.lib.Counters.IntToLeds" /> <entity name="DemoSensorC" class="tos.sensorboards.micasb.DemoSensorC" /> ... <link relation="relation1" port="Main.StdControl" /> <link port="IntToLeds.StdControl" relation="relation2" /> <link relation1="relation2" relation2="relation1" /> <link port="SenseToInt.StdControl" relation="relation3" /> <link relation1="relation3" relation2="relation1" /> <link relation="relation4" port="SenseToInt.Timer" /> <link port="TimerC.Timer" relation="relation5" /> <link relation1="relation5" relation2="relation4" /> ...</entity>...
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
8
SenseToLeds – Physical Environment
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
9
SenseToLeds – Hardware
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
10
SenseToLeds – Software
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
11
PtinyOSDirector
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
12
SenseToLeds – PhotoSource
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
13
SenseToLeds – PhotoChannel
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
14
SenseToLeds – WirelessDirector
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
15
SenseToLeds – Simulation
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
16
How it worksJava (PtinyOSDirector) Java (PtinyOSLoader) C (TOSSIM)
PtinyOSDirector.preinitialize() Generate nesC code, makefile, and PtinyOSLoader Java file. Run ‘make’.Compile nesC code to a TOSSIM shared object, and PtinyOSLoader Java file to a Java class file.
PtinyOSDirector.initialize() Load PtinyOSLoader Java class into memory.Create instance of PtinyOSLoader class (_loader).Call Java _loader.load().
_loader.load() Load the TOSSIM shared object into memory.
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
17
How it works (cont.)Java (PtinyOSDirector) Java (PtinyOSLoader) C (TOSSIM)
PtinyOSDirector.initialize(), continued Call Java _loader.main().
_loader.main() Call JNI main_unique_name() native method.
JNI main_unique_name() Call TOSSIM main(), which contains an initialization routine:
Call TOSSIM initializeSockets()Call TOSSIM ptII_startThreads()
Call JNI _loader.startThreads().
_loader.startThreads()Create Java threads.Call Java Thread.start() on each thread.
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
18
How it works (cont.)
Java (PtinyOSDirector) Java (PtinyOSLoader) C (TOSSIM)
TOSSIM main() initialization routine, continued Create bootup event.Call TOSSIM ptII_queue_insert_event().
Call JNI _loader.enqueueEvent().
_loader.enqueueEvent()Call Java PtinyOSDirector.enqueueEvent().
PtinyOSDirector.enqueueEvent() Call Java Ptolemy II fireAt() on the executive director.
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
19
SendAndReceiveCnt
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
20
SendAndReceiveCnt
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
21
SendAndReceiveCnt
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
22
SendAndReceiveCnt – Simulation
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
23
Multihop Routing – Surge
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
24
Performance Evaluation – SenseToLeds
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
25
Performance Evaluation – SendAndReceiveCnt
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
26
Related Work
ns-2 OPNET Modeler, OPNET Wireless Module OMNeT++, NesCT J-Sim Prowler Em*, EmTOS TOSSIM, TinyViz
February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
27
Conclusion
http://ptolemy.eecs.berkeley.edu/viptos
Elaine Cheong, Edward A. Lee and Yang Zhao. “Joint Modeling and Design of Wireless Networks and Sensor Node Software”, EECS Department, University of California, Berkeley, Technical Report No. UCB/EECS-2006-150, November 17, 2006.