在ubuntu 11.10下安装ns2-allinone-2.35.tar.gz

来源:互联网 发布:淘宝热销品牌排行榜 编辑:程序博客网 时间:2024/05/17 01:10

在ubuntu 11.10下安装ns2-allinone-2.35.tar.gz

 (2011-11-30 22:14:37)
转载
 分类: ubuntu
我是借鉴 http://hi.baidu.com/c00h00g/blog/item/c514d0856837e62366096e79.html 安装的ns2,由于刚刚安装,所以在这里再整理一下。安装过程很漫长大家一定要有耐心。

1.下载软件

      首先先下载ns-allinone-2.35.tar.gz (http://sourceforge.net/projects/nsnam/files/),将其放到你/home/wangtiantian/mysoft/ 下(wangtiantian是我的文件名,mysoft是我建立的一个文件夹)
通过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.准备工作做好后,开始安装软件

$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/wangtiantian/mysoft/ns-allinone-2.35/otcl-1.14, /home/wangtiantian/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/wangtiantian/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.配置环境变量

$sudo gedit .bashrc(这里一定要看清gedit和.bashrc之间有一个空格

在弹出来的窗口的文件末尾加入:(注意:下列代码中
wangtiantian/mysoft/是我的ns-allinone-2.35文件路径,要按照你自己的更改
export PATH=$PATH:/home/wangtiantian/mysoft/ns-allinone-2.35/bin:/home/wangtiantian/mysoft/ns-allinone-2.35/tcl8.4.18/unix:/home/wangtiantian/mysoft/ns-allinone-2.35/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/wangtiantian/mysoft/ns-allinone-2.35/otcl-1.13:/home/wangtiantian/mysoft/ns-allinone-2.35/lib

export TCL_LIBRARY=$TCL_LIBRARY:/home/wangtiantian/mysoft/ns-allinone-2.35/tcl8.4.18/library
 
保存退出。

5.验证测试

重新打开一个终端,输入ns并回车

$ns
(如果正常的话,会出现“%”操作提示符)

输入一段TCL脚本代码进行测试

%puts "Hello ns2"

Hello ns2

%


说明安装成功。真是不容易呀!