A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::RngSeedManager Class Reference

Manage the seed number and run number of the underlying random number generator, and automatic assignment of stream numbers. More...

#include "rng-seed-manager.h"

+ Collaboration diagram for ns3::RngSeedManager:

Static Public Member Functions

static uint64_t GetNextStreamIndex ()
 Get the next automatically assigned stream index.
 
static uint64_t GetRun ()
 Get the current run number.
 
static uint32_t GetSeed ()
 Get the current seed value which will be used by all subsequently instantiated RandomVariableStream objects.
 
static void ResetNextStreamIndex ()
 Resets the global stream index counter.
 
static void SetRun (uint64_t run)
 Set the run number of simulation.
 
static void SetSeed (uint32_t seed)
 Set the seed.
 

Related Symbols

(Note that these are not member symbols.)

static uint64_t g_nextStreamIndex = 0
 The next random number generator stream number to use for automatic assignment.
 
static ns3::GlobalValue g_rngRun ("RngRun", "The substream index used for all streams", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint64_t >())
 The random number generator substream index.
 
static ns3::GlobalValue g_rngSeed ("RngSeed", "The global seed of all rng streams", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
 The random number generator seed number global value.
 

Detailed Description

Manage the seed number and run number of the underlying random number generator, and automatic assignment of stream numbers.

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

Member Function Documentation

◆ GetNextStreamIndex()

uint64_t ns3::RngSeedManager::GetNextStreamIndex ( )
static

Get the next automatically assigned stream index.

Returns
The next stream index.

Definition at line 96 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:

◆ GetRun()

uint64_t ns3::RngSeedManager::GetRun ( )
static

Get the current run number.

Returns
The current run number
See also
SetRun

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

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

Referenced by LteCellSelectionTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), OfdmaAckSequenceTest::DoRun(), Experiment::IncrementCw(), NetAnimExperiment::IncrementCw(), ns3::RandomVariableStream::SetStream(), and ns3::test::RandomVariable::TestCaseBase::SetTestSuiteSeed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSeed()

uint32_t ns3::RngSeedManager::GetSeed ( )
static

Get the current seed value which will be used by all subsequently instantiated RandomVariableStream objects.

Returns
The seed value.

This returns the current seed value.

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

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

Referenced by LteCellSelectionTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), OfdmaAckSequenceTest::DoRun(), ns3::RandomVariableStream::SetStream(), and ns3::test::RandomVariable::TestCaseBase::SetTestSuiteSeed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResetNextStreamIndex()

void ns3::RngSeedManager::ResetNextStreamIndex ( )
static

Resets the global stream index counter.

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

References g_nextStreamIndex.

Referenced by ns3::TestCase::Run().

+ Here is the caller graph for this function:

◆ SetRun()

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);
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.

In this example, N could successively 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:...
Parameters
[in]runThe run number.

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

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

