CentOS 7 下安装 NS2

时间:2023-02-01 07:05:48
http://www.cnblogs.com/coder2012/p/3443961.html
http://blog.chinaunix.net/uid-23069658-id-3142068.html

安装前准备:
[koorey@maple ~]$yum install libX11-devel*
[koorey@maple ~]$yum install xorg-x11-proto-devel*
[koorey@maple ~]$yum install libXt-devel*
[koorey@maple ~]$yum install libXmu-devel* 

安装遇到如下错误时:

n file included from linkstate/ls.cc:67:0:
linkstate/ls.h: In instantiation of ‘void LsMap::eraseAll() [with Key = int; T = LsIdSeq]’:
linkstate/ls.cc:396:28: required from here
linkstate/ls.h:137:20: error: ‘erase’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
linkstate/ls.h:137:20: note: declarations in dependent base ‘std::map, std::allocator > >’ are not found by unqualified lookup
linkstate/ls.h:137:20: note: use ‘this->erase’ instead
make: *** [linkstate/ls.o] Error 1
Ns make failed!

修改ls文件:ns-2.35/linkstate/ls.h

第137行

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

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

问题2


tools/ranvar.cc: In member function ‘virtual double GammaRandomVariable::value()’:


tools/ranvar.cc:219:70: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly


tools/ranvar.cc:219:70: error:  for a function-style cast, remove the redundant ‘::GammaRandomVariable’


make: *** [tools/ranvar.o]错误1


Ns make failed!


See http://www.isi.edu/nsnam/ns/ns-problems.html for problems


在ns-allinone-2.33/ ns-2.33/tools文件夹下,找到报错提示中的ranvar.cc文件,打开找到对应的219行删除::GaammaRandomVariable,保存,


即:将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


mac/mac-802_11Ext.h: In member function ‘u_int32_t PHY_MIBExt::getHdrLen11()’:
mac/mac-802_11Ext.h:176:19: error: expected primary-expression before ‘struct’
mac/mac-802_11Ext.h:176:41: error: ‘dh_body’ was not declared in this scope
mac/mac-802_11Ext.h:176:51: error: ‘offsetof’ was not declared in this scope


在ns-allinone-2.34\ns-2.34\mac\mac-802_11Ext.h 文件添加#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


mobile/nakagami.cc:183:73: error:  for a function-style cast, remove the redundant ‘::ErlangRandomVariable’


mobile/nakagami.cc:185:67: error: cannot call constructor ‘GammaRandomVariable::GammaRandomVariable’ directly


mobile/nakagami.cc:185:67: error:  for a function-style cast, remove the redundant ‘::GammaRandomVariable’


 


在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的183行删除::ErlangRandomVariable,保存,


即:将183行的


resultPower = ErlangRandomVariable::ErlangRandomVariable(Pr/m, int_m).value();


改为:


resultPower = ErlangRandomVariable(Pr/m, int_m).value();


在ns-allinone-2.34/ ns-2.34/ mobile文件夹下,找到报错提示中的nakagami.cc文件,打开找到对应的185行删除::GammaRandomVariable,保存,


即:将185行的


resultPower = GammaRandomVariable::GammaRandomVariable(m, Pr/m).value();


改为:


resultPower = GammaRandomVariable(m, Pr/m).value();


最后修改相关系统PATH即可:
export JAVA_HOME=/usr/java/jdk1.8.0_65
export JRE_HOME=/usr/java/jdk1.8.0_65/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib


export NS_HOME=/usr/ns2/ns-allinone-2.34
export PATH=$PATH:/usr/ns2/ns-allinone-2.34/bin:/usr/ns2/ns-allinone-2.34/tcl8.4.18/unix:/usr/ns2/ns-allinone-2.34/tk8.4.18/unix
export LD_LIBRARY_PATH=/usr/src/ns-allinone-2.34/otcl-1.13:/usr/src/ns-allinone-2.34/lib
export TCL_LIBRARY=/usr/src/ns-allinone-2.34/tcl8.4.18/library