计网实验datalinklayersimulation.docx
《计网实验datalinklayersimulation.docx》由会员分享,可在线阅读,更多相关《计网实验datalinklayersimulation.docx(8页珍藏版)》请在冰豆网上搜索。
![计网实验datalinklayersimulation.docx](https://file1.bdocx.com/fileroot1/2023-2/22/ddfa072e-8bf9-454b-8fac-94e9000af912/ddfa072e-8bf9-454b-8fac-94e9000af9121.gif)
计网实验datalinklayersimulation
计网实验data-link-layer-simulation
————————————————————————————————作者:
————————————————————————————————日期:
ﻩ
《计算机通信与网络实验》
课程实验报告
实验二:
2.data linklayersimulation
实验名称:
2.datalinklayersimulation
1.实验内容
1.DrawFigure7.12and7.13.
2.Simulationon PerformanceofDataLinkControl Protocols
Usingthesameassumptionsthatareused forFigure7.13inAppendix 7A,plot lineutilizationasafunction ofP,theprobabilitythatasingle frameisinerrorforthe followingerror-controltechniques:
a.Stop-and-wait
b.Go-back-Nwith w=7
c.Go-back-Nwith w=127
d. Selectiverejectwithw=7
e.Selectivereject withw=127
Do alloftheprecedingfor thefollowingvaluesof a:
0.1, 1,10,100.Drawconclusions aboutwhichtechniqueis appropriateforvariousrangesofa.
2.实验结果
A=0.1
A=1
A=10
A=100
a=0.1时,W=7或者127都是大于2a+1;
a=1时,W=7或者127都是大于2a+1;
a=10时,则选择拒绝和返回N都是一个分段函数.
a=100时,则选择拒绝和返回N都是一个分段函数。
3.实验程序
Figure7.12
a=0:
0.1:
1000;
W = [1,7,127];
forj=1:
3
fori =1:
length(a)
ifW(j)>=2*a(i)+1
U(i)=1;
else
U(i)=W(j)/(2*a(i)+1);
end
end
ifj==1
W1=U;
end
ifj==2
W7=U;
end
ifj == 3
W10=U;
end
end
plot(a,W1);
holdon;
plot(a,W7);
plot(a,W10);
set(gca,'xscale','log');
axis([0.1100001]);
Figure7.13
a = 0:
0.1:
1000;
W=[1,7,127,127];
P=10^(-3);
forj=1:
4
fori=1:
length(a)
ifW(j) ==1
U(i)=(1-P)/(1+2*a(i));
end
ifW(j)==7
if W(2)>=2*a(i)+1
U(i)= 1-P;
else
U(i) = W(j)*(1-P)/(2*a(i)+1);
end
end
ifW(j)==127
ifW(j)>=2*a(i)+1
U(i)=(1-P)/(1+2*a(i)*P);
Y(i) =1-P;
else
U(i)= W(j)*(1-P)/((2*a(i)+1)*(1-P+W(j)*P));
Y(i)= W(j)*(1-P)/(2*a(i)+1);
end
end
ifj==1
W1=U;
end
ifj==2
W7=U;
end
if j==3
W10= U;
end
ifj == 4
W=Y;
end
end
end
plot(a,W1);
holdon;
plot(a,W7);
plot(a,W10);
plot(a,W);
set(gca,'xscale','log');
axis([0.11000 01]);
2、Draw
functionU=stopandwait(a,P)
U=(1-P)./(1+2*a);
end
functionU=selective_reject(a,W,P)
U=(1-P).*(W>=2*a+1)+W.*(1-P)./(2.*a+1).*(W<2*a+1);
end
functionU=gobackn(a,W,P)
U=(1-P)./(1+2.*a.*P).*(W>=2*a+1)+W.*(1-P)./(2.*a+1)./(1-P+W.*P).*(W<2*a+1);
end
functionlab2_draw(a)
P=0:
0.1:
1000;
U=stopandwait(a,P);
semilogx(P,U,'r');
holdon
U=selective_reject(a,7,P);
semilogx(P,U,'g');
holdon
U=gobackn(a,7,P);
semilogx(P,U,'b');
hold on
U=selective_reject(a,127,P);
semilogx(P,U,'k');holdon
U=gobackn(a,127,P);
semilogx(P,U,'y');
ylabel('Utilization') ;
xlabel('P');
legend('Stop-and-wait','Go-back-Nwithw=7 ','Go-back-N withw=127','Selectiverejectwithw=7','Selectiverejectwithw=127 ',3)
end