收藏 分销(赏)

无线传感器网络各类路由协议仿真.doc

上传人:人****来 文档编号:3875092 上传时间:2024-07-23 格式:DOC 页数:17 大小:63.04KB
下载 相关 举报
无线传感器网络各类路由协议仿真.doc_第1页
第1页 / 共17页
无线传感器网络各类路由协议仿真.doc_第2页
第2页 / 共17页
无线传感器网络各类路由协议仿真.doc_第3页
第3页 / 共17页
无线传感器网络各类路由协议仿真.doc_第4页
第4页 / 共17页
无线传感器网络各类路由协议仿真.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

1、实验报告课 程无线传感网络各类路由协议仿真1. 实验目的网络数据传输离不开路由协议,路由协议是其组网的基础,路由协议是无线传感器网络研究的重点之一,其主要的设计目标是降低节点能量消耗,延长网络的生命周期。本次实验将仿真各类无线传感器网络路由协议。2.实验要求争取考虑全面,考虑到各因素对各类协议的影响,以提高无线传感网络的性能。3. 设计思想(1) Flooding 泛洪是一种传统的路由技术,不要求维护网络的拓扑结构,并进行路由计算,接收到消息的节点以广播形式转发分组。对于自组织的传感器网络,泛洪路由是一种较直接的实现方法,但消息的“内爆”(implosion)和“重叠”(overlap)是其固

2、有的缺陷。为了克服这些缺陷,S。hedetniemi等人提出了Gossiping策略,节点随机选取一个相邻节点转发它接收到的分组,而不是采用广播形式。这种方法避免了消息的“内爆现象,但有可能增加端到端的传输延时. Flooding路由协议中的内爆和重叠问题(2) SPIN (sensor protocol for information via negotiation)SPIN是以数据为中心的自适应路由协议,通过协商机制来解决泛洪算法中的“内爆”和“重叠”问题。传感器节点仅广播采集数据的描述信息,当有相应的请求时,才有目的地发送数据信息.SPIN协议中有3种类型的消息,即ADV,REQ和DAT

3、A。ADV-用于新数据广播.当一个节点有数据可共享时,它以广播方式向外发送DATA数据包中的元数据。REQ用于请求发送数据。当一个节点希望接收DATA数据包时,发送REQ数据包。DATA包含附上元数据头(meta一header)的实际数据包。SPIN协议有4种不同的形式: SPINPP:采用点到点的通信模式,并假定两节点间的通信不受其他节点的干扰,分组不会丢失,功率没有任何限制。要发送数据的节点通过ADV向它的相邻节点广播消息,感兴趣的节点通过REQ发送请求,数据源向请求者发送数据。接收到数据的节点再向它的相邻节点广播ADV消息,如此重复,使所有节点都有机会接收到任何数据。 SPINEC:在S

4、PINPP的基础上考虑了节点的功耗,只有能够顺利完成所有任务且能量不低于设定阈值的节点才可参与数据交换。 SPINBC:设计了广播信道,使所有在有效半径内的节点可以同时完成数据交换.为了防止产生重复的REQ请求,节点在听到ADV消息以后,设定一个随机定时器来控制REQ请求的发送,其他节点听到该请求,主动放弃请求权利。 SPIN-RL:它是对SPINBC的完善,主要考虑如何恢复无线链路引入的分组差错与丢失。记录ADV消息的相关状态,如果在确定时间间隔内接收不到请求数据,则发送重传请求,重传请求的次数有一定的限制.图3。2表明了SPIN协议的路由建立与数据传送。 SPIN协议的路由建立与数据传送基

