Thursday 8 January 2015

Step by step installation of ns2.35 on ubuntu 14.04

step 1: step1: Download ns-allinone-2.35.tar.gz

Download link:
http://sourceforge.net/projects/nsnam/

step 2:Copy it to home folder(not compulsory, you can change as per your choice )

step 3:Open Terminal (Altr+ctrl+t)

step 4:Install the basic packages required to install the ns2

        $sudo apt-get update

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


step 5: Extract tar file to home. In terminal default directory is home.
            Run follwing command to extract tar file to home directory

          $tar -zxvf ns-allinone-2.35.tar.gz

step 6: Edit line 137 of ns-allinone-2.35/ns-2.35/linkstate/ls.h file as

    
        void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }

              after change save and close this file.

              Go to terminal

step 7:To install ns2  go to ns-allinone-2.35 directory and run ./install

           $ cd ns-allinone-2.35/
      
           $./install

            it will take 20- 30 min or may be more time to install
      
step 8:After successful installation(without any error) set path in
      ~/.bashrc profile file

          $gedit ~/.bashrc

          add following lines to the end of this file

 # LD_LIBRARY_PATH
OTCL_LIB=/home/suraj/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/suraj/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/suraj/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/suraj/ns-allinone-2.35/bin:/home/suraj/ns-allinone-2.35/tcl8.5.10/unix:/home/suraj/Desktop/ns-allinone-2.35/tk8.5.10/unix
NS=/home/suraj/ns-allinone-2.35/ns-2.35/
NAM=/home/suraj/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM


step 9: Change the directory name in above with yours

           $pwd

**copy the output of above and replace with  "/home/suraj/ns-allinone-2.35"

step7: save and exit the file and run following command

           $source ~/.bashrc

step 10: Run ns

            $ns

             It will show % sign
             type exit to exit

            Run nam command

            $nam

             it will show nam window


if nam shows you error like segmentation fault(core dumped)

go to nam-1.15 and run

$cd ns-allinone-2.35/nam-1.15

$sudo cp nam /usr/local/bin


now run nam

$nam

Enjoy!