ns2仿真mm1k队列

上传人:小** 文档编号:90942335 上传时间:2019-06-20 格式:DOC 页数:7 大小:54.65KB
返回 下载 相关 举报
ns2仿真mm1k队列_第1页
第1页 / 共7页
ns2仿真mm1k队列_第2页
第2页 / 共7页
ns2仿真mm1k队列_第3页
第3页 / 共7页
ns2仿真mm1k队列_第4页
第4页 / 共7页
ns2仿真mm1k队列_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《ns2仿真mm1k队列》由会员分享,可在线阅读,更多相关《ns2仿真mm1k队列(7页珍藏版)》请在金锄头文库上搜索。

1、本实验报告是利用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仿真实验图示如下:

2、 图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 intege

3、r# 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

4、$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

5、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 sendp

6、acket$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;elsecurlenhigh

7、est_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 = t

8、ime; 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

9、 = 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);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号