资源简介
无线传感器网络(WSN)leach分簇路由协议matlab仿真
代码片段和文件信息
NodeNums = 100; % the num of node
AreaR = 100 ; % the area of simulate
NodeTranR=10; % the transit Radius
Elec=50 * 10^(-9); %
Eamp=100*10^(-12);
Bx=50; % The Postion of baseation
By=175;
MaxInteral =700; % the leach simulate time
Pch=0.05; % the desired percentage of cluster heads
InitEn=0.5; % the init energy of all node
Tr=30;
TDMA=100;
Kbit=2000; % the bits of a node transmiting a packet every time
BandWitch = 1*10.^(6); % Channel Bandwitch
TOS_LOCAL_ADDRESS = 0;
for i=1:(MaxInteral)
AliveNode(i)=NodeNums;
AmountData(i)=0;
end
sym alldata;
alldata=0;
LAECH = zeros(1MaxInteral);
LAENO = zeros(1MaxInteral);
for i=1:1:NodeNums
EnNode(i)=InitEn; % the init energy of all node
StateNode(i)=1; % the State of all node 1: alive 0:dead
ClusterHeads(i)=0; % the Set of Cluster Head 1: cluster head 0 :node
Rounds=0; % the round
end
Threshold=0; % the threshold of node becoming a cluster-head
Node.x=AreaR*rand(1NodeNums); % the position of node
Node.y=AreaR*rand(1NodeNums);
Node.c=zeros(1NodeNums);
Node.d=zeros(1NodeNums);
Node.l=zeros(1NodeNums);
Node.csize=zeros(1NodeNums);
Node.initclEn=zeros(1NodeNums);
% for i=1:NodeNums
% Node.c(i)=0; % the Cluster head of node
% Node.d(i)=0; % the distance between cluster head and node
% Node.l(i)=Kbit; % the length of node i transmit packet
% Node.csize(i)=0;
% end
for Rounds = 1:MaxInteral
% the Setup phase of cluster
Node.csize=Node.csize-Node.csize;
Node.d=Node.d-Node.d;
Node.c=Node.c-Node.c;
for i =1:NodeNums
Threshold=Pch/(1-Pch*(mod(Rounds-11/Pch)));
if StateNode(i)==1 % if node is alive
if ClusterHeads(i) ==1
ClusterHeads(i)=0;
elseif rand(11)
ClusterHeads(i)=1;
Node.c(i)=TOS_LOCAL_ADDRESS;
Node.initclEn(i)=EnNode(i);
else ClusetHeads(i)=0;
Node.initclEn(i)=EnNode(i);
end
end
end
if sum(ClusterHeads)==0
continue;
end
EntranPCH = Elec * Kbit+ Eamp*Kbit*((Tr.^2+Tr.^2)); % The expended engergy by new Cluster head advertising that it is new cluster head
for i=1:NodeNums
if ClusterHeads(i) ==1
if EnNode(i) >= EntranPCH
EnNode(i) = EnNode(i) - EntranPCH ;
else
StateNode(i)=0;
end
end
end
for i=1:NodeNums
if StateNode(i)==1 % if node is alive
if ClusterHeads(i) ~=1 % the node is not cluster head
for j=1:NodeNums
if ClusterHeads(j) ==1
dist = ((Node.x(i)-Node.x(j)).^2)+((Node.y(i)-Node.y(j)).^2); % the distance.^2
% if dist < (Tr.^2+Tr.^2)
- 上一篇:无线传感器网络SEP协议的MATLAB实现
- 下一篇:循环谱代码
相关资源
- PSO版leach
- 无线传感器网络DVHOP定位算法
- LEACH分簇算法
- RSSI定位 MATLAB
- HEED、LEACH以及一种基于地理位置的非
- 无线传感网仿真代码
- leach分簇算法仿真基于matlab
- LEACH算法相关代码
- 无线传感器网络的拓扑结构下的无线
- 无线传感器网络中LEACH路由协议的MA
- WSN DV-Hop定位的Matlab仿真代码
- pegasis+leachvsdeec
- 无线传感器网络泛洪算法
- leach协议源代码matlab
- 无线传感器网络仿真代码
- LEACH协议仿真
- WSN的matlab仿真代码
- WSN中leach分簇路由代码MATLAB
- 基于LEACH算法的改进算法GAF算法
- Leach协议在MATLAB下面仿真的源代码
- 无线传感网络的能量控制
- LEACH仿真 簇头 节点存活 系统能耗
- WSN仿真-MATLAB节点个数和节点通信半径
- 无线传感器网络节能路由协议研究仿
- LEACH协议Matlab仿真代码
- LEACH改进算法MATLAB实现
- leach与sep算法matlab代码
- LEACH源代码
- MIMO-WSN系统的功率控制仿真
- leach算法改进
评论
共有 条评论