MF Integration

Different from CntToLedsAndRfm simulation, we will use Mobility Framework ' s MAC layer and mobility mechanisms in this simulation.


Note that, for linux operating system the version of g++ seems to be very important. You may consider upgrading your compiler before starting if yours is not supported. With buggy versions of the compilers, your simulation will crash with segmentation fault at basicmodule.h line 105. I tested this using Fedora core 5 and g++ version of

Thread model: posix
gcc version 4.1.1 20060525 (Red Hat 4.1.1-1)

Edit TinyOSApplLayer.cc instead of txc1.cc. Note that different from regular applications, node id is retrieved by querying parentModule via parentModule()->getIndex() instead of index().

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

if (parentModule()->getIndex() == 0)
{
   cCntToLedsAndRfm_Main *m = new cCntToLedsAndRfm_Main(this,main,"Main",parentModule()->getIndex());
   m->StdControl_init();
   m->StdControl_start();
}
else
{
   cRfmToLeds_Main *m = new cRfmToLeds_Main(this,main,"Main",parentModule()->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 opt]# cd tictoc
[root@sinan tictoc]# cd components
[root@sinan components]# cp CntToLedsAnRfm.nc ../Application.nc
[root@sinan components]# cd ..
[root@sinan tictoc]# ./nesct.exe Application.nc

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

MF Integration

Download MF from MF website here. This example has been tested with 2.0p2 version of MF.
Extract the sources to a directory (/opt for example replace /opt/mobility-fw2.0p2 with your own directory for instructions below)


[root@sinan opt]# unzip mobility-fw2.0p2.zip

If you are using Linux,

* add /opt/mobility-fw2.0p2/core/lib and /opt/mobility-fw2.0p2/contrib/lib to the end of ld.so.conf file in /etc directory. Do not forget to leave one empty line.


If you are using windows,

* Make sure that you have mobility framework and nesct_example package for mobility framework reside in the same directory, src/mobility-fw2.0p2 and src/tictoc for example.
* You'll need to edit mkmk.cmd; update your OMNETPP_ROOT directory to the folder that you have extracted OMNeT++ (c:\OMNeT++ , /opt/omnetpp).

Go back to your directory and

  1. type mkmk. It is going to create makefiles for the subdirectories.

    [root@sinan mobility-fw2.0p2]# ./mkmk
    Makefile created, adding dependencies...
    opp_makedep: warning: no input files
    Done.
    Makefile created, adding dependencies...
    Done.
    Makefile created, adding dependencies...
  2. type "make all" for linux and "nmake -f makefile.vc all" for windows. It is going to start compilation and building of the sources.
    This is going to build mobility framework.

     

    • Linux: Add lib directory of your mobility framework to your LD_LIBRARY_PATH environment variable for Linux. Best place for this is .bash_profile file. Edit your .bash_profile and add

      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/mobility-fw2.0p2/contrib/lib

      to your .bash_profile file in your home directory. Logout and login again to allow changes take effect.

     

    • Windows: You do not need to this for windows, it's hardcoded in config_mfw.win32.

      Your mobility framework must reside in a directory named
      mobility-fw2.0p2 next to tictoc
      MOBFW = ../mobility-fw2.0p2
      Otherwise, you need to modify MOBFW path in config_mfw.win32.
       
  3. Enter mfw directory and run install.bat for windows. For linux, we need to make sure that install.sh is in unix text file format. We do this by running "dos2unix install.sh" in mfw directory. To run install.sh for linux, type "sh install.sh". Note that, this operation will replace txc1.cc.


 

Updating Makefile

If you are using tos_example with date 240806, you'll notice that config_mfw is not included in the package. This was due to a compiler problem of my test environment. You can download it from here. Type 'opp_makemake -c config_mfw -f' to create new Makefile for your environment. If your build environment is windows type 'opp_nmakemake -c config_mfw.win32 -f'  to create new Makefile for your environment.

[root@sinan tictoc]# opp_makemake -c config_mfw -f
Makefile created, adding dependencies...
Done.


Build

Type "make" for linux, "nmake -f makefile.vc" for windows to build the binary.

[root@sinan tictoc]# make

Run

Execute tictoc to run the simulation. The simulation screen should like this.

Let's enable all debug options for demonstration purposes. 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.

                           

[root@sinan tictoc]# export DBG=all
[0] 0:0:6.44782950: Sending message: ffff, 4
[0] 0:0:6.44782950: TossimPacketM: Sending Message
host[0]::TinyOSApplLayer: Sending broadcast packet!
[4] 0:0:6.44822350: AM_address = ffff, 4; counter:3
[4] 0:0:6.44822350: Received message:
[4] 0:0:6.44822350: AM_type = 4
[6] 0:0:6.44822350: AM_address = ffff, 4; counter:3
[6] 0:0:6.44822350: Received message:
[6] 0:0:6.44822350: AM_type = 4
[8] 0:0:6.44822350: AM_address = ffff, 4; counter:3
[8] 0:0:6.44822350: Received message:
[8] 0:0:6.44822350: AM_type = 4
[4] 0:0:6.44822350: LEDS: Red off.
[6] 0:0:6.44822350: LEDS: Red off.
[8] 0:0:6.44822350: LEDS: Red off.
[4] 0:0:6.44822350: LEDS: Green on.
[6] 0:0:6.44822350: LEDS: Green on.
[8] 0:0:6.44822350: LEDS: Green on.
[4] 0:0:6.44822350: LEDS: Yellow off.
[6] 0:0:6.44822350: LEDS: Yellow off.
[8] 0:0:6.44822350: LEDS: Yellow off.
[0] 0:0:6.69195450: LEDS: Red on.
[0] 0:0:6.69195450: LEDS: Green on.
[0] 0:0:6.69195450: LEDS: Yellow off.


 

 

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