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

通讯编程

开发平台:

Visual C++

  1. #
  2. Agent/TCP set tcpTick_ 0.1
  3. # The default for tcpTick_ is being changed to reflect a changing reality.
  4. Agent/TCP set rfc2988_ false
  5. # The default for rfc2988_ is being changed to true.
  6. # FOR UPDATING GLOBAL DEFAULTS:
  7. Agent/TCP set precisionReduce_ false ;   # default changed on 2006/1/24.
  8. Agent/TCP set rtxcur_init_ 6.0 ;      # Default changed on 2006/01/21
  9. Agent/TCP set updated_rttvar_ false ;  # Variable added on 2006/1/21
  10. Agent/TCP set minrto_ 1
  11. # default changed on 10/14/2004.
  12. Agent/TCP set useHeaders_ false
  13. # The default is being changed to useHeaders_ true.
  14. Agent/TCP set windowInit_ 1
  15. # The default is being changed to 2.
  16. Agent/TCP set singledup_ 0
  17. # The default is being changed to 1
  18. Agent/TCP set SetCWRonRetransmit_ true
  19. # Changing the default value.
  20. #
  21. # Copyright (c) 1999 Regents of the University of California.
  22. # All rights reserved.
  23. #
  24. # Redistribution and use in source and binary forms, with or without
  25. # modification, are permitted provided that the following conditions
  26. # are met:
  27. # 1. Redistributions of source code must retain the above copyright
  28. #    notice, this list of conditions and the following disclaimer.
  29. # 2. Redistributions in binary form must reproduce the above copyright
  30. #    notice, this list of conditions and the following disclaimer in the
  31. #    documentation and/or other materials provided with the distribution.
  32. # 3. All advertising materials mentioning features or use of this software
  33. #    must display the following acknowledgement:
  34. #       This product includes software developed by the MASH Research
  35. #       Group at the University of California Berkeley.
  36. # 4. Neither the name of the University nor of the Research Group may be
  37. #    used to endorse or promote products derived from this software without
  38. #    specific prior written permission.
  39. #
  40. # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  41. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  44. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. # SUCH DAMAGE.
  51. #    
  52. # @(#) $Header: /cvsroot/nsnam/ns-2/tcl/test/test-suite-satellite.tcl,v 1.12 2006/01/24 23:00:07 sallyfloyd Exp $
  53. #
  54. # Contributed by Tom Henderson, UCB Daedalus Research Group, June 1999
  55. #    
  56. # This test suite is for validating the satellite extensions
  57. #
  58. # To run all tests:  test-all-satellite
  59. #
  60. # To run individual tests:
  61. # ns test-suite-satellite.tcl mixed 
  62. # ns test-suite-satellite.tcl mixed.legacy 
  63. # ns test-suite-satellite.tcl repeater
  64. # ns test-suite-satellite.tcl aloha
  65. # ns test-suite-satellite.tcl aloha.collisions
  66. # ns test-suite-satellite.tcl wired 
  67. #
  68. #
  69. # To view a list of available tests to run with this script:
  70. # ns test-suite-satellite.tcl
  71. #
  72. Agent/TCP set syn_ false
  73. Agent/TCP set delay_growth_ false
  74. # In preparation for changing the default values for syn_ and delay_growth_.
  75. # Some OTcl bound variables
  76. HandoffManager/Term set elevation_mask_ 8.2
  77. HandoffManager/Term set term_handoff_int_ 10
  78. HandoffManager set handoff_randomization_ "false"
  79. Mac/Sat/UnslottedAloha set mean_backoff_ 1s 
  80. Mac/Sat/UnslottedAloha set rtx_limit_ 3
  81. Mac/Sat/UnslottedAloha set send_timeout_ 270ms
  82. Class TestSuite
  83. TestSuite instproc init {} {
  84. $self instvar ns_ test_ topo_ node_ 
  85. set ns_ [new Simulator]
  86. $ns_ rtproto Dummy
  87. global f
  88. set f [open temp.rands w]
  89. $ns_ trace-all $f
  90. }
  91. TestSuite instproc finish args {
  92. $self instvar ns_
  93. $ns_ flush-trace
  94. exit 0
  95. }
  96. proc usage {} {
  97. global argv0
  98. puts stderr "usage: ns $argv0 <tests> "
  99. puts stderr "Valid tests are:t[get-subclasses TestSuite Test/]"
  100. exit 1
  101. }
  102. proc isProc? {cls prc} {
  103. if [catch "Object info subclass $cls/$prc" r] {
  104. global argv0
  105. puts stderr "$argv0: no such $cls: $prc"
  106. usage
  107. }
  108. }
  109. proc get-subclasses {cls pfx} {
  110. set ret ""
  111. set l [string length $pfx]
  112. set c $cls
  113. while {[llength $c] > 0} {
  114. set t [lindex $c 0]
  115. set c [lrange $c 1 end]
  116. if [string match ${pfx}* $t] {
  117. lappend ret [string range $t $l end]
  118. }
  119. eval lappend c [$t info subclass]
  120. }
  121. set ret
  122. }
  123. TestSuite proc runTest {} {
  124. global argc argv
  125. switch $argc {
  126. 1 {
  127. set test $argv
  128. isProc? Test $test
  129. }
  130. 2 {
  131. set test [lindex $argv 0]
  132. isProc? Test $test
  133. set a [lindex $argv 1]
  134. }
  135. default {
  136. usage
  137. }
  138. }
  139. set t [new Test/$test]
  140. $t run
  141. }
  142. # Global configuration parameters
  143. global opt
  144. set opt(chan)           Channel/Sat
  145. set opt(bw_up)          2Mb; # Uplink bandwidth
  146. set opt(bw_down)        2Mb; # Downlink bandwidth
  147. set opt(phy)            Phy/Sat
  148. set opt(mac)            Mac/Sat
  149. set opt(ifq)            Queue/DropTail
  150. set opt(qlim)           50
  151. set opt(ll)             LL/Sat
  152. # Definition of test-suite tests
  153. # Simple bent-pipe (repeater) satellite
  154. # NOTE:  This test is identical to sat-repeater.tcl in ~ns/tcl/ex
  155. Class Test/repeater -superclass TestSuite
  156. Test/repeater instproc init {} {
  157. $self instvar test_ 
  158. set test_ repeater
  159. $self next
  160. }
  161. Test/repeater instproc run {} {
  162. $self instvar ns_ node_ 
  163. global opt f
  164. set opt(wiredRouting)   OFF
  165. # GEO satellite at 95 degrees longitude West
  166. $ns_ node-config -satNodeType geo-repeater 
  167. -llType $opt(ll) 
  168. -ifqType $opt(ifq) 
  169. -ifqLen $opt(qlim) 
  170. -macType $opt(mac) 
  171. -phyType $opt(phy) 
  172. -channelType $opt(chan) 
  173. -downlinkBW $opt(bw_down) 
  174. -wiredRouting $opt(wiredRouting)
  175. set n1 [$ns_ node]
  176. $n1 set-position -95
  177. # Two terminals: one in NY and one in SF 
  178. $ns_ node-config -satNodeType terminal
  179. set n2 [$ns_ node] 
  180. $n2 set-position 40.9 -73.9; # NY
  181. set n3 [$ns_ node] 
  182. $n3 set-position 37.8 -122.4; # SF
  183. # Add GSLs to geo satellites
  184. $n2 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  185.             $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
  186. $n3 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up)  
  187.     $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
  188. # Add an error model to the receiving terminal node
  189. set em_ [new ErrorModel]
  190. $em_ unit pkt 
  191. $em_ set rate_ 0.02
  192. $em_ ranvar [new RandomVariable/Uniform] 
  193. $n3 interface-errormodel $em_
  194. $ns_ trace-all-satlinks $f
  195. # Attach agents for CBR traffic generator
  196. set udp0 [new Agent/UDP] 
  197. $ns_ attach-agent $n2 $udp0
  198. set cbr0 [new Application/Traffic/CBR]
  199. $cbr0 attach-agent $udp0
  200. $cbr0 set interval_ 6
  201. set null0 [new Agent/Null]
  202. $ns_ attach-agent $n3 $null0
  203.  
  204. $ns_ connect $udp0 $null0
  205. # Attach agents for FTP
  206. set tcp1 [$ns_ create-connection TCP $n2 TCPSink $n3 0]
  207. set ftp1 [$tcp1 attach-app FTP]
  208. $ns_ at 7.0 "$ftp1 produce 100"
  209. # We use centralized routing
  210. set satrouteobject_ [new SatRouteObject]
  211. $satrouteobject_ compute_routes
  212. $ns_ at 1.0 "$cbr0 start"
  213. $ns_ at 100.0 "$self finish"   
  214. $ns_ run
  215. }
  216. # Testing a geo satellite and a plane of polar satellites
  217. # NOTE:  This test is identical to sat-mixed.tcl in ~ns/tcl/ex
  218. Class Test/mixed -superclass TestSuite
  219. Test/mixed instproc init {} {
  220. $self instvar test_
  221. set test_       mixed 
  222. $self next
  223. }
  224. Test/mixed instproc run {} {
  225. $self instvar ns_  
  226. global opt f
  227. # Change some of the options
  228. set opt(bw_down)        1.5Mb
  229. set opt(bw_up)          1.5Mb
  230. set opt(bw_isl)         25Mb
  231. set opt(alt)            780
  232. set opt(inc)            90
  233. set opt(wiredRouting)   OFF
  234. $ns_ node-config -satNodeType polar 
  235.  -llType $opt(ll) 
  236.  -ifqType $opt(ifq) 
  237.  -ifqLen $opt(qlim) 
  238.  -macType $opt(mac) 
  239.  -phyType $opt(phy) 
  240.  -channelType $opt(chan) 
  241.  -downlinkBW $opt(bw_down) 
  242.  -wiredRouting $opt(wiredRouting)
  243. set n0 [$ns_ node]; set n1 [$ns_ node]; set n2 [$ns_ node];
  244. set n3 [$ns_ node]; set n4 [$ns_ node]; set n5 [$ns_ node];
  245. set n6 [$ns_ node]; set n7 [$ns_ node]; set n8 [$ns_ node];
  246. set n9 [$ns_ node]; set n10 [$ns_ node]
  247. set plane 1
  248. $n0 set-position $opt(alt) $opt(inc) 0 0 $plane 
  249. $n1 set-position $opt(alt) $opt(inc) 0 32.73 $plane 
  250. $n2 set-position $opt(alt) $opt(inc) 0 65.45 $plane 
  251. $n3 set-position $opt(alt) $opt(inc) 0 98.18 $plane 
  252. $n4 set-position $opt(alt) $opt(inc) 0 130.91 $plane 
  253. $n5 set-position $opt(alt) $opt(inc) 0 163.64 $plane 
  254. $n6 set-position $opt(alt) $opt(inc) 0 196.36 $plane 
  255. $n7 set-position $opt(alt) $opt(inc) 0 229.09 $plane 
  256. $n8 set-position $opt(alt) $opt(inc) 0 261.82 $plane 
  257. $n9 set-position $opt(alt) $opt(inc) 0 294.55 $plane 
  258. $n10 set-position $opt(alt) $opt(inc) 0 327.27 $plane 
  259. # By setting the next_ variable on polar sats; handoffs can be optimized
  260. # This step must follow all polar node creation
  261. $n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2
  262. $n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6
  263. $n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9
  264. # GEO satellite:  above North America
  265. $ns_ node-config -satNodeType geo
  266. set n11 [$ns_ node]
  267. $n11 set-position -100
  268. # Terminals
  269. $ns_ node-config -satNodeType terminal
  270. set n100 [$ns_ node]; set n101 [$ns_ node]
  271. $n100 set-position 37.9 -122.3; # Berkeley
  272. $n101 set-position 42.3 -71.1; # Boston
  273. set n200 [$ns_ node]; set n201 [$ns_ node]
  274. $n200 set-position 0 10
  275. $n201 set-position 0 -10
  276. # Add any necessary ISLs or GSLs
  277. # GSLs to the geo satellite:
  278. $n100 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  279.   $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
  280. $n101 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  281.   $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
  282. # Attach n200 and n201 
  283. $n200 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
  284. $n201 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
  285. #ISL
  286. $ns_ add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)
  287. $ns_ add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)
  288. $ns_ add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)
  289. $ns_ add-isl intraplane $n3 $n4 $opt(bw_isl) $opt(ifq) $opt(qlim)
  290. $ns_ add-isl intraplane $n4 $n5 $opt(bw_isl) $opt(ifq) $opt(qlim)
  291. $ns_ add-isl intraplane $n5 $n6 $opt(bw_isl) $opt(ifq) $opt(qlim)
  292. $ns_ add-isl intraplane $n6 $n7 $opt(bw_isl) $opt(ifq) $opt(qlim)
  293. $ns_ add-isl intraplane $n7 $n8 $opt(bw_isl) $opt(ifq) $opt(qlim)
  294. $ns_ add-isl intraplane $n8 $n9 $opt(bw_isl) $opt(ifq) $opt(qlim)
  295. $ns_ add-isl intraplane $n9 $n10 $opt(bw_isl) $opt(ifq) $opt(qlim)
  296. $ns_ add-isl intraplane $n10 $n0 $opt(bw_isl) $opt(ifq) $opt(qlim)
  297. # Trace all queues
  298. $ns_ trace-all-satlinks $f
  299. # Attach agents
  300. set udp0 [new Agent/UDP]
  301. $ns_ attach-agent $n100 $udp0
  302. set cbr0 [new Application/Traffic/CBR]
  303. $cbr0 attach-agent $udp0
  304. $cbr0 set interval_ 60.01
  305. set udp1 [new Agent/UDP]
  306. $ns_ attach-agent $n200 $udp1
  307. $udp1 set class_ 1
  308. set cbr1 [new Application/Traffic/CBR]
  309. $cbr1 attach-agent $udp1
  310. $cbr1 set interval_ 90.5
  311. set null0 [new Agent/Null]
  312. $ns_ attach-agent $n101 $null0
  313. set null1 [new Agent/Null]
  314. $ns_ attach-agent $n201 $null1
  315. $ns_ connect $udp0 $null0
  316. $ns_ connect $udp1 $null1
  317. set satrouteobject_ [new SatRouteObject]
  318. $satrouteobject_ compute_routes
  319. $ns_ at 1.0 "$cbr0 start"
  320. $ns_ at 305.0 "$cbr1 start"
  321. $ns_ at 9000.0 "$self finish"
  322. $ns_ run
  323. }
  324. # Same as mixed, but with wired-satellite integration
  325. # NOTE:  This test is identical to sat-wired.tcl in ~ns/tcl/ex
  326. Class Test/wired -superclass TestSuite
  327. Test/wired instproc init {} {
  328. $self instvar test_
  329. set test_       wired 
  330. $self next
  331. }
  332. Test/wired instproc run {} {
  333. $self instvar ns_  
  334. global opt f
  335. # Change some of the options
  336. set opt(bw_down)        1.5Mb
  337. set opt(bw_up)          1.5Mb
  338. set opt(bw_isl)         25Mb
  339. set opt(alt)            780
  340. set opt(inc)            90
  341. set opt(wiredRouting)  ON
  342. $ns_ node-config -satNodeType polar 
  343.  -llType $opt(ll) 
  344.  -ifqType $opt(ifq) 
  345.  -ifqLen $opt(qlim) 
  346.  -macType $opt(mac) 
  347.  -phyType $opt(phy) 
  348.  -channelType $opt(chan) 
  349.  -downlinkBW $opt(bw_down) 
  350.  -wiredRouting $opt(wiredRouting)
  351. set n0 [$ns_ node]; set n1 [$ns_ node]; set n2 [$ns_ node];
  352. set n3 [$ns_ node]; set n4 [$ns_ node]; set n5 [$ns_ node];
  353. set n6 [$ns_ node]; set n7 [$ns_ node]; set n8 [$ns_ node];
  354. set n9 [$ns_ node]; set n10 [$ns_ node]
  355. set plane 1
  356. $n0 set-position $opt(alt) $opt(inc) 0 0 $plane 
  357. $n1 set-position $opt(alt) $opt(inc) 0 32.73 $plane 
  358. $n2 set-position $opt(alt) $opt(inc) 0 65.45 $plane 
  359. $n3 set-position $opt(alt) $opt(inc) 0 98.18 $plane 
  360. $n4 set-position $opt(alt) $opt(inc) 0 130.91 $plane 
  361. $n5 set-position $opt(alt) $opt(inc) 0 163.64 $plane 
  362. $n6 set-position $opt(alt) $opt(inc) 0 196.36 $plane 
  363. $n7 set-position $opt(alt) $opt(inc) 0 229.09 $plane 
  364. $n8 set-position $opt(alt) $opt(inc) 0 261.82 $plane 
  365. $n9 set-position $opt(alt) $opt(inc) 0 294.55 $plane 
  366. $n10 set-position $opt(alt) $opt(inc) 0 327.27 $plane 
  367. # By setting the next_ variable on polar sats; handoffs can be optimized
  368. # This step must follow all polar node creation
  369. $n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2
  370. $n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6
  371. $n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9
  372. # GEO satellite:  above North America
  373. $ns_ node-config -satNodeType geo
  374. set n11 [$ns_ node]
  375. $n11 set-position -100
  376. # Terminals
  377. $ns_ node-config -satNodeType terminal
  378. set n100 [$ns_ node]; set n101 [$ns_ node]
  379. $n100 set-position 37.9 -122.3; # Berkeley
  380. $n101 set-position 42.3 -71.1; # Boston
  381. set n200 [$ns_ node]; set n201 [$ns_ node]
  382. $n200 set-position 0 10
  383. $n201 set-position 0 -10
  384. # Add any necessary ISLs or GSLs
  385. # GSLs to the geo satellite:
  386. $n100 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  387.   $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
  388. $n101 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  389.   $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
  390. # Attach n200 and n201 
  391. $n200 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
  392. $n201 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
  393. #ISL
  394. $ns_ add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)
  395. $ns_ add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)
  396. $ns_ add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)
  397. $ns_ add-isl intraplane $n3 $n4 $opt(bw_isl) $opt(ifq) $opt(qlim)
  398. $ns_ add-isl intraplane $n4 $n5 $opt(bw_isl) $opt(ifq) $opt(qlim)
  399. $ns_ add-isl intraplane $n5 $n6 $opt(bw_isl) $opt(ifq) $opt(qlim)
  400. $ns_ add-isl intraplane $n6 $n7 $opt(bw_isl) $opt(ifq) $opt(qlim)
  401. $ns_ add-isl intraplane $n7 $n8 $opt(bw_isl) $opt(ifq) $opt(qlim)
  402. $ns_ add-isl intraplane $n8 $n9 $opt(bw_isl) $opt(ifq) $opt(qlim)
  403. $ns_ add-isl intraplane $n9 $n10 $opt(bw_isl) $opt(ifq) $opt(qlim)
  404. $ns_ add-isl intraplane $n10 $n0 $opt(bw_isl) $opt(ifq) $opt(qlim)
  405. # Set up wired nodes
  406. # Connect $n300<->$n301<->$n302<->$n100<->$n11<->$n101<->$n303
  407. #                    ^               ^
  408. #                    |_______________|
  409. #
  410. # Packets from n303 to n300 should bypass n302 (node #18 in the trace)
  411. # (i.e., they should take the following path:  19,13,11,12,17,16)
  412. #
  413. $ns_ unset satNodeType_
  414. set n300 [$ns_ node]; # node 16 in trace
  415. set n301 [$ns_ node]; # node 17 in trace
  416. set n302 [$ns_ node]; # node 18 in trace
  417. set n303 [$ns_ node]; # node 19 in trace
  418. $ns_ duplex-link $n300 $n301 5Mb 2ms DropTail; # 16 <-> 17
  419. $ns_ duplex-link $n301 $n302 5Mb 2ms DropTail; # 17 <-> 18
  420. $ns_ duplex-link $n302 $n100 5Mb 2ms DropTail; # 18 <-> 11
  421. $ns_ duplex-link $n303 $n101 5Mb 2ms DropTail; # 19 <-> 13
  422. $ns_ duplex-link $n301 $n100 5Mb 2ms DropTail; # 17 <-> 11
  423. # Trace all queues
  424. $ns_ trace-all-satlinks $f
  425. # Attach agents
  426. set udp0 [new Agent/UDP]
  427. $ns_ attach-agent $n100 $udp0
  428. set cbr0 [new Application/Traffic/CBR]
  429. $cbr0 attach-agent $udp0
  430. $cbr0 set interval_ 60.01
  431. set udp1 [new Agent/UDP]
  432. $ns_ attach-agent $n200 $udp1
  433. $udp1 set class_ 1
  434. set cbr1 [new Application/Traffic/CBR]
  435. $cbr1 attach-agent $udp1
  436. $cbr1 set interval_ 90.5
  437. set null0 [new Agent/Null]
  438. $ns_ attach-agent $n101 $null0
  439. set null1 [new Agent/Null]
  440. $ns_ attach-agent $n201 $null1
  441. $ns_ connect $udp0 $null0
  442. $ns_ connect $udp1 $null1
  443. # Set up connection between wired nodes
  444. set udp2 [new Agent/UDP]
  445. $ns_ attach-agent $n303 $udp2
  446. set cbr2 [new Application/Traffic/CBR]
  447. $cbr2 attach-agent $udp2
  448. $cbr2 set interval_ 300
  449. set null2 [new Agent/Null]
  450. $ns_ attach-agent $n300 $null2
  451. $ns_ connect $udp2 $null2
  452. $ns_ at 10.0 "$cbr2 start"
  453.  
  454. set satrouteobject_ [new SatRouteObject]
  455. $satrouteobject_ compute_routes
  456. $ns_ at 1.0 "$cbr0 start"
  457. $ns_ at 305.0 "$cbr1 start"
  458. $ns_ at 9000.0 "$self finish"
  459. $ns_ run
  460. }
  461. # Testing unslotted aloha
  462. # bent-pipe gka geo satellite and a plane of polar satellites
  463. # NOTE:  This test is similar (fewer sources) to sat-aloha.tcl in ~ns/tcl/ex
  464. Class Test/aloha -superclass TestSuite
  465. Test/aloha instproc init {} {
  466. $self instvar test_
  467. set test_  aloha
  468. $self next
  469. }
  470. Test/aloha instproc run {} {
  471.     $self instvar ns_  
  472. global opt f 
  473. Mac/Sat set trace_drops_ false
  474. Mac/Sat set trace_collisions_ false
  475. set opt(bw_up)          2Mb
  476. set opt(bw_down)        2Mb
  477. set opt(mac)            Mac/Sat/UnslottedAloha 
  478. set opt(wiredRouting)   OFF
  479. $ns_ node-config -satNodeType geo-repeater 
  480. -llType $opt(ll) 
  481. -ifqType $opt(ifq) 
  482. -ifqLen $opt(qlim) 
  483. -macType $opt(mac) 
  484. -phyType $opt(phy) 
  485. -channelType $opt(chan) 
  486. -downlinkBW $opt(bw_down) 
  487. -wiredRouting $opt(wiredRouting)
  488. # GEO satellite at prime meridian
  489. set n1 [$ns_ node]
  490. $n1 set-position 0
  491. # Place 30 nodes at 30 different locations
  492. $ns_ node-config -satNodeType terminal
  493. set num_nodes           30
  494. for {set a 1} {$a <= $num_nodes} {incr a} {
  495. set n($a) [$ns_ node]
  496.          $n($a) set-position [expr -15 + $a ] [expr 15 - $a ]
  497.          $n($a) add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) 
  498.     $opt(bw_up) $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
  499. }
  500. for {set a 1} {$a <= $num_nodes} {incr a} {
  501.          set b [expr int($a + (0.5 * $num_nodes))]
  502.          if {$b > 30} {
  503.                  incr b -30 
  504.          }
  505.          set udp($a) [new Agent/UDP]
  506.          $ns_ attach-agent $n($a) $udp($a)
  507.          set exp($a) [new Application/Traffic/Exponential]
  508.          $exp($a) attach-agent $udp($a)
  509.          $exp($a) set rate_ 3Kb
  510.          set null($a) [new Agent/Null]
  511.          $ns_ attach-agent $n($b) $null($a)
  512.          $ns_ connect $udp($a) $null($a)
  513.          $ns_ at 1.0 "$exp($a) start"
  514. }
  515. $ns_ trace-all-satlinks $f
  516. # We use centralized routing
  517. set satrouteobject_ [new SatRouteObject]
  518. $satrouteobject_ compute_routes
  519. $ns_ at 50.0 "$self finish"
  520. $ns_ run
  521. }
  522. Class Test/aloha.collisions -superclass TestSuite
  523. Test/aloha.collisions instproc init {} {
  524. $self instvar test_
  525. set test_  aloha
  526. $self next
  527. }
  528. Test/aloha.collisions instproc run {} {
  529.     $self instvar ns_  
  530. global opt f 
  531. Mac/Sat set trace_drops_ true
  532. Mac/Sat set trace_collisions_ true
  533. set opt(bw_up)          2Mb
  534. set opt(bw_down)        2Mb
  535. set opt(mac)            Mac/Sat/UnslottedAloha 
  536. set opt(wiredRouting)   OFF
  537. $ns_ node-config -satNodeType geo-repeater 
  538. -llType $opt(ll) 
  539. -ifqType $opt(ifq) 
  540. -ifqLen $opt(qlim) 
  541. -macType $opt(mac) 
  542. -phyType $opt(phy) 
  543. -channelType $opt(chan) 
  544. -downlinkBW $opt(bw_down) 
  545. -wiredRouting $opt(wiredRouting)
  546. # GEO satellite at prime meridian
  547. set n1 [$ns_ node]
  548. $n1 set-position 0
  549. # Place 30 nodes at 30 different locations
  550. $ns_ node-config -satNodeType terminal
  551. set num_nodes           30
  552. for {set a 1} {$a <= $num_nodes} {incr a} {
  553. set n($a) [$ns_ node]
  554.          $n($a) set-position [expr -15 + $a ] [expr 15 - $a ]
  555.          $n($a) add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) 
  556.     $opt(bw_up) $opt(phy) [$n1 set downlink_] [$n1 set uplink_]
  557. }
  558. for {set a 1} {$a <= $num_nodes} {incr a} {
  559.          set b [expr int($a + (0.5 * $num_nodes))]
  560.          if {$b > 30} {
  561.                  incr b -30 
  562.          }
  563.          set udp($a) [new Agent/UDP]
  564.          $ns_ attach-agent $n($a) $udp($a)
  565.          set exp($a) [new Application/Traffic/Exponential]
  566.          $exp($a) attach-agent $udp($a)
  567.          $exp($a) set rate_ 3Kb
  568.          set null($a) [new Agent/Null]
  569.          $ns_ attach-agent $n($b) $null($a)
  570.          $ns_ connect $udp($a) $null($a)
  571.          $ns_ at 1.0 "$exp($a) start"
  572. }
  573. $ns_ trace-all-satlinks $f
  574. # We use centralized routing
  575. set satrouteobject_ [new SatRouteObject]
  576. $satrouteobject_ compute_routes
  577. $ns_ at 50.0 "$self finish"
  578. $ns_ run
  579. }
  580. # Backward compatibility syntax (legacy code) for "mixed"
  581. Class Test/mixed.legacy -superclass TestSuite
  582. Test/mixed.legacy instproc init {} {
  583. $self instvar test_
  584. set test_       mixed.legacy 
  585. $self next
  586. }
  587. Test/mixed.legacy instproc run {} {
  588. $self instvar ns_  
  589. global opt f
  590. # Change some of the options
  591. set opt(bw_down)        1.5Mb
  592. set opt(bw_up)          1.5Mb
  593. set opt(bw_isl)         25Mb
  594. set opt(mac)            Mac/Sat 
  595. set opt(alt)            780
  596. set opt(inc)            90
  597. set linkargs "$opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_down) $opt(phy)"
  598. set alt $opt(alt)
  599. set inc $opt(inc)
  600. set chan $opt(chan)
  601. set plane 1
  602. set n0 [$ns_ satnode-polar $alt $inc 0 0 $plane $linkargs $chan]
  603. set n1 [$ns_ satnode-polar $alt $inc 0 32.73 $plane $linkargs $chan]
  604. set n2 [$ns_ satnode-polar $alt $inc 0 65.45 $plane $linkargs $chan]
  605. set n3 [$ns_ satnode-polar $alt $inc 0 98.18 $plane $linkargs $chan]
  606. set n4 [$ns_ satnode-polar $alt $inc 0 130.91 $plane $linkargs $chan]
  607. set n5 [$ns_ satnode-polar $alt $inc 0 163.64 $plane $linkargs $chan]
  608. set n6 [$ns_ satnode-polar $alt $inc 0 196.36 $plane $linkargs $chan]
  609. set n7 [$ns_ satnode-polar $alt $inc 0 229.09 $plane $linkargs $chan]
  610. set n8 [$ns_ satnode-polar $alt $inc 0 261.82 $plane $linkargs $chan]
  611. set n9 [$ns_ satnode-polar $alt $inc 0 294.55 $plane $linkargs $chan]
  612. set n10 [$ns_ satnode-polar $alt $inc 0 327.27 $plane $linkargs $chan]
  613. # By setting the next_ variable on polar sats; handoffs can be optimized
  614. # This step must follow all polar node creation
  615. $n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2
  616. $n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6
  617. $n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9
  618. # GEO satellite:  above North America
  619. set n11 [$ns_ satnode-geo -100 $linkargs $opt(chan)]
  620. # Terminals
  621. set n100 [$ns_ satnode-terminal 37.9 -122.3]; # Berkeley
  622. set n101 [$ns_ satnode-terminal 42.3 -71.1]; # Boston
  623. set n200 [$ns_ satnode-terminal 0 10]
  624. set n201 [$ns_ satnode-terminal 0 -10]
  625. # Add any necessary ISLs or GSLs
  626. # GSLs to the geo satellite:
  627. $n100 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  628.   $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
  629. $n101 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  630.   $opt(phy) [$n11 set downlink_] [$n11 set uplink_]
  631. # Attach n200 and n201 
  632. $n200 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
  633. $n201 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) $opt(phy) [$n5 set downlink_] [$n5 set uplink_]
  634. #ISL
  635. $ns_ add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)
  636. $ns_ add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)
  637. $ns_ add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)
  638. $ns_ add-isl intraplane $n3 $n4 $opt(bw_isl) $opt(ifq) $opt(qlim)
  639. $ns_ add-isl intraplane $n4 $n5 $opt(bw_isl) $opt(ifq) $opt(qlim)
  640. $ns_ add-isl intraplane $n5 $n6 $opt(bw_isl) $opt(ifq) $opt(qlim)
  641. $ns_ add-isl intraplane $n6 $n7 $opt(bw_isl) $opt(ifq) $opt(qlim)
  642. $ns_ add-isl intraplane $n7 $n8 $opt(bw_isl) $opt(ifq) $opt(qlim)
  643. $ns_ add-isl intraplane $n8 $n9 $opt(bw_isl) $opt(ifq) $opt(qlim)
  644. $ns_ add-isl intraplane $n9 $n10 $opt(bw_isl) $opt(ifq) $opt(qlim)
  645. $ns_ add-isl intraplane $n10 $n0 $opt(bw_isl) $opt(ifq) $opt(qlim)
  646. # Trace all queues
  647. $ns_ trace-all-satlinks $f
  648. # Attach agents
  649. set udp0 [new Agent/UDP]
  650. $ns_ attach-agent $n100 $udp0
  651. set cbr0 [new Application/Traffic/CBR]
  652. $cbr0 attach-agent $udp0
  653. $cbr0 set interval_ 60.01
  654. set udp1 [new Agent/UDP]
  655. $ns_ attach-agent $n200 $udp1
  656. $udp1 set class_ 1
  657. set cbr1 [new Application/Traffic/CBR]
  658. $cbr1 attach-agent $udp1
  659. $cbr1 set interval_ 90.5
  660. set null0 [new Agent/Null]
  661. $ns_ attach-agent $n101 $null0
  662. set null1 [new Agent/Null]
  663. $ns_ attach-agent $n201 $null1
  664. $ns_ connect $udp0 $null0
  665. $ns_ connect $udp1 $null1
  666. set satrouteobject_ [new SatRouteObject]
  667. $satrouteobject_ compute_routes
  668. $ns_ at 1.0 "$cbr0 start"
  669. $ns_ at 305.0 "$cbr1 start"
  670. $ns_ at 9000.0 "$self finish"
  671. $ns_ run
  672. }
  673. TestSuite runTest