sat-teledesic.tcl
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:6k
源码类别:

通讯编程

开发平台:

Visual C++

  1. #
  2. # Copyright (c) 1999 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 MASH Research
  16. #       Group at the University of California Berkeley.
  17. # 4. Neither the name of the University nor of the Research Group may be
  18. #    used 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. # Contributed by Tom Henderson, UCB Daedalus Research Group, June 1999
  34. #
  35. # $Header: /cvsroot/nsnam/ns-2/tcl/ex/sat-teledesic.tcl,v 1.5 2002/06/12 04:43:13 tomh Exp $
  36. #
  37. # Example of a broadband LEO constellation with orbital configuration
  38. # similar to that of Teledesic's 288 satellite configuration.  The script 
  39. # sets up two terminals (one in # Boston, one at Berkeley) and sends a 
  40. # packet from Berkeley to Boston every second for a whole day-- the script 
  41. # illustrates how the latency due to propagation delay changes depending 
  42. # on the satellite configuration.
  43. #
  44. # This script relies on sourcing two additional files:
  45. # - sat-teledesic-nodes.tcl
  46. # - sat-teledesic-links.tcl
  47. #
  48. # 12 planes, 24 satellites per plane
  49. # Altitude = 1375 km
  50. # Orbital period = 6794 sec
  51. # intersatellite separation = 360/24 = 15 deg
  52. # interplane separation = 15 deg (guess)
  53. # seam separation = 15 deg (guess)
  54. # inclination = 84.7
  55. # eccentricity =  0.0018 (not modelled; from original 840 bird design)
  56. # minimum elevation angle at edge of coverage = (approx) 40 deg
  57. # ISL cross-link pattern:  4 intraplane, 4 interplane except 3 at the seam
  58. # ISL cross-seam pattern:  only one across the seam; one link is active
  59. #   while the other participates in acquiring the next node for handoff
  60. global ns
  61. set ns [new Simulator]
  62. # Global configuration parameters
  63. Node/SatNode set time_advance_ 0
  64. HandoffManager/Term set elevation_mask_ 40 
  65. HandoffManager/Term set term_handoff_int_ 10
  66. HandoffManager/Sat set sat_handoff_int_ 10
  67. HandoffManager/Sat set latitude_threshold_ 60
  68. HandoffManager/Sat set longitude_threshold_ 8
  69. HandoffManager set handoff_randomization_ true
  70. SatRouteObject set metric_delay_ true
  71. # Set this to false if opt(wiredRouting) == ON below
  72. SatRouteObject set data_driven_computation_ true
  73. # "ns-random 0" sets seed heuristically; other integers are deterministic
  74. ns-random 1
  75. Agent set ttl_ 32; # Should be > than max diameter in network
  76. global opt
  77. set opt(chan)           Channel/Sat
  78. set opt(bw_down)        1.5Mb; # Downlink bandwidth (satellite to ground)
  79. set opt(bw_up)          1.5Mb; # Uplink bandwidth
  80. set opt(bw_isl)         155Mb
  81. set opt(phy)            Phy/Sat
  82. set opt(mac)            Mac/Sat
  83. set opt(ifq)            Queue/DropTail
  84. set opt(qlim)           50
  85. set opt(ll)             LL/Sat
  86. set opt(wiredRouting) OFF
  87. set opt(alt)            1375; # Polar satellite altitude (Iridium)
  88. set opt(inc)            84.7; # Orbit inclination w.r.t. equator
  89. # XXX Tracing enabling must precede link creation !
  90. # and satellite classifiers, if tracing is to work
  91. set outfile [open out.tr w]
  92. $ns trace-all $outfile
  93. # Configure satellite nodes 
  94. $ns node-config -satNodeType polar 
  95. -llType $opt(ll) 
  96. -ifqType $opt(ifq) 
  97. -ifqLen $opt(qlim) 
  98. -macType $opt(mac) 
  99. -phyType $opt(phy) 
  100. -channelType $opt(chan) 
  101. -downlinkBW $opt(bw_down) 
  102. -wiredRouting $opt(wiredRouting)
  103. set alt $opt(alt)
  104. set inc $opt(inc)
  105. # Nodes n(100) - n(1223) are satellite nodes
  106. source sat-teledesic-nodes.tcl
  107. # configure the ISLs
  108. source sat-teledesic-links.tcl
  109. # Set up terminals
  110. $ns node-config -satNodeType terminal
  111. set n100 [$ns node]
  112. $n100 set-position 37.9 -122.3; # Berkeley
  113. set n101 [$ns node]
  114. $n101 set-position 42.3 -71.1; # Boston
  115. # Add GSL links
  116. # It doesn't matter what the sat node is (handoff algorithm will reset it)
  117. $n100 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  118.   $opt(phy) [$n(100) set downlink_] [$n(100) set uplink_]
  119. $n101 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) 
  120.   $opt(phy) [$n(100) set downlink_] [$n(100) set uplink_]
  121. # Trace all queues
  122. $ns trace-all-satlinks $outfile
  123. # Attach agents
  124. set udp0 [new Agent/UDP]
  125. $ns attach-agent $n100 $udp0
  126. set cbr0 [new Application/Traffic/CBR]
  127. $cbr0 attach-agent $udp0
  128. $cbr0 set interval_ 60
  129. set null0 [new Agent/Null]
  130. $ns attach-agent $n101 $null0
  131. $ns connect $udp0 $null0
  132. $ns at 1.0 "$cbr0 start"
  133. # We're using a centralized routing genie-- create and start it here
  134. set satrouteobject_ [new SatRouteObject]
  135. $satrouteobject_ suppress_initial_computation 
  136. $ns at 0.5 "$satrouteobject_ compute_routes"; # anytime before data is sent
  137. $ns at 86400.0 "finish" ; # one earth rotation 
  138. proc finish {} {
  139. global ns outfile 
  140. $ns flush-trace
  141. close $outfile
  142. exit 0
  143. }
  144. $ns run