A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::RandomVariableStream Class Referenceabstract

The Random Number Generator (RNG) that allows stream numbers to be set deterministically. More...

#include <random-variable-stream.h>

+ Inheritance diagram for ns3::RandomVariableStream:

Public Member Functions

virtual uint32_t GetInteger (void)=0
 Returns a random integer integer from the underlying distribution. More...
 
int64_t GetStream (void) const
 Returns the stream number for this RNG stream. More...
 
virtual double GetValue (void)=0
 Returns a random double from the underlying distribution. More...
 
bool IsAntithetic (void) const
 Returns true if antithetic values should be generated. More...
 
void SetAntithetic (bool isAntithetic)
 Specifies whether antithetic values should be generated. More...
 
void SetStream (int64_t stream)
 Specifies the stream number for this RNG stream. More...
 
- Public Member Functions inherited from ns3::Object
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 

Protected Member Functions

RngStreamPeek (void) const
 Returns a pointer to the underlying RNG stream.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoDispose (void)
 
virtual void DoInitialize (void)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 

Private Member Functions

 RandomVariableStream (const RandomVariableStream &o)
 
RandomVariableStreamoperator= (const RandomVariableStream &o)
 

Private Attributes

bool m_isAntithetic
 Indicates if antithetic values should be generated by this RNG stream.
 
RngStreamm_rng
 Pointer to the underlying RNG stream.
 
int64_t m_stream
 The stream number for this RNG stream.
 

Detailed Description

The Random Number Generator (RNG) that allows stream numbers to be set deterministically.

Note: The underlying random number generation method used by NS-3 is the RngStream code by Pierre L'Ecuyer at the University of Montreal.

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 functionalty 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 this RNG stream is automatically allocated.

Config Paths

ns3::RandomVariableStream is accessible through the following paths with Config::Set and Config::Connect:

  • /ChannelList/[i]/$ns3::WifiChannel/$ns3::YansWifiChannel/PropagationDelayModel/$ns3::RandomPropagationDelayModel/Variable
  • /ChannelList/[i]/$ns3::WifiChannel/$ns3::YansWifiChannel/PropagationLossModel/$ns3::RandomPropagationLossModel/Variable
  • /ChannelList/[i]/$ns3::YansWifiChannel/PropagationDelayModel/$ns3::RandomPropagationDelayModel/Variable
  • /ChannelList/[i]/$ns3::YansWifiChannel/PropagationLossModel/$ns3::RandomPropagationLossModel/Variable
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::GaussMarkovMobilityModel/MeanDirection
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::GaussMarkovMobilityModel/MeanPitch
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::GaussMarkovMobilityModel/MeanVelocity
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomDirection2dMobilityModel/Pause
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomDirection2dMobilityModel/Speed
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWalk2dMobilityModel/Direction
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWalk2dMobilityModel/Speed
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/Pause
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomBoxPositionAllocator/X
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomBoxPositionAllocator/Y
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomBoxPositionAllocator/Z
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomDiscPositionAllocator/Rho
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomDiscPositionAllocator/Theta
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomRectanglePositionAllocator/X
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/PositionAllocator/$ns3::RandomRectanglePositionAllocator/Y
  • /NodeList/[i]/$ns3::MobilityModel/$ns3::RandomWaypointMobilityModel/Speed
  • /NodeList/[i]/ApplicationList/[i]/$ns3::OnOffApplication/OffTime
  • /NodeList/[i]/ApplicationList/[i]/$ns3::OnOffApplication/OnTime
  • /NodeList/[i]/DeviceList/[i]/$ns3::CsmaNetDevice/ReceiveErrorModel/$ns3::BurstErrorModel/BurstSize
  • /NodeList/[i]/DeviceList/[i]/$ns3::CsmaNetDevice/ReceiveErrorModel/$ns3::BurstErrorModel/BurstStart
  • /NodeList/[i]/DeviceList/[i]/$ns3::CsmaNetDevice/ReceiveErrorModel/$ns3::RateErrorModel/RanVar
  • /NodeList/[i]/DeviceList/[i]/$ns3::PointToPointNetDevice/ReceiveErrorModel/$ns3::BurstErrorModel/BurstSize
  • /NodeList/[i]/DeviceList/[i]/$ns3::PointToPointNetDevice/ReceiveErrorModel/$ns3::BurstErrorModel/BurstStart
  • /NodeList/[i]/DeviceList/[i]/$ns3::PointToPointNetDevice/ReceiveErrorModel/$ns3::RateErrorModel/RanVar
  • /NodeList/[i]/DeviceList/[i]/$ns3::SimpleNetDevice/ReceiveErrorModel/$ns3::BurstErrorModel/BurstSize
  • /NodeList/[i]/DeviceList/[i]/$ns3::SimpleNetDevice/ReceiveErrorModel/$ns3::BurstErrorModel/BurstStart
  • /NodeList/[i]/DeviceList/[i]/$ns3::SimpleNetDevice/ReceiveErrorModel/$ns3::RateErrorModel/RanVar
  • /NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Channel/$ns3::YansWifiChannel/PropagationDelayModel/$ns3::RandomPropagationDelayModel/Variable
  • /NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Channel/$ns3::YansWifiChannel/PropagationLossModel/$ns3::RandomPropagationLossModel/Variable