5、于数据描述的协商机制和能量自适应机制的SP创协议能够很好地解决传统的Flooding协议所带来的信息爆炸、信息重复和资源浪费等问题。此外,由于协议中每个节点只需知道其单跳邻居节点的信息,拓扑改变呈现本地化特征.SP州协议的缺点是数据广告机制不能保证数据的可靠传递,如果对数据感兴趣的节点远离源节点或者在源节点和目的节点中间的节点对数据不感兴趣,那么数据就不可能被传递到目的地。因此,对于入侵发现等需要在定期间隔内可靠传递数据的应用系统来说,SP州并不是一个很好的选择.(3) SAR (sequential assignment routing)在选择路径时,有序分配路由(SAR)策略充分考虑了功耗

6、、QoS和分组优先权等特殊要求,采用局部路径恢复和多路经备份策略,避免节点或链路失败时进行路由重计算需要的过量计算开销。为了在每个节点与sink节点间生成多条路经,需要维护多个树结构,每个树以落在sink节点有效传输半径内的节点为根向外生长,枝干的选择需满足一定QOS要求并要有一定的能量储备。这一处理使大多数传感器节点可能同时属于多个树,可任选其一将采集数据回传到sink节点.(4) LEACH (low energy adaptive clustering hierarchy)LEACH是MIT的Chandrakasan等人为无线传感器网络设计的低功耗自适应聚类路由算法。与一般的平面多跳路由

7、协议和静态聚类算法相比,LEACH可以将网络生命周期延长15,主要通过随机选择聚类首领,平均分担中继通信业务来实现.LEACH定义了“轮”(round)的概念,一轮由初始化和稳定工作两个阶段组成。为了避免额外的处理开销,稳定态一般持续相对较长的时间. 如图3.4所示:初始化阶段稳定工作阶段时间 LEACH协议的时序图在初始化阶段,聚类首领是通过下面的机制产生的。传感器节点生成0,1之间的随机数,如果大于阈值T,则选该节点为聚类首领。T的计算方法如下: (3。1)其中p为节点中成为聚类首领的百分数,r是当前的轮数。 当簇头选定之后,簇头节点主动向网络中节点广播自己成为簇头的消息(ADV_CH).

8、接收到此消息的节点,依据接收信号的强度,选择它所要加入的簇,并发消息通知相应的簇头(JOIN_REQ)。基于时分多址(Time Division Multiple Address,简称TDMA)的方式,簇头节点为其中的每个成员分配通信时隙,并以广播的形式通知所有的簇内节点(ADVSCH).这样保证了簇内每个节点在指定的传输时隙进行数据传输,而在其他时间进入休眠状态,减少了能量消耗。在稳定工作阶段,节点持续采集监测数据,在自身传输时隙到来时把监测数据传给簇头节点(DATA),如图3.5所示。簇头节点对接收到数据进行融合处理之后,发送到Sink节点,这是一种减小通信业务量的合理工作模式。持续一段时

9、间以后,整个网络进入下一轮工作周期,重新选择簇头节点.LEACH协议采用动态转换簇头的方法来平均网络节点的能量消耗,使因能量耗尽而失效的节点呈随机分布状态,因而与一般的多跳路由协议和静态簇算法相比,LEACH可以将网络生命周期延长15%。但是LEACH协议在每轮固定簇头节点后在划分簇的过程中,簇头节点开销较大。并且簇头节点的选择无法达到最优,有可能簇头节点位于网络的边缘或者几个簇头节点相邻,某些节点不得不传输较远的距离来与簇头通信,这就导致了大量能量消耗。而且LEACH协议所有簇头节点直接与Sink节点通信,采用连续数据发送模式和单跳路径选择模式,使得每轮中簇头节点能耗巨大,因此不适合在大规模

10、的传感器网络中应用。(5) TEEN (threshold sensitive energy efficient sensor network protocol)依照应用模式的不同,通常可以简单地将无线自组织网络(包括传感器网络和Adhoc网络)分为主动(proactive)和响应(reactive)两种类型.主动型传感器网络持续监测周围的物质现象,并以恒定速率发送监测数据;而响应型传感器网络只是在被观测变量发生突变时才传送数据。相比之下,响应型传感器网络更适合应用在敏感时间的应用中。TEEN和LEACH的实现机制非常相似,只是前者是响应型的,而后者属于主动型传感器网络.在TEEN中定义了硬、

