A Graphical Development and Simulation Environment for Tiny



























- Slides: 27
A Graphical Development and Simulation Environment for Tiny. OS-based Wireless Sensor Networks Elaine Cheong February 13, 2007 Seventh Biennial Ptolemy Miniconference Berkeley, California February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference
Wireless Sensor Networks February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 2
Tiny. OS and nes. C configuration Sense. To. Leds { } implementation { components Main, Sense. To. Int, Int. To. Leds, Timer. C, Demo. Sensor. C as Sensor; Main. Std. Control -> Sense. To. Int; Main. Std. Control -> Int. To. Leds; Sense. To. Int. Timer -> Timer. C. Timer[unique("Timer")]; Sense. To. Int. Timer. Control -> Timer. C; Sense. To. Int. ADC -> Sensor; Sense. To. Int. ADCControl -> Sensor; Sense. To. Int. Output -> Int. To. Leds; } February 13, 2007 module Sense. To. Int { provides { interface Std. Control; } uses { interface Timer; interface Std. Control as Timer. Control; interface ADC; interface Std. Control as ADCControl; interface Int. Output; } } implementation {. . . } configuration Timer. C { provides interface Timer[uint 8_t id]; provides interface Std. Control; } implementation { components Timer. M, Clock. C, No. Leds, HPLPower. Management. M; Timer. M. Leds -> No. Leds; Timer. M. Clock -> Clock. C; Timer. M. Power. Management -> HPLPower. Management. M; Std. Control = Timer. M; Timer = Timer. M; } Elaine Cheong, UC Berkeley, Ptolemy Miniconference 3
Sense. To. Leds in Viptos February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 4
Converting between nes. C and Mo. ML n nc 2 moml q n nes. C component code Mo. ML class (Ptolemy actor) ncapp 2 moml q nes. C application code Mo. ML entity (Ptolemy model) February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 5
Generating Mo. ML for Timer. C. nc – nc 2 moml <? xml version="1. 0"? > <!DOCTYPE plot PUBLIC "-//UC Berkeley//DTD Mo. ML 1//EN" "http: //ptolemy. eecs. berkeley. edu/xml/dtd/Mo. ML_1. dtd"> <class name="Timer. C" extends="ptolemy. domains. ptinyos. lib. NCComponent"> <property name="source" value="$CLASSPATH/tos/system/Timer. C. nc" /> <port name="Std. Control" class="ptolemy. actor. IOPort"> <property name="input" /> <property name="_show. Name" class="ptolemy. kernel. util. Singleton. Attribute" /> </port> <port name="Timer" class="ptolemy. actor. IOPort"> <property name="input" /> <property name="multiport" /> <property name="_show. Name" class="ptolemy. kernel. util. Singleton. Attribute" /> </port> </class> February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 6
Generating Mo. ML for Sense. To. Leds. nc – ncapp 2 moml. . . <entity name="Mica. Composite. Actor" class="ptolemy. domains. ptinyos. lib. Mica. Composite. Actor"> <entity name="Main" class="tos. system. Main" /> <entity name="Timer. C" class="tos. system. Timer. C" /> <entity name="Sense. To. Int" class="tos. lib. Counters. Sense. To. Int" /> <entity name="Int. To. Leds" class="tos. lib. Counters. Int. To. Leds" /> <entity name="Demo. Sensor. C" class="tos. sensorboards. micasb. Demo. Sensor. C" />. . . <link relation="relation 1" port="Main. Std. Control" /> <link port="Int. To. Leds. Std. Control" relation="relation 2" /> <link relation 1="relation 2" relation 2="relation 1" /> <link port="Sense. To. Int. Std. Control" relation="relation 3" /> <link relation 1="relation 3" relation 2="relation 1" /> <link relation="relation 4" port="Sense. To. Int. Timer" /> <link port="Timer. C. Timer" relation="relation 5" /> <link relation 1="relation 5" relation 2="relation 4" />. . . </entity>. . . February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 7
Sense. To. Leds – Physical Environment February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 8
Sense. To. Leds – Hardware February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 9
Sense. To. Leds – Software February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 10
Ptiny. OSDirector February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 11
Sense. To. Leds – Photo. Source February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 12
Sense. To. Leds – Photo. Channel February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 13
Sense. To. Leds – Wireless. Director February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 14
Sense. To. Leds – Simulation February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 15
How it works Java (Ptiny. OSDirector) Java (Ptiny. OSLoader) C (TOSSIM) Ptiny. OSDirector. preinitialize() n. Generate nes. C code, makefile, and Ptiny. OSLoader Java file. n. Run ‘make’. n. Compile nes. C code to a TOSSIM shared object, and Ptiny. OSLoader Java file to a Java class file. Ptiny. OSDirector. initialize() n. Load Ptiny. OSLoader Java class into memory. n. Create instance of Ptiny. OSLoader class (_loader). n. Call Java _loader. load() n. Load the TOSSIM shared object into memory. February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 16
How it works (cont. ) Java (Ptiny. OSDirector) Java (Ptiny. OSLoader) C (TOSSIM) Ptiny. OSDirector. initialize(), continued n. Call Java _loader. main() n. Call JNI main_unique_name() native method. JNI main_unique_name() n. Call TOSSIM main(), which contains an initialization routine: q. Call TOSSIM initialize. Sockets() n. Call TOSSIM pt. II_start. Threads() q. Call JNI _loader. start. Threads() n. Create Java threads. n. Call Java Thread. start() on each thread. February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 17
How it works (cont. ) Java (Ptiny. OSDirector) Java (Ptiny. OSLoader) C (TOSSIM) TOSSIM main() initialization routine, continued n. Create bootup event. n. Call TOSSIM pt. II_queue_insert_event(). q Call JNI _loader. enqueue. Event() n. Call Java Ptiny. OSDirector. enqueue. Event() n. Call Java Ptolemy II fire. At() on the executive director. February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 18
Send. And. Receive. Cnt February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 19
Send. And. Receive. Cnt February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 20
Send. And. Receive. Cnt February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 21
Send. And. Receive. Cnt – Simulation February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 22
Multihop Routing – Surge February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 23
Performance Evaluation – Sense. To. Leds February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 24
Performance Evaluation – Send. And. Receive. Cnt February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 25
Related Work n n n ns-2 OPNET Modeler, OPNET Wireless Module OMNe. T++, Nes. CT J-Sim Prowler Em*, Em. TOSSIM, Tiny. Viz February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 26
Conclusion n http: //ptolemy. eecs. berkeley. edu/viptos n 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. February 13, 2007 Elaine Cheong, UC Berkeley, Ptolemy Miniconference 27