Skip to content

Patching ns-2 for OLSR Routing Protocol

Optimized Link State Routing Protocol(OLSR) is not readily available with ns-2. We can apply a suitable version of the OLSR patch on a suitable version of ns-2 and do our OLSR experiments. 

In fact, this subject is very old. There were some old discussions about OLSR in our forum also.

Here we assume that the student is having some elementary knowledge on Linux and ns2. For installation of Linux and ns2.28, refer internet for the procedure for installing linux and installing ns2 on Linux or consult your lab admin or your friend or anybody who knows installation of Linux and ns2

(The given procedure is for ns2.28 only)

Installing ns2.28

Download ns2.28 from the following link

login as root copy the ns-allinone-2.28.tar.gz file in / (root of the filesystem)
$ cd/
$ gunzip -d ns*.gzthis will extract ns-allinone-2.28.tar in the/ file system
$ tar -xvf ns*.tar this will extract ns.28 under the directory/ns-allinone-2.28

First install ns2.28

$ cd /ns-allinone-2.28/
$ ./ install – to install ns2.

After successful installation, edit the /home/user_name/.bash_profile with the following values – then only the following commands will work from any project directory) [/.bash_profile is a hidden file and you have to edit these paths according to your ns2 installation path]

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/ns-allinone-2.28/otcl-1.9:/ns-allinone-2.28/lib:/root/bin/glnx86/
TCL_LIBRARY=/ns-allinone-2.28/tcl8.4.5/library
PATH=$PATH:$HOME/bin:/ns-allinone-2.28/bin:/ns-allinone-2.28/tcl8.4.5/unix:/ns-allinone-2.28/tk8.4.5/unix
export USERNAME BASH_ENV PATH LD_LIBRARY_PATH TCL_LIBRARY

Reboot the system and login again

Check the good working of ns2 by just typing the following command.

$ ns
– this will produce % prompt (Ctrl+C to exit)
 
$ nam
– This will start nam
 
$ xgraph
– it should wait for input (Ctrl+C to exit)

 

If all the above three commands are working, then only you may proceed with the following.

 

Installing OLSR Routing Agent in ns2.28

We are downloading the OLSR patch from the following link and just renamed it as OLSR.patch (see bottom of this article for the updated patch for ns2.35)

You need to first patch your ns version 2.28 as follows.

Now you are having a working version of ns2.28

copy the file OLSR.patch to ns-allinone-2.28 folder.
run terminal window and change to ns-allinone-2.28 folder.
apply OLSR patch as follows

$ patch -p0 < OLSR.patch

the following screen shows a successful patch operation

 

Chage to ns-allinone-2.28/ns-2.28 folder and make new ns binary with swarm as follows. (cd /ns-allinone-2.28/ns-2.28)

$ make

A successful compilation of ns2 with OLSR

OLSR is getting compiled

The final screen showing no errors – means successful compilation

$ make install

(some times optional – it will copy ns binary files to /bin and /usr/bin directory)

If everything is ok, then it will create a new ns binary with OLSR routing protocol.

7. Now we can test the installation with a sample tcl script wich is using OLSR routing protocol.

You can download a sample ns2 simulation script to test the working of OLSR from the following link.

http://masimum.dif.um.es/um-olsr/olsr_example.tcl

$ ns olsr_example.tcl
$ nam olsr_example.nam.

It will run the code and open the example scenario in nam window.

 

If you are getting any routing agent related errors, then check from the top.

Yes It may be tough for a normal student. There is no other simple way to do it.

You have to complete the above things even before starting a single line of coding for your project on OLSR under ns2.

Updates:

Resent version of patches may be found at the following links. 

 
 
One should alter the above procedure according to the version of the patch and version of ns2 that they are using.

Reference

https://en.wikipedia.org/wiki/Optimized_Link_State_Routing_Protocol

Leave a Reply

WhatsApp Discuss Through WhatsApp