基于LEACH的随机网络生成无线传感器网络路由协议的仿真比较(Matlab代码实现)

    目录

💥1 概述

📚2 运行结果

🎉3 参考文献

👨‍💻4 Matlab代码


💥1 概述

无线传感器网络(WSN)数据传输离不开路由协议,路由协议是其组网的基础。由于WSN是一种资源受限网络,尤其是能量的受限,因此路由协议必须维持较小的路由信息并尽可能的减少能耗。文中从其体系结构、协议栈、网络层次等几个方面分析介绍了无线传感器网络,在对传感器网络路由协议作了充分了解的基础上深入研究了经典的聚类路由算法——LEACH(Low Energy Adaptive Clustering Hierarchy),提出了对它的改进方案并用OPNET对改进前后的算法进行了仿真比较。仿真结果证明了改进后算法的有效性,并且在能耗和网络生存时间上比LEACH有了提高。

📚2 运行结果

 

 

 

 

 

 

 

 

 

 

 

🎉3 参考文献

[1]胡钢,谢冬梅,吴元忠.无线传感器网络路由协议LEACH的研究与改进[J].传感技术学报,2007(06):1391-1396.

👨‍💻4 Matlab代码

主函数部分代码:

clc; clear all; close all;
NUM_NODES = 100;
no_of_clusters = 5;
angle_sector = 2*pi/no_of_clusters;
radius_field = 100;
x0 = 0;
y0 = 0;
packet_length = 500;
ad_length = 10;

radius_ms = 25;
%%%%Energy parameters
Eo = 0.5;
Eelec=50*10^(-9); % units in Joules/bit
Efs = 10*10^(-12);
Emp = 13*10^(-16);
EDA=5*10^(-9);
do = sqrt(Efs/Emp);


figure(1);
viscircles([x0,y0],radius_field);
hold on
for i = 1:NUM_NODES
    t = 2*pi*rand(1,1);
    r = radius_field*sqrt(rand(1,1));
    S(i, 1) = x0 + r*cos(t);
    S(i, 2) = y0 + r*sin(t);
    plot(S(i, 1), S(i, 2), 'red .');
    title 'Wireless Sensor Network';
    xlabel '(m)';
    ylabel '(m)';
    hold on;
end

a2 = 0;
for i = 1:no_of_clusters
    a1 = a2;  % A random direction
    a2 = a1 + angle_sector;
    t = linspace(a1,a2);
    x = x0 + radius_field*cos(t);
    y = y0 + radius_field*sin(t);
    plot([x0,x,x0],[y0,y,y0],'k -')
    axis equal
    hold on;
end

for i = 1:NUM_NODES
    nodes(i).id=i;    % sensor's ID number
    nodes(i).x=S(i, 1);    % X-axis coordinates of sensor node
    nodes(i).y=S(i, 2);    % Y-axis coordinates of sensor node
    nodes(i).battery=Eo;     % nodes energy levels (initially set to be equal to "Eo"
    nodes(i).role=0;   % node acts as normal if the value is '0', if elected as a cluster head it  gets the value '1' (initially all nodes are normal)
    nodes(i).cluster=0;    % the cluster which a node belongs to
    nodes(i).cond=1;
    nodes(i).dist_origin = sqrt((nodes(i).x-x0)^2+(nodes(i).y-y0)^2);    
    nodes(i).role=0;
    nodes(i).cond=1;
    nodes(i).dist_CH=0;
end

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值