When working with AODV, i need to change the algorithm which is already exist in NS2,when we create a New Algorithm how to implement / which place it should be added in NS2.
Adding a new module and Recompiling NS2 using “Make” command
To add a module in Ns-2 is not a simple task especially for beginner. There are two cases in which the NS2 need to be recompiled.
1. Modifying the existing algorithm (use the same header and the C++ source files)
2. Adding new files/Protocols (adding new header and C++ source files)
Modifying the Existing Algorithm:
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, go to step 1.
Step 3: execute the following command,
make clean
make depend
make
If you have no errors in the modified code, then the compilation will be success and NS will be created, else you may get errors, which needs to be fixed.
Step 4: Test your TCL script for the new algorithm.
Adding New Protocol:
Step 1: open the shell prompt and go to the /home/user/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 ns-allinone-2.34/ns-2.34/).
Step 3: Put all your files inside a respective folder under the folder /home/user/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 New file/folder information.
For example: "newfolder/newfile.o \"
Step 6: after editing the file entry, follow these procedures:
Go to NS2 location in terminal (If you are using ns-allinone-2.xx, then go to ns-allinone-2.xx/ns2x)
Then type "./configure" in terminal (The Makefile will be replaced with modified one.)
Then type "make clean" (*optional))[use this, If you want to recompile the whole ns2. This will remove all the object files in NS2].
Then type "make" [this will make all object files which are missing]
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: Now test your TCL script for the new protocol.
Based on your research algorithm, edit the .cc file of existing AODV protocol , and follow the procedures for adding protocol into NS2 package. Here newrp is a protocol name.
Write your c++ code in /ns-allinone-2.32/ns-2.32/newrp folder
you can go to ns-allinone-2.34 make copy of ns-2.32 save it with different name in same folder i.e newns-2.32. the original will remain intact whatever change you want to do in AODV do it in copy.
when you want to execute modified AODV, go to ns-allinone-2.32/newns-2.32 make and then make install.
this will also maintain your original copy as well as your modified AODV.