1.问题描述:
1)接收节点数N变化,各节点丢包率P1=P2=…=Pn=0.08,节点数从2变化到10,增量为1,重传时间间隔为100Δt,作出平均传输次数随接收节点数变化的曲线图
2)P1=P2=…=Pn且变化,从0.02变化到0.10,增量为0.02,接收节点数N=5,重传时间间隔为100Δt,作出平均传输次数随节点丢包率变化的曲线图
3)各节点丢包率均不等且变化,接收节点数N=5,重传时间间隔为100Δt,P1从0.01变化到0.06,增量为0.01,P2=P1+0.01,P3=P1+0.02,P4=P1+0.03,P5=P1+0.04,作出平均传输次数随节点丢包率变化的曲线图
2.部分程序:
clc;
clear;
close all;
warning off;
addpath 'func\'
figure;
M = [2:1:10];
Avg_T = zeros(1,length(M));
N = 7;%数据包长度
%定义重传次数,如果超过这个次数,则表示传输彻底失败
k = 5;
for i = 1:length(M);
i
%各节点丢包率
P = 0.2*ones(1,M(i));
%计算重传概率
tmps1 = 1;
tmps2 = 1;
for j = 1:M(i)
Ps1 = zeros(1,k+1);
for n = 1:k+1
Ps1(n) = func_P(N,n,P(j));
end
if j == 1
tmps1 = sum(Ps1);
else
tmps1 = tmps1*sum(Ps1);
end
end
for j = 1:M(i)
Ps2 = zeros(1,k);
for n = 1:k
Ps2(n) = func_P(N,n,P(j));
end
if j == 1
tmps2 = sum(Ps2);
else
tmps2 = tmps2*sum(Ps2);
end
end
%平均传输次数
Avg_T(i) = 1 + (tmps1 - tmps2)/N;
end
plot(M,Avg_T,'--rs','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',5);
grid on;
legend('RLNCBR');
xlabel('接收节点个数N');
ylabel('平均传输次数');
save r1.mat M Avg_T
3.仿真结论:
A-12-13