下的NS229安裝及錯誤調(diào)試_第1頁
下的NS229安裝及錯誤調(diào)試_第2頁
下的NS229安裝及錯誤調(diào)試_第3頁
下的NS229安裝及錯誤調(diào)試_第4頁
下的NS229安裝及錯誤調(diào)試_第5頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、Linux下的NS2安裝+LEACH及錯誤修改1、 安裝前的準(zhǔn)備說明為了方便實(shí)驗(yàn)和使用,采用的實(shí)在虛擬機(jī)上安裝,安裝和配置過程與實(shí)體無異。環(huán)境:準(zhǔn)備:在安裝編譯之前確保Linux中已經(jīng)安裝了gcc+編譯工具,以及 XFree86-devel and XFree86-libs兩個組件。分別為:X 軟件開發(fā) KDE桌面環(huán)境,可以在添加刪除程序中進(jìn)行安裝。2、 安裝過程1. 本實(shí)驗(yàn)安裝環(huán)境:完全安裝的RedHat 9.0操作系統(tǒng),ns-allinone-2.29安裝包。2. 到官方下載網(wǎng)址下載NS2安裝軟件包ns-allinone-2.29.tar.gz.3. 以root登錄RH9,在/home下建

2、立ns2文件夾,將ns-allinone-2.29.tar.gz放在該文件夾下,在終端運(yùn)行cd /home/ns2,使用解壓命令tar xvfz ns-allinone-2.29.tar.gz,即生成/home/ns2/ ns-allinone-2.9.4. 修改/home/ns2/ ns-allinone-2.9/nam-1.11/agent.h中的第73行,將NULL改為0.5. 在/home/ns2/ ns-allinone-2.9/下運(yùn)行。/install6. 根據(jù)安裝結(jié)束后結(jié)尾處的提示,將某些路徑復(fù)制下來,或者直接按照以下修改(可以對照提示理解):7. 修改/root/.bashrc

3、(注意該文件為隱藏文件),在該文件末尾加上以下三句話:exportexportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ns2/ns-allinone-2.29/otcl-1.11: /home/ns2/ns-allinone-2.29/libexport在root路徑下輸入命令:source .bash_profile進(jìn)行環(huán)境變量的更新8. 這時,如果以上設(shè)置正確,直接運(yùn)行ns會出現(xiàn)%,或者可以運(yùn)行軟件自帶的例子,在 /home/ns2/ns-allinone-2.29/ns-2.29/ns-tutorial/examples下運(yùn)行ns example2.

4、tclLEACH協(xié)議的安裝準(zhǔn)備:獲取LEACH的源碼文件:mit.tar.gz 1. 進(jìn)入到目錄/home/ns2/ns-allinone-2.29下解壓LEACH協(xié)議源文件mit.tar.gz rootlocalhost root# cd /home/ns2/ns-allinone-2.29rootlocalhost ns-2.29# tar -xzcf mit.tar.gz ./2. 修改MakeFile文件1) 添加-DMIT_uAMPS到DEFINE中DEFINE = -DTCP_DELAY_BIND_ALL.-DMIT_uAMPS2) 添加 -I./mit/rca -I./mit/u

5、AMPS到INCLUDE中INCLUDES = -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -I./mit/rca -I./mit/uAMPS 3) 添加以下代碼在gaf/gaf.o 之前mit/rca/energy.o mit/rca/rcagent.o mit/rca/rca-ll.o mit/rca/resource.o mac/mac-sensor-timers.o mac/mac-sensor.o mit/uAMPS/bsagent.o 注:添加過程中使用TAB鍵代替空

6、格。否則編譯會出錯。4) 將MakeFile文件中的mit/mit.o mit/mit注銷掉(有的話)。3. 進(jìn)入ns-2.29目錄下,輸入make cleanrootlocalhost ns-2.29# make clean注:若出現(xiàn)Makefile:1: * missing separator. Stop.錯誤,查看MakeFile文件添加修改的代碼是否使用空格代替了TAB,是的話改過來。4. 編譯make5. 修改test文件如下:#!/bin/bash cd tcl/ex ns wireless-demo-csci694.tcl sleep 2 cd ./././leach_test6

7、. 修改leach_test文件,ns tcl/ex/wireless.tcl 前添加以下代碼RCA_LIBRARY=mit/rcaexport RCA_LIBRARYuAMPS_LIBRARY=mit/uAMPSexport uAMPS_LIBRARY7. 修改.bashrc文件(rootlocalhost root# vim .bashrc ),在文件最后添加以下環(huán)境變量。export RCA_LIBRARY=/home/ns2/ns-allinone-2.29/ns-2.29/mit/rcaexport uAMPS_LIBRARY=/home/ns2/ns-allinone-2.29/n

8、s-2.29/mit/uAMPS8. mit MPSsims mps.tcl文件。將代碼source $env(RCA_LIBRARY)/ns-ranode.tclsource $env( MPS_LIBRARY)/ns-bsapp.tclsource $env( MPS_LIBRARY)/extras.tclsource $env( MPS_LIBRARY)/stats.tcl#Uncomment these lines to use gdb to debug the c code#source mit/ MPS/ns-bsapp.tcl#source mit/ MPS/extras.tcl

9、#source mit/ MPS/stats.tclsource $env(RCA_LIBRARY)/resources/ns-resource-manager.tclsource $env(RCA_LIBRARY)/resources/ns-energy-resource.tclsource $env(RCA_LIBRARY)/resources/ns-neighbor-resource.tcl修改成代碼source mit/rca/ns-ranode.tclsource mit/ MPS/ns-bsapp.tclsource mit/ MPS/extras.tclsource mit/ M

10、PS/stats.tclsource mit/rca/resources/ns-resource-manager.tclsource mit/rca/resources/ns-energy-resource.tclsource mit/rca/resources/ns-neighbor-resource.tcl9. 驗(yàn)證結(jié)果rootlocalhost ns-2.29# ./testnum_nodes is set 3Loading connection pattern.Loading scenario file.Starting Simulation.channel.cc:sendUp - C

11、alc highestAntennaZ_ and distCST_highestAntennaZ_ = 1.5, distCST_ = 89.8SORTING LISTS .DONE!NS EXITING.10查看rootlocalhost mit# cd leach_sims/rootlocalhost leach_sims# cat leach.errINITIALIZE THE LIST xListHeadchannel.cc:sendUp - Calc highestAntennaZ_ and distCST_highestAntennaZ_ = 1.5, distCST_ = 222

12、.8SORTING LISTS .DONE!表明LEACH安裝成功!rootlocalhost leach_sims# cat leach.outCreating sensor nodes.0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

13、 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 (100 = BS)* NOTE: no connection pattern specified.Loading scenario file.Node 1: (21.008649990432268,92.380389195112684)Node 4: (35.003944130150579,11.288995440718249)Node 7: (94.45503554048716,5.7823289678349754)Nod

14、e 8: (83.602962402441989,14.98909784247591)Node 9: (21.767438492629417,45.338745622587737)Node 11: (94.220422624713009,62.643053551503947)錯誤錦集及修改1 編譯出錯1.pt_xcp的問題在/home/ns2/ns-allinone-2.29/ns-2.29/common/packet.h 文件中,enum packet_t下添加 PT_XCP,接著在p_info()里添加name_PT_XCP="xcp"/home/ns2/ns-alli

15、none-2.29/ns-2.29/mac /channel.cc中:WirelessPhy *wifp = (WirelessPhy *)tifp;之后加入:distCST_ = wifp->getDist(wifp->getCSThresh(), wifp->getPt(), 1.0, 1.0,highestZ , highestZ, wifp->getL(),wifp->getLambda(); ns-2.29/mac下面的wireless-phy.h文件中 WirelessPhy()下添加double getDist(double Pr, double P

16、t, double Gt, double Gr,double hr, double ht, double L, double lambda);然后在wireless-phy.cc的最后添加double WirelessPhy:getDist(double Pr, double Pt, double Gt, double Gr,double hr, double ht, double L, double lambda) if (propagation_) return propagation_->getDist(Pr, Pt, Gt, Gr, hr, ht, L,lambda); retu

17、rn 0;2.mac/mac-802_11.cc:DROP_MAC_COLLISION在cmu-trace.h文件中#define DROP_MAC_COLLISION "COL"之后加入/ BUGFIX UKA: capture/ packet drop in case of a packet capture#define DROP_MAC_CAPTURE "CAP"/ BUGFIX UKA END: capture3.mac/mac-tdma.cc:node_sleep沒有定義(說明leach函數(shù)少了好多呀,從原來的ns里找到函數(shù),復(fù)制過來)wire

18、less-phy.cc里添加這兩個函數(shù)。voidWirelessPhy:node_wakeup() if (status_= IDLE) return; if (em() = NULL) return; if ( NOW > update_energy_time_ && (status_= SLEEP) ) /the power consumption when radio goes from SLEEP mode to IDLE mode em()->DecrTransitionEnergy(T_transition_,P_transition_); em()-&

19、gt;DecrSleepEnergy(NOW-update_energy_time_, P_sleep_); status_ = IDLE; update_energy_time_ = NOW; / log node energy if (em()->energy() > 0) (MobileNode *)node_)->log_energy(1); else (MobileNode *)node_)->log_energy(0); voidWirelessPhy:node_sleep()/ node_on_= FALSE;/ if (status_= SLEEP) r

