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
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Hold a signed integer type.
Definition: integer.h:45
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
hold a so-called 'global value'.
Definition: global-value.h:47
static void SetRun(uint64_t run)
Set the run number of simulation.
static uint64_t GetRun(void)
int64_t Get(void) const
static uint64_t g_nextStreamIndex
static ns3::GlobalValue g_rngRun("RngRun","The run number used to modify the global seed", ns3::IntegerValue(1), ns3::MakeIntegerChecker< int64_t >())
static uint32_t GetSeed(void)
Get the seed value.
static void SetSeed(uint32_t seed)
set the seed it will duplicate the seed value 6 times
NS_LOG_COMPONENT_DEFINE("RngSeedManager")
static uint64_t GetNextStreamIndex(void)
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:707
static ns3::GlobalValue g_rngSeed("RngSeed","The global seed of all rng streams", ns3::IntegerValue(1), ns3::MakeIntegerChecker< uint32_t >())
void GetValue(AttributeValue &value) const