转自: http://hi.baidu.com/_dragonwarrior/blog/item/ba462fdc070fde43ccbf1a9e.html

Ubuntu 10.04 下 安装 NS2.30 

1. NS2下载

在OpenSource中search  NS2.30

我下载的版本是NS2.30, 下载的文件为ns-allinone-2.30.tar.gz。

下载完后将它解压缩到主文件夹下(我的是 /home/Soft/ns2):

tar xvfz ns-allinone-2.30.tar.gz

2. 需要用到的软件包

build-essential

tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev

libxmu-dev

3. 安装

cd/home/nuaa/Soft/ns-allinone-2.30

sudo ./install

4. 出错处理

1).

ld -shared -olibotcl.so otcl.o

otcl.o: Infunction `OTclDispatch':

/home/yanna/ns-allinone-2.30/otcl-1.12/otcl.c:495:undefined reference to `__stack_chk_fail_local'

otcl.o: Infunction `Otcl_Init':

/home/yanna/ns-allinone-2.30/otcl-1.12/otcl.c:2284:undefined reference to `__stack_chk_fail_local'

ld: libotcl.so:hidden symbol `__stack_chk_fail_local' isn't defined

ld: final linkfailed: Nonrepresentable section on output

make: ***[libotcl.so] 错误 1cd ns-2.30;./validate

otcl-1.12 makefailed! Exiting ...

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

在官网上有解决方案,应该是个BUG,会在以后版本中解决:

otcl.o: In function `OTclDispatch':

/home/ns/ns-allinone-2.30/otcl/otcl.c:495:undefined reference to `__stack_chk_fail_local'

otcl.o: In function `Otcl_Init':

/home/ns/ns-allinone-2.30/otcl/otcl.c:2284:undefined reference to `__stack_chk_fail_local'

ld: libotcl.so: hidden symbol `__stack_chk_fail_local'isn't defined

ld: final link failed: Nonrepresentablesection on output

make: *** [libotcl.so] Error 1

This error is because the linker being usedis "ld -shared" instead of"gcc -shared".  If you edit one line in otcl-1.12/configure,and rerun install , it should work:

修改   /home/nuaa/Soft/ns2/ns-allinone-2.30/otcl-1.12/configure  文件

;;

Linux*)

SHLIB_CFLAGS="-fpic"

SHLIB_LD="ld-shared"   →   SHLIB_LD="gcc-shared"

SHLIB_SUFFIX=".so"

DL_LIBS="-ldl"

SHLD_FLAGS=""

This will be fixed in future revisions ofns-2.    改完后重新安装。

2).

Tcl.cc:In member function ‘void Tcl::eval(char*)’:
Tcl.cc:182: warning: deprecated conversion from string constant to ‘char*’
Tcl.cc: In member function ‘int TclObject::traceVar(const char*, TclObject*)’:
Tcl.cc:421: warning: deprecated conversion from string constant to ‘char*’
Tcl.cc: In static member function ‘static int TclClass::create_shadow(void*,Tcl_Interp*, int, const char**)’:
Tcl.cc:509: warning: deprecated conversion from string constant to ‘char*’
Tcl.cc:511: warning: deprecated conversion from string constant to ‘char*’
Tcl.cc: In static member function ‘static int TclClass::dispatch_instvar(void*,Tcl_Interp*, int, const char**)’:
Tcl.cc:566: error: invalid conversion from ‘const char*’ to ‘char*’
Tcl.cc:571: warning: deprecated conversion from string constant to ‘char*’
Tcl.cc: In member function ‘virtual void TclClass::bind()’:
Tcl.cc:603: warning: deprecated conversion from string constant to ‘char*’
Tcl.cc:605: warning: deprecated conversion from string constant to ‘char*’
make: *** [Tcl.o] 错误 1
tclcl-1.18 make failed! Exiting ...
*******************************************************原作者解决方法开始************************************************************

由于gcc版本过高引起的编译问题 gcc-4.4  --> gcc-4.3

1. sudo apt-get install gcc-4.3

安装了之后,系统之中就存在两个GCC版本4.4和4.3,可以通过ls命令查看:

1. ls /usr/bin/gcc*

2. /usr/bin/gcc  /usr/bin/gcc-4.3  /usr/bin/gcc-4.4  /usr/bin/gccbug-4.3

但是这时系统默认的GCC还是4.4版的,可以通过gcc -v查看版本号

设置GCC4.3和GCC4.4的可选项,在终端输入以下命令

1.  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40

2.  sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 30

现在设置GCC的默认版本,输入下面命令:

sudoupdate-alternatives --config gcc

我得到的结果:

There are 2choices for the alternative gcc (providing /usr/bin/gcc).

