First, you have to download the NS2 allinone installation file from here and untar the compressed file (I’m using release ns2-2.33). Common to Ubuntu distribution, the OS is lack of developer tools like compilers and stuffs. Thus, make sure you already have installed your build essentials. If you haven’t,
sudo apt-get install build-essential
Next, you’ll need some dependencies which will allow the installation process to be successful. Else, you’ll probably get a “make : *** [tk3d.o ] Error 1 tk8.4.14 make failed !” error .
sudo apt-get install autoconf automake libxmu-dev
After installation is successful, it’s time to install the NS2/Nam program
cd ns-allinone-2.33
./install
The installation process will take several minutes (depending on your machine’s processing power) with lots of installation verbose on your terminal. When the installation has ended, it will tell the user that installation is successful.
Next, you’ll need to change some Environment values in order to make your program work correctly.
sudo gedit ~/.bashrc
Add these lines to your bashrc file. Replace “your directory” with the installation directory of your ns2 program.
#environment values for NS2/NAM # LD_LIBRARY_PATH OTCL_LIB=/your directory/ns-allinone-2.33/otcl-1.13 NS2_LIB=/your directory/ns-allinone-2.33/lib X11_LIB=/usr/X11R6/lib USR_LOCAL_LIB=/usr/local/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB # TCL_LIBRARY TCL_LIB=/your directory/tcl8.4.18/library USR_LIB=/usr/lib export TCL_LIBRARY=$TCL_LIB:$USR_LIB # PATH XGRAPH=/your directory/ns-allinone-2.33/bin:/your directory/ns-allinone-2.33/tcl8.4.18/unix:/your directory/ns-allinone-2.33/tk8.4.18/unix NS=/your directory/ns-allinone-2.33/ns-2.33/ NAM=/your directory/ns-allinone-2.33/nam-1.13/ PATH=$PATH:$XGRAPH:$NS:$NAM
Then type,
source ~/.bashrc
Next, you would want to validate the installation process. Go to the library and,
cd ns-2.33
./validate
This will take a much longer time than the first installation command (./install). After installation, a validation confirmation “validate overall report: all tests passed” will be shown.
To use ns2 simulator, just type,
$> ns
Hope this help for those who are planning to use the NS-2.