12.07.2015 Views

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 ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

25.1.2 OTcl SupportComm<strong>and</strong>s<strong>The</strong> following comm<strong>and</strong>s on the RNG class can be accessed from OTcl <strong>and</strong> 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 <strong>and</strong> a counternext-r<strong>and</strong>om – return the next r<strong>and</strong>om 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 <strong>and</strong> st<strong>and</strong>ard devi<strong>at</strong>ionlognormal avg std – return a number sampled from a lognormal distribution with the given average <strong>and</strong> st<strong>and</strong>ard devi<strong>at</strong>ion<strong>The</strong> following comm<strong>and</strong>s on the RNG class can be accessed from OTcl <strong>and</strong> are found in tcl/lib/<strong>ns</strong>-r<strong>and</strong>om.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: <strong>ns</strong> rng-test2.tcl [replic<strong>at</strong>ion number]if {$argc > 1} {puts "Usage: <strong>ns</strong> rng-test2.tcl \[replic<strong>at</strong>ion 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# cre<strong>at</strong>e the RNGs <strong>and</strong> set them to the correct substreamset arrivalRNG [new RNG]set sizeRNG [new RNG]for {set j 1} {$j < $run} {incr j} {$arrivalRNG next-substream223

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!