please explain me the following code for stop and wait protocol
显示 更早的评论
clc;
clear all;
disp('SAMPLE INPUT AND OUTPUT: ');
n=input('Number of Frames: ');
frame=1;
while frame<=n
fprintf('Transmitting Frame %d\n',frame);
s=randint(1,1,15);
if s<3
fprintf('TIME OUT\n Re-');
elseif s>6
fprintf('PAK of Frame %d Received\n',frame);
frame=frame+1;
else
fprintf('NAK of Frame %d Received\n Re-',frame);
end
end
1 个评论
Walter Roberson
2021-10-1
No, that is not what the code does. See my description below.
回答(1 个)
Walter Roberson
2013-11-12
0 个投票
The code simply simulates receiving timeouts or PAK or NAK, choosing one of them at random.
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!