|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/simulator.h"
22 #include "ns3/double.h"
33 static TypeId tid =
TypeId (
"ns3::SteadyStateRandomWaypointMobilityModel")
35 .SetGroupName (
"Mobility")
37 .AddAttribute (
"MinSpeed",
38 "Minimum speed value, [m/s]",
41 MakeDoubleChecker<double> ())
42 .AddAttribute (
"MaxSpeed",
43 "Maximum speed value, [m/s]",
46 MakeDoubleChecker<double> ())
47 .AddAttribute (
"MinPause",
48 "Minimum pause value, [s]",
51 MakeDoubleChecker<double> ())
52 .AddAttribute (
"MaxPause",
53 "Maximum pause value, [s]",
56 MakeDoubleChecker<double> ())
57 .AddAttribute (
"MinX",
58 "Minimum X value of traveling region, [m]",
61 MakeDoubleChecker<double> ())
62 .AddAttribute (
"MaxX",
63 "Maximum X value of traveling region, [m]",
66 MakeDoubleChecker<double> ())
67 .AddAttribute (
"MinY",
68 "Minimum Y value of traveling region, [m]",
71 MakeDoubleChecker<double> ())
72 .AddAttribute (
"MaxY",
73 "Maximum Y value of traveling region, [m]",
76 MakeDoubleChecker<double> ())
78 "Z value of traveling region (fixed), [m]",
81 MakeDoubleChecker<double> ());
87 alreadyStarted (false)
89 m_speed = CreateObject<UniformRandomVariable> ();
90 m_pause = CreateObject<UniformRandomVariable> ();
91 m_x1_r = CreateObject<UniformRandomVariable> ();
92 m_y1_r = CreateObject<UniformRandomVariable> ();
93 m_x2_r = CreateObject<UniformRandomVariable> ();
94 m_y2_r = CreateObject<UniformRandomVariable> ();
95 m_u_r = CreateObject<UniformRandomVariable> ();
96 m_x = CreateObject<UniformRandomVariable> ();
97 m_y = CreateObject<UniformRandomVariable> ();
98 m_position = CreateObject<RandomBoxPositionAllocator> ();
142 double log1 = b*b / a*std::log (std::sqrt ((a*a)/(b*b) + 1) + a/b);
143 double log2 = a*a / b*std::log (std::sqrt ((b*b)/(a*a) + 1) + b/a);
144 double expectedTravelTime = 1.0/6.0*(log1 + log2);
145 expectedTravelTime += 1.0/15.0*((a*a*a)/(b*b) + (b*b*b)/(a*a)) -
146 1.0/15.0*std::sqrt (a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3);
149 expectedTravelTime /= v0;
153 expectedTravelTime *= std::log (v1/v0)/(v1 - v0);
155 double probabilityPaused = expectedPauseTime/(expectedPauseTime + expectedTravelTime);
156 NS_ASSERT (probabilityPaused >= 0 && probabilityPaused <= 1);
159 if (u < probabilityPaused)
179 pause =
Seconds (u*expectedPauseTime);
186 double x1, x2, y1, y2;
196 r = std::sqrt (((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))/(a*a + b*b));
219 double dx = (destination.x - m_current.x);
220 double dy = (destination.y - m_current.y);
221 double dz = (destination.z - m_current.z);
222 double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
241 double dx = (destination.x - m_current.x);
242 double dy = (destination.y - m_current.y);
243 double dz = (destination.z - m_current.z);
244 double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
288 int64_t positionStreamsAllocated = 0;
298 positionStreamsAllocated =
m_position->AssignStreams (stream + 9);
299 return (9 + positionStreamsAllocated);
Ptr< UniformRandomVariable > m_u_r
rv used in step 5 of algorithm
a unique identifier for an interface.
double m_maxX
maximum x value of traveling region (m)
Ptr< UniformRandomVariable > m_y
rv used for position allocator
void SetVelocity(const Vector &vel)
Set new velocity vector.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
double m_maxPause
maximum pause value (s)
Ptr< UniformRandomVariable > m_speed
random variable for speed values
void Start(void)
Start a pause period and schedule the ending of the pause.
Ptr< UniformRandomVariable > m_pause
random variable for pause values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double m_minX
minimum x value of traveling region (m)
Ptr< RandomBoxPositionAllocator > m_position
position allocator
double m_z
z value of traveling region
virtual int64_t DoAssignStreams(int64_t)
The default implementation does nothing but return the passed-in parameter.
void NotifyCourseChange(void) const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
void DoInitializePrivate(void)
Configure random variables based on attributes; calculate the steady state probability that node is i...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
double m_minSpeed
minimum speed value (m/s)
double m_minPause
minimum pause value (s)
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< UniformRandomVariable > m_x2_r
rv used in rejection sampling phase
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
virtual Vector DoGetVelocity(void) const
virtual void DoInitialize(void)
Initialize() implementation.
double m_minY
minimum y value of traveling region (m)
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Vector GetCurrentPosition(void) const
Get current position vector.
virtual void DoSetPosition(const Vector &position)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Ptr< UniformRandomVariable > m_y2_r
rv used in rejection sampling phase
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Simulation virtual time values and global simulation resolution.
Ptr< UniformRandomVariable > m_y1_r
rv used in rejection sampling phase
bool alreadyStarted
flag for starting state
void Unpause(void)
Resume mobility from current position at current velocity.
virtual void DoInitialize(void)
Initialize() implementation.
void BeginWalk(void)
Start a motion period and schedule the ending of the motion.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
EventId m_event
current event ID
Steady-state random waypoint mobility model.
Ptr< UniformRandomVariable > m_x
rv used for position allocator
virtual Vector DoGetPosition(void) const
Time Seconds(double value)
Construct a Time in the indicated unit.
void Update(void) const
Update position, if not paused, from last position and time of last update.
Ptr< UniformRandomVariable > m_x1_r
rv used in rejection sampling phase
double m_maxSpeed
maximum speed value (m/s)
SteadyStateRandomWaypointMobilityModel()
double m_maxY
maximum y value of traveling region (m)
void SetPosition(const Vector &position)
Set position vector.
Keep track of the current position and velocity of an object.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
ConstantVelocityHelper m_helper
helper for velocity computations
void Pause(void)
Pause mobility at current position.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Vector GetVelocity(void) const
Get velocity; if paused, will return a zero vector.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
void SteadyStateBeginWalk(const Vector &destination)
Use provided destination to calculate travel delay, and schedule a Start() event at that time.