Does these DSP codes run?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Shaurya Bhav
il 24 Nov 2022
Commentato: sanskar
il 25 Apr 2023
Are these codes usable and usefull.
2 Commenti
sanskar
il 25 Apr 2023
clc;
clear all;
n=10;
w=3;
while w>=n
w = input("invalid window size - cannot be bigger than or eualt to number of frames.\n Re enter window size");
end
sentframes=0;
windowframes=0;
unsentframes=n;
pt=1;
flag=0;
flag2=0;
a=1:n;
threshold = 32;
dropcount=0;
pause(1.0);
%starting protocol
while flag==0
if flag2==0
for i=1:w
fprintf('frame %d transmitted\n',a(pt));
unsentframes = unsentframes-1;
windowframes= windowframes+1;
pt=pt+1;
end
pause(2.0);
flag2=1;
end
noise = randi(100,1,1);
pause(2.0);
if noise>threshold
fprintf('acknowledgement of frame %d received\n',a(pt-w));
sentframes = sentframes+1;
if pt==n+1;
fprintf('frame %d transmitted\n',a(pt-1));
else
fprintf('frame %d transmitted\n',a(pt));
end
windowframes = windowframes+1;
unsentframes = unsentframes-1;
if pt==n || a(pt)==n
flag=1;
end
pt=pt+1;
else
dropcount = dropcount+1;
err = randi(10,1,1);
if err>5
fprintf('corrupted frame %d received\n',a(pt-w));
else
pause(1.0);
fprintf('no acknoledgement of frame %d received\n',a(pt-w));
end
for j=w-1:-1:1
fprintf('frame %d discarded\n',a(pt-w+j));
windowframes= windowframes-1;
unsentframes=unsentframes+1;
end
fprintf('nak of frame %d received\n',a(pt-2));
windowframes=windowframes-1;
unsentframes=unsentframes+1;
pt=pt-w;
flag2=0;
end
end
i=n-w+1;
while(i<=n)
noise = randi(100,1,1);
pause(2.0);
if noise > threshold
fprintf('acknowldeement of frame %d received\n',a(i));
sentframes = sentframes+1'
i=i+1;
else
dropcount = dropcount+1;
err=randi(10,1,1);
if err>5
fprintf('corrupted frame %d received\n',a(i));
else
pause(1.0);
fprintf('no acknowledgment of frame %received\n',a(i));
end
for j=n:-1:i+1
fprintf('frame % discarded\n',a(j));
windowframes=windowframes-1;
unsentframes = unsentframes+1;
end
fprintf('nak of frame %d received\n',a(i));
windowframes = windowframes-1;
unsentframes =unsentframes+1;
pause(2.0);
for k=i:n
fprintf('frame %d transmitted\n',a(k));
windowframes = windowframes+1;
unsentframes = unsentframes-1;
end
end
end
Risposta accettata
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Pulsed Waveforms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!