文章目录

  • 一、理论基础
  • 二、方法描述
    • 1、节点分簇
    • 2、节点能量消耗
  • 三、仿真分析
    • 1、节点分簇
    • 2、节点能量消耗
  • 四、参考文献

一、理论基础

LEACH(Low-Energy Adaptive Clustering Hierarchy)是由Wendi Rabiner Heinzelman、Anantha Chandrakasan和Hari Balakrishnan三人于2000年提出的一种无线传感器网络路由协议,它利用簇头的随机轮换在网络中的传感器之间均匀地分配能量负载。LEACH使用局部协调来实现动态网络的可伸缩性和健壮性,并将数据融合纳入路由协议中,以减少必须传输到基站的信息量。仿真结果表明,与传统的路由协议相比,LEACH协议的能耗降低了8倍。此外,LEACH能够在传感器中均匀地分配能量耗散,使网络的有效系统的生命周期延长一倍。

二、方法描述

1、节点分簇

簇头选举初始阶段,每个节点根据所建议网络簇头的百分比(事先确定)和节点已经成为簇头的次数来确定自己是否当选为簇头。每个节点产生一个0-1的随机数字,如果该数字小于阈值,节点成为当前轮的簇头。阈值定义为:
T(n)={p1−p×(rmod1p),n∈G0,else(1)T(n)=\begin{dcases} \frac{p}{1-p×(r mod \frac1p)},\quad n∈G\\0, \quad \quad \quad \quad \quad \quad \quad \quad else\end{dcases}\tag{1}T(n)=⎩⎨⎧​1−p×(rmodp1​)p​,n∈G0,else​(1)其中,nnn为当前节点,ppp为预期的簇头百分比,rrr为当前轮数,GGG是最近1/p1/p1/p轮里没有成为簇头的节点的集合。

2、节点能量消耗

传感器节点在传输kkkbit数据到距离该传感器节点ddd的邻接传感器节点时需消耗的能量如式(2)所示:ETx(k,d)={Eelec⋅k+εfs⋅k⋅d2,d<d0Eelec⋅k+εmp⋅k⋅d4,d≥d0(2)E_{Tx}(k,d)=\begin{dcases} E_{elec}\boldsymbol ·k+\varepsilon_{fs}\boldsymbol ·k\boldsymbol ·d^2,d<d_{0}\\E_{elec}\boldsymbol ·k+\varepsilon_{mp}\boldsymbol ·k\boldsymbol ·d^4,d\geq d_0\end{dcases}\tag{2}ETx​(k,d)={Eelec​⋅k+εfs​⋅k⋅d2,d<d0​Eelec​⋅k+εmp​⋅k⋅d4,d≥d0​​(2)节点接收到kkkbit数据需消耗的能量如式(3)所示:ERx(k)=Eelec⋅k(3)E_{Rx}(k)=E_{elec}\boldsymbol ·k\tag{3}ERx​(k)=Eelec​⋅k(3)其中,EelecE_{elec}Eelec​是传感器处理单位bit的数据时所需要的能量值,εfs\varepsilon_{fs}εfs​和εmp\varepsilon_{mp}εmp​是通信能量参数,d0d_0d0​是阈值。如果距离ddd小于d0d_0d0​,则使用自由空间传播(free space communication)模型; 否则,使用多路径衰减信道(multipath fading channel)模型。阈值d0d_0d0​的计算方法如式(4) 所示:d0=εfsεmp(4)d_0=\sqrt {\frac {\varepsilon_{fs}}{\varepsilon_{mp}}}\tag{4}d0​=εmp​εfs​​​(4)

三、仿真分析

节点分布如图1所示。

图1 100节点随机分布图

1、节点分簇

仿真程序如下:

%% 清空环境变量
clear;
clc;%% 初始化参数
xmin = 0; xmax = 100;          % 区域x轴范围
ymin = 0; ymax = 100;            % 区域y轴范围
sink.x = 50;                     % 基站x轴 50
sink.y = 200;                    % 基站y轴 200
n = 100;                         % 节点总数
p = 0.05;                        % 簇头概率
Eelec = 50*10^(-9);
Efs=10*10^(-12);
Emp=0.0013*10^(-12);
ED=5*10^(-9);
d0 = sqrt(Efs/Emp);
packetLength = 4000;
ctrPacketLength = 100;
rmax = 2000;figure;
%% 节点随机分布
for i = 1:nNode(i).xd = rand*(xmax-xmin)+xmin;Node(i).yd = rand*(ymax-ymin)+ymin;   % 随机产生100个点Node(i).type = 'N';        % 进行选举簇头前先将所有节点设为普通节点Node(i).E = 0.5;           % 初始能量Node(i).CH = 0;            % 保存普通节点的簇头节点,-1代表自己是簇头Node(i).d = sqrt((Node(i).xd-sink.x)^2+(Node(i).yd-sink.y)^2);Node(i).G = 0;             % 候选集标志plot(Node(i).xd, Node(i).yd, 'o', sink.x, sink.y, 'p', 'LineWidth', 2);hold on;
end
legend('节点', '基站');
xlabel 'x'; ylabel 'y'; title 'WSN分布图';%%
alive = zeros(rmax, 1);        % 每轮存活节点数
re = zeros(rmax, 1);           % 每轮节点总能量
ce = zeros(rmax, 1);           % 每轮节点消耗总能量
for r = 1:10figure;if mod(r, round(1/p)) == 0for i = 1:nNode(i).G=0;endendfor i = 1:nif Node(i).E > 0Node(i).type = 'N';Node(i).CH = 0;alive(r) = alive(r)+1;re(r) = re(r)+Node(i).E;endendif alive(r) == 0break;end%% 簇头选举cluster = 0;for i = 1:nif  Node(i).E > 0temp_rand = rand;if Node(i).G <= 0 && temp_rand < p/(1-p*mod(r,round(1/p)))Node(i).type = 'C';      % 节点类型为簇头Node(i).G = 1;cluster = cluster + 1;% 簇头节点存入C数组C(cluster).xd = Node(i).xd;C(cluster).yd = Node(i).yd;C(cluster).dist = Node(i).d;C(cluster).id = i;plot(C(cluster).xd, C(cluster).yd, '*');text(Node(i).xd, Node(i).yd, num2str(i));hold on;CH = C;Node(i).CH = -1;% 广播自成为簇头distanceBroad = sqrt((xmax-xmin)^2+(ymax-ymin)^2);if distanceBroad > d0Node(i).E = Node(i).E- (Eelec*ctrPacketLength + Emp*ctrPacketLength*distanceBroad^4);ce(r) = ce(r)+Eelec*ctrPacketLength + Emp*ctrPacketLength*distanceBroad^4;elseNode(i).E = Node(i).E- (Eelec*ctrPacketLength + Efs*ctrPacketLength*distanceBroad^2);ce(r) = ce(r)+Eelec*ctrPacketLength + Efs*ctrPacketLength*distanceBroad^2;end% 簇头自己发送数据包能量消耗if Node(i).d > d0Node(i).E = Node(i).E- ((Eelec+ED)*packetLength+Emp*packetLength*Node(i).d^4);ce(r) = ce(r)+(Eelec+ED)*packetLength+Emp*packetLength*Node(i).d^4;elseNode(i).E = Node(i).E- ((Eelec+ED)*packetLength+Efs*packetLength*Node(i).d^2);ce(r) = ce(r)+(Eelec+ED)*packetLength+Efs*packetLength*Node(i).d^2;endendendend% 判断最近的簇头结点,如何去判断,采用距离矩阵for i = 1:nif Node(i).type == 'N' && Node(i).E > 0if cluster > 0Length = zeros(cluster, 1);for c = 1:clusterLength(c) = sqrt((Node(i).xd - C(c).xd)^2+(Node(i).yd-C(c).yd)^2);end[min_dis, min_dis_cluster] = min(Length);    % 找到距离簇头最近的簇成员节点plot(Node(i).xd, Node(i).yd, 'o');text(Node(i).xd, Node(i).yd, num2str(i));hold on;plot([Node(i).xd; Node(C(min_dis_cluster).id).xd], [Node(i).yd; Node(C(min_dis_cluster).id).yd]);hold on;% 接收簇头发来的广播的消耗Node(i).E = Node(i).E - Eelec*ctrPacketLength;ce(r) = ce(r)+Eelec*ctrPacketLength;% 加入这个簇,并发送数据给簇头if min_dis < d0Node(i).E = Node(i).E-(Eelec*(ctrPacketLength+packetLength)+Efs*(ctrPacketLength+packetLength)*min_dis^2);ce(r) = ce(r)+Eelec*(ctrPacketLength+packetLength)+Efs*(ctrPacketLength+packetLength)*min_dis^2;elseNode(i).E = Node(i).E-(Eelec*(ctrPacketLength+packetLength)+Emp*(ctrPacketLength+packetLength)*min_dis^4);ce(r) = ce(r)+Eelec*(ctrPacketLength+packetLength)+Emp*(ctrPacketLength+packetLength)*min_dis^4;endNode(i).CH = C(min_dis_cluster).id;% 簇头接收簇成员数据包消耗能量,接收加入消息和确认加入消息if min_dis > 0Node(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - (Eelec+ED)*packetLength; %接受簇成员发来的数据包Node(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - Eelec*ctrPacketLength; %接收加入消息ce(r) = ce(r)+(Eelec+ED)*packetLength+Eelec*ctrPacketLength;if min_dis > d0    % 簇头向簇成员发送确认加入的消息Node(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - (Eelec*ctrPacketLength+Emp*ctrPacketLength*min_dis^4);ce(r) = ce(r)+Eelec*ctrPacketLength+Emp*ctrPacketLength*min_dis^4;elseNode(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - (Eelec*ctrPacketLength+Efs*ctrPacketLength*min_dis^2);ce(r) = ce(r)+Eelec*ctrPacketLength+Efs*ctrPacketLength*min_dis^2;endendelseif Node(i).d < d0Node(i).E = Node(i).E-(Eelec*packetLength+Efs*packetLength*Node(i).d^2);ce(r) = ce(r)+Eelec*packetLength+Efs*packetLength*Node(i).d^2;elseNode(i).E = Node(i).E-(Eelec*packetLength+Emp*packetLength*Node(i).d^4);ce(r) = ce(r)+Eelec*packetLength+Emp*packetLength*Node(i).d^4;endendendendclear C;
end

随机选取4幅分簇图,如图2~5所示。

图2~5 LEACH分簇图

2、节点能量消耗

代码如下:

%% 清空环境变量
clear;
clc;xmin = 0; xmax = 100;          % 区域x轴范围
ymin = 0; ymax = 100;            % 区域y轴范围
sink.x = 50;                     % 基站x轴 50
sink.y = 200;                    % 基站y轴 200
n = 100;                         % 节点总数
p = 0.05;                        % 簇头概率
Eelec = 50*10^(-9);
Efs=10*10^(-12);
Emp=0.0013*10^(-12);
ED=5*10^(-9);
d0 = sqrt(Efs/Emp);
packetLength = 4000;
ctrPacketLength = 100;
rmax = 1500;figure;
%% 节点随机分布
for i = 1:nNode(i).xd = rand*(xmax-xmin)+xmin;Node(i).yd = rand*(ymax-ymin)+ymin;   % 随机产生100个点Node(i).type = 'N';        % 进行选举簇头前先将所有节点设为普通节点Node(i).E = 0.5;           % 初始能量Node(i).CH = 0;            % 保存普通节点的簇头节点,-1代表自己是簇头Node(i).d = sqrt((Node(i).xd-sink.x)^2+(Node(i).yd-sink.y)^2);Node(i).G = 0;             % 候选集标志plot(Node(i).xd, Node(i).yd, 'o', sink.x, sink.y, 'p', 'LineWidth', 2);hold on;
end
legend('节点', '基站');
xlabel 'x'; ylabel 'y'; title 'WSN分布图';%%
alive = zeros(rmax, 1);        % 每轮存活节点数
re = zeros(rmax, 1);           % 每轮节点总能量
ce = zeros(rmax, 1);           % 每轮节点消耗总能量
for r = 1:rmaxif mod(r, round(1/p)) == 0for i = 1:nNode(i).G=0;endendfor i = 1:nif Node(i).E > 0Node(i).type = 'N';Node(i).CH = 0;alive(r) = alive(r)+1;re(r) = re(r)+Node(i).E;endendif alive(r) == 0break;end%% 簇头选举cluster = 0;for i = 1:nif  Node(i).E > 0temp_rand = rand;if Node(i).G <= 0 && temp_rand < p/(1-p*mod(r,round(1/p)))Node(i).type = 'C';      % 节点类型为簇头Node(i).G = 1;cluster = cluster + 1;% 簇头节点存入C数组C(cluster).xd = Node(i).xd;C(cluster).yd = Node(i).yd;C(cluster).dist = Node(i).d;C(cluster).id = i;CH = C;Node(i).CH = -1;% 广播自成为簇头distanceBroad = sqrt((xmax-xmin)^2+(ymax-ymin)^2);if distanceBroad > d0Node(i).E = Node(i).E- (Eelec*ctrPacketLength + Emp*ctrPacketLength*distanceBroad^4);ce(r) = ce(r)+Eelec*ctrPacketLength + Emp*ctrPacketLength*distanceBroad^4;elseNode(i).E = Node(i).E- (Eelec*ctrPacketLength + Efs*ctrPacketLength*distanceBroad^2);ce(r) = ce(r)+Eelec*ctrPacketLength + Efs*ctrPacketLength*distanceBroad^2;end% 簇头自己发送数据包能量消耗if Node(i).d > d0Node(i).E = Node(i).E- ((Eelec+ED)*packetLength+Emp*packetLength*Node(i).d^4);ce(r) = ce(r)+(Eelec+ED)*packetLength+Emp*packetLength*Node(i).d^4;elseNode(i).E = Node(i).E- ((Eelec+ED)*packetLength+Efs*packetLength*Node(i).d^2);ce(r) = ce(r)+(Eelec+ED)*packetLength+Efs*packetLength*Node(i).d^2;endendendend% 判断最近的簇头结点,如何去判断,采用距离矩阵for i = 1:nif Node(i).type == 'N' && Node(i).E > 0if cluster > 0Length = zeros(cluster, 1);for c = 1:clusterLength(c) = sqrt((Node(i).xd - C(c).xd)^2+(Node(i).yd-C(c).yd)^2);end[min_dis, min_dis_cluster] = min(Length);    % 找到距离簇头最近的簇成员节点% 接收簇头发来的广播的消耗Node(i).E = Node(i).E - Eelec*ctrPacketLength;ce(r) = ce(r)+Eelec*ctrPacketLength;% 加入这个簇,并发送数据给簇头if min_dis < d0Node(i).E = Node(i).E-(Eelec*(ctrPacketLength+packetLength)+Efs*(ctrPacketLength+packetLength)*min_dis^2);ce(r) = ce(r)+Eelec*(ctrPacketLength+packetLength)+Efs*(ctrPacketLength+packetLength)*min_dis^2;elseNode(i).E = Node(i).E-(Eelec*(ctrPacketLength+packetLength)+Emp*(ctrPacketLength+packetLength)*min_dis^4);ce(r) = ce(r)+Eelec*(ctrPacketLength+packetLength)+Emp*(ctrPacketLength+packetLength)*min_dis^4;endNode(i).CH = C(min_dis_cluster).id;% 簇头接收簇成员数据包消耗能量,接收加入消息和确认加入消息if min_dis > 0Node(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - (Eelec+ED)*packetLength; %接受簇成员发来的数据包Node(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - Eelec*ctrPacketLength; %接收加入消息ce(r) = ce(r)+(Eelec+ED)*packetLength+Eelec*ctrPacketLength;if min_dis > d0        % 簇头向簇成员发送确认加入的消息Node(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - (Eelec*ctrPacketLength+Emp*ctrPacketLength*min_dis^4);ce(r) = ce(r)+Eelec*ctrPacketLength+Emp*ctrPacketLength*min_dis^4;elseNode(C(min_dis_cluster).id).E = Node(C(min_dis_cluster).id).E - (Eelec*ctrPacketLength+Efs*ctrPacketLength*min_dis^2);ce(r) = ce(r)+Eelec*ctrPacketLength+Efs*ctrPacketLength*min_dis^2;endendelse                 % 无簇头选出,直接发送数据包到基站if Node(i).d < d0Node(i).E = Node(i).E-(Eelec*packetLength+Efs*packetLength*Node(i).d^2);ce(r) = ce(r)+Eelec*packetLength+Efs*packetLength*Node(i).d^2;elseNode(i).E = Node(i).E-(Eelec*packetLength+Emp*packetLength*Node(i).d^4);ce(r) = ce(r)+Eelec*packetLength+Emp*packetLength*Node(i).d^4;endendendendclear C;
end
%% 绘图显示
figure;
plot(1:rmax, alive, 'r', 'LineWidth', 2);
xlabel '轮数'; ylabel '每轮存活节点数';
figure;
plot(1:rmax, re, 'b', 'LineWidth', 2);
xlabel '轮数'; ylabel '每轮剩余总能量';
figure;
plot(1:rmax, ce, 'm', 'LineWidth', 1);
xlabel '轮数'; ylabel '每轮消耗总能量';

每轮节点存活个数如图6所示。

图6 每轮节点存活个数

每轮节点总剩余能量如图7所示。

图7 每轮节点总剩余能量

每轮节点总消耗能量如图8所示。

图8 每轮节点总消耗能量

四、参考文献

[1] W. R. Heinzelman, A. Chandrakasan, H. Balakrishnan. Energy-efficient communication protocol for wireless microsensor networks[C]. Proceedings of the 33rd Annual Hawaii International Conference on System Sciences, 2000, 2: 1-10.
[2] kkzhang. LEACH分簇算法实现和能量控制算法实现. 博客园.
[3] 喻小惠, 张晶, 陶涛, 等. 基于蚁群策略的无线传感器网络能耗均衡分簇算法[J]. 计算机工程与科学, 2019, 41(7): 1197-1202.

Energy-Efficient Communication Protocol for Wireless Microsensor Networks相关推荐

  1. Yik-Chung Wu ---Time synchronization for wireless sensor networks

    Mei Leng and Yik-Chung Wu, "On Clock Synchronization Algorithms for Wireless Sensor Networks un ...

  2. 无线传感器网络(Wireless Sensor Networks)概述

    文章目录 Introduction Sensor Mote Platforms Low-End-Platforms High-End-Platforms WSN Architecture and Pr ...

  3. 无线传感网课后习题(书本名称无线传感器网络基础 : 理论和实践 : Fundamentals of wireless sensor networks : theory and practice)二

    7.4 Describe a WSN application for each of the following categories: time-driven, eventdriven, and q ...

  4. Internet of Things(IOTS)and Wireless Sensor Networks Lecture1(WSNS)

    一. 简介和背景以及具体应用 1.什么是物联网(IOTS)和无线传感网络(WSNS) 1.物联网(IOTS)是指通过智能实时应用将物理世界连接到数字世界的方式.(eg 智能家居,智能电网) 2.通过使 ...

  5. 无线传感网课后习题(书本名称无线传感器网络基础 : 理论和实践 : Fundamentals of wireless sensor networks : theory and practice)

    无线传感网课后习题(书本名称无线传感器网络基础 : 理论和实践 : Fundamentals of wireless sensor networks : theory and practice) 1 ...

  6. An Energy-Efficient Ant-Based Routing Algorithm for Wireless Sensor Networks (无线传感网中一种基于蚁群算法的能量有效路由)

    牙说:这篇论文是研究蚁群算法在能量有效路由协议的过程中必读的一篇文章,原是全英文,在这里按照自己的理解大致翻译成中文,好好学习,与君共勉. 论文题目:An Energy-Efficient Ant-B ...

  7. 【论文翻译】3461 AdderSR Towards Energy Efficient Image Super-Resolution(个人粗略翻译)

    AdderSR: Towards Energy Efficient Image Super-Resolution[3461] 本文仅为根据博主个人理解的翻译,如有错误或不准确之处,敬请各位读者指出 摘 ...

  8. 全三轨磁条卡读卡器|阅读机|刷卡器MRS100串口通信协议 Communication Protocol

    全三轨磁条卡读卡器|阅读机|刷卡器MRS100串口通信协议 Communication Protocol  1.Command       Command name Command code Comm ...

  9. Highly-Resilient, Energy-Effificient Multipath Routing in Wireless Sensor Networks阅读报告

    Ganesan D, Govindan R, Shenker S, et al. Highly-resilient, energy-efficient multipath routing in wir ...

最新文章

  1. 数字图象处理之二维码图像提取算法(九)
  2. python小程序-python学习—几个简单小程序
  3. 利用 Vmware 安装 Linux 虚拟机
  4. 惠普微型计算机怎么样,垃圾佬的养成①日记之惠普HP 400G3 DM迷你小主机入手日记...
  5. python学习笔记(一):python入门
  6. python调用mysql数据库sql语句过长有问题吗_python连接MYSQL数据库,调用update语句后无法更新数据,解决...
  7. 关于c/s vs web 程序的并发问题
  8. [转载] 正则表达式“派别”简述
  9. 文件--非连续空间存放方式
  10. 使用git进行word版本管理
  11. spark的数三角形算法_腾讯开源全栈机器学习平台 Angel 3.0,支持三大类型图计算算法...
  12. maven工程读取resource资源文件(踩坑)
  13. python的文件怎么删除干净_python 实现彻底删除文件夹和文件夹下的文件
  14. 基于MATLAB的数字图像处理的设计与实现 转
  15. C语言学习(2):enum枚举时出现的问题:
  16. 2019微生物组——16S扩增子分析专题培训第四期
  17. QML控件类型:Tumbler
  18. 转义符——反斜杠(\)
  19. 当一个摆子前端太闲的时候会做什么
  20. AVS全面学习[ZT]

热门文章

  1. 锁眼卫星的介绍与数据下载
  2. 堆球问题,开普勒猜想(格密码相关)
  3. SVG公众号排版『iOS手机长按禁止选中文字』解决方法
  4. Scanner、Random和ArrayList的基本使用规则;猜数字的小游戏程序与随机不重复点名的程序
  5. 国产高端GPU,国产替代加速(附国产厂家汇总)
  6. 助理电子工程师第二个月的实习总结,问题很多的一个月
  7. cpu的位宽、操作系统的位宽和寻址能力的关系
  8. spring 定时器demo
  9. O2O平台模式为什么需要接入分账系统?
  10. 细数GitHub上既有趣又有用的Java项目Top14