A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::DeterministicRandomVariable Class Reference

The Random Number Generator (RNG) that returns a predetermined sequence. More...

#include <random-variable-stream.h>

+ Inheritance diagram for ns3::DeterministicRandomVariable:
+ Collaboration diagram for ns3::DeterministicRandomVariable:

Public Member Functions

 DeterministicRandomVariable ()
 Creates a deterministic RNG that will have a predetermined sequence of values.
virtual ~DeterministicRandomVariable ()
virtual uint32_t GetInteger (void)
 Returns the next value in the sequence.
virtual double GetValue (void)
 Returns the next value in the sequence.
void SetValueArray (double *values, uint64_t length)
 Sets the array of values that holds the predetermined sequence.
- Public Member Functions inherited from ns3::RandomVariableStream
 RandomVariableStream ()
virtual ~RandomVariableStream ()
int64_t GetStream (void) const
 Returns the stream number for this RNG stream.
bool IsAntithetic (void) const
 Returns true if antithetic values should be generated.
void SetAntithetic (bool isAntithetic)
 Specifies whether antithetic values should be generated.
void SetStream (int64_t stream)
 Specifies the stream number for this RNG stream.
- Public Member Functions inherited from ns3::Object
 Object ()
virtual ~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 Start (void)
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 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
virtual ~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)
 This method returns the TypeId associated to ns3::DeterministicRandomVariable.

Private Attributes

uint64_t m_count
 Position in the array of values.
double * m_data
 Array of values to return in sequence.
uint64_t m_next
 Position of the next value in the array of values.

Additional Inherited Members

- Protected Member Functions inherited from ns3::RandomVariableStream
RngStreamPeek (void) const
 Returns a pointer to the underlying RNG stream.

Detailed Description

The Random Number Generator (RNG) that returns a predetermined sequence.

Defines a random variable that has a specified, predetermined sequence. This would be useful when trying to force the RNG to return a known sequence, perhaps to compare NS-3 to some other simulator

Creates a generator that returns successive elements of the values array on successive calls to RandomVariableStream::GetValue. Note that the values in the array are copied and stored by the generator (deep-copy). Also note that the sequence repeats if more values are requested than are present in the array.

Here is an example of how to use this class:

Ptr<DeterministicRandomVariable> s = CreateObject<DeterministicRandomVariable> ();
// The following array should give the sequence
//
// 4, 4, 7, 7, 10, 10 .
//
double array [] = { 4, 4, 7, 7, 10, 10};
uint64_t count = 6;
s->SetValueArray (array, count);
double value = x->GetValue ();

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

Constructor & Destructor Documentation

ns3::DeterministicRandomVariable::DeterministicRandomVariable ( )

Creates a deterministic RNG that will have a predetermined sequence of values.

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

ns3::DeterministicRandomVariable::~DeterministicRandomVariable ( )
virtual

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

References m_data.

Member Function Documentation

uint32_t ns3::DeterministicRandomVariable::GetInteger ( void  )
virtual

Returns the next value in the sequence.

Returns
The integer next value in the sequence.

Implements ns3::RandomVariableStream.

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

References GetValue().

+ Here is the call graph for this function:

TypeId ns3::DeterministicRandomVariable::GetTypeId ( void  )
static

This method returns the TypeId associated to ns3::DeterministicRandomVariable.

This object is accessible through the following paths with Config::Set and Config::Connect:

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

No Attributes defined for this type.
Attributes defined in parent class ns3::RandomVariableStream:

  • 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 defined for this type.

Reimplemented from ns3::RandomVariableStream.

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

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

double ns3::DeterministicRandomVariable::GetValue ( void  )
virtual

Returns the next value in the sequence.

Returns
The floating point next value in the sequence.

Implements ns3::RandomVariableStream.

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

References m_count, m_data, m_next, and NS_ASSERT.

Referenced by RandomVariableStreamDeterministicTestCase::DoRun(), and GetInteger().

+ Here is the caller graph for this function:

void ns3::DeterministicRandomVariable::SetValueArray ( double *  values,
uint64_t  length 
)

Sets the array of values that holds the predetermined sequence.

Parameters
valuesArray of random values to return in sequence.
lengthNumber of values in the array.

Note that the values in the array are copied and stored (deep-copy).

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

References m_count, m_data, and m_next.

Referenced by RandomVariableStreamDeterministicTestCase::DoRun(), and main().

+ Here is the caller graph for this function:

Member Data Documentation

uint64_t ns3::DeterministicRandomVariable::m_count
private

Position in the array of values.

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

Referenced by GetValue(), and SetValueArray().

double* ns3::DeterministicRandomVariable::m_data
private

Array of values to return in sequence.

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

Referenced by GetValue(), SetValueArray(), and ~DeterministicRandomVariable().

uint64_t ns3::DeterministicRandomVariable::m_next
private

Position of the next value in the array of values.

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

Referenced by GetValue(), and SetValueArray().


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