Linux下安裝NS2 33(建議fedora8)

2021-08-27 01:09:11 字數 3991 閱讀 4494

ns2可以在很多linux系統下安裝,不過安裝過程比較折騰,支援包很多要匹配,這裡介紹下我配置成功的版本。

作業系統建議是fedora8,其他的作業系統也可以就是,最好不要太新版本的,我也在ubuntu10.10上面配過,ubuntu10.10最好裝server版本,都裝完最好,否則可能會出現問題,過程還是特別折騰的

這裡按照fedora8來配置,ubuntu需要配置gcc4.1和g++4.1的,參考下我前篇寫的怎麼降級裝g++4.1的

ps:有個我基本配置好的版本,由於上傳空間限制,分了兩個包

進入ns-allinone-2.33目錄

[xfx@localhost share]$ cd ns-allinone-2.33/

ps:很多情況下會在後期出現nam呼叫不起來的問題,問題原因有點折騰,沒有bind上。。。具體也不用管,打兩個patch就行,fedora可以直接patch,ubuntu要apt-get下

然後patch –p1,提示輸入時候輸入generic/tk.h

接著把tk-8.4.18-tkbind.patch放到ns-allinone-2.33/,然後patch -p0 ,這個不會提示輸入

ns2.33版本這樣打就行了,ns2.30我沒打成功,tk-8.4.13那個還要修改patch的內容,麻煩很多,所以用2.30的話不如換到2.33吧,除非對編譯比較熟的可以去自己改下

打完patch後

[xfx@localhost ns-allinone-2.33]$ ./install

ps:這裡如果出現這樣的錯

ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined

ld: final link failed: nonrepresentable section on output

make: *** [libotcl.so] 錯誤 1

otcl-1.13 make failed! exiting ...

解決辦法如下:

gcc 4.0版本以前是用ld -share來生成共享庫的,但是到了4.0以上的版本(我的為gcc version 4.4.1),這個命令改為了gcc -share即可。

cd ns-allinone-2.33/otcl-1.13

gedit configure.in

把77行處的

shlib_ld="ld -shared"

改為shlib_ld="gcc -shared"

儲存退出

然後gedit configure

把5518行的

shlib_ld="ld -shared"

改為shlib_ld="gcc -shared"

儲存退出,

然後cd ..

回到目錄ns-allinone-2.33下執行./install,如果install正確了,那麼就會出現

please put /home/share/ns-allinone-2.33/bin:/home/share/ns-allinone-2.33/tcl8.4.18/unix:/home/share/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/share/ns-allinone-2.33/otcl-1.13, /home/share/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/share/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

also search the ns mailing list archive

for related posts.

這麼一長串的東西,這段話是提示你怎麼修改path等環境變數的,覺得麻煩的或者對linux不大熟的建議

在/home下面建立乙個資料夾share

就是mkdir /home/share,然後把ns-allinone-2.33都放進去,然後path直接用以下設定,在/home/(你的使用者名稱)下修改.bashrc(ps:這個改的安全點,etc下面的也行,不過改多了會亂)

改這個vi /home/xfx/.bashrc

在末尾新增如下,儲存就行了

# ns 2.33 config

export path="$path:/home/share/ns-allinone-2.33/bin:/home/share/ns-allinone-2.33/tcl8.4.18/unix:/home/share/ns-allinone-2.33/tk8.4.18/unix"

export ld_library_path="$ld_library_path:/home/share/ns-allinone-2.33/otcl-1.13:/home/share/ns-allinone-2.33/lib"

export tcl_library="$tcl_library:/home/share/ns-allinone-2.33/tcl8.4.18/library"

不是這個目錄的可以對應下面,應該能明白怎麼修改的吧

please put /home/share/ns-allinone-2.33/bin:/home/share/ns-allinone-2.33/tcl8.4.18/unix:/home/share/ns-allinone-2.33/tk8.4.18/unix

into your path environment; so that you'll be able to run itm/tclsh/wish/xgraph.

對應修改path

you must put /home/share/ns-allinone-2.33/otcl-1.13, /home/share/ns-allinone-2.33/lib,

into your ld_library_path environment variable.

對應修改ld_library

you must put /home/share/ns-allinone-2.33/tcl8.4.18/library into your tcl_library environmental

variable. otherwise ns/nam will complain during startup.

對應修改tcl_library

現在可以大致測試下了,ns-allinone-2.33/ns-2.33目錄下執行

[root@localhost ns-2.33]# ./validate

不會出現could not found就是ok了

然後測試nam,

[root@localhost ns-2.33]# nam

會出現個圖形的框子就是可以的了,這樣ns2就基本配置好了

在NS2 33下安裝tcl debug 2 0

在ns2.33下安裝tcl debug 2.0步驟 經驗證,此方法最全,並且可用於ns2.33,ns2.30,ns2.29等版本。現記錄如下 make 3 檢查可載入的庫檔案 a 在編譯之後是否被建立。檢視是否產生了乙個 libtcldbg.a 檔案。他是乙個tcl的庫檔案。4 複製這個庫檔案到ns...

NS2 NS2在ubuntu下的安裝

step1 更新系統。在終端輸入如下命令 sudo apt get update 更新源列表 sudo apt get upgrade 更新已經安裝的包 sudo apt get dist upgrade 更新軟體,公升級系統 step2 安裝幾個需要的包 sudo apt get install ...

Ubuntu下NS3安裝步驟

原文位置 1.ns3安裝預先設定ubuntu環境,執行在終端以下命令 sudo apt get install gcc g python sudo apt get install mercurial sudo apt get install bzr sudo apt get install gdb ...