转:ubuntu8.04下安装ns2

转个贴子,最近要用ns2做仿真。

自己实践了一下在linux下安装ns2,很顺利;

默认安装好的xubuntu 8.04下:

http://jaist.dl.sourceforge.net/sourceforge/nsnam/http://sourceforge.net/project/s ... 3&package_id=169689等地方下载ns-allinone-2.33.tar.gz

因为ubuntu的source没有ns2;
# wget -c url;

下载过程中可以安装相关的库等:
# sudo apt-get install build-essential
# sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev
# sduo apt-get install libxmu-dev libxmu-headers

可以把解压缩后的源码放到欲安装的位置。例如:

# sudo mkdir /usr/local/NS2
# tar xvfz ns-allinone-2.33.tar.gz
# sudo mv ns-allinone-2.33/* /usr/local/NS2
# cd NS2
# sudo ./install

安装完后,注意提示:
IMPORTANT NOTICES:

(1) You MUST put /usr/local/NS2/otcl-1.13, /usr/local/NS2/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 /usr/local/NS2/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.33; ./validate

可以在shell下添加更新环境变量,或者在~/.bashrc尾部添加:

export PATH=$PATH:/usr/local/NS2/bin:/usr/local/NS2/tcl8.4.184/unix:/usr/local/NS2/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/NS2/otcl-1.13:/usr/local/NS2/lib
export TCL_LIBRARY=$TCL_LIBRARY:/usr/local/NS2/tcl8.4.18/library

对于是.cshrc,方式为:

set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/X11R6/bin
$HOME/bin /usr/local/NS2/bin /usr/local/NS2/tcl8.4.18/unix /usr/local/NS2/tk8.4.18/unix)

setenv LD_LIBRARY_PATH /usr/local/NS2/otcl-1.13:/usr/local/NS2/lib
setenv TCL_LIBRARY /usr/local/NS2/tcl8.4.18/library

做验证安装情况:

# cd /usr/local/NS2/ns-2.31
# ./validate

验证OK;

#ns
%

......ok......

你可能感兴趣的:(ubuntu)