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 ...
Chapter 5Nodes and Packet ForwardingThis chapter describes one aspect of creating a topology in ns, i.e., creating the nodes. In the next chapter (Chapter 6), wewill describe second aspect of creating the topology, i.e., connecting the nodes to form links.Recall that each simulation requires a single instance of the class Simulator to control and operate that simulation.The class provides instance procedures to create and manage the topology, and internally stores references to each elementof the topology. We begin by describing the procedures in the class Simulator (Section 5.1). We then describe the instanceprocedures in the class Node (Section 5.2) to access and operate on individual nodes. We conclude with detailed descriptionsof the Classifier (Section 5.4) from which the more complex node objects are formed.The procedures and functions described in this chapter can be found in ~ns/tcl/lib/ns-lib.tcl, ~ns/tcl/lib/ns-node.tcl,~ns/tcl/lib/ns-rtmodule.tcl, ~ns/rtmodule.{cc,h}, ~ns/classifier.{cc, h}, ~ns/classifier-addr.cc, ~ns/classifier-mcast.cc, ~ns/classifiermpath.cc,and, ~ns/replicator.cc.5.1 Node BasicsThe basic primitive for creating a node isset ns [new Simulator]$ns nodeThe instance procedure node constructs a node out of more simple classifier objects (Section 5.4). The Node itself is astandalone class in OTcl. However, most of the components of the node are themselves TclObjects. The typical structureof a (unicast) node is as shown in Figure 5.1. This simple structure consists of two TclObjects: an address classifer(classifer_) and a port classifier (dmux_). The function of these classifiers is to distribute incoming packets to thecorrect agent or outgoing link.All nodes contain at least the following components:• an address or id_, monotonically increasing by 1 (from initial value 0) across the simulation namespace as nodes arecreated,• a list of neighbors (neighbor_),45
NODEPortClassifierAgentAgentAddrClassifierdmux_Agentagents_Node entryentry_classifier_LinkLinkLinkFigure 5.1: Structure of a Unicast Node. Notice that entry_ is simply a label variable instead of a real object, e.g., theclassifier_.• a list of agents (agent_),• a node type identifier (nodetype_), and• a routing module (described in Section 5.5 below)By default, nodes in ns are constructed for unicast simulations. In order to enable multicast simulation, the simulation shouldbe created with an option “-multicast on”, e.g.:set ns [new Simulator -multicast on]The internal structure of a typical multicast node is shown in Figure 5.2.When a simulation uses multicast routing, the highest bit of the address indicates whether the particular address is a multicastaddress or an unicast address. If the bit is 0, the address represents a unicast address, else the address represents a multicastaddress.46
- Page 6 and 7: 18 Radio Propagation Models 17718.1
- Page 8 and 9: 30 Multicast Routing 25130.1 Multic
- Page 10 and 11: 38.2.5 An example . . . . . . . . .
- Page 12 and 13: X Other 40347 Educational use of NS
- Page 14: # so, we lied. now, we define the t
- Page 17 and 18: Chapter 2Undocumented FacilitiesNs
- Page 19 and 20: Part IInterface to the Interpreter1
- Page 21 and 22: • if you can do what you want by
- Page 23 and 24: • tcl.result(const char* s)Pass t
- Page 25 and 26: By convention in ns, the class Agen
- Page 27 and 28: $object set bwvar 1500kb$object set
- Page 29 and 30: For a C++ variable to be traceable,
- Page 31 and 32: 3.5 Class TclClassThis compiled cla
- Page 33 and 34: class Packet {......static int hdrl
- Page 35 and 36: The actual arguments passed by the
- Page 37 and 38: class TclClass (Section 3.5) define
- Page 39 and 40: Chapter 4The Class SimulatorThe ove
- Page 41 and 42: 4.2.2 the heap schedulerThe heap sc
- Page 43 and 44: 4.4 Commands at a glanceSynopsis:ns
- Page 45: $ns_ dumpqCommand for dumping event
- Page 49 and 50: The Node instance variable, entry_,
- Page 51 and 52: The default values for all the abov
- Page 53 and 54: The classify() method is pure virtu
- Page 55 and 56: };The class imposes no direct seman
- Page 57 and 58: flow-specific queuing disciplines a
- Page 59 and 60: 5.5 Routing Module and Classifier O
- Page 61 and 62: Module NameRtModule/BaseRtModule/Mc
- Page 63 and 64: $node neighborsThis returns the lis
- Page 65 and 66: Linkhead_enqT_queue_ deqT_ link_ tt
- Page 67 and 68: 6.2 ConnectorsConnectors, unlink cl
- Page 69 and 70: $ns_ link-lossmodel This function
- Page 71 and 72: Chapter 7Queue Management and Packe
- Page 73 and 74: }}}void Queue::resume(){Packet* p =
- Page 75 and 76: 7.3 Different types of Queue object
- Page 77 and 78: maxidle_ is the maximum amount of t
- Page 79 and 80: dst_ The destination address of pac
- Page 81 and 82: 7.5.2 ConfigurationRunning a JoBS s
- Page 83 and 84: mean_pkt_size_ Used to set the expe
- Page 85 and 86: Demarker objects$q trace-file This
- Page 87 and 88: The recv() method overrides the bas
- Page 89 and 90: 9.2 ImplementationThe procedures an
- Page 91 and 92: Average sending rateTSW window leng
- Page 93 and 94: The following command adds an entry
- Page 95 and 96: $qCE configQ 0 1 10 20 0.10Note tha
Chapter 5Nodes <strong>and</strong> Packet ForwardingThis chapter describes one aspect of cre<strong>at</strong>ing a topology in <strong>ns</strong>, i.e., cre<strong>at</strong>ing the nodes. In the next chapter (Chapter 6), wewill describe second aspect of cre<strong>at</strong>ing the topology, i.e., connecting the nodes to form links.Recall th<strong>at</strong> each simul<strong>at</strong>ion requires a single i<strong>ns</strong>tance of the class Simul<strong>at</strong>or to control <strong>and</strong> oper<strong>at</strong>e th<strong>at</strong> simul<strong>at</strong>ion.<strong>The</strong> class provides i<strong>ns</strong>tance procedures to cre<strong>at</strong>e <strong>and</strong> manage the topology, <strong>and</strong> internally stores references to each elementof the topology. We begin by describing the procedures in the class Simul<strong>at</strong>or (Section 5.1). We then describe the i<strong>ns</strong>tanceprocedures in the class Node (Section 5.2) to access <strong>and</strong> oper<strong>at</strong>e on individual nodes. We conclude with detailed descriptio<strong>ns</strong>of the Classifier (Section 5.4) from which the more complex node objects are formed.<strong>The</strong> procedures <strong>and</strong> functio<strong>ns</strong> described in this chapter can be found in ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-lib.tcl, ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-node.tcl,~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-rtmodule.tcl, ~<strong>ns</strong>/rtmodule.{cc,h}, ~<strong>ns</strong>/classifier.{cc, h}, ~<strong>ns</strong>/classifier-addr.cc, ~<strong>ns</strong>/classifier-mcast.cc, ~<strong>ns</strong>/classifiermp<strong>at</strong>h.cc,<strong>and</strong>, ~<strong>ns</strong>/replic<strong>at</strong>or.cc.5.1 Node Basics<strong>The</strong> basic primitive for cre<strong>at</strong>ing a node isset <strong>ns</strong> [new Simul<strong>at</strong>or]$<strong>ns</strong> node<strong>The</strong> i<strong>ns</strong>tance procedure node co<strong>ns</strong>tructs a node out of more simple classifier objects (Section 5.4). <strong>The</strong> Node itself is ast<strong>and</strong>alone class in OTcl. However, most of the components of the node are themselves TclObjects. <strong>The</strong> typical structureof a (unicast) node is as shown in Figure 5.1. This simple structure co<strong>ns</strong>ists of two TclObjects: an address classifer(classifer_) <strong>and</strong> a port classifier (dmux_). <strong>The</strong> function of these classifiers is to distribute incoming packets to thecorrect agent or outgoing link.All nodes contain <strong>at</strong> least the following components:• an address or id_, monotonically increasing by 1 (from initial value 0) across the simul<strong>at</strong>ion namespace as nodes arecre<strong>at</strong>ed,• a list of neighbors (neighbor_),45