Friday, April 12, 2013

STEPS TO INSTALL NS 2.35/NS2.34 IN UBUNTU 12.04 and 12.10

STEP TO INSTALL NS-2.34 IN UBUNTU 12.04 LTS



Step 1:Make it sure that internet connectivity is good.Download NS2.34 from
http://www.isi.edu/nsnam/ns/

Step 2:make a new folder [ns] in /home/Extracts downloaded files in above folder.

Step 3 :copy downloaded ns-allinone-2.34.tar.gz in /home/ns/

Step 4 :open terminal

Step 5:Run following commands
cd ns-allinone-2.34

sudo apt-get update

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

Step 6 :Run following command
./install

IF U MET WITH THE ERRORS THEN MAKE FOLLOWING CHANGES IN THE PACKAGE :

1. ERROR
ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Bad value
make: *** [libotcl.so] Error 1
otcl-1.13 make failed! Exiting ...
Solution:
In otcl-1.13/configure, line number 6304
  Replace 
-SHLIB_LD="ld -shared" 
with
+SHLIB_LD="gcc -shared"

2. ERROR
tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’:
tools/ranvar.cc:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly [-fpermissive]
tools/ranvar.cc:219:70: error:   for a function-style cast, remove the redundant ‘::GammaRandomVariable’ [-fpermissive]
make: *** [tools/ranvar.o] Error 1

Solution:
In ns-2.34/tools/ranvar.cc, line 219
REPLACE
-return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);WITH
+return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
3.ERROR
In file included from mac/mac-802_11Ext.cc:66:0:
mac/mac-802_11Ext.h: In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:
mac/mac-802_11Ext.h:175:19: error: expected primary-expression before ‘struct’
mac/mac-802_11Ext.h:175:41: error: ‘dh_body’ was not declared in this scope
mac/mac-802_11Ext.h:175:51: error: ‘offsetof’ was not declared in this scope
mac/mac-802_11Ext.h:177:3: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [mac/mac-802_11Ext.o] Error 1
Ns make failed!

Solution:
In mac/mac-802_Ext.h, line 65

+#include 

4.ERROR
mobile/nakagami.cc: In member function ‘virtual double Nakagami::Pr(PacketStamp*, PacketStamp*, WirelessPhy*)’:
mobile/nakagami.cc:183:73: error: cannot call constructor ‘ErlangRandomVariable::ErlangRandomVariable’ directly [-fpermissive]
mobile/nakagami.cc:183:73: error:   for a function-style cast, remove the redundant ‘::ErlangRandomVariable’ [-fpermissive]
mobile/nakagami.cc:185:67: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly [-fpermissive]
mobile/nakagami.cc:185:67: error:   for a function-style cast, remove the redundant ‘::GammaRandomVariable’ [-fpermissive]
make: *** [mobile/nakagami.o] Error 1

Solution:
In ns-2.34/mobile/nakagami.cc ,


if (int_m == m) {
             resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
         } else {
             resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
         }
        return resultPower;  }
Replace the above with :  if (int_m == m) {
            resultPower = ErlangRandomVariable(Pr/m, int_m).value();
         } else {
             resultPower = GammaRandomVariable(m, Pr/m).value();
         }
        return resultPower;
    }

Step 7:Run following command to install X – graph
$ sudo apt-get install xgraph

Step 8.Set environment variables by run this command
gedit ~/.bashrc

Add the following lines to the end of the file. Remember replace "/your/path" by the folder where you have stored extracted the ns-2 file (For example, if your Linux account name is purple, and you have extracted the file to your home directory, you have to change /your path to /home/ns)
# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/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=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-
2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Step 9 :run following command
source ~/.bashrc

Now you can run your ns with ns command...
The "%" symbol appears on the screen. Type "exit" to quit.

2 comments:

  1. 4th error cant be solving ..only #include in line 65 in that file nothing will change same error comes. is i need to add anything with #include? pls reply

    ReplyDelete
  2. there is correction add #include in 65 line not #include

    ReplyDelete

SOME NOTES

Computer Graphics https://drive.google.com/file/d/0B3gZB7x45-P8cHVwVzNuOG80elU/view?usp=sharing Basics of Java https://drive.google.co...