Selection   Path              Priority   Status

------------------------------------------------------------

* 0            /usr/bin/gcc-4.4   40       auto mode

1           /usr/bin/gcc-4.3   30        manual mode

2           /usr/bin/gcc-4.4   40        manual mode

然后输入“1”,再查看一下gcc的版本,已经变成4.3的了~~~~

同样对于g++也可以使用同样的方法从4.4高版本切换到4.3低版本。。。

*******************************************************原作者解决方法结束************************************************************

*******************************************************我的解决方法开始************************************************************

由于我按照上述步骤装了gcc-4.3的不行,又装了gcc-4.1的仍然不行,于是就干脆进到tclcl-1.18文件夹下查找原因,最终发现的确因为是编译器版本过高引起的,但是是由于g++版本过高,而不是gcc,解决步骤如下:

1. sudo apt-get install g++-4.1

2. ls /usr/bin/g++*

得到结果:

/usr/bin/g++  /usr/bin/g++-4.1  /usr/bin/g++-4.4

3. update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40

4. update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.1 30

5. sudo update-alternatives --config g++

得到结果:
  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/g++-4.4   40        auto mode
  1            /usr/bin/g++-4.1   30        manual mode
  2            /usr/bin/g++-4.4   40        manual mode
选择1即可

5. 配置环境变量

安装完成后会看到修改环境变量的提示:

Please put /home/nuaa/Soft/ns2/ns-allinone-2.30/bin,/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/unix,home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/unix"

into your PATH environment; so that you'llbe able to run itm/tclsh/wish/xgraph.

IMPORTANT NOTICES:

(1) You MUST put /home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/otcl-1.12,/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/lib

into your LD_LIBRARY_PATH environment variable.

Ifit 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 /home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/libraryinto your TCL_LIBRARY environmental

variable. Otherwise ns/nam will complain during startup.

After these steps, you can now run the nsvalidation suite with

cd ns-2.30; ./validate

For trouble shooting, please first read nsproblems page

http://www.isi.edu/nsnam/ns/ns-problems.html.Also search the ns mailing list archive

for related posts .

回到主文件夹,修改bash配置文件.bashrc:

sudo gedit .bashrc

在文件最后加上:

PATH="$PATH:/home/nuaa/Soft/ns2/ns-allinone-2.30/bin:/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/unix:/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/unix"

LD_LIBRARY_PATH="/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/otcl-1.12:/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/lib"

TCL_LIBRARY="$TCL_LIBRARY:/home/nuaa/Soft/ns2/ns-allinone-2.30/tcl8.4.13/library"

还得运行一个命令,为source .bashrc

6. 安装验证 

安装结束后的提示中也告诉我们如何验证是否正确安装:

cdns-2.30

./validate

另外,也可以打开一个新终端进行试运行:

输入ns,如果显示一个%则说明已正确安装。如果提示“command not found”则重新启动试试。

安装NS-2.28全过程一(包括所有可能遇到的问题)

NS2.28在Ubuntu7.10下的安装

安装包是ns-allinone-2.28.tar.gz。Ubuntu7.10内核是2.6.22-14.

首先sudo apt-get update

sudo apt-get install build-essential                        这是更新ubuntu

sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev          这是为安装NS做准备

sudo apt-get install libxmu-dev libxmu-headers              安装nam做准备

解压缩后,

输入:cd ns-allinone-2.28
  输入:ls -a 
  回车后就可以看到一个名字为install的文件. 
  然后在终端中输入:./install 
   OK,NS开始安装了
          然后waiting……

出现问题及解决方法

问题1

checking system version (for dynamic loading)... ./configure: 1: Syntax error: Unterminated quoted string

tcl8.3.2 configuration failed! Exiting ...

Tcl is not part of the ns project. Please see www.Scriptics.com

to see if they have a fix for your platform.

解决方法

分别进入以下目录:
tcl8.x.x/unix/tcl.m4.
tk8.x.x/unix/tcl.m4.
otcl-1.x/configure.in.
将这些文件里的system=MP-RAS-`awk ' { print $3 } '/tc/.relid'` 改为:
system=MP-RAS-`awk ' { print $3 } '/etc/.relid`

然后再在这三个目录下运行命令autoconf.每个目录下运行两次~

问题2

继续输入 ./install

./sctp/sctp.h:630: error: extra qualification ‘SctpAgent::’on member ‘DumpSendBuffer’ make: *** [trace/trace.o] Error 1

Ns make failed!

解决办法

将文件sctp.h里面第630行DumpSendBuffer函数前面的'SctpAgent::'去掉。

问题3

继续输入 ./install

./mobile/god.h:88: error: extra qualification ‘vector::’ on member ‘operator=’

