Does these DSP codes run?

조회 수: 19 (최근 30일)
Shaurya Bhav
Shaurya Bhav 2022년 11월 24일
댓글: sanskar 2023년 4월 25일
Are these codes usable and usefull.
  댓글 수: 2
Tushar Verma
Tushar Verma 2022년 11월 24일
Works
sanskar
sanskar 2023년 4월 25일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Shaurya Bhav
Shaurya Bhav 2022년 11월 24일
confirmed. They work fine.

추가 답변 (1개)

King
King 2022년 11월 24일

카테고리

Help CenterFile Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by