资源简介
使用matlab编写,无线传感器网络的泛洪算法
代码片段和文件信息
function [] = DFS(rTTL)
global connMatrix;
global visited;
global xLocation;
global yLocation;
global floodProb;
global savedTransmission;
global distMatrix;
global ETX;
global ERX;
global Efs;
global Emp;
global EDA;
global do;
global Energy;
global numOfNodes;
global radius;
global radius_s;
% Get the number of reachable neighbors
connMatrix = zeros(1numOfNodes);
radius_temp=radius;
index=find(distMatrix(r:)<=radius);
if (length(index)==0)%在半径范围找不到节点
radius_temp=radius+radius_s;
while(length(find(distMatrix(r:)<=radius_temp))==0)
radius_temp=radius_temp+radius_s;
end
end
connMatrix =(distMatrix(r:)<=radius_temp);
neighborNodes = find(connMatrix(:) == 1);%距离小于门限的坐标
% Get the unreached neighbors
neigbborNodes = intersect(neighborNodes find(visited(:) == 0));%找到可访问并且距离近的
% for k = 1:length(neighborNodes)
%
% end;
for k = 1:length(neighborNodes)
if (visited(neighborNodes(k)) == 0)
if(distMatrix(rneighborNodes(k))>do)
Energy(r)=Energy(r)-( ETX*(4000) + Emp*4000*(distMatrix(rneighborNodes(k)).^4));
end;
if(distMatrix(rneighborNodes(k))<=do)
Energy(r)=Energy(r)-( ETX*(4000) + Emp*4000*(distMatrix(rneighborNodes(k)).^2));
end;
Energy(neighborNodes(k))=Energy(neighborNodes(k))-((ERX + EDA)*4000);
TTL=TTL-1;
if(neighborNodes(k)==numOfNodes|TTL==0)%当传给中心点或TTL为零时结束
break;
end;
visited(neighborNodes(k)) = 1;
DFS(neighborNodes(k)TTL);
end;
end;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1664 2012-07-07 09:26 DFS.m
文件 2097 2012-07-07 09:32 flooding.m
- 上一篇:基于小波阈值去噪
- 下一篇:MATLAB绘制蜂窝网络程序
相关资源
- 无线传感器网络仿真代码
- WSN的matlab仿真代码
- WSN中leach分簇路由代码MATLAB
- WSN仿真-MATLAB节点个数和节点通信半径
- 无线传感器网络节能路由协议研究仿
- MIMO-WSN系统的功率控制仿真
- wsn分簇LEACH和DEEC算法之matlab仿真
- Water flooding Algorithm 认知无线电中的注
- energyharvesting
- 尚硅谷SpringCloud思维导图(全)
- WSN-matlab-simulation
- wsn-simulation-in-matlab
- flooding 无线传感器网络
- wsn 本文件中包含大量与无线传感器网
- 华南理工 WSN课程作业 DV-Hop算法的Ma
- WSN之RSSI定位算法MATLAB实现代码
- WSN中的matlab仿真代码
- WSN无线传感器网络的分簇仿真Matlab代
评论
共有 条评论