1 / 19
文档名称:

WSN中LEACH协议源码分析报告.doc

格式:doc   大小:67KB   页数:19页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

WSN中LEACH协议源码分析报告.doc

上传人:水中望月 2019/5/29 文件大小:67 KB

下载得到文件列表

WSN中LEACH协议源码分析报告.doc

相关文档

文档介绍

文档介绍:Forpersonaluseonlyinstudyandresearch;mercialuse肅WSN中LEACH协议源码分析袄分析(一),先对默认的脚本选项进行初始化:艿setopt(chan)Channel/WirelessChannel膈setopt(prop)Propagation/if)Phy/WirelessPhy芀setopt(mac)Mac/802_11羁setopt(ifq)Queue/DropTail/PriQueue袇setopt(ll)LL羄setopt(ant)Antenna/OmniAntenna蚁setopt(x)0 ;#Xdimensionofthetopography莈setopt(y)0 ;#Ydimensionofthetopography蚆setopt(cp)""肄setopt(sc)"../mobility/scene/scen-670x670-50-600-20-2";#scenariofile肂setopt(ifqlen) 50;#maxpacketinif肀setopt(nn) 51;#numberofnodes蚈setopt(seed)(stop);#simulationtime蒂setopt(tr);#tracefile薈setopt(rp)dsdv;#routingprotocolscript蒇setopt(lm)"on";#:袃#芀#InitializeGlobalVariables芆#莄setns_[newSimulator]羀setchan[new$opt(chan)]螈setprop[new$opt(prop)]羅settopo[newTopography]蒃settracefd[open$opt(tr)w]莁$topoload_flatgrid$opt(x)$opt(y)蒀$proptopography$topo肈这些初始化将在后面的使用中用到,该文件最重要的是创建leach节点:创建方法如下:薃}elseif{[pare$opt(rp)"leach"]==0}{螂for{seti0}{$i<$opt(nn)}{incri}{袈leach-create-mobile-node$i袇}薃如果路由协议是leach协议,-create-mobile-node方法创建leach节点。将在第二小节讲如何创建leach节点。膃for{seti0}{$i<$opt(nn)}{incri}{蚀$ns_at$opt(stop).000000001"$node_($i)reset";//完成后,重置节点的应用薆}蚃$ns_at$opt(stop).00000001"puts\"NSEXITING...\";$ns_halt"薄if{$opt(sc)==""}{肇puts"***NOTE:noscenariofilespecified."虿setopt(sc)"none"螃}else{蚀puts"Loadingscenariofile..."蝿source$opt(sc)莇puts"plete..."袃}膁ns在什么时候结束simulation,并告诉ns加载sc场景文件。最后$ns_run则ns就开始运行了。蒁分析(二),。羃setopt(Efriss_amp)[expr[*$opt(RXThresh)*16*$PI*$PI]/\薂[expr$opt(bw)*$opt(Gt)*$opt(Gr)*$l*$l]]罿#Etwo_ray_amp=RXThresh/(RbGtGrht^2hr^2)羅setopt(Etwo_ray_amp)[*$opt(RXThresh)/\肃[expr$opt(bw)*$opt(Gt)*$opt(Gr)*\羃$opt(ht)*$opt(ht)*$opt(ht)*$opt(ht)]]蚁setopt(EXcvr)50e-9;#Energyforradiocircuitry羈setopt(e_bf)5e-9;#Beamformingenergy(J/bit)膂setopt(Esense)0;#Sensingenergy(J/bit)肀setopt(thresh_energy) ;#Thresholdforpoweradaptation腿setopt(Pidle)0;#Idlepower(W)螇setopt(Psleep)0;#Sleeppower(W)膂se