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 ...
};double& timestamp() { return (ts_); }This structure primarily defines fields used for tracing the flow of packets or measuring other quantities. The time stamp fieldis used to measure queuing delay at switch nodes. The ptype_ field is used to identify the type of packets, which makesreading traces simpler. The uid_ field is used by the scheduler in scheduling packet arrivals. The size_ field is of generaluse and gives the simulated packet’s size in bytes. Note that the actual number of bytes consumed in the simulation may notrelate to the value of this field (i.e., size_ has no relationship to sizeof(struct hdr_cmn) or other ns structures).Rather, it is used most often in computing the time required for a packet to be delivered along a network link. As such itshould be set to the sum of the application data size and IP-, transport-, and application-level headers for the simulated packet.The iface_ field is used by the simulator when performing multicast distribution tree computations. It is a label indicating(typically) on which link a packet was received.12.2.4 The PacketHeaderManager ClassAn object of the class PacketHeaderManager is used to manage the set of currently-active packet header types andassign each of them unique offsets in the BOB. It is defined in both the C++ and OTcl code:From tcl/lib/ns-packet.tcl:PacketHeaderManager set hdrlen_ 0......foreach prot {AODVARPaSRMCommonCtrMcastDiffusion......TORAUMP} {add-packet-header $prot}Simulator instproc create_packetformat {} {PacketHeaderManager instvar tab_set pm [new PacketHeaderManager]foreach cl [PacketHeader info subclass] {if [info exists tab_($cl)] {set off [$pm allochdr $cl]$cl offset $off}}$self set packetManager_ $pm}PacketHeaderManager instproc allochdr cl {set size [$cl set hdrlen_]$self instvar hdrlen_set NS_ALIGN 8 ;# round up to nearest NS_ALIGN bytes, (needed on sparc/solaris)set incr [expr ($size + ($NS_ALIGN-1)) & ~($NS_ALIGN-1)]set base $hdrlen_123
}incr hdrlen_ $incrreturn $baseFrom packet.cc:/* manages active packet header types */class PacketHeaderManager : public TclObject {public:PacketHeaderManager() {bind("hdrlen_", &Packet::hdrlen_);}};The code in ~ns/tcl/lib/ns-packet.tcl is executed when the simulator initializes. Thus, the foreach statement is executedbefore the simulation begins, and initializes the OTcl class array tab_ to contain the mapping between class the name andthe names of the currently active packet header classes. As discussed above (12.1), packet headers should be accessed usinghdr_〈hdrname〉::access().The create_packetformat{} instance procedure is part of the basic Simulator class and is called one time during simulatorconfiguration. It first creates a single PacketHeaderManager object. The C++ constructor links the OTcl instancevariable hdrlen_ (of class PacketHeaderManager) to the C++ variable Packet::hdrlen_ (a static member of thePacket class). This has the effect of setting Packet::hdrlen_ to zero. Note that binding across class types in thisfashion is unusual.After creating the packet manager, the foreach loop enables each of the packet headers of interest. This loop iteratesthrough the list of defined packet headers of the form (h i , o i ) where h i is the name of the ith header and o i is the name of thevariable containing the location of the h i header in BOB. The placement of headers is performed by the allochdr instprocof the PacketHeaderManager OTcl class. The procedure keeps a running variable hdrlen_ with the current length ofBOB as new packet headers are enabled. It also arranges for 8-byte alignment for any newly-enabled packet header. Thisis needed to ensure that when double-world length quantities are used in packet headers on machines where double-wordalignment is required, access faults are not produced. 3 .12.3 Commands at a glanceFollowing is a list of packet-header related procedures:Simulator::create_packetformatThis is an internal simulator procedure and is called once during the simulator configuration to setup apacketHeaderManager object.PacketHeaderManager::allochdrThis is another internal procedure of Class PacketHeaderManager that keeps track of a variable called hdrlen_ as newpacket-headers are enabled. It also allows 8-byte allignment for any newly-enabled pkt header.add-packet-header takes a list of arguments, each of which is a packet header name (without PacketHeader/prefix). This global proc will tell simulator to include the specified packet header(s) in your simulation.3 In some processer architectures, including the Sparc and HP-PA, double-word access must be performed on a double-word boundary (i.e. addressesending in 0 mod 8). Attempting to perform unaligned accesses result in an abnormal program termination.124
- 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
- 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: the system’s memory allocator. In
- 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 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
};double& timestamp() { return (ts_); }This structure primarily defines fields used for tracing the flow of packets or measuring other quantities. <strong>The</strong> time stamp fieldis used to measure queuing delay <strong>at</strong> switch nodes. <strong>The</strong> ptype_ field is used to identify the type of packets, which makesreading traces simpler. <strong>The</strong> uid_ field is used by the scheduler in scheduling packet arrivals. <strong>The</strong> size_ field is of generaluse <strong>and</strong> gives the simul<strong>at</strong>ed packet’s size in bytes. Note th<strong>at</strong> the actual number of bytes co<strong>ns</strong>umed in the simul<strong>at</strong>ion may notrel<strong>at</strong>e to the value of this field (i.e., size_ has no rel<strong>at</strong>io<strong>ns</strong>hip to sizeof(struct hdr_cmn) or other <strong>ns</strong> structures).R<strong>at</strong>her, it is used most often in computing the time required for a packet to be delivered along a network link. As such itshould be set to the sum of the applic<strong>at</strong>ion d<strong>at</strong>a size <strong>and</strong> IP-, tra<strong>ns</strong>port-, <strong>and</strong> applic<strong>at</strong>ion-level headers for the simul<strong>at</strong>ed packet.<strong>The</strong> iface_ field is used by the simul<strong>at</strong>or when performing multicast distribution tree comput<strong>at</strong>io<strong>ns</strong>. It is a label indic<strong>at</strong>ing(typically) on which link a packet was received.12.2.4 <strong>The</strong> PacketHeaderManager ClassAn object of the class PacketHeaderManager is used to manage the set of currently-active packet header types <strong>and</strong>assign each of them unique offsets in the BOB. It is defined in both the C++ <strong>and</strong> OTcl code:From tcl/lib/<strong>ns</strong>-packet.tcl:PacketHeaderManager set hdrlen_ 0......foreach prot {AODVARPaSRMCommonCtrMcastDiffusion......TORAUMP} {add-packet-header $prot}Simul<strong>at</strong>or i<strong>ns</strong>tproc cre<strong>at</strong>e_packetform<strong>at</strong> {} {PacketHeaderManager i<strong>ns</strong>tvar tab_set pm [new PacketHeaderManager]foreach cl [PacketHeader info subclass] {if [info exists tab_($cl)] {set off [$pm allochdr $cl]$cl offset $off}}$self set packetManager_ $pm}PacketHeaderManager i<strong>ns</strong>tproc allochdr cl {set size [$cl set hdrlen_]$self i<strong>ns</strong>tvar hdrlen_set NS_ALIGN 8 ;# round up to nearest NS_ALIGN bytes, (needed on sparc/solaris)set incr [expr ($size + ($NS_ALIGN-1)) & ~($NS_ALIGN-1)]set base $hdrlen_123