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 
7 namespace ns3 {
8 
9 static uint64_t g_nextStreamIndex = 0;
10 static ns3::GlobalValue g_rngSeed ("RngSeed",
11  "The global seed of all rng streams",
13  ns3::MakeIntegerChecker<uint32_t> ());
14 static ns3::GlobalValue g_rngRun ("RngRun",
15  "The run number used to modify the global seed",
17  ns3::MakeIntegerChecker<int64_t> ());
18 
19 
20 uint32_t RngSeedManager::GetSeed (void)
21 {
22  IntegerValue seedValue;
23  g_rngSeed.GetValue (seedValue);
24  return seedValue.Get ();
25 }
26 void
27 RngSeedManager::SetSeed (uint32_t seed)
28 {
29  Config::SetGlobal ("RngSeed", IntegerValue(seed));
30 }
31 
32 void RngSeedManager::SetRun (uint64_t run)
33 {
34  Config::SetGlobal ("RngRun", IntegerValue (run));
35 }
36 
38 {
39  IntegerValue value;
40  g_rngRun.GetValue (value);
41  int run = value.Get();
42  return run;
43 }
44 
46 {
47  uint64_t next = g_nextStreamIndex;
49  return next;
50 }
51 
52 } // namespace ns3