1、下载ns(network simulation)安装包
到网站http://www.isi.edu/nsnam/ns/ns-build.html下载最新的ns-allinone套件,现在使用的是ns-allinone-2.34.tar.gz
2、配置系统环境
安装依赖包
#yum install gcc-c++ #yum install libX11-devel #yum install xorg-x11-proto-devel #yum install libXt-devel #yum install libXmu-devel
3、安装ns-allinone-2.34.tar.gz
3.1、安装目录为:主文件夹”/home/jean"(用户名为jean)
#解压 sudo tar xvfz ns-allinone-2.34.tar.gz #进入tk8.4.18文件夹 cd ns-allinone-2.34/tk8.4.18/ #wget用ftp下载包 wget ftp://ftp.swin.edu.au/gentoo-portage...astevent.patch #重新安装 patch -p0 < tk-8.4-lastevent.patch #返回ns-allinone-2.34 cd ../ #设定CC为需要的gcc版本,和CXX为需要的g++版本(ns-allinone-2.34里面的C语言编译版本是4.0以下的) export CC=gcc34 CXX=g++34 #安装 ./install
最后出现:
IMPORTANT NOTICES: (1) You MUST put /home/jean/ns-allinone-2.34/otcl-1.13, /home/jean/ns-allinone-2.34/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/jean/ns-allinone-2.34/tcl8.4.18/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.34; ./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
4、设置环境变量
#在/home/jean目录下,运行
sudo gedit .bashrc
#在第8行输入
PATH="$PATH:/home/jean/ns-allinone-2.34/bin:/home/jean/ns-allinone-2.34/tcl8.4.18/unix:/home/jean/ns-allinone-2.34/tk8.4.18/unix"
LD_LIBRARY_PATH="/home/jean/ns-allinone-2.34/otcl-1.13:/home/jean/ns-allinone-2.34/lib"
TCL_LIBRARY="$TCL_LIBRARY:/home/jean/ns-allinone-2.34/tcl8.4.18/library"
如图:
5、运行
打开新的终端:输入
ns
若出现%号,则安装成功
用一个例子试试:
ns ns-allinone-2.34/ns-2.34/tcl/ex/simple.tcl
出现如图所示: