无线传感器网络flooding路由协议的MATLAB仿真(2).docx

上传人:lao****ou 文档编号:1055745 上传时间:2024-09-27 格式:DOCX 页数:5 大小:27.78KB
下载 相关 举报
无线传感器网络flooding路由协议的MATLAB仿真(2).docx_第1页
第1页 / 共5页
无线传感器网络flooding路由协议的MATLAB仿真(2).docx_第2页
第2页 / 共5页
无线传感器网络flooding路由协议的MATLAB仿真(2).docx_第3页
第3页 / 共5页
无线传感器网络flooding路由协议的MATLAB仿真(2).docx_第4页
第4页 / 共5页
无线传感器网络flooding路由协议的MATLAB仿真(2).docx_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《无线传感器网络flooding路由协议的MATLAB仿真(2).docx》由会员分享,可在线阅读,更多相关《无线传感器网络flooding路由协议的MATLAB仿真(2).docx(5页珍藏版)》请在第一文库网上搜索。

1、functionparam=params;param(1).defau1t=0.5;param(1).name=P;functiontopo1ogy,mote_IDs=topo1ogy(varargin);Nx=10;Ny=I;%numberofpointsonthegridix=1;t=;distx=1;disty=5;X=1:distx:(Nx-1)*distx+1;Y=I:disty:(Ny-1)*disty+1;fori=Xforj=Yt=t;i,j;endendtopo1ogy=t;mote_IDs=1:Nx*Ny;functionx=animationpersistentanim_

2、dataifisempty(anim_data)sma11=5;medium=20;1arge=50;%Event_nameAnimatedCo1or/on/off/togg1eSizeanim_def=.Init-App1ication,1,000,sma11,.Packet-Sent2,100,sma11,.PackeCReceived,3,100,sma11,.Co11ided_Packet_Received,4,100,sma11,.C1oCkJriCKO,000,sma11,.Channe1Request,O,000,sma11),.Channe1IdIe_Check,1,100,s

3、ma11),.,Packet-Receive_Start,O,010,sma11,.Packet_Receive_EndO,000,sma11,.Packet_Transmit_Start1,100,medium,.Packet_Transmit_End1,010,sma11;fori=1:1ength(anim_def)=WORD完整版.可编辑-专业资料分享=a=anim-defi;ifi=1anim-data=struct(event,a1,animated,a2,co1or,a3,size,a4);e1seanim-data(i)=struct(event,a1,animated1,a2

4、,co1or,a3,size,a4);endendendx=anim_data;functionapp1ication(S)S;persistentapp_dataS;g1oba1IDtS;t,event,ID,data=get_event(S);S;topo1ogy,moteJDs=prow1er(GetTopo1ogyInfo,);S;ix=find(mote_IDs=ID);S;if-strcmp(event,Init-App1ication,)S;trymemory=app_dataix;catchmemory=;end,S;endS;SENDER-ID=sim-params(,get

5、-app,Start-Mote,);ifisempty(SENDERJD),SENDERJD=1;endswitcheventcase,Init-App1ication,Signa1strength=1;memory=struct(,send,1,signa1_strength,signa1_strength);ifID=SENDERJD%thisnodestartsf1oodSecciock(IOOO)endPrintMessageCi)casePacket-Sent,memory.send=0;PrintMessageCs)casePacket-Received%data.data%mes

6、sage%data.signa1_strength%receivedsigna1strengthifmemory.sendp=sim-params(,get-app,P);ifisempty(p);p=.3;end%p=0.3;%pisforcedto0.3/Commentthis1ineifyouwanttouseitforoptimization=WORD完整版.可编辑-专业资料分享=ifrandpSend_Packet(radiostream(data.data,memory.signa1-strength);endmemory.send=0;PrintMessage(r,)endcas

7、eCo11ided_Packet_Received%thisisfordebugpurposeson1ycaseC1ock-TickSend_Packet(radiostream(thisisthemessage*,memory.Signa1strength);case,GuiInfoRequest,if-isemty(memory)disp(sprintf(MemoryDumpofmoteID#%dn,ID);disp(memory)e1sedisp(sprintf(Nomemorydumpavai1ab1efornode%d.n,ID);endcaseApp1ication-Stopped

8、%thiseventisca11edwhensimu1ationisStoppedZsuspendedcaseApp1ication-Finished%thiseventisca11edwhensimu1ationisfinishedotherwiseerror(,Badeventnameforapp1ication:event)endS;app.dataix=memory;S;functionb=Send_Packet(data);g1oba1IDtradio=prow1er(GetRadioName,);b=feva1(radio,Send-Packet,ID,data,t);functi

9、onb=Set_C1ock(a1arm_time);g1oba1IDprow1er(,InsertEvents2Q,make_event(a1arm_time,C1ock-Tick,ID);functionPrintMessage(msg)g1oba1IDprow1er(,TextMessage,ID,msg)functionvarargout=infotit1e!-App1icationF100D2D,;str1=Thisapp1icationi11ustratesthef1oodinga1gorithmin2D.;.,Thesendermotetransmitsamessage.Eachm

10、otereceivingthe;.,messageretransmitsitwithprobabi1ityp.,Theva1ueofpcanbesetintheuApp1icationParameters*;.,window.Thedefau1tva1ueisp=0.5.;.H.,Thestartingnodecana1sobese1ected(parameterStart_Mote).,;.,Try1tostartfromthe1ower1eftcomer,and55tostartfrom1;.,thecenterofthe(IOx1O)grid.,;.H.,Ifpistoo1ow,thef

11、1ooddiesoutbeforeeverymotecou1d;.,receivethemessage.Ifpittoohigh,themessageis,;.Retransmittedsevera1timesaftereverymotehavereceivedit,thuscausinganunnecessari1yhighsett1ingtime.;.9Theoptima1va1ueofphigh1ydependsontopo1ogy.,;.,Youcanchangethetopo1ogybychangingtheparametersX_Number,;.,Y-Number,andDist

12、ance.,;.“;ifnargout=0he1pwin(tit1e1,str1,App1icationInfo)e1sevarargout=tit1e1,str1;endfunctionparam=params;param(1).defau1t=.5;param(2).defau1t=1;param(3).defau1t=10;param(4).defau1t=10;param(5).defau1t=1;param(1).name=P;param(2).name=,Start-Mote,;param(3).name=X-Number;param(4).name=,Y-Number,;para

13、m(5).name=,Distance;functiontopo1ogy,mote_IDs=topo1ogy(varargin);ix=1;t=;%dist=1;%Nx=10;Ny=10;%numberofpointsonthegridNx=sim-params(,get-app,X-Number,);ifisempty(Nx),Nx=10;endNy=sim-params(,get-app,Y-Number,);ifisempty(Ny),Ny=10;enddist=sim_params(get_appDistance);ifisempty(dist),dist=1;endX=1:dist:(Nx-1)*dist+1;Y=1:dist:(Ny-1)*dist+1;fori=Xforj=Yt=t;i,j;endendtoo1ogy=t;mote_IDs=1:Nx*Ny;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 应用文档 > 工作总结

copyright@ 2008-2022 001doc.com网站版权所有   

经营许可证编号:宁ICP备2022001085号

本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有,必要时第一文库网拥有上传用户文档的转载和下载权。第一文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知第一文库网,我们立即给予删除!



客服