Installation and configuration of network simulator: NS2

NS-2 stands for Network Simulator version 2. NS-2 Is a discrete event simulator for networking research. It is work at packet level. It provides substantial support to simulate bunch of protocols like TCP, UDP, FTP, HTTP and DSR. It simulates wired and wireless network. It is primarily UNIX based. It uses TCL as its scripting language. NS-2 is a standard experiment environment in research community.

 (1) Download ns2.34
http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz/download or from anywhere else.

(2) Unzip the ns-allinone-2.34.tar.gz to any place where you want to install your ns.
Here it is  unzipped  in  /home/gz/ (note that here zipped folder of ns2 was in /home/gz)$ cd /home/gz
$ tar -xzvf ns-allinone-2.34.tar.gz

(3) $cd ns-allinone-2.34

(4) $sudo apt-get install build-essential autoconf automake libxmu-dev

(5) $./install

Errors:
It will take some time. After this step you may encounter some errors like the following
Snapshot
If you get the errors as above, follow the steps from 5.1 to 5.6, otherwise go to step (6)

5.1 $gedit otcl-1.13/Makefile.in

5.2 edit the file as follows:
old file snapshot
new file
5.3 $sudo apt-get install g++-4.3

5.4 $cd ns-allinone-2.34

5.5 ns-allinone-2.34$CC=gcc-4.3 CXX=g++-4.3 ./install

5.6 You are done if you get the following screen
(6) $ gedit ~/.bashrc
It will open the file shown below. Edit the lines that are highlighted according to your path of ns2. I installed my ns2 in /home/gz/ns-allinone-2.34
(7) $ source ~/.bashrc

(8) $cd ns2.34

(9) $./validate
It will take long time to finish(longer than the install)
If you get this screen shot, you are successful.
(10) Create a symlink, so that ns can be called from everywhere
 $ sudo ln -s /home/gz/ns-allinone-2.33/ns-2.33/ns /usr/bin/ns

(11) $reboot
To restart the system.

(12) To check whether ns is installed successfully or not, test it by entering $ns.


If you are prompted with %, it means your installation is successful otherwise check your environment variables,  specifically compare the versions of otcl, nam etc in ./bashrc with those in your ns-allinone-2.34. press exit to go back from %.