In this tutorial, we will see how to install NS2 2.35 in ubuntu 14.04 linux operating system. It is not a good idea to use direct commands in the terminal like
// These commands ok for 12.04 but not recommended for UBUNTU 14.04 sudo apt-get install ns2 sudo apt-get install nam
This results "Segmentation Fault and core dumped". So just follow the below step by step instructions to install successfully.
STEP 1: Does we need to do anything before starting the installation? YES
Install all necessary dependencies using below commands one after another.
sudo apt-get install tcl8.5-dev tk8.5-dev sudo apt-get install build-essential autoconf automake sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev
STEP 2:
- Download the NS2 Package from this link.
- Copy the downloaded file to your /Home folder in ubuntu 14.04.
- Right click on the file and select "Extract here" option. (You can also do this using command line).
STEP 3:
Now go to ns-allinone-2.35/ns-2.35/linkstate sub folder.
double click on "ls.h" file to open.
go to line number 137 and change the below line
from void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
STEP 4:
Open the Terminal by pressing "ALT+CNTL+T" keys combination. And move to ns-allinne-2.35 folder from home through terminal
maggi@maggi-PC:~$ cd ns-allinone-2.35/ maggi@maggi-PC:~/ns-allinone-2.35$
Now type ./install on terminal
maggi@maggi-PC:~/ns-allinone-2.35$ ./install
hit enter and wait for some time till it shows path information. That's done now and you are installed NS2.
STEP 5:
Now it's time to set the path information. In the terminal use sudo gedit .bashrc and hit enter. It will ask for password to enter (Its not visible).
maggi@maggi-PC:~$ sudo gedit .bashrc [sudo] password for maggi:
Go to the last line of the newly opened file (bashrc), copy and paste these 3 lines. Make sure that you changed maggi with your username on ubuntu.
PATH=$PATH:/home/maggi/ns-allinone-2.35/bin:/home/maggi/ns-allinone-2.35/tcl8.5.10/unix:/home/maggi/ns-allinone-2.35/tk8.5.10/unix LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/maggi/ns-allinone-2.35/otcl-1.14:/home/maggi/ns-allinone-2.35/lib TCL_LIBRARY=$TCL_LIBRARY:/home/maggi/ns-allinone-2.35/tcl8.5.10/library
Save the document and close. Reload the .bashrc using the following command.
source ~/.bashrc
STEP 6:
Its done! open the terminal and type "ns" hit enter. You will get a % sign, it indicates the successful installation.