论文已接近尾声了,现在正开始用 ns作为模拟实验的平台,因而把ns装好成了我的必修之路。由于是新手,上网找了不少资料,但今我失望是的,很多文章都只是介绍如何在win+cygwin的平台下安装ns的。现在给后来者更好的参考,我把在linux9.0下的安装过程写出来,希望对大家有帮助。
下载ns
http://www.isi.edu/nsnam/dist/ns-allinone-2.29.tar.gz,在这个URL中可以下载到ns2.29版本,同时该网站提供了新的版本,有需要的朋友可以查看最新版本并下载。需要说明的一点是allinone方式是比较方便的,把ns的所有组件下载,并且一次性安装,给初学者带来了不省的方便。
解压
用如下命令进行解压即可:tar -xzvf ns-allinone-2.29.tar.gz,解压完成后,会在当前目录下生成ns-allinone-2.29子目前,用cd命令进入它,开始安装过程。
安装
安装过程很简单,运行./install即可。安装过程会比较久,请大家耐心等待,因为离成功只有一步之差了。安装完成后,系统出现如下的提示:
Please put /home/lyt/ns/ns-allinone-2.29/bin:/home/lyt/ns/ns-allinone-2.29/tcl8.4.11/unix:/home/lyt/ns/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/lyt/ns/ns-allinone-2.29/otcl-1.11, /home/lyt/ns/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/lyt/ns/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/lyt/ns/ns-allinone-2.29/{bin,include,lib}
After these steps, you can now run the ns validation suite with
cd ns-2.29; ./validate
配置
安装成功后,要对系统进行一点简单的配置才可以正常运行ns的。其实配置是根据安装完成后给出的提示进行的,方法如下:
假定解压文件放在/home/lyt/ns/目录下,打开当前用户目录下的.bashrc文件(如/home/lyt/.bashrc文件,lyt为当前用户名)在文件未尾增加如下内容:
export PATH="$PATH:/home/lyt/ns/ns-allinone-2.29/bin:/home/lyt/ns/ns-allinone-2.29/tcl8.4.11/unix:/home/lyt/ns/ns-allinone-2.29/tk8.4.11/unix"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/lyt/ns/ns-allinone-2.9/otcl-1.11:/home/lyt/ns/ns-allinone-2.29/lib"
export TCL_LIBRARY="$TCL_LIBRARY:/home/lyt/ns/ns-allinone-2.29/tcl8.4.11/library"
然后再进入ns-allinone-2.29目录下的ns-2.29子目录,运行./validate即可验证你的安装和配置是否成功。如果没有成功,请不要灰心,请楚检查一次,肯定会成功的。至此,ns的安装已完成!
可以在命令行下输入ns试试看,如果出现%则说明你安装和配置成功了!感受你的NS之旅吧……