% This script generates a random deployed wireless network, and
% probabilistic broadcast is simulated.
% In probabilistic broadcast, each node re-transmits the packet according
% to a probability.
% A link on probabilistic broadcast:
% http://lsewww.epfl.ch/Documents/acrobat/SCS03.pdf
% A link on DFS algorithm:
% http://en.wikipedia.org/wiki/Depth-first_search
clear;
rand('state', 5);
numOfNodes = 200; % number of nodes
envSize=100; % envsizeXenvsize environment
txRange = 15;
global floodProb; % the pre-defined probability to broadcast;
global savedTransmission; % The number of saved re-transmissions;
savedTransmission = 0;
global xLocation; % Array containing the X-coordinations of wireless nodes;
global yLocation; % Array containing the Y-coordinations of wireless nodes;
xLocation = rand(numOfNodes,1) * envSize;
yLocation = rand(numOfNodes,1) * envSize; %x,y coords of nodes
% Generate the adjacent matrix to represent the topology graph of the
% randomly deployed wireless networks;
distMatrix = zeros(numOfNodes,numOfNodes);
for i=1:numOfNodes
for j=1:numOfNodes
distMatrix(i,j)=sqrt((xLocation(i)-xLocation(j))^2 + (yLocation(i)-yLocation(j))^2); %distance between node pairs
end
end
% If the Euclidean distance between two nodes is less than the transmission range, there
% exists a link.
global connMatrix;
connMatrix = ( distMatrix < txRange); %binary connectivity matrix
% The broadcast will start from a sink node;
sinkNode = 1; % sink node;
% Array visited[] stores the boolean value if the broadcast has reach the node.
global visited;
visited = zeros(1, numOfNodes);
% Show the topology;
figure(1);
plot(xLocation, yLocation, '.');
text(xLocation(sinkNode), yLocation(sinkNode), 'sink');
% title(['p = ' num2str(floodProb)]);
% sink node;
visited(sinkNode) = 1;
% recursive Depth first search is adopted to traverse the whole graph;
DFS(sinkNode);
savedTransmission
return;
没有合适的资源?快使用搜索试试~ 我知道了~
基于Matlab生成随机部署的无线网络,并模拟概率广播。.zip
共2个文件
m:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 30 浏览量
2023-10-21
14:56:56
上传
评论
收藏 2KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a,内含运行结果,不会运行可私信 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 5.作者介绍:某大厂资深算法工程师,从事Matlab算法仿真工作10年;擅长智能优化算法、神经网络预测、信号处理、元胞自动机等多种领域的算法仿真实验,更多仿真源码、数据集定制私信+。 %% 开发者:Matlab科研助手 %% 更多咨询关注天天Matlab微信公众号
资源推荐
资源详情
资源评论
收起资源包目录
基于Matlab生成随机部署的无线网络,并模拟概率广播。.zip (2个子文件)
基于Matlab生成随机部署的无线网络,并模拟概率广播。
gossip.m 2KB
DFS.m 919B
共 2 条
- 1
资源评论
Matlab科研辅导帮
- 粉丝: 2w+
- 资源: 7672
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功