leo
leo

Reputation: 13

cant generate random number in omnetpp

I have define host traffic send interval in this way in my NED file and I expect to receive different number in every execution:

    volatile double sendInterval @unit("s") = default(exponential(1s));

but it gives me same result in every execution, where is the problem?

Upvotes: 1

Views: 1071

Answers (1)

Attila
Attila

Reputation: 1493

There isn't any problem here. This is a feature. Any random number in OMNeT++ is actually a pseudo-random number. And they really need to be deterministic, so every experiment can be exactly reproduced.

See the manual section: https://omnetpp.org/doc/omnetpp/manual/#sec:sim-lib:random-number-generators

Where it says:

Starting from the same seed, RNGs always produce the same sequence of random numbers. This is a useful property and of great importance, because it makes simulation runs repeatable.

To get different values, try setting a different seed-set for your configuration in the .ini file, or running multiple repetitions by adjusting the repeat option - each repetition automatically sets a different seed for the PRNGs.

Also see: https://omnetpp.org/doc/omnetpp/manual/#sec:config-sim:repeating-runs-with-different-seeds

Upvotes: 3

Related Questions