#这是我自己的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 #这个版本传输层使用了TCP协议 #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 set nodenum 100 Queue/RED/MYRIO set pmyriority_method_ 0 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 $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 100 $ns queue-limit $r1 $r0 100 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 } 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. 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