11、软两个门限值,以确定是否需要发送监测数据。当监测数据第一次超过设定的硬门限时,节点用它作为新的硬门限,并在接着到来的时隙内发送它。在接下来的过程中,如果监测数据的变化幅度大于软门限界定的范围,则节点传送最新采集的数据,并将它设定为新的硬门限。通过调节软门限值的大小,可以在监测精度和系统能耗之间取得合理的平衡.图3。6表示的是TEEN协议中由聚簇构成的层次结构。SinkHigh level cluster head ClusteringNormal sensor nodeLow level cluster headTEEN协议中由聚簇构成的层次结构TENE适用于实时性要求较高的应用场合,比如入侵

12、警报,爆炸预警等,用户可以及时获取感兴趣的信息。而且用户可以通过设置不同的软门限方便地平衡监测的准确性与系统节能性两项指标。但是这个方案也有一些不足之处,例如门限值达不到,节点就永远不会和簇头节点通信,用户就无法从网络得到任何数据;没有相应的机制去区分那些没有感应到足够大变化的节点和处于关闭状态的节点,所以TEEN协议不适合应用在.(6) PEGAGIS (power-efficient gathering in sensor information system)PEGASIS由LEACH发展而来。它假定组成网络的传感器节点是同构且静止的.节点发送能量递减的测试信号,通过检测应答来确定离自己

13、最近的相邻节点。在收集数据前,首先利用贪心算法将网络中的所有节点连接成一条单链.通过这种方式,网络中的所有节点能够了解彼此的位置关系,进而每个节点依据自己的位置选择所属的聚类,聚类的首领向链的两端发出收集数据的请求,数据从单链的两个端点向首领流动.中间节点在传递数据前要执行融合操作,最终由首领节点将结果数据传送给Sink节点.因为PEGASIS中每个节点都以最小功率发送数据分组,并有条件完成必要的数据融合,减小业务流量。因此,整个网络的功耗较小.研究结果表明,PEGASIS支持的传感器网络的生命周期是LEACH的近两倍。 4。实验器材与工具MATLAB5.程序源代码function x=ani

14、mation_datasmall=5; medium=20; large=50;% Event_name Animated Color/on/off/toggle Size anim_def=.。 Init_Application, 0, 0 0 0 , small, .。. Packet_Sent, 1, 0 1 0 , small, 。. Packet_Received, 1, 0 1 0 , small, .。 Collided_Packet_Received, 0, 1 0 0 , small, .。 Clock_Tick, 0, 0 0 0 , small, .。 Channel_R

15、equest, 0, 0 0 0 , small, 。 Channel_Idle_Check, 1, 1 0 0 , small, . Packet_Receive_Start, 0, 0 1 0 , small, 。 Packet_Receive_End, 0, 0 0 0 , small, .。 Packet_Transmit_Start, 1, 1 0 0 , medium, 。.。 Packet_Transmit_End, 0, 0 1 0 , small;for i=1:length(anim_def) a=anim_defi; x(i)=struct(event, a1, anim

16、ated, a2, color, a3, size, a4);endfunction application(S) DO NOT edit simulator code (lines that begin with S;)S; persistent app_data S; global ID tS; t, event, ID, data=get_event(S);S; topology, mote_IDs=prowler(GetTopologyInfo);S; ix=find(mote_IDs=ID);S; if strcmp(event, Init_Application) S; try m

17、emory=app_dataix; catch memory=; end, S; endS; switch eventcase Init_Application signal_strength=1; if ID=1 first node starts flood Set_Clock(1000) end PrintMessage(i) case Packet_Sent PrintMessage(s) case Packet_Received data。data message data.signal_strength received signal strength if memory.send

