1.下载ns 2.33安装包
首先从网上下载ns 2.33 all in one安装包(http://nchc.dl.sourceforge.net/sourceforge/nsnam/ns-allinone-2.33.tar.gz),最好在sourceforge页面选择合适镜像进行下载(如澳大利亚的很快),下载完成后将其放在你想要存放的目录下。
之后在终端下解压:tar –xzvf ns-allinone-2.33.tar.gz,这样安装包内的文件就被解压到了该目录下。cd至该目录下。
2.必要的依赖包,一个都不能少
3. 安装ns 2.33
./install
安装过程耗时不少,若成功,最后显示:
Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.4.18: /home/tnt/ns-allinone-2.33/{bin,include,lib}
tk8.4.18: /home/tnt/ns-allinone-2.33/{bin,include,lib}
otcl: /home/tnt/ns-allinone-2.33/otcl-1.13
tclcl: /home/tnt/ns-allinone-2.33/tclcl-1.19
ns: /home/tnt/ns-allinone-2.33/ns-2.33/ns
nam: /home/tnt/ns-allinone-2.33/nam-1.13/nam
xgraph: /home/tnt/ns-allinone-2.33/xgraph-12.1
gt-itm: /home/tnt/ns-allinone-2.33/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns
Please put /home/tnt/ns-allinone-2.33/bin:/home/tnt/ns-allinone2.33/tcl8.4.18/unix:/home/tnt/ns-allinone-2.33/tk8.4.18/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.
IMPORTANT NOTICES:
(1) You MUST put /home/tnt/ns-allinone-2.33/otcl-1.13, /home/tnt/ns-allinone-2.33/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/tnt/ns-allinone-2.33/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
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.
4. 按照提示,配置环境变量
输入:gedit ~/.bashrc ,将下面的代码加入.bashrc 文件的尾部。
下面是代码例子: (改动相应的目录和版本号,其它的地方不要修改)
export PATH="$PATH:/home/nsuser/ns-allinone-2.33/bin:/home/nsuser/ns-allinone-2.33/tcl8.4.18/unix:/home/nsuser/ns-allinone-2.33/tk8.4.18/unix"
export LD_LIBRARY_PATH="$LD_LIBRARY:/home/nsuser/ns-allinone-2.33otcl-1.13:/home/nsuser/ns-allinone-2.33/lib"
export TCL_LIBRARY="$TCL_LIBRARY:/home/nsuser/ns-allinone-2.33/tcl8.4.18/library"
完成后,在终端中输入下面代码: source ~/.bashrc 应用刚才加入的环境变量。
5. 输入:ns
若出现提示符%,表示ns安装成功,
如果出现这样的错误:你在终端下键入“ns”,可能会出现下面的错误提示: The program 'ns' is currently not installed. You can install it by typing: sudo apt-get install host '''(不要安装host)''' Make sure you have the 'universe' component enabled bash: ns: command not found
这是因为你的环境变量尚未设置好。确定你的~/.bashrc文件设置正确,并被写入进~ /.bashrc中了,然后重启电脑。
6. 还可以验证NS2。进入终端输入cd /ns-allinone-2.33/ns-2.33,./validate(这可能会花相当相当长一段时间)。
验证结束你将会看到如下信息:
These messages are NOT errors and can be ignored:
warning: using backward compatibility mode
This test is not implemented in backward compatibility mode
validate overall report: all tests passed
7. sudo apt-get install gawk
(for gawk)
sudo apt-get install gnuplot
(for gnuplot)
8.调试工具tcldebug的安装:
参考:http://nsnam.isi.edu/nsnam/index.php?title=Installing_tcl-debug_for_ns-allinone-2.31&redirect=no
1).下载 tcl-debug( 地址 http://expect.nist.gov/tcl-debug/tcl-debug.tar.gz),以版本2.33为例,解压到ns-allinone-2.33目录下面。
2).
$ cd ~/ns-allinone-2.33/tcl-debug-2.0$ $ ./configure --with-tcl=/home/pengkuny/ns-allinone-2.33/tcl8.4.18/unix/ #配置并且编译tcl-debug$ make3).$ cd ~/ns-allinone-2.33/ns-2.33$ ./configure --with-tcldebug #重新配置NS-2以便启用tcl-debug$ make clean #删除以前的编译纪录 $ make #重新编译NS-2