centos下安裝NS2

在進行網絡實驗時,經常需要進仿真實驗,這裏給大家提供一款非常強大的仿真工具:NS2。NS2是在UNIX系統上面開發的,因此UNIX系統和類UNIX系統是最佳平臺(當然windows系統也能安裝使用)。這裏我們主要介紹在類UNIX系統中的安裝(以centos爲例)。NS2主要有兩種安裝,一種是純手動安裝,需要依次安裝所有依賴包,對於手殘黨和新手黨來說無疑是個噩夢,所以爲了造福各位小夥伴們,當然就介紹最懶得安裝方式啦:通過allinone包安裝

1.安裝gcc和g++(注意yum源的g++跟debain的apt-get源的不同)

yum install gcc
yum install gcc-c++

2.安裝依賴

yum install libX11-devel*
yum install xorg-x11-proto-devel*
yum install libXt-devel*
yum install libXmu-devel*  

3、下載ns-allinone-2.35.tar.gz

wget http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz/download
tar -xzf ns-allinone-2.34.tar.gz

4.安裝NS2

 cd ns-allinone-2.34/    #進入ns2源碼目錄
 ./install               #一步操作,但是需要耐心等待

如果安裝成功,那麼將會出現下面的信息
Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.5.10: /home/ivan/Downloads/ns-allinone-2.35/{bin,include,lib}
tk8.5.10: /home/ivan/Downloads/ns-allinone-2.35/{bin,include,lib}
otcl: /home/ivan/Downloads/ns-allinone-2.35/otcl-1.14
tclcl: /home/ivan/Downloads/ns-allinone-2.35/tclcl-1.20
ns: /home/ivan/Downloads/ns-allinone-2.35/ns-2.35/ns
nam: /home/ivan/Downloads/ns-allinone-2.35/nam-1.15/nam
xgraph: /home/ivan/Downloads/ns-allinone-2.35/xgraph-12.2
gt-itm: /home/ivan/Downloads/ns-allinone-2.35/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns

當然這並沒有完成,你會發現除了上面這些信息外,還有其他信息:

Please put /home/ivan/Downloads/ns-allinone-2.35/bin:/home/ivan/Downloads/ns-allinone-2.35/tcl8.5.10/unix:/home/ivan/Downloads/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/ivan/Downloads/ns-allinone-2.35/otcl-1.14, /home/ivan/Downloads/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
If you are using sh, you can set it like:
export LD_LIBRARY_PATH=

(2) You MUST put /home/ivan/Downloads/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.

5、注意這些提示信息,網上很多教程都說,將上面提及的幾個環境變量加入到/home/username/.bashrc文件中,這樣做確實也沒一點問題。可問題是如果你是系統管理,搭好的環境要給研究所或全公司所有的同事使用的話,將上述三個環境變量添加到/etc/profile文件中不失爲一種很簡便省事的方法。

6、切換到ns-allinone-2.35/ns-2.35/tcl/ex目錄下,然後執行:

ns simple.tcl

這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章