Referenced by BriteTopologyStructureTestCase::DoRun(), Bug2222TestCase::DoRun(), Bug772ChainTest::DoRun(), BurstErrorModelSimple::DoRun(), ChainRegressionTest::DoRun(), DcfImmediateAccessBroadcastTestCase::DoRun(), ErrorModelSimple::DoRun(), FlameRegressionTest::DoRun(), HwmpDoRfRegressionTest::DoRun(), HwmpProactiveRegressionTest::DoRun(), HwmpReactiveRegressionTest::DoRun(), HwmpSimplestRegressionTest::DoRun(), IdealRateManagerChannelWidthTest::DoRun(), IdealRateManagerMimoTest::DoRun(), Issue169TestCase::DoRun(), Issue211Test::DoRun(), LrWpanAckTestCase::DoRun(), LrWpanCcaTestCase::DoRun(), LrWpanEdTestCase::DoRun(), LrWpanErrorDistanceTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), ns3::olsr::Bug780Test::DoRun(), ns3::olsr::HelloRegressionTest::DoRun(), ns3::olsr::TcRegressionTest::DoRun(), ns3::test::RandomVariable::ShuffleElementsTest::DoRun(), PeerManagementProtocolRegressionTest::DoRun(), TestAmpduReception::DoRun(), TestMultipleHeTbPreambles::DoRun(), TestNonHtDuplicatePhyReception::DoRun(), TestPhyHeadersReception::DoRun(), TestSimpleFrameCaptureModel::DoRun(), TestThresholdPreambleDetectionWithFrameCapture::DoRun(), TestThresholdPreambleDetectionWithoutFrameCapture::DoRun(), TestUlOfdmaPpduUid::DoRun(), TestUnsupportedBandwidthReception::DoRun(), TestWifiPhyRxTraceHelper::DoRun(), TestWifiPhyRxTraceHelperMloStr::DoRun(), TestWifiPhyRxTraceHelperYans::DoRun(), ThreeGppChannelMatrixComputationTest::DoRun(), ThreeGppMimoPolarizationTest::DoRun(), ThreeGppV2vBuildingsChCondModelTestCase::DoRun(), ThreeGppV2vHighwayLosNlosvChCondModelTestCase::DoRun(), ThreeGppV2vUrbanLosNlosvChCondModelTestCase::DoRun(), V2vHighwayProbChCondModelTestCase::DoRun(), V2vUrbanProbChCondModelTestCase::DoRun(), WifiChannelSwitchingTest::DoRun(), WifiTxopTest::DoRun(), WifiUseAvailBwTest::DoRun(), ZigbeeRreqRetryTestCase::DoRun(), AidAssignmentTest::DoSetup(), BackoffGenerationTest::DoSetup(), EmlsrOperationsTestBase::DoSetup(), MultiLinkOperationsTestBase::DoSetup(), TestMultipleCtsResponsesFromMuRts::DoSetup(), TestPhyPaddingExclusion::DoSetup(), WifiFilsFrameTest::DoSetup(), WifiPrimaryChannelsTest::DoSetup(), WifiRetransmitTest::DoSetup(), Experiment::IncrementCw(), NetAnimExperiment::IncrementCw(), Experiment::Run(), Issue40TestCase::RunOne(), TestDlMuMimoPhyTransmission::RunOne(), TestDlOfdmaPhyPuncturing::RunOne(), TestDlOfdmaPhyTransmission::RunOne(), TestInterBssConstantObssPdAlgo::RunOne(), TestUlMuMimoPhyTransmission::RunOne(), TestUlOfdmaPhyTransmission::RunOne(), TestUlOfdmaPowerControl::RunOne(), WifiPhyCcaIndicationTest::RunOne(), Bug2470TestCase::RunSubtest(), and StaWifiMacScanningTestCase::Setup().

+ Here is the call graph for this function:

◆ SetSeed()

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

Set the seed.

This sets the global initial seed which will be used all subsequently instantiated RandomVariableStream objects.

UniformVariable x(2,3); // These will give the same output every time
ExponentialVariable y(120); // as long as the seed stays the same.
Parameters
[in]seedThe seed value to use.
Note
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 72 of file rng-seed-manager.cc.

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

