10#include "ns3/csv-reader.h"
11#include "ns3/double.h"
14#include "ns3/pointer.h"
15#include "ns3/string.h"
16#include "ns3/uinteger.h"
50 .SetGroupName(
"Mobility")
74 while (
csv.FetchNextRow())
76 if (
csv.ColumnCount() == 1)
85 bool ok =
csv.GetValue(0, x);
88 ok =
csv.GetValue(1, y);
91 if (
csv.ColumnCount() > 2)
93 ok =
csv.GetValue(2, z);
140 TypeId(
"ns3::GridPositionAllocator")
142 .SetGroupName(
"Mobility")
144 .AddAttribute(
"GridWidth",
145 "The number of objects laid out on a line.",
149 .AddAttribute(
"MinX",
150 "The x coordinate where the grid starts.",
154 .AddAttribute(
"MinY",
155 "The y coordinate where the grid starts.",
160 "The z coordinate of all the positions allocated.",
164 .AddAttribute(
"DeltaX",
165 "The x space between objects.",
169 .AddAttribute(
"DeltaY",
170 "The y space between objects.",
174 .AddAttribute(
"LayoutType",
175 "The type of layout.",
282 return Vector(x, y,
m_z);
297 TypeId(
"ns3::RandomRectanglePositionAllocator")
299 .SetGroupName(
"Mobility")
302 "A random variable which represents the x coordinate of a position in a "
304 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
308 "A random variable which represents the y coordinate of a position in a "
310 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
314 "The z coordinate of all the positions allocated.",
352 return Vector(x, y,
m_z);
369 TypeId(
"ns3::RandomBoxPositionAllocator")
371 .SetGroupName(
"Mobility")
374 "A random variable which represents the x coordinate of a position in a "
376 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
380 "A random variable which represents the y coordinate of a position in a "
382 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
386 "A random variable which represents the z coordinate of a position in a "
388 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
426 return Vector(x, y, z);
444 TypeId(
"ns3::RandomDiscPositionAllocator")
446 .SetGroupName(
"Mobility")
448 .AddAttribute(
"Theta",
449 "A random variable which represents the angle (gradients) of a position "
451 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=6.2830]"),
456 "A random variable which represents the radius of a position in a random disc.",
457 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=200.0]"),
461 "The x coordinate of the center of the random position disc.",
466 "The y coordinate of the center of the random position disc.",
471 "The z coordinate of all the positions in the disc.",
524 return Vector(x, y,
m_z);
540 static TypeId tid =
TypeId(
"ns3::UniformDiscPositionAllocator")
542 .SetGroupName(
"Mobility")
545 "The radius of the disc",
550 "The x coordinate of the center of the disc.",
555 "The y coordinate of the center of the disc.",
560 "The z coordinate of all the positions in the disc.",
609 }
while (std::sqrt(x * x + y * y) >
m_rho);
614 return Vector(x, y,
m_z);
620 m_rv->SetStream(stream);
Provides functions for parsing and extracting data from Comma Separated Value (CSV) formatted text fi...
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
Allocate positions on a rectangular 2d grid.
void SetDeltaX(double deltaX)
double m_deltaX
x interval between two consecutive x positions
double m_deltaY
y interval between two consecutive y positions
LayoutType GetLayoutType() const
LayoutType
Determine whether positions are allocated row first or column first.
@ COLUMN_FIRST
In column-first mode, positions are allocated on the first column until N positions have been allocat...
@ ROW_FIRST
In row-first mode, positions are allocated on the first row until N positions have been allocated.
void SetMinY(double yMin)
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t m_current
currently position
void SetDeltaY(double deltaY)
double m_yMin
minimum boundary on y positions
Vector GetNext() const override
double m_z
z coordinate of all the positions generated
LayoutType m_layoutType
currently selected layout type
double m_xMin
minimum boundary on x positions
uint32_t m_n
number of positions to allocate on each row or column
static TypeId GetTypeId()
Register this type with the TypeId system.
void SetLayoutType(LayoutType layoutType)
void SetMinX(double xMin)
Allocate positions from a deterministic list specified by the user.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void Add(Vector v)
Add a position to the list of positions.
uint32_t GetSize() const
Return the number of positions stored.
static TypeId GetTypeId()
Register this type with the TypeId system.
std::vector< Vector >::const_iterator m_current
vector iterator
Vector GetNext() const override
std::vector< Vector > m_positions
vector of positions
A base class which provides memory management and object aggregation.
Allocate a set of positions.
static TypeId GetTypeId()
Register this type with the TypeId system.
~PositionAllocator() override
Smart pointer class similar to boost::intrusive_ptr.
Allocate random positions within a 3D box according to a set of three random variables.
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions.
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
Vector GetNext() const override
~RandomBoxPositionAllocator() override
static TypeId GetTypeId()
Register this type with the TypeId system.
Ptr< RandomVariableStream > m_z
pointer to z's random variable stream
RandomBoxPositionAllocator()
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
Vector GetNext() const override
~RandomDiscPositionAllocator() override
RandomDiscPositionAllocator()
double m_y
y coordinate of center of disc
Ptr< RandomVariableStream > m_rho
pointer to rho's random variable stream
static TypeId GetTypeId()
Register this type with the TypeId system.
void SetRho(Ptr< RandomVariableStream > rho)
Set the random variable that generates position radius, in meters.
double m_x
x coordinate of center of disc
void SetTheta(Ptr< RandomVariableStream > theta)
Set the random variable that generates position angle, in radians.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< RandomVariableStream > m_theta
pointer to theta's random variable stream
double m_z
z coordinate of the disc
Allocate random positions within a rectangle according to a pair of random variables.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Vector GetNext() const override
RandomRectanglePositionAllocator()
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
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.
static TypeId GetTypeId()
Register this type with the TypeId system.
~RandomRectanglePositionAllocator() override
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
double m_z
z coordinate of all the positions generated
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold variables of type string.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)