📄 test-suite-rh.tcl
字号:
set errmodule [$lossylink2_ errormodule] return $errmodule}TestSuite instproc setloss {} { $self instvar topo_ $topo_ instvar lossylink_ set errmodule [$lossylink_ errormodule] set errmodel [$errmodule errormodels] if { [llength $errmodel] > 1 } { puts "droppedfin: confused by >1 err models..abort" exit 1 } return $errmodel}TestSuite instproc setTopo {} { $self instvar node_ net_ ns_ topo_ set topo_ [new Topology/$net_ $ns_] if {$net_ == "net2" || $net_ == "net2-lossy"} { set node_(s1) [$topo_ node? s1] set node_(s2) [$topo_ node? s2] set node_(s3) [$topo_ node? s3] set node_(s4) [$topo_ node? s4] set node_(r1) [$topo_ node? r1] set node_(r2) [$topo_ node? r2] set node_(a1) [$topo_ node? a1] set node_(a2) [$topo_ node? a2] set node_(a3) [$topo_ node? a3] set node_(a4) [$topo_ node? a4] set node_(a5) [$topo_ node? a5] set node_(a6) [$topo_ node? a6] set node_(b1) [$topo_ node? b1] set node_(b2) [$topo_ node? b2] set node_(b3) [$topo_ node? b3] set node_(b4) [$topo_ node? b4] set node_(b5) [$topo_ node? b5] set node_(b6) [$topo_ node? b6] [$ns_ link $node_(r1) $node_(r2)] trace-dynamics $ns_ stdout } if {$net_ == "net6"} { set node_(s1) [$topo_ node? s1] set node_(s2) [$topo_ node? s2] set node_(r1) [$topo_ node? r1] set node_(k1) [$topo_ node? k1] [$ns_ link $node_(r1) $node_(k1)] trace-dynamics $ns_ stdout } }TestSuite instproc enable_tracecwnd { ns tcp } { $self instvar cwnd_chan_ if { ! [info exists cwnd_chan_] } then { set cwnd_chan_ [open all.cwnd w] } $tcp trace cwnd_ $tcp attach $cwnd_chan_}TestSuite instproc plot_cwnd {} { global quiet $self instvar cwnd_chan_ set awkCode { { if ($6 == "cwnd_") { print $1, $7 >> "temp.cwnd"; } } } set f [open cwnd.xgr w] puts $f "TitleText: cwnd" puts $f "Device: Postscript" if { [info exists cwnd_chan_] } { close $cwnd_chan_ } exec rm -f temp.cwnd exec touch temp.cwnd exec awk $awkCode all.cwnd puts $f \"cwnd exec cat temp.cwnd >@ $f close $f if {$quiet == "false"} { exec xgraph -M -bb -tk -x time -y cwnd cwnd.xgr & }}TestSuite instproc netsetup { {stoptime 3.0} {ecnmode false} } { $self instvar ns_ node_ testName_ net_ $self setTopo#### Agent/TCP set maxburst_ 4## set delay 30ms $ns_ delay $node_(r1) $node_(r2) $delay $ns_ delay $node_(r2) $node_(r1) $delay set redq [[$ns_ link $node_(r1) $node_(r2)] queue]## The following controls ECN: $redq set setbit_ $ecnmode $redq set maxthresh_ 20 # trace only the bottleneck link #$self traceQueues $node_(r1) [$self openTrace $stoptime $testName_] $ns_ at $stoptime "$self cleanupAll $testName_"}TestSuite instproc tcpsetup { tcptype {starttime 0.0} {numpkts 10000} {ssthresh 30} { tcp1fid 0 } { delack 0 } {src s1} {dst s3} } { $self instvar ns_ node_ if {$tcptype == "Tahoe" && $delack == 0} { set tcp1 [$ns_ create-connection TCP $node_($src) \ TCPSink $node_($dst) $tcp1fid] } elseif {$tcptype == "Sack1" && $delack == 0} { set tcp1 [$ns_ create-connection TCP/Sack1 $node_($src) \ TCPSink/Sack1 $node_($dst) $tcp1fid] } elseif {$tcptype == "SackRH" && $delack == 0} { set tcp1 [$ns_ create-connection TCP/SackRH $node_($src) \ TCPSink/Sack1 $node_($dst) $tcp1fid] } elseif {$tcptype == "SackRHNewReno" && $delack == 0} { set tcp1 [$ns_ create-connection TCP/SackRH $node_($src) \ TCPSink $node_($dst) $tcp1fid] } elseif {$delack == 0} { set tcp1 [$ns_ create-connection TCP/$tcptype $node_($src) \ TCPSink $node_($dst) $tcp1fid] } elseif {$tcptype == "Tahoe" && $delack == 1} { set tcp1 [$ns_ create-connection TCP $node_($src) \ TCPSink/DelAck $node_($dst) $tcp1fid] } elseif {$tcptype == "Sack1" && $delack == 1} { set tcp1 [$ns_ create-connection TCP/Sack1 $node_($src) \ TCPSink/Sack1/DelAck $node_($dst) $tcp1fid] } elseif {$tcptype == "SackRH" && $delack == 1} { set tcp1 [$ns_ create-connection TCP/SackRH $node_($src) \ TCPSink/Sack1/DelAck $node_($dst) $tcp1fid] } else { set tcp1 [$ns_ create-connection TCP/$tcptype $node_($src) \ TCPSink/DelAck $node_($dst) $tcp1fid] } $tcp1 set window_ 100 $tcp1 set ecn_ 1 $tcp1 set rtxcur_init_ 3.0 $ns_ at 0.2 "$tcp1 set ssthresh_ $ssthresh" set ftp1 [$tcp1 attach-app FTP] $self enable_tracecwnd $ns_ $tcp1 # $self enable_tracequeue $ns_ $ns_ at $starttime "$ftp1 produce $numpkts" $self tcpDump $tcp1 5.0}# Drop the specified packet.TestSuite instproc drop_pkt { number } { $self instvar ns_ lossmodel set lossmodel [$self setloss] $lossmodel set offset_ $number $lossmodel set period_ 10000}TestSuite instproc drop_pkts pkts { $self instvar ns_ errmodel1 set emod [$self emod] set errmodel1 [new ErrorModel/List] $errmodel1 droplist $pkts $emod insert $errmodel1 $emod bind $errmodel1 1}TestSuite instproc ecn_pkts pkts { $self instvar ns_ errmodel2 set emod [$self emod2] set errmodel2 [new ErrorModel/List] $errmodel2 droplist $pkts $emod insert $errmodel2 $emod bind $errmodel2 1 $errmodel2 set markecn_ true}######################################################################## All tests######################################################################## The following set of tests go through a pile of tests for SackRH# to make sure that they all work correctly. ## Single DropClass Test/test_sackRH -superclass TestSuiteTest/test_sackRH instproc init {} { $self instvar net_ test_ xlimits_ fig_file_ Queue/RED set setbit_ true set net_ net2-lossy Agent/TCP set bugFix_ true set test_ "SackRH(NewReno)..SackRH..NewReno..Reno" set xlimits_ "0,12.0" set fig_file_ fig1B.eps $self next}Test/test_sackRH instproc run {} { $self instvar ns_ errmodel1 Agent/TCP set old_ecn_ 1 $self netsetup 12.0 true $self tcpsetup SackRHNewReno 0.0 150 30 1 0 $self tcpsetup SackRH 3.0 150 30 1 0 $self tcpsetup Newreno 6.0 150 30 1 0 $self tcpsetup Reno 9.0 150 30 1 0 puts "Enter loss sequence" gets stdin drops set offset [expr 150 + [llength $drops]] $self drop_pkts [offset_list_3 $drops $offset] puts "Enter ecn sequence" gets stdin ecns $self ecn_pkts [offset_list_3 $ecns $offset] $ns_ run}proc offset_list {l1 l2} { set len1 [llength $l1] set len2 [llength $l2] for {set i 0} {$i < $len2} {incr i} { for {set j 0} {$j < $len1} {incr j} { lappend l1 [expr [lindex $l1 $j] + [lindex $l2 $i]] } } return $l1}# This applies the offset 3 times, so we get a total of# four of the same sequence of packet drops.proc offset_list_3 {l1 offset} { set len1 [llength $l1] for {set j 0} {$j < [expr $len1 * 3]} {incr j} { lappend l1 [expr [lindex $l1 $j] + $offset] } return $l1}TestSuite runTest
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -