|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/double.h"
22 #include "ns3/string.h"
23 #include "ns3/pointer.h"
24 #include "ns3/uinteger.h"
27 #include "ns3/csv-reader.h"
42 .SetGroupName (
"Mobility");
58 static TypeId tid =
TypeId (
"ns3::ListPositionAllocator")
60 .SetGroupName (
"Mobility")
81 NS_LOG_FUNCTION (
this << filePath << std::string (
"'") + delimiter +
"'");
97 NS_LOG_INFO (
"read y = " << y << (ok ?
" ok" :
" FAIL"));
102 NS_LOG_INFO (
"read z = " << z << (ok ?
" ok" :
" FAIL"));
111 Vector pos (
x, y, z);
148 static TypeId tid =
TypeId (
"ns3::GridPositionAllocator")
150 .SetGroupName (
"Mobility")
152 .AddAttribute (
"GridWidth",
"The number of objects laid out on a line.",
155 MakeUintegerChecker<uint32_t> ())
156 .AddAttribute (
"MinX",
"The x coordinate where the grid starts.",
159 MakeDoubleChecker<double> ())
160 .AddAttribute (
"MinY",
"The y coordinate where the grid starts.",
163 MakeDoubleChecker<double> ())
165 "The z coordinate of all the positions allocated.",
168 MakeDoubleChecker<double> ())
169 .AddAttribute (
"DeltaX",
"The x space between objects.",
172 MakeDoubleChecker<double> ())
173 .AddAttribute (
"DeltaY",
"The y space between objects.",
176 MakeDoubleChecker<double> ())
177 .AddAttribute (
"LayoutType",
"The type of layout.",
271 double x = 0.0, y = 0.0;
284 return Vector (
x, y,
m_z);
299 static TypeId tid =
TypeId (
"ns3::RandomRectanglePositionAllocator")
301 .SetGroupName (
"Mobility")
304 "A random variable which represents the x coordinate of a position in a random rectangle.",
305 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
307 MakePointerChecker<RandomVariableStream> ())
309 "A random variable which represents the y coordinate of a position in a random rectangle.",
310 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
312 MakePointerChecker<RandomVariableStream> ())
314 "The z coordinate of all the positions allocated.",
317 MakeDoubleChecker<double> ())
351 return Vector (
x, y,
m_z);
368 static TypeId tid =
TypeId (
"ns3::RandomBoxPositionAllocator")
370 .SetGroupName (
"Mobility")
373 "A random variable which represents the x coordinate of a position in a random box.",
374 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
376 MakePointerChecker<RandomVariableStream> ())
378 "A random variable which represents the y coordinate of a position in a random box.",
379 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
381 MakePointerChecker<RandomVariableStream> ())
383 "A random variable which represents the z coordinate of a position in a random box.",
384 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
386 MakePointerChecker<RandomVariableStream> ())
421 return Vector (
x, y, z);
439 static TypeId tid =
TypeId (
"ns3::RandomDiscPositionAllocator")
441 .SetGroupName (
"Mobility")
443 .AddAttribute (
"Theta",
444 "A random variable which represents the angle (gradients) of a position in a random disc.",
445 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=6.2830]"),
447 MakePointerChecker<RandomVariableStream> ())
448 .AddAttribute (
"Rho",
449 "A random variable which represents the radius of a position in a random disc.",
450 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=200.0]"),
452 MakePointerChecker<RandomVariableStream> ())
454 "The x coordinate of the center of the random position disc.",
457 MakeDoubleChecker<double> ())
459 "The y coordinate of the center of the random position disc.",
462 MakeDoubleChecker<double> ())
464 "The z coordinate of all the positions in the disc.",
467 MakeDoubleChecker<double> ())
513 double x =
m_x + std::cos (theta) * rho;
514 double y =
m_y + std::sin (theta) * rho;
516 return Vector (
x, y,
m_z);
533 static TypeId tid =
TypeId (
"ns3::UniformDiscPositionAllocator")
535 .SetGroupName (
"Mobility")
537 .AddAttribute (
"rho",
538 "The radius of the disc",
541 MakeDoubleChecker<double> ())
543 "The x coordinate of the center of the disc.",
546 MakeDoubleChecker<double> ())
548 "The y coordinate of the center of the disc.",
551 MakeDoubleChecker<double> ())
553 "The z coordinate of all the positions in the disc.",
556 MakeDoubleChecker<double> ())
563 m_rv = CreateObject<UniformRandomVariable> ();
602 while (std::sqrt (
x *
x + y * y) >
m_rho);
607 return Vector (
x, y,
m_z);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
void Add(Vector v)
Add a position to the list of positions.
uint32_t GetN(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
RandomRectanglePositionAllocator()
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t m_current
currently position
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool FetchNextRow()
Reads one line from the input until a new line is encountered.
RandomDiscPositionAllocator()
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
void SetDeltaX(double deltaX)
double GetMinY(void) const
std::size_t RowNumber() const
The number of lines that have been read.
virtual Vector GetNext(void) const
Allocate positions on a rectangular 2d grid.
double m_deltaY
y interval between two consecutive y positions
std::vector< Vector > m_positions
vector of positions
static TypeId GetTypeId(void)
Register this type with the TypeId system.
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions.
Ptr< RandomVariableStream > m_rho
pointer to rho's random variable stream
static TypeId GetTypeId(void)
Register this type with the TypeId system.
virtual ~RandomDiscPositionAllocator()
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetMinY(double yMin)
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
enum LayoutType GetLayoutType(void) const
Allocate positions from a deterministic list specified by the user.
@ COLUMN_FIRST
In column-first mode, positions are allocated on the first column until N positions have been allocat...
enum LayoutType m_layoutType
currently selected layout type
double m_x
x coordinate of center of disc
void SetTheta(Ptr< RandomVariableStream > theta)
Set the random variable that generates position angle, in radians.
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
virtual ~RandomRectanglePositionAllocator()
virtual Vector GetNext(void) const
LayoutType
Determine whether positions are allocated row first or column first.
A base class which provides memory management and object aggregation.
@ ROW_FIRST
In row-first mode, positions are allocated on the first row until N positions have been allocated.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void SetLayoutType(enum LayoutType layoutType)
virtual Vector GetNext(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 GetDeltaX(void) const
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
double m_xMin
minimum boundary on x positions
Ptr< RandomVariableStream > m_theta
pointer to theta's random variable stream
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
bool GetValue(std::size_t columnIndex, T &value) const
Attempt to convert from the string data in the specified column to the specified data type.
double m_y
y coordinate of center of disc
double m_z
z coordinate of all the positions generated
void SetMinX(double xMin)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
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 string.
void SetDeltaY(double deltaY)
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Provides functions for parsing and extracting data from Comma Separated Value (CSV) formatted text fi...
virtual ~RandomBoxPositionAllocator()
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
double m_deltaX
x interval between two consecutive x positions
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
RandomBoxPositionAllocator()
double GetDeltaY(void) const
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual Vector GetNext(void) const
uint32_t GetSize(void) const
Return the number of positions stored.
double GetMinX(void) const
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
Allocate a set of positions.
double m_yMin
minimum boundary on y positions
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
std::vector< Vector >::const_iterator m_current
vector iterator
Ptr< RandomVariableStream > m_z
pointer to z's random variable stream
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold an unsigned integer type.
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
double m_z
z coordinate of all the positions generated
void SetRho(Ptr< RandomVariableStream > rho)
Set the random variable that generates position radius, in meters.
Ptr< const AttributeAccessor > MakeUintegerAccessor(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.
uint32_t m_n
number of positions to allocate on each row or column
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
Allocate random positions within a 3D box according to a set of three random variables.
Allocate random positions within a rectangle according to a pair of random variables.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
std::size_t ColumnCount() const
Returns the number of columns in the csv data.
virtual Vector GetNext(void) const
double m_z
z coordinate of the disc
virtual ~PositionAllocator()