test-suite-friendly.tcl
来自「一款用来进行网络模拟的软件」· TCL 代码 · 共 2,073 行 · 第 1/5 页
TCL
2,073 行
Test/delayedTFRC instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ delayedTFRC set guide_ \ "One TFRC flow, with some packets delayed 0.03 seconds, numPkts_ 1." set period_ 40.0 ErrorModel set delay_pkt_ true ErrorModel set drop_ false ErrorModel set delay_ 0.03 Agent/TFRCSink set numPkts_ 1 Test/delayedTFRC instproc run {} [Test/goodTFRC info instbody run ] $self next pktTraceFile}Class Test/delayedTFRC1 superclass TestSuiteTest/delayedTFRC1 instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ delayedTFRC1 set guide_ \ "One TFRC flow, with some packets delayed 0.03 seconds, numPkts_ 5." set period_ 40.0 ErrorModel set delay_pkt_ true ErrorModel set drop_ false ErrorModel set delay_ 0.03 Agent/TFRCSink set numPkts_ 5 Test/delayedTFRC1 instproc run {} [Test/goodTFRC info instbody run ] $self next pktTraceFile}Class Test/delayedTFRC2 superclass TestSuiteTest/delayedTFRC2 instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ delayedTFRC2 set guide_ \ "One TFRC flow, with some packets delayed 0.01 seconds, numPkts_ 3." set period_ 40.0 ErrorModel set delay_pkt_ true ErrorModel set drop_ false ErrorModel set delay_ 0.01 Agent/TFRCSink set numPkts_ 3 Test/delayedTFRC2 instproc run {} [Test/goodTFRC info instbody run ] $self next pktTraceFile}Class Test/goodTCP superclass TestSuiteTest/goodTCP instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ goodTCP set guide_ \ "One TCP flow, no reordering and no extra drops." set list_ {50000 50001} set period_ 1000.0 $self next pktTraceFile}Test/goodTCP instproc run {} { global quiet $self instvar ns_ node_ testName_ interval_ dumpfile_ guide_ list_ period_ puts "Guide: $guide_" $self setTopo set interval_ 0.1 set stopTime 20.0 set stopTime0 [expr $stopTime - 0.001] set stopTime2 [expr $stopTime + 0.001] set dumpfile_ [open temp.s w] if {$quiet == "false"} { set tracefile [open all.tr w] $ns_ trace-all $tracefile } set tcp1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0] set ftp1 [$tcp1 attach-app FTP] $ns_ at 0.0 "$ftp1 start" $self pktsDump 1 $tcp1 $interval_ $dumpfile_ $self dropPktsPeriodic [$ns_ link $node_(r2) $node_(s3)] 0 200.0 $period_ $ns_ at $stopTime0 "close $dumpfile_; $self finish_1 $testName_" #$self traceQueues $node_(r1) [$self openTrace $stopTime $testName_] $ns_ at $stopTime "$self cleanupAll $testName_" if {$quiet == "false"} { $ns_ at $stopTime2 "close $tracefile" } $ns_ at $stopTime2 "exec cp temp2.rands temp.rands; exit 0" $ns_ at $stopTime0 "$self printpkts 0 $tcp1" # trace only the bottleneck link $ns_ run}Class Test/droppedTCP superclass TestSuiteTest/droppedTCP instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ droppedTCP set guide_ \ "One TCP flow, with extra dropped packets." set period_ 40.0 Test/droppedTCP instproc run {} [Test/goodTCP info instbody run ] $self next pktTraceFile}Class Test/delayedTCP superclass TestSuiteTest/delayedTCP instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ delayedTCP set guide_ \ "One TCP flow, with some packets delayed 0.03 seconds." set period_ 40.0 ErrorModel set delay_pkt_ true ErrorModel set drop_ false ErrorModel set delay_ 0.03 Test/delayedTCP instproc run {} [Test/goodTCP info instbody run ] $self next pktTraceFile}Class Test/delayedTCP2 superclass TestSuiteTest/delayedTCP2 instproc init {} { $self instvar net_ test_ guide_ list_ period_ set net_ net2 set test_ delayedTCP2 set guide_ \ "One TCP flow, with some packets delayed 0.01 seconds." set period_ 40.0 ErrorModel set delay_pkt_ true ErrorModel set drop_ false ErrorModel set delay_ 0.01 Test/delayedTCP2 instproc run {} [Test/goodTCP info instbody run ] $self next pktTraceFile}Class Test/initRate superclass TestSuiteTest/initRate instproc init {} { $self instvar net_ test_ guide_ period_ set net_ net2 set test_ initRate set guide_ \ "One TFRC flow, initial rate of one packet per RTT." set period_ 10000.0 Agent/TFRC set rate_init_ 1 Agent/TFRC set rate_init_option_ 1 $self next pktTraceFile}Test/initRate instproc run {} { global quiet $self instvar ns_ node_ testName_ interval_ dumpfile_ guide_ period_ puts "Guide: $guide_" $self setTopo Agent/TFRC set SndrType_ 1 Agent/TFRC set idleFix_ true ; set interval_ 0.1 set stopTime 2.0 set stopTime0 [expr $stopTime - 0.001] set stopTime2 [expr $stopTime + 0.001] set dumpfile_ [open temp.s w] if {$quiet == "false"} { set tracefile [open all.tr w] $ns_ trace-all $tracefile } set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(s3) 0] set ftp [new Application/FTP] $ftp attach-agent $tf1 $ns_ at 0 "$ftp produce 50" $ns_ at 1.5 "$ftp producemore 50" $self dropPktsPeriodic [$ns_ link $node_(r2) $node_(s3)] 0 1000.0 $period_ $self tfccDump 1 $tf1 $interval_ $dumpfile_ $ns_ at $stopTime0 "close $dumpfile_; $self finish_1 $testName_" #$self traceQueues $node_(r1) [$self openTrace $stopTime $testName_] $ns_ at $stopTime "$self cleanupAll $testName_" if {$quiet == "false"} { $ns_ at $stopTime2 "close $tracefile" } $ns_ at $stopTime2 "exec cp temp2.rands temp.rands; exit 0" # $ns_ at $stopTime0 "$self printTFRCpkts 0 $tf1" # trace only the bottleneck link $ns_ run}Class Test/initRateLarge superclass TestSuiteTest/initRateLarge instproc init {} { $self instvar net_ test_ guide_ period_ set net_ net2 set test_ initRateLarge set guide_ \ "One TFRC flow, initial rate of 4 packets per RTT." set period_ 10000.0 Agent/TFRC set rate_init_ 4.0 Agent/TFRC set rate_init_option_ 1 Test/initRateLarge instproc run {} [Test/initRate info instbody run ] $self next pktTraceFile}Class Test/initRateLarger superclass TestSuiteTest/initRateLarger instproc init {} { $self instvar net_ test_ guide_ period_ set net_ net2 set test_ initRateLarger set guide_ \ "One TFRC flow, initial rate of 8 packets per RTT." set period_ 10000.0 Agent/TFRC set rate_init_ 8.0 Agent/TFRC set rate_init_option_ 1 Test/initRateLarger instproc run {} [Test/initRate info instbody run ] $self next pktTraceFile}Class Test/initRateRFC3390 superclass TestSuiteTest/initRateRFC3390 instproc init {} { $self instvar net_ test_ guide_ period_ set net_ net2 set test_ initRateRFC3390 set guide_ \ "One TFRC flow, initial rate from RFC 3390." set period_ 10000.0 Agent/TFRC set rate_init_option_ 2 Test/initRateRFC3390 instproc run {} [Test/initRate info instbody run ] $self next pktTraceFile}TestSuite instproc printdrops { fid fmon } { set fcl [$fmon classifier]; # flow classifier # set flow [$fcl lookup auto 0 0 $fid] puts "fid: $fid drops [$flow set pdrops_] marks [$flow set pmarks_]" puts "fid: $fid packets [$flow set pdepartures_] _bytes [$flow set bdepartures_]"}Class Test/tfrcOnly superclass TestSuiteTest/tfrcOnly instproc init {} { $self instvar net_ test_ guide_ set net_ net2d set test_ tfrcOnly set guide_ \ "One VoIP TFRC flow." Agent/TFRC set voip_ 1 Agent/TFRCSink set ShortIntervals_ 1 $self next pktTraceFile}Test/tfrcOnly instproc run {} { global quiet $self instvar ns_ node_ testName_ interval_ dumpfile_ guide_ puts "Guide: $guide_" $self setTopo set interval_ 0.1 set stopTime 20.0 set stopTime0 [expr $stopTime - 0.001] set stopTime2 [expr $stopTime + 0.001] set pktsize 120 set cbrInterval 0.01 set slink [$ns_ link $node_(r1) $node_(r2)]; # link to collect stats on set fmon [$ns_ makeflowmon Fid] $ns_ attach-fmon $slink $fmon set dumpfile_ [open temp.s w] if {$quiet == "false"} { set tracefile [open all.tr w] $ns_ trace-all $tracefile } $ns_ at 0.0 "$ns_ bandwidth $node_(r1) $node_(r2) 0.2Mbps duplex" $ns_ queue-limit $node_(r1) $node_(r2) 50 set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(s3) 0] $tf1 set packetSize_ $pktsize set cbr [new Application/Traffic/CBR] $cbr set packetSize_ $pktsize $cbr set interval_ $cbrInterval $cbr attach-agent $tf1 $ns_ at 2.0 "$cbr start" $ns_ at $stopTime0 "$cbr stop" $self tfccDump 1 $tf1 $interval_ $dumpfile_ $ns_ at $stopTime0 "close $dumpfile_; $self finish_1 $testName_" $ns_ at $stopTime0 "$self printdrops 0 $fmon" $ns_ at $stopTime "$self cleanupAll $testName_" if {$quiet == "false"} { $ns_ at $stopTime2 "close $tracefile" } $ns_ at $stopTime2 "exec cp temp2.rands temp.rands; exit 0" # trace only the bottleneck link $ns_ run}Class Test/tfrcOnlyHighLoss superclass TestSuiteTest/tfrcOnlyHighLoss instproc init {} { $self instvar net_ test_ guide_ voip set net_ net2d set test_ tfrcOnlyHighLoss set guide_ "One VoIP TFRC flow, high loss." Agent/TFRC set voip_ 1 Agent/TFRCSink set ShortIntervals_ 1 $self next pktTraceFile}Test/tfrcOnlyHighLoss instproc run {} { global quiet $self instvar ns_ node_ testName_ interval_ dumpfile_ guide_ voip puts "Guide: $guide_" $self setTopo set interval_ 0.1 set stopTime 20.0 set stopTime0 [expr $stopTime - 0.001] set stopTime2 [expr $stopTime + 0.001] set pktsize 120 set cbrInterval 0.01 set droprate 0.2 set slink [$ns_ link $node_(r1) $node_(r2)]; # link to collect stats on set fmon [$ns_ makeflowmon Fid] $ns_ attach-fmon $slink $fmon set lossylink_ [$ns_ link $node_(r1) $node_(r2)] set em [new ErrorModule Fid] set errmodel [new ErrorModel/Uniform $droprate pkt ] $lossylink_ errormodule $em $em insert $errmodel $em bind $errmodel 0 5 $em default pass set dumpfile_ [open temp.s w] if {$quiet == "false"} { set tracefile [open all.tr w] $ns_ trace-all $tracefile } $ns_ at 0.0 "$ns_ bandwidth $node_(r1) $node_(r2) 0.2Mbps duplex" $ns_ queue-limit $node_(r1) $node_(r2) 50 set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(s3) 0] $tf1 set packetSize_ $pktsize set cbr [new Application/Traffic/CBR] $cbr set packetSize_ $pktsize $cbr set interval_ $cbrInterval $cbr attach-agent $tf1 $ns_ at 2.0 "$cbr start" $ns_ at $stopTime0 "$cbr stop" $self tfccDump 1 $tf1 $interval_ $dumpfile_ $ns_ at $stopTime0 "close $dumpfile_; $self finish_1 $testName_" $ns_ at $stopTime0 "$self printdrops 0 $fmon" $ns_ at $stopTime "$self cleanupAll $testName_" if {$quiet == "false"} { $ns_ at $stopTime2 "close $tracefile" } $ns_ at $stopTime2 "exec cp temp2.rands temp.rands; exit 0" # trace only the bottleneck link $ns_ run}Class Test/tfrcOnlyHighLoss1 superclass TestSuiteTest/tfrcOnlyHighLoss1 instproc init {} { $self instvar net_ test_ guide_ voip set net_ net2d set test_ tfrcOnlyHighLoss1 set guide_ "One VoIP TFRC flow, high loss, old measurement of loss event rate." Agent/TFRC set voip_ 1 Agent/TFRCSink set ShortIntervals_ 11 Test/tfrcOnlyHighLoss1 instproc run {} [Test/tfrcOnlyHighLoss info instbody run ] $self next pktTraceFile}Class Test/voip superclass TestSuiteTest/voip instproc init {} { $self instvar net_ test_ guide_ set net_ net2d set test_ voip set guide_ \ "One VoIP TFRC flow and one TCP flow, different packet sizes." Agent/TFRC set voip_ 1 Agent/TFRCSink set ShortIntervals_ 1 $self next pktTraceFile}Test/voip instproc run {} { global quiet $self instvar ns_ node_ testName_ interval_ dumpfile_ guide_ puts "Guide: $guide_" $self setTopo set interval_ 0.1 set stopTime 20.0 set stopTime0 [expr $stopTime - 0.001] set stopTime2 [expr $stopTime + 0.001] set pktsize 120 set cbrInterval 0.01 set slink [$ns_ link $node_(r1) $node_(r2)]; # link to collect stats on set fmon [$ns_ makeflowmon Fid] $ns_ attach-fmon $slink $fmon set dumpfile_ [open temp.s w] if {$quiet == "false"} { set tracefile [open all.tr w] $ns_ trace-all $tracefile } $ns_ at 0.0 "$ns_ bandwidth $node_(r1) $node_(r2) 0.2Mbps duplex" $ns_ queue-limit $node_(r1) $node_(r2) 50 set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?