21 #include "ns3/double.h" 
   22 #include "ns3/string.h" 
   23 #include "ns3/pointer.h" 
   24 #include "ns3/uinteger.h" 
   40     .SetGroupName (
"Mobility");
 
   57   static TypeId tid = 
TypeId (
"ns3::ListPositionAllocator")
 
   59     .SetGroupName (
"Mobility")
 
  101   static TypeId tid = 
TypeId (
"ns3::GridPositionAllocator")
 
  103     .SetGroupName (
"Mobility")
 
  105     .AddAttribute (
"GridWidth", 
"The number of objects layed out on a line.",
 
  108                    MakeUintegerChecker<uint32_t> ())
 
  109     .AddAttribute (
"MinX", 
"The x coordinate where the grid starts.",
 
  112                    MakeDoubleChecker<double> ())
 
  113     .AddAttribute (
"MinY", 
"The y coordinate where the grid starts.",
 
  116                    MakeDoubleChecker<double> ())
 
  117     .AddAttribute (
"DeltaX", 
"The x space between objects.",
 
  120                    MakeDoubleChecker<double> ())
 
  121     .AddAttribute (
"DeltaY", 
"The y space between objects.",
 
  124                    MakeDoubleChecker<double> ())
 
  125     .AddAttribute (
"LayoutType", 
"The type of layout.",
 
  203   double x = 0.0, y = 0.0;
 
  215   return Vector (x, y, 0.0);
 
  229   static TypeId tid = 
TypeId (
"ns3::RandomRectanglePositionAllocator")
 
  231     .SetGroupName (
"Mobility")
 
  234                    "A random variable which represents the x coordinate of a position in a random rectangle.",
 
  235                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
 
  237                    MakePointerChecker<RandomVariableStream> ())
 
  239                    "A random variable which represents the y coordinate of a position in a random rectangle.",
 
  240                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
 
  242                    MakePointerChecker<RandomVariableStream> ());
 
  269   return Vector (x, y, 0.0);
 
  285   static TypeId tid = 
TypeId (
"ns3::RandomBoxPositionAllocator")
 
  287     .SetGroupName (
"Mobility")
 
  290                    "A random variable which represents the x coordinate of a position in a random box.",
 
  291                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
 
  293                    MakePointerChecker<RandomVariableStream> ())
 
  295                    "A random variable which represents the y coordinate of a position in a random box.",
 
  296                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
 
  298                    MakePointerChecker<RandomVariableStream> ())
 
  300                    "A random variable which represents the z coordinate of a position in a random box.",
 
  301                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
 
  303                    MakePointerChecker<RandomVariableStream> ());
 
  336   return Vector (x, y, z);
 
  353   static TypeId tid = 
TypeId (
"ns3::RandomDiscPositionAllocator")
 
  355     .SetGroupName (
"Mobility")
 
  357     .AddAttribute (
"Theta",
 
  358                    "A random variable which represents the angle (gradients) of a position in a random disc.",
 
  359                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=6.2830]"),
 
  361                    MakePointerChecker<RandomVariableStream> ())
 
  362     .AddAttribute (
"Rho",
 
  363                    "A random variable which represents the radius of a position in a random disc.",
 
  364                    StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=200.0]"),
 
  366                    MakePointerChecker<RandomVariableStream> ())
 
  368                    "The x coordinate of the center of the random position disc.",
 
  371                    MakeDoubleChecker<double> ())
 
  373                    "The y coordinate of the center of the random position disc.",
 
  376                    MakeDoubleChecker<double> ())
 
  413   double x = 
m_x + std::cos (theta) * rho;
 
  414   double y = 
m_y + std::sin (theta) * rho;
 
  416   return Vector (x, y, 0.0);
 
  434   static TypeId tid = 
TypeId (
"ns3::UniformDiscPositionAllocator")
 
  436     .SetGroupName (
"Mobility")
 
  438     .AddAttribute (
"rho",
 
  439                    "The radius of the disc",
 
  442                    MakeDoubleChecker<double> ())
 
  444                    "The x coordinate of the center of the  disc.",
 
  447                    MakeDoubleChecker<double> ())
 
  449                    "The y coordinate of the center of the  disc.",
 
  452                    MakeDoubleChecker<double> ())
 
  459   m_rv = CreateObject<UniformRandomVariable> ();
 
  489   while (std::sqrt (x*x + y*y) > 
m_rho);
 
  494   return Vector (x, y, 0.0);
 