Attributes

  • Stream: The stream number for this RNG stream. -1 means "allocate a stream automatically". Note that if -1 is set, Get will return -1 so that it is not possible to know which value was automatically allocated.
    • Set with class: ns3::IntegerValue
    • Underlying type: int64_t -9223372036854775808:9223372036854775807
    • Initial value: -1
    • Flags: construct write read
  • Antithetic: Set this RNG stream to generate antithetic values
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read

No TraceSources are defined for this type.

Definition at line 57 of file random-variable-stream.h.

Member Function Documentation

int64_t ns3::RandomVariableStream::GetStream ( void  ) const

Returns the stream number for this RNG stream.

Returns
The stream number for this RNG stream. -1 means "allocate a stream number automatically".

Definition at line 120 of file random-variable-stream.cc.

References m_stream, and NS_LOG_FUNCTION.

void ns3::RandomVariableStream::SetAntithetic ( bool  isAntithetic)

Specifies whether antithetic values should be generated.

Parameters
isAntitheticSet equal to true if antithetic values should be generated by this RNG stream.

Definition at line 79 of file random-variable-stream.cc.

References m_isAntithetic, and NS_LOG_FUNCTION.

void ns3::RandomVariableStream::SetStream ( int64_t  stream)

Specifies the stream number for this RNG stream.

Parameters
streamThe stream number for this RNG stream. -1 means "allocate a stream number automatically".

Definition at line 91 of file random-variable-stream.cc.

References ns3::RngSeedManager::GetRun(), ns3::RngSeedManager::GetSeed(), m_rng, m_stream, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::RandomBuildingPositionAllocator::AssignStreams(), ns3::RandomVariableStreamHelper::AssignStreams(), ns3::RealRandomStream::AssignStreams(), ns3::Radvd::AssignStreams(), ns3::LteUeMac::AssignStreams(), ns3::RandomRoomPositionAllocator::AssignStreams(), ns3::dsdv::RoutingProtocol::AssignStreams(), ns3::dot11s::HwmpProtocol::AssignStreams(), ns3::Backoff::AssignStreams(), ns3::UanMacCw::AssignStreams(), ns3::MinstrelWifiManager::AssignStreams(), ns3::aodv::RoutingProtocol::AssignStreams(), ns3::olsr::RoutingProtocol::AssignStreams(), ns3::OnOffApplication::AssignStreams(), ns3::Ipv6Extension::AssignStreams(), ns3::SameRoomPositionAllocator::AssignStreams(), ns3::MeshWifiInterfaceMac::AssignStreams(), ns3::dot11s::PeerManagementProtocol::AssignStreams(), ns3::YansWifiPhy::AssignStreams(), ns3::RedQueue::AssignStreams(), ns3::SimpleOfdmWimaxPhy::AssignStreams(), ns3::RandomRectanglePositionAllocator::AssignStreams(), ns3::RandomBoxPositionAllocator::AssignStreams(), ns3::UanPhyGen::AssignStreams(), ns3::RateErrorModel::AssignStreams(), ns3::Ipv4GlobalRouting::AssignStreams(), ns3::RandomDiscPositionAllocator::AssignStreams(), ns3::UniformDiscPositionAllocator::AssignStreams(), ns3::BurstErrorModel::AssignStreams(), ns3::LteSpectrumPhy::AssignStreams(), ns3::AnimationInterface::AssignStreams(), ns3::dsr::DsrRouting::AssignStreams(), ns3::JakesPropagationLossModel::DoAssignStreams(), ns3::RandomDirection2dMobilityModel::DoAssignStreams(), ns3::RandomWaypointMobilityModel::DoAssignStreams(), ns3::RandomWalk2dMobilityModel::DoAssignStreams(), ns3::SteadyStateRandomWaypointMobilityModel::DoAssignStreams(), ns3::RandomPropagationDelayModel::DoAssignStreams(), ns3::GaussMarkovMobilityModel::DoAssignStreams(), ns3::RandomPropagationLossModel::DoAssignStreams(), ns3::LteX2HandoverTestCase::DoRun(), ErrorModelSimple::DoRun(), and BurstErrorModelSimple::DoRun().


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