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-walk-2d-mobility-model.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006,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_WALK_2D_MOBILITY_MODEL_H
9
#define RANDOM_WALK_2D_MOBILITY_MODEL_H
10
11
#include "
constant-velocity-helper.h
"
12
#include "
mobility-model.h
"
13
#include "
rectangle.h
"
14
15
#include "ns3/event-id.h"
16
#include "ns3/nstime.h"
17
#include "ns3/object.h"
18
#include "ns3/random-variable-stream.h"
19
20
namespace
ns3
21
{
22
23
/**
24
* @ingroup mobility
25
* @brief 2D random walk mobility model.
26
*
27
* Each instance moves with a speed and direction chosen at random
28
* with the user-provided random variables until
29
* either a fixed distance has been walked or until a fixed amount
30
* of time. If we hit one of the boundaries (specified by a rectangle),
31
* of the model, we rebound on the boundary with a reflexive angle
32
* and speed. This model is often identified as a brownian motion
33
* model.
34
*
35
* The Direction random variable is used for any point strictly
36
* inside the boundaries. The points on the boundary have their
37
* direction chosen randomly, without considering the Direction
38
* Attribute.
39
*/
40
class
RandomWalk2dMobilityModel
:
public
MobilityModel
41
{
42
public
:
43
/**
44
* Register this type with the TypeId system.
45
* @return the object TypeId
46
*/
47
static
TypeId
GetTypeId
();
48
49
~RandomWalk2dMobilityModel
()
override
;
50
51
// Inherited from MobilityModel
52
Ptr<MobilityModel>
Copy
()
const override
53
{
54
return
CreateObject<RandomWalk2dMobilityModel>
(*
this
);
55
}
56
57
/** An enum representing the different working modes of this module. */
58
enum
Mode
59
{
60
MODE_DISTANCE
,
61
MODE_TIME
62
};
63
64
private
:
65
/**
66
* @brief Performs the rebound of the node if it reaches a boundary
67
* @param timeLeft The remaining time of the walk
68
*/
69
void
Rebound
(
Time
timeLeft);
70
/**
71
* Walk according to position and velocity, until distance is reached,
72
* time is reached, or intersection with the bounding box
73
* @param timeLeft The remaining time of the walk
74
*/
75
void
DoWalk
(
Time
timeLeft);
76
/**
77
* Draw a new random velocity and distance to travel, and call DoWalk()
78
*/
79
void
DrawRandomVelocityAndDistance
();
80
void
DoDispose
()
override
;
81
void
DoInitialize
()
override
;
82
Vector
DoGetPosition
()
const override
;
83
void
DoSetPosition
(
const
Vector& position)
override
;
84
Vector
DoGetVelocity
()
const override
;
85
int64_t
DoAssignStreams
(int64_t)
override
;
86
87
ConstantVelocityHelper
m_helper
;
//!< helper for this object
88
EventId
m_event
;
//!< stored event ID
89
Mode
m_mode
;
//!< whether in time or distance mode
90
double
m_modeDistance
;
//!< Change direction and speed after this distance
91
Time
m_modeTime
;
//!< Change current direction and speed after this delay
92
Ptr<RandomVariableStream>
m_speed
;
//!< rv for picking speed
93
Ptr<RandomVariableStream>
m_direction
;
//!< rv for picking direction
94
Rectangle
m_bounds
;
//!< Bounds of the area to cruise
95
};
96
97
}
// namespace ns3
98
99
#endif
/* RANDOM_WALK_2D_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::RandomWalk2dMobilityModel
2D random walk mobility model.
Definition
random-walk-2d-mobility-model.h:41
ns3::RandomWalk2dMobilityModel::Copy
Ptr< MobilityModel > Copy() const override
Copy function allows one to copy the underlying MobilityModel from a MobilityModel pointer,...
Definition
random-walk-2d-mobility-model.h:52
ns3::RandomWalk2dMobilityModel::m_speed
Ptr< RandomVariableStream > m_speed
rv for picking speed
Definition
random-walk-2d-mobility-model.h:92
ns3::RandomWalk2dMobilityModel::GetTypeId
static TypeId GetTypeId()
Register this type with the TypeId system.
Definition
random-walk-2d-mobility-model.cc:27
ns3::RandomWalk2dMobilityModel::DoInitialize
void DoInitialize() override
Initialize() implementation.
Definition
random-walk-2d-mobility-model.cc:78
ns3::RandomWalk2dMobilityModel::m_modeDistance
double m_modeDistance
Change direction and speed after this distance.
Definition
random-walk-2d-mobility-model.h:90
ns3::RandomWalk2dMobilityModel::~RandomWalk2dMobilityModel
~RandomWalk2dMobilityModel() override
Definition
random-walk-2d-mobility-model.cc:72
ns3::RandomWalk2dMobilityModel::DrawRandomVelocityAndDistance
void DrawRandomVelocityAndDistance()
Draw a new random velocity and distance to travel, and call DoWalk()
Definition
random-walk-2d-mobility-model.cc:87
ns3::RandomWalk2dMobilityModel::DoWalk
void DoWalk(Time timeLeft)
Walk according to position and velocity, until distance is reached, time is reached,...
Definition
random-walk-2d-mobility-model.cc:149
ns3::RandomWalk2dMobilityModel::Mode
Mode
An enum representing the different working modes of this module.
Definition
random-walk-2d-mobility-model.h:59
ns3::RandomWalk2dMobilityModel::MODE_TIME
@ MODE_TIME
Definition
random-walk-2d-mobility-model.h:61
ns3::RandomWalk2dMobilityModel::MODE_DISTANCE
@ MODE_DISTANCE
Definition
random-walk-2d-mobility-model.h:60
ns3::RandomWalk2dMobilityModel::Rebound
void Rebound(Time timeLeft)
Performs the rebound of the node if it reaches a boundary.
Definition
random-walk-2d-mobility-model.cc:196
ns3::RandomWalk2dMobilityModel::DoGetPosition
Vector DoGetPosition() const override
Definition
random-walk-2d-mobility-model.cc:235
ns3::RandomWalk2dMobilityModel::m_helper
ConstantVelocityHelper m_helper
helper for this object
Definition
random-walk-2d-mobility-model.h:87
ns3::RandomWalk2dMobilityModel::DoGetVelocity
Vector DoGetVelocity() const override
Definition
random-walk-2d-mobility-model.cc:253
ns3::RandomWalk2dMobilityModel::m_modeTime
Time m_modeTime
Change current direction and speed after this delay.
Definition
random-walk-2d-mobility-model.h:91
ns3::RandomWalk2dMobilityModel::m_bounds
Rectangle m_bounds
Bounds of the area to cruise.
Definition
random-walk-2d-mobility-model.h:94
ns3::RandomWalk2dMobilityModel::DoSetPosition
void DoSetPosition(const Vector &position) override
Definition
random-walk-2d-mobility-model.cc:242
ns3::RandomWalk2dMobilityModel::DoDispose
void DoDispose() override
Destructor implementation.
Definition
random-walk-2d-mobility-model.cc:227
ns3::RandomWalk2dMobilityModel::m_direction
Ptr< RandomVariableStream > m_direction
rv for picking direction
Definition
random-walk-2d-mobility-model.h:93
ns3::RandomWalk2dMobilityModel::DoAssignStreams
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Definition
random-walk-2d-mobility-model.cc:259
ns3::RandomWalk2dMobilityModel::m_mode
Mode m_mode
whether in time or distance mode
Definition
random-walk-2d-mobility-model.h:89
ns3::RandomWalk2dMobilityModel::m_event
EventId m_event
stored event ID
Definition
random-walk-2d-mobility-model.h:88
ns3::Rectangle
a 2d rectangle
Definition
rectangle.h:24
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:96
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.
rectangle.h
src
mobility
model
random-walk-2d-mobility-model.h
Generated on Wed Oct 1 2025 18:22:19 for ns-3 by
1.13.2