ubuntu12.04安装ns.doc_第1页
ubuntu12.04安装ns.doc_第2页
ubuntu12.04安装ns.doc_第3页
ubuntu12.04安装ns.doc_第4页
ubuntu12.04安装ns.doc_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Ubuntu装ns2.351、下载ns2.3.5ns2.3.5 下载地址:/detail/sxsj333/6257231官方下载地址:/nsnam/ns/ns-build.html2、通过虚拟机(Vmware等)或直接安装双系统Ubuntu12.04就不赘述了3、解压ns-allinone-2.35.tar.gz假设将解压文件ns-allinone-2.35放在Home目录下。cdns-allinone-2.35然后先安装好依赖包 以免后面报错。sudo apt-get install libx11-devsudo apt-get install libXt-devsudo apt-get install g+安装好后,开始安装,输入./install耐心等待安装过程。安装完成后,cd ns2.35./validate4、配置环境变量gedit /.bashrcplain view plaincopyprint?1. exportNS_HOME=/Home/ns-allinone-2.352. exportPATH=$NS_HOME/nam-1.15:$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$NS_HOME/bin:$PATH3. exportLD_LIBRARY_PATH=$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$NS_HOME/otcl-1.14:$NS_HOME/lib:$LD_LIBRARY_PATH4. exportTCL_LIBRARY=$NS_HOME/tcl8.5.10/libraryexport NS_HOME=/Home/ns-allinone-2.35export PATH=$NS_HOME/nam-1.15:$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$NS_HOME/bin:$PATHexport LD_LIBRARY_PATH=$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$NS_HOME/otcl-1.14:$NS_HOME/lib:$LD_LIBRARY_PATHexport TCL_LIBRARY=$NS_HOME/tcl8.5.10/library5、最后验证ns。在控制台输入ns%显示安装成功。6、运行例子时,第一次有时有提示错误,一般会有提示,提示安装nam或者ns2,按照要求装好就可以了。sudo apt-get install namsudo apt-get install ns2如果报错可以先使用sudo apt-get update/Ubuntu 12.04安装ns-2.34环境:一、下载ns-allinone-2.34。原版本下载:点此下载。二、安装X Windows的开发包和g+编译器在终端输入如下命令:如果还是没有成功安装的话,可以先安装这些软件包。sudo apt-get install build-essentialsudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-devsudo apt-get install libxmu-dev libxmu-headerssudo apt-get install xorg-dev g+xgraphsudo apt-get install g+-4.4三、修改otcl的configure文件然后解压ns-allinone-2.34.tar.gz,放到你指定的目录。检查你的gcc版本,如果gcc版本大于4.0(大部分人的都是,建议直接改),要在执行./install之前作出一些修改。gcc4.0版本以前是用ld-share来生成共享库的,但是到了4.0以上的版本,这个命令改为了gcc-share。修改命令如下:cdns-allinone-2.34/otcl-1.13sudogedit configure.in 把77行处的 SHLIB_LD=ld-shared改为SHLIB_LD=gcc-shared保存退出,然后sudogedit configure 把6304行(Ctrl+i跳到6304行)的SHLIB_LD=ld-shared 改为 SHLIB_LD=gcc-shared 保存退出,然后在终端中cd 到ns-allinone-2.34目录下,然后输入 ./install ,进行安装laycherubuntu:/ns-allinone-2.34$ ./instal四、出现问题补充=错误一:安装NS2.34过程中出现如下的错误:tools/ranvar.cc: In member function virtual doubleGammaRandomVariable:value():tools/ranvar.cc:219:70: error: cannot call constructorGammaRandomVariable:GammaRandomVariable directlytools/ranvar.cc:219:70:error:for a function-stylecast, remove the redundant :GammaRandomVariablemake: * tools/ranvar.o错误1Ns make failed!See /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.=错误二:In fileincluded from mac/mac-802_11Ext.cc:66:0:mac/mac-802_11Ext.h: In member functionu_int32_t PHY_MIBExt:getHdrLen11():mac/mac-802_11Ext.h:175:19: error: expectedprimary-expression before structmac/mac-802_11Ext.h:175:41: error: dh_body wasnot declared in this scopemac/mac-802_11Ext.h:175:51: error: offsetof wasnot declared in this scopemac/mac-802_11Ext.h:177:3: warning: controlreaches end of non-void function -Wreturn-typemake: *mac/mac-802_11Ext.o Error 1Ns makefailed!下面是网上找得关于本问题的解决方案:If you get error like:mac/mac-802_11Ext.h: In member function u_int32_tPHY_MIBExt:getHdrLen11():mac/mac-802_11Ext.h:176:19: error: expected primary-expressionbefore structmac/mac-802_11Ext.h:176:41: error: dh_body was not declared inthis scopemac/mac-802_11Ext.h:176:51: error: offsetof was not declared inthis scopeopen that file and add#include to the header files.在ns-allinone-2.34ns-2.34macmac-802_11Ext.h文件添加#include然后重新安装,就OK了。=错误三:mobile/nakagami.cc: In member function virtual doubleNakagami:Pr(PacketStamp*, PacketStamp*, WirelessPhy*):mobile/nakagami.cc:183:73: error: cannot call constructorErlangRandomVariable:ErlangRandomVariable directlymobile/nakagami.cc:183:73:error:for a function-stylecast, remove the redundant :ErlangRandomVariablemobile/nakagami.cc:185:67: error: cannot call constructorGammaRandomVariable:GammaRandomVariable directlymobile/nakagami.cc:185:67:error:for a function-stylecast, remove the redundant :GammaRandomVariablemake: * mobile/nakagami.o错误1Ns make failed!See /nsnam/ns/ns-problems.html forproblems解决方法:在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安装,再次出现同类问题时,仿照此次解决方法,找到对应的文件和行数,修改即可。直到安装成功。=五、设置全局路径变量。安装成功后,会出现如下图所示的文字,该部分提示你必须设置三个全局变量PATH、LD_LIBRARY_PATH、TCL_LIBRARY。laycherubuntu:/ns-allinone-2.34$ cd (回到home目录下)laycherubuntu:$ vim .bashrc (用vim编辑器编辑文件.bashrc,如果没有vim,可以用gedit或者vi)在该文件的最后一行下插入如下字段。export PATH=$PATH:/ns-allinone-2.34/bin:/home/laycher/ns-allinone-2.34/tcl8.4.18/unix:/home/laycher/ns-allinone-2.34/tk8.4.18/unixexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/laycher/ns-allinone-2.34/otcl-1.13:/home/laycher/ns-allinone-2.34/libexport TCL_LIBRARY=$TCL_LIBRARY:/home/laycher/ns-alllinone-2.34/tcl8.4.18/library每一句export为一行,共三行,export和PATH之间有一个空格,后面部分不要用任何字符隔开。每个路径用“:”隔开。“”相当于/home/laycher。上面的laycher用户名改为自己的。如果安装ns低版本的,请自行修改相应的版本号。六、验证(测试) (1)打开一个新的终端 (2)输入ns并回车 $ns (如果正常,会出现%操作提示符,如果显示还没有安装ns2,可以先安装nam,再测试ns) (3)输入一段测试用的Tcl脚本代码进行测试 %puts Hello World (输出Hello World字符串) Hello World (如果正确,会显示Hello World) % (然后跳到下一个%提示符等待下一条指令输入)=安装nam cd ns-allinone-2.34/nam-1.14 ./configure make sudo make install (至此,nam安装好)在终端中输入nam命令,弹出nam界面则说明nam安装好了到此ns2终于安装好!%安装过程:首先介绍下软件安装的环境概况,这点很重要,通过我的安装发现,好多安装过程中的错误,很多情况并不是因为方法的问题,而是因为安装环境跟文章介绍地有区别,导致gcc/g+等编译器的版本不用而出现这样那样的编译错误,导致最终的安装不成功,从而花费很多时间去找解决方法!后来我又再别的机器上安装过一遍,时间只花了30分钟(要知道原来用了7天的时间)。* 系统安装环境 操作系统:Ubuntu 9.04gcc版本:3.4.6 (Ubuntu 3.4.6-8ubuntu2) g+版本:4.0.3 (Ubuntu 4.0.3-1ubuntu5)NS2版本:ns-allinone-2.29 *相应软件下载地址:Ubuntu9.04:官方网站: 各大校园BT:晨光/ 六维/ns-allinone-2.29:/nsnam/dist/找到ns-allinone-2.29.tar.gz(65MB)下载*安装步骤:1.安装gcc-3.4 or gcc-4.0 (maybe your will update your sources.list)$sudo apt-getgcc-3.4然后就等着它地安装;如果提示说找不到此软件,说明你的源里面没有此版本的软件,这就需要你去更新源文件sources.list,方法如下: (1)备份原始sources.list$sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup (2)更新sources.list$sudo apt-getupdate 耐心等待几分钟 (3)等你更新完sources.list后,安装一些软件时,可能回碰到如下错误:Reading package lists. Error! E: Dynamic MMap ranoutof room. Please increase the size of APT:Cache-Limit. Current value: 25165824. (man 5 apt.conf)|E: Error occurredwhileprocessing epic4-help (NewFileDesc2) E: Problem with MergeList /var/lib/apt/lists/_ubuntu_dists_jaunty_universe_binary-i386_Packages E: The package lists or status file could not be parsed or opened. 这说明需要用来储存信息的cache空间不够大,所以我们需要将它设置的大一些,比如33MB。设置方法如下:$cd /etc/apt/apt.conf.d $sudo gedit user0 在打开地user0文件里输入以下信息(里面的数字可以再大些,如果还是出现上述问题):APT:Cache-Limit33554432; 然后再re-install$./install2.安装几个库文件:(1)安裝gcc,make相关库文件$sudo apt-getinstall build-essential(2)安裝tk,tcl相关库文件$sudo apt-getinstall tcl8.4$sudo apt-getinstall tcl8.4-dev$sudo apt-getinstall tk8.4$sudo apt-getinstall tk8.4-dev(3)安裝nam相关库文件$sudo apt-getinstall libxmu-dev3.ns2.29的安装 安装ns-allinone-2.29.tar.gz,注意此压缩包中的文件有错,安装之前修改ns-allinone-2.29nam-1.11agent.h文件第73行NULL为0,否则会出现“找不到NAM命令”的错误信息。$tar -xzvf ns-allinone-2.29.tar.gz$cd ns-allinone-2.29$./install如果出现如下错误:Syntax error: Unterminated quotedstringns2解决方法:(1)查找所有含有字段system=MP-RAS的文件,对其进行编辑,将system=MP-RAS-awk print $3 /etc/.relid 改为system=MP-RAS-awk print $3 /etc/.relid;$grep -Rsystem=MP-RAS* | sort | uniq(4)重新install$./install可能又会出现如下错误:./sctp/sctp.h:564: warning: typedef was ignoredinthisdeclaration./sctp/sctp.h:571: warning: typedef was ignoredinthisdeclaration./sctp/sctp.h:577: warning: typedef was ignoredinthisdeclaration./sctp/sctp.h:705: error: extra qualification SctpAgent: on member DumpSendBuffertrace/trace.cc:185: warning: deprecated conversion fromstringconstant to char*trace/trace.cc:185: warning: deprecated conversion fromstringconstant to char*trace/trace.cc:185: warning: deprecated conversion fromstringconstant to char*trace/trace.cc:185: warning: deprecated conversion fromstringconstant to char*trace/trace.cc:185: warning: deprecated conversion fromstringconstant to char*make: * trace/trace.o Error 1解决方法:这可能是由于gcc/g+版本过高引起的,对gcc版本进行降级,可以安装 gcc-3.4 or gcc-4.0 & g+-4.0,方法点击查询当前系统使用的gcc、g+版本命令:1. $gcc -v2. $g+ -v如果一切安装顺利的话,会出现以下相似信息:Nam has been installed successfully.Please compile your gt-itm & sgb2ns separately.Ns-allinone package has been installed successfully.Here are the installation places:tcl8.4.11: /home/ys/ns2/ns-allinone-2.29/bin,include,libtk8.4.11:/home/ys/ns2/ns-allinone-2.29/bin,include,libotcl:/home/ys/ns2/ns-allinone-2.29/otcl-1.11tclcl:/home/ys/ns2/ns-allinone-2.29/tclcl-1.17ns:/home/ys/ns2/ns-allinone-2.29/ns-2.29/nsnam: /home/ys/ns2/ns-allinone-2.29/nam-1.11/namxgraph: /home/ys/ns2/ns-allinone-2.29/xgraph-12.1-Please put /home/ys/ns2/ns-allinone-2.29/bin:/home/ys/ns2/ns-allinone-2.29/tcl8.4.11/unix:/home/ys/ns2/ns-allinone-2.29/tk8.4.11/unixinto your PATH environment; so that youll be able to run itm/tclsh/wish/xgraph.IMPORTANT NOTICES:(1) You MUST put /home/ys/ns2/ns-allinone-2.29/otcl-1.11, /home/ys/ns2/ns-allinone-2.29/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 areusingcsh, you cansetit like:setenv LD_LIBRARY_PATH If you areusingsh, you cansetit like:export LD_LIBRARY_PATH=(2) You MUST put /home/ys/ns2/ns-allinone-2.29/tcl8.4.11/library into your TCL_LIBRARY environmentalvariable. Otherwise ns/nam will complain during startup.(3) OPTIONAL To save disk space, you can now delete directories tcl8.4.11 and tk8.4.11. They are now installed under /home/ys/ns2/ns-allinone-2.29/bin,include,libAfter these steps, you can now run the ns validation suite withcd ns-2.29; ./validateFor trouble shooting, please first read ns problems page /nsnam/ns/ns-problems.html. Also search the ns mailing list archiveforrelated posts.4.安装成功以后,提示要更改环境变量,运行$gedit/.bashrc 打开.bashrc文件后,在文件尾部加上以下内容export PATH=$PATH:/home/ys/ns2/ns-allinone-2.29/bin:/home/ys/ns2/ns-allinone-2.29/tcl8.4.11/unix:/home/ys/ns2/ns-allinone-2.29/tk8.4.11/unixexport LD_LIBRARY_PATH=/home/ys/ns2/ns-allinone-2.29/otcl-1.11, /home/ys/ns2/ns-allinone-2.29/lib: &LD_LIBRARY_PATHexport TCL_LIBRARY=/home/ys/ns2/ns-allinone-2.29/tcl8.4.11/library: &TCL_LIBRARY5.成功安装好ns2.29后,运行NS2自带的几个例程,看是否能够运行成功$cd /ns-allinone-2.29/ns-2.29/tcl/ex/$ns simple.tcl这里有可能出现下面的错误:ysubuntu:/ns2/ns-allinone-2.29/ns-2.29/tcl/ex$nam: code omitted because of length: noeve

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论