A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
11
#include "
constant-velocity-helper.h
"
12
#include "
mobility-model.h
"
13
#include "
position-allocator.h
"
14
15
#include "ns3/ptr.h"
16
#include "ns3/random-variable-stream.h"
17
18
namespace
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
*/
42
class
RandomWaypointMobilityModel
:
public
MobilityModel
43
{
44
public
:
45
/**
46
* Register this type with the TypeId system.
47
* @return the object TypeId
48
*/
49
static
TypeId
GetTypeId
();
50
51
~RandomWaypointMobilityModel
()
override
;
52
53
// Inherited from MobilityModel
54
Ptr<MobilityModel>
Copy
()
const override
55
{
56
return
CreateObject<RandomWaypointMobilityModel>
(*
this
);
57
}
58
59
protected
:
60
void
DoInitialize
()
override
;
61
62
private
:
63
/**
64
* Get next position, begin moving towards it, schedule future pause event
65
*/
66
void
BeginWalk
();
67
/**
68
* Begin current pause event, schedule future walk event
69
*/
70
void
DoInitializePrivate
();
71
Vector
DoGetPosition
()
const override
;
72
void
DoSetPosition
(
const
Vector& position)
override
;
73
Vector
DoGetVelocity
()
const override
;
74
int64_t
DoAssignStreams
(int64_t)
override
;
75
76
ConstantVelocityHelper
m_helper
;
//!< helper for velocity computations
77
Ptr<PositionAllocator>
m_position
;
//!< pointer to position allocator
78
Ptr<RandomVariableStream>
m_speed
;
//!< random variable to generate speeds
79
Ptr<RandomVariableStream>
m_pause
;
//!< random variable to generate pauses
80
EventId
m_event
;
//!< event ID of next scheduled event
81
};
82
83
}
// namespace ns3
84
85
#endif
/* RANDOM_WAYPOINT_MOBILITY_MODEL_H */
ns3::ConstantVelocityHelper
Utility class used to move node with constant velocity.
Definition
constant-velocity-helper.h:27
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:44
ns3::MobilityModel::MobilityModel
MobilityModel()
Definition
mobility-model.cc:47
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:67
ns3::RandomWaypointMobilityModel
Random waypoint mobility model.
Definition
random-waypoint-mobility-model.h:43
ns3::RandomWaypointMobilityModel::BeginWalk
void BeginWalk()
Get next position, begin moving towards it, schedule future pause event.
Definition
random-waypoint-mobility-model.cc:57
ns3::RandomWaypointMobilityModel::m_helper
ConstantVelocityHelper m_helper
helper for velocity computations
Definition
random-waypoint-mobility-model.h:76
ns3::RandomWaypointMobilityModel::DoInitializePrivate
void DoInitializePrivate()
Begin current pause event, schedule future walk event.
Definition
random-waypoint-mobility-model.cc:90
ns3::RandomWaypointMobilityModel::DoAssignStreams
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Definition
random-waypoint-mobility-model.cc:121
ns3::RandomWaypointMobilityModel::m_position
Ptr< PositionAllocator > m_position
pointer to position allocator
Definition
random-waypoint-mobility-model.h:77
ns3::RandomWaypointMobilityModel::m_speed
Ptr< RandomVariableStream > m_speed
random variable to generate speeds
Definition
random-waypoint-mobility-model.h:78
ns3::RandomWaypointMobilityModel::DoInitialize
void DoInitialize() override
Initialize() implementation.
Definition
random-waypoint-mobility-model.cc:83
ns3::RandomWaypointMobilityModel::GetTypeId
static TypeId GetTypeId()
Register this type with the TypeId system.
Definition
random-waypoint-mobility-model.cc:25
ns3::RandomWaypointMobilityModel::DoGetPosition
Vector DoGetPosition() const override
Definition
random-waypoint-mobility-model.cc:100
ns3::RandomWaypointMobilityModel::m_pause
Ptr< RandomVariableStream > m_pause
random variable to generate pauses
Definition
random-waypoint-mobility-model.h:79
ns3::RandomWaypointMobilityModel::m_event
EventId m_event
event ID of next scheduled event
Definition
random-waypoint-mobility-model.h:80
ns3::RandomWaypointMobilityModel::DoGetVelocity
Vector DoGetVelocity() const override
Definition
random-waypoint-mobility-model.cc:115
ns3::RandomWaypointMobilityModel::Copy
Ptr< MobilityModel > Copy() const override
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
Definition
random-waypoint-mobility-model.h:54
ns3::RandomWaypointMobilityModel::~RandomWaypointMobilityModel
~RandomWaypointMobilityModel() override
Definition
random-waypoint-mobility-model.cc:51
ns3::RandomWaypointMobilityModel::DoSetPosition
void DoSetPosition(const Vector &position) override
Definition
random-waypoint-mobility-model.cc:107
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
constant-velocity-helper.h
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
mobility-model.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
position-allocator.h
src
mobility
model
random-waypoint-mobility-model.h
Generated on Wed Oct 1 2025 18:22:20 for ns-3 by
1.13.2