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

通讯编程

开发平台:

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-rap.tcl,v 1.7 2004/10/18 19:42:18 sfloyd Exp $
  34. #
  35. # To view a list of available tests to run with this script:
  36. # ns test-suite-tcpVariants.tcl
  37. #
  38. source misc_simple.tcl
  39. # FOR UPDATING GLOBAL DEFAULTS:
  40. Trace set show_tcphdr_ 1
  41. set wrap 90
  42. set wrap1 [expr 90 * 512 + 40]
  43. Class Topology
  44. Topology instproc node? num {
  45.     $self instvar node_
  46.     return $node_($num)
  47. }
  48. #
  49. # Links1 uses 8Mb, 5ms feeders, and a 800Kb 10ms bottleneck.
  50. # Queue-limit on bottleneck is 2 packets.
  51. #
  52. Class Topology/net4 -superclass Topology
  53. Topology/net4 instproc init ns {
  54.     $self instvar node_
  55.     set node_(s1) [$ns node]
  56.     set node_(s2) [$ns node]
  57.     set node_(r1) [$ns node]
  58.     set node_(k1) [$ns node]
  59.     $self next
  60.     $ns duplex-link $node_(s1) $node_(r1) 8Mb 0ms DropTail
  61.     $ns duplex-link $node_(s2) $node_(r1) 8Mb 0ms DropTail
  62.     $ns duplex-link $node_(r1) $node_(k1) 800Kb 100ms DropTail
  63.     $ns queue-limit $node_(r1) $node_(k1) 8
  64.     $ns queue-limit $node_(k1) $node_(r1) 8
  65.     $self instvar lossylink_
  66.     set lossylink_ [$ns link $node_(r1) $node_(k1)]
  67.     set em [new ErrorModule Fid]
  68.     set errmodel [new ErrorModel/Periodic]
  69.     $errmodel unit pkt
  70.     $lossylink_ errormodule $em
  71. }
  72. TestSuite instproc finish file {
  73. global quiet wrap PERL
  74.         exec $PERL ../../bin/set_flow_id -s all.tr | 
  75.           $PERL ../../bin/getrc -s 2 -d 3 | 
  76.           $PERL ../../bin/raw2xg -s 0.01 -m $wrap -t $file > temp.rands
  77. if {$quiet == "false"} {
  78. exec xgraph -bb -tk -nl -m -x time -y packets temp.rands &
  79. }
  80.         ## now use default graphing tool to make a data file
  81. ## if so desired
  82.         exit 0
  83. }
  84. TestSuite instproc emod {} {
  85.         $self instvar topo_
  86.         $topo_ instvar lossylink_
  87.         set errmodule [$lossylink_ errormodule]
  88.         return $errmodule
  89. TestSuite instproc drop_pkts pkts {
  90.     $self instvar ns_
  91.     set emod [$self emod]
  92.     set errmodel1 [new ErrorModel/List]
  93.     $errmodel1 droplist $pkts
  94.     $emod insert $errmodel1
  95.     $emod bind $errmodel1 1
  96. }
  97. TestSuite instproc setup {tcptype list} {
  98. global wrap wrap1
  99.         $self instvar ns_ node_ testName_
  100. $self setTopo
  101. set fid 1
  102.         # Set up connection
  103.      if {$tcptype == "RAP"} {
  104.        set conn1 [$ns_ create-connection RAP $node_(s1) 
  105.            RAP $node_(k1) $fid]
  106.      } 
  107.         $ns_ at 1.0 "$conn1 start"
  108.         $self drop_pkts $list
  109.         #$self traceQueues $node_(r1) [$self openTrace 8.0 $testName_]
  110. $ns_ at 8.0 "$self cleanupAll $testName_"
  111.         $ns_ run
  112. }
  113. # Definition of test-suite tests
  114. ###################################################
  115. ## One drop
  116. ###################################################
  117. Class Test/onedrop_rap -superclass TestSuite
  118. Test/onedrop_rap instproc init {} {
  119. $self instvar net_ test_
  120. set net_ net4
  121. set test_ onedrop_rap
  122. $self next pktTraceFile
  123. }
  124. Test/onedrop_rap instproc run {} {
  125.         $self setup RAP {14}
  126. }
  127. ###################################################
  128. ## Two drops
  129. ###################################################
  130. Class Test/twodrops_rap -superclass TestSuite
  131. Test/twodrops_rap instproc init {} {
  132. $self instvar net_ test_
  133. set net_ net4
  134. set test_ twodrops_rap
  135. $self next pktTraceFile
  136. }
  137. Test/twodrops_rap instproc run {} {
  138.         $self setup RAP {14 28}
  139. }
  140. ###################################################
  141. ## Three drops
  142. ###################################################
  143. Class Test/threedrops_rap -superclass TestSuite
  144. Test/threedrops_rap instproc init {} {
  145. $self instvar net_ test_
  146. set net_ net4
  147. set test_ threedrops_rap
  148. $self next pktTraceFile
  149. }
  150. Test/threedrops_rap instproc run {} {
  151.         $self setup RAP {14 26 28}
  152. }
  153. ###################################################
  154. ## Four drops
  155. ###################################################
  156. Class Test/fourdrops_rap -superclass TestSuite
  157. Test/fourdrops_rap instproc init {} {
  158. $self instvar net_ test_
  159. set net_ net4
  160. set test_ fourdrops_rap
  161. $self next pktTraceFile
  162. }
  163. Test/fourdrops_rap instproc run {} {
  164.         $self setup RAP {14 24 26 28}
  165. }
  166. ###################################################
  167. ## Different parameters
  168. ###################################################
  169. Class Test/diff_decrease_rap -superclass TestSuite
  170. Test/diff_decrease_rap instproc init {} {
  171. $self instvar net_ test_
  172. set net_ net4
  173. set test_ diff_decrease_rap
  174. Agent/RAP set beta_ 0.875
  175. $self next pktTraceFile
  176. }
  177. Test/diff_decrease_rap instproc run {} {
  178.         $self setup RAP {14}
  179. }
  180. ###################################################
  181. ## Different parameters
  182. ###################################################
  183. Class Test/diff_increase_rap -superclass TestSuite
  184. Test/diff_increase_rap instproc init {} {
  185. $self instvar net_ test_
  186. set net_ net4
  187. set test_ diff_increase_rap
  188. Agent/RAP set alpha_ 0.2
  189. $self next pktTraceFile
  190. }
  191. Test/diff_increase_rap instproc run {} {
  192.         $self setup RAP {14}
  193. }
  194. TestSuite runTest