A Discrete-Event Network Simulator
API
ns3::RngSeedManager Class Reference

#include <rng-seed-manager.h>

+ Collaboration diagram for ns3::RngSeedManager:

Static Public Member Functions

static uint64_t GetNextStreamIndex (void)
 
static uint64_t GetRun (void)
 
static uint32_t GetSeed (void)
 Get the seed value. More...
 
static void SetRun (uint64_t run)
 Set the run number of simulation. More...
 
static void SetSeed (uint32_t seed)
 set the seed it will duplicate the seed value 6 times More...
 

Related Functions

(Note that these are not member functions.)

static uint64_t g_nextStreamIndex = 0
 
static ns3::GlobalValue g_rngRun ("RngRun","The run number used to modify the global seed", ns3::IntegerValue(1), ns3::MakeIntegerChecker< int64_t >())
 
static ns3::GlobalValue g_rngSeed ("RngSeed","The global seed of all rng streams", ns3::IntegerValue(1), ns3::MakeIntegerChecker< uint32_t >())
 

Detailed Description

Definition at line 27 of file rng-seed-manager.h.

Member Function Documentation

uint64_t ns3::RngSeedManager::GetNextStreamIndex ( void  )
static

Definition at line 94 of file rng-seed-manager.cc.

References g_nextStreamIndex, and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::RandomVariableStream::SetStream().

+ Here is the caller graph for this function:

uint64_t ns3::RngSeedManager::GetRun ( void  )
static
Returns
the current run number
See also
SetRun

Definition at line 85 of file rng-seed-manager.cc.

References g_rngRun, ns3::IntegerValue::Get(), ns3::GlobalValue::GetValue(), and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::RandomVariableStream::SetStream().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t ns3::RngSeedManager::GetSeed ( void  )
static

Get the seed value.

Returns
the seed value

Note: returns the first of the six seed values used in the underlying RNG

Definition at line 65 of file rng-seed-manager.cc.

References g_rngSeed, ns3::IntegerValue::Get(), ns3::GlobalValue::GetValue(), and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::RandomVariableStream::SetStream().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::RngSeedManager::SetRun ( uint64_t  run)
static

Set the run number of simulation.

int N = atol(argv[1]); //read in run number from command line
UniformVariable x(0,10);
ExponentialVariable y(2902);

In this example, N could successivly be equal to 1,2,3, etc. and the user would continue to get independent runs out of the single simulation. For this simple example, the following might work:

./simulation 0
...Results for run 0:...
./simulation 1
...Results for run 1:...

Definition at line 79 of file rng-seed-manager.cc.

References NS_LOG_FUNCTION, and ns3::Config::SetGlobal().

Referenced by ns3::olsr::Bug780Test::DoRun(), ns3::olsr::HelloRegressionTest::DoRun(), and ns3::olsr::TcRegressionTest::DoRun().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::RngSeedManager::SetSeed ( uint32_t  seed)
static

set the seed it will duplicate the seed value 6 times

RngSeedManger::SetSeed(15);
UniformVariable x(2,3); //these will give the same output everytime
ExponentialVariable y(120); //as long as the seed stays the same
Parameters
seedNote, while the underlying RNG takes six integer values as a seed; it is sufficient to set these all to the same integer, so we provide a simpler interface here that just takes one integer.

Definition at line 73 of file rng-seed-manager.cc.

References NS_LOG_FUNCTION, and ns3::Config::SetGlobal().

Referenced by SteadyStateRandomWaypointTest::DoRun(), ns3::olsr::Bug780Test::DoRun(), ns3::olsr::HelloRegressionTest::DoRun(), and ns3::olsr::TcRegressionTest::DoRun().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

uint64_t g_nextStreamIndex = 0
related

The next random number generator stream number to use for automatic assignment.

Definition at line 42 of file rng-seed-manager.cc.

Referenced by GetNextStreamIndex().

ns3::GlobalValue g_rngRun("RngRun","The run number used to modify the global seed", ns3::IntegerValue(1), ns3::MakeIntegerChecker< int64_t >())
related

The random number generator run number global value.

This is accessible as "--RngRun" from CommandLine.

Referenced by GetRun().

ns3::GlobalValue g_rngSeed("RngSeed","The global seed of all rng streams", ns3::IntegerValue(1), ns3::MakeIntegerChecker< uint32_t >())
related

The random number generator seed number global value.

This is accessible as "--RngSeed" from CommandLine.

Referenced by GetSeed().


The documentation for this class was generated from the following files: