在ubuntu下安装ns2-allinone-2.35.tar.gz
1.软件下载
首先先下载ns-allinone-2.35.tar.gz (下载路径http://sourceforge.net/projects/nsnam/files/),将其放到你/home/mysoft/ 下(mysoft是我建立的一个文件夹)(在ubuntu安装VMware Tools工具前提下,可以直接从windows系统下复制到虚拟机的Linux系统下)
通过ctrl+alt+T打开终端,在其中输入
cd mysoft <回车>
tar zxvf ns-allinone-2.35.tar.gz <回车>
将ns2.35解压到当前目录下
2.安装前的准备工作
通过ctrl+alt+T打开终端,在其中输入
cd mysoft <回车>
tar zxvf ns-allinone-2.35.tar.gz <回车>
将ns2.35解压到当前目录下
2.安装前的准备工作
为了更好的安装ns2,需要更新ubuntu系统文件,在终端中输入命令
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
首次采用sudo时,需要用户密码,也就是安装ubuntu时设置的。还需要进行一些package的安装,输入命令
sudo apt-get install build-essential
sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev
sudo apt-get install libxmu-dev libxmu-headers
3.准备工作做好后,开始安装软件
3.准备工作做好后,开始安装软件
$cd ns-allinone-2.35
$./install (别忘了前面的那个点)
安装过程需要一会。安装正确的话应该可以看到:
Please put /home/wangtiantian/mysoft/ns-allinone-2.35/bin:/home/wangtiantian/mysoft/ns-allinone-2.35/tcl8.5.10/unix:/home/wangtiantian/mysoft/ns-allinone-2.35/tk8.5.10/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.
IMPORTANT NOTICES:
(1) You MUST put /home/mysoft/ns-allinone-2.35/otcl-1.14, /home/mysoft/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 <paths>
If you are using sh, you can set it like:
export LD_LIBRARY_PATH=<paths>
(2) You MUST put /home/mysoft/ns-allinone-2.35/tcl8.5.10/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.35; ./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.配置环境变量(注意路径安装第3步中红字部分)
$sudo gedit .bashrc(这里一定要看清gedit和.bashrc之间有一个空格)
在弹出来的窗口的文件末尾加入:(注意:下列代码中mysoft/是我的ns-allinone-2.35文件路径,要按照你自己的更改)
export PATH=$PATH:/home/mysoft/ns-allinone-2.35/bin:/home/mysoft/ns-allinone-2.35/tcl8.4.18/unix:/home/mysoft/ns-allinone-2.35/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mysoft/ns-allinone-2.35/otcl-1.13:/home/mysoft/ns-allinone-2.35/lib
export TCL_LIBRARY=$TCL_LIBRARY:/home/mysoft/ns-allinone-2.35/tcl8.4.18/library
保存退出。
5.验证测试
重新打开一个终端,输入ns并回车
$ns
(如果正常的话,会出现“%”操作提示符)
输入一段TCL脚本代码进行测试
%puts "Hello ns2"
Hello ns2
%
说明安装成功。