close

1.下載ns-allinone-2.34.tar.gz


2.複製「ns-allinone-2.34.tar.gz」到/home/"your username" (your username是你的帳號名稱)


3.執行終端機(命令列模式)輸入sudo -i切換到root帳號


4.輸入"sudo apt-get remove gcc"移除gcc,

5.並輸入"sudo apt-get install build-essential"命令來安裝gcc and some essential


6.輸入"sudo apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev"命令來安裝tcl和tk要用的元件


7.輸入"sudo apt-get install libxmu-dev libxmu-headers"來安裝nam要用的元件


8.解壓縮 ns-allinone-2.34.tar.gz 到 /home/"your username"


9.進入/home/"your username"/ns-allinone-2.34/otcl-1.13/,找到configure和configure.in檔案,用文字編輯器編輯它


10.文件編輯器開啟configure和configure.in檔案後,找到這一段 (gcc 4版本後才需要)

Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="ld -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""

將SHLIB_LD="ld -shared"改成SHLIB_LD="gcc -shared",儲存。


11.修改ns-2.34/tools/中的ranvar.cc第219行, 將GammaRandomVariable::GammaRandomVariable改為GammaRandomVariable


12.修改ns-2.34/mobile/中的nakagami.cc第183行, 將ErlangRandomVariable::ErlangRandomVariable 改為ErlangRandomVariable; 第185行GammaRandomVariable::GammaRandomVariable改為GammaRandomVariable


13.修改ns-2.34/mac/中的mac-802_11Ext.h, 加入#include <cstddef>


14.到/home/"your username"/ns-allinone-2.34/執行"./install"安裝ns2,等候編譯及安裝。

你會看到以下資訊!

Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.4.18: /home/tnt/ns-allinone-2.33/{binincludelib}
tk8.4.18: /home/tnt/ns-allinone-2.33/{binincludelib}
otcl: /home/tnt/ns-allinone-2.33/otcl-1.13
tclcl: /home/tnt/ns-allinone-2.33/tclcl-1.19
ns: /home/tnt/ns-allinone-2.33/ns-2.33/ns
nam: /home/tnt/ns-allinone-2.33/nam-1.13/nam
xgraph: /home/tnt/ns-allinone-2.33/xgraph-12.1
gt-itm: /home/tnt/ns-allinone-2.33/itm edriver sgb2alt sgb2ns sgb2comns sgb2hierns

----------------------------------------------------------------------------------

Please put /home/tnt/ns-allinone-2.33/bin:/home/tnt/ns-allinone2.33/tcl8.4.18/unix:/home/tnt/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/tnt/ns-allinone-2.33/otcl-1.13 /home/tnt/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/tnt/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
http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive
for related posts.


11.安裝完成後,還需要編輯.bashrc產生關聯。進入終端機介面,跳到/home/"your username",執行

gedit .bashrc

跳出文字編輯介面,請在最後面加入以下這幾段:
/**********************************記得改名字steve**********************************/
export PATH=$PATH:/home/steve/ns-allinone-2.34/bin:/home/steve/ns-allinone-2.34/tcl8.4.18/unix:/home/steve/ns-allinone-2.34/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/steve/ns-allinone-2.34/otcl-1.13:/home/steve/ns-allinone-2.34/lib
export TCL_LIBRARY=$TCL_LIBRARY:/home/steve/ns-allinone-2.34/tcl8.4.18/library

修改完儲存後,輸入

source .bashrc

重新載入.bashrc檔案,至此ns2安裝全部完成。


12.在終端機介面,輸入ns執行,若有跳出%符號,表示安裝成功


13.你可以在終端機介面,跳到/home/"your username"/ns-allinone-2.34/ns-2.34,輸入./validate驗證安裝(非必要)


-------------------------------------------------------------------------------------------------------
這一部份是把Kelvin程式載入:

1.把/Kevin/MH-TCP/ns-2.34/整個取代ubuntu的ns-2.34資料夾內的文件
   遇到問題:ns2.34/tcl/lib/ns-autoconf.tcl會有權限問題
   解法:使用chown steve:steve ns-autoconf.tcl(修改擁有者)
   P.S: 可使用ls -al觀看檔案文件的權限資料
   遇到問題:ns2.34/Makefile會有權限問題
   解法:使用chown steve:steve Makefile(修改擁有者)
   P.S: 可使用ls -al觀看檔案文件的權限資料


2.把Kelvin/MH-TCP/new_top/整個資料夾丟進ubuntu的 /home/you name/ns-allinone-2.34


3.下載Kelvin 195版本丟入ns-2.34/multihoming


4.到/ns-2.34中 ./configure
  遇到問題:若你現在不是root會發生以下錯誤
   ./configure: line 1520: config.log: Permission denied
   ./configure: line 1530: config.log: Permission denied
   解法:使用sudo -i(變更為root)


5.在/ns-2.34中 make clean


6.在/ns-2.34中 make
   你會看到以下資訊!
   -------------------------------------------------------------------------------------------------------
   make[1]: Entering directory `/home/steve/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/ucb'
   make[1]: Nothing to be done for `all'.
   make[1]: Leaving directory `/home/steve/ns-allinone-2.34/ns-2.34/indep-utils/webtrace-conv/ucb'
   -------------------------------------------------------------------------------------------------------
   表示OK!!


最後遭遇問題:執行ns會有[code omitted because of length]
原因:因為./configure時會根據Makefile.in會去產生Makefile,雖然剛剛複製時有把Makefile修改了
但再重新./configure時又重新改過ns-2.34/Makefile檔了。
解法1: ./configure後再修改Makefile檔(OBJ_CC最下面幾行multihoming要加上去)
解法2: ./configure前再修改Makefile.in檔之後再./configure

之後還要make clean, make一次即完成 

如何執行Kelvin程式? ./cmt


-------------------------------------------------------------------------------------------------------
以下和教學文件無關:

For Ubuntu 9.10 (karmic), you may encounter this error in the linking of otcl:

otcl.o: In function `OTclDispatch':
/home/ns/ns-allinone-2.34/otcl/otcl.c:495: undefined reference to `__stack_chk_fail_local'
otcl.o: In function `Otcl_Init':
/home/ns/ns-allinone-2.34/otcl/otcl.c:2284: undefined reference to `__stack_chk_fail_local'
ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
ld: final link failed: Nonrepresentable section on output
make: *** [libotcl.so] Error 1

This error is because the linker being used is "ld -shared" instead of "gcc -shared". If you edit one line in otcl-1.13/configure, and rerun install, it should work:

--- configure.orig 2009-11-02 12:14:52.556167945 -0800
+++ configure 2009-11-02 12:17:28.966706099 -0800
@@ -6301,7 +6301,7 @@
;;
Linux*)
SHLIB_CFLAGS="-fpic"
- SHLIB_LD="ld -shared"
+ SHLIB_LD="gcc -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""

arrow
arrow
    全站熱搜

    LittleChoCho 發表在 痞客邦 留言(0) 人氣()