下载此文档

WSN中LEACH协议源码分析.doc


文档分类:通信/电子 | 页数:约20页 举报非法文档有奖
1/20
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/20 下载此文档
文档列表 文档介绍
芇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-{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,$(二),(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)蚃莀setinitialized0蚇setrng_[newRNG]#用于产生随机数肆首先往opt数

WSN中LEACH协议源码分析 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数20
  • 收藏数0 收藏
  • 顶次数0
  • 上传人镜花水月
  • 文件大小70 KB
  • 时间2019-03-27