- Download the ns version of your choice (here I am using ns-allinone-2.35 for Ubuntu 16.04) and un-tar your folder (check online on how to un-tar your folder).
- Open the terminal using the key combination 'alt+ctrl+t' and issue the following command(s)
- sudo su (press enter)
- Now give the system password
- Ensure that a # symbol is shown at the end of the path name.
- Now issue the command(s) one by one
sudo apt-get update
sudo apt-get install build-essential autoconf automake
sudo apt-get install tcl8.5-dev tk8.5-dev
sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev
4. Extract and install ns2
After extracting the "ns-allinone-2.35" folder, open up the file "/ns-allinone-2.35/ns-2.35/linkstate/ls.h" in an editor. We have to make some changes in the ls.h file else it will show an error while installing the NS. After opening the file, move to the line number 137 and replace the erase (image 1) with this->erase (image 2) and save the file.
Image 1
Image 2
5. Now go to the folder where ns-allinone folder is present and then issue the command ./install (on my machine the path to the folder is /home/ccnlab/ccnlab/ns-allinone-2.35) . Here the first 'ccnlab' is name of the machine and the second 'ccnlab' is the name of the folder where ns-allinone-2.35 is present.
If ns2 installation is successful, then edit the bashrc file as follows: Issue the command gedit ~/.bashrc in the terminal and enter the following code.
-----------------------------------------------------------------------------------------------------------
# LD_LIBRARY_PATH
OTCL_LIB=/home/ccnlab/ccnlab/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/home/ccnlab/ccnlab/ns-allinone-2.35/lib/
USR_Local_LIB=/usr/local/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_Local_LIB
# TCL_LIBRARY
TCL_LIB=/home/ccnlab/ccnlab/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/ccnlab/ccnlab/ns-allinone-2.35/xgraph-12.2/:/home/ccnlab/ccnlab/ns-allinone-2.35/bin/:/home/ccnlab/ccnlab/ns-allinone-2.35/tcl8.5.10/unix/:/home/ccnlab/ccnlab/ns-allinone-2.35/tk8.5.10/unix/
NS=/home/ccnlab/ccnlab/ns-allinone-2.35/ns-2.35/
NAM=/home/ccnlab/ccnlab/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM
-------------------------------------------------------------------------------------------------------
In the above file the text "home/ccnlab/ccnlab" must be replaced with appropriate path where the ns-allinone-2/35 folder is present. Now save the file and close it.
6. Now issue the command source ~/.bashrc
7. Now type ns (if you get a % symbol, then you are successful in installing ns2 else tyr installing it using the command sudo apt-get install ns2)
8. Now type nam (if you get a new animation window then you are done!. If you get any error such as, say for isntance, segment fault core dump, then follow the link here)
Note: If any of your folders are locked (you can see the keypad) then unlock them using the command chmod -R 777 *
Un-installation step(s):
To uninstall ns2, type the following command at the command prompt in the terminal
sudo apt-get remove ns2