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 ...
portdemuxSrc/Sinkentry_DSRtarget_ll_uptarget_LLll_(0)arptable_ARPdowntarget_IFqdowntarget_MACuptarget_downtarget_uptarget_RadioPropagationModelpropagation_NetIFchannel_uptarget_ChannelFigure 16.2: Schematic of a SRNode under the CMU monarch’s wireless extensions to nsare handed dow n to the DSR routing agent by default. The DSR routing agent either receives pkts for itself by handing itover to the port dmux or forwards pkts as per source routes in the pkt hdr or sends out route requests and route replies forfresh packets. Details on DSR routing agent may be found in section 16.1.5. The schematic model for a SRNode is shown inFigure 16.2.147
16.1.2 Creating Node movementsThe mobilenode is designed to move in a three dimensional topology. However the third dimension (Z) is not used. That isthe mobilenode is assumed to move always on a flat terrain with Z always equal to 0. Thus the mobilenode has X, Y, Z(=0)co-ordinates that is continually adjusted as the node moves. There are two mechanisms to induce movement in mobilenodes.In the first method, starting position of the node and its future destinations may be set explicitly. These directives are normallyincluded in a separate movement scenario file.The start-position and future destinations for a mobilenode may be set by using the following APIs:$node set X_ $node set Y_ $node set Z_ $ns at $time $node setdest At $time sec, the node would start moving from its initial position of (x1,y1) towards a destination (x2,y2) at the definedspeed.In this method the node-movement-updates are triggered whenever the position of the node at a given time is required to beknown. This may be triggered by a query from a neighbouring node seeking to know the distance between them, or the setdestdirective described above that changes the direction and speed of the node.An example of a movement scenario file using the above APIs, can be found in ~ns/tcl/mobility/scene/scen-670x670-50-600-20-0. Here 670x670 defines the length and width of the topology with 50 nodes moving at a maximum speed of 20m/s withaverage pause time of 600s. These node movement files may be generated using CMU’s scenario generator to be found under~ns/indep-utils/cmu-scen-gen/setdest. See subsection 16.1.8 for details on generation of node movement scenarios.The second method employs random movement of the node. The primitive to be used is:$mobilenode startwhich starts the mobilenode with a random position and have routined updates to change the direction and speed of the node.The destination and speed values are generated in a random fashion. We have not used the second method and leave it to theuser to explore the details. The mobilenode movement is implemented in C++. See methods in ~ns/mobilenode.{cc.h} forthe implementational details.Irrespective of the methods used to generate node movement, the topography for mobilenodes needs to be defined. It should bedefined before creating mobilenodes. Normally flat topology is created by specifying the length and width of the topographyusing the following primitive:set topo [new Topography]$topo load_flatgrid $opt(x) $opt(y)where opt(x) and opt(y) are the boundaries used in simulation.The movement of mobilenodes may be logged by using a procedure like the following:proc log-movement {} {148
- Page 97 and 98: Chapter 10AgentsAgents represent en
- Page 99 and 100: CtrMcast/EncapCtrMcast/DecapMessage
- Page 101 and 102: }bind("windowOption_", &wnd_option_
- Page 103 and 104: hdr_flags* nf = (hdr_flags*)npkt->a
- Page 105 and 106: public:ECHO_Timer(ECHO_Agent *a) :
- Page 107 and 108: 10.6.4 Using the agent through OTcl
- Page 109 and 110: State Variables are:dupacks_ Number
- Page 111 and 112: $agent attach-tbf Attaches a token
- Page 113 and 114: (void)Scheduler::instance().schedul
- Page 115 and 116: * outstanding, cancel it.*/void Tcp
- Page 117 and 118: Chapter 12Packet Headers and Format
- Page 119 and 120: method is now obsolete; its usage i
- Page 121 and 122: Packethdrsize_next_bits()points to
- Page 123 and 124: the system’s memory allocator. In
- Page 125 and 126: }incr hdrlen_ $incrreturn $baseFrom
- Page 127 and 128: Chapter 13Error ModelThis chapter d
- Page 129 and 130: SimpleLink::errormodule argsSimulat
- 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: entry_addrdemuxIP addressdefaulttar
- 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 and 182: This will add an error model to the
- Page 183 and 184: lh_firstnameobj‘‘name’’ is
- 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
16.1.2 Cre<strong>at</strong>ing Node movements<strong>The</strong> mobilenode is designed to move in a three dime<strong>ns</strong>ional topology. However the third dime<strong>ns</strong>ion (Z) is not used. Th<strong>at</strong> isthe mobilenode is assumed to move always on a fl<strong>at</strong> terrain with Z always equal to 0. Thus the mobilenode has X, Y, Z(=0)co-ordin<strong>at</strong>es th<strong>at</strong> is continually adjusted as the node moves. <strong>The</strong>re are two mechanisms to induce movement in mobilenodes.In the first method, starting position of the node <strong>and</strong> its future destin<strong>at</strong>io<strong>ns</strong> may be set explicitly. <strong>The</strong>se directives are normallyincluded in a separ<strong>at</strong>e movement scenario file.<strong>The</strong> start-position <strong>and</strong> future destin<strong>at</strong>io<strong>ns</strong> for a mobilenode may be set by using the following APIs:$node set X_ $node set Y_ $node set Z_ $<strong>ns</strong> <strong>at</strong> $time $node setdest At $time sec, the node would start moving from its initial position of (x1,y1) towards a destin<strong>at</strong>ion (x2,y2) <strong>at</strong> the definedspeed.In this method the node-movement-upd<strong>at</strong>es are triggered whenever the position of the node <strong>at</strong> a given time is required to beknown. This may be triggered by a query from a neighbouring node seeking to know the distance between them, or the setdestdirective described above th<strong>at</strong> changes the direction <strong>and</strong> speed of the node.An example of a movement scenario file using the above APIs, can be found in ~<strong>ns</strong>/tcl/mobility/scene/scen-670x670-50-600-20-0. Here 670x670 defines the length <strong>and</strong> width of the topology with 50 nodes moving <strong>at</strong> a maximum speed of 20m/s withaverage pause time of 600s. <strong>The</strong>se node movement files may be gener<strong>at</strong>ed using CMU’s scenario gener<strong>at</strong>or to be found under~<strong>ns</strong>/indep-utils/cmu-scen-gen/setdest. See subsection 16.1.8 for details on gener<strong>at</strong>ion of node movement scenarios.<strong>The</strong> second method employs r<strong>and</strong>om movement of the node. <strong>The</strong> primitive to be used is:$mobilenode startwhich starts the mobilenode with a r<strong>and</strong>om position <strong>and</strong> have routined upd<strong>at</strong>es to change the direction <strong>and</strong> speed of the node.<strong>The</strong> destin<strong>at</strong>ion <strong>and</strong> speed values are gener<strong>at</strong>ed in a r<strong>and</strong>om fashion. We have not used the second method <strong>and</strong> leave it to theuser to explore the details. <strong>The</strong> mobilenode movement is implemented in C++. See methods in ~<strong>ns</strong>/mobilenode.{cc.h} forthe implement<strong>at</strong>ional details.Irrespective of the methods used to gener<strong>at</strong>e node movement, the topography for mobilenodes needs to be defined. It should bedefined before cre<strong>at</strong>ing mobilenodes. Normally fl<strong>at</strong> topology is cre<strong>at</strong>ed by specifying the length <strong>and</strong> width of the topographyusing the following primitive:set topo [new Topography]$topo load_fl<strong>at</strong>grid $opt(x) $opt(y)where opt(x) <strong>and</strong> opt(y) are the boundaries used in simul<strong>at</strong>ion.<strong>The</strong> movement of mobilenodes may be logged by using a procedure like the following:proc log-movement {} {148