./mobile/god.h:93: error: extra qualification ‘vector::’ on member ‘operator+=’

./mobile/god.h:98: error: extra qualification ‘vector::’ on member ‘operator==

./mobile/god.h:101: error: extra qualification ‘vector::’ on member ‘operator!=’

make: *** [src_rtg/sragent.o] Error 1

Ns make failed!

解决办法:
分别将这些文件里面的‘vector::'去掉。

问题 4

queue/cbq.cc:112: error: ISO C++ forbids declaration of ‘CBQueue’ with no type

queue/cbq.cc:112: error: expected ‘;’ before ‘*’ token

queue/cbq.cc: In member function ‘virtual int CBQueue::insert_class(CBQClass*)’:

queue/cbq.cc:488: error: ‘class CBQClass’ has no member named ‘cbq_’

queue/cbq.cc: In constructor ‘CBQClass::CBQClass()’:

queue/cbq.cc:805: error: class ‘CBQClass’ does not have any field named ‘cbq_’

queue/cbq.cc: In member function ‘virtual void CBQClass::recv(Packet*, Handler*)’:

queue/cbq.cc:850: error: ‘cbq_’ was not declared in this scope

queue/cbq.cc:856: error: ‘cbq_’ was not declared in this scope

queue/cbq.cc: In member function ‘void CBQClass::update(Packet*, double)’:

queue/cbq.cc:873: error: ‘cbq_’ was not declared in this scope

queue/cbq.cc: In member function ‘int CBQClass::desc_with_demand()’:

queue/cbq.cc:928: error: ‘cbq_’ was not declared in this scope

queue/cbq.cc: In member function ‘void CBQClass::newallot(double)’:

queue/cbq.cc:975: error: ‘cbq_’ was not declared in this scope

queue/cbq.cc: In member function ‘virtual int CBQClass::command(int, const char* const*)’:

queue/cbq.cc:1002: error: ‘cbq_’ was not declared in this scope

make: *** [queue/cbq.o] Error 1

Ns make failed!

解决办法

用补丁——
补丁的用法即找到相应文件后,找到相应的程序段,行列数为@@ ...... @@之间数字,手动把补丁程序段中前面带有“+”号的行添加到文件中,而将前面带有“-”号的行在文件中删除,这是很花费时间的一件事,要有耐心~~

(网上很多类似的补丁,但很少类似的补丁用法说明。我自己在这里也浪费了很多时间,后来慢慢摸索出来的,为了看明白还去找了些patch的说明来看,后来还是一个同学说的好,patch为后缀的补丁包其实是注明了在哪个文件中的什么地方添加什么程序段,减少什么程序段)

用如下补丁
--- cbq.cc.old 2006-08-31 11:42:09.000000000 -0300
+++ cbq.cc 2006-08-31 11:43:31.000000000 -0300

@@ -87,6 +87,8 @@

#define LEAF_LEVEL 1 /* level# for leaves *
#define POWEROFTWO 16
+class CBQueue;
+
class CBQClass : public Connector {
   public:
   friend class CBQueue;

问题5

./tora/tora_neighbor.h:72: error: ISO C++ forbids declaration of ‘toraAgent’ with no type

./tora/tora_neighbor.h:72: error: expected ‘;’ before ‘*’ token

make: *** [tora/tora.o] Error 1

Ns make failed!

解决办法:
用如下补丁——
--- tora_neighbor.h.old 2006-08-31 11:57:34.000000000 -0300
+++ tora_neighbor.h 2006-08-31 11:58:11.000000000 -0300
@@ -41,6 +41,8 @@

#ifndef __tora_neighbor_h__
#define __tora_neighbor_h__
  +class toraAgent;
  +
   enum LinkStatus {
   LINK_UP = 0x0001, // upstream
   LINK_DN = 0x0002, // downstream

问题6

dsr/dsragent.cc: In member function ‘void DSRAgent::handleFlowForwarding(SRPacket&, int)’:

dsr/dsragent.cc:804: error: ‘XmitFlowFailureCallback’ was not declared in this scope

dsr/dsragent.cc: In member function ‘void DSRAgent::sendOutPacketWithRoute(SRPacket&, bool, Time)’:

dsr/dsragent.cc:1361: error: ‘XmitFailureCallback’ was not declared in this scope

dsr/dsragent.cc:1362: error: ‘XmitFlowFailureCallback’ was not declared in this scope

dsr/dsragent.cc:1379: error: ‘XmitFailureCallback’ was not declared in this scope

make: *** [dsr/dsragent.o] Error 1

Ns make failed!

解决办法

打开       dsr/dsragent.cc 搜索XmitFlowFailureCallback和XmitFailureCallback,发现除了828、1385、1386、1403行之外,在文件后面还有这两个函数声明,把这两个函数声明移到文件前面

ns2 安装与问题集锦相关推荐

