Follow the below given steps:
Download ns-allinnone-2.33 from nasam website
http://sourceforge.net/projects/nsnam/files/ns-2
Create a folder in home with name ns2
Extract the tar file in ns2
Open terminal and type cd ns2/ns-allinone-2.33
Install required libraries for ns2 using terminal
sudo apt-get install build-essential autoconf automake libxmu-dev
Then, sudo ./install
For errors,
1.
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
-SHLIB_LD="ld -shared"
+SHLIB_LD="gcc -shared"
2.
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.33/tools/ranvar.cc, line 219
-return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
+return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
3.
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<cstddef>
4.
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.33/mobile/nakagami.cc, Line no.
-if (int_m == m) {
- resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
- } else {
- resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
- }
- return resultPower;
- }
+if (int_m == m) {
+ resultPower = ErlangRandomVariable(Pr/m, int_m).value();
+ } else {
+ resultPower = GammaRandomVariable(m, Pr/m).value();
+ }
+ return resultPower;
+ }
Path Setup:
In terminal sudo gedit ~/.bash_aliases
Then update the environmrnt variable
# LD_LIBRARY_PATH
OTCL_LIB=/home/ramakrishna/ns2/ns-allinone-2.33/otcl-1.13
NS2_LIB=/home/ramakrishna/ns2/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=/home/ramakrishna/ns2/ns-allinone-2.33/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/ramakrishna/ns2/ns-allinone-2.33/bin:/home/ramakrishna/ns2/ns-allinone-2.33/tcl8.4.18/unix:/home/ramakrishna/ns2/ns-allinone-2.33/tk8.4.18/unix
NS=/home/ramakrishna/ns2/ns-allinone-2.33/ns-2.33/
NAM=/home/ramakrishna/ns2/ns-allinone-2.33/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM