獻給同樣為了ns2抓破了頭皮的同志們。
1, get started:
2, download all in once: ns-allinonce-2.35.tar.gz
3, tar zxvf ns-allinonce-2.35.tar.gz;
./install
4, tk8.5.10安裝出錯。(tk最新版本是8.6.1。)
in file included from /home/chn/desktop/ns-allinone-2.35/tk8.5.10/unix/../generic/tkint.h:19,
from /home/chn/desktop/ns-allinone-2.35/tk8.5.10/unix/../generic/tk3d.c:14:
/home/chn/desktop/ns-allinone-2.35/tk8.5.10/unix/../generic/tk.h:76:23: error: x11/xlib.h: no such file or directory
5, 網上查到:若在ubuntu上安裝ns2要先裝幾個庫檔案:
(1)sudo apt-get install build-essential,這樣可以安裝gcc,make。
(2)安裝tk,tcl
sudo apt-get install tcl8.4
sudo apt-get install tcl8.4-dev
sudo apt-get install tk8.4
sudo apt-get install tk8.4-dev
(3)sudo apt-get install libxmu-dev,是和nam有關的東西。
6, sudo apt-get install build-essential
再次嘗試./install【相同的失敗】
7, sudo apt-get install tk8.5
sudo apt-get install tk8.5-dev
再次嘗試./install
【tk安裝成功,otcl-1.14 configuration failed!】
8, 網上查到:can't find x includes
otcl-1.11 configuration failed exiting ...
安裝x-window-system-dev可以解決問題
另:安裝libxt-dev可以解決問題
sudo apt-get install libxt-dev
9, apt-cache search x11-dev
libghc6-x11-dev - haskell x11 binding for ghc
libwx11-dev - library to manage xlib - devel
libgl1-mesa-swx11-dev - a free implementation of the opengl api -- development files
libx11-dev - x11 client-side library (development headers)
然後一一安裝。(為什麼要安裝x11 dev?)
【安裝ns2成功】
10, 安裝出錯時,實際上考官方的解決方法:
11, 環境變數設定:
important notices:
(1) you must put /home/chn/desktop/ns-allinone-2.35/otcl-1.14, /home/chn/desktop/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/chn/desktop/ns-allinone-2.35/tcl8.5.10/library into your tcl_library environmental
variable. otherwise ns/nam will complain during startup.
這些對於ubuntu,還需要配置path變數。總的來說是這樣的:
export ns_home=/home/chn/desktop/ns-allinone-2.35
path="$path:$ns_home/bin:$ns_home/tcl8.5.10/unix:$ns_home/tk8.5.10/unix"
export ld_library_path="$ns_home/otcl-1.14,$ns_home/lib"
export tcl_library="$ns_home/tcl8.5.10/library"
把以上**加到~/.bashrc中。使用命令source ~/.bashrc可以使上述環境變數立即生效。
after these steps, you can now run the ns validation suite with
cd ns-2.35; ./validate
進入漫長的validating process(漫長,據說1個小時?)
【end】
example
ns2的example在ns-2.35/tcl/ex/中。執行: ns
12, 執行ns wireless-flooding.tcl【報錯!】
nam: can't find a usable tk.tcl in the following directories:
/home/chn/desktop/ns-allinone-2.35/tk8.5.10/library /home/chn/desktop/ns-allinone-2.35/tcl8.5.10/library/tk8.5 /home/chn/desktop/ns-allinone-2.35/tcl8.5.10/tk8.5 ./lib/tk8.5 /home/chn/desktop/ns-allinone-2.35/lib/tk8.5 ./library
/home/chn/desktop/ns-allinone-2.35/tk8.5.10/library/tk.tcl: wrong # args: should be "::source filename"
wrong # args: should be "::source filename"
while executing
"::source -encoding utf-8 /home/chn/desktop/ns-allinone-2.35/tk8.5.10/library/msgs/en.msg"
("uplevel" body line 1)
invoked from within
"uplevel 1 [list ::source -encoding utf-8 $langfile]"
(procedure "::msgcat::mcload" line 10)
invoked from within
"::msgcat::mcload [file join $::tk_library msgs]"
(in namespace eval "::tk::msgcat" script line 23)
invoked from within
"namespace eval msgcat ]} else ]} else {
uplevel source.orig [list $filename]
..."
(procedure "source" line 8)
invoked from within
"source /home/chn/desktop/ns-allinone-2.35/lib/tk8.5/tk.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $file]"
this probably means that tk wasn't installed properly.
經過半天多辛苦的搜尋、嘗試,終於在乙個google group裡找到了辦法。現將其擴散:
export tcl_library=/home/username/
desktop/ns-allin
one-2.35/tcl8.
5.10/library:/home/username/desktop/ns-allinone-2.35/tk8.5.10/library
and run "source ~./bashrc" in terminal.
【真正的end】
NS2 除錯環境安裝 GDB
首先安裝gdb,這個比較容易 在 home ns allinone 2.35 ns 2.35 目錄下的makefile 檔案,找到55行附近 ccopt wall wno write strings 將這句修改為 ccopt wall wno write strings g 36行附近的兩行 cc ...
NS2學習筆記
國慶假期用來研究ns2,基於socket的網路程式設計和演算法 現在看的差不多了,每天陸續寫些筆記,用來複習,也用來交流 本人也是初學者,如果有什麼錯誤,希望也可以指出 讀完了這個再去讀ns2的手冊,這個對於高階式相當重要的,而且因為有中文版的,需要的也可以留郵箱。ns2的安裝,建議安裝在linux...
NS2 速率控制
無線網路實驗106 速率控制 rate control 1 簡介 該練習旨在 在多跳網路中速率控制和載波偵聽閾值的變化如何影響空間重用 以及總吞吐量 接收端能夠成功接收資料所要求的訊號干擾雜訊比 signal to interference noise ratio,sinr 依賴於使用的傳輸速率。頻...