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

通讯编程

开发平台:

Visual C++

  1. #
  2. # Copyright (c) 2004-2006 University of Southern California.
  3. # All rights reserved.   
  4. #  
  5. # Redistribution and use in source and binary forms are permitted
  6. # provided that the above copyright notice and this paragraph are
  7. # duplicated in all such forms and that any documentation, advertising
  8. # materials, and other materials related to such distribution and use
  9. # acknowledge that the software was developed by the University of
  10. # Southern California, Information Sciences Institute. The name of the
  11. # University may not be used to endorse or promote products derived from
  12. # this software without specific prior written permission.
  13. # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
  14. # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  15. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16. # To run all tests: test-all-xcp
  17. # to run individual test:
  18. # ns test-suite-xcp.tcl simple-xcp
  19. # ns test-suite-xcp.tcl simple-full-xcp
  20. # To view a list of available test to run with this script:
  21. # ns test-suite-xcp.tcl
  22. # This test-suite validate xcp congestion control scenarios along with
  23. # xcp-tcp mixed flows through routers.
  24. remove-all-packet-headers       ; # removes all except common
  25. add-packet-header Flags IP TCP XCP ; # hdrs reqd for validation
  26. set fullxcp 1
  27. set halfxcp 1
  28. set validtests ""
  29. if {![TclObject is-class Agent/TCP/Reno/XCP]} {
  30. puts "xcp (half) module is not present; validation skipped"
  31. set halfxcp 0
  32. } else {
  33. set validtests "simple-xcp $validtests"
  34. }
  35. if {![TclObject is-class Agent/TCP/FullTcp/Newreno/XCP]} {
  36. puts "xcp (full) module is not present; validation skipped"
  37. set fullxcp 0
  38. if { $halfxcp == 0 } {
  39. exit 0; #will skip entire suite
  40. }
  41. } else {
  42. set validtests "$validtests simple-full-xcp"
  43. # The following tests aren't validated because
  44. #   xcp-tcp isn't really testing anything useful and
  45. #   parking-lot-topo utilization plot is useless
  46. #set validtests "$validtests xcp-tcp parking-lot-topo"
  47. }
  48. Class TestSuite
  49. proc usage {} {
  50. global argv0 validtests
  51. puts stderr "usage: ns $argv0 <tests> "
  52. puts "Valid Tests: $validtests"
  53. exit 1
  54. }
  55. TestSuite instproc init {} {
  56. $self instvar ns_ rtg_ tracefd_ qType_ qSize_ BW_ delay_ 
  57.     tracedFlows_
  58. set ns_ [new Simulator]
  59. $ns_ use-scheduler Heap
  60. set rtg_ [new RNG]
  61. $rtg_ seed 472904
  62. }
  63. TestSuite instproc create-Bottleneck {} {
  64. global R0 R1 Bottleneck rBottleneck l rl all_links
  65. $self instvar ns_ qType_ qSize_ BW_ delay_
  66. # create bottleneck nodes
  67. set R0 [$ns_ node]
  68. set R1 [$ns_ node]
  69. $ns_ duplex-link $R0 $R1 [set BW_]Mb [set delay_]ms $qType_
  70. $ns_ queue-limit $R0 $R1 $qSize_
  71. $ns_ queue-limit $R1 $R0 $qSize_
  72. # Give a global handle to the Bottleneck Queue to allow 
  73. # setting the RED paramters
  74. set  Bottleneck  [[$ns_ link $R0 $R1] queue] 
  75. set  rBottleneck [[$ns_ link $R1 $R0] queue]
  76. set  l  [$ns_ link $R0 $R1]  
  77. set  rl [$ns_ link $R1 $R0]
  78. set all_links "$l $rl "
  79. }
  80. TestSuite instproc create-sidelinks {numSideLinks deltaDelay} {
  81. global R0 R1 all_links n
  82. $self instvar ns_ BW_ delay_ qSize_ qType_
  83. set i 0
  84. while { $i < $numSideLinks } {
  85. set n($i)  [$ns_ node]
  86. $ns_ duplex-link $n($i) $R0 [set BW_]Mb [expr $delay_ + $i * $deltaDelay]ms $qType_
  87. $ns_ queue-limit $n($i)  $R0  $qSize_
  88. $ns_ queue-limit $R0 $n($i)   $qSize_
  89. set  q$i   [[$ns_ link $n($i)  $R0] queue] 
  90. set  rq$i  [[$ns_ link $R0 $n($i)] queue]
  91. set  l$i    [$ns_ link $n($i)  $R0] 
  92. set  rl$i   [$ns_ link $R0 $n($i)]
  93. set all_links "$all_links [set l$i] [set rl$i] "
  94. incr i
  95. }
  96. }
  97. TestSuite instproc create-string-topology {numHops BW_list d_list qtype_list qsize_list } {
  98. $self instvar ns_
  99. global quiet n all_links
  100. set numNodes [expr $numHops + 1 ]
  101. # first sanity check
  102.     if { [llength $BW_list] !=  [llength $d_list] || [llength $qtype_list] !=  [llength $qsize_list]} {
  103. error "Args sizes don't match with $numHops hops"
  104. if { [llength $BW_list] != $numHops || $numHops != [llength $qsize_list]} {
  105.     puts "error in using proc create-string-topology"
  106.     error "Args sizes don't match with $numHops hops"
  107. }
  108.     }
  109. # compute the pipe assuming delays are in msec and BWs are in Mbits
  110.     set i 0; set forwarddelay 0; global minBW; set minBW [lindex $BW_list 0];
  111.     while { $i < $numHops } {
  112. set forwarddelay [expr $forwarddelay + [lindex $d_list $i]]
  113. if {$minBW > [lindex $BW_list $i] } { set $minBW [lindex $BW_list $i] }
  114. incr i
  115.     }
  116. # pipe in bytes,assuming pktsize as 1000bytes,BW in Mbps,delay in ms
  117. set pipe [expr round([expr ($minBW * 2.0 * $forwarddelay)/8.0 ])]
  118. set i 0
  119. while { $i < $numNodes } {
  120. set n($i) [$ns_ node]
  121. incr i
  122. }
  123. set all_links ""
  124. set  i 0 
  125. while { $i < $numHops } {
  126. set qsize [lindex $qsize_list $i]
  127. set bw    [lindex $BW_list $i]
  128. set delay [lindex $d_list $i]
  129. set qtype [lindex $qtype_list $i]
  130. if {$quiet == 0} {
  131. puts "$i bandwidth $bw"
  132. }
  133. if {$qsize == 0} { set qsize $pipe}
  134. $ns_ duplex-link [set n($i)] [set n([expr $i +1])] [set bw]Mb [set delay]ms $qtype
  135. $ns_ queue-limit [set n($i)] [set n([expr $i + 1])] $qsize
  136. $ns_ queue-limit [set n([expr $i + 1])] [set n($i)] $qsize
  137. # Give a global handle to the Queues to allow setting the RED paramters
  138. set  l$i   [$ns_ link [set n($i)] [set n([expr $i + 1])]]
  139. set  rl$i  [$ns_ link [set n([expr $i + 1])] [set n($i)]]
  140. set all_links "$all_links [set l$i] [set rl$i] "
  141. global q$i rq$i
  142. set q$i  [[$ns_ link [set n($i)] [set n([expr $i + 1])]] queue]
  143. set rq$i [[$ns_ link [set n([expr $i + 1])] [set n($i)]] queue]
  144. incr i
  145. }
  146. }
  147. TestSuite instproc process-parking-lot-data {what name flows PlotTime} {
  148. global quiet
  149. set tracedFlows $flows
  150. exec rm -f temp.rands
  151. set f [open temp.rands w]
  152. foreach i $tracedFlows {
  153. exec rm -f temp.c temp.out
  154. exec touch temp.c temp.out
  155. set result [exec awk -v PlotTime=$PlotTime -v what=$what {
  156. {
  157. if (($1 == what) && ($2 > PlotTime)) {
  158. print $2, $3 >> "temp.c";
  159. }
  160. }
  161. } ft_red_q$i.tr ]
  162. exec awk -v L=$i 
  163.     {BEGIN {sum=0.0; f=0;} {sum=sum+$2;f=f+1} 
  164.  END {printf("%d %.2gn", L+1, sum/f);} } 
  165.     "temp.c" >> "temp.out"
  166. exec cat temp.out >@ $f
  167. flush $f
  168. }
  169. close $f
  170. if {$quiet == 0} {
  171. exec xgraph -m -x "link ID" -y $name temp.rands &
  172. }
  173. }
  174. TestSuite instproc post-process {what PlotTime} {
  175. global quiet
  176. $self instvar tracedFlows_ src_
  177. exec rm -f temp.rands
  178. set f [open temp.rands w]
  179. foreach i $tracedFlows_ {
  180. exec rm -f temp.c 
  181. exec touch temp.c
  182. set result [exec awk -v PlotTime=$PlotTime -v what=$what {
  183. {
  184. if (($6 == what) && ($1 > PlotTime)) {
  185.     if ((what == "throughput"))
  186.                                         print $1, ($7 * 8) >> "temp.c";
  187.                                     else
  188.                                    print $1, $7 >> "temp.c";
  189. }
  190. }
  191. } xcp$i.tr ]
  192. puts $f "$what$i
  193. exec cat temp.c >@ $f
  194. puts $f "n"
  195. flush $f
  196. }
  197. close $f
  198. if {$quiet == 0} {
  199. exec xgraph -nl -m -x time -y $what temp.rands &
  200. }
  201. }
  202. TestSuite instproc finish {} {
  203. $self instvar ns_ tracefd_ tracedFlows_ src_ qtraces_
  204. if [info exists tracedFlows_] {
  205. foreach i $tracedFlows_ {
  206. set file [[set src_($i)] set tcpTrace_]
  207. if {[info exists file]} {
  208. flush $file
  209. close $file
  210. }
  211. }
  212. }
  213. if {[info exists tracefd_]} {
  214. flush $tracefd_
  215. close $tracefd_
  216. }
  217. if {[info exists qtraces_]} {
  218. foreach file $qtraces_ {
  219. if {[info exists file]} {
  220. flush $file
  221. close $file
  222. }
  223. }
  224. }
  225. $ns_ halt
  226. }
  227. Class GeneralSender  -superclass Agent 
  228. #   otherparams are "startTime TCPclass .."
  229. GeneralSender instproc init { ns id srcnode dstnode otherparams } {
  230. global quiet
  231. $self next
  232. $self instvar tcp_ id_ ftp_ snode_ dnode_ tcp_rcvr_ tcp_type_
  233. set id_ $id
  234. if { [llength $otherparams] > 1 } {
  235. set TCP [lindex $otherparams 1]
  236. } else { 
  237. puts stderr "undefined transport protocol type"
  238. exit 1
  239. }
  240. switch -exact $TCP {
  241. TCP/FullTcp/Newreno/XCP {
  242. set TCPSINK "TCP/FullTcp/Newreno/XCP"
  243. TCP/FullTcp/Newreno {
  244. set TCPSINK "TCP/FullTcp/Newreno"
  245. }
  246. TCP/Reno/XCP {
  247. set TCPSINK "TCPSink/XCPSink"
  248. }
  249. TCP/Reno {
  250. set TCPSINK "TCPSink"
  251. }
  252. default {
  253. puts stderr "unsupported protocol $TCP"
  254. exit 1
  255. }
  256. }
  257. if { [llength $otherparams] > 2 } {
  258. set traffic_type [lindex $otherparams 2]
  259. } else {
  260. set traffic_type FTP
  261. }
  262. set   tcp_type_ $TCP
  263. set   tcp_ [new Agent/$TCP]
  264. set   tcp_rcvr_ [new Agent/$TCPSINK]
  265. $tcp_ set  packetSize_ 1000   
  266. $tcp_ set  segsize_ 1000
  267. $tcp_ set  class_  $id
  268. switch -exact $traffic_type {
  269. FTP {
  270. set traf_ [new Application/FTP]
  271. $traf_ attach-agent $tcp_
  272. }
  273. EXP {
  274. set traf_ [new Application/Traffic/Exponential]
  275. $traf_ set packetSize_ 1000
  276. $traf_ set burst_time_ 250ms
  277. $traf_ set idle_time_ 250ms
  278. $traf_ set rate_ 10Mb
  279. $traf_ attach-agent $tcp_
  280. }
  281. default {
  282. puts "unsupported trafficn"
  283. exit 1
  284. }
  285. }
  286. $ns   attach-agent $srcnode $tcp_
  287. $ns   attach-agent $dstnode $tcp_rcvr_
  288. $ns   connect $tcp_  $tcp_rcvr_
  289.         $tcp_rcvr_ listen;
  290. set   startTime [lindex $otherparams 0]
  291. $ns   at $startTime "$traf_ start"
  292. if {$quiet == 0} {
  293. puts  "initialized Sender $id_ at $startTime"
  294. }
  295. }
  296. GeneralSender instproc trace-xcp parameters {
  297. $self instvar tcp_ id_ tcpTrace_
  298. set ftracetcp$id_ [open  xcp$id_.tr w]
  299. set tcpTrace_ [set ftracetcp$id_]
  300. $tcp_ attach-trace $tcpTrace_
  301. if { -1 < [lsearch $parameters cwnd]  } { $tcp_ tracevar cwnd_ }
  302. if { -1 < [lsearch $parameters seqno] } { $tcp_ tracevar t_seqno_ }
  303. if { -1 < [lsearch $parameters ackno] } { $tcp_ tracevar ack_ }
  304. if { -1 < [lsearch $parameters rtt]  } { $tcp_ tracevar rtt_ }
  305. if { -1 < [lsearch $parameters ssthresh]  } { $tcp_ tracevar ssthresh_ }
  306. if { -1 < [lsearch $parameters throughput]  } { $tcp_ tracevar throughput_ }
  307. }
  308. Class Test/simple-xcp -superclass TestSuite
  309. Test/simple-xcp instproc init {} {
  310. global halfxcp
  311. if { $halfxcp == 0 } { exit 0 }
  312. $self instvar ns_ testName_ qType_ qSize_ BW_ delay_ nXCPs_ 
  313.       SimStopTime_ tracedFlows_
  314.   set testName_ simple-xcp
  315.   set qType_ XCP
  316.   set BW_ 20; # in Mb/s
  317.   set delay_ 10; # in ms
  318.   set qSize_ [expr round([expr ($BW_ / 8.0) * 4 * $delay_])];#set buffer to the pipe size
  319.   set SimStopTime_ 30
  320.   set nXCPs_ 3
  321.   set tracedFlows_ "0 1 2"
  322.   $self next 
  323. }
  324. Test/simple-xcp instproc get-tcpType {} {
  325. return  "TCP/Reno/XCP"
  326. }
  327. Test/simple-xcp instproc run {} {
  328.   global R1 n all_links Bottleneck quiet
  329.   $self instvar ns_ SimStopTime_ nXCPs_ qSize_ delay_ rtg_ 
  330.       tracedFlows_ src_ allchan_
  331.   set numsidelinks 3
  332.   set deltadelay 0.0
  333.   $self create-Bottleneck
  334.   $self create-sidelinks $numsidelinks $deltadelay
  335.   foreach link $all_links {
  336.   set queue [$link queue]
  337.   if {[$queue info class] == "Queue/XCP"} {
  338.   $queue set-link-capacity [[$link set link_] set bandwidth_];  
  339.   }
  340.   }
  341. # added for troubleshooting purposes - Sally
  342. if {$quiet == "false"} {
  343. set allchan_ [open all.tr w]
  344. $ns_ trace-all $allchan_
  345. }
  346.   # Create sources:
  347.   set i 0
  348.   while { $i < $nXCPs_  } {
  349.   set StartTime [expr $i * 10]
  350.   set src_($i) [new GeneralSender $ns_ $i [set n($i)] $R1 "$StartTime [$self get-tcpType]"]
  351. set pktSize_  1000
  352.   [[set src_($i)] set tcp_]  set  packetSize_ $pktSize_
  353. [[set src_($i)] set tcp_]  set   segsize_ $pktSize_
  354.   [[set src_($i)] set tcp_]  set  window_     [expr $qSize_]
  355.   incr i
  356.   }
  357.   # trace bottleneck queue, if needed
  358.   #foreach queue_name "Bottleneck" {
  359. #set queue [set "$queue_name"]
  360. #if {[$queue info class] == "Queue/XCP"} {
  361. # $queue attach $tracefd_
  362.   # } 
  363.   #}
  364.   # trace sources
  365.   foreach i $tracedFlows_ {
  366.   #[set src_($i)] trace-xcp "cwnd"
  367. [set src_($i)] trace-xcp "throughput"
  368.   }
  369. if {$quiet == "false"} {
  370. $ns_ at $SimStopTime_ "close $allchan_"
  371. }
  372.        
  373.   $ns_ at $SimStopTime_ "$self finish"
  374.   $ns_ run
  375.   #$self post-process cwnd_ 0.0
  376.   $self post-process throughput 0.0
  377. }
  378. Class Test/simple-full-xcp -superclass Test/simple-xcp
  379. Test/simple-full-xcp instproc init {} {
  380. global fullxcp
  381. if { $fullxcp == 0 } { exit 0 }
  382.   $self set testName_ simple-full-xcp
  383.   $self next 
  384. }
  385. Test/simple-full-xcp instproc get-tcpType {} {
  386. return  "TCP/FullTcp/Newreno/XCP"
  387. }
  388. #disabled on 05/27/06
  389.  Class Test/xcp-tcp -superclass TestSuite
  390. Test/xcp-tcp instproc init {} {
  391. global halfxcp
  392. if { $halfxcp == 0 } { exit 0 }
  393. $self instvar ns_ testName_ qType_ qSize_ BW_ delay_ nXCPs_ 
  394.     SimStopTime_ tracedFlows_
  395. # set RED parameters for TCP queue
  396. Queue/RED set maxthresh_ [expr 0.8 * [Queue set limit_]]
  397. Queue/RED set thresh_ [expr 0.6 * [Queue set limit_]]
  398. Queue/RED set q_weight_ 0.001
  399. Queue/RED set linterm_ 10
  400. set testName_   xcp-tcp
  401. set qType_ XCP
  402. set BW_ 0; # in Mb/s
  403. set delay_ 10; # in ms
  404. set qSize_      [expr round([expr ($BW_ / 8.0) * 4 * $delay_])];#set buffer to the pipe size
  405. set SimStopTime_   30
  406. set nXCPs_   3
  407. set tracedFlows_   "0 1 2 3"
  408. $self next
  409. }
  410. Test/xcp-tcp instproc run {} {
  411. global R1 n all_links Bottleneck
  412. $self instvar ns_ tracefd_ SimStopTime_ nXCPs_ qSize_ delay_ rtg_ 
  413.     tracedFlows_ src_
  414. Queue/XCP set tcp_xcp_on_ 1
  415. set numsidelinks 4
  416. set deltadelay 0.0
  417. $self create-Bottleneck
  418. $self create-sidelinks $numsidelinks $deltadelay
  419. foreach link $all_links {
  420. set queue [$link queue]
  421. if {[$queue info class] == "Queue/XCP"} {
  422. $queue set-link-capacity [[$link set link_] set bandwidth_];  
  423. }
  424. }
  425. # Create sources:
  426. set i 0
  427. while { $i < $nXCPs_  } {
  428. set StartTime [expr [$rtg_ integer 1000] * 0.001 * (0.01 * $delay_) + $i  * 0.0] 
  429. set src_($i) [new GeneralSender $ns_ $i [set n($i)] $R1 "$StartTime TCP/Reno/XCP"]
  430. set pktSize_              1000
  431. [[set src_($i)] set tcp_]  set  packetSize_ $pktSize_
  432. [[set src_($i)] set tcp_]  set  window_     [expr $qSize_ * 10]
  433. incr i
  434. }
  435. set StartTime [expr [$rtg_ integer 1000] * 0.001 * (0.01 * $delay_) + $i  * 0.0] 
  436. set src_($i) [new GeneralSender $ns_ $i [set n($i)] $R1 "$StartTime TCP/Reno"]
  437. set pktSize_              1000
  438. [[set src_($i)] set tcp_]  set  packetSize_ $pktSize_
  439. [[set src_($i)] set tcp_]  set  window_     [expr $qSize_ * 10]
  440. # trace sources
  441. foreach i $tracedFlows_ {
  442. [set src_($i)] trace-xcp "cwnd"
  443. }
  444. $ns_ at $SimStopTime_ "$self finish"
  445. $ns_ run
  446. $self post-process cwnd_ 0.0
  447. }
  448. #disabled on 05/27/06
  449.  Class Test/parking-lot-topo -superclass TestSuite
  450. # This is a downsized version of Dina's original test. We use around 30 flows
  451. # compared to 300 flows in the original version.
  452. Test/parking-lot-topo instproc init {} {
  453. global halfxcp
  454. if { $halfxcp == 0 } { exit 0 }
  455.     $self instvar ns_ testName_ delay_ BW_list_ qType_list_ delay_list_ qSize_list_ nTCPsPerHop_list_ rTCPs_ nAllHopsTCPs_ qEffective_RTT_ numHops_ SimStopTime_ qSize_
  456.     set testName_   parking-lot-topo
  457.     set qType_ XCP
  458.     set BW_         30;                 #in Mb/s
  459.     set BBW_         [expr $BW_ / 2.0]  ; #BW of bottleneck
  460.     set delay_ 10;                 #in ms
  461.     set qSize_      [expr round([expr ($BW_ / 8.0) * 2.0 * $delay_ * 4.5])];
  462.     set SimStopTime_   20
  463.     set qEffective_RTT_        [expr  20 * $delay_ * 0.001]
  464.     set nAllHopsTCPs_          10
  465.     set numHops_               9
  466.     set BW_list_     " $BW_ $BW_ $BBW_ $BW_ $BW_ $BW_ $BW_ $BW_ $BW_"
  467.     set qType_list_  " $qType_ $qType_  $qType_ $qType_  $qType_ $qType_ $qType_ $qType_ $qType_"
  468.     set delay_list_  "$delay_ $delay_ $delay_ $delay_ $delay_ $delay_ $delay_ $delay_ $delay_"
  469.     set qSize_list_  "$qSize_ $qSize_ $qSize_ $qSize_ $qSize_ $qSize_ $qSize_ $qSize_ $qSize_"
  470.     set nTCPsPerHop_list_     "1 1 1 1 1 1 1 1 1"
  471.     set rTCPs_                1; #traverse all of the reverse path
  472.     $self next
  473. }
  474. Test/parking-lot-topo instproc run {} {
  475. $self instvar ns_ rtg_ numHops_ BW_list_ qType_list_ delay_ delay_list_ qSize_list_ nTCPsPerHop_list_ rTCPs_ nAllHopsTCPs_ qtraces_ qEffective_RTT_ SimStopTime_ qSize_
  476.     global n all_links
  477. #all except the first are lists
  478.     $self create-string-topology $numHops_ $BW_list_ $delay_list_ $qType_list_ $qSize_list_;
  479.      #set BW for xcp queue
  480.     foreach link $all_links {
  481.     set queue [$link queue]
  482.     if {[$queue info class] == "Queue/XCP"} {
  483.     $queue set-link-capacity [[$link set link_] set bandwidth_];  
  484.     }
  485.     }
  486. #Create sources: 1) Long TCPs
  487.     set i 0
  488.     while { $i < $nAllHopsTCPs_  } {
  489.     set StartTime     [expr [$rtg_ integer 1000] * 0.001 * (0.01 * $numHops_ * $delay_)] 
  490.     set src_($i)      [new GeneralSender $ns_ $i $n(0) [set n($numHops_)] "$StartTime TCP/Reno/XCP"]
  491.     [[set src_($i)] set tcp_]  set  window_     [expr $qSize_ * 10]
  492.     incr i
  493.     }
  494.      #2) jth Hop TCPs; start at j*1000
  495.     set i 0;
  496.     while {$i < $numHops_} {
  497.     set j [expr (1000 * $i) + 1000 ]; 
  498.     while { $j < [expr [lindex $nTCPsPerHop_list_ $i] + ($i + 1) * 1000]  } {
  499.     set StartTime     [expr [$rtg_ integer 1000] * 0.001 * (0.01 * $numHops_ * $delay_)] 
  500.     set src_($j)      [new GeneralSender $ns_ $j [set n($i)] [set n([expr $i+1])] "$StartTime TCP/Reno/XCP"]
  501.     [[set src_($j)] set tcp_] set window_ [expr $qSize_ * 10]
  502.     incr j
  503.     }
  504.     incr i    }
  505.      #3) reverse TCP; ids follow directly allhops TCPs
  506.     set i 0
  507.     while {$i < $numHops_} {
  508.     set l 0
  509.     while { $l < $rTCPs_} {
  510.     set s [expr $l + $nAllHopsTCPs_ + ( $i * $rTCPs_ ) ] 
  511.     set StartTime     [expr [$rtg_ integer 1000] * 0.001 * (0.01 * $numHops_ * $delay_)+ 0.0] 
  512.     set src_($s)      [new GeneralSender $ns_ $s [set n([expr $i + 1])] [set n($i)] "$StartTime TCP/Reno/XCP"]
  513.     [[set src_($s)] set tcp_] set window_ [expr $qSize_ * 10]
  514.     incr l
  515.     }
  516.     incr i
  517.     }
  518.      #Trace Queues
  519.     set i 0;
  520.     while { $i < $numHops_ } {
  521.     set qtype [lindex $qType_list_ $i]
  522.     global q$i rq$i
  523.     foreach queue_name "q$i rq$i" {
  524.     set queue [set "$queue_name"]
  525.     switch $qtype {
  526.     "XCP" {
  527.     set qtrace [open ft_red_[set queue_name].tr w]
  528.     $queue attach $qtrace
  529. lappend qtraces_ $qtrace
  530.     }
  531.     }
  532.     }
  533.   #sample parameters at queue at a given time interval of qeffective_RTT
  534.     foreach queue_name "q$i" {
  535.     set queue [set "$queue_name"]
  536.     $queue queue-sample-everyrtt $qEffective_RTT_
  537.     }
  538.     incr i
  539.     }
  540.     $ns_ at $SimStopTime_ "$self finish"
  541.     $ns_ run
  542.     set flows "0 1 2 3 4 5 6 7 8"
  543. #use utilization as validation output
  544. $self process-parking-lot-data "u" "Utilization" $flows 0.0
  545. #$self process-parking-lot-data "q" "Average Queue" $flows 0.0
  546. }
  547. proc runtest {arg} {
  548. global quiet
  549. set quiet 0
  550. set b [llength $arg]
  551. if {$b == 1} {
  552. set test $arg
  553. } elseif {$b == 2} {
  554. set test [lindex $arg 0]
  555. if {[lindex $arg 1] == "QUIET"} {
  556. set quiet 1
  557. }
  558. } else {
  559. usage
  560. }
  561. set t [new Test/$test]
  562. $t run
  563. }
  564. global argv arg0
  565. runtest $argv