我的RIO测试脚本v1.0(传输层:UDP)

#这是我自己的RIO改进算法MYRIO的tcl测试脚本,如果你想自己用的话,把脚本中的MYRIO改成RIO,pmyriority_method_改成priority_method_ #下面是拓扑图 # s(0) d(0) # / / # 10Mb,2ms / 5Mb,20ms / 10Mb,2ms # r1 --------- r2 # 10Mb,2ms / / 10Mb,2ms # / / # s(n) d(n) #本范例中n=2,就是说源节点和目的节点各3个 #flow 0 设定于out队列中,可以从nam动画中看到,丢包都是丢弃的flow0的数据包,起到了区分服务的作用(diffserv) #输出文件包括了瞬时队列长度temp.q,平均队列长度temp.a #这个版本传输层使用了UDP协议 #souroot at Aug 16,2010 #my qq :578075318 set ns [new Simulator] set nd [open out.tr w] $ns trace-all $nd set nf [open out.nam w] $ns namtrace-all $nf Queue/RED/MYRIO set pmyriority_method_ 1 Queue/RED/MYRIO set in_thresh_ 10 Queue/RED/MYRIO set in_maxthresh_ 20 Queue/RED/MYRIO set out_thresh_ 3 Queue/RED/MYRIO set out_maxthresh_ 9 Queue/RED/MYRIO set in_linterm_ 10 Queue/RED/MYRIO set linterm_ 10 #Queue/RED/RIO set debug_ true Queue/RED/RIO set debug_ false set packetSize 1000 set rate 2000000 #nodenum是源节点(目的节点)的个数 set nodenum 3 $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/MYRIO # 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 25 $ns queue-limit $r1 $r0 25 #$ns duplex-link-op $s(0) $r0 orient up-right #$ns duplex-link-op $s(1) $r0 orient up-right #$ns duplex-link-op $s(1) $r0 orient up-right $ns duplex-link-op $r0 $r1 orient right #$ns duplex-link-op $r1 $d(0) orient up-right #$ns duplex-link-op $r1 $d(1) orient up-right #$ns duplex-link-op $r1 $d(2) orient up-right #$ns duplex-link-op $r0 $r1 queuePos 0.5 #$ns duplex-link-op $r1 $r0 queuePos 0.5 # Set up one CBR connection between each source and the destination: for {set i 0} {$i < $nodenum} {incr i} { set udp($i) [new Agent/UDP] $udp($i) set fid_ $i $ns attach-agent $s($i) $udp($i) set cbr($i) [new Application/Traffic/CBR] $cbr($i) attach-agent $udp($i) $cbr($i) set packet_size_ $packetSize $udp($i) set packetSize_ $packetSize $cbr($i) set rate_ $rate set null($i) [new Agent/Null] $ns attach-agent $d($i) $null($i) $ns connect $udp($i) $null($i) } for {set i 0} {$i < $nodenum} {incr i} { $ns at 0.0 "$cbr($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 exec nam out.nam exit 0 } $ns run

你可能感兴趣的:(测试,脚本,null,each,Tcl,plot)