📄 test-suite-simple.tcl
字号:
$self instvar node_ set node_(s1) [$ns node] set node_(s2) [$ns node] set node_(r1) [$ns node] set node_(r2) [$ns node] set node_(s3) [$ns node] set node_(s4) [$ns node]}Class Topology/net2 -superclass NodeTopology/6nodesTopology/net2 instproc init ns { $self next $ns $self instvar node_ Queue/RED set drop_rand_ true $ns duplex-link $node_(s1) $node_(r1) 10Mb 2ms DropTail $ns duplex-link $node_(s2) $node_(r1) 10Mb 3ms DropTail $ns duplex-link $node_(r1) $node_(r2) 1.5Mb 20ms RED $ns queue-limit $node_(r1) $node_(r2) 25 $ns queue-limit $node_(r2) $node_(r1) 25 $ns duplex-link $node_(s3) $node_(r2) 10Mb 4ms DropTail $ns duplex-link $node_(s4) $node_(r2) 10Mb 5ms DropTail if {[$class info instprocs config] != ""} { $self config $ns }}Class Topology/net3 -superclass NodeTopology/6nodesTopology/net3 instproc init ns { $self next $ns $self instvar node_ Queue/RED set drop_rand_ true $ns duplex-link $node_(s1) $node_(r1) 100Mb 1ms DropTail $ns duplex-link $node_(s2) $node_(r1) 100Mb 30ms DropTail $ns duplex-link $node_(r1) $node_(r2) 10Mb 10ms RED $ns queue-limit $node_(r1) $node_(r2) 25 $ns queue-limit $node_(r2) $node_(r1) 25 $ns duplex-link $node_(s3) $node_(r2) 100Mb 1ms DropTail $ns duplex-link $node_(s4) $node_(r2) 100Mb 5ms DropTail if {[$class info instprocs config] != ""} { $self config $ns }}# Definition of test-suite testsClass Test/tahoe1 -superclass TestSuiteTest/tahoe1 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ tahoe set guide_ \ "Tahoe TCP with multiple packets dropped from a window of data." Queue/DropTail set summarystats_ true $self next}Test/tahoe1 instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} # Set up TCP connection set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 50 # Set up FTP source set ftp1 [$tcp1 attach-app FTP] $ns_ at 0.0 "$ftp1 start" $self tcpDump $tcp1 1.0 set link1 [$ns_ link $node_(r1) $node_(k1)] set queue1 [$link1 queue] $ns_ at 5.0 "$queue1 printstats" # Trace only the bottleneck link # # Actually, we now trace all activity at the node around the # bottleneck link. This allows us to track acks, as well # packets taking any alternate paths around the bottleneck # link. # $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_] $ns_ run}Class Test/tahoe1Bytes -superclass TestSuiteTest/tahoe1Bytes instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ tahoe1Bytes set guide_ "DropTail queue in bytes instead of packets." Queue/DropTail set queue_in_bytes_ true Queue/DropTail set mean_pktsize_ 1000 Queue/DropTail set summarystats_ true Test/tahoe1Bytes instproc run {} [Test/tahoe1 info instbody run ] $self next}# Tahoe1 with REDClass Test/tahoe1RED -superclass TestSuiteTest/tahoe1RED instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0a set test_ tahoe1RED set guide_ \ "RED queue, configured for 5 packets instead of DropTail's 6 packets." Queue/RED set summarystats_ true Test/tahoe1RED instproc run {} [Test/tahoe1 info instbody run ] $self next}# Tahoe1 with REDClass Test/tahoe1REDbytes -superclass TestSuiteTest/tahoe1REDbytes instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0a set test_ tahoe1REDbytes set guide_ "RED queue in bytes." Queue/RED set queue_in_bytes_ true Queue/RED set mean_pktsize_ 1000 Queue/RED set summarystats_ true Test/tahoe1REDbytes instproc run {} [Test/tahoe1 info instbody run ] $self next}Class Test/tahoe2 -superclass TestSuiteTest/tahoe2 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ tahoe2 set guide_ "Tahoe TCP with one packet dropped." $self next}Test/tahoe2 instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 14 set ftp1 [$tcp1 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $self tcpDump $tcp1 1.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_] $ns_ run}Class Test/tahoe3 -superclass TestSuiteTest/tahoe3 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ tahoe3 set guide_ \ "Tahoe TCP, two packets dropped from a congestion window of 5 packets." $self next}Test/tahoe3 instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} $ns_ queue-limit $node_(r1) $node_(k1) 8 $ns_ queue-limit $node_(k1) $node_(r1) 8 set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 100 set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1] $tcp2 set window_ 16 set ftp1 [$tcp1 attach-app FTP] set ftp2 [$tcp2 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $ns_ at 0.5 "$ftp2 start" $self tcpDump $tcp1 1.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 8.0 $testName_] $ns_ run}# Tahoe3 with RED.Class Test/tahoe3RED -superclass TestSuiteTest/tahoe3RED instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0a set test_ tahoe3RED set guide_ \ "Tahoe TCP, two packets dropped, RED queue configured for 5 packets." Test/tahoe3RED instproc run {} [Test/tahoe3 info instbody run ] $self next}Class Test/tahoe4 -superclass TestSuiteTest/tahoe4 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ tahoe4 set guide_ \ "Tahoe TCP, two connections with different round-trip times." $self next}Test/tahoe4 instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} $ns_ delay $node_(s2) $node_(r1) 200ms $ns_ delay $node_(r1) $node_(s2) 200ms $ns_ queue-limit $node_(r1) $node_(k1) 11 $ns_ queue-limit $node_(k1) $node_(r1) 11 set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 30 set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1] $tcp2 set window_ 30 set ftp1 [$tcp1 attach-app FTP] set ftp2 [$tcp2 attach-app FTP] $ns_ at 0.0 "$ftp1 start" $ns_ at 0.0 "$ftp2 start" $self tcpDump $tcp1 5.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 25.0 $testName_] $ns_ run}Class Test/no_bug -superclass TestSuiteTest/no_bug instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net1 set test_ no_bug set guide_ "Tahoe TCP with TCP/bugFix_ set to true." $self next}Test/no_bug instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} $ns_ delay $node_(s1) $node_(r1) 3ms $ns_ delay $node_(r1) $node_(s1) 3ms set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 50 set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1] $tcp2 set window_ 50 set ftp1 [$tcp1 attach-app FTP] set ftp2 [$tcp2 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $ns_ at 1.75 "$ftp2 produce 99" $self tcpDump $tcp1 1.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 6.0 $testName_] $ns_ run}Class Test/bug -superclass TestSuiteTest/bug instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net1 set test_ bug set guide_ "Tahoe TCP with TCP/bugFix_ set to false." $self next}Test/bug instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} $ns_ delay $node_(s1) $node_(r1) 3ms $ns_ delay $node_(r1) $node_(s1) 3ms set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 50 $tcp1 set bugFix_ false set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1] $tcp2 set window_ 50 $tcp2 set bugFix_ false set ftp1 [$tcp1 attach-app FTP] set ftp2 [$tcp2 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $ns_ at 1.75 "$ftp2 produce 100" $self tcpDump $tcp1 1.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 6.0 $testName_] $ns_ run}Class Test/reno1 -superclass TestSuiteTest/reno1 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ reno1 set guide_ \ "Reno TCP, one packet dropped, Fast Recovery and Fast Retransmit" $self next}Test/reno1 instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 14 set ftp1 [$tcp1 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $self tcpDump $tcp1 1.0 # trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_] $ns_ run}Class Test/reno -superclass TestSuiteTest/reno instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ reno set guide_ \ "Reno TCP, limited by maximum congestion window maxcwnd_." $self next}Test/reno instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 28 $tcp1 set maxcwnd_ 14 set ftp1 [$tcp1 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $self tcpDump $tcp1 1.0 # trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_] $ns_ run}Class Test/renoA -superclass TestSuiteTest/renoA instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ renoA set guide_ \ "Reno TCP, one packet dropped, Fast Recovery and Fast Retransmit" $self next}Test/renoA instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} $ns_ queue-limit $node_(r1) $node_(k1) 8 set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 28 set tcp2 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 1] $tcp2 set window_ 4 set tcp3 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 2] $tcp3 set window_ 4 set ftp1 [$tcp1 attach-app FTP] $ns_ at 1.0 "$ftp1 start" set ftp2 [$tcp2 attach-app FTP] $ns_ at 1.2 "$ftp2 produce 6" set ftp3 [$tcp3 attach-app FTP] $ns_ at 1.2 "$ftp3 produce 6" $self tcpDump $tcp1 1.0 $self tcpDump $tcp2 1.0 $self tcpDump $tcp3 1.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_] $ns_ run}Class Test/reno2 -superclass TestSuiteTest/reno2 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ reno2 set guide_ \ "Reno TCP, multiple packets dropped, Retransmit Timeout." $self next}Test/reno2 instproc run {} { global quiet $self instvar ns_ node_ testName_ guide_ if {$quiet == "false"} {puts $guide_} $ns_ queue-limit $node_(r1) $node_(k1) 9 set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 50 set tcp2 [$ns_ create-connection TCP/Reno $node_(s2) TCPSink $node_(k1) 1] $tcp2 set window_ 20 set ftp1 [$tcp1 attach-app FTP] set ftp2 [$tcp2 attach-app FTP] $ns_ at 1.0 "$ftp1 start" $ns_ at 1.0 "$ftp2 start" $self tcpDump $tcp1 1.0 # Trace only the bottleneck link $self traceQueues $node_(r1) [$self openTrace 10.0 $testName_] $ns_ run}Class Test/reno3 -superclass TestSuiteTest/reno3 instproc init topo { $self instvar net_ defNet_ test_ guide_ set net_ $topo set defNet_ net0 set test_ reno3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -