10#include "ns3/double.h" 
   11#include "ns3/simulator.h" 
   25        TypeId(
"ns3::SteadyStateRandomWaypointMobilityModel")
 
   27            .SetGroupName(
"Mobility")
 
   29            .AddAttribute(
"MinSpeed",
 
   30                          "Minimum speed value, [m/s]",
 
   34            .AddAttribute(
"MaxSpeed",
 
   35                          "Maximum speed value, [m/s]",
 
   39            .AddAttribute(
"MinPause",
 
   40                          "Minimum pause value, [s]",
 
   44            .AddAttribute(
"MaxPause",
 
   45                          "Maximum pause value, [s]",
 
   50                          "Minimum X value of traveling region, [m]",
 
   55                          "Maximum X value of traveling region, [m]",
 
   60                          "Minimum Y value of traveling region, [m]",
 
   65                          "Maximum Y value of traveling region, [m]",
 
   70                          "Z value of traveling region (fixed), [m]",
 
 
  139    double log1 = b * b / a * std::log(std::sqrt((a * a) / (b * b) + 1) + a / b);
 
  140    double log2 = a * a / b * std::log(std::sqrt((b * b) / (a * a) + 1) + b / a);
 
  141    double expectedTravelTime = 1.0 / 6.0 * (log1 + log2);
 
  142    expectedTravelTime +=
 
  143        1.0 / 15.0 * ((a * a * a) / (b * b) + (b * b * b) / (a * a)) -
 
  144        1.0 / 15.0 * std::sqrt(a * a + b * b) * ((a * a) / (b * b) + (b * b) / (a * a) - 3);
 
  147        expectedTravelTime /= v0;
 
  151        expectedTravelTime *= std::log(v1 / v0) / (v1 - v0);
 
  153    double probabilityPaused = expectedPauseTime / (expectedPauseTime + expectedTravelTime);
 
  154    NS_ASSERT(probabilityPaused >= 0 && probabilityPaused <= 1);
 
  156    double u = 
m_u_r->GetValue(0, 1);
 
  157    if (
u < probabilityPaused) 
 
  160        u = 
m_u_r->GetValue(0, 1);
 
  178            pause = 
Seconds(
u * expectedPauseTime);
 
  190        x1 = x2 = y1 = y2 = 0;
 
  195            x1 = 
m_x1_r->GetValue(0, a);
 
  196            y1 = 
m_y1_r->GetValue(0, b);
 
  197            x2 = 
m_x2_r->GetValue(0, a);
 
  198            y2 = 
m_y2_r->GetValue(0, b);
 
  199            u1 = 
m_u_r->GetValue(0, 1);
 
  200            r = std::sqrt(((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) / (a * a + b * b));
 
  203        double u2 = 
m_u_r->GetValue(0, 1);
 
  205            Vector(
m_minX + u2 * x1 + (1 - u2) * x2, 
m_minY + u2 * y1 + (1 - u2) * y2, 
m_z));
 
 
  219    Vector m_current = 
m_helper.GetCurrentPosition();
 
  224    double u = 
m_u_r->GetValue(0, 1);
 
  226    double dx = (destination.x - m_current.x);
 
  227    double dy = (destination.y - m_current.y);
 
  228    double dz = (destination.z - m_current.z);
 
  229    double k = speed / std::sqrt(dx * dx + dy * dy + dz * dz);
 
  231    m_helper.SetVelocity(Vector(k * dx, k * dy, k * dz));
 
 
  243    Vector m_current = 
m_helper.GetCurrentPosition();
 
  247    double speed = 
m_speed->GetValue();
 
  248    double dx = (destination.x - m_current.x);
 
  249    double dy = (destination.y - m_current.y);
 
  250    double dz = (destination.z - m_current.z);
 
  251    double k = speed / std::sqrt(dx * dx + dy * dy + dz * dz);
 
  253    m_helper.SetVelocity(Vector(k * dx, k * dy, k * dz));
 
 
  275    return m_helper.GetCurrentPosition();
 
 
  298    int64_t positionStreamsAllocated = 0;
 
  300    m_pause->SetStream(stream + 1);
 
  301    m_x1_r->SetStream(stream + 2);
 
  302    m_y1_r->SetStream(stream + 3);
 
  303    m_x2_r->SetStream(stream + 4);
 
  304    m_y2_r->SetStream(stream + 5);
 
  305    m_u_r->SetStream(stream + 6);
 
  306    m_x->SetStream(stream + 7);
 
  307    m_y->SetStream(stream + 8);
 
  308    positionStreamsAllocated = 
m_position->AssignStreams(stream + 9);
 
  309    return (9 + positionStreamsAllocated);
 
 
This class can be used to hold variables of floating point type such as 'double' or 'float'.
 
void NotifyCourseChange() const
Must be invoked by subclasses when the course of the position changes to notify course change listene...
 
virtual void DoInitialize()
Initialize() implementation.
 
Smart pointer class similar to boost::intrusive_ptr.
 
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
 
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
 
Steady-state random waypoint mobility model.
 
Ptr< UniformRandomVariable > m_u_r
rv used in step 5 of algorithm
 
void DoSetPosition(const Vector &position) override
 
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
 
void DoInitialize() override
Initialize() implementation.
 
double m_maxSpeed
maximum speed value (m/s)
 
double m_minPause
minimum pause value (s)
 
double m_minX
minimum x value of traveling region (m)
 
Ptr< UniformRandomVariable > m_y2_r
rv used in rejection sampling phase
 
Ptr< UniformRandomVariable > m_pause
random variable for pause values
 
Ptr< UniformRandomVariable > m_x2_r
rv used in rejection sampling phase
 
void SteadyStateBeginWalk(const Vector &destination)
Use provided destination to calculate travel delay, and schedule a Start() event at that time.
 
Vector DoGetVelocity() const override
 
Ptr< UniformRandomVariable > m_y
rv used for position allocator
 
Ptr< UniformRandomVariable > m_speed
random variable for speed values
 
double m_z
z value of traveling region
 
double m_maxX
maximum x value of traveling region (m)
 
Vector DoGetPosition() const override
 
static TypeId GetTypeId()
Register this type with the TypeId system.
 
double m_maxPause
maximum pause value (s)
 
double m_minSpeed
minimum speed value (m/s)
 
Ptr< UniformRandomVariable > m_x1_r
rv used in rejection sampling phase
 
void DoInitializePrivate()
Configure random variables based on attributes; calculate the steady state probability that node is i...
 
void BeginWalk()
Start a motion period and schedule the ending of the motion.
 
double m_minY
minimum y value of traveling region (m)
 
void Start()
Start a pause period and schedule the ending of the pause.
 
Ptr< UniformRandomVariable > m_x
rv used for position allocator
 
SteadyStateRandomWaypointMobilityModel()
 
ConstantVelocityHelper m_helper
helper for velocity computations
 
Ptr< UniformRandomVariable > m_y1_r
rv used in rejection sampling phase
 
bool alreadyStarted
flag for starting state
 
~SteadyStateRandomWaypointMobilityModel() override
 
EventId m_event
current event ID
 
double m_maxY
maximum y value of traveling region (m)
 
Ptr< RandomBoxPositionAllocator > m_position
position allocator
 
Simulation virtual time values and global simulation resolution.
 
a unique identifier for an interface.
 
TypeId SetParent(TypeId tid)
Set the parent TypeId.
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
 
Ptr< const AttributeChecker > MakeDoubleChecker()
 
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
 
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
 
Time Seconds(double value)
Construct a Time in the indicated unit.
 
Every class exported by the ns3 library is enclosed in the ns3 namespace.
 
double CalculateDistance(const Vector3D &a, const Vector3D &b)