18、 p=sim_params(get_app, P); if isempty(p); p=。5; end if randp Send_Packet(radiostream(data。data, memory。signal_strength); end memory。send=0; PrintMessage(r) endcase Collided_Packet_Received this is for debug purposes onlycase Clock_Tick Send_Packet(radiostream(Message for 00111 from Golomb, memory。si

19、gnal_strength);case GuiInfoRequest disp(sprintf(Memory Dump of mote ID %d:n,ID); disp(memory)case Application_Stopped this event is called when simulation is stopped/suspended case Application_Finished this event is called when simulation is finished otherwise error(Bad event name for application: e

20、vent)endS; app_dataix=memory;function b=Send_Packet(data);global ID tradio=prowler(GetRadioName);b=feval(radio, Send_Packet, ID, data, t);function b=Set_Clock(alarm_time);global IDprowler(InsertEvents2Q, make_event(alarm_time, Clock_Tick, ID));function PrintMessage(msg)global IDprowler(TextMessage,

21、ID, msg)function LED(msg)global IDprowler(LED, ID, msg)function varargout=infotitle1=Application FLOOD1D;str1= This application illustrates the simple flooding algorithm.; .。 ;。. The sender mote transmits a message。 Each mote receiving the;。. message retransmits it with probability p。 ;。 The value o

22、f p can be set in the Application Parameters;。.。 window. The default value is p=0。5;。. ;。. If p is too low, the flood dies out before every mote could;.。 receive the message。 If p it too high, the message is;。. retransmitted several times after every mote have received it, ;。.。 thus causing an unnec

23、essarily high settling time。;。 ;.。 The optimal value of p highly depends on topology。;.。 ;.。. You can change the topology by editing the file FLOOD1D_TOPOLOGY.;。. ;.。. See also FLOOD2D.;。. ;if nargout=0 helpwin( title1, str1, Application Info)else varargout= title1, str1;endfunction param=params;par

24、am(1).name=P; param(1)。default=0.5;function topology,mote_IDs=topology(varargin);Nx=10; Ny=1; % number of points on the gridix=1;t=;distx=1;disty=5;X=1:distx:(Nx1)*distx+1;Y=1:disty:(Ny1)disty+1;for i=X for j=Y t=t; i,j; endendtopology=t;mote_IDs=1:Nx*Ny; function x=animationpersistent anim_dataif i

25、sempty(anim_data) small=5; medium=20; large=50; % Event_name Animated Color/on/off/toggle Size anim_def=。. Init_Application, 1, 0 0 0 , small, 。 Packet_Sent, 2, 1 0 0 , small, 。 Packet_Received, 3, 1 0 0 , small, .。 Collided_Packet_Received, 4, 1 0 0 , small, .。 Clock_Tick, 0, 0 0 0 , small, 。 Chann

26、el_Request, 0, 0 0 0 , small, .。 Channel_Idle_Check, 1, 1 0 0 , small, 。 Packet_Receive_Start, 0, 0 1 0 , small, . Packet_Receive_End, 0, 0 0 0 , small, 。. Packet_Transmit_Start, 1, 1 0 0 , medium, .。 Packet_Transmit_End, 1, 0 1 0 , small; for i=1:length(anim_def) a=anim_defi; if i=1 anim_data=struc

27、t(event, a1, animated, a2, color, a3, size, a4); else anim_data(i)=struct(event, a1, animated, a2, color, a3, size, a4); end endendx=anim_data;function application(S)S; persistent app_data S; global ID tS; t, event, ID, data=get_event(S);S; topology, mote_IDs=prowler(GetTopologyInfo);S; ix=find(mote

28、_IDs=ID);S; if strcmp(event, Init_Application) S; try memory=app_dataix; catch memory=; end, S; endS; SENDER_ID=sim_params(get_app, Start_Mote); if isempty(SENDER_ID), SENDER_ID=1; endswitch eventcase Init_Application signal_strength=1; memory=struct(send,1, signal_strength, signal_strength); if ID=

29、SENDER_ID % this node starts flood Set_Clock(1000) end PrintMessage(i) case Packet_Sent memory。send=0; PrintMessage(s) case Packet_Received data。data % message % data.signal_strength received signal strength if memory.send p=sim_params(get_app, P); if isempty(p); p=。3; end % p=0.3; p is forced to 0。

30、3 / Comment this line if you want to use it for optimization if randp Send_Packet(radiostream(data。data, memory。signal_strength); end memory。send=0; PrintMessage(r) endcase Collided_Packet_Received this is for debug purposes onlycase Clock_Tick Send_Packet(radiostream(this is the message, memory。sig

31、nal_strength);case GuiInfoRequest if isempty(memory) disp(sprintf(Memory Dump of mote ID d:n,ID)); disp(memory) else disp(sprintf(No memory dump available for node d.n,ID); endcase Application_Stopped % this event is called when simulation is stopped/suspended case Application_Finished % this event

32、is called when simulation is finished otherwise error(Bad event name for application: event)endS; app_dataix=memory;S;function b=Send_Packet(data);global ID tradio=prowler(GetRadioName);b=feval(radio, Send_Packet, ID, data, t);function b=Set_Clock(alarm_time);global IDprowler(InsertEvents2Q, make_ev

33、ent(alarm_time, Clock_Tick, ID));function PrintMessage(msg)global IDprowler(TextMessage, ID, msg)function varargout=infotitle1=Application FLOOD2D;str1= This application illustrates the flooding algorithm in 2D。; .。 ;.。. The sender mote transmits a message。 Each mote receiving the;。. message retrans

34、mits it with probability p. ;.。 The value of p can be set in the Application Parameters;.。. window. The default value is p=0。5。;.。 ;。 The starting node can also be selected (parameter Start_Mote)。;.。 Try 1 to start from the lower left corner, and 55 to start from;。. the center of the (10x10) grid.;。

35、. ;。. If p is too low, the flood dies out before every mote could;.。 receive the message。 If p it too high, the message is;.。. retransmitted several times after every mote have received it, ;。.。 thus causing an unnecessarily high settling time.;。.。 ;.。 The optimal value of p highly depends on topolo

36、gy。;。 ;。. You can change the topology by changing the parameters X_Number,;. Y_Number, and Distance.;.。 ;if nargout=0 helpwin( title1, str1, Application Info)else varargout= title1, str1;endfunction param=params;param(1).name=P; param(1)。default=0。5;param(2).name=Start_Mote; param(2).default=1;param

37、(3)。name=X_Number; param(3).default=10;param(4)。name=Y_Number; param(4).default=10;param(5).name=Distance; param(5)。default=1;function topology,mote_IDs=topology(varargin);ix=1;t=;dist=1; Nx=10; Ny=10; % number of points on the gridNx =sim_params(get_app, X_Number); if isempty(Nx), Nx=10; endNy =sim

38、_params(get_app, Y_Number); if isempty(Ny), Ny=10; enddist=sim_params(get_app, Distance); if isempty(dist), dist=1; endX=1:dist:(Nx-1)dist+1;Y=1:dist:(Ny-1)dist+1;for i=X for j=Y t=t; i,j; endendtopology=t;mote_IDs=1:NxNy; 6. 实验结果7. 结论名称主要思想Flooding收到数据的节点向所有邻居节点广播报文Gossiping收到的数据节点随机选取地选择一个邻节点转发报文SAR依据每条路径上的能量资源和QoS要求来决策路由SPIN根据临时的请求、应答的方式转发数据Flooding中节点的能耗较快。所以使用SFD时网络检测到的事件总数较Flooding多,网络检测事件的平均能耗较Flooding低.通过实验我们对目前传感器网络路由方面的研究进行了分析,并对常见的路由算法进行分类,详细地描述了现有的算法,并阐述了它们各自的优缺点。

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 应用文书 > 合同范本

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服