uint32_t m_current
currently position 
 
LayoutType
Determine whether positions are allocated row first or column first. 
 
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream 
 
void SetStream(int64_t stream)
Specifies the stream number for the RngStream. 
 
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream 
 
double GetMinY(void) const 
 
void SetDeltaX(double deltaX)
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
static TypeId GetTypeId(void)
Register this type with the TypeId system. 
 
Hold variables of type string. 
 
Ptr< RandomVariableStream > m_theta
pointer to theta's random variable stream 
 
void SetMinX(double xMin)
 
virtual ~PositionAllocator()
 
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
 
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions. 
 
double GetDeltaY(void) const 
 
enum LayoutType GetLayoutType(void) const 
 
virtual Vector GetNext(void) const 
 
std::vector< Vector > m_positions
vector of positions 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
Ptr< RandomVariableStream > m_rho
pointer to rho's random variable stream 
 
void SetMinY(double yMin)
 
static TypeId GetTypeId(void)
Register this type with the TypeId system. 
 
virtual ~RandomBoxPositionAllocator()
 
double GetDeltaX(void) const 
 
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
double m_deltaX
x interval between two consecutive x positions 
 
static TypeId GetTypeId(void)
Register this type with the TypeId system. 
 
std::vector< Vector >::const_iterator m_current
vector iterator 
 
void SetRho(Ptr< RandomVariableStream > rho)
Set the random variable that generates position angle. 
 
virtual Vector GetNext(void) const 
 
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution. 
 
In row-first mode, positions are allocated on the first row until N positions have been allocated...
 
double m_deltaY
y interval between two consecutive y positions 
 
virtual Vector GetNext(void) const 
 
double m_xMin
minimum boundary on x positions 
 
static TypeId GetTypeId(void)
Register this type with the TypeId system. 
 
void SetDeltaY(double deltaY)
 
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
 
Hold variables of type enum. 
 
double m_x
x coordinate of center of disc 
 
uint32_t m_n
number of positions to allocate on each row or column 
 
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream 
 
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions. 
 
Hold an unsigned integer type. 
 
virtual ~RandomRectanglePositionAllocator()
 
Allocate positions on a rectangular 2d grid. 
 
double m_yMin
minimum boundary on y positions 
 
void SetTheta(Ptr< RandomVariableStream > theta)
Set the random variable that generates position radius. 
 
Allocate positions from a deterministic list specified by the user. 
 
uint32_t GetSize(void) const 
Return the number of positions stored. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
virtual Vector GetNext(void) const 
 
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions. 
 
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
RandomDiscPositionAllocator()
 
static TypeId GetTypeId(void)
Register this type with the TypeId system. 
 
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
RandomRectanglePositionAllocator()
 
enum LayoutType m_layoutType
currently selected layout type 
 
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
 
static TypeId GetTypeId(void)
Register this type with the TypeId system. 
 
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name. 
 
double m_y
y coordinate of center of disc 
 
Allocate random positions within a rectangle according to a pair of random variables. 
 
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
void Add(Vector v)
Add a position to the list of positions. 
 
void SetLayoutType(enum LayoutType layoutType)
 
virtual Vector GetNext(void) const 
 
uint32_t GetN(void) const 
 
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions. 
 
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions. 
 
Allocate random positions within a 3D box according to a set of three random variables. 
 
RandomBoxPositionAllocator()
 
A base class which provides memory management and object aggregation. 
 
In column-first mode, positions are allocated on the first column until N positions have been allocat...
 
This class can be used to hold variables of floating point type such as 'double' or 'float'...
 
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
 
a unique identifier for an interface. 
 
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
 
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
 
virtual ~RandomDiscPositionAllocator()
 
Ptr< RandomVariableStream > m_z
pointer to z's random variable stream 
 
double GetMinX(void) const 
 
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream 
 
Allocate a set of positions.