How to install NS-2.34 in Fedora 15

This post shows the detailed procedure of installing NS-2.34 in fedora 15. This post also indicates the errors faced during installation and the possible solutions.
1. Download the ns-allinone-2.34 package from net http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/ in directory like /usr/src.
2. Go to /usr/src and extract ns-allinone-2.34.tar
tar xvfz ns-allinone-2.34.tar.gz
3.go to ns-allinone-2.34
cd ns-allinone-2.34
4. install
./install

Errors
1

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
Ns make failed!

Sol:

open the /tools/ranvar.cc file. change line no 219 as shown in bold

double GammaRandomVariable::value()

{
// Proposed by Marsaglia in 2000:
// G. Marsaglia, W. W. Tsang: A simple method for gereating Gamma variables
// ACM Transactions on mathematical software, Vol. 26, No. 3, Sept. 2000
if (alpha_ < 1) {
double u = rng_->uniform(1.0);
//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_);
}

double x, v, u;
double d = alpha_ – 1.0 / 3.0;
double c = (1.0 / 3.0) / sqrt (d);

2.

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!
Sol:
open /mac/mac-802_11Ext.cc and add #include <cstddef>

#include “delay.h”
#include “connector.h”
#include “packet.h”
#include “random.h”
#include “mobilenode.h”
#include “arp.h”
#include “ll.h”
#include “mac.h”
#include <cstddef>
#include “mac-802_11Ext.h”
#include “cmu-trace.h”
#include <iostream>
#include “common/agent.h”

3.

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
Ns make failed!

Sol.

open mobile/nakagami.cc and replace line no 183 and 185 with lines as shown in bold

unsigned int int_m = (unsigned int)(floor (m));

double resultPower;

if (int_m == m) {
//resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();
resultPower = ErlangRandomVariable(Pr/m, int_m).value();
} else {
//resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();
resultPower = GammaRandomVariable(m, Pr/m).value();
}
return resultPower;
}
After installation put the paths in bashrc file

(1) You MUST put /usr/src/ns-allinone-2.34/otcl-1.13, /usr/src/ns-allinone-2.34/lib,
into your LD_LIBRARY_PATH environment variable.
If it complains about X libraries, add path to your X libraries
into LD_LIBRARY_PATH.
If you are using csh, you can set it like:
setenv LD_LIBRARY_PATH <paths>
If you are using sh, you can set it like:
export LD_LIBRARY_PATH=<paths>

(2) You MUST put /usr/src/ns-allinone-2.34/tcl8.4.18/library into your TCL_LIBRARY environmental
variable. Otherwise ns/nam will complain during startup.
go to etc/bashrc and paste the following lines at the end of file

fi
# vim:ts=4:sw=4
#for ns-allinone-2.34
export PATH=/usr/src/ns-allinone-2.34/tcl8.4.18/unix:/usr/src/ns-allinone-2.34/tk8.4.18/unix:/usr/src/ns-allinone-2.34/bin:$PATH
export LD_LIBRARY_PATH=/usr/src/ns-allinone-2.34/tcl8.4.18/unix:/usr/src/ns-allinone-2.34/tk8.4.18/unix:/usr/src/ns-allinone-2.34/otcl-1.13:/usr/src/ns-allinone-2.34/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=/usr/src/ns-allinone-2.34/tcl8.4.18/library

Leave a Reply

Your email address will not be published. Required fields are marked *