资源描述:
《计网实验data link layer simulation》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《计算机通信与网络实验》课程实验报告实验二:2.datalinklayersimulation实验名称:2.datalinklayersimulation1.实验内容1.DrawFigure7.12and7.13.2.SimulationonPerformanceofDataLinkControlProtocolsUsingthesameassumptionsthatareusedforFigure7.13inAppendix7A,plotlineutilizationasafunctionof
2、P,theprobabilitythatasingleframeisinerrorforthefollowingerror-controltechniques:a.Stop-and-waitb.Go-back-Nwithw=7c.Go-back-Nwithw=127d.Selectiverejectwithw=7e.Selectiverejectwithw=127Doalloftheprecedingforthefollowingvaluesofa:0.1,1,10,100.Drawconclu
3、sionsaboutwhichtechniqueisappropriateforvariousrangesofa.2.实验结果A=0.1A=1A=10A=100a=0.1时,W=7或者127都是大于2a+1;a=1时,W=7或者127都是大于2a+1;a=10时,则选择拒绝和返回N都是一个分段函数.a=100时,则选择拒绝和返回N都是一个分段函数。3.实验程序Figure7.12a=0:0.1:1000;W=[1,7,127];forj=1:3fori=1:length(a)ifW(j)>=2*
4、a(i)+1U(i)=1;elseU(i)=W(j)/(2*a(i)+1);endendifj==1W1=U;endifj==2W7=U;endifj==3W10=U;endendplot(a,W1);holdon;plot(a,W7);plot(a,W10);set(gca,'xscale','log');axis([0.1100001]);Figure7.13a=0:0.1:1000;W=[1,7,127,127];P=10^(-3);forj=1:4fori=1:length(a)ifW(
5、j)==1U(i)=(1-P)/(1+2*a(i));endifW(j)==7ifW(2)>=2*a(i)+1U(i)=1-P;elseU(i)=W(j)*(1-P)/(2*a(i)+1);endendifW(j)==127ifW(j)>=2*a(i)+1U(i)=(1-P)/(1+2*a(i)*P);Y(i)=1-P;elseU(i)=W(j)*(1-P)/((2*a(i)+1)*(1-P+W(j)*P));Y(i)=W(j)*(1-P)/(2*a(i)+1);endendifj==1W1=U
6、;endifj==2W7=U;endifj==3W10=U;endifj==4W=Y;endendendplot(a,W1);holdon;plot(a,W7);plot(a,W10);plot(a,W);set(gca,'xscale','log');axis([0.1100001]);2、DrawfunctionU=stopandwait(a,P)U=(1-P)./(1+2*a);endfunctionU=selective_reject(a,W,P)U=(1-P).*(W>=2*a+1)+
7、W.*(1-P)./(2.*a+1).*(W<2*a+1);endfunctionU=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);endfunctionlab2_draw(a)P=0:0.1:1000;U=stopandwait(a,P);semilogx(P,U,'r');holdonU=selective_reject(a,7,P);semilogx(P,U,
8、'g');holdonU=gobackn(a,7,P);semilogx(P,U,'b');holdonU=selective_reject(a,127,P);semilogx(P,U,'k');holdonU=gobackn(a,127,P);semilogx(P,U,'y');ylabel('Utilization');xlabel('P');legend('Stop-and-wait','Go-back-Nwithw=7','Go-back-Nwithw=127','Selectivere