Friday, January 24, 2014

NS2.34 installation



1. Download ns-allinone-2.34             
2.Extract it to any folder, I generally do it on home

3. Install the libraries
(before install ns-2 you will need the packages that are shown below )
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf automake libxmu-dev
$ sudo apt-get install libx11-dev libxmu-dev libxmu-headers libxt-dev libtool
$ sudo apt-get install dpkg-dev g++ libc6-dev make
$ sudo apt-get install tcl8.4 tk8.4
$ sudo apt-get install build-essential
$sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3 
 3. Open terminal (cntrl+alt+t) and type cd ns-allinone-2.34
4. type ./install Now you will get some errors probably.
5. Go to ns-allinone-2.34/otcl-1.13/configure, line number 6304 remove thde line

SHLIB_LD="ld -shared"
and make it
SHLIB_LD="gcc -shared"
6. Now go to

ns-allinone-2.34/ns-2.34/ tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’:
In ns-2.34/tools/ranvar.cc, line 219 replace the line

return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
to
return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
7. In ns-allinone-2.34/ns-2.34/mac/mac-802_Ext.h, line 65 add

#include<cstddef>
8.
In ns-allinone-2.34/ns-2.33/mobile/nakagami.cc

Find the lines 
if (int_m == m) {
             resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
         } else {
             resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
         }
         return resultPower;
    } And replace with
  if (int_m == m) {
            resultPower = ErlangRandomVariable(Pr/m, int_m).value();
         } else {
             resultPower = GammaRandomVariable(m, Pr/m).value();
         }
        return resultPower;
    }

In Makefile.in 
find the line
CC=    @CC@
and change it to
CC=    gcc-4.3

Now  go to ns-allinone-2.34 
and type
$./configure
$make clean
$make
Path Setup:
Open your terminal again and type
  gedit ~/.bashrc

Then in the end of the page update the env variables append the following lines. Change the path to your path ***************************************************************************
# LD_LIBRARY_PATH
OTCL_LIB=/home/anupama/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/anupama/ns2/ns-allinone-2.34/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=/home/anupama/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/anupama/ns-allinone-2.34/bin:/home/anupama/ns-allinone-2.34/tcl8.4.18/unix:/home/anupama/ns-allinone-2.34/tk8.4.18/unix
NS=/home/anupama/ns-allinone-2.34/ns-2.34/
NAM=/home/anupama/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

******************************************************************************
Now , close your terminal
Open a new terminal again and type ns
U ll see a % coming up which means ns is installed.