zoukankan      html  css  js  c++  java
  • [置顶] NS2.33在Ubuntu12.10的完整安装过程及相关问题

    准备工作:Ubuntu12.10已经成功安装+下载NS2安装文件,我这里是ns-allinone-2.33.tar,另外准备两个补丁:tk-8.4-lastevent.patchtk-8.4.18-tkBind.patch

    第一步:将ns2的压缩包ns-allinone-2.33.tar.gz拷贝到桌面,右键解压到桌面,将解压后的文件夹复制到准备安装的位置,

                    例如我的件夹home/wl(wl是登录用户名)下新建文件夹program,将ns2的文件夹粘帖到home/wl/program下。

    第二步:在root的用户名下或admin用户下,下载并安装ns-2.33安装时需要的系统包,具体如下:

                         首先,在终端里输入apt-get install build-essential 进行下载安装,这一步是为了gcc and some essential 的安装;

                    接着,在终端里输入apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev 进行下载安装,这一步是为了tcl and tk 的安装;

                    最后,在终端里输入apt-get install libxmu-dev 进行下载安装,这一步是为了nam的安装。

    第三步:检查gcc版本,现在系统自动安装的版本一般高于4.0,但是安装之前仍有必要检查下,终端命令如下:

                   终端执行ls  /usr/bin/gcc –l或者gcc --rsion或者gcc -v都可以,我的是gcc4.7.2

                   因为gcc 4.0版本以前是用ld -share来生成共享库的,但是到了4.0以上的版本,这个命令改为了gcc -share。

                  所以,若版本高于gcc4.0则需要做如下更改:

                 cd  /home/liu/Program/ns-allinone-2.33//otcl-1.13
                    do gedit configure.in

                    将77行,SHLIB_LD="ld -shared" 改为SHLIB_LD="gcc -shared"保存,退出

    同时修改configure 第5518行SHLIB_LD="ld -shared"改为SHLIB_LD="gcc -shared"保存退出。

                   上述修改是终端命令的形式,也可以在视图下直接打开,前提是开放文件的“read and write"权限。

    第四步:由于我的是安装的ns2.33,据说存在一些问题,所以提前进行了测试并安装了补丁,具体步骤如下:

                   

    (1)运行自带的实例进行测试: /ns-allinone-2.33/ns-2.33/tcl/ex/simple.tcl
      可能的问题:
           系统提示如下,
    [code omitted because of length]

    : no event type or button # or keysym
        while executing
    "bind Listbox <MouseWheel> {
    %W yview scroll [expr {- (%D / 120) * 4}] units
    }"
        invoked from within
    "if {[tk windowingsystem] eq "classic" || [tk windowingsystem] eq "aqua"} {
    bind Listbox <MouseWheel> {
    %W yview scroll [expr {- (%D)}] units
    }
    bind Li..."

           原因:据说是ns2.33,它的nam调用的tk组件和xproto-7.0.13 不兼容导致的(xproto-7.0.13 新添加了 GenericEvent),所以在安装ns2之前要先打上补丁。如果不打上补丁的话,后面调用nam时会报错。

         解决方法为:

    (1)打上准备的补丁tk-8.4-lastevent.patch

       把这个文件移动至ns目录下tk8.4.18下

         $ cd/home/liu/Program/ns-allinone-2.33/tk8.4.18

         $ patch –p1<tk-8.4-lastevent.patch

    (2)打上准备的补丁tk-8.4.18-tkBind.patch
        将文件tk-8.4.18-tkBind.patch移至ns-allinone-2.33目录下,并运行如下命令:
        $patch -p0 <tk-8.4.18-tkBind.patch

    第五步:开始安装安装ns2,具体命令如下:

                     移动到ns2目录下cd /home/liu/Program/ns-allinone-2.33/

                      安装 ./install

    PS:本以为接下来是经过几分钟的翻滚,然后安装成功,但是遇到如下一系列问题,咱们逐一解决:

    1.输入安装命令后,提示“Permission denied"的错误,尽管我已经是root的身份进行安装仍然有如此提示,解决方法是:修改install的权限,这个在视图下进行,修改如下图所示
    再重新安装即可。

    终于开始安装了,但不顺的是如下问题出现:

    1.错误一:安装NS2.34过程中出现如下的错误:

    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

    这是由于gcc版本提高后对类内部函数调用的简化造成的不兼容,解决方法如下:

    在ns-allinone-2.34/ ns-2.34/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_);

     然后保存退出,重新安装ns2.

    2.错误二:重新在ns目录下键入$ ./install安装,再次出现同类问题时,

    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’

    make: *** [mobile/nakagami.o]错误1

    Ns make failed!

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

    解决方法:

    在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();


    重新在ns目录下键入$ ./install安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。直到安装成功。

     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!

    关于本问题的解决方案:

    If you get error like:

    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

    open that file and add

    #include <cstddef>

    to the header files.
    在ns-allinone-2.34\ns-2.34\mac\mac-802_11Ext.h 文件添加#include <cstddef>
    然后重新安装。

    4.

    In 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()); }

    然后重新 ./install,在经过一段时间后,终于有如下提示:

    即安装完成!

    第六步:正如提示所说,需要进行一些配置:
     

    退到ns-allinone-2.33的上一级目录,在终端输入:sudo gedit .bashrc

          在文件最后编辑如下信息,并保存:

     PATH="$PATH:/home/wl/program/ns-allinone-2.33/bin:/home/wl/program/ns-allinone- 2.33/tcl8.4.18/unix:/home/wl/program/ns-allinone-2.33/tk8.4.18/unix"

     LD_LIBRARY_PATH="/home/wl/program/ns-allinone-2.33/otcl-1.13:/home/wl/program/ns- allinone-2.33/lib"

     TCL_LIBRARY="$TCL_LIBRARY:/home/wl/ns-allinone-2.33/tcl8.4.18/library"
    PS:把路径中的wl换成你自己的路径

    但是提示如下图所示错误:

    我这里出现的问题是,没有仍然是在program的目录下打开.bashrc,打开后的.bashrc实际是空的,直接将上述内容编辑进去是不对的,即没有设置好环境变量。

    所以我有按照如下步骤进行:

    退出原来的终端,新建一个终端,并直接键入命令:gedit .bashrc 回车后,出现如下正确的非空.bashrc ,并修改编辑命令如下图的红色线框中内容:

    第七步:验证是否安装成功:另外打开一个终端,输入ns,查看是否进入%,如果已经进入则表示安装成功,运行自带的实例进行测试: /ns-allinone-2.33/ns-2.33/tcl/ex/simple.tcl

    接下来,我在该终端接着输入:ns ,但是仍然得到没有安装的错误提示,于是我关掉所有打开的窗口,并重新键入命令:ns 终于出现了%,接着键入 nam 又成功出现如下图所示框:

    至此,终于是安装成功了,真是一波三折!

    第八步:安装xgraph:

    输入命令:sudo apt-get install xgraph,输入密码回车安装xgraph,结果如图所示,表示安装成功:

    最后完成验证例子,

    先进入目录/home/wl/program/ns-allinone-2.33/ns-2.33/tcl/ex,然后键入命令ns simple.tcl,并回车,如图所示:

      

    此时出现上面的网络模拟动画。至此,NS就算是安装好了。

  • 相关阅读:
    koa2 ctx.body 在 mysql query的回调函数中无法赋值的问题
    hibernate 实现多表连接查询
    Struts2 的国际化实现
    struts2 dwr There is no Action mapped for action ... 原因及解决方案
    Hibernate4.1配置数据库连接池 org.hibernate.service.jndi.JndiException:Unable to lookup JNDI name java:comp/env...
    Android 使用JSON格式与服务器交互 中文乱码问题解决
    Struts2 访问 Servlet API 的三种方法
    Struts2 输入校验
    hibernate4 和 spring3 整合注意事项 否则java.lang.NoSuchMethodError异常
    MySQL密码忘记的解决方案
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3067513.html
Copyright © 2011-2022 走看看