Steps for Creating a New Routing Module in Castalia WSN Simulator

ATTENTION:
i) Make sure the path CASTALIA_HOME point to the location where Castalia is being installed
ii) “MyCustomRouting” is the name of the routing module that we wish to create

STEP 1: Creating the source-code files for the new module

1.a) Create a directory with name “MyCustomRouting” under the directory:
        CASTALIA_HOME/src/Node/Communication/Network

1.b) Copy the source-code files (*.h *.cc *.ned files) of directory:
        CASTALIA_HOME/src/Node/Communication/Network/BypassRouting
        into the new directory that was created in Step 1.a):
        CASTALIA_HOME/src/Node/Communication/Network/MyCustomRouting

1.c) Rename the contents of folder:
        CASTALIA_HOME/src/Node/Communication/Network/MyCustomRouting
        as follows:

BypassRoutingModule.h —> MyCustomRoutingModule.h
BypassRoutingModule.cc —> MyCustomRoutingModule.cc
BypassRoutingModule.ned —> MyCustomRoutingModule.ned

1.d) Open file “MyCustomRoutingModule.h” for editing and make the following text
        replacements:

BYPASSROUTINGMODULE –> replace with –> MYCUSTOMROUTINGMODULE
        BypassRoutingModule –> replace with –> MyCustomRoutingModule

        Save changes

1.e) Open file MyCustomRoutingModule.cc for editing and make the following text
        replacements:

BypassRoutingModule –> replace with –> MyCustomRoutingModule

        Save changes

1.f) Open file MyCustomRoutingModule.ned for editing and make the following text
        replacements:

BypassRoutingModule –> replace with –> MyCustomRoutingModule

        Save changes

STEP 2: Modify the build configuration file

2) Open file CASTALIA_HOME/config/makemake.config for editing and add the
      following lines/text:
      At end of line 38 (which starts with “ALL_WSN_INCLUDES =”) add the following
      text:

-I$(SRCDIR)/Node/Communication/Network/MyCustomRouting

      (make sure that you include a spaces before and after this text)
      Save changes
      This file is used by the script “makemake” and contains information on how to
      generate Makefile files at each sub-directory of the Castalia/src folder.

**Variables reside in makemake.config file:
2.a) OPTS ==> here you can add/modify the options of the opp_makemake tool.
        Usually it has not to be modified at all.



2.b) ALL_WSN_INCLUDES ==> here you MUST add every directory that either
        contains an *.h (C++ header) file or it will contain one after the invocation of
        opp_makemake by the Castalia/makemake script (usually the *.msg files produce
        extra header files). What you have to do is to add all the directories
        with the *.h or *.msg files that you created in the form of:
        -I$(SRCDIR)/Your_include_Dir_Under_Castalia_src.

** Make Targets:
2.c) You MUST modify the “WSNetwork” target. Most of the times you need to add a line
        like

cd $(SRCDIR)/Your_Dir_Under_Castalia_src && $(MAKEMAKE) $(OPTS) -n -r
-I$(SRCDIR)/Your_include_Dir_A_Under_Castalia_src

        for each new directory that you have created and that contains source(*.ned, *.cc,
        *.h) or *.msg files.

ATTENTION :
i) You may need to add more than one
           -I$(SRCDIR)/Your_include_Dir_XX_Under_Castalia_src
    flag at the end of this line if you use a source file from a different directory
ii) You don’t have to create your own omnetpp.config. It is generated automatically
      after the execution of “makemake”
iii) You don’t have to create your own nedfiles.lst. It is generated automatically after the
      execution of “makemake”

STEP 3: Clean and re-build Castalia

3) Change into directory CASTALIA_HOME and issue the following
      commands at the terminal:
      This will produce all the needed “Makefile” files automatically.

# make clean
# ./makemake
# make

      Normally you will not get any compile-time errors and you will be able
      to see in file CASTALIA_HOME/nedfiles.lst the following line:

./src/Node/Communication/Network/MyCustomRouting.ned



STEP 4: Create the appropriate ini file for simulations

4.a) Create a new file with name “Routing_myCustom.ini” under the directory:
         CASTALIA_HOME/ Simulations/Parameter_Include_Files

4.b) Copy and paste the contents of file:
         CASTALIA_HOME/Simulations/Parameter_Include_Files/Routing_bypass.ini
         into file:
         CASTALIA_HOME/Simulations/Parameter_Include_Files/Routing_MyCustom.ini          
         and then replace all occurrences of “BypassRoutingModule” with
         “MyCustomRoutingModule”

4.c) You can use MyCustomRouting module as your preferred
         Network-level protocol in your simulation by including the following line at the
         appropriate place inside your omnetpp.ini file:
         include ../Parameter_Include_Files/Routing_MyCustom.ini

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
IMPORTANT NOTICE:
Please make sure that you always provide a correct relative directory pointer to the containing folder of Routing_MyCustom.ini from within your omnetpp.ini file.

Check the Castalia/nedfiles.lst to all the ned files that have been found inside the sources.
Check the Castalia/Bin to see the CastaliaBin executable binary with the core functionalities of the simulator.
This binary is invoked everytime you need to run a simulation.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Original link: http://groups.google.com/group/castalia-simulator/browse_thread/thread/7265a1327f281c4d/5ccd943bfabf458e?lnk=gst&q=New+Routing+Module+in+Castalia#5ccd943bfabf458e

OR

Refer the README.txt file in Castalia folder.