The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...
The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ... The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...
are computed at different times (while propagation delays are continuously changing). This effect can be seen bytoggling this parameter in the Iridium example script ~ns/tcl/ex/sat-iridium.tcl.• In the trace file, when a packet is dropped due to “no route to host” (such as when there is a topology change), the tracelooks a bit different depending on whether wiredRouting is turned OFF or ON. In the former case, there is one line perdrop, with the destination labelled as “-2”. In the latter case, there are three events (enque “+”, deque “-”, and drop “d”)corresponding to the same packet, and the destination is shown as “-1”.• In rare cases, there may be warning messages during the execution indicating “node out of range.” This can occur if anode becomes disconnected in the topology and then another node tries to send a packet to it. For example, try enablingwiredRouting in the file ~ns/tcl/ex/sat-mixed.tcl. This occurs because the routing table is dynamically sized upontopology change, and if a node becomes disconnected it may not have any entries inserted in the routing table (andhence the routing table is not grown to accommodate its node number). This warning should not affect actual traceoutput.• There has been no attempt to interoperate with wireless or mobile-IP code.17.2.10 Example scriptsExample scripts can be found in the ~ns/tcl/ex directory, including:• sat-mixed.tcl A simulation with a mixture of polar and geostationary satellites.• sat-wired.tcl Similar to the previous script, but shows how to connect wired nodes to a satellite simulation.• sat-repeater.tcl Demonstrates the use of a simple bent-pipe geostationary satellite, and also error models.• sat-aloha.tcl Simulates one hundred terminals in a mesh-VSAT configuration using an unslotted Aloha MACprotocol with a “bent-pipe” geostationary satellite. Terminals listen to their own transmissions (after a delay), and ifthey do not successfully receive their own packet within a timeout interval, they perform exponential backoff and thenretransmit the packet. Three variants exist: basic, basic_tracing, and poisson. These variants are describedfurther in the header comments of the script.• sat-iridium.tcl Simulates a broadband LEO constellation with parameters similar to that of the Iridium constellation(with supporting scripts sat-iridium-links.tcl, sat-iridium-linkswithcross.tcl, andsat-iridium-nodes.tcl).• sat-teledesic.tcl Simulates a broadband LEO constellation with parameters similar to those proposed for the288 satellite Teledesic constellation (with supporting scripts sat-teledesic-links.tcl and sat-teledesic-nodes.tclIn addition, there is a test suite script that tries to exercise a lot of features simultaneously, it can be found at ~ns/tcl/test/testsuite-sat.tcl.17.3 ImplementationThe code for the implementation of satellite extensions can be found in ~ns/{sat.h, sathandoff.{cc,h}, satlink.{cc,h}, satnode.{cc,h},satposition.{cc,h}, satroute.{cc,h}, sattrace.{cc,h}}, and ~ns/tcl/lib/ns-sat.tcl. Almost all of the mechanism isimplemented in C++.In this section, we focus on some of the key components of the implementation; namely, the use of linked lists, the nodestructure, and a detailed look at the satellite link structure.181
lh_firstnameobj‘‘name’’ is the name of the structure containing the list head‘‘lh_first’’ is a pointer of type *obj, initialized to NULL‘‘lh_next’’ is a pointer of type *obj‘‘lh_prev’’ (of type **obj) is a pointer to the previous lh_nextobjobjlh_nextlh_prevlh_nextlh_prevlh_nextlh_prevNULLFigure 17.4: Linked list implementation in ns.17.3.1 Use of linked listsThere are a number of linked lists used heavily in the implementation:• class Node maintains a (static) list of all objects of class Node in the simulator. The variable Node::nodehead_stores the head of the list. The linked list of nodes is used for centralized routing, for finding satellites to hand off to,and for tracing.• class Node maintains a list of all (satellite) links on the node. Specifically, the list is a list of objects of classLinkHead. The variable linklisthead_ stores the head of the list. The linked list of LinkHeads is used forchecking whether or not to handoff links, and to discover topology adjacencies.• class Channel maintains a list of all objects of class Phy on the channel. The head of the list is stored in thevariable if_head_. This list is used to determine the set of interfaces on a channel that should receive a copy of apacket.Figure 17.4 provides a schematic of how the linked list is organized. Each object in the list is linked through a “LINK_ENTRY”that is a protected member of the class. This entry contains a pointer to the next item in the list and also a pointer to the addressof the previous “next” pointer in the preceding object. Various macros found in ~ns/list.h can be used to manipulate the list;the implementation of linked-lists in ns is similar to the queue implementation found in some variants of BSD UNIX.17.3.2 Node structureFigure 17.5 is a schematic of the main components of a SatNode. The structure bears resemblance to the MobileNode inthe wireless extensions, but there are several differences. Like all ns nodes, the SatNode has an “entry” point to a series ofclassifiers. The address classifier contains a slot table for forwarding packets to foreign nodes, but since OTcl routing is notused, all packets not destined for this node (and hence forwarded to the port classifier), are sent to the default target, whichpoints to a routing agent. Packets destined on the node for port 255 are classified as routing packets and are also forwarded tothe routing agent.Each node contains one or more “network stacks” that include a generic SatLinkHead at the entry point of the link. TheSatLinkHead is intended to serve as an API to get at other objects in the link structure, so it contains a number of pointers(although the API here has not been finalized). Packets leaving the network stack are sent to the node’s entry. An importantfeature is that each packet leaving a network stack has its iface_ field in the common packet header coded with the uniqueNetworkInterface index corresponding to the link. This value can be used to support distributed routing as describedbelow.The base class routing agent is class SatRouteAgent; it can be used in conjunction with centralized routing. SatRouteAgentscontain a forwarding table that resolves a packet’s address to a particular LinkHead target– it is the job of the SatRouteObject182
- Page 131 and 132: This is a simple example of how to
- Page 133 and 134: Higher LayersNode 1Node 2. . .Node
- Page 135 and 136: };void recv(Packet* p, Handler*);vi
- Page 137 and 138: and the frame type. It then passes
- Page 139 and 140: $ll_ set delay_ $delay$ll_ set band
- Page 141 and 142: 14.10 Commands at a glanceThe follo
- Page 143 and 144: 15.2.1 Default Hierarchical Setting
- Page 145 and 146: Chapter 16Mobile Networking in nsTh
- Page 147 and 148: entry_addrdemuxIP addressdefaulttar
- Page 149 and 150: 16.1.2 Creating Node movementsThe m
- Page 151 and 152: set netif $netif_($t)set mac $mac_(
- Page 153 and 154: the hardware address of a packet’
- Page 155 and 156: destined to itself to the port dmux
- Page 157 and 158: switch(ch->ptype()) {case PT_MAC:br
- Page 159 and 160: 16.1.7 Revised format for wireless
- Page 161 and 162: Packet info at "Application level"
- Page 163 and 164: The main problem facing the wired-c
- Page 165 and 166: target_target_encapsulatorreg_agent
- Page 167 and 168: why: This avoids header clashes bet
- Page 169 and 170: This command is used to create a Go
- Page 171 and 172: Chapter 17Satellite Networking in n
- Page 173 and 174: in counter-rotating planes (where t
- Page 175 and 176: • Position/Sat/Geo A geostationar
- Page 177 and 178: $ns add-isl $ltype $node1 $node2 $b
- Page 179 and 180: $satrouteobject_ compute_routeswher
- Page 181: This will add an error model to the
- Page 185 and 186: from routing agentto Node->entrySat
- Page 187 and 188: $satnode add-isl This method c
- Page 189 and 190: set prop [new Propagation/FreeSpace
- Page 191 and 192: 18.3.2 Using shadowing modelBefore
- Page 193 and 194: Chapter 19Energy Model in nsEnergy
- Page 195 and 196: Chapter 20Directed DiffusionThe dir
- Page 197 and 198: However if we have a large and dens
- Page 199 and 200: yr application in the ns context. T
- Page 201 and 202: value of opt(pre-stop) is usually t
- Page 203 and 204: 21.2 Implementation of XCP in NSIn
- Page 205 and 206: the persistent queue length in the
- Page 207 and 208: Thruput2 0.054024 60000residue_pos_
- Page 209 and 210: Chapter 22DelayBox: Per-Flow Delay
- Page 211 and 212: $ns attach-agent $n_sink $sink# mak
- Page 213 and 214: Chapter 23Changes made to the IEEE
- Page 215 and 216: Part IIISupport214
- Page 217 and 218: endenddocument pargvcPrint out argc
- Page 219 and 220: 24.4.2 Memory Conservation TipsSome
- Page 221 and 222: Chapter 25Mathematical SupportThe s
- Page 223 and 224: set run [lindex $argv 0]}if {$run <
- Page 225 and 226: }$sizeRNG next-substream# print the
- Page 227 and 228: protected:RNG* rng_;};Classes deriv
- Page 229 and 230: ns-random is implemented in ~ns/mis
- Page 231 and 232: Chapter 26Trace and Monitoring Supp
are computed <strong>at</strong> different times (while propag<strong>at</strong>ion delays are continuously changing). This effect can be seen bytoggling this parameter in the Iridium example script ~<strong>ns</strong>/tcl/ex/s<strong>at</strong>-iridium.tcl.• In the trace file, when a packet is dropped due to “no route to host” (such as when there is a topology change), the tracelooks a bit different depending on whether wiredRouting is turned OFF or ON. In the former case, there is one line perdrop, with the destin<strong>at</strong>ion labelled as “-2”. In the l<strong>at</strong>ter case, there are three events (enque “+”, deque “-”, <strong>and</strong> drop “d”)corresponding to the same packet, <strong>and</strong> the destin<strong>at</strong>ion is shown as “-1”.• In rare cases, there may be warning messages during the execution indic<strong>at</strong>ing “node out of range.” This can occur if anode becomes disconnected in the topology <strong>and</strong> then another node tries to send a packet to it. For example, try enablingwiredRouting in the file ~<strong>ns</strong>/tcl/ex/s<strong>at</strong>-mixed.tcl. This occurs because the routing table is dynamically sized upontopology change, <strong>and</strong> if a node becomes disconnected it may not have any entries i<strong>ns</strong>erted in the routing table (<strong>and</strong>hence the routing table is not grown to accommod<strong>at</strong>e its node number). This warning should not affect actual traceoutput.• <strong>The</strong>re has been no <strong>at</strong>tempt to interoper<strong>at</strong>e with wireless or mobile-IP code.17.2.10 Example scriptsExample scripts can be found in the ~<strong>ns</strong>/tcl/ex directory, including:• s<strong>at</strong>-mixed.tcl A simul<strong>at</strong>ion with a mixture of polar <strong>and</strong> geost<strong>at</strong>ionary s<strong>at</strong>ellites.• s<strong>at</strong>-wired.tcl Similar to the previous script, but shows how to connect wired nodes to a s<strong>at</strong>ellite simul<strong>at</strong>ion.• s<strong>at</strong>-repe<strong>at</strong>er.tcl Demo<strong>ns</strong>tr<strong>at</strong>es the use of a simple bent-pipe geost<strong>at</strong>ionary s<strong>at</strong>ellite, <strong>and</strong> also error models.• s<strong>at</strong>-aloha.tcl Simul<strong>at</strong>es one hundred terminals in a mesh-VSAT configur<strong>at</strong>ion using an u<strong>ns</strong>lotted Aloha MACprotocol with a “bent-pipe” geost<strong>at</strong>ionary s<strong>at</strong>ellite. Terminals listen to their own tra<strong>ns</strong>missio<strong>ns</strong> (after a delay), <strong>and</strong> ifthey do not successfully receive their own packet within a timeout interval, they perform exponential backoff <strong>and</strong> thenretra<strong>ns</strong>mit the packet. Three variants exist: basic, basic_tracing, <strong>and</strong> poisson. <strong>The</strong>se variants are describedfurther in the header comments of the script.• s<strong>at</strong>-iridium.tcl Simul<strong>at</strong>es a broadb<strong>and</strong> LEO co<strong>ns</strong>tell<strong>at</strong>ion with parameters similar to th<strong>at</strong> of the Iridium co<strong>ns</strong>tell<strong>at</strong>ion(with supporting scripts s<strong>at</strong>-iridium-links.tcl, s<strong>at</strong>-iridium-linkswithcross.tcl, <strong>and</strong>s<strong>at</strong>-iridium-nodes.tcl).• s<strong>at</strong>-teledesic.tcl Simul<strong>at</strong>es a broadb<strong>and</strong> LEO co<strong>ns</strong>tell<strong>at</strong>ion with parameters similar to those proposed for the288 s<strong>at</strong>ellite Teledesic co<strong>ns</strong>tell<strong>at</strong>ion (with supporting scripts s<strong>at</strong>-teledesic-links.tcl <strong>and</strong> s<strong>at</strong>-teledesic-nodes.tclIn addition, there is a test suite script th<strong>at</strong> tries to exercise a lot of fe<strong>at</strong>ures simultaneously, it can be found <strong>at</strong> ~<strong>ns</strong>/tcl/test/testsuite-s<strong>at</strong>.tcl.17.3 Implement<strong>at</strong>ion<strong>The</strong> code for the implement<strong>at</strong>ion of s<strong>at</strong>ellite exte<strong>ns</strong>io<strong>ns</strong> can be found in ~<strong>ns</strong>/{s<strong>at</strong>.h, s<strong>at</strong>h<strong>and</strong>off.{cc,h}, s<strong>at</strong>link.{cc,h}, s<strong>at</strong>node.{cc,h},s<strong>at</strong>position.{cc,h}, s<strong>at</strong>route.{cc,h}, s<strong>at</strong>trace.{cc,h}}, <strong>and</strong> ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-s<strong>at</strong>.tcl. Almost all of the mechanism isimplemented in C++.In this section, we focus on some of the key components of the implement<strong>at</strong>ion; namely, the use of linked lists, the nodestructure, <strong>and</strong> a detailed look <strong>at</strong> the s<strong>at</strong>ellite link structure.181