EWsnSim Integration

We will use EYES WSN framework (EWSNSIM)'s MAC layer and mobility mechanisms in this simulation. Download EYES WSN framework from here first. Then, download tos_examples_with_ewsnsim package from download section. If you want your TinyOS nodes to use EWSNSIM for other examples, you can use this package instead of nesct_tos_examples package.

Extract simulation framework package. It is going to create a directory named simfw_PACKAGE_DATE possibly in your src directory.

[root@sinan src]# tar zxvf simfw171105.tgz

Extract nesct_tos_examples_with_ewsnsim package.

[root@sinan src]# tar zxvf nesct_tos_example_with_ewsnsim_171105.tar.gz

Copy contents of ewsnsim directory to your simfw directory.

[root@sinan src]# cd ewsnsim/
[root@sinan ewsnsim]# cp -r * ../simfw171105

Enter simfw directory.

[root@sinan ewsnsim]# cd ..
[root@sinan src]# cd simfw171105/

Remove dbg.h and dbg_modes.h in your simfw directory.

[root@sinan simfw171105]# rm dbg.h dbg_modes.h
 

 

  1. Node Configuration

#include "gen/cRfmToLeds_TinyOSModule.h"
#include "gen/cRfmToLeds_Main.h"
#include "gen/cCntToLedsAndRfm_TinyOSModule.h"
#include "gen/cCntToLedsAndRfm_Main.h"

if (getIndex() == 0)
{
   cCntToLedsAndRfm_Main *m = new cCntToLedsAndRfm_Main(this,main,"Main",getIndex());
   m->StdControl_init();
   m->StdControl_start();
}
else
{
   cRfmToLeds_Main *m = new cRfmToLeds_Main(this,main,"Main",getIndex());
   m->StdControl_init();
   m->StdControl_start();
}

Code Generation

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 simfw171105]# cd components
[root@sinan components]# cp CntToLedsAnRfm.nc ../Application.nc
[root@sinan components]# cd ..
[root@sinan simfw171105]# ./nesct.exe Application.nc

Enter components directory again:
[root@sinan components]# cp RfmToLeds.nc ../Application.nc
[root@sinan components]# cd ..
[root@sinan simfw171105]# ./nesct.exe Application.nc
 

 

Updating Makefile

  Type makemake.bat/makemake.sh to create new Makefile for Win32/Linux.

Set the Number of Nodes


Edit omnetpp.ini and change the parameter NNODES in parameters section from 1 to 3. This is not enough for the change to take effect. Also edit globaldef.h file and change the value of macro NNODES from 1 to 3.
 


Build

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

Run

Execute simfw171105 to run the simulation. The simulation screen should like this.
Three nodes will be moving around the screen. Check here for more documentation.

                           


Let's enable all debug options for demonstration purposes and run again. 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. Nodes will be able to communicate only if they come to the same transmission range. Here node 0 is the transmitter and nodes 1 and 2 are listeners. Wait for a while until node 1 comes close to 0. You should see the following output.



[root@sinan testNetwork]# export DBG=all
[root@sinan simfw171105]# ./simfw171105
[0] 0:1:47.27145425: LEDS: Red on.
[0] 0:1:47.27145425: LEDS: Green on.
[0] 0:1:47.27145425: LEDS: Yellow on.
[0] 0:1:47.27145425: Sending message: ffff, 4
[0] 0:1:47.27145425: TossimPacketM: Sending Message
[1] 0:1:47.27145425: AM_address = ffff, 4; counter:1
[1] 0:1:47.27145425: Received message:
[1] 0:1:47.27145425: AM_type = 4
[1] 0:1:47.27145425: LEDS: Red on.
[1] 0:1:47.27145425: LEDS: Green on.
[1] 0:1:47.27145425: LEDS: Yellow on.



 

 

This project has been supported by Featherlight project at University of Twente, the Netherlands and European Embedded WiseNt project at Yeditepe University.