diff --git a/src/core/random-variable.cc b/src/core/random-variable.cc index 891a6c3ed..8583ac0fd 100644 --- a/src/core/random-variable.cc +++ b/src/core/random-variable.cc @@ -33,6 +33,7 @@ #include "assert.h" +#include "config.h" #include "integer.h" #include "random-variable.h" #include "rng-stream.h" @@ -62,14 +63,12 @@ uint32_t SeedManager::GetSeed() void SeedManager::SetSeed(uint32_t seed) { - IntegerValue seedValue(seed); - g_rngSeed.SetValue(seedValue); + Config::SetGlobal("RngSeed", IntegerValue(seed)); } void SeedManager::SetRun(uint32_t run) { - IntegerValue runValue(run); - g_rngRun.SetValue(runValue); + Config::SetGlobal("RngRun", IntegerValue(run)); } uint32_t SeedManager::GetRun() diff --git a/src/core/rng-stream.cc b/src/core/rng-stream.cc index c464ef055..fb0320f32 100644 --- a/src/core/rng-stream.cc +++ b/src/core/rng-stream.cc @@ -201,15 +201,7 @@ void MatPowModM (const double A[3][3], double B[3][3], double m, int32_t n) } } -static ns3::GlobalValue g_rngSeed ("RngSeed", - "The global seed of all rng streams", - (getenv ("NS_RNG") !=0) ? GetSeedFromEnv() : ns3::IntegerValue (1), - ns3::MakeIntegerChecker ()); -static ns3::GlobalValue g_rngRun ("RngRun", - "The run number used to modify the global seed", - (getenv ("NS_RNG") !=0) ? GetRunFromEnv() : ns3::IntegerValue (1), - ns3::MakeIntegerChecker ()); - +//two seeding methods follow ns3::IntegerValue GetSeedFromEnv () { uint32_t seed; @@ -254,6 +246,15 @@ ns3::IntegerValue GetRunFromEnv () return run; } +static ns3::GlobalValue g_rngSeed ("RngSeed", + "The global seed of all rng streams", + (getenv ("NS_RNG") !=0) ? GetSeedFromEnv() : ns3::IntegerValue (1), + ns3::MakeIntegerChecker ()); +static ns3::GlobalValue g_rngRun ("RngRun", + "The run number used to modify the global seed", + (getenv ("NS_RNG") !=0) ? GetRunFromEnv() : ns3::IntegerValue (1), + ns3::MakeIntegerChecker ()); + } // end of anonymous namespace @@ -425,11 +426,11 @@ RngStream::RngStream () { g_rngSeed.GetValue (tmp); SetPackageSeed (tmp.Get()); - initialized = true; + globalSeedInitialized = true; } //get the global run number - g_rngRun.GetValue (value); - uint32_t run = value.Get (); + g_rngRun.GetValue (tmp); + uint32_t run = tmp.Get (); anti = false; incPrec = false; diff --git a/utils/run-tests.cc b/utils/run-tests.cc index 2e7fd3321..0e1d3ef91 100644 --- a/utils/run-tests.cc +++ b/utils/run-tests.cc @@ -26,8 +26,6 @@ int main (int argc, char *argv[]) { #ifdef RUN_SELF_TESTS - uint32_t rngSeed[6] = {1,2,3,4,5,6}; - ns3::SeedManager::SetSeed(rngSeed); ns3::PacketMetadata::Enable (); ns3::TestManager::EnableVerbose (); bool success = ns3::TestManager::RunTests ();