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

Respuestas (1)

Walter Roberson
Walter Roberson el 12 de Nov. de 2013
The code simply simulates receiving timeouts or PAK or NAK, choosing one of them at random.

Categorías

Más información sobre Audio Processing Algorithm Design en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

hra
el 12 de Nov. de 2013

Comentada:

el 1 de Oct. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by