20、eturn; if (em() = NULL) return; if ( NOW > update_energy_time_ && (status_= IDLE) ) /the power consumption when radio goes from IDLE mode to SLEEP mode em()->DecrTransitionEnergy(T_transition_,P_transition_); em()->DecrIdleEnergy(NOW-update_energy_time_, P_idle_); status_ = SLEEP; u

21、pdate_energy_time_ = NOW; / log node energy if (em()->energy() > 0) (MobileNode *)node_)->log_energy(1); else (MobileNode *)node_)->log_energy(0); 同時在wireless-phy.h文件中void node_off(); 之后加入 void node_wakeup(); void node_sleep() ;m/mobilenode.cc:POSITION_UPDATE_INTERVAL沒有定義mobilenode.h中加入#

22、define POSITION_UPDATE_INTERVAL 30.05.mac/wireless-phy.cc中SLEEP、P_sleep_、P_transition_ 、T_transition_ 及沒有定義:在wireless-phy.h中修改enum ChannelStatus SLEEP, IDLE, RECV, SEND ;在double P_idle_; 之后加入 double P_sleep_ ; double P_transition_; double T_transition_ ;6.satellite/sat-hdlc.h:'HDR_HDLC'沒有定義?

23、在packet.h中加入#define HDR_HDLC(p) (hdr_hdlc*)hdr_ll:access(p)enum packet_t 中加入PT_HDLCclass p_info public:中加入name_PT_HDLC="HDLC"7.大端小端的問題注釋掉#ifndef和#endif。mon/mobilenode.cc: In member function void MobileNode:update_position()':common/mobilenode.cc:477: warning: unused variable double old

24、Y'注釋掉:9.mac/wireless-phy.cc: In member function virtual void WirelessPhy:sendDown(Packet*)':mac/wireless-phy.cc:320: min' undeclared (first use this function)把min改成MIN說明:具體的錯誤修改可以參考其他版本(如:ns-2.35)的對應(yīng)文件進(jìn)行修改。2 測試出錯1.rootlocalhost ns-2.29# ./testnum_nodes is set 3warning: Please use -channe

25、l as shown in tcl/ex/wireless-mitf.tclwarning: no class variable Phy/WirelessPhy:alive_ see tcl-object.tcl in tclcl for info about this warning.warning: no class variable Phy/WirelessPhy:Efriss_amp_warning: no class variable Phy/WirelessPhy:Etwo_ray_amp_warning: no class variable Phy/WirelessPhy:EXc

26、vr_warning: no class variable Phy/WirelessPhy:sleep_。解決方法:ns-allinone-2.29ns-2.29tcllibns_default.tcl文件第692行加入7個初始值如下:Phy/WirelessPhy set alive_ 1Phy/WirelessPhy set Efriss_amp_ 100 * 1e-12Phy/WirelessPhy set Etwo_ray_amp_ 0.013 * 1e-12Phy/WirelessPhy set EXcvr_ 50 * 1e-9Phy/WirelessPhy set sleep_ 0

27、Phy/WirelessPhy set ss_ 1Phy/WirelessPhy set dist_ 0具體的初始值應(yīng)該對照ns-allinone-2.29ns-2.29macwireless-phy.cc輸入(第95行,第97-99行,第104-105行,第107行)注意:提示code omitted because of length 錯誤, 錯誤在set Efriss_amp_ 100*1e-12;原因是:不能設(shè)置表達(dá)式,要改成set Efriss_amp_ *1e-10, 同理改_amp_ 0.013*1e-12; set EXcvr_ 50*1e-9 )。修改之后,要重新編譯。即先執(zhí)

28、行make clean,再執(zhí)行make。成功后,再次運(yùn)行./test,得到第一次的結(jié)果。2.rootlocalhost leach_sims# cat leach.out .Warning dst_ is no longer being supported in NS. dst_ 0xffffffffUse dst_addr_ and dst_port_ insteadWarning dst_ is no longer being supported in NS. dst_ 0xffffffffUse dst_addr_ and dst_port_ insteadWarning dst_ is no longer being supported in NS. dst_ 0xffffffffUse dst_addr_ and dst_port_ insteadWarning dst_ is no longer being supported in NS. dst_ 0xffffffffUse dst_addr_ and dst_port_ insteadThis represents data from nodes: 33 80Warning dst_ is no longer being supported in NS. dst_ 0xffffffffUse d

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論