test-suite-quiescent.tcl
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
源码类别:

通讯编程

开发平台:

Visual C++

  1. # copyright (c) 1995 The Regents of the University of California.
  2. # All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions
  6. # are met:
  7. # 1. Redistributions of source code must retain the above copyright
  8. #    notice, this list of conditions and the following disclaimer.
  9. # 2. Redistributions in binary form must reproduce the above copyright
  10. #    notice, this list of conditions and the following disclaimer in the
  11. #    documentation and/or other materials provided with the distribution.
  12. # 3. All advertising materials mentioning features or use of this software
  13. #    must display the following acknowledgement:
  14. # This product includes software developed by the Computer Systems
  15. # Engineering Group at Lawrence Berkeley Laboratory.
  16. # 4. Neither the name of the University nor of the Laboratory may be used
  17. #    to endorse or promote products derived from this software without
  18. #    specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  21. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  24. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. # SUCH DAMAGE.
  31. #
  32. # @(#) $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-quiescent.tcl,v 1.14 2006/03/15 04:04:28 sallyfloyd Exp $
  33. #
  34. source misc_simple.tcl
  35. source support.tcl
  36. # FOR UPDATING GLOBAL DEFAULTS:
  37. Agent/TCP set precisionReduce_ false ;   # default changed on 2006/1/24.
  38. Agent/TCP set rtxcur_init_ 6.0 ;      # Default changed on 2006/01/21
  39. Agent/TCP set updated_rttvar_ false ;  # Variable added on 2006/1/21
  40. Agent/TCP set packetSize_ 500
  41. Application/Traffic/CBR set packetSize_ 500
  42. Agent/TCP set window_ 1000
  43. Agent/TCP set partial_ack_ 1
  44. Agent/TFRC set SndrType_ 1 
  45. Agent/TFRC set packetSize_ 500 
  46. # Uncomment the line below to use a random seed for the
  47. #  random number generator.
  48. # ns-random 0
  49. TestSuite instproc finish {file stoptime} {
  50.         global quiet PERL
  51. exec $PERL ../../bin/getrc -s 2 -d 3 all.tr | 
  52.   $PERL ../../bin/raw2xg -s 0.01 -m 90 -t $file > temp.rands
  53.         exec echo $stoptime 0 >> temp.rands 
  54.         if {$quiet == "false"} {
  55.                 exec xgraph -bb -tk -nl -m -x time -y packets temp.rands &
  56.         }
  57.         ## now use default graphing tool to make a data file
  58.         ## if so desired
  59. #       exec csh figure2.com $file
  60. # exec cp temp.rands temp.$file 
  61. # exec csh gnuplotA.com temp.$file $file
  62.         exit 0
  63. }
  64. Class Topology
  65. Topology instproc node? num {
  66.     $self instvar node_
  67.     return $node_($num)
  68. }
  69. Class Topology/net2 -superclass Topology
  70. Topology/net2 instproc init ns {
  71.     $self instvar node_
  72.     set node_(s1) [$ns node]
  73.     set node_(s2) [$ns node]
  74.     set node_(r1) [$ns node]
  75.     set node_(r2) [$ns node]
  76.     set node_(s3) [$ns node]
  77.     set node_(s4) [$ns node]
  78.     $self next
  79.     $ns duplex-link $node_(s1) $node_(r1) 10Mb 2ms DropTail
  80.     $ns duplex-link $node_(s2) $node_(r1) 10Mb 3ms DropTail
  81.     $ns duplex-link $node_(r1) $node_(r2) 1.5Mb 20ms RED
  82.     #$ns duplex-link $node_(r1) $node_(r2) 10Mb 20ms RED
  83.     $ns queue-limit $node_(r1) $node_(r2) 50
  84.     $ns queue-limit $node_(r2) $node_(r1) 50 
  85.     $ns duplex-link $node_(s3) $node_(r2) 10Mb 4ms DropTail
  86.     $ns duplex-link $node_(s4) $node_(r2) 10Mb 5ms DropTail
  87. }
  88. Class Test/tfrc_onoff -superclass TestSuite
  89. Test/tfrc_onoff instproc init {} {
  90.     $self instvar net_ test_ guide_ stopTime1_ sender 
  91.     set net_ net2
  92.     set test_ tfrc_onoff
  93.     set guide_  
  94.     "TFRC with a data source with limited, bursty data, no congestion."
  95.     set sender TFRC
  96.     Agent/TFRC set oldCode_ false
  97.     set stopTime1_ 10
  98.     $self next pktTraceFile
  99. }
  100. Test/tfrc_onoff instproc run {} {
  101.     global quiet
  102.     $self instvar ns_ node_ testName_ guide_ stopTime1_ sender 
  103.     puts "Guide: $guide_"
  104.     $self setTopo
  105.     set stopTime $stopTime1_
  106.     if {$sender == "TFRC"} {
  107.       set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(s3) 0]
  108.     } elseif {$sender == "TCP"} {
  109.       set tf1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  110.     }
  111.     set ftp [new Application/FTP]
  112.     $ftp attach-agent $tf1
  113.     $ns_ at 0 "$ftp produce 100"
  114.     $ns_ at 5 "$ftp producemore 100"
  115.     $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime" 
  116.     # trace only the bottleneck link
  117.     $ns_ run
  118. }
  119. Class Test/tfrc_onoff_oldcode -superclass TestSuite
  120. Test/tfrc_onoff_oldcode instproc init {} {
  121.     $self instvar net_ test_ guide_ stopTime1_ sender 
  122.     set net_ net2
  123.     set test_ tfrc_onoff_oldcode
  124.     set guide_  
  125.     "TFRC, bursty data, no congestion, old code."
  126.     set sender TFRC
  127.     Agent/TFRC set oldCode_ true
  128.     set stopTime1_ 10
  129.     Test/tfrc_onoff_oldcode instproc run {} [Test/tfrc_onoff info instbody run ]
  130.     $self next pktTraceFile
  131. }
  132. Class Test/tcp_onoff -superclass TestSuite
  133. Test/tcp_onoff instproc init {} {
  134.     $self instvar net_ test_ guide_ stopTime1_ sender 
  135.     set net_ net2
  136.     set test_ tcp_onoff
  137.     set guide_  
  138.     "TCP with a data source with limited, bursty data, no congestion."
  139.     set sender TCP
  140.     set stopTime1_ 10
  141.     Test/tcp_onoff instproc run {} [Test/tfrc_onoff info instbody run ]
  142.     $self next pktTraceFile
  143. }
  144. Class Test/tfrc_telnet -superclass TestSuite
  145. Test/tfrc_telnet instproc init {} {
  146.     $self instvar net_ test_ guide_ sender 
  147.     set net_ net2
  148.     set test_ tfrc_telnet
  149.     set guide_  
  150.     "TFRC with a Telnet data source, telnet data rate increased at time 4."
  151.     set sender TFRC
  152.     $self next pktTraceFile
  153. }
  154. Test/tfrc_telnet instproc run {} {
  155.     global quiet
  156.     $self instvar ns_ node_ testName_ guide_ sender 
  157.     puts "Guide: $guide_"
  158.     $self setTopo
  159.     set stopTime 10
  160.     if {$sender == "TFRC"} {
  161.       set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(s3) 0]
  162.     } elseif {$sender == "TCP"} {
  163.       set tf1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  164.     }
  165.     set telnet1 [new Source/Telnet]
  166.     $telnet1 attach-agent $tf1
  167.     $telnet1 set interval_ 0.01
  168.     $ns_ at 0.0 "$telnet1 start"
  169.     $ns_ at 4.0 "$telnet1 set interval_ 0.001"
  170.     $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime" 
  171.     # trace only the bottleneck link
  172.     $ns_ run
  173. }
  174. Class Test/tcp_telnet -superclass TestSuite
  175. Test/tcp_telnet instproc init {} {
  176.     $self instvar net_ test_ guide_ sender 
  177.     set net_ net2
  178.     set test_ tcp_telnet
  179.     set guide_  
  180.     "TCP with a Telnet data source, telnet data rate increased at time 4."
  181.     set sender TCP
  182.     Test/tcp_telnet instproc run {} [Test/tfrc_telnet info instbody run ]
  183.     $self next pktTraceFile
  184. }
  185. Class Test/tcp_telnet_CWV -superclass TestSuite
  186. Test/tcp_telnet_CWV instproc init {} {
  187.     $self instvar net_ test_ guide_ sender 
  188.     set net_ net2
  189.     set test_ tcp_telnet_CWV
  190.     set guide_  
  191.     "TCP with a Telnet data source, with Congestion Window Validation."
  192.     set sender TCP
  193.     Agent/TCP set QOption_ 1
  194.     Agent/TCP set control_increase_ 1
  195.     # Agent/TCP set EnblRTTCtr_ 1
  196.     Test/tcp_telnet_CWV instproc run {} [Test/tfrc_telnet info instbody run]
  197.     $self next pktTraceFile
  198. }
  199. Class Test/tfrc_cbr -superclass TestSuite
  200. Test/tfrc_cbr instproc init {} {
  201.     $self instvar net_ test_ guide_ sender 
  202.     set net_ net2
  203.     set test_ tfrc_cbr
  204.     set guide_  
  205.     "TFRC with a CBR data source, CBR data rate changes over time."
  206.     set sender TFRC
  207.     $self next pktTraceFile
  208. }
  209. Test/tfrc_cbr instproc run {} {
  210.     global quiet
  211.     $self instvar ns_ node_ testName_ guide_ sender 
  212.     puts "Guide: $guide_"
  213.     $self setTopo
  214.     set stopTime 15
  215.     if {$sender == "TFRC"} {
  216.       set tf1 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(s3) 0]
  217.     } elseif {$sender == "TCP"} {
  218.       set tf1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  219.     }
  220.     set cbr1 [new Application/Traffic/CBR]
  221.     $cbr1 attach-agent $tf1
  222.     # $tf1 set type_ CBR
  223.     $cbr1 set interval_ 0.01
  224.     $ns_ at 0.01 "$cbr1 start"
  225.     $ns_ at 2.0 "$cbr1 set interval_ 0.002"
  226.     $ns_ at 3.0 "$cbr1 set interval_ 0.01"
  227.     $ns_ at 8.0 "$cbr1 set interval_ 0.002"
  228.     $ns_ at $stopTime "$self cleanupAll $testName_ $stopTime" 
  229.     # trace only the bottleneck link
  230.     $ns_ run
  231. }
  232. Class Test/tfrc_cbr_conservative -superclass TestSuite
  233. Test/tfrc_cbr_conservative instproc init {} {
  234.     $self instvar net_ test_ guide_ sender
  235.     set net_ net2
  236.     set test_ tfrc_cbr_conservative
  237.     set guide_  
  238.     "TFRC with a CBR data source, conservative option."
  239.     set sender TFRC
  240.     Agent/TFRC set conservative_ true
  241.     Agent/TFRC set scmult_ 1.2
  242.     Test/tfrc_cbr_conservative instproc run {} [Test/tfrc_cbr info instbody run ]
  243.     $self next pktTraceFile
  244. }
  245. Class Test/tcp_cbr -superclass TestSuite
  246. Test/tcp_cbr instproc init {} {
  247.     $self instvar net_ test_ guide_ sender
  248.     set net_ net2
  249.     set test_ tcp_cbr
  250.     set guide_  
  251.     "TCP with a CBR data source, CBR data rate changes over time."
  252.     set sender TCP
  253.     Test/tcp_cbr instproc run {} [Test/tfrc_cbr info instbody run ]
  254.     $self next pktTraceFile
  255. }
  256. Class Test/tcp_cbr_CWV -superclass TestSuite
  257. Test/tcp_cbr_CWV instproc init {} {
  258.     $self instvar net_ test_ guide_ sender 
  259.     set net_ net2
  260.     set test_ tcp_cbr_CWV
  261.     set guide_  
  262.     "TCP with a CBR data source, with Congestion Window Validation." 
  263.     set sender TCP
  264.     Agent/TCP set QOption_ 1
  265.     Agent/TCP set control_increase_ 1
  266.     # Agent/TCP set EnblRTTCtr_ 1
  267.     Test/tcp_cbr_CWV instproc run {} [Test/tfrc_cbr info instbody run ]
  268.     $self next pktTraceFile
  269. }
  270. TestSuite runTest