版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实验报告课程无线传感网络各类路由协议仿真1实验目的网络数据传输离不开路由协议,路由协议是其组网的基础,路由协议是无线 传感器网络研究的重点之一,其主要的设计冃标是降低节点能量消耗,延长网络 的生命周期。本次实验将仿真各类无线传感器网络路由协议。2. 实验要求争収考虑全面,考虑到各因素对各类协议的彫响,以提高无线传感网络的性能。3. 设计思想(1) flooding泛洪是一种传统的路由技术,不要求维护网络的拓扑结构,并进行路由计算, 接收到消息的节点以广播形式转发分组。对于自组织的传感器网络,泛洪路由是 一种较直接的实现方法,但消息的"内爆” (implosion)和“重叠"
2、(overlap)是其固有的 缺陷。为了克服这些缺陷,s.hedetniemi等人提出了gossiping策略,节点随机选 取一个相邻节点转发它接收到的分组,而不是采用广播形式。这种方法避免了消 息的“内爆'观熟但有可能增加端到端的传输延时。flooding路由协议中的内爆和重叠问题(2) spin (sensor protocol for information via negotiation)spin是以数据为中心的自适应路由协议,通过协商机制来解决泛洪算法中的“内爆”和“重叠订可题。传感器节点仅广播采集数据的描述信息,当有相应的请 求时,才有目的地发送数据信息。spin协议中有3
3、种类型的消息,即adv, req 和data。adv用于新数据广播。当一个节点有数据可共享时,它以广播方式向外发送 data数据包中的元数据。req用于请求发送数据。当一个节点希望接收data数据包时,发送req数据 包。data包含附上元数据头(meta-header)的实际数据包。spin协议有4种不同的形式: spin-pp:采用点到点的通信模式,并假定两节点间的通信不受其他节点的干 扰,分组不会丢失,功率没有任何限制。要发送数据的节点通过adv向它的相 邻节点广播消息,感兴趣的节点通过req发送请求,数据源向请求者发送数据。 接收到数据的节点再向它的相邻节点广播adv消息,如此重复,使
4、所有节点都 有机会接收到任何数据。 spin-ec:在spin-pp的基础上考虑了节点的功耗,只有能够顺利完成所有任务 且能量不低于设定阈值的节点才可参与数据交换。-spin-bc:设计了广播信道,使所有在有效半径内的节点可以同时完成数据交 换。为了防止产生重复的req请求,节点在听到adv消息以后,设定一个随机 定时器来控制req请求的发送,其他节点听到该请求,主动放弃请求权利。 spin-rl:它是对spin-bc的完善,主要考虑如何恢复无线链路引入的分组差 错与丢失。记录adv消息的相关状态,如果在确定时间间隔内接收不到请求数 据,则发送重传请求,重传请求的次数有一定的限制。图3.2表明
5、了spin协议的 路由建立与数据传送。(a) ad* propa ration(b) draiequect(b)赠w*(c) data tranter(c)鱷传送(diadvpiopasation(d) adv扩散(e) data tequeit ()mt(f) data nansfei (0址血传送spin协议的路由建立与数据传送基于数据描述的协商机制和能量自适应机制的sp创协议能够很好地解决传 统的flooding协议所带来的信息爆炸、信息重复和资源浪费等问题。此外,由于协议中每个节点只需知道其单跳邻居节点的信息,拓扑改变呈现本地化特征。sp 州协议的缺点是数据广告机制不能保证数据的可靠传
6、递,如果对数据感兴趣的节 点远离源节点或者在源节点和目的节点中间的节点对数据不感兴趣,那么数据就 不可能被传递到目的地。因此,对于入侵发现等需耍在定期间隔内可靠传递数据 的应用系统来说,sp州并不是一个很好的选择。(3) sar (sequential assignment routing)在选择路径时,有序分配路由(sar)策略充分考虑了功耗、qos和分组优先 权等特殊要求,采用局部路径恢复和多路经备份策略,避免节点或链路失败时进 行路由重计算需要的过量计算开销。为了在每个节点与sink节点间生成多条路 经,需要维护多个树结构,每个树以落在sink节点有效传输半径内的节点为根向 外生长,枝干
7、的选择需满足一定qos要求并要有一定的能量储备。这一处理使大 多数传感器节点可能同时屈于多个树,可任选其一将采集数据回传到sink节点。(4) leach (low energy adaptive clustering hierarchy)leach是mit的chandrakasan等人为无线传感器网络设计的低功耗自适应 聚类路由算法。与一般的平面多跳路由协议和静态聚类算法相比,leach可以将 网络生命周期延长15%,主要通过随机选择聚类首领,平均分担中继通信业务来实 现。leach定义了“轮七ound)的概念,一轮由初始化和稳定工作两个阶段组成。 为了避免额外的处理开销,稳定态一般持续相对
8、较长的时间。如图3.4所示:初始化阶段稳定工作阶段吋间leach协议的时序图在初始化阶段,聚类首领是通过下面的机制产生的。传感器节点生成0,1之间的随机数,如果大于阈值t,则选该节点为聚类首领.t的计算方法如下:1-prmod(%)(3.1)其中p为节点中成为聚类首领的百分数,i是当前的轮数。当簇头选定之后,簇头节点主动向网络中节点广播自己成为簇头的消息 (adv_ch)o接收到此消息的节点,依据接收信号的强度,选择它所要加入的簇, 并发消息通知相应的簇头(join_req)。基于时分多址(time division multiple address,简称tdma)的方式,簇头节点为其中的每个
9、成员分配通信时隙,并以 广播的形式通知所有的簇内节点(advsch)o这样保证了簇内每个节点在指定的 传输时隙进行数据传输,而在其他时间进入休眠状态,减少了能量消耗。在稳定 工作阶段,节点持续釆集监测数据,在自身传输时隙到来时把监测数据传给簇头 节点(data),如图3.5所示。簇头节点对接收到数据进行融合处理之后,发送 到sink节点,这是一种减小通信业务量的合理工作模式。持续一段时间以后,ooi)3)整个网络进入下一轮工作周期,重新选择簇头节点。leach协议采用动态转换簇头的方法来平均网络节点的能量消耗,使因能 量耗尽而失效的节点呈随机分布状态,因而与一般的多跳路由协议和静态簇算法 相比
10、,leach可以将网络生命周期延长15%。但是leach协议在每轮固定簇 头节点后在划分簇的过程屮,簇头节点开销较大。并且簇头节点的选择无法达到 最优,有可能簇头节点位于网络的边缘或者几个簇头节点相邻,某些节点不得不 传输较远的距离来与簇头通信,这就导致了大量能量消耗。而且leach协议所 有簇头节点直接与sink节点通信,采用连续数据发送模式和单跳路径选择模式, 使得每轮中簇头节点能耗巨大,因此不适合在大规模的传感器网络屮应用。(5) teen (threshold sensitive energy efficient sensor network protocol)依照应用模式的不同,通常
11、可以简单地将无线自组织网络(包括传感器网络 和ad-hoc网络)分为主动(proactive)和响应(reactive)两种类型。主动型传感器网络 持续监测周围的物质现象,并以恒定速率发送监测数据;而响应型传感器网络只 是在被观测变量发生突变吋才传送数据。相比之下,响应型传感器网络更适合应 用在敏感时间的应用中oteen和leach的实现机制非常相似,只是前者是响应 型的,而后者属于主动型传感器网络。在teen中定义了硕、软两个门限值,以 确定是否需要发送监测数据。当监测数据第一次超过设定的硬门限吋,节点用它作为新的硕门限,并在接着到来的时隙内发送它。在接下来的过程中,如果监测 数据的变化幅度
12、大于软门限界定的范围,则节点传送最新采集的数据,并将它设 定为新的硬门限。通过调节软门限值的大小,可以在监测精度和系统能耗之间取 得合理的平衡。图3.6表示的是teen协议中由聚簇构成的层次结构。teen协议中由聚簇构成的层次结构tene适用于实时性要求较高的应用场合,比如入侵警报,爆炸预警等,用 户可以及时获取感兴趣的信息。而且用户可以通过设置不同的软门限方便地平衡 监测的准确性与系统节能性两项指标。但是这个方案也有一些不足之处,例如门 限值达不到,节点就永远不会和簇头节点通信,用户就无法从网络得到任何数据; 没有相应的机制去区分那些没有感应到足够大变化的节点和处于关闭状态的节 点,所以te
13、en协议不适合应用在。(6) pegagis (power-efficient gathering in sensor information system)pegasis由leach发展而来。它假定组成网络的传感器节点是同构且静止 的。节点发送能量递减的测试信号,通过检测应答来确定离自己最近的相邻节点。 在收集数据前,首先利用贪心算法将网络中的所有节点连接成一条单链。通过这 种方式,网络中的所有节点能够了解彼此的位置关系,进而每个节点依据自己的 位置选择所展的聚类,聚类的首领向链的两端发出收集数据的请求,数据从单链 的两个端点向首领流动。中间节点在传递数据前要执行融合操作,最终由首领节 点将
14、结果数据传送给sink节点。因为pegasis中每个节点都以最小功率发送数据分组,并有条件完成必要的数据融合,减小业务流量。因此,整个网络的功耗较 小。研究结果表明,pegasis支持的传感器网络的生命周期是leach的近两倍。4实验器材与工具matlab5程序源代码function x=animation_data small=5; medium=20; large=50;%event_name animatedanim_def=.tnit_application;0,'packecsent1,1,!packet_received1,'collided_packet_rece
15、ived', 0, clock.tick1,0,'channel_request;0,'channeldle_check,1,*packet_receive_start',0,'packet_receive_end,0,'packectransmicstart*,1,tackectransmicend*,0,coior/ on/off/toggle size0001,0 10,0 10,100,000,000,100, 0 10,000, 1 00,0 10,small,small,small,.small,.small,.small,small
16、,. small,small,. medium,.small;for i=l :length(anim_def)a=anim_defi;x(i)=struct(revent al, 'animated; a2, 'color; a3, 'size; a4); end function application(s)% do not edit simulator code (lines that begin with s;)s;persistent app_datas;global id ts;t, event, id, data=get_event(s);s;topolo
17、gy, mote_ids=prowler(,gettopologyinfol);s;s;s;ix=find(mote_ids=id);if strcmp(event, 'init_applicatioif)try memory=app_data ix; catch memory=; end,s;ends;switch eventcase tnit_application'signal_strength=l;if id=1 % first node starts floodset_clock(1000)endprintmessage(丫)case tackecsentprintm
18、essage(,sf)case ,packet_received,% data.data% message% data.signal_strength % received signal strengthif memory.sendp=sim_params(!get_app p);if isempty(p); p=5; endif rand<psend_packet(radiostream(data.data, memory.signal_strength); endmemory.send=0;printmessage(t)end case ollided-packet-received
19、1% this is for debug purposes onlycase 'clock_tick'send_packet(radiostream(,message for 00111 from golomb1, memory.signal_strength);case 'guilnforequesfdisp(sprintf(fmemory dump of mote id# %d:nid); disp(memory)case ,application_stopped,% this event is called when simulation is stopped/s
20、uspendedcase 'application_finishect% this event is called when simulation is finishedotherwiseerror(fbad event name for application: 1 event)ends;app_data ix =memory;function b=send_packet(data);global id tradio=prowler(,getradioname,);b=feval(radio, 'send_packet; id, data, t);function b=set
21、_clock(alarm_time);global idprowler(finsertevents2q make_event(alarm_time, fclock_tick id);function printmessage(msg)global idprowler(textmessage id, msg)function led(msg)global idprowler('led; id, msg)function varargout=infotitled1 application flood id1;strl = this application illustrates the s
22、imple flooding algorithm.1;the sender mote transmits a message each mote receiving the;'message retransmits it with probability p/ ;the value of p can be set in the napplication parameters111;. window. the default value is p=05;'if p is too low, the flood dies out before every mote could1;.
23、deceive 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 topology/;.'you can change the topology by editing the file flood1d_topolog
24、y/;.'see also fl00d2d.'.";if nargout=0helpwin( title 1, strl, application info')else varargout= title 1, strl;endfunction param=params;param( 1 ).name二p;param( 1 )>default=0.5;function topology,mote_ids=topology(varargin);nx= 10; ny= 1; % number of points on the gridix=l;t=j;dist
25、x=l;disty=5;x= 1:distx:(nx-l )*distx+1;y=1:disty:(ny-l )*disty+1;for i=xforj=yt=t; ij;endendtopology=t;mote_ids= 1:nx*ny;function x=animationpersistent anim_dataif isempty(anim_data)small=5; medium=20; large=50;%event_nameanimatedcolor/ on/off/togglesizeanim_def=.small,.'inicapplication',1,0
26、00,small,tackecsent*,2,100,small,.*packet_received',3,100,small,'collided_packet_received',4,100,small,.,clock_tick,0,000,end end end xhanimda 目function application(s)persistent appldag global id r feven 厂 ipdagllgerevenxs)-topology- motelidsllprowor(gettopoogyinfo); ixhfind(motelidsh
27、9;'d)八 if smcmp(evenh initlapplicatiorf) iry memory happdata(ix7rcahh memory “二八 endendsenderdhsimlparams(getlappstartlmote);if isempry(senderiid)" senderiid二 endswitch even- case initlapp-ication- signallstrengthh 1;charme 一request 09small):channe 匚 dolcheck 一 “sm 巴二:packerreceivesgrr-psma
28、 三:packetlrec2.velendpsmall):packaitransmirlsiarr-lmedium-:(-packeitransmrend 1 “small;00 0 k u 0 0 l 6 10k 00 0 l u 0 0 l o一 0 kforn-1 二 cngs-(animldedauanimldef 三八ifn-hla2.mldhahstsc(evesa(二a nimaed a(2l coora(3 丁 -size a(4 一);elseanimlde.a(ihstruct(qventa(二animaoda(2h co lora(3h size 34 一);memory
29、=struct(lsend 1, fsignal_strength signal_strength);if id=sender_id % this node starts floodset_clock(1000)endprintmessage(,i,)case tackecsent1memory.send=0;printmessage(s,)case tackecreceived*% data.data% message% data.signal_strength % received signal strengthif memory.sendp=sim_params(,get_app p);
30、if isempty(p); p=.3; end% p=0.3;% p is forced to 0.3 / comment this line if you want to use it foroptimizationif rand<psend_packet(radiostream(data.data, memory.signal_strength);endmemory.send=0;printmessage(t)endcase ollided-packet-received1% this is for debug purposes onlycase 'clock_tick
31、39;send_packet(radiostream(fthis is the message1, memory.signal_strength);case 'gu订nforequest'if isempty(memory) disp(sprintf(,memory dump of mote id# %d:nid); disp(memory) elsedisp(sprintf(fno memory dump available for node %d.n'jd);endcase 'application_stoppect% this event is calle
32、d when simulation is stopped/suspendedcase 'application_finished% this event is called when simulation is finished otherwiseerror(fbad event name for application:1 event)s;app_data ix二memory;s;function b=send_packet(data);global id tradio=prowler(/getradioname,);b=feval(radio, 'send_packet;
33、id, data, t);function b=set_clock(alann_time);global idprowler(rinsertevents2q make_event(alarm_time, rclock_tick id);function printmessage(msg)global idprowlerctextmessage1, id, msg) function varargout=infotitle 1 application fl00d2d1; strl = this application illustrates the flooding algorithm in 2
34、d.1;the sender mote transmits a message. each mote receiving the: 'message retransmits it with probability p/the value of p can be set in the napplication parameters111;. 'window. the default value is p=o.5j;.the starting node can also be selected (parameter start_mote)/;. try 1 to start fro
35、m the lower left corner, and 55 to start from: the center of the (10x10) grid/;.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 topology/;.you can change the topology by changing the parameters x_number/;. ,y_number, and dista
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 寒假安全培训直播内容2026年全套攻略
- 2026年消防队伍安全培训内容重点
- 2026年冲孔桩安全培训内容深度解析
- 延边朝鲜族自治州龙井市2025-2026学年第二学期六年级语文第五单元测试卷部编版含答案
- 2026年元宇宙数据隐私保护合同
- 菏泽地区郓城县2025-2026学年第二学期六年级语文第五单元测试卷部编版含答案
- 邯郸市魏县2025-2026学年第二学期六年级语文第五单元测试卷部编版含答案
- 辽源市龙山区2025-2026学年第二学期六年级语文第五单元测试卷部编版含答案
- 通化市柳河县2025-2026学年第二学期四年级语文第五单元测试卷(部编版含答案)
- 昌吉回族自治州木垒哈萨克自治县2025-2026学年第二学期三年级语文第六单元测试卷(部编版含答案)
- 贵州省六盘水市2025-2026学年九年级上学期期末语文试题(含答案)
- 一年级数学5以内加减法计算专项练习题(每日一练共42份)
- 2026年山西云时代技术有限公司校园招聘笔试备考题库及答案解析
- 数字孪生智慧管网监测系统构建课题申报书
- 统编版(新版)道德与法治八年级下册课件13.1全面依法治国的指导思想
- 汽车驾驶员技师论文
- 2025年三季度云南航空产业投资集团招聘(云南云航投现代物流有限公司岗位)考试笔试历年常考点试题专练附带答案详解2套试卷
- 3.长方体和正方体(单元测试)2025-2026学年五年级数学下册人教版(含答案)
- 八大特殊作业安全管理流程图(可编辑)
- 初中劳动教育试题及答案
- 清明文明安全祭扫课件
评论
0/150
提交评论