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
src
core
model
rng-seed-manager.cc
Generated on Tue May 14 2013 11:08:18 for ns-3 by
1.8.1.2