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

通讯编程

开发平台:

Visual C++

  1. #
  2. # Copyright (c) 1995-1997 The Regents of the University of California.
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. #    notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. #    notice, this list of conditions and the following disclaimer in the
  12. #    documentation and/or other materials provided with the distribution.
  13. # 3. All advertising materials mentioning features or use of this software
  14. #    must display the following acknowledgement:
  15. # This product includes software developed by the Computer Systems
  16. # Engineering Group at Lawrence Berkeley Laboratory.
  17. # 4. Neither the name of the University nor of the Laboratory may be used
  18. #    to endorse or promote products derived from this software without
  19. #    specific prior written permission.
  20. #
  21. # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. # SUCH DAMAGE.
  32. #
  33. # To run all tests: test-all-rem
  34. set dir [pwd]
  35. catch "cd tcl/test"
  36. source misc_simple.tcl
  37. remove-all-packet-headers       ; # removes all except common
  38. add-packet-header Flags IP TCP  ; # hdrs reqd for validation test
  39.  
  40. # FOR UPDATING GLOBAL DEFAULTS:
  41. Agent/TCP set precisionReduce_ false ;   # default changed on 2006/1/24.
  42. Agent/TCP set rtxcur_init_ 6.0 ;      # Default changed on 2006/01/21
  43. Agent/TCP set updated_rttvar_ false ;  # Variable added on 2006/1/21
  44. Agent/TCP set tcpTick_ 0.1
  45. # The default for tcpTick_ is being changed to reflect a changing reality.
  46. Agent/TCP set rfc2988_ false
  47. # The default for rfc2988_ is being changed to true.
  48. Agent/TCP set minrto_ 1
  49. # default changed on 10/14/2004.
  50. Agent/TCP set useHeaders_ false
  51. # The default is being changed to useHeaders_ true.
  52. Agent/TCP set singledup_ 0
  53. Agent/TCP set overhead_ 0.001
  54. # The default is being changed to 1
  55. catch "cd $dir"
  56. set flowfile fairflow.tr; # file where flow data is written
  57. set flowgraphfile fairflow.xgr; # file given to graph tool 
  58. TestSuite instproc finish file {
  59. global quiet PERL
  60. $self instvar ns_ tchan_ testName_
  61.         exec $PERL ../../bin/getrc -s 2 -d 3 all.tr | 
  62.           $PERL ../../bin/raw2xg -a -s 0.01 -m 90 -t $file > temp.rands
  63. if {$quiet == "false"} {
  64.          exec xgraph -bb -tk -nl -m -x time -y packets temp.rands &
  65. }
  66.         ## now use default graphing tool to make a data file
  67.         ## if so desired
  68. if { [info exists tchan_] && $quiet == "false" } {
  69. $self plotQueue $testName_
  70. }
  71. $ns_ halt
  72. }
  73. TestSuite instproc enable_tracequeue ns {
  74. $self instvar tchan_ node_
  75. set remq [[$ns link $node_(r1) $node_(r2)] queue]
  76. set tchan_ [open all.q w]
  77. $remq trace curq_
  78. $remq attach $tchan_
  79. }
  80. Class Topology
  81. Topology instproc node? num {
  82.     $self instvar node_
  83.     return $node_($num)
  84. }
  85. Class Topology/net2 -superclass Topology
  86. Topology/net2 instproc init ns {
  87.     $self instvar node_
  88.     set node_(s1) [$ns node]
  89.     set node_(s2) [$ns node]    
  90.     set node_(r1) [$ns node]    
  91.     set node_(r2) [$ns node]    
  92.     set node_(s3) [$ns node]    
  93.     set node_(s4) [$ns node]    
  94.     $self next 
  95.     $ns duplex-link $node_(s1) $node_(r1) 10Mb 2ms DropTail
  96.     $ns duplex-link $node_(s2) $node_(r1) 10Mb 3ms DropTail
  97.     $ns duplex-link $node_(r1) $node_(r2) 1.5Mb 20ms REM
  98.     $ns queue-limit $node_(r1) $node_(r2) 25
  99.     $ns queue-limit $node_(r2) $node_(r1) 25
  100.     $ns duplex-link $node_(s3) $node_(r2) 10Mb 4ms DropTail
  101.     $ns duplex-link $node_(s4) $node_(r2) 10Mb 5ms DropTail
  102.  
  103.     $ns duplex-link-op $node_(s1) $node_(r1) orient right-down
  104.     $ns duplex-link-op $node_(s2) $node_(r1) orient right-up
  105.     $ns duplex-link-op $node_(r1) $node_(r2) orient right
  106.     $ns duplex-link-op $node_(r1) $node_(r2) queuePos 0
  107.     $ns duplex-link-op $node_(r2) $node_(r1) queuePos 0
  108.     $ns duplex-link-op $node_(s3) $node_(r2) orient left-down
  109.     $ns duplex-link-op $node_(s4) $node_(r2) orient left-up
  110. }   
  111. Class Topology/net3 -superclass Topology
  112. Topology/net3 instproc init ns {
  113.     $self instvar node_
  114.     set node_(s1) [$ns node]
  115.     set node_(s2) [$ns node]    
  116.     set node_(r1) [$ns node]    
  117.     set node_(r2) [$ns node]    
  118.     set node_(s3) [$ns node]    
  119.     set node_(s4) [$ns node]    
  120.     $self next 
  121.     $ns duplex-link $node_(s1) $node_(r1) 10Mb 0ms DropTail
  122.     $ns duplex-link $node_(s2) $node_(r1) 10Mb 1ms DropTail
  123.     $ns duplex-link $node_(r1) $node_(r2) 1.5Mb 10ms REM
  124.     $ns duplex-link $node_(r2) $node_(r1) 1.5Mb 10ms REM
  125.     $ns queue-limit $node_(r1) $node_(r2) 100
  126.     $ns queue-limit $node_(r2) $node_(r1) 100
  127.     $ns duplex-link $node_(s3) $node_(r2) 10Mb 2ms DropTail
  128.     $ns duplex-link $node_(s4) $node_(r2) 10Mb 3ms DropTail
  129.  
  130.     $ns duplex-link-op $node_(s1) $node_(r1) orient right-down
  131.     $ns duplex-link-op $node_(s2) $node_(r1) orient right-up
  132.     $ns duplex-link-op $node_(r1) $node_(r2) orient right
  133.     $ns duplex-link-op $node_(r1) $node_(r2) queuePos 0
  134.     $ns duplex-link-op $node_(r2) $node_(r1) queuePos 0
  135.     $ns duplex-link-op $node_(s3) $node_(r2) orient left-down
  136.     $ns duplex-link-op $node_(s4) $node_(r2) orient left-up
  137. }   
  138. TestSuite instproc plotQueue file {
  139. global quiet
  140. $self instvar tchan_
  141. #
  142. # Plot the queue size and average queue size, for REM gateways.
  143. #
  144. set awkCode {
  145. {
  146. if ($1 == "Q" && NF>2) {
  147. print $2, $3 >> "temp.q";
  148. set end $2
  149. }
  150. }
  151. }
  152. set f [open temp.queue w]
  153. puts $f "TitleText: $file"
  154. puts $f "Device: Postscript"
  155. if { [info exists tchan_] } {
  156. close $tchan_
  157. }
  158. exec rm -f temp.q
  159. exec touch temp.q
  160. exec awk $awkCode all.q
  161. puts $f "queue
  162. exec cat temp.q >@ $f  
  163. close $f
  164. if {$quiet == "false"} {
  165. exec xgraph -bb -tk -x time -y queue temp.queue &
  166. }
  167. }
  168. TestSuite instproc tcpDumpAll { tcpSrc interval label } {
  169.     global quiet
  170.     $self instvar dump_inst_ ns_
  171.     if ![info exists dump_inst_($tcpSrc)] {
  172. set dump_inst_($tcpSrc) 1
  173. set report $label/window=[$tcpSrc set window_]/packetSize=[$tcpSrc set packetSize_]
  174. if {$quiet == "false"} {
  175. puts $report
  176. }
  177. $ns_ at 0.0 "$self tcpDumpAll $tcpSrc $interval $label"
  178. return
  179.     }
  180.     $ns_ at [expr [$ns_ now] + $interval] "$self tcpDumpAll $tcpSrc $interval $label"
  181.     set report time=[$ns_ now]/class=$label/ack=[$tcpSrc set ack_]/packets_resent=[$tcpSrc set nrexmitpack_]
  182.     if {$quiet == "false"} {
  183.      puts $report
  184.     }
  185. }       
  186. Class Test/rem1 -superclass TestSuite
  187. Test/rem1 instproc init {} {
  188.     $self instvar net_ test_
  189.     set net_ net2 
  190.     set test_ rem1
  191.     $self next pktTraceFile
  192. }
  193. Test/rem1 instproc run {} {
  194.     $self instvar ns_ node_ testName_ net_
  195.     $self setTopo
  196.     set remq [[$ns_ link $node_(r1) $node_(r2)] queue]
  197.     $remq set markpkts_ false 
  198.     $remq set phi_ 5 # This is just for fun.
  199.     set stoptime 10.0
  200.     set tcp1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  201.     $tcp1 set window_ 50
  202.     set tcp2 [$ns_ create-connection TCP/Sack1 $node_(s2) TCPSink/Sack1 $node_(s3) 1]
  203.     $tcp2 set window_ 50
  204.     set ftp1 [$tcp1 attach-app FTP]
  205.     set ftp2 [$tcp2 attach-app FTP]
  206.     $self enable_tracequeue $ns_
  207.     $ns_ at 0.0 "$ftp1 start"
  208.     $ns_ at 3.0 "$ftp2 start"
  209.     $self tcpDump $tcp1 5.0
  210.     # trace only the bottleneck link
  211.     #$self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  212.     $ns_ at $stoptime "$self cleanupAll $testName_"
  213.     $ns_ run
  214. }
  215. Class Test/ecn -superclass TestSuite
  216. Test/ecn instproc init {} {
  217.     $self instvar net_ test_
  218.     Queue/REM set setbit_ true
  219.     Agent/TCP set old_ecn_ 1
  220.     set net_ net2
  221.     set test_ ecn
  222.     $self next pktTraceFile
  223. }
  224. Test/ecn instproc run {} {
  225.     $self instvar ns_ node_ testName_
  226.     $self setTopo 
  227.     set stoptime 10.0
  228.     set remq [[$ns_ link $node_(r1) $node_(r2)] queue]
  229.     $remq set markpkts_ true 
  230.     $remq set phi_ 5 # This is just for fun.
  231.     set tcp1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  232.     $tcp1 set window_ 50
  233.     $tcp1 set ecn_ 1
  234.     set tcp2 [$ns_ create-connection TCP/Sack1 $node_(s2) TCPSink/Sack1 $node_(s3) 1]
  235.     $tcp2 set window_ 50
  236.     $tcp2 set ecn_ 1
  237.         
  238.     set ftp1 [$tcp1 attach-app FTP]
  239.     set ftp2 [$tcp2 attach-app FTP]
  240.         
  241.     $self enable_tracequeue $ns_
  242.     $ns_ at 0.0 "$ftp1 start"
  243.     $ns_ at 3.0 "$ftp2 start"
  244.         
  245.     $self tcpDump $tcp1 5.0
  246.         
  247.     # trace only the bottleneck link
  248.     #$self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  249.     $ns_ at $stoptime "$self cleanupAll $testName_"
  250.         
  251.     $ns_ run
  252. }
  253. Class Test/rem2 -superclass TestSuite
  254. Test/rem2 instproc init {} {
  255.     $self instvar net_ test_
  256.     set net_ net3
  257.     set test_ rem2
  258.     $self next pktTraceFile
  259. }
  260. Test/rem2 instproc run {} {
  261.     $self instvar ns_ node_ testName_
  262.     $self setTopo
  263.     set stoptime 10.0
  264.     set remq [[$ns_ link $node_(r1) $node_(r2)] queue]
  265.     $remq set markpkts_ false 
  266.     $remq set queue_in_bytes_ false 
  267.     set tcp1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  268.     $tcp1 set window_ 100 
  269.     set tcp2 [$ns_ create-connection TCP/Sack1 $node_(s2) TCPSink/Sack1 $node_(s3) 1]
  270.     $tcp2 set window_ 100
  271.     set ftp1 [$tcp1 attach-app FTP]
  272.     set ftp2 [$tcp2 attach-app FTP]
  273.     $self enable_tracequeue $ns_
  274.     $ns_ at 0.0 "$ftp1 start"
  275.     $ns_ at 3.0 "$ftp2 start"
  276.     $self tcpDump $tcp1 5.0
  277.     
  278.     # trace only the bottleneck link
  279.     #$self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  280.     $ns_ at $stoptime "$self cleanupAll $testName_"
  281.     $ns_ run
  282. }
  283. # The queue is measured in "packets".
  284. Class Test/rem_twoway -superclass TestSuite
  285. Test/rem_twoway instproc init {} {
  286.     $self instvar net_ test_
  287.     set net_ net3
  288.     set test_ rem_twoway
  289.     $self next pktTraceFile
  290. }
  291. Test/rem_twoway instproc run {} {
  292.     $self instvar ns_ node_ testName_
  293.     $self setTopo
  294.     set stoptime 10.0
  295.     set remq [[$ns_ link $node_(r1) $node_(r2)] queue]
  296.     $remq set markpkts_ false 
  297.     $remq set phi_ 5 
  298.     set tcp1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  299.     $tcp1 set window_ 100 
  300.     set tcp2 [$ns_ create-connection TCP/Sack1 $node_(s2) TCPSink/Sack1 $node_(s4) 1]
  301.     $tcp2 set window_ 100 
  302.     set ftp1 [$tcp1 attach-app FTP]
  303.     set ftp2 [$tcp2 attach-app FTP]
  304.     set tcp3 [$ns_ create-connection TCP/Sack1 $node_(s3) TCPSink/Sack1 $node_(s1) 2]
  305.     $tcp3 set window_ 100 
  306.     set tcp4 [$ns_ create-connection TCP/Sack1 $node_(s4) TCPSink/Sack1 $node_(s2) 3]
  307.     $tcp4 set window_ 100 
  308.     set ftp3 [$tcp3 attach-app FTP]
  309.     set telnet1 [$tcp4 attach-app Telnet] ; $telnet1 set interval_ 0
  310.     $self enable_tracequeue $ns_
  311.     $ns_ at 0.0 "$ftp1 start"
  312.     $ns_ at 2.0 "$ftp2 start"
  313.     $ns_ at 3.5 "$ftp3 start"
  314.     $ns_ at 1.0 "$telnet1 start"
  315.     $self tcpDump $tcp1 5.0
  316.     # trace only the bottleneck link
  317.     #$self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  318.     $ns_ at $stoptime "$self cleanupAll $testName_"
  319.     $ns_ run
  320. }
  321. Class Test/rem_twowayecn -superclass TestSuite
  322. Test/rem_twowayecn instproc init {} {
  323.     $self instvar net_ test_
  324.     set net_ net3
  325.     set test_ rem_twowayecn
  326.     $self next pktTraceFile
  327. }
  328. Test/rem_twowayecn instproc run {} {
  329.     $self instvar ns_ node_ testName_
  330.     $self setTopo
  331.     set stoptime 10.0
  332.     set remq [[$ns_ link $node_(r1) $node_(r2)] queue]
  333.     $remq set markpkts_ true 
  334.     $remq set phi_ 5 
  335.     set tcp1 [$ns_ create-connection TCP/Sack1 $node_(s1) TCPSink/Sack1 $node_(s3) 0]
  336.     $tcp1 set window_ 100
  337.     $tcp1 set ecn_ 1
  338.     set tcp2 [$ns_ create-connection TCP/Sack1 $node_(s2) TCPSink/Sack1 $node_(s4) 1]
  339.     $tcp2 set window_ 100
  340.     $tcp2 set ecn_ 1
  341.     set ftp1 [$tcp1 attach-app FTP]
  342.     set ftp2 [$tcp2 attach-app FTP]
  343.     set tcp3 [$ns_ create-connection TCP/Sack1 $node_(s3) TCPSink/Sack1 $node_(s1) 2]
  344.     $tcp3 set window_ 100
  345.     $tcp3 set ecn_ 1
  346.     set tcp4 [$ns_ create-connection TCP/Sack1 $node_(s4) TCPSink/Sack1 $node_(s2) 3]
  347.     $tcp4 set window_ 100
  348.     $tcp4 set ecn_ 1
  349.     set ftp3 [$tcp3 attach-app FTP]
  350.     set telnet1 [$tcp4 attach-app Telnet] ; $telnet1 set interval_ 0
  351.     $self enable_tracequeue $ns_
  352.     $ns_ at 0.0 "$ftp1 start"
  353.     $ns_ at 2.0 "$ftp2 start"
  354.     $ns_ at 3.5 "$ftp3 start"
  355.     $ns_ at 1.0 "$telnet1 start"
  356.     $self tcpDump $tcp1 5.0
  357.     # trace only the bottleneck link
  358.     #$self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  359.     $ns_ at $stoptime "$self cleanupAll $testName_"
  360.     $ns_ run
  361. }
  362. #
  363. #######################################################################
  364. TestSuite instproc create_flowstats {} {
  365. global flowfile flowchan
  366. $self instvar ns_ node_ r1fm_
  367. set r1fm_ [$ns_ makeflowmon Fid]
  368. set flowchan [open $flowfile w]
  369. $r1fm_ attach $flowchan
  370. $ns_ attach-fmon [$ns_ link $node_(r1) $node_(r2)] $r1fm_ 1
  371. }
  372. #
  373. # awk code used to produce:
  374. #       x axis: # arrivals for this flow+category / # total arrivals [bytes]
  375. #       y axis: # drops for this flow+category / # drops this category [pkts]
  376. # (verified compatible for ns2 - kfall, 10/30/97)
  377. TestSuite instproc unforcedmakeawk { } {
  378.         set awkCode {
  379.             {
  380.                 if ($2 != prev) {
  381.                         print " "; print ""flow " $2;
  382. if ($13 > 0 && $14 > 0) {
  383.     print 100.0 * $9/$13, 100.0 * $10 / $14
  384. }
  385. prev = $2;
  386.                 } else if ($13 > 0 && $14 > 0) {
  387.                         print 100.0 * $9 / $13, 100.0 * $10 / $14
  388. }
  389.             }
  390.         }
  391.         return $awkCode
  392. }
  393. #
  394. # awk code used to produce:
  395. #       x axis: # arrivals for this flow+category / # total arrivals [bytes]
  396. #       y axis: # drops for this flow+category / # drops this category [bytes]
  397. # (modified for compatibility with ns2 flowmon - kfall, 10/30/97)
  398. TestSuite instproc forcedmakeawk { } {
  399.         set awkCode {
  400.             BEGIN { print ""flow 0" }
  401.             {
  402.                 if ($2 != prev) {
  403.                         print " "; print ""flow " $2;
  404. if ($13 > 0 && ($17 - $15) > 0) {
  405. print 100.0 * $9/$13, 100.0 * ($19 - $11) / ($17 - $15);
  406. }
  407. prev = $2;
  408.                 } else if ($13 > 0 && ($17 - $15) > 0) {
  409.                         print 100.0 * $9 / $13, 100.0 * ($19 - $11) / ($17 - $15)
  410. }
  411.             }
  412.         }
  413.         return $awkCode
  414. }
  415. #
  416. # awk code used to produce:
  417. #      x axis: # arrivals for this flow+category / # total arrivals [bytes]
  418. #      y axis: # drops for this flow / # drops [pkts and bytes combined]
  419. TestSuite instproc allmakeawk { } {
  420.     set awkCode {
  421.         BEGIN {prev=-1; tot_bytes=0; tot_packets=0; forced_total=0; unforced_total=0}
  422.         {
  423.             if ($5 != prev) {
  424.                 print " "; print ""flow ",$5;
  425.                 prev = $5
  426.             }
  427.             tot_bytes = $19-$11;
  428.             forced_total= $16-$14;
  429.             tot_packets = $10;
  430.             tot_arrivals = $9;
  431.             unforced_total = $14;
  432.             if (unforced_total + forced_total > 0) {
  433.                 if ($14 > 0) {
  434.                     frac_packets = tot_packets/$14;
  435.                 }
  436.                 else { frac_packets = 0;}
  437.                 if ($17-$15 > 0) {
  438.                     frac_bytes = tot_bytes/($17-$15);
  439.                 }
  440.                 else {frac_bytes = 0;} 
  441.                 if ($13 > 0) {
  442.                     frac_arrivals = tot_arrivals/$13;
  443.                 }
  444.                 else {frac_arrivals = 0;}
  445.                 if (frac_packets + frac_bytes > 0) {
  446.                     unforced_total_part = frac_packets * unforced_total / ( unforced_total + forced_total)
  447.                     forced_total_part = frac_bytes * forced_total / ( unforced_total + forced_total)
  448.                     print 100.0 * frac_arrivals, 100.0 * ( unforced_total_part +forced_total_part)
  449.                 }
  450.             }
  451.         }
  452.     }
  453.     return $awkCode
  454. }
  455. TestSuite instproc create_flow_graph { graphtitle graphfile } {
  456.         global flowfile quiet
  457. $self instvar awkprocedure_
  458.         if {$quiet == "false"} {
  459. puts "awkprocedure: $awkprocedure_"
  460. }
  461.         set tmpfile1 /tmp/fg1[pid]
  462.         set tmpfile2 /tmp/fg2[pid]
  463.         exec rm -f $graphfile
  464.         set outdesc [open $graphfile w]
  465.         #
  466.         # this next part is xgraph specific
  467.         #
  468.         puts $outdesc "TitleText: $graphtitle"
  469.         puts $outdesc "Device: Postscript"
  470.         exec rm -f $tmpfile1 $tmpfile2
  471. if {$quiet == "false"} {
  472.          puts "writing flow xgraph data to $graphfile..."
  473. }
  474.         exec sort -n -k2 -o $flowfile $flowfile
  475.         exec awk [$self $awkprocedure_] $flowfile >@ $outdesc
  476.         close $outdesc
  477. }
  478. TestSuite instproc finish_flows testname {
  479. global flowgraphfile flowfile flowchan quiet
  480. $self instvar r1fm_
  481. $r1fm_ dump
  482. close $flowchan
  483. $self create_flow_graph $testname $flowgraphfile
  484. if {$quiet == "false"} {
  485. puts "running xgraph..."
  486. }
  487. exec cp $flowgraphfile temp.rands
  488. if {$quiet == "false"} {
  489. exec xgraph -bb -tk -nl -m -lx 0,100 -ly 0,100 -x "% of data bytes" -y "% of discards" $flowgraphfile &
  490. }
  491. exit 0
  492. }
  493. TestSuite instproc new_tcp { startTime source dest window fid verbose size } {
  494. $self instvar ns_
  495. set tcp [$ns_ create-connection TCP/Sack1 $source TCPSink/Sack1 $dest $fid]
  496. $tcp set window_ $window
  497. if {$size > 0}  {$tcp set packetSize_ $size }
  498. set ftp [$tcp attach-app FTP]
  499. $ns_ at $startTime "$ftp start"
  500. if {$verbose == "1"} {
  501.   $self tcpDumpAll $tcp 20.0 $fid 
  502. }
  503. }
  504. TestSuite instproc new_cbr { startTime source dest pktSize interval fid } {
  505. $self instvar ns_
  506.     set s_agent [new Agent/UDP]
  507.     set d_agent [new Agent/LossMonitor]
  508.     $s_agent set fid_ $fid 
  509.     $d_agent set fid_ $fid 
  510.     set cbr [new Application/Traffic/CBR]
  511.     $cbr attach-agent $s_agent
  512.     $ns_ attach-agent $source $s_agent
  513.     $ns_ attach-agent $dest $d_agent
  514.     $ns_ connect $s_agent $d_agent
  515.     if {$pktSize > 0} {
  516. $cbr set packetSize_ $pktSize
  517.     }
  518.     $cbr set rate_ [expr 8 * $pktSize / $interval]
  519.     $ns_ at $startTime "$cbr start"
  520. }
  521. TestSuite instproc dumpflows interval {
  522.     $self instvar dumpflows_inst_ ns_ r1fm_
  523.     $self instvar awkprocedure_ dump_pthresh_
  524.     global flowchan
  525.     if ![info exists dumpflows_inst_] {
  526.         set dumpflows_inst_ 1
  527.         $ns_ at 0.0 "$self dumpflows $interval"
  528.         return  
  529.     }
  530.     if { $awkprocedure_ == "unforcedmakeawk" } {
  531. set pcnt [$r1fm_ set epdrops_]
  532.     } elseif { $awkprocedure_ == "forcedmakeawk" } {
  533. set pcnt [expr [$r1fm_ set pdrops_] - [$r1fm_ set epdrops_]]
  534.     } elseif { $awkprocedure_ == "allmakeawk" } {
  535. set pcnt [$r1fm_ set pdrops_]
  536.     } else {
  537. puts stderr "unknown handling of flow dumps!"
  538. exit 1
  539.     }
  540.     if { $pcnt >= $dump_pthresh_ } {
  541.     $r1fm_ dump
  542.     flush $flowchan
  543.     foreach f [$r1fm_ flows] {
  544. $f reset
  545.     }
  546.     $r1fm_ reset
  547.     set interval 2.0
  548.     } else {
  549.     set interval 1.0
  550.     }
  551.     $ns_ at [expr [$ns_ now] + $interval] "$self dumpflows $interval"
  552. }   
  553. TestSuite runTest