资源预览内容
第1页 / 共7页
第2页 / 共7页
第3页 / 共7页
第4页 / 共7页
第5页 / 共7页
第6页 / 共7页
第7页 / 共7页
亲,该文档总共7页全部预览完了,如果喜欢就下载吧!
资源描述
本实验报告是利用ns2仿真M/M/1/ 队列模型l 网络拓扑结构采用最基本的拓扑结构,即有两个网络节点分别代表源发端和目的端,中间连接一条链路(具体实现请见下面附录)。l 网络参数链路带宽100kbps队列容量 100000 /因为必须需要队列容量参数,而本模型考虑的是无穷大因此将此设为100000代表无穷大。分组大小 200l 性能评价 平均队长Lq 平均逗留时间Ws实验采用 = 30 =40来验证M/M/1/ 队列模型= = 0.75平均队长理论值 =2.25平均逗留时间理论值: =0.1而实际测量值Lq = 2.404304(具体分析请见附录)Ws = 0.100828仿真实验图示如下: 图1表示瞬间队长横轴表示时间,单位是100毫秒;纵轴表示队列分组长度。图1,链路中的瞬间队长 图2表示,平均逗留时间其中横轴表示数据包开始发送时间,纵轴表示该数据包的延迟图2,每个数据包的延迟附录:TCL、Gawk代码如下所示:TCL:(mm1.tcl 生成网络拓扑结构)set ns new Simulatorset tf open out.tr w $ns trace-all $tfset lambda 30.0set mu 40.0set n1 $ns nodeset n2 $ns node# Since packet sizes will be rounded to an integer# number of bytes, we should have large packets and# to have small rounding errors, and so we take large bandwidthset link $ns duplex-link $n1 $n2 100kb 0ms DropTail$ns queue-limit $n1 $n2 100000# generate random interarrival times and packet sizesset InterArrivalTime new RandomVariable/Exponential$InterArrivalTime set avg_ expr 1/$lambdaset pktSize new RandomVariable/Exponential$pktSize set avg_ expr 100000.0/(8*$mu)set src new Agent/UDP$ns attach-agent $n1 $src# queue monitoringset qm $ns monitor-queue $n1 $n2 open qtr w 0.01$ns link $n1 $n2 queue-sample-timeoutproc finish global ns tf $ns flush-trace close $tf exit 0 proc sendpacket global ns src InterArrivalTime pktSize set time $ns now $ns at expr $time + $InterArrivalTime value sendpacket set bytes expr round ($pktSize value) $src send $bytesset sink new Agent/Null$ns attach-agent $n2 $sink$ns connect $src $sink$ns at 0.0001 sendpacket$ns at 500.0 finish$ns runGawk代码:(文件curlen.awk得到瞬间队列长度)BEGINhighest_packet_id = 0;num = 0; packet_id = $6;len = $5;if(highest_packet_id=packet_id)curlenhighest_packet_id += len;num+;if(highest_packet_idpacket_id)if(num=0)highest_packet_id = packet_id;curlenhighest_packet_id = len;elsecurlenhighest_packet_id = curlenhighest_packet_id/(num+1);highest_packet_id = packet_id;curlenhighest_packet_id = len;num = 0;END for ( packet_id = 0; packet_id highest_packet_id ) highest_packet_id = packet_id; if ( start_timepacket_id = 0 ) start_timepacket_id = time; if ( action = r ) end_timepacket_id = time; else end_timepacket_id = -1; END for ( packet_id = 0; packet_id = highest_packet_id; packet_id+ ) start = start_timepacket_id; end = end_timepacket_id; packet_duration = end - start; if ( start highest_packet_id ) highest_packet_id = packet_id; if ( start_timepacket_id = 0 ) start_timepacket_id = time; if ( action = r ) end_timepacket_id = time; else end_timepacket_id = -1; END for ( packet_id = 0; packet_id = highest_packet_id; packet_id+ ) start = start_timepacket_id; end = end_timepacket_id; packet_duration = end - start; if ( start end ) total_delay+=packet_duration; num +; printf(avg delay is:%f,total_delay/num);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号