1.安装 Sun xVM VirtualBox。
2.建立New Virtual Machine,用“ubuntu-8.04.1-desktop-i386.iso”安装Ubuntu8.04;(Ubuntu8.04可到http://www.ubuntu.org.cn/products/GetUbuntu下载)。
3.建立VM tools。
4.升级Ubuntu8.04。
以上因人而异
5.下载ns-allinone-2.33.tar.gz。(下载地址http://downloads.sourceforge.net/nsnam/ns-allinone-2.33.tar.gz?modtime=1206990403&big_mirror=0)。
6.复制“ns-allinone-2.33.tar.gz”到 /home/”your username”。我的username为neo
7.安装NS2
8.进入终端:输入sudo -i切换到root账号。
apt-get install build-essential
(for gcc and some essential)
apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev
(for tcl and tk)
apt-get install libxmu-dev
(for nam)
9.cd /home/”your username”
tar xvfz ns-allinone-2.33.tar.gz
(解压 ns-allinone-2.33.tar.gz) 可以直接右击压缩文件 Extract Here 进行解压
10.cd ns-allinone-2.33 解压后的路径名称(我的是caoxu)
./install
(安装 ns-allinone-2.33)
11.Wait a while。你将会看到如下信息!
Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.4.18: /home/tnt/ns-allinone-2.33/{binincludelib}
tk8.4.18: /home/tnt/ns-allinone-2.33/{binincludelib}
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.
12.cd ..
仔细看这个命令,表示返回到上一层目录,也就是你的 /home/”your username” ,不要敲错,目录是不能错滴!
gedit .bashrc
在文件最后编辑如下信息
export PATH=$PATH:/home/”your username”/ns-allinone-2.33/bin:/home/”your username”/ns-allinone-2.33/tcl8.4.18/unix:/home/”your username”/ns-allinone-2.33/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/”your username”/ns-allinone-2.33/otcl-1.13:/home/”your username”/ns-allinone-2.33/lib
export TCL_LIBRARY=$TCL_LIBRARY:/home/”your username”/ns-allinone-2.33/tcl8.4.18/library
中间用冒号隔开
路径的设置相当重要,安装的时候错了好几次(比如permission denied 或者 找不到路径,打不开nam……),现把源文件贴出来(我自己机子上的):
修改完后进行重载 source .bashrc
以下全部无关紧要,有空玩玩也可以
13.现在你可以log-out Ubuntu以便重载环境变量。
14.验证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
15. sudo apt-get install gawk
(for gawk)
16. sudo apt-get install gnuplot
(for gnuplot)
17.结束,OK。