Example Application: Surge LEPSM
Algorithmic strategy
A neighbor table is maintained to track link history and
relationship to
nodes within radio range. Information in the table is based on
what
we receive from the node.
Similar information is maintained about our routing parent
based on
acks/nacks on messages sent to the parent.
Link estimation technique is an EWMA of windowed average
success rates.
For neighbors, on packet arrival we can calculate the number
of missing
packets based on the seq. no. difference. We also assume that
we should
receive a packet from each neighbor in each interval, which is
a small
multiple of the basic timer interval. If not, we accumulate a
timeout
count. A multiple of the timeout count is taken as an estimate
of the
number of losses since last received packet.
For parent estimation, the ack associated with each packet is
used to
feed the average.
#include "gen/cSurge_TinyOSModule.h" #include "gen/cSurge_Main.h" cSurge_Main *m = new cSurge_Main(this,main,"Main",getIndex()); m->StdControl_init(); m->StdControl_start(); |
NesCT is going to build all the classes in gen directory.
Replace "cp" with "copy" and slash (/) with backslash (\) for
windows operating system at the following instructions.
[root@sinan tictoc]# cd components/
[root@sinan components]# cp Surge.nc ../Application.nc
[root@sinan components]# cd ..
[root@sinan tictoc]# ./nesct.exe Application.nc
done.
Type makemake.bat/makemake.sh to create new Makefile for Win32/Linux.Type "make" to build the binary.
[root@sinan tictoc]# make
g++ -c -g -fpermissive -fPIC -DWITH_NETBUILDER -w
-DTOSNODES=1000 -DLINUX -DPLATFORM_OMNETPP -I./include
-I/root/projects/tinyos-1.x/tos/interfaces -I./include_tos
-I/opt/omnetpp-3.2/include simstart.cc
g++ tictoc1_n.o debug.o simstart.o tinyos.o tinyosmain.o
tossim.o txc1.o -g -L/opt/omnetpp-3.2/lib -lenvir -lcmdenv
-lsim_std -lnedxml -lxml2 -ldl -lstdc++ -lpthread -o tictoc
echo>.tstamp
Edit omnetpp.ini file and change wait-for-sf to true. After enabling this option, the simulation will wait 10 seconds before starting to allow sf to connect.
Start SerialForwarder by running ./bin/sf_sim . For windows,
you may need to enter the contents of the file yourself in a
console windows (cygwin). The exceptions will be lost once we
start the simulator.
[root@sinan tictoc]# ./bin/sf_sim
Listening to tossim-serial
SF enabled, 0 clients, 0 packets read, 0 packets written
getenv JNI library not found. Env.getenv will not work
(please consult installation directions in
tinyos-1.x/tools/java/net/tinyos/util/Env.INSTALL)
Platform avrmote
Opening tossim-serial source
Connecting to Tossim event port at localhost:10585
Listening for client connections on port 9001
SF enabled, 0 clients, 0 packets read, 0 packets written
java.net.ConnectException: Connection refused
To complicate things, let's use another topology file in ned
directory.
[root@sinan tictoc]# cd ned
[root@sinan ned]# cp surge.ned ../bin/tictoc1.ned
Start Surge java tool.
[root@sinan tictoc]# java net.tinyos.surge.MainClass 125
This time I'll set only route debug environment variable. Use
"export" keyword for linux and "set" keyword for windows to
change environment variable. You should see an output similar
to this in TK window.
Run tictoc. The simulation screen should like this.
[root@sinan tictoc]# export DBG=route
[root@sinan tictoc]# ./tictoc
0:0:2.10000000: MultiHopLEPSM timer task.
0:0:2.10000000: addr prnt misd rcvd lstS hop rEst sEst
0:0:2.10000000: MultiHopLEPSM Sending route update msg.
0:0:2.10000000: MultiHopLEPSM timer task.
0:0:2.10000000: addr prnt misd rcvd lstS hop rEst sEst
0:0:2.10000000: MultiHopLEPSM Sending route update msg.
0:0:2.10000000: QueuedSend: queue msg enq 0 deq 0
0:0:2.10000000: QueuedSend: Successfully queued msg to 0xffff,
enq 1, deq 0
0:0:2.10000000: QueuedSend: queue msg enq 0 deq 0
0:0:2.10000000: QueuedSend: Successfully queued msg to 0xffff,
enq 1, deq
If you notice, the event take too much of time in the TK
window, one way of speeding up the simulation is to build the
simulation for command environment. Go back to tictoc
directory. Edit your makefile and change the definition of
USER_IFLIBS from TK to CMD. Use # for making a line comment.
Then make again. Copy and run tictoc again.
[root@sinan tictoc]# make
[root@sinan tictoc]# cp tictoc bin
[root@sinan tictoc]# cd bin
[root@sinan bin]# ./tictoc
Wait for a while. Route discovery in Surge takes a while.
Results will not come before 2 simulation minutes.