13 August 2011

Recompiling NS2 (Network Simulator 2)

Assumptions:

I have installed my ns-allinone-2.34 under /home/pradeep/ns-allinone-2.34
Path is been set in the .bash_profile (which are located at /home/pradeep/) in fedora and .bashrc in ubuntu

There are two ways in which the NS2 can be recompiled

1. You modify the existing algorithm (use the same header and the C++ source files)

2. Adding new files (adding new header and C++ source files)

In first method,

Step 1: open the shell prompt and go to the ns-allinone-2.34/ns-2.34/ folder(there are 3 makefiles, Makefile.vc, Makefile, Makefile.in, for adding any new file should be done at the Makefile.in file)

Step 2: Once the existing algorithm is changed (after modifying the existing header and the C++ source file), go to step 1

Step 3: execute the command, make (the make command executes the instructions given in the Makefile.in) and press enter, If you have no errors in your modified code, then the compilation will be success, else you may get errors, which needs to be corrected

Step 4: Test your tcl script for the new algorithm

In the second Method,

Step 1: open the shell prompt and go to the /home/pradeep/ns-allinone-2.34/ns-2.34/ folder(there are 3 makefiles namely Makefile.vc, Makefile, Makefile.in, for adding any new file should be done at the Makefile.in file)

Step 2: You may create new header and C++ source files for your new proposed algorithm and hence you need to tell that information to the Makefile.in (which is available in /home/pradeep/ns-allinone-2.34/ns-2.34/). For example, assume i created two files tcpnew.h and tcpnew.cc

Step 3: Put all your files inside a folder (for Example create a new folder tcpnew) and put the tcpnew folder under the folder /home/pradeep/ns-allinone-2.34/ns-2.34/

Step 4: Now open the Makefile.in using any editor (usually vi or gedit) and add the folder information to the OBJ_CC variable)

Step 5: anywhere inside the OBJ_CC variable, put the tcpnew folder information like this  tcpnew/tcpnew.o  \

Step 6: after editing the file entry, go to step 1 and execute the command make and press enter. If you have no errors in your modified code, then the compilation will be success, else you may get errors, which needs to be corrected.

Step 7: Test your tcl script for the new Algorithm.