NS2安装与简单测试

安装采用VirtualBox + Ubuntu 12.04        /*username 代表自己的用户名*/

一、下载NS2

http://www.isi.edu/nsnam/ns/

下载ns-allinone-2.35

 放入/home/username/目录下 右击Extract Here或命令行解压

二、安装依赖文件

#sudo apt-get update    //更新所有系统需要更新软件
# sudo apt-get install build-essential    //安装依赖
# sudo apt-get install tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev    //8.5.10版本

# sduo apt-get install libxmu-dev libxmu-headers

三、安装NS2

cd /home/username/ns-allinone-2.35

./install

四、安装完成后提示:

IMPORTANT NOTICES:

(1) You MUST put /home/username/ns-allinone-2.35/otcl-1.14, /home/username/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
   If you are using sh, you can set it like:
       export LD_LIBRARY_PATH=

(2) You MUST put /home/username/ns-allinone-2.35/tcl8.5.10/library into your TCL_LIBRARY environmental
   variable. Otherwise ns/nam will complain during startup.

五、修改文件
cd ns-2.35; ./validate //可选

接着修改环境变量,到home目录
#gedit ~/.bashrc
在文件最后加入:

export PATH="$PATH:/home/username/ns-allinone-2.35/bin:/home/username/ns-allinone-2.35/tcl8.5.10/unix:/home/username/ns-allinone-2.35/tk8.5.10/unix"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/username/ns-allinone-2.35/otcl-1.14:/home/username/ns-allinone-2.35/lib"
export TCL_LIBRARY="$TCL_LIBRARY:home/username/ns-allinone-2.35/tcl8.5.10/library "

保存后在终端窗口输入ns,会提示安装ns2.

按着提示输入sudo apt-get install ns2

安装之后,再输入ns,出现%,则安装成功。

六、简单测试

进入http://nile.wpi.edu/NS/下载的ns-simple.tcl目录

输入ns ns-simple.tcl

运行成功。