Referenced by AodvExample::Configure(), TracerouteExample::Configure(), BriteTopologyStructureTestCase::DoRun(), Bug2222TestCase::DoRun(), Bug772ChainTest::DoRun(), BurstErrorModelSimple::DoRun(), ChainRegressionTest::DoRun(), DcfImmediateAccessBroadcastTestCase::DoRun(), ErrorModelSimple::DoRun(), FlameRegressionTest::DoRun(), HwmpDoRfRegressionTest::DoRun(), HwmpProactiveRegressionTest::DoRun(), HwmpReactiveRegressionTest::DoRun(), HwmpSimplestRegressionTest::DoRun(), IdealRateManagerChannelWidthTest::DoRun(), IdealRateManagerMimoTest::DoRun(), Issue169TestCase::DoRun(), Issue211Test::DoRun(), LrWpanAckTestCase::DoRun(), LrWpanCcaTestCase::DoRun(), LrWpanEdTestCase::DoRun(), LrWpanErrorDistanceTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteRlcUmE2eTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), ns3::olsr::Bug780Test::DoRun(), ns3::olsr::HelloRegressionTest::DoRun(), ns3::olsr::TcRegressionTest::DoRun(), ns3::test::RandomVariable::ShuffleElementsTest::DoRun(), PeerManagementProtocolRegressionTest::DoRun(), RngExponentialTestCase::DoRun(), RngNormalTestCase::DoRun(), RngParetoTestCase::DoRun(), RngUniformTestCase::DoRun(), SteadyStateRandomWaypointTest::DoRun(), TestAmpduReception::DoRun(), TestMultipleHeTbPreambles::DoRun(), TestNonHtDuplicatePhyReception::DoRun(), TestPhyHeadersReception::DoRun(), TestSimpleFrameCaptureModel::DoRun(), TestThresholdPreambleDetectionWithFrameCapture::DoRun(), TestThresholdPreambleDetectionWithoutFrameCapture::DoRun(), TestUlOfdmaPpduUid::DoRun(), TestUnsupportedBandwidthReception::DoRun(), TestWifiPhyRxTraceHelper::DoRun(), TestWifiPhyRxTraceHelperMloStr::DoRun(), TestWifiPhyRxTraceHelperYans::DoRun(), ThreeGppChannelMatrixComputationTest::DoRun(), ThreeGppMimoPolarizationTest::DoRun(), ThreeGppV2vBuildingsChCondModelTestCase::DoRun(), ThreeGppV2vHighwayLosNlosvChCondModelTestCase::DoRun(), ThreeGppV2vUrbanLosNlosvChCondModelTestCase::DoRun(), V2vHighwayProbChCondModelTestCase::DoRun(), V2vUrbanProbChCondModelTestCase::DoRun(), WifiChannelSwitchingTest::DoRun(), WifiTxopTest::DoRun(), WifiUseAvailBwTest::DoRun(), ZigbeeRreqRetryTestCase::DoRun(), AidAssignmentTest::DoSetup(), BackoffGenerationTest::DoSetup(), EmlsrOperationsTestBase::DoSetup(), MultiLinkOperationsTestBase::DoSetup(), TestMultipleCtsResponsesFromMuRts::DoSetup(), TestPhyPaddingExclusion::DoSetup(), WifiFilsFrameTest::DoSetup(), WifiPrimaryChannelsTest::DoSetup(), WifiRetransmitTest::DoSetup(), Experiment::Run(), Issue40TestCase::RunOne(), TestDlMuMimoPhyTransmission::RunOne(), TestDlOfdmaPhyPuncturing::RunOne(), TestDlOfdmaPhyTransmission::RunOne(), TestInterBssConstantObssPdAlgo::RunOne(), TestUlMuMimoPhyTransmission::RunOne(), TestUlOfdmaPhyTransmission::RunOne(), TestUlOfdmaPowerControl::RunOne(), WifiPhyCcaIndicationTest::RunOne(), Bug2470TestCase::RunSubtest(), ns3::test::RandomVariable::TestCaseBase::SetTestSuiteSeed(), and StaWifiMacScanningTestCase::Setup().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ g_nextStreamIndex

uint64_t g_nextStreamIndex = 0
related

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

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

Referenced by GetNextStreamIndex(), and ResetNextStreamIndex().

◆ g_rngRun

ns3::GlobalValue g_rngRun("RngRun", "The substream index used for all streams", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint64_t >())
related

The random number generator substream index.

This is used to generate new PRNG sequences for all streams (random variables) in such a manner that the streams remain uncorrelated. Incrementing this variable can be used for independent replications.

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

Referenced by GetRun().

◆ g_rngSeed

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

The random number generator seed number global value.

This is used to generate an new master PRNG sequence. It is typically not modified by user programs; the variable RngRun is preferred for independent replications.

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

Referenced by GetSeed().


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