[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ns-3 simulations can be configured to produce deterministic or random results. If the ns-3 simulation is configured to use a fixed, deterministic seed with the same run number, it should give the same output each time it is run.
By default, ns-3 simulations use random seeds where the seeding
is drawn from /dev/random
(if it is available) or else from
the time of day. A user who wants to fix the initial seeding
of the PRNG must call the following static method during simulation
configuration:
RandomVariable::UseGlobalSeed (uint32_t s0, s1, s2, s3, s4, s5);
where the six parameters are each of type uint32_t.
A typical use case is to run a simulation as a sequence of independent trials, so as to compute statistics on a large number of independent runs. The user can either change the global seed and rerun the simulation, or can advance the substream state of the RNG. This seeding and substream state setting must be called before any random variables are created; e.g.
RandomVariable::UseGlobalSeed(1,2,3,4,5,6); int N = atol(argv[1]); //read in run number from command line RandomVariable::SetRunNumber(N); // Now, create random variables UniformVariable x(0,10); ExponentialVariable y(2902); ...
Which is better, setting a new seed or advancing the substream state? There is no guarantee that the streams produced by two random seeds will not overlap. The only way to guarantee that two streams do not overlap is to use the substream capability provided by the RNG implementation. Therefore, use the substream capability to produce multiple independent runs of the same simulation. In other words, the more statistically rigorous way to configure multiple independent replications is not to simply ignore the seeding (and use /dev/random to seed the generator each time) but instead to use a fixed seed and to iterate the run number. This implementation allows for a maximum of 2.3x10^15 independent replications using the substreams.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated on December, 19 2008 using texi2html 1.78.