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

通讯编程

开发平台:

Visual C++

  1. #
  2. # Copyright (c) 1995 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. # @(#) $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-simple.tcl,v 1.44 2006/01/25 22:02:05 sallyfloyd Exp $
  34. #
  35. #
  36. # This test suite reproduces most of the tests from the following note:
  37. # Floyd, S., Simulator Tests. July 1995.  
  38. # URL ftp://ftp.ee.lbl.gov/papers/simtests.ps.Z.
  39. #
  40. # To run all tests:  test-all
  41. #
  42. # To run individual tests:
  43. # ns test-suite.tcl tahoe1
  44. # ns test-suite.tcl tahoe2
  45. # ...
  46. #
  47. # To view a list of available tests to run with this script:
  48. # ns test-suite.tcl
  49. #
  50. # Much more extensive test scripts are available in tcl/test
  51. # This script is a simplified version of tcl/test/test-suite-routed.tcl
  52. # ns-random 0
  53. #source misc_simple.tcl
  54. #source support.tcl
  55. remove-all-packet-headers       ; # removes all except common
  56. add-packet-header Flags IP TCP TFRC TFRC_ACK ; # hdrs reqd for TCP
  57. # FOR UPDATING GLOBAL DEFAULTS:
  58. Agent/TCP set rtxcur_init_ 6.0 ;      # Default changed on 2006/01/21
  59. Agent/TCP set updated_rttvar_ false ;  # Variable added on 2006/1/21
  60. Agent/TFRC set ss_changes_ 1 ;  # Added on 10/21/2004
  61. Agent/TFRC set slow_increase_ 1 ;  # Added on 10/20/2004
  62. Agent/TFRC set rate_init_ 2 ;          # Added on 10/20/2004
  63. Agent/TFRC set rate_init_option_ 2 ;    # Added on 10/20/2004
  64. Agent/TFRC set useHeaders_ false ;     # Added on 6/24/2004, default of true
  65. Agent/TFRC set headersize_ 40 ;         # Changed on 6/24/2004 to 32.
  66. Agent/TCP set minrto_ 1
  67. # default changed on 10/14/2004.
  68. Queue/RED set bytes_ false              
  69. # default changed on 10/11/2004.
  70. Queue/RED set queue_in_bytes_ false
  71. # default changed on 10/11/2004.
  72. Queue/RED set q_weight_ 0.002
  73. Queue/RED set thresh_ 5 
  74. Queue/RED set maxthresh_ 15
  75. # The RED parameter defaults are being changed for automatic configuration.
  76. Agent/TCP set useHeaders_ false
  77. # The default is being changed to useHeaders_ true.
  78. Agent/TCP set singledup_ 0
  79. # The default is being changed to 1
  80. set tcpTick_ 0.1
  81. Agent/TCP set tcpTick_ $tcpTick_ 
  82. # The default for tcpTick_ is being changed to reflect a changing reality.
  83. Agent/TCP set rfc2988_ false
  84. # The default for rfc2988_ is being changed to true.
  85. Class TestSuite
  86. TestSuite instproc init {} {
  87. $self instvar ns_ net_ defNet_ test_ topo_ node_ testName_
  88. set ns_ [new Simulator]
  89. # trace-all is only used in more extensive test suites
  90. # $ns_ trace-all [open all.tr w]
  91. if {$net_ == ""} {
  92. set net_ $defNet_
  93. }
  94. if ![Topology/$defNet_ info subclass Topology/$net_] {
  95. global argv0
  96. puts "$argv0: cannot run test $test_ over topology $net_"
  97. exit 1
  98. }
  99. set topo_ [new Topology/$net_ $ns_]
  100. foreach i [$topo_ array names node_] {
  101. # This would be cool, but lets try to be compatible
  102. # with test-suite.tcl as far as possible.
  103. #
  104. # $self instvar $i
  105. # set $i [$topo_ node? $i]
  106. #
  107. set node_($i) [$topo_ node? $i]
  108. }
  109. if {$net_ == $defNet_} {
  110. set testName_ "$test_"
  111. } else {
  112. set testName_ "$test_:$net_"
  113. }
  114. # XXX
  115. if [info exists node_(k1)] {
  116. set blink [$ns_ link $node_(r1) $node_(k1)]
  117. } else {
  118. set blink [$ns_ link $node_(r1) $node_(r2)] 
  119. }
  120. $blink trace-dynamics $ns_ stdout
  121. }
  122. TestSuite instproc finish file {
  123. global env quiet PERL
  124. #
  125. # we don't bother checking for the link we're interested in
  126. # since we know only such events are in our trace file
  127. #
  128. set perlCode {
  129. sub BEGIN { $c = 0; @p = @a = @d = @lu = @ld = (); }
  130. /^[+-] / && do {
  131. if ($F[4] eq 'tcp' || $F[4] eq 'tcpFriend') {
  132.   push(@p, $F[1], ' ',
  133. $F[7] + ($F[10] % 90) * 0.01, "n");
  134. } elsif ($F[4] eq 'ack' || $F[4] eq 'tcpFriendCtl') {
  135.   push(@a, $F[1], ' ',
  136. $F[7] + ($F[10] % 90) * 0.01, "n");
  137. }
  138. $c = $F[7] if ($c < $F[7]);
  139. next;
  140. };
  141. /^d / && do {
  142. push(@d, $F[1], ' ',
  143. $F[7] + ($F[10] % 90) * 0.01, "n");
  144. next;
  145. };
  146. /link-down/ && push(@ld, $F[1]);
  147. /link-up/ && push(@lu, $F[1]);
  148. sub END {
  149. print ""packetsn", @p, "n";
  150. # insert dummy data sets
  151. # so we get X's for marks in data-set 4
  152. print ""skip-1n0 1nn"skip-2n0 1nn";
  153. #
  154. # Repeat the first line twice in the drops file because
  155. # often we have only one drop and xgraph won't print
  156. # marks for data sets with only one point.
  157. #
  158. print "n", '"drops', "n", @d[0..3], @d;
  159. # To plot acks, uncomment the following line
  160. # print "n", '"acks', "n", @a;
  161. $c++;
  162. foreach $i (@ld) {
  163. print "n"link-downn$i 0n$i $cn";
  164. }
  165. foreach $i (@lu) {
  166. print "n"link-upn$i 0n$i $cn";
  167. }
  168. }
  169. }
  170. set f [open temp.rands w]
  171. puts $f "TitleText: $file"
  172. puts $f "Device: Postscript"
  173.     exec $PERL -ane $perlCode out.tr >@ $f
  174. close $f
  175. if {$quiet == "false"} {
  176.   if {[info exists env(DISPLAY)] && ![info exists env(NOXGRAPH)]} {
  177.     exec xgraph -display $env(DISPLAY) -bb -tk -nl -m -x time -y packet temp.rands &
  178.   } else {
  179.     puts stderr "output trace is in temp.rands"
  180.   }
  181. }
  182. exit 0
  183. }
  184. #
  185. # Arrange for tcp source stats to be dumped for $tcpSrc every
  186. # $interval seconds of simulation time
  187. #
  188. TestSuite instproc tcpDump { tcpSrc interval } {
  189. global quiet
  190. $self instvar dump_inst_ ns_
  191. if ![info exists dump_inst_($tcpSrc)] {
  192. set dump_inst_($tcpSrc) 1
  193. $ns_ at 0.0 "$self tcpDump $tcpSrc $interval"
  194. return
  195. }
  196. $ns_ at [expr [$ns_ now] + $interval] "$self tcpDump $tcpSrc $interval"
  197. set report [$ns_ now]/cwnd=[format "%.4f" [$tcpSrc set cwnd_]]/ssthresh=[$tcpSrc set ssthresh_]/ack=[$tcpSrc set ack_]
  198. if {$quiet == "false"} {
  199. puts $report
  200. }
  201. }
  202. TestSuite instproc tcpDumpAll { tcpSrc interval label } {
  203. $self instvar dump_inst_ ns_
  204. if ![info exists dump_inst_($tcpSrc)] {
  205. set dump_inst_($tcpSrc) 1
  206. puts $label/window=[$tcpSrc set window_]/packetSize=[$tcpSrc set packetSize_]/bugFix=[$tcpSrc set bugFix_]
  207. $ns_ at 0.0 "$self tcpDumpAll $tcpSrc $interval $label"
  208. return
  209. }
  210. $ns_ at [expr [$ns_ now] + $interval] "$self tcpDumpAll $tcpSrc $interval $label"
  211. puts $label/time=[$ns_ now]/cwnd=[format "%.4f" [$tcpSrc set cwnd_]]/ssthresh=[$tcpSrc set ssthresh_]/ack=[$tcpSrc set ack_]/rtt=[$tcpSrc set rtt_]
  212. }
  213. TestSuite instproc openTrace { stopTime testName } {
  214. $self instvar ns_
  215. exec rm -f out.tr temp.rands
  216. set traceFile [open out.tr w]
  217. puts $traceFile "v testName $testName"
  218. $ns_ at $stopTime 
  219. "close $traceFile ; $self finish $testName"
  220. return $traceFile
  221. }
  222. TestSuite instproc traceQueues { node traceFile } {
  223. $self instvar ns_
  224. foreach nbr [$node neighbors] {
  225. $ns_ trace-queue $node $nbr $traceFile
  226. [$ns_ link $node $nbr] trace-dynamics $ns_ $traceFile
  227. }
  228. }
  229. proc usage {} {
  230. global argv0
  231. puts stderr "usage: ns $argv0 <tests> [<topologies>]"
  232. puts stderr "Valid tests are:t[get-subclasses TestSuite Test/]"
  233. puts stderr "Valid Topologies are:t[get-subclasses SkelTopology Topology/]"
  234. exit 1
  235. }
  236. proc isProc? {cls prc} {
  237. if [catch "Object info subclass $cls/$prc" r] {
  238. global argv0
  239. puts stderr "$argv0: no such $cls: $prc"
  240. usage
  241. }
  242. }
  243. proc get-subclasses {cls pfx} {
  244. set ret ""
  245. set l [string length $pfx]
  246. set c $cls
  247. while {[llength $c] > 0} {
  248. set t [lindex $c 0]
  249. set c [lrange $c 1 end]
  250. if [string match ${pfx}* $t] {
  251. lappend ret [string range $t $l end]
  252. }
  253. eval lappend c [$t info subclass]
  254. }
  255. set ret
  256. }
  257. TestSuite proc runTest {} {
  258. global argc argv quiet
  259. set quiet false
  260. switch $argc {
  261. 1 {
  262. set test $argv
  263. isProc? Test $test
  264. set topo ""
  265. }
  266. 2 {
  267. set test [lindex $argv 0]
  268. isProc? Test $test
  269. set topo [lindex $argv 1]
  270. if {$topo == "QUIET"} {
  271. set quiet true
  272. set topo ""
  273. } else {
  274. isProc? Topology $topo
  275. }
  276. }
  277. 3 {
  278. set test [lindex $argv 0]
  279. isProc? Test $test
  280. set topo [lindex $argv 1]
  281. isProc? Topology $topo
  282. set extra [lindex $argv 2]
  283. if {$extra == "QUIET"} {
  284. set quiet true
  285. }
  286. }
  287. default {
  288. usage
  289. }
  290. }
  291. set t [new Test/$test $topo]
  292. $t run
  293. }
  294. # Skeleton topology base class
  295. Class SkelTopology
  296. SkelTopology instproc init {} {
  297.     $self next
  298. }
  299. SkelTopology instproc node? n {
  300.     $self instvar node_
  301.     if [info exists node_($n)] {
  302. set ret $node_($n)
  303.     } else {
  304. set ret ""
  305.     }
  306.     set ret
  307. }
  308. SkelTopology instproc add-fallback-links {ns nodelist bw delay qtype args} {
  309.    $self instvar node_
  310.     set n1 [lindex $nodelist 0]
  311.     foreach n2 [lrange $nodelist 1 end] {
  312. if ![info exists node_($n2)] {
  313.     set node_($n2) [$ns node]
  314. }
  315. $ns duplex-link $node_($n1) $node_($n2) $bw $delay $qtype
  316. foreach opt $args {
  317.     set cmd [lindex $opt 0]
  318.     set val [lindex $opt 1]
  319.     if {[llength $opt] > 2} {
  320. set x1 [lindex $opt 2]
  321. set x2 [lindex $opt 3]
  322.     } else {
  323. set x1 $n1
  324. set x2 $n2
  325.     }
  326.     $ns $cmd $node_($x1) $node_($x2) $val
  327.     $ns $cmd $node_($x2) $node_($x1) $val
  328. }
  329. set n1 $n2
  330.     }
  331. }
  332. Class NodeTopology/4nodes -superclass SkelTopology
  333. # Create a simple four node topology:
  334. #
  335. #    s1
  336. #       
  337. #  8Mb,5ms    0.8Mb,100ms
  338. #         r1 --------- k1
  339. #  8Mb,5ms /
  340. #      /
  341. #    s2
  342. NodeTopology/4nodes instproc init ns {
  343.     $self next
  344.     $self instvar node_
  345.     set node_(s1) [$ns node]
  346.     set node_(s2) [$ns node]
  347.     set node_(r1) [$ns node]
  348.     set node_(k1) [$ns node]
  349. }
  350. #
  351. # Links1 uses 8Mb, 5ms feeders, and a 800Kb 100ms bottleneck.
  352. # Queue-limit on bottleneck is 6 packets.
  353. #
  354. Class Topology/net0 -superclass NodeTopology/4nodes
  355. Topology/net0 instproc init ns {
  356.     $self next $ns
  357.     $self instvar node_
  358.     $ns duplex-link $node_(s1) $node_(r1) 8Mb 5ms DropTail
  359.     $ns duplex-link $node_(s2) $node_(r1) 8Mb 5ms DropTail
  360.     $ns duplex-link $node_(r1) $node_(k1) 800Kb 100ms DropTail
  361.     $ns queue-limit $node_(r1) $node_(k1) 6
  362.     $ns queue-limit $node_(k1) $node_(r1) 6
  363.     if {[$class info instprocs config] != ""} {
  364. $self config $ns
  365.     }
  366. }
  367. # The net0a topology with RED at the bottleneck should be functionally
  368. # equivalent to the net0 topology above.
  369. # The queue-limit on bottleneck is 5 instead of 6 packets, to account
  370. #   for a difference in measuring the queue between RED and DT.
  371. # However, there are stilll performance differences between net0 and net0a.
  372. Class Topology/net0a -superclass NodeTopology/4nodes
  373. Topology/net0a instproc init ns {
  374.     $self next $ns
  375.     $self instvar node_
  376.     $ns duplex-link $node_(s1) $node_(r1) 8Mb 5ms DropTail
  377.     $ns duplex-link $node_(s2) $node_(r1) 8Mb 5ms DropTail
  378.     $ns duplex-link $node_(r1) $node_(k1) 800Kb 100ms RED
  379.     $ns queue-limit $node_(r1) $node_(k1) 5
  380.     $ns queue-limit $node_(k1) $node_(r1) 5
  381.     Queue/RED set thresh_ 1000
  382.     Queue/RED set maxthresh_ 1000
  383.     if {[$class info instprocs config] != ""} {
  384. $self config $ns
  385.     }
  386. }
  387. #
  388. # Links1 uses 10Mb, 5ms feeders, and a 1.5Mb 100ms bottleneck.
  389. # Queue-limit on bottleneck is 23 packets.
  390. #
  391. Class Topology/net1 -superclass NodeTopology/4nodes
  392. Topology/net1 instproc init ns {
  393.     $self next $ns
  394.     $self instvar node_
  395.     $ns duplex-link $node_(s1) $node_(r1) 10Mb 5ms DropTail
  396.     $ns duplex-link $node_(s2) $node_(r1) 10Mb 5ms DropTail
  397.     $ns duplex-link $node_(r1) $node_(k1) 1.5Mb 100ms DropTail
  398.     $ns queue-limit $node_(r1) $node_(k1) 23
  399.     $ns queue-limit $node_(k1) $node_(r1) 23
  400.     if {[$class info instprocs config] != ""} {
  401. $self config $ns
  402.     }
  403. }
  404. Class NodeTopology/6nodes -superclass SkelTopology
  405. #
  406. # Create a simple six node topology:
  407. #
  408. #        s1                 s3
  409. #                          /
  410. # 10Mb,2ms   1.5Mb,20ms   / 10Mb,4ms
  411. #           r1 --------- r2
  412. # 10Mb,3ms /                10Mb,5ms
  413. #         /                 
  414. #        s2                 s4 
  415. #
  416. NodeTopology/6nodes instproc init ns {
  417.     $self next
  418.     $self instvar node_
  419.     set node_(s1) [$ns node]
  420.     set node_(s2) [$ns node]
  421.     set node_(r1) [$ns node]
  422.     set node_(r2) [$ns node]
  423.     set node_(s3) [$ns node]
  424.     set node_(s4) [$ns node]
  425. }
  426. Class Topology/net2 -superclass NodeTopology/6nodes
  427. Topology/net2 instproc init ns {
  428.     $self next $ns
  429.     $self instvar node_
  430.     Queue/RED set drop_rand_ true
  431.     $ns duplex-link $node_(s1) $node_(r1) 10Mb 2ms DropTail
  432.     $ns duplex-link $node_(s2) $node_(r1) 10Mb 3ms DropTail
  433.     $ns duplex-link $node_(r1) $node_(r2) 1.5Mb 20ms RED
  434.     $ns queue-limit $node_(r1) $node_(r2) 25
  435.     $ns queue-limit $node_(r2) $node_(r1) 25
  436.     $ns duplex-link $node_(s3) $node_(r2) 10Mb 4ms DropTail
  437.     $ns duplex-link $node_(s4) $node_(r2) 10Mb 5ms DropTail
  438.     if {[$class info instprocs config] != ""} {
  439. $self config $ns
  440.     }
  441. }
  442. Class Topology/net3 -superclass NodeTopology/6nodes
  443. Topology/net3 instproc init ns {
  444.     $self next $ns
  445.     $self instvar node_
  446.     Queue/RED set drop_rand_ true
  447.     $ns duplex-link $node_(s1) $node_(r1) 100Mb 1ms DropTail
  448.     $ns duplex-link $node_(s2) $node_(r1) 100Mb 30ms DropTail
  449.     $ns duplex-link $node_(r1) $node_(r2) 10Mb 10ms RED
  450.     $ns queue-limit $node_(r1) $node_(r2) 25
  451.     $ns queue-limit $node_(r2) $node_(r1) 25
  452.     $ns duplex-link $node_(s3) $node_(r2) 100Mb 1ms DropTail
  453.     $ns duplex-link $node_(s4) $node_(r2) 100Mb 5ms DropTail
  454.     if {[$class info instprocs config] != ""} {
  455. $self config $ns
  456.     }
  457. }
  458. # Definition of test-suite tests
  459. Class Test/tahoe1 -superclass TestSuite
  460. Test/tahoe1 instproc init topo {
  461. $self instvar net_ defNet_ test_ guide_
  462. set net_ $topo
  463. set defNet_ net0
  464. set test_ tahoe
  465. set guide_ 
  466. "Tahoe TCP with multiple packets dropped from a window of data."
  467. Queue/DropTail set summarystats_ true
  468. $self next
  469. }
  470. Test/tahoe1 instproc run {} {
  471. global quiet
  472. $self instvar ns_ node_ testName_ guide_
  473. puts "Guide: $guide_"
  474. # Set up TCP connection
  475. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  476. $tcp1 set window_ 50
  477. # Set up FTP source
  478. set ftp1 [$tcp1 attach-app FTP]
  479. $ns_ at 0.0 "$ftp1 start"
  480. $self tcpDump $tcp1 1.0
  481. set link1 [$ns_ link $node_(r1) $node_(k1)]
  482. set queue1 [$link1 queue]
  483. $ns_ at 5.0 "$queue1 printstats"
  484. # Trace only the bottleneck link
  485. #
  486. # Actually, we now trace all activity at the node around the
  487. # bottleneck link.  This allows us to track acks, as well
  488. # packets taking any alternate paths around the bottleneck
  489. # link.
  490. #
  491. $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_]
  492. $ns_ run
  493. }
  494. Class Test/tahoe1Bytes -superclass TestSuite
  495. Test/tahoe1Bytes instproc init topo {
  496. $self instvar net_ defNet_ test_ guide_
  497. set net_ $topo
  498. set defNet_ net0
  499. set test_ tahoe1Bytes
  500. set guide_ "DropTail queue in bytes instead of packets."
  501. Queue/DropTail set queue_in_bytes_ true
  502. Queue/DropTail set mean_pktsize_ 1000
  503. Queue/DropTail set summarystats_ true
  504. Test/tahoe1Bytes instproc run {} [Test/tahoe1 info instbody run ]
  505. $self next
  506. }
  507. # Tahoe1 with RED
  508. Class Test/tahoe1RED -superclass TestSuite
  509. Test/tahoe1RED instproc init topo {
  510. $self instvar net_ defNet_ test_ guide_
  511. set net_ $topo
  512. set defNet_ net0a
  513. set test_ tahoe1RED
  514. set guide_
  515. "RED queue, configured for 5 packets instead of DropTail's 6 packets."
  516. Queue/RED set summarystats_ true
  517. Test/tahoe1RED instproc run {} [Test/tahoe1 info instbody run ]
  518. $self next
  519. }
  520. # Tahoe1 with RED
  521. Class Test/tahoe1REDbytes -superclass TestSuite
  522. Test/tahoe1REDbytes instproc init topo {
  523. $self instvar net_ defNet_ test_ guide_
  524. set net_ $topo
  525. set defNet_ net0a
  526. set test_ tahoe1REDbytes
  527. set guide_      "RED queue in bytes."
  528. Queue/RED set queue_in_bytes_ true
  529. Queue/RED set mean_pktsize_ 1000
  530. Queue/RED set summarystats_ true
  531. Test/tahoe1REDbytes instproc run {} [Test/tahoe1 info instbody run ]
  532. $self next
  533. }
  534. Class Test/tahoe2 -superclass TestSuite
  535. Test/tahoe2 instproc init topo {
  536. $self instvar net_ defNet_ test_ guide_
  537. set net_ $topo
  538. set defNet_ net0
  539. set test_ tahoe2
  540. set guide_ "Tahoe TCP with one packet dropped."
  541. $self next
  542. }
  543. Test/tahoe2 instproc run {} {
  544. global quiet
  545. $self instvar ns_ node_ testName_ guide_
  546. puts "Guide: $guide_"
  547. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  548. $tcp1 set window_ 14
  549. set ftp1 [$tcp1 attach-app FTP]
  550. $ns_ at 1.0 "$ftp1 start"
  551. $self tcpDump $tcp1 1.0
  552. # Trace only the bottleneck link
  553. $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_]
  554. $ns_ run
  555. }
  556. Class Test/tahoe3 -superclass TestSuite
  557. Test/tahoe3 instproc init topo {
  558. $self instvar net_ defNet_ test_ guide_
  559. set net_ $topo
  560. set defNet_ net0
  561. set test_ tahoe3
  562. set guide_      
  563. "Tahoe TCP, two packets dropped from a congestion window of 5 packets."
  564. $self next
  565. }
  566. Test/tahoe3 instproc run {} {
  567. global quiet
  568. $self instvar ns_ node_ testName_ guide_
  569. puts "Guide: $guide_"
  570. $ns_ queue-limit $node_(r1) $node_(k1) 8   
  571. $ns_ queue-limit $node_(k1) $node_(r1) 8   
  572. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  573. $tcp1 set window_ 100
  574. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  575. $tcp2 set window_ 16
  576. set ftp1 [$tcp1 attach-app FTP]
  577. set ftp2 [$tcp2 attach-app FTP]
  578. $ns_ at 1.0 "$ftp1 start"
  579. $ns_ at 0.5 "$ftp2 start"
  580. $self tcpDump $tcp1 1.0
  581. # Trace only the bottleneck link
  582. $self traceQueues $node_(r1) [$self openTrace 8.0 $testName_]
  583. $ns_ run
  584. }
  585. # Tahoe3 with RED.
  586. Class Test/tahoe3RED -superclass TestSuite
  587. Test/tahoe3RED instproc init topo {
  588. $self instvar net_ defNet_ test_ guide_
  589. set net_ $topo
  590. set defNet_ net0a
  591. set test_ tahoe3RED
  592. set guide_      
  593. "Tahoe TCP, two packets dropped, RED queue configured for 5 packets."
  594. Test/tahoe3RED instproc run {} [Test/tahoe3 info instbody run ]
  595. $self next
  596. }
  597. Class Test/tahoe4 -superclass TestSuite
  598. Test/tahoe4 instproc init topo {
  599. $self instvar net_ defNet_ test_ guide_
  600. set net_ $topo
  601. set defNet_ net0
  602. set test_ tahoe4
  603. set guide_
  604. "Tahoe TCP, two connections with different round-trip times."
  605. $self next
  606. }
  607. Test/tahoe4 instproc run {} {
  608. global quiet
  609. $self instvar ns_ node_ testName_ guide_
  610. puts "Guide: $guide_"
  611. $ns_ delay $node_(s2) $node_(r1) 200ms
  612. $ns_ delay $node_(r1) $node_(s2) 200ms
  613. $ns_ queue-limit $node_(r1) $node_(k1) 11
  614. $ns_ queue-limit $node_(k1) $node_(r1) 11  
  615. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  616. $tcp1 set window_ 30
  617. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  618. $tcp2 set window_ 30
  619. set ftp1 [$tcp1 attach-app FTP]
  620. set ftp2 [$tcp2 attach-app FTP]
  621. $ns_ at 0.0 "$ftp1 start"
  622. $ns_ at 0.0 "$ftp2 start"
  623. $self tcpDump $tcp1 5.0
  624. # Trace only the bottleneck link
  625. $self traceQueues $node_(r1) [$self openTrace 25.0 $testName_]
  626. $ns_ run
  627. }
  628. Class Test/no_bug -superclass TestSuite
  629. Test/no_bug instproc init topo {
  630. $self instvar net_ defNet_ test_ guide_
  631. set net_ $topo
  632. set defNet_ net1
  633. set test_ no_bug
  634. set guide_      "Tahoe TCP with TCP/bugFix_ set to true."
  635. $self next
  636. }
  637. Test/no_bug instproc run {} {
  638. global quiet
  639. $self instvar ns_ node_ testName_ guide_
  640. puts "Guide: $guide_"
  641. $ns_ delay $node_(s1) $node_(r1) 3ms
  642. $ns_ delay $node_(r1) $node_(s1) 3ms
  643. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  644. $tcp1 set window_ 50
  645. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  646. $tcp2 set window_ 50
  647. set ftp1 [$tcp1 attach-app FTP]
  648. set ftp2 [$tcp2 attach-app FTP]
  649. $ns_ at 1.0 "$ftp1 start"
  650. $ns_ at 1.75 "$ftp2 produce 99"
  651. $self tcpDump $tcp1 1.0
  652. # Trace only the bottleneck link
  653. $self traceQueues $node_(r1) [$self openTrace 6.0 $testName_]
  654. $ns_ run
  655. }
  656. Class Test/bug -superclass TestSuite
  657. Test/bug instproc init topo {
  658. $self instvar net_ defNet_ test_ guide_
  659. set net_ $topo
  660. set defNet_ net1
  661. set test_ bug
  662. set guide_      "Tahoe TCP with TCP/bugFix_ set to false."
  663. $self next
  664. }
  665. Test/bug instproc run {} {
  666. global quiet
  667. $self instvar ns_ node_ testName_ guide_
  668. puts "Guide: $guide_"
  669. $ns_ delay $node_(s1) $node_(r1) 3ms
  670. $ns_ delay $node_(r1) $node_(s1) 3ms
  671. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  672. $tcp1 set window_ 50
  673. $tcp1 set bugFix_ false
  674. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  675. $tcp2 set window_ 50
  676. $tcp2 set bugFix_ false
  677. set ftp1 [$tcp1 attach-app FTP]
  678. set ftp2 [$tcp2 attach-app FTP]
  679. $ns_ at 1.0 "$ftp1 start"
  680. $ns_ at 1.75 "$ftp2 produce 100"
  681. $self tcpDump $tcp1 1.0
  682. # Trace only the bottleneck link
  683. $self traceQueues $node_(r1) [$self openTrace 6.0 $testName_]
  684. $ns_ run
  685. }
  686. Class Test/reno1 -superclass TestSuite
  687. Test/reno1 instproc init topo {
  688. $self instvar net_ defNet_ test_ guide_
  689. set net_ $topo
  690. set defNet_ net0
  691. set test_ reno1
  692. set guide_
  693. "Reno TCP, one packet dropped, Fast Recovery and Fast Retransmit"
  694. $self next
  695. }
  696. Test/reno1 instproc run {} {
  697. global quiet
  698. $self instvar ns_ node_ testName_ guide_
  699. puts "Guide: $guide_"
  700. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  701. $tcp1 set window_ 14
  702. set ftp1 [$tcp1 attach-app FTP]
  703. $ns_ at 1.0 "$ftp1 start"
  704. $self tcpDump $tcp1 1.0
  705. # trace only the bottleneck link
  706. $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_]
  707. $ns_ run
  708. }
  709. Class Test/reno -superclass TestSuite
  710. Test/reno instproc init topo {
  711. $self instvar net_ defNet_ test_ guide_
  712. set net_ $topo
  713. set defNet_ net0
  714. set test_ reno
  715. set guide_      
  716. "Reno TCP, limited by maximum congestion window maxcwnd_."
  717. $self next
  718. }
  719. Test/reno instproc run {} {
  720. global quiet
  721. $self instvar ns_ node_ testName_ guide_
  722. puts "Guide: $guide_"
  723. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  724. $tcp1 set window_ 28
  725. $tcp1 set maxcwnd_ 14
  726. set ftp1 [$tcp1 attach-app FTP]
  727. $ns_ at 1.0 "$ftp1 start"
  728. $self tcpDump $tcp1 1.0
  729. # trace only the bottleneck link
  730. $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_]
  731. $ns_ run
  732. }
  733. Class Test/renoA -superclass TestSuite
  734. Test/renoA instproc init topo {
  735. $self instvar net_ defNet_ test_ guide_
  736. set net_ $topo
  737. set defNet_ net0
  738. set test_ renoA
  739. set guide_ 
  740. "Reno TCP, one packet dropped, Fast Recovery and Fast Retransmit"
  741. $self next
  742. }
  743. Test/renoA instproc run {} {
  744. global quiet
  745. $self instvar ns_ node_ testName_ guide_
  746. puts "Guide: $guide_"
  747. $ns_ queue-limit $node_(r1) $node_(k1) 8
  748. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  749. $tcp1 set window_ 28
  750. set tcp2 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 1]
  751. $tcp2 set window_ 4
  752. set tcp3 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 2]
  753. $tcp3 set window_ 4
  754. set ftp1 [$tcp1 attach-app FTP]
  755. $ns_ at 1.0 "$ftp1 start"
  756. set ftp2 [$tcp2 attach-app FTP]
  757. $ns_ at 1.2 "$ftp2 produce 6"
  758. set ftp3 [$tcp3 attach-app FTP]
  759. $ns_ at 1.2 "$ftp3 produce 6"
  760. $self tcpDump $tcp1 1.0
  761. $self tcpDump $tcp2 1.0
  762. $self tcpDump $tcp3 1.0
  763. # Trace only the bottleneck link
  764. $self traceQueues $node_(r1) [$self openTrace 5.0 $testName_]
  765. $ns_ run
  766. }
  767. Class Test/reno2 -superclass TestSuite
  768. Test/reno2 instproc init topo {
  769. $self instvar net_ defNet_ test_ guide_
  770. set net_ $topo
  771. set defNet_ net0
  772. set test_ reno2
  773. set guide_ 
  774. "Reno TCP, multiple packets dropped, Retransmit Timeout."
  775. $self next
  776. }
  777. Test/reno2 instproc run {} {
  778. global quiet
  779. $self instvar ns_ node_ testName_ guide_
  780. puts "Guide: $guide_"
  781. $ns_ queue-limit $node_(r1) $node_(k1) 9
  782. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  783. $tcp1 set window_ 50
  784. set tcp2 [$ns_ create-connection TCP/Reno $node_(s2) TCPSink $node_(k1) 1]
  785. $tcp2 set window_ 20
  786. set ftp1 [$tcp1 attach-app FTP]
  787. set ftp2 [$tcp2 attach-app FTP]
  788. $ns_ at 1.0 "$ftp1 start"
  789. $ns_ at 1.0 "$ftp2 start"
  790. $self tcpDump $tcp1 1.0
  791. # Trace only the bottleneck link
  792. $self traceQueues $node_(r1) [$self openTrace 10.0 $testName_]
  793. $ns_ run
  794. }
  795. Class Test/reno3 -superclass TestSuite
  796. Test/reno3 instproc init topo {
  797. $self instvar net_ defNet_ test_ guide_
  798. set net_ $topo
  799. set defNet_ net0
  800. set test_ reno3
  801. set guide_
  802. "Reno TCP, two packets dropped from a congestion window of 5 packets."
  803. $self next
  804. }
  805. Test/reno3 instproc run {} {
  806. global quiet
  807. $self instvar ns_ node_ testName_ guide_
  808. puts "Guide: $guide_"
  809. $ns_ queue-limit $node_(r1) $node_(k1) 8
  810. $ns_ queue-limit $node_(k1) $node_(r1) 8
  811. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  812. $tcp1 set window_ 100
  813. set tcp2 [$ns_ create-connection TCP/Reno $node_(s2) TCPSink $node_(k1) 1]
  814. $tcp2 set window_ 16
  815. set ftp1 [$tcp1 attach-app FTP]
  816. set ftp2 [$tcp2 attach-app FTP]
  817. $ns_ at 1.0 "$ftp1 start"
  818. $ns_ at 0.5 "$ftp2 start"
  819. $self tcpDump $tcp1 1.0
  820. # Trace only the bottleneck link
  821. $self traceQueues $node_(r1) [$self openTrace 8.0 $testName_]
  822. $ns_ run
  823. }
  824. Class Test/reno4 -superclass TestSuite
  825. Test/reno4 instproc init topo {
  826. $self instvar net_ defNet_ test_ guide_
  827. set net_ $topo
  828. set defNet_ net2
  829. set test_ reno4
  830. set guide_
  831. "Reno TCP, two packets dropped, no Retransmit Timeout"
  832. $self next
  833. }
  834. Test/reno4 instproc run {} {
  835. global quiet
  836. $self instvar ns_ node_ testName_ guide_
  837. puts "Guide: $guide_"
  838. $ns_ queue-limit $node_(r1) $node_(r2) 29
  839. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink/DelAck $node_(r2) 0]
  840. $tcp1 set window_ 80
  841. $tcp1 set maxcwnd_ 40
  842. set ftp1 [$tcp1 attach-app FTP]
  843. $ns_ at 0.0 "$ftp1 start"
  844. $self tcpDump $tcp1 1.0
  845. # Trace only the bottleneck link
  846. $self traceQueues $node_(s1) [$self openTrace 2.0 $testName_]
  847. $ns_ run
  848. }
  849. Class Test/reno4a -superclass TestSuite
  850. Test/reno4a instproc init topo {
  851. $self instvar net_ defNet_ test_ guide_
  852. set net_ $topo
  853. set defNet_ net2
  854. set test_ reno4a
  855. set guide_
  856. "Reno TCP, two packets dropped, Retransmit Timeout"
  857. $self next
  858. }
  859. Test/reno4a instproc run {} {
  860. global quiet
  861. $self instvar ns_ node_ testName_ guide_
  862. puts "Guide: $guide_"
  863. $ns_ queue-limit $node_(r1) $node_(r2) 29
  864. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink/DelAck $node_(r2) 0]
  865. $tcp1 set window_ 40
  866. $tcp1 set maxcwnd_ 40
  867. set ftp1 [$tcp1 attach-app FTP]
  868. $ns_ at 0.0 "$ftp1 start"
  869. $self tcpDump $tcp1 1.0
  870. # Trace only the bottleneck link
  871. $self traceQueues $node_(s1) [$self openTrace 4.0 $testName_]
  872. $ns_ run
  873. }
  874. Class Test/reno5 -superclass TestSuite
  875. Test/reno5 instproc init topo {
  876. $self instvar net_ defNet_ test_ guide_
  877. set net_ $topo
  878. set defNet_ net0
  879. set test_ reno5
  880. set guide_
  881. "Reno TCP, TCP/bugFix_ set to false."
  882. Agent/TCP set bugFix_ false
  883. $self next
  884. }
  885. Test/reno5 instproc run {} {
  886. global quiet
  887. $self instvar ns_ node_ testName_ guide_
  888. puts "Guide: $guide_"
  889. $ns_ queue-limit $node_(r1) $node_(k1) 9
  890. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  891. $tcp1 set window_ 50
  892. set tcp2 [$ns_ create-connection TCP/Reno $node_(s2) TCPSink $node_(k1) 1]
  893. $tcp2 set window_ 20
  894. set ftp1 [$tcp1 attach-app FTP]
  895. set ftp2 [$tcp2 attach-app FTP]
  896. $ns_ at 1.0 "$ftp1 start"
  897. $ns_ at 1.1 "$ftp2 start"
  898. $self tcpDump $tcp1 1.0
  899. # Trace only the bottleneck link
  900. $self traceQueues $node_(r1) [$self openTrace 10.0 $testName_]
  901. $ns_ run
  902. }
  903. Class Test/reno5_nobug -superclass TestSuite
  904. Test/reno5_nobug instproc init topo {
  905. $self instvar net_ defNet_ test_ guide_
  906. set net_ $topo
  907. set defNet_ net0
  908. set test_ reno5_nobug
  909. set guide_
  910. "Reno TCP, TCP/bugFix_ set to true."
  911. Agent/TCP set bugFix_ true
  912. Test/reno5_nobug instproc run {} [Test/reno5 info instbody run ]
  913. $self next
  914. }
  915. Class Test/telnet -superclass TestSuite
  916. Test/telnet instproc init topo {
  917. $self instvar net_ defNet_ test_ guide_
  918. set net_ $topo
  919. set defNet_ net0
  920. set test_ telnet
  921. set guide_
  922. "Telnet connections with two different packet generation processes."
  923. Agent/TCP set timerfix_ false
  924. # The default is being changed to true.
  925. $self next
  926. }
  927. Test/telnet instproc run {} {
  928. global quiet
  929. $self instvar ns_ node_ testName_ guide_
  930. puts "Guide: $guide_"
  931. $ns_ queue-limit $node_(r1) $node_(k1) 8
  932. $ns_ queue-limit $node_(k1) $node_(r1) 8
  933. set tcp1 [$ns_ create-connection TCP/Reno $node_(s1) TCPSink $node_(k1) 0]
  934. set tcp2 [$ns_ create-connection TCP/Reno $node_(s2) TCPSink $node_(k1) 1]
  935. set tcp3 [$ns_ create-connection TCP/Reno $node_(s2) TCPSink $node_(k1) 2]
  936. set telnet1 [$tcp1 attach-app Telnet]; $telnet1 set interval_ 1
  937. set telnet2 [$tcp2 attach-app Telnet]; $telnet2 set interval_ 0
  938. # Interval 0 designates the tcplib telnet interarrival distribution
  939. set telnet3 [$tcp3 attach-app Telnet]; $telnet3 set interval_ 0
  940. $ns_ at 0.0 "$telnet1 start"
  941. $ns_ at 0.0 "$telnet2 start"
  942. $ns_ at 0.0 "$telnet3 start"
  943. $self tcpDump $tcp1 5.0
  944. # Trace only the bottleneck link
  945. $self traceQueues $node_(r1) [$self openTrace 50.0 $testName_]
  946. # use a different seed each time
  947. #puts seed=[$ns_ random 0]
  948. $ns_ run
  949. }
  950. Class Test/delayed -superclass TestSuite
  951. Test/delayed instproc init topo {
  952. $self instvar net_ defNet_ test_ guide_
  953. set net_ $topo
  954. set defNet_ net0
  955. set test_ delayed
  956. set guide_
  957. "TCP receiver with delayed acknowledgements."
  958. $self next
  959. }
  960. Test/delayed instproc run {} {
  961. global quiet
  962. $self instvar ns_ node_ testName_ guide_
  963. puts "Guide: $guide_"
  964. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink/DelAck $node_(k1) 0]
  965. $tcp1 set window_ 50
  966. # lookup up the sink and set it's delay interval
  967. [$node_(k1) agent [$tcp1 dst-port]] set interval 100ms
  968. set ftp1 [$tcp1 attach-app FTP];
  969. $ns_ at 1.0 "$ftp1 start"
  970. $self tcpDump $tcp1 1.0
  971. # Trace only the bottleneck link
  972. $self traceQueues $node_(r1) [$self openTrace 4.0 $testName_]
  973. $ns_ run
  974. }
  975. Class Test/phase -superclass TestSuite
  976. Test/phase instproc init topo {
  977. $self instvar net_ defNet_ test_ guide_
  978. set net_ $topo
  979. set defNet_ net0
  980. set test_ phase
  981. set guide_ "Phase effects: connection 0 wins."
  982. $self next
  983. }
  984. Test/phase instproc run {} {
  985. global quiet
  986. $self instvar ns_ node_ testName_ guide_
  987. puts "Guide: $guide_"
  988. $ns_ delay $node_(s2) $node_(r1) 3ms
  989. $ns_ delay $node_(r1) $node_(s2) 3ms
  990. $ns_ queue-limit $node_(r1) $node_(k1) 16
  991. $ns_ queue-limit $node_(k1) $node_(r1) 100
  992. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  993. $tcp1 set window_ 32 
  994. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  995. $tcp2 set window_ 32 
  996. set ftp1 [$tcp1 attach-app FTP]
  997. set ftp2 [$tcp2 attach-app FTP]
  998. $ns_ at 5.0 "$ftp1 start"
  999. $ns_ at 1.0 "$ftp2 start"
  1000. $self tcpDump $tcp1 5.0
  1001. # Trace only the bottleneck link
  1002. $self traceQueues $node_(r1) [$self openTrace 25.0 $testName_]
  1003. $ns_ run
  1004. }
  1005. Class Test/phase1 -superclass TestSuite
  1006. Test/phase1 instproc init topo {
  1007. $self instvar net_ defNet_ test_ guide_
  1008. set net_ $topo
  1009. set defNet_ net0
  1010. set test_ phase1
  1011. set guide_ "Phase effects: connection 1 wins."
  1012. $self next
  1013. }
  1014. Test/phase1 instproc run {} {
  1015. global quiet
  1016. $self instvar ns_ node_ testName_ guide_
  1017. puts "Guide: $guide_"
  1018. $ns_ delay $node_(s2) $node_(r1) 9.5ms
  1019. $ns_ delay $node_(r1) $node_(s2) 9.5ms
  1020. $ns_ queue-limit $node_(r1) $node_(k1) 16
  1021. $ns_ queue-limit $node_(k1) $node_(r1) 100
  1022. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  1023. $tcp1 set window_ 32 
  1024. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  1025. $tcp2 set window_ 32 
  1026. set ftp1 [$tcp1 attach-app FTP]
  1027. set ftp2 [$tcp2 attach-app FTP]
  1028. $ns_ at 5.0 "$ftp1 start"
  1029. $ns_ at 1.0 "$ftp2 start"
  1030. $self tcpDump $tcp1 5.0
  1031. # Trace only the bottleneck link
  1032. $self traceQueues $node_(r1) [$self openTrace 25.0 $testName_]
  1033. $ns_ run
  1034. }
  1035. Class Test/phase2 -superclass TestSuite
  1036. Test/phase2 instproc init topo {
  1037. $self instvar net_ defNet_ test_ guide_
  1038. set net_ $topo
  1039. set defNet_ net0
  1040. set test_ phase2
  1041. set guide_
  1042. "Phase effects: TCP/overhead_ is used, and neither connection loses."
  1043. $self next
  1044. }
  1045. Test/phase2 instproc run {} {
  1046. global quiet
  1047. $self instvar ns_ node_ testName_ guide_
  1048. puts "Guide: $guide_"
  1049. $ns_ delay $node_(s2) $node_(r1) 3ms
  1050. $ns_ delay $node_(r1) $node_(s2) 3ms
  1051. $ns_ queue-limit $node_(r1) $node_(k1) 16
  1052. $ns_ queue-limit $node_(k1) $node_(r1) 100
  1053. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  1054. $tcp1 set window_ 32 
  1055. $tcp1 set overhead_ 0.01
  1056. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  1057. $tcp2 set window_ 32 
  1058. # $tcp2 set overhead_ 0.01
  1059. # The random overhead_ was increased slightly to illustrate fairness 
  1060. #   for this scenario.
  1061. $tcp2 set overhead_ 0.015
  1062. set ftp1 [$tcp1 attach-app FTP]
  1063. set ftp2 [$tcp2 attach-app FTP]
  1064. $ns_ at 5.0 "$ftp1 start"
  1065. $ns_ at 1.0 "$ftp2 start"
  1066. $self tcpDump $tcp1 5.0
  1067. # Trace only the bottleneck link
  1068. $self traceQueues $node_(r1) [$self openTrace 25.0 $testName_]
  1069. $ns_ run
  1070. }
  1071. Class Test/timers -superclass TestSuite
  1072. Test/timers instproc init topo {
  1073. $self instvar net_ defNet_ test_ guide_
  1074. set net_ $topo
  1075. set defNet_ net0
  1076. set test_ timers
  1077. set guide_ "TCP retransmit timers."
  1078. Agent/TCP set timerfix_ false
  1079. # The default is being changed to true.
  1080. $self next
  1081. }
  1082. Test/timers instproc run {} {
  1083. global quiet
  1084. $self instvar ns_ node_ testName_ guide_
  1085. $ns_ queue-limit $node_(r1) $node_(k1) 2
  1086. $ns_ queue-limit $node_(k1) $node_(r1) 100
  1087. set tcp1 [$ns_ create-connection TCP $node_(s1) TCPSink/DelAck $node_(k1) 0]
  1088. $tcp1 set window_ 4
  1089. # look up the sink and set its delay interval
  1090. [$node_(k1) agent [$tcp1 dst-port]] set interval_ 100ms
  1091. set tcp2 [$ns_ create-connection TCP $node_(s2) TCPSink/DelAck $node_(k1) 1]
  1092. $tcp2 set window_ 4
  1093. # look up the sink and set its delay interval
  1094. [$node_(k1) agent [$tcp2 dst-port]] set interval_ 100ms
  1095. set ftp1 [$tcp1 attach-app FTP]
  1096. set ftp2 [$tcp2 attach-app FTP]
  1097. $ns_ at 1.0 "$ftp1 start"
  1098. $ns_ at 1.3225 "$ftp2 start"
  1099. $self tcpDump $tcp1 5.0
  1100. # Trace only the bottleneck link
  1101. $self traceQueues $node_(r1) [$self openTrace 10.0 $testName_]
  1102. $ns_ run
  1103. }
  1104. # Many small TCP flows.
  1105. Class Test/manyflows -superclass TestSuite
  1106. Test/manyflows instproc init topo {
  1107. $self instvar net_ defNet_ test_ guide_
  1108. set net_ $topo
  1109. set defNet_ net0
  1110. set test_ manyflows
  1111. set guide_ "Using FTP commands to create many small flows."
  1112. $self next
  1113. }
  1114. Test/manyflows instproc run {} {
  1115. global quiet
  1116. $self instvar ns_ node_ testName_ guide_
  1117. puts "Guide: $guide_"
  1118. # Set up TCP connections
  1119. set rng_ [new RNG]
  1120. ## $rng_ seed [ns random 0]
  1121. set stoptime 5
  1122. set randomflows 10
  1123. for {set i 0} {$i < $randomflows} {incr i} {
  1124.     set tcp [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 1]
  1125.     set ftp [[set tcp] attach-app FTP]    
  1126.     set numpkts [$rng_ uniform 0 10]
  1127.     set starttime [$rng_ uniform 0 $stoptime]
  1128.     $ns_ at $starttime "[set ftp] produce $numpkts" 
  1129.     $ns_ at $stoptime "[set ftp] stop"  
  1130. }   
  1131. # Trace only the bottleneck link
  1132. #
  1133. # Actually, we now trace all activity at the node around the
  1134. # bottleneck link.  This allows us to track acks, as well
  1135. # packets taking any alternate paths around the bottleneck
  1136. # link.
  1137. #
  1138. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1139. $ns_ run
  1140. }
  1141. TestSuite instproc printpkts { label tcp } {
  1142.         global tcpTick_ 
  1143. puts "tcp $label highest_seqment_acked [$tcp set ack_]"
  1144. puts "tcp $label data_bytes_sent [$tcp set ndatabytes_]"
  1145.         set numRtts [$tcp set rtt_]
  1146. set tick $tcpTick_
  1147.         set rtt [expr $numRtts * $tcpTick_]
  1148. puts "tcp $label most_recent_rtt [format "%5.3f" $rtt]"  
  1149. }
  1150. TestSuite instproc printpktsTFRC { label tfrc } {
  1151.         global tcpTick_ 
  1152. puts "tfrc $label data_pkts_sent [$tfrc set ndatapack_]"
  1153. }
  1154. TestSuite instproc printdrops { fid fmon } {
  1155. set fcl [$fmon classifier]; # flow classifier
  1156. #
  1157. # look up the flow using the classifier.  Because we are
  1158. # using a Fid classifier, the src/dst fields are not compared,
  1159. # and can thus be just zero, as illustrated here.  The "auto"
  1160. # indicates we don't already know which bucket in the classifier's
  1161. # hash table to find the flow we're looking for.
  1162. #
  1163. set flow [$fcl lookup auto 0 0 $fid]
  1164. puts "fid: $fid per-link total_drops [$flow set pdrops_]"
  1165. puts "fid: $fid per-link total_marks [$flow set pmarks_]"
  1166. puts "fid: $fid per-link total_packets [$flow set pdepartures_]"
  1167. puts "fid: $fid per-link total_bytes [$flow set bdepartures_]"
  1168. #
  1169. # note there is much more date available in $flow and $fmon
  1170. # that isn't being printed here.
  1171. #
  1172. }
  1173. TestSuite instproc printstop { stoptime } {
  1174. puts "stop-time $stoptime"
  1175. }
  1176. TestSuite instproc printall { fmon } {
  1177.   puts "aggregate per-link total_drops [$fmon set pdrops_]"
  1178. puts "aggregate per-link total_marks [$fmon set pmarks_]"
  1179. puts "aggregate per-link total_packets [$fmon set pdepartures_]"
  1180. }
  1181. TestSuite instproc printPeakRates { fmon time } {
  1182.         $self instvar pastbytes
  1183.         set allflows [$fmon flows]
  1184.         foreach f $allflows {
  1185.                 set fid [$f set flowid_]
  1186. #set src [$f set src_]
  1187. #set dst [$f set dst_]
  1188.                 set bytes [$f set bdepartures_]
  1189.                 if [info exists pastbytes($f)] {
  1190.                         set newbytes [expr $bytes - $pastbytes($f)]
  1191.                 }  else {
  1192.                         set newbytes $bytes 
  1193.                 }
  1194.                 if {$newbytes > 0} {
  1195. #src: $src d st: $dst
  1196.                         puts "time: [format "%3.2f" $time] fid: $fid new_bytes $newbytes"
  1197.                         set pastbytes($f) $bytes
  1198.                 }
  1199.         }
  1200. }
  1201. TestSuite instproc printPeakRate { fmon time interval } {
  1202.         $self instvar ns_
  1203.         set newTime [expr [$ns_ now] + $interval]
  1204.         $ns_ at $time "$self printPeakRates $fmon $time"
  1205.         $ns_ at $newTime "$self printPeakRate $fmon $newTime $interval"
  1206. }
  1207. Class Test/stats -superclass TestSuite
  1208. Test/stats instproc init topo {
  1209. $self instvar net_ defNet_ test_ guide_
  1210. set net_ $topo
  1211. set defNet_ net0
  1212. set test_ stats
  1213. set guide_
  1214. "TCP statistics, and per-flow and aggregate link statistics."
  1215. $self next
  1216. }
  1217. Test/stats instproc run {} {
  1218. global quiet
  1219. $self instvar ns_ node_ testName_ guide_ 
  1220. puts "Guide: $guide_"
  1221. $ns_ delay $node_(s2) $node_(r1) 200ms
  1222. $ns_ delay $node_(r1) $node_(s2) 200ms
  1223. $ns_ queue-limit $node_(r1) $node_(k1) 10
  1224. $ns_ queue-limit $node_(k1) $node_(r1) 10
  1225. set slink [$ns_ link $node_(r1) $node_(k1)]; # link to collect stats on
  1226. set fmon [$ns_ makeflowmon Fid]
  1227. $ns_ attach-fmon $slink $fmon
  1228. set stoptime 10.1 
  1229. set tcp0 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  1230. $tcp0 set window_ 30
  1231. set tcp1 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  1232. $tcp1 set window_ 30
  1233. set ftp0 [$tcp0 attach-app FTP]
  1234. set ftp1 [$tcp1 attach-app FTP]
  1235. $ns_ at 1.0 "$ftp0 start"
  1236. $ns_ at 1.0 "$ftp1 start"
  1237. $self tcpDumpAll $tcp0 5.0 tcp0
  1238. $self tcpDumpAll $tcp1 5.00001 tcp1
  1239. set almosttime [expr $stoptime - 0.001]
  1240. $ns_ at $almosttime "$self printpkts 0 $tcp0"
  1241. $ns_ at $almosttime "$self printpkts 1 $tcp1"
  1242. $ns_ at $stoptime "$self printdrops 0 $fmon; $self printdrops 1 $fmon"
  1243. $ns_ at $stoptime "$self printall $fmon"
  1244. # trace only the bottleneck link
  1245. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1246. $ns_ run
  1247. }
  1248. Class Test/statsECN -superclass TestSuite
  1249. Test/statsECN instproc init topo {
  1250. $self instvar net_ defNet_ test_ guide_
  1251. set net_ $topo
  1252. set defNet_ net0a
  1253. set test_ statsECN
  1254. Queue/RED set setbit_ true
  1255. Queue/RED set thresh_ 1
  1256. Queue/RED set maxthresh_ 0
  1257. Agent/TCP set ecn_ 1
  1258. set guide_
  1259. "Flow monitor statistics with ECN."
  1260. $self next
  1261. }
  1262. Test/statsECN instproc run {} {
  1263. global quiet
  1264. $self instvar ns_ node_ testName_ guide_ 
  1265. puts "Guide: $guide_"
  1266. $ns_ delay $node_(s2) $node_(r1) 200ms
  1267. $ns_ delay $node_(r1) $node_(s2) 200ms
  1268. $ns_ queue-limit $node_(r1) $node_(k1) 100
  1269. $ns_ queue-limit $node_(k1) $node_(r1) 100
  1270. set slink [$ns_ link $node_(r1) $node_(k1)]; # link to collect stats on
  1271. set fmon [$ns_ makeflowmon Fid]
  1272. $ns_ attach-fmon $slink $fmon
  1273. set stoptime 10.1 
  1274. set tcp0 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  1275. $tcp0 set window_ 30
  1276. set tcp1 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  1277. $tcp1 set window_ 30
  1278. set ftp0 [$tcp0 attach-app FTP]
  1279. set ftp1 [$tcp1 attach-app FTP]
  1280. $ns_ at 1.0 "$ftp0 start"
  1281. $ns_ at 1.0 "$ftp1 start"
  1282. set almosttime [expr $stoptime - 0.001]
  1283. $ns_ at $stoptime "$self printdrops 0 $fmon; $self printdrops 1 $fmon"
  1284. $ns_ at $stoptime "$self printall $fmon"
  1285. # trace only the bottleneck link
  1286. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1287. $ns_ run
  1288. }
  1289. Class Test/stats1 -superclass TestSuite
  1290. Test/stats1 instproc init topo {
  1291. $self instvar net_ defNet_ test_ guide_
  1292. set net_ $topo
  1293. set defNet_ net0
  1294. Queue/DropTail set summarystats_ true
  1295. set test_ stats1
  1296. set guide_
  1297. "FTP statistics on bytes produced, and queue statistics.
  1298. Should be: fid: 0 per-link total_bytes 940."
  1299. $self next
  1300. }
  1301. Test/stats1 instproc run {} {
  1302. global quiet
  1303. $self instvar ns_ node_ testName_ guide_ 
  1304. puts "Guide: $guide_"
  1305. $ns_ delay $node_(s2) $node_(r1) 200ms
  1306. $ns_ delay $node_(r1) $node_(s2) 200ms
  1307. $ns_ queue-limit $node_(r1) $node_(k1) 10
  1308. $ns_ queue-limit $node_(k1) $node_(r1) 10
  1309. set packetSize_ 100
  1310. Agent/TCP set packetSize_ $packetSize_
  1311. puts "TCP packetSize [Agent/TCP set packetSize_]"
  1312. set slink [$ns_ link $node_(r1) $node_(k1)]; # link to collect stats on
  1313. set fmon [$ns_ makeflowmon Fid]
  1314. $ns_ attach-fmon $slink $fmon
  1315. set stoptime 10.1 
  1316. set tcp0 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(k1) 0]
  1317. $tcp0 set window_ 30
  1318. set tcp1 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(k1) 1]
  1319. $tcp1 set window_ 30
  1320. set ftp0 [$tcp0 attach-app FTP]
  1321. set ftp1 [$tcp1 attach-app FTP]
  1322. set packets_ftp 9
  1323. set bytes_ftp [expr $packets_ftp * $packetSize_]
  1324. $ns_ at 1.0 "$ftp0 produce $packets_ftp"
  1325. puts "ftp 0 segments_produced $packets_ftp (using `FTP produce pktcnt')"
  1326. $ns_ at 1.0 "$ftp1 send $bytes_ftp"
  1327. puts "ftp 1 bytes_produced $bytes_ftp (using `FTP send nbytes')"
  1328. set link1 [$ns_ link $node_(r1) $node_(k1)]
  1329. set queue1 [$link1 queue]
  1330. $ns_ at 10.0 "$queue1 printstats"
  1331. set almosttime [expr $stoptime - 0.001]
  1332. $ns_ at $almosttime "$self printpkts 0 $tcp0"
  1333. $ns_ at $almosttime "$self printpkts 1 $tcp1"
  1334. $ns_ at $stoptime "$self printdrops 0 $fmon; $self printdrops 1 $fmon"
  1335. $ns_ at $stoptime "$self printall $fmon"
  1336. # trace only the bottleneck link
  1337. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1338. $ns_ run
  1339. }
  1340. Class Test/stats1Bytes -superclass TestSuite
  1341. Test/stats1Bytes instproc init topo {
  1342. $self instvar net_ defNet_ test_ guide_
  1343. set net_ $topo
  1344. set defNet_ net0
  1345. Queue/DropTail set summarystats_ true
  1346. Queue/DropTail set queue_in_bytes_ true
  1347. set test_ stats1Bytes
  1348. set guide_ "Queue statistics for a queue in bytes.
  1349. Should be:      True average queue: 0.439 (in bytes)"
  1350. Test/stats1Bytes instproc run {} [Test/stats1 info instbody run]
  1351. $self next
  1352. }
  1353. Class Test/stats1a -superclass TestSuite
  1354. Test/stats1a instproc init topo {
  1355. $self instvar net_ defNet_ test_ guide_
  1356. set net_ $topo
  1357. set defNet_ net0a
  1358. Queue/RED set summarystats_ true
  1359. set test_ stats1a
  1360. set guide_ "Queue statistics for a RED queue.
  1361. Should be: True average queue: 0.004"
  1362. Test/stats1a instproc run {} [Test/stats1 info instbody run]
  1363. $self next
  1364. }
  1365. Class Test/stats1aBytes -superclass TestSuite
  1366. Test/stats1aBytes instproc init topo {
  1367. $self instvar net_ defNet_ test_ guide_
  1368. set net_ $topo
  1369. set defNet_ net0a
  1370. Queue/RED set summarystats_ true
  1371. Queue/RED set queue_in_bytes_ true
  1372. set test_ stats1aBytes
  1373. set guide_ "Queue statistics for a RED queue in bytes.
  1374. Should be:      True average queue: 0.439 (in bytes)"
  1375. Test/stats1aBytes instproc run {} [Test/stats1 info instbody run]
  1376. $self next
  1377. }
  1378. Class Test/statsHeaders -superclass TestSuite
  1379. Test/statsHeaders instproc init topo {
  1380. $self instvar net_ defNet_ test_ guide_
  1381. set net_ $topo
  1382. set defNet_ net0a
  1383. Queue/RED set summarystats_ true
  1384. Agent/TCP set useHeaders_ true
  1385. set test_ statsHeaders
  1386. set guide_
  1387. "FTP and packet statistics for TCP with correct accounting for headers.
  1388. Should be: fid: 0 per-link total_bytes 1300"
  1389. Test/statsHeaders instproc run {} [Test/stats1 info instbody run]
  1390. $self next
  1391. }
  1392. Class Test/stats2 -superclass TestSuite
  1393. Test/stats2 instproc init topo {
  1394. $self instvar net_ defNet_ test_ guide_
  1395. set net_ $topo
  1396. set defNet_ net2
  1397. Queue/RED set summarystats_ true
  1398. set test_ stats2
  1399. set guide_
  1400. "Queue statistics for the true average queue size.
  1401. Should be:     True average queue: 8.632"
  1402. $self next
  1403. }
  1404. Test/stats2 instproc run {} {
  1405. global quiet
  1406. $self instvar ns_ node_ testName_ guide_ 
  1407. puts "Guide: $guide_"
  1408. set stoptime 10.1 
  1409. set tcp0 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(s3) 0]
  1410. $tcp0 set window_ 1000
  1411. set tcp1 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(s3) 1]
  1412. $tcp1 set window_ 1000
  1413. set ftp0 [$tcp0 attach-app FTP]
  1414. set ftp1 [$tcp1 attach-app FTP]
  1415. $ns_ at 0.0 "$ftp0 start"
  1416. $ns_ at 1.0 "$ftp1 start"
  1417. set link1 [$ns_ link $node_(r1) $node_(r2)]
  1418. set queue1 [$link1 queue]
  1419. $ns_ at 10.0 "$queue1 printstats"
  1420. # trace only the bottleneck link
  1421. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1422. $ns_ run
  1423. }
  1424. Class Test/stats3 -superclass TestSuite
  1425. Test/stats3 instproc init topo {
  1426. $self instvar net_ defNet_ test_ guide_
  1427. set net_ $topo
  1428. set defNet_ net3
  1429. set test_ stats3
  1430. QueueMonitor set keepRTTstats_ 1
  1431. QueueMonitor set maxRTT_ 1
  1432. QueueMonitor set binsPerSec_ 100
  1433. QueueMonitor set keepSeqnoStats_ 1
  1434. QueueMonitor set maxSeqno_ 2000
  1435. QueueMonitor set SeqnoBinSize_ 100
  1436. Agent/TCP set tcpTick_ 0.01
  1437. set guide_ "Printing RTT and Seqno statistics."
  1438. $self next
  1439. }
  1440. Test/stats3 instproc run {} {
  1441. global quiet
  1442. $self instvar ns_ node_ testName_ guide_ 
  1443. puts "Guide: $guide_"
  1444. set stoptime 1.1 
  1445. set slink [$ns_ link $node_(r1) $node_(r2)]; 
  1446. set fmon [new QueueMonitor]
  1447. #set outfile [open temp.stats w]
  1448. set outfile stdout
  1449. $fmon traceDist $outfile
  1450. $ns_ attach-fmon $slink $fmon
  1451. set tcp0 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(s3) 0]
  1452. $tcp0 set window_ 10
  1453. set tcp1 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(s3) 1]
  1454. $tcp1 set window_ 10
  1455. set ftp0 [$tcp0 attach-app FTP]
  1456. set ftp1 [$tcp1 attach-app FTP]
  1457. $ns_ at 0.0 "$ftp0 start"
  1458. $ns_ at 0.1 "$ftp1 start"
  1459. set link1 [$ns_ link $node_(r1) $node_(r2)]
  1460. set queue1 [$link1 queue]
  1461. $ns_ at $stoptime "$fmon printRTTs"
  1462. #
  1463. ## to plot RTTs:  
  1464. ## ./test-all-simple stats3 > out %
  1465. ## awk -f rtts.awk out > data   
  1466.         ## xgraph -bb -tk -x rtt -y frac_of_pkts data &
  1467. #
  1468. $ns_ at $stoptime "$fmon printSeqnos"
  1469. #
  1470. ## to plot seqnos:  
  1471. ## ./test-all-simple stats3 > out &
  1472. ## awk -f seqnos.awk out > data   
  1473.         ## xgraph -bb -tk -x seqno_bin -y frac_of_pkts data &
  1474. #
  1475. # trace only the bottleneck link
  1476. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1477. $ns_ run
  1478. }
  1479. Class Test/stats4 -superclass TestSuite
  1480. Test/stats4 instproc init topo {
  1481. $self instvar net_ defNet_ test_ guide_
  1482. set net_ $topo
  1483. set defNet_ net3
  1484. set test_ stats4
  1485. Agent/TCP set tcpTick_ 0.01
  1486. set guide_ "Printing peak rate statistics."
  1487. $self next
  1488. }
  1489. Test/stats4 instproc run {} {
  1490. global quiet
  1491. $self instvar ns_ node_ testName_ guide_ 
  1492. puts "Guide: $guide_"
  1493. set stoptime 1.1 
  1494. set PeakRateInterval 0.1
  1495. set slink [$ns_ link $node_(r1) $node_(r2)]; 
  1496. #set fmon [$ns_ makeflowmon SrcDestFid]
  1497. set fmon [$ns_ makeflowmon Fid]
  1498. set outfile stdout
  1499. $fmon traceDist $outfile
  1500. $ns_ attach-fmon $slink $fmon
  1501. set tcp0 [$ns_ create-connection TCP $node_(s1) TCPSink $node_(s3) 0]
  1502. $tcp0 set window_ 10
  1503. set tcp1 [$ns_ create-connection TCP $node_(s2) TCPSink $node_(s3) 1]
  1504. $tcp1 set window_ 10
  1505. set ftp0 [$tcp0 attach-app FTP]
  1506. set ftp1 [$tcp1 attach-app FTP]
  1507. $ns_ at 0.0 "$ftp0 start"
  1508. $ns_ at 0.1 "$ftp1 start"
  1509. set link1 [$ns_ link $node_(r1) $node_(r2)]
  1510. set queue1 [$link1 queue]
  1511. $ns_ at 0.5 "$self printPeakRate $fmon 0.5 $PeakRateInterval"
  1512. # trace only the bottleneck link
  1513. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1514. $ns_ run
  1515. }
  1516. Class Test/statsTFRC -superclass TestSuite
  1517. Test/statsTFRC instproc init topo {
  1518. $self instvar net_ defNet_ test_ guide_
  1519. set net_ $topo
  1520. set defNet_ net0
  1521. set test_ statsTFRC
  1522. set guide_
  1523. "TFRC statistics, and per-flow and aggregate link statistics."
  1524. $self next
  1525. }
  1526. Test/statsTFRC instproc run {} {
  1527. global quiet
  1528. $self instvar ns_ node_ testName_ guide_ test_
  1529. puts "Guide: $guide_"
  1530. $ns_ delay $node_(s2) $node_(r1) 200ms
  1531. $ns_ delay $node_(r1) $node_(s2) 200ms
  1532. $ns_ queue-limit $node_(r1) $node_(k1) 10
  1533. $ns_ queue-limit $node_(k1) $node_(r1) 10
  1534. set slink [$ns_ link $node_(r1) $node_(k1)]; # link to collect stats on
  1535. set fmon [$ns_ makeflowmon Fid]
  1536. $ns_ attach-fmon $slink $fmon
  1537. set stoptime 5.1 
  1538. set tf0 [$ns_ create-connection TFRC $node_(s1) TFRCSink $node_(k1) 0]
  1539. #$tf0 set window_ 30
  1540. set tf1 [$ns_ create-connection TFRC $node_(s2) TFRCSink $node_(k1) 1]
  1541. #$tf1 set window_ 30
  1542. set ftp0 [new Application/FTP]; $ftp0 attach-agent $tf0
  1543. set ftp1 [new Application/FTP]; $ftp1 attach-agent $tf1
  1544. $ns_ at 1.0 "$ftp0 start"
  1545. $ns_ at 1.0 "$ftp1 start"
  1546. #$self tcpDumpAll $tf0 5.0 tf0
  1547. #$self tcpDumpAll $tf1 5.00001 tf1
  1548. set almosttime [expr $stoptime - 0.001]
  1549. $ns_ at $almosttime "$self printpktsTFRC 0 $tf0"
  1550. $ns_ at $almosttime "$self printpktsTFRC 1 $tf1"
  1551. $ns_ at $stoptime "$self printdrops 0 $fmon; $self printdrops 1 $fmon"
  1552. $ns_ at $stoptime "$self printall $fmon"
  1553. # trace only the bottleneck link
  1554. $self traceQueues $node_(r1) [$self openTrace $stoptime $testName_]
  1555. $ns_ run
  1556. }
  1557. # Add a test to printTimestamps.
  1558. # tcp-sink.cc, p. 337.
  1559. TestSuite runTest
  1560. ### Local Variables:
  1561. ### mode: tcl
  1562. ### tcl-indent-level: 8
  1563. ### tcl-default-application: ns
  1564. ### End: