用户工具

站点工具


01-基础学习:课程:计算机网络:实验:ns2:ns2的安装

ns2的安装

以下引自ns2官方wiki:

Introduction

NS-2 is designed to run from on most UNIX based operating systems. It is possible to run NS-2 on Windows machines using Cygwin. If you don't have a UNIX install, you can also use a virtual linux machine and run that under Windows. VMWare has a free VMWare Player that allows you to download linux systems like Ubuntu and run them on your computer. You will need to make sure you have standard development packages like 'make' and 'gcc'.

Installing NS2 on UNIX Based System

Ok, you've got a development ready UNIX system. First, download a copy of ns-allinone-2.34.tar.gz. Then from the command prompt there, execute the following:

tar -xzf ns-allinone-2.34.tar.gz 
cd ns-allinone-2.34
./install

After a long wait and a whole lot of text, you should see the installation finish up with text like the following:

Nam has been installed successfully.
Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.4.11:      /home/pcraven/ns-allinone-2.29/{bin,include,lib}
tk8.4.11:               /home/pcraven/ns-allinone-2.29/{bin,include,lib}
otcl:           /home/pcraven/ns-allinone-2.29/otcl-1.11
tclcl:          /home/pcraven/ns-allinone-2.29/tclcl-1.17
ns:             /home/pcraven/ns-allinone-2.29/ns-2.29/ns
nam:    /home/pcraven/ns-allinone-2.29/nam-1.11/nam
xgraph: /home/pcraven/ns-allinone-2.29/xgraph-12.1
gt-itm:   /home/pcraven/ns-allinone-2.29/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns
 
----------------------------------------------------------------------------------
 
Please put /home/myusername/ns-allinone-2.29/bin:/home/myusername/ns-allinone-2.29/tcl8.4.11/unix:/home/myusername/ns-allinone-2.29/tk8.4.11/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.
 
IMPORTANT NOTICES:
 
(1) You MUST put /home/myusername/ns-allinone-2.29/otcl-1.11, /home/myusername/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 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/myusername/ns-allinone-2.29/tcl8.4.11/library into your TCL_LIBRARY environmental
    variable. 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/myusername/ns-allinone-2.29/{bin,include,lib}
 
After these steps, you can now run the ns validation suite with
cd ns-2.29; ./validate
 
For trouble shooting, please first read ns problems page 
http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive
for related posts.

At this point, you should follow the advice here and update your environment variables. You should also add ns-allinone-2.29/bin to you path. This has links to all the executables created by NS-2. Since the Tcl scripts may call these executables (like nam or xgraph), it is a good idea to have them in the path. You can test the installation by doing the following:

cd ns-2.29
./validate

Note that this validation takes a really long time. If it starts out ok, you probably have a good installation. At this point, you can see Getting Started with NS-2 .

安装时遇到的问题

使用vmware虚拟机,客户机为xubuntu 12.10,报错:

checking for X... no
checking for X11 header files... couldn't find any!
checking for X11 libraries... checking for XCreateWindow in -lXwindow... no
could not find any!  Using -lX11.
checking for main in -lXbsd... no
checking whether to try to use XScreenSaver... no
 
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no

安装x11

apt-get install libx11-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
将会安装下列额外的软件包:
  libpthread-stubs0 libpthread-stubs0-dev libx11-doc libxau-dev libxcb1-dev
  libxdmcp-dev x11proto-core-dev x11proto-input-dev x11proto-kb-dev
  xorg-sgml-doctools xtrans-dev
建议安装的软件包:
  libxcb-doc
下列【新】软件包将被安装:
  libpthread-stubs0 libpthread-stubs0-dev libx11-dev libx11-doc libxau-dev
  libxcb1-dev libxdmcp-dev x11proto-core-dev x11proto-input-dev
  x11proto-kb-dev xorg-sgml-doctools xtrans-dev
升级了 0 个软件包,新安装了 12 个软件包, 要卸载 0 个软件包,有 132 个软件包未被升级。
需要下载 4,739 kB 的软件包。
解压缩后会消耗掉 17.3 MB 的额外空间。
您希望继续执行吗?[Y/n] y

