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
rng-seed-manager.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 Mathieu Lacage
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
*/
19
20
#include "
rng-seed-manager.h
"
21
#include "
global-value.h
"
22
#include "
attribute-helper.h
"
23
#include "
integer.h
"
24
#include "
config.h
"
25
#include "
log.h
"
26
27
namespace
ns3
{
28
29
NS_LOG_COMPONENT_DEFINE
(
"RngSeedManager"
);
30
36
static
uint64_t g_nextStreamIndex = 0;
43
static
ns3::GlobalValue
g_rngSeed (
"RngSeed"
,
44
"The global seed of all rng streams"
,
45
ns3::IntegerValue
(1),
46
ns3::MakeIntegerChecker<uint32_t> ());
53
static
ns3::GlobalValue
g_rngRun (
"RngRun"
,
54
"The run number used to modify the global seed"
,
55
ns3::IntegerValue
(1),
56
ns3::MakeIntegerChecker<int64_t> ());
57
58
59
uint32_t
RngSeedManager::GetSeed
(
void
)
60
{
61
NS_LOG_FUNCTION_NOARGS
();
62
IntegerValue
seedValue;
63
g_rngSeed
.
GetValue
(seedValue);
64
return
seedValue.
Get
();
65
}
66
void
67
RngSeedManager::SetSeed
(uint32_t seed)
68
{
69
NS_LOG_FUNCTION
(seed);
70
Config::SetGlobal
(
"RngSeed"
,
IntegerValue
(seed));
71
}
72
73
void
RngSeedManager::SetRun
(uint64_t run)
74
{
75
NS_LOG_FUNCTION
(run);
76
Config::SetGlobal
(
"RngRun"
,
IntegerValue
(run));
77
}
78
79
uint64_t
RngSeedManager::GetRun
()
80
{
81
NS_LOG_FUNCTION_NOARGS
();
82
IntegerValue
value;
83
g_rngRun
.
GetValue
(value);
84
int
run = value.
Get
();
85
return
run;
86
}
87
88
uint64_t
RngSeedManager::GetNextStreamIndex
(
void
)
89
{
90
NS_LOG_FUNCTION_NOARGS
();
91
uint64_t next =
g_nextStreamIndex
;
92
g_nextStreamIndex++;
93
return
next;
94
}
95
96
}
// namespace ns3
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Definition:
log-macros-enabled.h:207
ns3::IntegerValue
Hold a signed integer type.
Definition:
integer.h:44
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:170
ns3::GlobalValue
hold a so-called 'global value'.
Definition:
global-value.h:48
config.h
ns3::RngSeedManager::SetRun
static void SetRun(uint64_t run)
Set the run number of simulation.
Definition:
rng-seed-manager.cc:73
ns3::RngSeedManager::GetRun
static uint64_t GetRun(void)
Definition:
rng-seed-manager.cc:79
ns3::IntegerValue::Get
int64_t Get(void) const
Definition:
integer.cc:35
rng-seed-manager.h
ns3::RngSeedManager::g_rngSeed
static ns3::GlobalValue g_rngSeed("RngSeed","The global seed of all rng streams", ns3::IntegerValue(1), ns3::MakeIntegerChecker< uint32_t >())
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
global-value.h
ns3::RngSeedManager::GetSeed
static uint32_t GetSeed(void)
Get the seed value.
Definition:
rng-seed-manager.cc:59
attribute-helper.h
Declaration of Attribute helper macros.
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:67
ns3::RngSeedManager::g_rngRun
static ns3::GlobalValue g_rngRun("RngRun","The run number used to modify the global seed", ns3::IntegerValue(1), ns3::MakeIntegerChecker< int64_t >())
integer.h
Integer attribute value declarations and template implementations.
ns3::RngSeedManager::GetNextStreamIndex
static uint64_t GetNextStreamIndex(void)
Definition:
rng-seed-manager.cc:88
ns3::RngSeedManager::g_nextStreamIndex
static uint64_t g_nextStreamIndex
Definition:
rng-seed-manager.cc:36
log.h
Debug message logging.
ns3::Config::SetGlobal
void SetGlobal(std::string name, const AttributeValue &value)
Definition:
config.cc:717
ns3::GlobalValue::GetValue
void GetValue(AttributeValue &value) const
Definition:
global-value.cc:111
src
core
model
rng-seed-manager.cc
Generated on Thu Feb 5 2015 18:33:34 for ns-3 by
1.8.9.1