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 ...
Multiple rtproto{} lines for the same or different routing protocols can occur in a simulation script. However, a simulationcannot use both centralized routing mechanisms such as static or session routing and detailed dynamic routing protocols suchas DV.In dynamic routing, each node can be running more than one routing protocol. In such situations, more than one routingprotocol can have a route to the same destination. Therefore, each protocol affixes a preference value to each of its routes.These values are non-negative integers in the range 0. . . 255. The lower the value, the more preferred the route. When multiplerouting protocol agents have a route to the same destination, the most preferred route is chosen and installed in the node’sforwarding tables. If more than one agent has the most preferred routes, the ones with the lowest metric is chosen. We callthe least cost route from the most preferred protocol the “candidate” route. If there are multiple candidate routes from thesame or different protocols, then, currently, one of the agent’s routes is randomly chosen 2 .Preference Assignment and Control Each protocol agent stores an array of route preferences, rtpref_. There is oneelement per destination, indexed by the node handle. The default preference values used by each protocol are derived from aclass variable, preference_, for that protocol. The current defaults are:Agent/rtProto set preference_ 200Agent/rtProto/Direct 3 set preference_ 100Agent/rtProto/DV set preference_ 120;# global default preferenceA simulation script can control routing by altering the preference for routes in one of three ways: alter the preference for aspecific route learned via a particular protocol agent, alter the preference for all routes learned by the agent, or alter the classvariables for the agent before the agent is created.Link Cost Assignment and Control In the currently implemented route protocols, the metric of a route to a destination,at a node, is the cost to reach the destination from that node. It is possible to change the link costs at each of the links.The instance procedure cost{} is invoked as $ns cost 〈node1〉 〈node2〉 〈cost〉,and sets the cost of the link from〈node1〉 to 〈node2〉 to 〈cost〉.$ns cost $n1 $n2 10 ;# set cost of link from $n1 to $n2 to 10$ns cost $n2 $n1 5 ;# set cost of link in reverse direction to 5[$ns link $n1 $n2] cost? ;# query cost of link from $n1 to $n2[$ns link $n2 $n1] cost?;# query cost of link in reverse directionNotice that the procedure sets the cost along one direction only. Similarly, the procedure cost?{} returns the cost oftraversing the specified unidirectional link. The default cost of a link is 1.29.2 Other Configuration Mechanisms for Specialised RoutingIt is possible to adjust preference and cost mechanisms to get two special types of route configurations: asymmetric routing,and multipath routing.2 This really is undesirable, and may be fixed at some point. The fix will probably be to favor the agents in class preference order. A user level simulationrelying on this behavior, or getting into this situation in specific topologies is not recommended.3 Direct is a special routing strategy that is used in conjunction with Dynamic routing. We will describe this in greater detail as part of the route architecturedescription.251
Asymmetric Routing Asymmetric routing occurs when the path from node n 1 to node n 2 is different from the path fromn 2 to n 1 . The following shows a simple topology, and cost configuration that can achieve such a result:Nodes n 1 and n 2 use differentpaths to reach each other. Allother pairs of nodes use symmetricpaths to reach each other.n1r1r2n2$ns cost $n1 $r1 2$ns cost $n2 $r2 2$ns cost $r1 $n2 3Any routing protocol that uses link costs as the metric can observe such asymmetric routing if the link costs are appropriatelyconfigured 4 .MultiPath Routing Each node can be individually configured to use multiple separate paths to a particular destination.The instance variable multiPath_ determines whether or not that node will use multiple paths to any destination. Eachnode initialises its instance variable from a class variable of the same name. If multiple candidate routes to a destinationare available, all of which are learned through the same protocol, then that node can use all of the different routes to thedestination simultaneously. A typical configuration is as shown below:Node set multiPath_ 1or alternatelyset n1 [$ns Node]$n1 set multiPath_ 1;# All new nodes in the simulation use multiPaths where applicable;# only enable $n1 to use multiPaths where applicableCurrently, only DV routing can generate multipath routes.29.3 Protocol Specific Configuration ParametersStatic Routing The static route computation strategy is the default route computation mechanism in ns. This strategyuses the Dijkstra’s all-pairs SPF algorithm []. The route computation algorithm is run exactly once prior to the start of thesimulation. The routes are computed using an adjacency matrix and link costs of all the links in the topology.(Note that static routing is static in the sense that it is computed once when the simulation starts, as opposed to session andDV routing that allow routes to change mid-simulation. An alternative to static routing is Manual routing where routes arenot computed but instead are set (manually) by the user.)Session Routing The static routing strategy described earlier only computes routes for the topology once in the course of asimulation. If the above static routing is used and the topology changes while the simulation is in progress, some sources anddestinations may become temporarily unreachable from each other for a short time.Session routing strategy is almost identical to static routing, in that it runs the Dijkstra all-pairs SPF algorithm prior to thestart of the simulation, using the adjacency matrix and link costs of the links in the topology. However, it will also run thesame algorithm to recompute routes in the event that the topology changes during the course of a simulation. In other words,route recomputation and recovery is done instantaneously and there will not be transient routing outage as in static routing.Session routing provides complete and instantaneous routing changes in the presence of topology dynamics. If the topology isalways connected, there is end-to-end connectivity at all times during the course of the simulation. However, the user should4 Link costs can also be used to favour or disregard specific links in order to achieve particular topology configurations.252
- 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
- Page 233 and 234: The monitor-queue function is const
- Page 235 and 236: also used to accumulate packet drop
- Page 237 and 238: }name,th->size(),flags,iph->flowid(
- Page 239 and 240: PT_TORA,PT_DSR,PT_AODV,// insert ne
- Page 241 and 242: The QueueMonitor class is not deriv
- Page 243 and 244: $ns_ trace-all This is the command
- Page 245 and 246: Chapter 27Test Suite SupportThe ns
- Page 247 and 248: ... ...}$ns_ at $opt(stop).1 "$self
- Page 249 and 250: Example: To enable debugging in Que
- Page 251: Chapter 29Unicast RoutingThis secti
- Page 255 and 256: class RouteLogic This class defines
- Page 257 and 258: — The procedure init-all{} is a g
- Page 259 and 260: Global Actions Once the detailed ac
- Page 261 and 262: This dumps next hop information in
- Page 263 and 264: $ns mrtproto ST;# specify shared tr
- Page 265 and 266: Dense Mode The Dense Mode protocol
- Page 267 and 268: and unique label (id). Thus, “inc
- Page 269 and 270: add-iif{ifid link},add-oif{link if}
- Page 271 and 272: CtrMcastComp is the centralised mul
- Page 273 and 274: $ns_ mrtproto This command specifi
- Page 275 and 276: Chapter 31Network DynamicsThis chap
- Page 277 and 278: v 0.8123 link-up 3 5v 0.8123 link-u
- Page 279 and 280: The first argument is the time at w
- Page 281 and 282: $ns_ rtmodel This command defines
- Page 283 and 284: $ns set-address-format hierarchical
- Page 285 and 286: 32.4 Hierarchical Routing with Sess
- Page 287 and 288: Chapter 33UDP Agents33.1 UDP Agents
- Page 289 and 290: Chapter 34TCP AgentsThis section de
- Page 291 and 292: set ns [new Simulator]set node1 [$n
- Page 293 and 294: 34.2.1 The Base TCP SinkThe base TC
- Page 295 and 296: Agent/TCP/FullTcp set dupseg_fix_ t
- Page 297 and 298: 34.5 Tracing TCP DynamicsThe behavi
- Page 299 and 300: Chapter 35SCTP AgentsThis chapter d
- Page 301 and 302: Figure 35.1: Example of a Multihome
Multiple rtproto{} lines for the same or different routing protocols can occur in a simul<strong>at</strong>ion script. However, a simul<strong>at</strong>ioncannot use both centralized routing mechanisms such as st<strong>at</strong>ic or session routing <strong>and</strong> detailed dynamic routing protocols suchas DV.In dynamic routing, each node can be running more than one routing protocol. In such situ<strong>at</strong>io<strong>ns</strong>, more than one routingprotocol can have a route to the same destin<strong>at</strong>ion. <strong>The</strong>refore, each protocol affixes a preference value to each of its routes.<strong>The</strong>se values are non-neg<strong>at</strong>ive integers in the range 0. . . 255. <strong>The</strong> lower the value, the more preferred the route. When multiplerouting protocol agents have a route to the same destin<strong>at</strong>ion, the most preferred route is chosen <strong>and</strong> i<strong>ns</strong>talled in the node’sforwarding tables. If more than one agent has the most preferred routes, the ones with the lowest metric is chosen. We callthe least cost route from the most preferred protocol the “c<strong>and</strong>id<strong>at</strong>e” route. If there are multiple c<strong>and</strong>id<strong>at</strong>e routes from thesame or different protocols, then, currently, one of the agent’s routes is r<strong>and</strong>omly chosen 2 .Preference Assignment <strong>and</strong> Control Each protocol agent stores an array of route preferences, rtpref_. <strong>The</strong>re is oneelement per destin<strong>at</strong>ion, indexed by the node h<strong>and</strong>le. <strong>The</strong> default preference values used by each protocol are derived from aclass variable, preference_, for th<strong>at</strong> protocol. <strong>The</strong> current defaults are:Agent/rtProto set preference_ 200Agent/rtProto/Direct 3 set preference_ 100Agent/rtProto/DV set preference_ 120;# global default preferenceA simul<strong>at</strong>ion script can control routing by altering the preference for routes in one of three ways: alter the preference for aspecific route learned via a particular protocol agent, alter the preference for all routes learned by the agent, or alter the classvariables for the agent before the agent is cre<strong>at</strong>ed.Link Cost Assignment <strong>and</strong> Control In the currently implemented route protocols, the metric of a route to a destin<strong>at</strong>ion,<strong>at</strong> a node, is the cost to reach the destin<strong>at</strong>ion from th<strong>at</strong> node. It is possible to change the link costs <strong>at</strong> each of the links.<strong>The</strong> i<strong>ns</strong>tance procedure cost{} is invoked as $<strong>ns</strong> cost 〈node1〉 〈node2〉 〈cost〉,<strong>and</strong> sets the cost of the link from〈node1〉 to 〈node2〉 to 〈cost〉.$<strong>ns</strong> cost $n1 $n2 10 ;# set cost of link from $n1 to $n2 to 10$<strong>ns</strong> cost $n2 $n1 5 ;# set cost of link in reverse direction to 5[$<strong>ns</strong> link $n1 $n2] cost? ;# query cost of link from $n1 to $n2[$<strong>ns</strong> link $n2 $n1] cost?;# query cost of link in reverse directionNotice th<strong>at</strong> the procedure sets the cost along one direction only. Similarly, the procedure cost?{} retur<strong>ns</strong> the cost oftraversing the specified unidirectional link. <strong>The</strong> default cost of a link is 1.29.2 Other Configur<strong>at</strong>ion Mechanisms for Specialised RoutingIt is possible to adjust preference <strong>and</strong> cost mechanisms to get two special types of route configur<strong>at</strong>io<strong>ns</strong>: asymmetric routing,<strong>and</strong> multip<strong>at</strong>h routing.2 This really is undesirable, <strong>and</strong> may be fixed <strong>at</strong> some point. <strong>The</strong> fix will probably be to favor the agents in class preference order. A user level simul<strong>at</strong>ionrelying on this behavior, or getting into this situ<strong>at</strong>ion in specific topologies is not recommended.3 Direct is a special routing str<strong>at</strong>egy th<strong>at</strong> is used in conjunction with Dynamic routing. We will describe this in gre<strong>at</strong>er detail as part of the route architecturedescription.251