安装build-essential

 apt-get install build-essential
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
将会安装下列额外的软件包:
  dpkg-dev fakeroot g++ g++-4.7 libalgorithm-diff-perl
  libalgorithm-diff-xs-perl libalgorithm-merge-perl libstdc++6-4.7-dev
建议安装的软件包:
  debian-keyring g++-multilib g++-4.7-multilib gcc-4.7-doc libstdc++6-4.7-dbg
  libstdc++6-4.7-doc
下列【新】软件包将被安装:
  build-essential dpkg-dev fakeroot g++ g++-4.7 libalgorithm-diff-perl
  libalgorithm-diff-xs-perl libalgorithm-merge-perl libstdc++6-4.7-dev
升级了 0 个软件包,新安装了 9 个软件包, 要卸载 0 个软件包,有 132 个软件包未被升级。
需要下载 10.4 MB 的软件包。
解压缩后会消耗掉 29.7 MB 的额外空间。
您希望继续执行吗?[Y/n] 

报错:

can't find X includes

安装libxt-dev

apt-get install libxt-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
将会安装下列额外的软件包:
  libice-dev libsm-dev
建议安装的软件包:
  libice-doc libsm-doc libxt-doc
下列【新】软件包将被安装:
  libice-dev libsm-dev libxt-dev
升级了 0 个软件包,新安装了 3 个软件包, 要卸载 0 个软件包,有 132 个软件包未被升级。
需要下载 569 kB 的软件包。
解压缩后会消耗掉 1,634 kB 的额外空间。
您希望继续执行吗?[Y/n] 

仍然不能通过,百度之后:

第二步:在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"权限。

来自:http://www.linuxidc.com/Linux/2013-05/84032.htm
另见:http://www.cnblogs.com/watsonlong/archive/2011/03/31/2000852.html

错误关键词linkstate/ls.cc:396:28: required from here

linkstate/ls.h: In instantiation of ‘void LsMap<Key, T>::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<int, LsIdSeq, std::less<int>, std::allocator<std::pair<const int, LsIdSeq> > >’ are not found by unqualified lookup
linkstate/ls.h:137:20: note: use ‘this->erase’ instead
make: *** [linkstate/ls.o] Error 1

解决方案:

修改ls文件:ns-2.35/linkstate/ls.h 
 
第137行
 
void eraseAll() { erase(baseMap::begin(), baseMap::end()); }
 
改为:void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
 
然后重新 ./install

参见:http://blog.csdn.net/fengqiyunran/article/details/8900219

安装成功

此页面22:59建立,随后开始安装,安装结束0:57,真折腾人!东哥不欺我也!之前小看ns2了@_@。。。

Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.5.10:	/home/vps/ns-allinone-2.35/{bin,include,lib}
tk8.5.10:		/home/vps/ns-allinone-2.35/{bin,include,lib}
otcl:		/home/vps/ns-allinone-2.35/otcl-1.14
tclcl:		/home/vps/ns-allinone-2.35/tclcl-1.20
ns:		/home/vps/ns-allinone-2.35/ns-2.35/ns
nam:	/home/vps/ns-allinone-2.35/nam-1.15/nam
xgraph:	/home/vps/ns-allinone-2.35/xgraph-12.2
gt-itm:   /home/vps/ns-allinone-2.35/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns
 
----------------------------------------------------------------------------------
 
Please put /home/vps/ns-allinone-2.35/bin:/home/vps/ns-allinone-2.35/tcl8.5.10/unix:/home/vps/ns-allinone-2.35/tk8.5.10/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.
 
IMPORTANT NOTICES:
 
(1) You MUST put /home/vps/ns-allinone-2.35/otcl-1.14, /home/vps/ns-allinone-2.35/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 /home/vps/ns-allinone-2.35/tcl8.5.10/library into your TCL_LIBRARY environmental
    variable. Otherwise ns/nam will complain during startup.
 
 
After these steps, you can now run the ns validation suite with
cd ns-2.35; ./validate
 
For trouble shooting, please first read ns problems page 
http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive
for related posts.
01-基础学习/课程/计算机网络/实验/ns2/ns2的安装.txt · 最后更改: 2020/04/07 06:34 由 annhe