A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rng-seed-manager.cc
Go to the documentation of this file.
1 #include "rng-seed-manager.h"
2 #include "global-value.h"
3 #include "attribute-helper.h"
4 #include "integer.h"
5 #include "config.h"
6 #include "log.h"
7 
8 NS_LOG_COMPONENT_DEFINE ("RngSeedManager");
9 
10 namespace ns3 {
11 
12 static uint64_t g_nextStreamIndex = 0;
13 static ns3::GlobalValue g_rngSeed ("RngSeed",
14  "The global seed of all rng streams",
16  ns3::MakeIntegerChecker<uint32_t> ());
17 static ns3::GlobalValue g_rngRun ("RngRun",
18  "The run number used to modify the global seed",
20  ns3::MakeIntegerChecker<int64_t> ());
21 
22 
23 uint32_t RngSeedManager::GetSeed (void)
24 {
26  IntegerValue seedValue;
27  g_rngSeed.GetValue (seedValue);
28  return seedValue.Get ();
29 }
30 void
31 RngSeedManager::SetSeed (uint32_t seed)
32 {
33  NS_LOG_FUNCTION (seed);
34  Config::SetGlobal ("RngSeed", IntegerValue(seed));
35 }
36 
37 void RngSeedManager::SetRun (uint64_t run)
38 {
39  NS_LOG_FUNCTION (run);
40  Config::SetGlobal ("RngRun", IntegerValue (run));
41 }
42 
44 {
46  IntegerValue value;
47  g_rngRun.GetValue (value);
48  int run = value.Get();
49  return run;
50 }
51 
53 {
55  uint64_t next = g_nextStreamIndex;
57  return next;
58 }
59 
60 } // namespace ns3