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 ...
25.1.2 OTcl SupportCommandsThe following commands on the RNG class can be accessed from OTcl and are found in tools/rng.cc:seed n – seed the RNG to n, if n == 0, the seed is set according to the current time and a counternext-random – return the next random numberseed – return the current value of the seednext-substream – advance to the next substreamreset-start-substream – reset the stream to the beginning of the current substreamnormal avg std – return a number sampled from a normal distribution with the given average and standard deviationlognormal avg std – return a number sampled from a lognormal distribution with the given average and standard deviationThe following commands on the RNG class can be accessed from OTcl and are found in tcl/lib/ns-random.tcl:exponential mu – return a number sampled from an exponential distribution with mean muuniform min max – return an integer sampled from a uniform distribution on [min, max]integer k – return an integer sampled from a uniform distribution on [0, k-1]Example# Usage: ns rng-test2.tcl [replication number]if {$argc > 1} {puts "Usage: ns rng-test2.tcl \[replication number\]"exit}set run 1if {$argc == 1} {set run [lindex $argv 0]}if {$run < 1} {set run 1}# the default RNG is seeded with 12345# create the RNGs and set them to the correct substreamset arrivalRNG [new RNG]set sizeRNG [new RNG]for {set j 1} {$j < $run} {incr j} {$arrivalRNG next-substream223
}$sizeRNG next-substream# print the first 5 arrival times and sizesfor {set j 0} {$j < 5} {incr j} {puts [format "%-8.3f %-4d" [$arrivalRNG lognormal 5 0.1] \[expr round([$sizeRNG normal 5000 100])]]}Output% ns rng-test2.tcl 1142.776 5038174.365 5024147.160 4984169.693 4981187.972 4982% ns rng-test2.tcl 5160.993 4907119.895 4956149.468 5131137.678 4985158.936 487125.1.3 C++ SupportMember FunctionsThe random number generator is implemented by the RNG class and is defined in tools/rng.h.Note: The Random class in tools/random.h is an older interface to the standard random number stream.Member functions provide the following operations:void set_seed (long seed) – set the seed of the RNG, if seed == 0, the seed is set according to the current timeand a counterlong seed (void) – return the current seedlong next (void) – return the next random number as an integer on [0, MAXINT]double next_double (void) – return the next random number on [0, 1]void reset_start_substream (void) – reset the stream to the beginning of the current substreamvoid reset_next_substream (void) – advance to the next substreamint uniform (int k) – return an integer sampled from a uniform distribution on [0, k-1]double uniform (double r) – return a number sampled from a uniform distribution on [0, r]224
- 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
- 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: set run [lindex $argv 0]}if {$run <
- 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 and 252: Chapter 29Unicast RoutingThis secti
- Page 253 and 254: Asymmetric Routing Asymmetric routi
- 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
}$sizeRNG next-substream# print the first 5 arrival times <strong>and</strong> sizesfor {set j 0} {$j < 5} {incr j} {puts [form<strong>at</strong> "%-8.3f %-4d" [$arrivalRNG lognormal 5 0.1] \[expr round([$sizeRNG normal 5000 100])]]}Output% <strong>ns</strong> rng-test2.tcl 1142.776 5038174.365 5024147.160 4984169.693 4981187.972 4982% <strong>ns</strong> rng-test2.tcl 5160.993 4907119.895 4956149.468 5131137.678 4985158.936 487125.1.3 C++ SupportMember Functio<strong>ns</strong><strong>The</strong> r<strong>and</strong>om number gener<strong>at</strong>or is implemented by the RNG class <strong>and</strong> is defined in tools/rng.h.Note: <strong>The</strong> R<strong>and</strong>om class in tools/r<strong>and</strong>om.h is an older interface to the st<strong>and</strong>ard r<strong>and</strong>om number stream.Member functio<strong>ns</strong> provide the following oper<strong>at</strong>io<strong>ns</strong>:void set_seed (long seed) – set the seed of the RNG, if seed == 0, the seed is set according to the current time<strong>and</strong> a counterlong seed (void) – return the current seedlong next (void) – return the next r<strong>and</strong>om number as an integer on [0, MAXINT]double next_double (void) – return the next r<strong>and</strong>om number on [0, 1]void reset_start_substream (void) – reset the stream to the beginning of the current substreamvoid reset_next_substream (void) – advance to the next substreamint uniform (int k) – return an integer sampled from a uniform distribution on [0, k-1]double uniform (double r) – return a number sampled from a uniform distribution on [0, r]224