The basic uniform Random Number Generator (RNG). More...
#include "random-variable-stream.h"
Public Member Functions | |
RandomVariableStream () | |
Default constructor. More... | |
RandomVariableStream (const RandomVariableStream &)=delete | |
~RandomVariableStream () override | |
Destructor. More... | |
virtual uint32_t | GetInteger () |
Get the next random value drawn from the distribution. More... | |
int64_t | GetStream () const |
Returns the stream number for the RngStream. More... | |
virtual double | GetValue ()=0 |
Get the next random value drawn from the distribution. More... | |
bool | IsAntithetic () const |
Check if antithetic values will be generated. More... | |
RandomVariableStream & | operator= (const RandomVariableStream &)=delete |
void | SetAntithetic (bool isAntithetic) |
Specify whether antithetic values should be generated. More... | |
void | SetStream (int64_t stream) |
Specifies the stream number for the RngStream. More... | |
![]() | |
Object () | |
Constructor. More... | |
~Object () override | |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose () |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. More... | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. More... | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. More... | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized () const |
Check if the object has been initialized. More... | |
![]() | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o[[maybe_unused]]) |
Assignment operator. More... | |
void | Ref () const |
Increment the reference count. More... | |
void | Unref () const |
Decrement the reference count. More... | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Register this type. More... | |
![]() | |
static TypeId | GetTypeId () |
Register this type. More... | |
![]() | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Protected Member Functions | |
RngStream * | Peek () const |
Get the pointer to the underlying RngStream. More... | |
![]() | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoDispose () |
Destructor implementation. More... | |
virtual void | DoInitialize () |
Initialize() implementation. More... | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. More... | |
Private Attributes | |
bool | m_isAntithetic |
Indicates if antithetic values should be generated by this RNG stream. More... | |
RngStream * | m_rng |
Pointer to the underlying RngStream. More... | |
int64_t | m_stream |
The stream number for the RngStream. More... | |
Additional Inherited Members | |
![]() | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
The basic uniform Random Number Generator (RNG).
ns-3 has a rich set of random number generators that allow stream numbers to be set deterministically if desired. Class RandomVariableStream defines the base class functionality required for all such random number generators.
By default, the underlying generator is seeded all the time with the same seed value and run number coming from the ns3::GlobalValue RngSeed and RngRun. Also by default, the stream number value for the underlying RngStream is automatically allocated.
Instances can be configured to return "antithetic" values. See the documentation for the specific distributions to see how this modifies the returned values.
Definition at line 100 of file random-variable-stream.h.
ns3::RandomVariableStream::RandomVariableStream | ( | ) |
Default constructor.
Definition at line 79 of file random-variable-stream.cc.
References NS_LOG_FUNCTION.
|
override |
Destructor.
Definition at line 85 of file random-variable-stream.cc.
References m_rng, and NS_LOG_FUNCTION.
|
delete |
|
virtual |
Get the next random value drawn from the distribution.
Reimplemented in ns3::UniformRandomVariable, ns3::BernoulliRandomVariable, ns3::BinomialRandomVariable, ns3::EmpiricalRandomVariable, ns3::DeterministicRandomVariable, ns3::ZetaRandomVariable, ns3::ZipfRandomVariable, ns3::TriangularRandomVariable, ns3::ErlangRandomVariable, ns3::GammaRandomVariable, ns3::LogNormalRandomVariable, ns3::NormalRandomVariable, ns3::WeibullRandomVariable, ns3::ParetoRandomVariable, ns3::ExponentialRandomVariable, ns3::SequentialRandomVariable, and ns3::ConstantRandomVariable.
Definition at line 106 of file random-variable-stream.cc.
References GetValue(), and NS_LOG_FUNCTION.
Referenced by ns3::BurstErrorModel::DoCorrupt(), and ns3::MeshPointDevice::GetForwardingDelay().
int64_t ns3::RandomVariableStream::GetStream | ( | ) | const |
Returns the stream number for the RngStream.
Definition at line 139 of file random-variable-stream.cc.
References m_stream, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
static |
Register this type.
Definition at line 55 of file random-variable-stream.cc.
References GetStream(), IsAntithetic(), ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeIntegerAccessor(), SetAntithetic(), ns3::TypeId::SetParent(), and SetStream().
|
pure virtual |
Get the next random value drawn from the distribution.
Implemented in ns3::BernoulliRandomVariable, ns3::BinomialRandomVariable, ns3::EmpiricalRandomVariable, ns3::DeterministicRandomVariable, ns3::ZetaRandomVariable, ns3::ZipfRandomVariable, ns3::TriangularRandomVariable, ns3::ErlangRandomVariable, ns3::GammaRandomVariable, ns3::LogNormalRandomVariable, ns3::NormalRandomVariable, ns3::WeibullRandomVariable, ns3::ParetoRandomVariable, ns3::ExponentialRandomVariable, ns3::SequentialRandomVariable, ns3::ConstantRandomVariable, and ns3::UniformRandomVariable.
Referenced by ns3::test::RandomVariable::TestCaseBase::Average(), ns3::RandomWalk2dOutdoorMobilityModel::AvoidBuilding(), ns3::RandomDirection2dMobilityModel::BeginPause(), ns3::RandomWaypointMobilityModel::BeginWalk(), ns3::DhcpClient::Boot(), ns3::BasicEnergyHarvester::CalculateHarvestedPower(), ns3::test::RandomVariable::TestCaseBase::ChiSquared(), ns3::RandomPropagationLossModel::DoCalcRxPower(), ns3::BurstErrorModel::DoCorrupt(), ns3::RateErrorModel::DoCorruptBit(), ns3::RateErrorModel::DoCorruptByte(), ns3::RateErrorModel::DoCorruptPkt(), ns3::Icmpv6L4Protocol::DoDAD(), ns3::RandomWalk2dOutdoorMobilityModel::DoInitializePrivate(), ns3::RandomWalk2dMobilityModel::DoInitializePrivate(), ns3::RandomWaypointMobilityModel::DoInitializePrivate(), ns3::RandomPropagationDelayModel::GetDelay(), GetInteger(), ns3::OutdoorPositionAllocator::GetNext(), ns3::RandomRectanglePositionAllocator::GetNext(), ns3::RandomBoxPositionAllocator::GetNext(), ns3::RandomDiscPositionAllocator::GetNext(), ns3::SequentialRandomVariable::GetValue(), ns3::ArpL3Protocol::Lookup(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), ns3::DhcpClient::Request(), ns3::OnOffApplication::ScheduleStartEvent(), ns3::OnOffApplication::ScheduleStopEvent(), ns3::Icmpv6L4Protocol::SendNS(), ns3::Icmpv6L4Protocol::SendRS(), ns3::RandomDirection2dMobilityModel::SetDirectionAndSpeed(), ns3::GaussMarkovMobilityModel::Start(), ns3::StaWifiMac::StartScanning(), and ns3::ApplicationContainer::StartWithJitter().
bool ns3::RandomVariableStream::IsAntithetic | ( | ) | const |
Check if antithetic values will be generated.
true
if antithetic values will be generated. Definition at line 99 of file random-variable-stream.cc.
References m_isAntithetic, and NS_LOG_FUNCTION.
Referenced by ns3::ErlangRandomVariable::GetExponentialValue(), ns3::GammaRandomVariable::GetNormalValue(), GetTypeId(), ns3::GammaRandomVariable::GetValue(), ns3::ExponentialRandomVariable::GetValue(), ns3::TriangularRandomVariable::GetValue(), ns3::NormalRandomVariable::GetValue(), ns3::UniformRandomVariable::GetValue(), ns3::LogNormalRandomVariable::GetValue(), ns3::BernoulliRandomVariable::GetValue(), ns3::ParetoRandomVariable::GetValue(), ns3::WeibullRandomVariable::GetValue(), ns3::ZipfRandomVariable::GetValue(), ns3::BinomialRandomVariable::GetValue(), and ns3::EmpiricalRandomVariable::PreSample().
|
delete |
|
protected |
Get the pointer to the underlying RngStream.
Definition at line 146 of file random-variable-stream.cc.
References m_rng, and NS_LOG_FUNCTION.
Referenced by ns3::ErlangRandomVariable::GetExponentialValue(), ns3::GammaRandomVariable::GetNormalValue(), ns3::GammaRandomVariable::GetValue(), ns3::ExponentialRandomVariable::GetValue(), ns3::TriangularRandomVariable::GetValue(), ns3::NormalRandomVariable::GetValue(), ns3::UniformRandomVariable::GetValue(), ns3::LogNormalRandomVariable::GetValue(), ns3::BernoulliRandomVariable::GetValue(), ns3::ParetoRandomVariable::GetValue(), ns3::WeibullRandomVariable::GetValue(), ns3::ZipfRandomVariable::GetValue(), ns3::BinomialRandomVariable::GetValue(), and ns3::EmpiricalRandomVariable::PreSample().
void ns3::RandomVariableStream::SetAntithetic | ( | bool | isAntithetic | ) |
Specify whether antithetic values should be generated.
[in] | isAntithetic | If true antithetic value will be generated. |
Definition at line 92 of file random-variable-stream.cc.
References m_isAntithetic, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::RandomVariableStream::SetStream | ( | int64_t | stream | ) |
Specifies the stream number for the RngStream.
[in] | stream | The stream number for the RngStream. -1 means "allocate a stream number automatically". |
Definition at line 113 of file random-variable-stream.cc.
References ns3::RngSeedManager::GetNextStreamIndex(), ns3::RngSeedManager::GetRun(), ns3::RngSeedManager::GetSeed(), m_rng, m_stream, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by RandCartAroundGeoTestSuite::RandCartAroundGeoTestSuite(), ns3::aodv::RoutingProtocol::AssignStreams(), ns3::OnOffApplication::AssignStreams(), ns3::ThreeGppHttpVariables::AssignStreams(), ns3::Backoff::AssignStreams(), ns3::dsdv::RoutingProtocol::AssignStreams(), ns3::dsr::DsrRouting::AssignStreams(), ns3::BasicEnergyHarvester::AssignStreams(), ns3::DhcpClient::AssignStreams(), ns3::Radvd::AssignStreams(), ns3::ArpL3Protocol::AssignStreams(), ns3::Icmpv6L4Protocol::AssignStreams(), ns3::Ipv4GlobalRouting::AssignStreams(), ns3::Ipv6Extension::AssignStreams(), ns3::Rip::AssignStreams(), ns3::RipNg::AssignStreams(), ns3::LrWpanCsmaCa::AssignStreams(), ns3::LrWpanPhy::AssignStreams(), ns3::LteSpectrumPhy::AssignStreams(), ns3::LteUeMac::AssignStreams(), ns3::dot11s::HwmpProtocol::AssignStreams(), ns3::dot11s::PeerManagementProtocol::AssignStreams(), ns3::MeshPointDevice::AssignStreams(), ns3::MeshWifiInterfaceMac::AssignStreams(), ns3::RateErrorModel::AssignStreams(), ns3::BurstErrorModel::AssignStreams(), ns3::olsr::RoutingProtocol::AssignStreams(), ns3::SixLowPanNetDevice::AssignStreams(), ns3::ThreeGppChannelModel::AssignStreams(), ns3::CobaltQueueDisc::AssignStreams(), ns3::PieQueueDisc::AssignStreams(), ns3::RedQueueDisc::AssignStreams(), ns3::ApWifiMac::AssignStreams(), ns3::StaWifiMac::AssignStreams(), ns3::Txop::AssignStreams(), ns3::WifiPhy::AssignStreams(), ns3::RandomBuildingPositionAllocator::AssignStreams(), ns3::OutdoorPositionAllocator::AssignStreams(), ns3::RandomRoomPositionAllocator::AssignStreams(), ns3::RandomRectanglePositionAllocator::AssignStreams(), ns3::RandomBoxPositionAllocator::AssignStreams(), ns3::RandomDiscPositionAllocator::AssignStreams(), ns3::UniformDiscPositionAllocator::AssignStreams(), ns3::ThreeGppChannelConditionModel::AssignStreams(), ns3::UanMacCw::AssignStreams(), ns3::UanMacRc::AssignStreams(), ns3::UanPhyGen::AssignStreams(), ns3::MinstrelHtWifiManager::AssignStreams(), ns3::MinstrelWifiManager::AssignStreams(), ns3::RrpaaWifiManager::AssignStreams(), ns3::SimpleOfdmWimaxPhy::AssignStreams(), ns3::TrickleTimer::AssignStreams(), ns3::TvSpectrumTransmitterHelper::AssignStreams(), ns3::BriteTopologyHelper::AssignStreams(), ns3::SameRoomPositionAllocator::AssignStreams(), ns3::FixedRoomPositionAllocator::AssignStreams(), ns3::RandomVariableStreamHelper::AssignStreams(), ns3::JakesPropagationLossModel::DoAssignStreams(), ns3::RandomPropagationDelayModel::DoAssignStreams(), ns3::RandomPropagationLossModel::DoAssignStreams(), ns3::ThreeGppPropagationLossModel::DoAssignStreams(), ns3::ThreeGppUmaPropagationLossModel::DoAssignStreams(), ns3::ThreeGppV2vUrbanPropagationLossModel::DoAssignStreams(), ns3::TwoRaySpectrumPropagationLossModel::DoAssignStreams(), ns3::RandomWalk2dOutdoorMobilityModel::DoAssignStreams(), ns3::GaussMarkovMobilityModel::DoAssignStreams(), ns3::RandomDirection2dMobilityModel::DoAssignStreams(), ns3::RandomWalk2dMobilityModel::DoAssignStreams(), ns3::RandomWaypointMobilityModel::DoAssignStreams(), ns3::SteadyStateRandomWaypointMobilityModel::DoAssignStreams(), ns3::TraceFadingLossModel::DoCalcRxPowerSpectralDensity(), LteX2HandoverMeasuresTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), ErrorModelSimple::DoRun(), BurstErrorModelSimple::DoRun(), GetTypeId(), and ns3::TcpBbr::SetStream().
|
private |
Indicates if antithetic values should be generated by this RNG stream.
Definition at line 169 of file random-variable-stream.h.
Referenced by IsAntithetic(), and SetAntithetic().
|
private |
Pointer to the underlying RngStream.
Definition at line 166 of file random-variable-stream.h.
Referenced by ~RandomVariableStream(), Peek(), and SetStream().
|
private |
The stream number for the RngStream.
Definition at line 172 of file random-variable-stream.h.
Referenced by GetStream(), and SetStream().