  1. Windows+Cygwin+NS2安装

    近来需要做无线网络仿真实验,老师让搭建ns2仿真环境.其过程可谓是崎岖,上网搜的时候发现大家在第一次装的时候都一样,不是一帆风顺的,毕竟不是点点点安装软件啊[笑哭]. 先说一下NS2吧,NS就是ns- ...

  2. ns2安装教程(ns2.35 Ubuntu16.04)

    //如果要安装olsr 请先将olsr模块导入在安装 //具体方法见olsr安装方法第一种 ns2 linux安装教程 Ubuntu16.04 1更新系统 sudo apt-get update #更 ...

  3. ns2安装详细过程与网络仿真

    ns2安装详细过程与网络仿真 博客分类: Networks TclLinuxUnixGCCVC++ 简单的说,NS-2是一个网络模拟器,所以经常被用到网络课的教学中. NS-2是OpenSource的 ...

  4. NS2安装笔记 - Ubuntu9.10

    转帖:http://blog.csdn.net/wuyanna1989/archive/2010/01/02/5119823.aspx 参考书推荐:<NS与网络模拟> - 徐雷鸣等 1. ...

  5. NS2安装笔记---SUSE Linux

    NS2的下载地址 http://www.isi.edu/nsnam/ns/ns-build.html NS2的安装分为2种 第一种是采用allinone包,因为NS2的依赖包有很多,要成功安装NS2需 ...

  6. Ubuntu中NS2安装详细教程

    前言: NS2是指 Network Simulator version 2,NS(Network Simulator) 是一种针对网络技术的源代码公开的.免费的软件模拟平台,研究人员使用它可以很容易的 ...

  7. ubuntu16.04 ns2安装教程

    一 到网站http://www.isi.edu/nsnam/ns/ns-build.html下载ns,如下图 下载完成后解压,比如我是解压到了/home/l用户名/ns/ 二 在命令行里进入管理员权限 ...

  8. Ubuntu16.04:NS2安装与入门实例

    NS2是一个全开源的比较成熟的网络模拟器,与之相对有的有商业付费软件OPNet.因为工作需要,所以对NS2进行了调研,安装并简单使用了一下,做个记录.NS2早在2011年就已经不维护了,这算是考古了. ...

  9. Ns2安装详细教程(Ubuntu)以及常见问题2019

    参考博客:https://blog.csdn.net/qiushye/article/details/53082096?tdsourcetag=s_pcqq_aiomsg 1.升级更新  sudo a ...

最新文章

  1. java 获得当月天数_java中 如何获取当月的天数、指定日期的月份天数详解
  2. 如何在前端生成二维码
  3. 【渝粤题库】国家开放大学2021春1349学前教育科研方法答案
  4. 求两个已排序单链表中相同的数据(C语言)
  5. MFC开发-MFC 树控件 将一棵树全部展开
  6. leetcode刷题:三数之和
  7. 查询oracle 数据库中回滚段中一个时间点被修改的表数据并还原表中原来数据
  8. 单电源运算放大器全波整流电路_电子电路识图从入门到精通,从零开始学电子电路...
  9. Django生命周期,FBV,CBV
  10. OC--Protocol 协议
  11. 人工势场法matlab讲解,传统人工势场法(matlab)
  12. 2017第十九届中国国际地面材料及铺装技术展览会会刊(参展商名录)
  13. html+css画虚线,实线
  14. Linux下scp的用法
  15. NPDCCH发送周期解析
  16. 【LabVIEW小技巧】LabVIEW自定义系统按钮时图片项设置说明
  17. Centos安装SVN服务端
  18. PMP考试冲刺计算专题
  19. 最大公因数等于 K 的子数组数目求解全过程
  20. 特殊字符url编码以后再解码后出现错误(not , cent, curren, pound)

热门文章

  1. 迭代Kalman滤波
  2. win10安装revit失败,怎么强力卸载删除注册表并重新安装
  3. 《那些年啊,那些事——一个程序员的奋斗史》——91
  4. Redis学习之路(八)封装Redis工具类
  5. 苹果App Store程序提交审核指南中文版
  6. 菜鸟学Android源码——Setting(1)
  7. python tkinter库引用tkk_Python之tkinter:调用python库的tkinter带你进入GUI世界(一)——Jason niu...
  8. 蓝桥杯模块学习10——串口通信(深夜学习——单片机)
  9. 戮力同心,精诚协作 Stibo Systems(思迪博)和点春科技正式签署战略合作伙伴协议
  10. rocket mq 用户名密码访问