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.

set run [lindex $argv 0]}if {$run < 1} {set run 1}# seed the default RNGglobal defaultRNG$defaultRNG seed 9999# 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-substream$sizeRNG next-substream}# arrival_ is a exponential r<strong>and</strong>om variable describing the time# between co<strong>ns</strong>ecutive packet arrivalsset arrival_ [new R<strong>and</strong>omVariable/Exponential]$arrival_ set avg_ 5$arrival_ use-rng $arrivalRNG# size_ is a uniform r<strong>and</strong>om variable describing packet sizesset size_ [new R<strong>and</strong>omVariable/Uniform]$size_ set min_ 100$size_ set max_ 5000$size_ use-rng $sizeRNG# 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" [$arrival_ value] \[expr round([$size_ value])]]}Output% <strong>ns</strong> rng-test.tcl 16.358 47835.828 17321.469 21880.732 30764.002 626% <strong>ns</strong> rng-test.tcl 50.691 11870.204 49248.849 8572.111 45053.200 1143222

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

Saved successfully!

Ooh no, something went wrong!