【WSN通信】Matlab实现低能耗自适应聚类层次结构协议

LEACH是一种低能量自适应聚类层次的MAC协议,旨在降低无线传感器网络的能耗,延长网络寿命。节点通过随机算法轮换成为簇头,非簇头节点则以TDMA方式向最近的簇头发送数据。协议还利用CDMA减少集群间的干扰。仿真代码展示了LEACH的工作流程,并提供了相关统计信息。

1 简介

低能量自适应聚类层次(“LEACH”)是一种基于TDMA的MAC协议,它与聚类和无线传感器网络(WSN)中的简单路由协议相结合。 LEACH 的目标是降低创建和维护集群所需的能源消耗,以提高无线传感器网络的使用寿命。

LEACH 是一种分层协议,其中大多数节点向簇首传输数据,簇首聚合和压缩数据并转发到基站(宿)。每个节点在每一轮使用随机算法来确定它是否会成为本轮的簇头。 LEACH 假设每个节点都有一个足够强大的无线电,可以直接到达基站或最近的簇头,但是一直以全功率使用这个无线电会浪费能量。已经成为簇首的节点在 P 轮中不能再次成为簇首,其中 P 是簇首的期望百分比。此后,每个节点都有 1/P 的概率再次成为簇头。在每一轮结束时,不是簇头的每个节点都会选择最近的簇头并加入该簇。然后,簇头为其簇中的每个节点创建一个调度以传输其数据。根据簇头创建的调度,所有不是簇头的节点仅以 TDMA 方式与簇头通信。他们这样做使用到达簇头所需的最小能量,并且只需要在其时隙内保持无线电开启。

LEACH 还使用 CDMA,以便每个集群使用一组不同的 CDMA 代码,以最大限度地减少集群之间的干扰。

2 部分代码

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                      %% SEP: A Stable Election Protocol for clustered                        %%      heterogeneous wireless sensor networks                          %%                                                                      %% (c) Georgios Smaragdakis                                             %% WING group, Computer Science Department, Boston University           %%                                                                      %% You can find full documentation and related information at:          %% http://csr.bu.edu/sep                                                %%                                                                      %  % To report your comment or any bug please send e-mail to:             %% gsmaragd@cs.bu.edu                                                   %%                                                                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                      %% This is the SEP [1] code we have used.                               %%                                                                      %% [1]  Georgios Smaragdakis, Ibrahim Matta and Azer bestavros,         %      %      "SEP: A Stable Election Protocol for clustered                  %%      heterogeneous wireless sensor networks",                        %%      Second International Workshop on Sensor and Actor Network       %%      Protocols and Applications (SANPA 2004),Boston MA, August       %                         %      2004.                                                           %%                                                                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%Field Dimensions - x and y maximum (in meters)xm=100;ym=100;%x and y Coordinates of the Sinksink.x=0.5*xm;sink.y=0.5*ym;%Number of Nodes in the fieldn=100;%Optimal Election Probability of a node%to become cluster headp=0.1;%Energy Model (all values in Joules)%Initial Energy Eo=0.5;%Eelec=Etx=ErxETX=50*0.000000001;ERX=50*0.000000001;%Transmit Amplifier typesEfs=10*0.000000000001;Emp=0.0013*0.000000000001;%Data Aggregation EnergyEDA=5*0.000000001;%Values for Hetereogeneity%Percentage of nodes than are advancedm=0.1;%\alphaa=1;%maximum number of roundsrmax=1000;%%%%%%%%%%%%%%%%%%%%%%%%% END OF PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%Computation of dodo=sqrt(Efs/Emp); %Creation of the random Sensor Networkfigure(1);for i=1:1:n    S(i).xd=rand(1,1)*xm;    XR(i)=S(i).xd;    S(i).yd=rand(1,1)*ym;    YR(i)=S(i).yd;    S(i).G=0;    %initially there are no cluster heads only nodes    S(i).type='N';       temp_rnd0=i;    %Random Election of Normal Nodes    if (temp_rnd0>=m*n+1)         S(i).E=Eo;        S(i).ENERGY=0;        %%%%plot(S(i).xd,S(i).yd,'o');        hold on;    end    %Random Election of Advanced Nodes    if (temp_rnd0<m*n+1)          S(i).E=Eo*(1+a)        S(i).ENERGY=1;        %%%%plot(S(i).xd,S(i).yd,'+');         hold on;              end endendhold on;countCHs;rcountCHs=rcountCHs+countCHs;%Code for Voronoi Cells%Unfortynately if there is a small%number of cells, Matlab's voronoi%procedure has some problems%[vx,vy]=voronoi(X,Y);%plot(X,Y,'r*',vx,vy,'b-');% hold on;% voronoi(X,Y);% axis([0 xm 0 ym]);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   STATISTICS    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                                     %%  DEAD  : a rmax x 1 array of number of dead nodes/round %  DEAD_A : a rmax x 1 array of number of dead Advanced nodes/round%  DEAD_N : a rmax x 1 array of number of dead Normal nodes/round%  CLUSTERHS : a rmax x 1 array of number of Cluster Heads/round%  PACKETS_TO_BS : a rmax x 1 array of number packets send to Base Station/round%  PACKETS_TO_CH : a rmax x 1 array of number of packets send to ClusterHeads/round%  first_dead: the round where the first node died                   %                                                                                     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3 仿真结果

4 参考文献

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值