%% Definicion de variables
aa = 8*[1:1:1024];
% instring; %Temporary input string
% d; %Link distance in meters
% R; %Link data rate in bits per second
% L; %Frame length in bits
% pr_bit; %Probability of a bit error
% protocol_type; %Protocol type (1 = SAW, 2 = SW)
% ARQ_type; %ARQ type for SW (1 = SR, 2 = GBN)
% N; %Window size for SW
% P; %Probability of a frame error
% a; %Stallings "a" parameter
% U; %Link utilization as a ratio
V = 2.0e8; %Copper propagation in meters per second
%% INICIALIZACION DE VARIABLES
disp('-------------------------------------------- dlc.c -----');
disp('- Program to compute utilization for DLC protocols -');
disp('--------------------------------------------------------');
%Prompt for distance of link in meters
instring = input('Length of link in meters =======================> ');
d = instring;
%Prompt for data rate of link in bits per second
instring = input('Data rate of link in bits per second ===========> ');
R = instring;
%Prompt for size of frames in bytes (converted to bits for L)
instring = input('Size of frames in bytes ========================> ');
L = 8 * instring;
%Prompt for error rate (BER)
instring = input('Pr[bit error] (0.0 to 1.0) =====================> ');
pr_bit = instring;
%Prompt for protocol (SAW or SW)
instring = input('Protocol type (1 = SAW, 2 = SW) ================> ');
protocol_type = instring;
%If SW then prompt for other parameters
if (protocol_type == 2)
%Prompt for window size
instring = input('Window size ====================================> ');
N = instring;
%Prompt for error control (GBN or SR)
instring = input('ARQ type (1 = SR, 2 = GBN) =====================> ');
ARQ_type = instring;
end
for i=1:1024
L=aa(i);
%Compute P (probability of frame error)
P = 1 - (1 - pr_bit)^L;
%Compute "a" value
a = (R * d) / ( V * L);
%Compute U for SAW
if (protocol_type == 1)
U(i) = (1 - P) / (1 + (2 * a));
end
%Compute U for SW and SR
if ((protocol_type == 2) && (ARQ_type == 1))
if (N >= ((2 * a) + 1))
U(i) = (1 - P);
else
U(i) = (N * (1 - P)) / ((2 * a) + 1);
end
end
%Compute U for SW and GBN
if ((protocol_type == 2) && (ARQ_type == 2))
if (N >= ((2 * a) + 1))
U(i) = (1 - P) / (1 + (2 * a * P));
else
U(i) = (N * (1 - P)) / (((2 * a) + 1) * (1 - P + N * P));
end
end
%Output results
% disp('-------------------------------------------------------- ');
% disp('a = ')
% disp(a)
% disp('Pr[frame loss] = ')
% disp(P)
% disp('U = ')
% disp(U)
end
U = U*100;
plot (aa,U)
ARQ.zip_ARQ_zip
版权申诉
72 浏览量
2022-09-23
18:17:08
上传
评论
收藏 1KB ZIP 举报
![avatar](https://profile-avatar.csdnimg.cn/3b38fb294f114a0a8dfd7bc633aed231_weixin_42660494.jpg!1)
alvarocfc
- 粉丝: 112
- 资源: 1万+
最新资源
- 数据库管理工具:dbeaver-ce-23.3.4-amd64.deb
- 数据库管理工具:dbeaver-ce-23.3.3-amd64.deb
- 数据库管理工具:dbeaver-ce-23.3.2-amd64.deb
- 数据库管理工具:dbeaver-ce-23.3.1-amd64.deb
- 深度学习记录,训练集?
- 数据库管理工具:dbeaver-ce-23.3.0-amd64.deb
- 数据库管理工具:dbeaver-ce-23.2.5-amd64.deb
- 数据库管理工具:dbeaver-ce-23.2.4-amd64.deb
- 数据库管理工具:dbeaver-ce-23.2.3-amd64.deb
- 数据库管理工具:dbeaver-ce-23.2.2-amd64.deb
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)