A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
random-waypoint-mobility-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef RANDOM_WAYPOINT_MOBILITY_MODEL_H
9#define RANDOM_WAYPOINT_MOBILITY_MODEL_H
10
12#include "mobility-model.h"
13#include "position-allocator.h"
14
15#include "ns3/ptr.h"
16#include "ns3/random-variable-stream.h"
17
18namespace ns3
19{
20
21/**
22 * \ingroup mobility
23 * \brief Random waypoint mobility model.
24 *
25 * Each object starts by pausing at time zero for the duration governed
26 * by the random variable "Pause". After pausing, the object will pick
27 * a new waypoint (via the PositionAllocator) and a new random speed
28 * via the random variable "Speed", and will begin moving towards the
29 * waypoint at a constant speed. When it reaches the destination,
30 * the process starts over (by pausing).
31 *
32 * This mobility model enforces no bounding box by itself; the
33 * PositionAllocator assigned to this object will bound the movement.
34 * If the user fails to provide a pointer to a PositionAllocator to
35 * be used to pick waypoints, the simulation program will assert.
36 *
37 * The implementation of this model is not 2d-specific. i.e. if you provide
38 * a 3d random waypoint position model to this mobility model, the model
39 * will still work. There is no 3d position allocator for now but it should
40 * be trivial to add one.
41 */
43{
44 public:
45 /**
46 * Register this type with the TypeId system.
47 * \return the object TypeId
48 */
49 static TypeId GetTypeId();
50
52
53 protected:
54 void DoInitialize() override;
55
56 private:
57 /**
58 * Get next position, begin moving towards it, schedule future pause event
59 */
60 void BeginWalk();
61 /**
62 * Begin current pause event, schedule future walk event
63 */
65 Vector DoGetPosition() const override;
66 void DoSetPosition(const Vector& position) override;
67 Vector DoGetVelocity() const override;
68 int64_t DoAssignStreams(int64_t) override;
69
70 ConstantVelocityHelper m_helper; //!< helper for velocity computations
71 Ptr<PositionAllocator> m_position; //!< pointer to position allocator
72 Ptr<RandomVariableStream> m_speed; //!< random variable to generate speeds
73 Ptr<RandomVariableStream> m_pause; //!< random variable to generate pauses
74 EventId m_event; //!< event ID of next scheduled event
75};
76
77} // namespace ns3
78
79#endif /* RANDOM_WAYPOINT_MOBILITY_MODEL_H */
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition event-id.h:45
Keep track of the current position and velocity of an object.
Smart pointer class similar to boost::intrusive_ptr.
void BeginWalk()
Get next position, begin moving towards it, schedule future pause event.
ConstantVelocityHelper m_helper
helper for velocity computations
void DoInitializePrivate()
Begin current pause event, schedule future walk event.
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Ptr< PositionAllocator > m_position
pointer to position allocator
Ptr< RandomVariableStream > m_speed
random variable to generate speeds
void DoInitialize() override
Initialize() implementation.
static TypeId GetTypeId()
Register this type with the TypeId system.
Ptr< RandomVariableStream > m_pause
random variable to generate pauses
EventId m_event
event ID of next scheduled event
void DoSetPosition(const Vector &position) override
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.