RIO测试脚本标准注释版

#下面是拓扑图 # s(0) d(0) # / / # 10Mb,2ms / 5Mb,20ms / 10Mb,2ms # r1 --------- r2 # 10Mb,2ms / / 10Mb,2ms # / / # s(n) d(n) #本范例中n=2,就是说源节点和目的节点各3个 #输出文件包括了瞬时队列长度temp.q,平均队列长度temp.a #这个版本传输层使用了TCP协议 set ns [new Simulator] set nd [open out.tr w] $ns trace-all $nd set nf [open out.nam w] $ns namtrace-all $nf set nodenum 3 Queue/RED/RIO set priority_method_ 0 Queue/RED/RIO set in_thresh_ 15 Queue/RED/RIO set in_maxthresh_ 45 Queue/RED/RIO set out_thresh_ 5 Queue/RED/RIO set out_maxthresh_ 15 Queue/RED/RIO set in_linterm_ 10 Queue/RED/RIO set linterm_ 10 $ns color 0 Yellow $ns color 1 Blue $ns color 2 Red $ns color 3 Green $ns color 4 Brown #creat topo for {set i 0} {$i < $nodenum} {incr i} { set s($i) [$ns node] } set r0 [$ns node] set r1 [$ns node] for {set i 0} {$i < $nodenum} {incr i} { set d($i) [$ns node] } $ns duplex-link $r0 $r1 5Mb 20ms RED/RIO # Tracing a queue set redq [[$ns link $r0 $r1] queue] set tchan_ [open all.q w] $redq trace curq_ $redq trace ave_ $redq attach $tchan_ for {set i 0} {$i < $nodenum} {incr i} { $ns duplex-link $s($i) $r0 10Mb 2ms DropTail } for {set i 0} {$i < $nodenum} {incr i} { $ns duplex-link $r1 $d($i) 10Mb 2ms DropTail } $ns queue-limit $r0 $r1 50 $ns queue-limit $r1 $r0 50 for {set i 0} {$i < $nodenum} {incr i} { set tcp($i) [$ns create-connection TCP/Reno $s($i) TCPSink $d($i) $i] $tcp($i) set window_ 15 #通告窗口为15,数据包负载数据大小为1000byte,加上数据包头部,共为1040byte, #则最大速率为15*1040/(24*2ms)=312KB/S(没有超过1000000Byte/s) #也就是说,链路带宽至少为312*8=2.5Mbit/s时,网络才不发生拥塞。 } for {set i 0} {$i < $nodenum} {incr i} { set ftp($i) [$tcp($i) attach-source FTP] } # make token bucket limiter for flow i # Fill rate 1000000 Bps, or 1000 packets per second. #就是说,当速率超过1000000字节每秒时,或者1000个数据包每秒时,数据包被标记为out。 for {set i 0} {$i < $nodenum} {incr i} { set link($i) [$ns link $s($i) $r0] set tcm($i) [$ns maketbtagger Fid] $ns attach-tagger $link($i) $tcm($i) set fcl($i) [$tcm($i) classifier]; # flow classifier $fcl($i) set-flowrate $i 1000000 10000 1 } for {set i 0} {$i < $nodenum} {incr i} { $ns at 0.0 "$ftp($i) start" } $ns at 20 "finish" proc finish {} { global tchan_ nf nd # # Plot the queue size and average queue size, for RED gateways. # set awkCode { { if ($1 == "Q" && NF>2) { print $2, $3 >> "temp.q"; set end $2 } else if ($1 == "a" && NF>2) print $2, $3 >> "temp.a"; } } set f [open temp.queue w] if { [info exists tchan_] } { close $tchan_ } exec rm -f temp.q temp.a exec touch temp.a temp.q exec awk $awkCode all.q puts $f /"queue exec cat temp.q >@ $f puts $f /n/"ave_queue exec cat temp.a >@ $f ###puts $f /n"thresh ###puts $f 0 [[ns link $r1 $r2] get thresh] ###puts $f $end [[ns link $r1 $r2] get thresh] close $f close $nf close $nd exit 0 } $ns run

你可能感兴趣的:(RIO测试脚本标准注释版)