A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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"
,
15
ns3::IntegerValue
(1),
16
ns3::MakeIntegerChecker<uint32_t> ());
17
static
ns3::GlobalValue
g_rngRun
(
"RngRun"
,
18
"The run number used to modify the global seed"
,
19
ns3::IntegerValue
(1),
20
ns3::MakeIntegerChecker<int64_t> ());
21
22
23
uint32_t
RngSeedManager::GetSeed
(
void
)
24
{
25
NS_LOG_FUNCTION_NOARGS
();
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
43
uint64_t
RngSeedManager::GetRun
()
44
{
45
NS_LOG_FUNCTION_NOARGS
();
46
IntegerValue
value;
47
g_rngRun
.
GetValue
(value);
48
int
run = value.
Get
();
49
return
run;
50
}
51
52
uint64_t
RngSeedManager::GetNextStreamIndex
(
void
)
53
{
54
NS_LOG_FUNCTION_NOARGS
();
55
uint64_t next =
g_nextStreamIndex
;
56
g_nextStreamIndex
++;
57
return
next;
58
}
59
60
}
// namespace ns3
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::IntegerValue
Hold a signed integer type.
Definition:
integer.h:45
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log.h:309
ns3::GlobalValue
hold a so-called 'global value'.
Definition:
global-value.h:47
config.h
ns3::RngSeedManager::SetRun
static void SetRun(uint64_t run)
Set the run number of simulation.
Definition:
rng-seed-manager.cc:37
ns3::RngSeedManager::GetRun
static uint64_t GetRun(void)
Definition:
rng-seed-manager.cc:43
ns3::IntegerValue::Get
int64_t Get(void) const
rng-seed-manager.h
ns3::g_nextStreamIndex
static uint64_t g_nextStreamIndex
Definition:
rng-seed-manager.cc:12
global-value.h
ns3::g_rngRun
static ns3::GlobalValue g_rngRun("RngRun","The run number used to modify the global seed", ns3::IntegerValue(1), ns3::MakeIntegerChecker< int64_t >())
ns3::RngSeedManager::GetSeed
static uint32_t GetSeed(void)
Get the seed value.
Definition:
rng-seed-manager.cc:23
attribute-helper.h
ns3::RngSeedManager::SetSeed
static void SetSeed(uint32_t seed)
set the seed it will duplicate the seed value 6 times
Definition:
rng-seed-manager.cc:31
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("RngSeedManager")
integer.h
ns3::RngSeedManager::GetNextStreamIndex
static uint64_t GetNextStreamIndex(void)
Definition:
rng-seed-manager.cc:52
log.h
ns3::Config::SetGlobal
void SetGlobal(std::string name, const AttributeValue &value)
Definition:
config.cc:707
ns3::g_rngSeed
static ns3::GlobalValue g_rngSeed("RngSeed","The global seed of all rng streams", ns3::IntegerValue(1), ns3::MakeIntegerChecker< uint32_t >())
ns3::GlobalValue::GetValue
void GetValue(AttributeValue &value) const
Definition:
global-value.cc:112
src
core
model
rng-seed-manager.cc
Generated on Sat Apr 19 2014 14:06:52 for ns-3 by
1.8.6