【WSN协议】基于低能量自适应集群层次结构 (LEACH) 集群的路由协议附matlab代码

​✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

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

⛄ 部分代码

function clusterModel = newCluster(netArch, nodeArch, ...

                        clusterFun, clusterFunParam, p_numCluster)

% Create the network architecture with desired parameters

%   

%   Input:

%       clusterFun          Function name for clustering algorithm.

%       clusterFunParam     Parameters for the cluster function

%       numCluster          Number of clusters (CHs)

%       netArch             Network model

%       nodeArch            Nodes model

%   Example:

%       clusterModel = newCluster();

%

% Hossein Dehghan, hd.dehghan@gmail.com

% Ver 1. 2/2013

    % set the parameters

    if ~exist('clusterFun','var')

        clusterFun = 'leach'; % default for clustering the node is leach algorithm

    end

    if strcmp(clusterFun, 'def')

        clusterFun = 'leach'; % default for clustering the node is leach algorithm

    end

    clusterModel.clusterFun = clusterFun;

   

    if ~exist('clusterFunParam','var')

        clusterFunParam = [];

    end

    clusterModel.clusterFunParam = clusterFunParam;

   

    if ~exist('netArch','var')

        netArch = newNetwork();

    end

    clusterModel.netArch = netArch;

    

    if ~exist('nodeArch','var')

        nodeArch = newNodes();

    end

    clusterModel.nodeArch = nodeArch;

    

    if ~exist('p_numCluster','var')

        dBS        = sqrt((netArch.Sink.x - netArch.Yard.Length) ^ 2 + ...

                          (netArch.Sink.y - netArch.Yard.Width) ^ 2);

        numCluster = clusterOptimum(netArch, nodeArch, dBS); 

        p = 1 / numCluster;

    else

        if p_numCluster < 1

            p = p_numCluster;

            numCluster = 1 / p;

        else

            numCluster = p_numCluster;

            p = 1 / numCluster;

        end

    end

    %p = Optimal Election Probability of a node to become cluster head

    clusterModel.numCluster = numCluster;

    clusterModel.p          = p;

    

    % run the clustering algorithm

    addpath Cluster % put the clustering algorithm in the cluster folder

    [nodeArch, clusterNode] = feval(clusterFun, clusterModel, clusterFunParam); % execute the cluster function

    

    clusterModel.nodeArch = nodeArch;       % new architecture of nodes

    clusterModel.clusterNode = clusterNode; % the CHs

end

⛄ 运行结果

⛄ 参考文献

[1]张子辰. 基于LEACH协议的无线传感器网络路由协议的研究. Diss. 太原理工大学, 2014.

⛄ Matlab代码关注

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

❤️ 关注我领取海量matlab电子书和数学建模资料

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

matlab科研助手

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

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

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

打赏作者

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

抵扣说明:

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

余额充值