test-suite-quickstart.tcl

来自「一款用来进行网络模拟的软件」· TCL 代码 · 共 1,116 行 · 第 1/3 页

TCL
1,116
字号
    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}Class Test/bad_router -superclass TestSuiteTest/bad_router instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net3    set test_ bad_router	    set guide_  "Not all routers support quickstart."    set sndr TCP/Sack1    set rcvr TCPSink/Sack1    set qs ON    $self next pktTraceFile}Test/bad_router instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set router $node_(r2)    [$router qs-agent] set qs_enabled_ 0    set stopTime 6    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s3) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 20    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 80"    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}Class Test/changing_rtt -superclass TestSuiteTest/changing_rtt instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net3    set test_ changing_rtt	    set guide_  "Changing round-trip times."    set sndr TCP/Sack1    set rcvr TCPSink/Sack1    set qs ON    $self next pktTraceFile}Test/changing_rtt instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set stopTime 6    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s3) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 20    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 80"    $ns_ at 3.1 "$ns_ delay $node_(r1) $node_(r2) 100ms duplex"    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}Class Test/changing_rtt1 -superclass TestSuiteTest/changing_rtt1 instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net3    set test_ changing_rtt1	    set guide_  "Changing round-trip times."    set sndr TCP/Newreno    set rcvr TCPSink    set qs ON    Test/changing_rtt1 instproc run {} [Test/changing_rtt info instbody run ]    $self next pktTraceFile}Class Test/no_acks_back -superclass TestSuiteTest/no_acks_back instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net3    set test_ no_acks_back	    set guide_  "After the first exchange, sender receives no acks."    set sndr TCP/Sack1    set rcvr TCPSink/Sack1    set qs ON    $self next pktTraceFile}Test/no_acks_back instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set stopTime 10    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s4) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 20    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 80"    $ns_ at 3.0 "$ns_ delay $node_(r2) $node_(s4) 10000ms duplex"    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}Class Test/pkt_drops -superclass TestSuiteTest/pkt_drops instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net2    set test_ pkt_drops	    set guide_  "Packets are dropped in the initial window after quickstart."    set sndr TCP/Sack1    set rcvr TCPSink/Sack1    set qs ON    $self next pktTraceFile}Test/pkt_drops instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set stopTime 20    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s4) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 20    $tcp2 set tcp_qs_recovery_ true    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 80"    $self drop_pkts {5 6}    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}proc printdrops { fid fmon } {        set fcl [$fmon classifier]; # flow classifier        set flow [$fcl lookup auto 0 0 $fid]        if {$flow != ""} {          puts "fid: $fid per-link total_packets [$flow set pdepartures_]"          puts "fid: $fid per-link total_bytes [$flow set bdepartures_]"          puts "fid: $fid per-link total_drops [$flow set pdrops_]"          puts "fid: $fid per-link qs_pkts [$flow set qs_pkts_]"          puts "fid: $fid per-link qs_bytes [$flow set qs_bytes_]"          puts "fid: $fid per-link qs_drops [$flow set qs_drops_]"        }}Class Test/many_requests -superclass TestSuiteTest/many_requests instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net4    set test_ many_requests	    set guide_  "Many Quick-Start requests."    set sndr TCP/Newreno    set rcvr TCPSink    set qs ON    $self next pktTraceFile}Test/many_requests instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set stopTime 10    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s3) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 100    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 400"    set tcp3 [$ns_ create-connection $sndr $node_(s2) $rcvr $node_(s4) 2]    $tcp3 set window_ 1000    $tcp3 set rate_request_ 100    set ftp3 [new Application/FTP]    $ftp3 attach-agent $tcp3    $ns_ at 3.0 "$ftp3 produce 200"    set tcp4 [$ns_ create-connection $sndr $node_(s2) $rcvr $node_(s4) 3]    $tcp4 set window_ 1000    $tcp4 set rate_request_ 100    set ftp4 [new Application/FTP]    $ftp4 attach-agent $tcp4    $ns_ at 4.0 "$ftp4 produce 100"    set tcp5 [$ns_ create-connection $sndr $node_(s2) $rcvr $node_(s4) 4]    $tcp5 set window_ 1000    $tcp5 set rate_request_ 100    set ftp5 [new Application/FTP]    $ftp5 attach-agent $tcp5    $ns_ at 6.0 "$ftp5 produce 100"    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}Class Test/many_requests3 -superclass TestSuiteTest/many_requests3 instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net4    set test_ many_requests3    set guide_  "Many Quick-Start requests, generous router."    set sndr TCP/Newreno    set rcvr TCPSink    set qs ON    Agent/QSAgent set alloc_rate_ 0.95     Agent/QSAgent set threshold_ 0.95    Test/many_requests3 instproc run {} [Test/many_requests info instbody run ]    $self next pktTraceFile}Class Test/stats -superclass TestSuiteTest/stats instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_  net2    set test_ stats       set guide_  "Two TCPs, statistics."    set sndr TCP/Newreno    set rcvr TCPSink    Agent/TCP set print_request_ true    set qs ON    $self next pktTraceFile}Test/stats instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    if {$quiet == "false"} {puts $guide_}    $ns_ node-config -QS $qs    $self setTopo    set stopTime 6    set slink [$ns_ link $node_(r1) $node_(r2)]     set fmon [$ns_ makeflowmon Fid]    $ns_ attach-fmon $slink $fmon    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s3) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 20    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 80"    $ns_ at $stopTime "printdrops 1 $fmon;"    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}Class Test/stats1 -superclass TestSuiteTest/stats1 instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net2    set test_ stats1	    set guide_  "Quick-Start packet drops, statistics."    Agent/TCP set print_request_ true    set sndr TCP/Sack1    set rcvr TCPSink/Sack1    set qs ON    $self next pktTraceFile}Test/stats1 instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set stopTime 20    set slink [$ns_ link $node_(s1) $node_(r1)]     set fmon [$ns_ makeflowmon Fid]    $ns_ attach-fmon $slink $fmon    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]    $tcp1 set window_ 8    set ftp1 [new Application/FTP]    $ftp1 attach-agent $tcp1    $ns_ at 0.0 "$ftp1 start"    set tcp2 [$ns_ create-connection $sndr $node_(s1) $rcvr $node_(s4) 1]    $tcp2 set window_ 1000    $tcp2 set rate_request_ 20    $tcp2 set tcp_qs_recovery_ true    set ftp2 [new Application/FTP]    $ftp2 attach-agent $tcp2    $ns_ at 2.0 "$ftp2 produce 80"    $self drop_pkts {5 6}    $ns_ at $stopTime "printdrops 1 $fmon;"    $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime"     $ns_ run}# 20 KBps = 20 pkts per secondClass Test/rate_request -superclass TestSuiteTest/rate_request instproc init {} {    $self instvar net_ test_ guide_ sndr rcvr qs    set net_	net3    set test_ rate_request	    set guide_  "Quick-Start, request of 20 Kbps."    set qs ON    Agent/TCP set qs_request_mode_ 0    $self next pktTraceFile}Test/rate_request instproc run {} {    global quiet    $self instvar ns_ node_ testName_ guide_ sndr rcvr qs    puts "Guide: $guide_"    $ns_ node-config -QS $qs    $self setTopo    set stopTime 2    if {$quiet == "false"} {        Agent/TCP set print_request_ true    }    set tcp1 [$ns_ create-connection TCP/Newreno $node_(s1) TCPSink $node_(s3) 0]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?