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
/** An enum representing the different working modes of this module. */
52
enum
Mode
53
{
54
MODE_DISTANCE
,
55
MODE_TIME
56
};
57
58
private
:
59
/**
60
* @brief Performs the rebound of the node if it reaches a boundary
61
* @param timeLeft The remaining time of the walk
62
*/
63
void
Rebound
(
Time
timeLeft);
64
/**
65
* Walk according to position and velocity, until distance is reached,
66
* time is reached, or intersection with the bounding box
67
* @param timeLeft The remaining time of the walk
68
*/
69
void
DoWalk
(
Time
timeLeft);
70
/**
71
* Draw a new random velocity and distance to travel, and call DoWalk()
72
*/
73
void
DrawRandomVelocityAndDistance
();
74
void
DoDispose
()
override
;
75
void
DoInitialize
()
override
;
76
Vector
DoGetPosition
()
const override
;
77
void
DoSetPosition
(
const
Vector& position)
override
;
78
Vector
DoGetVelocity
()
const override
;
79
int64_t
DoAssignStreams
(int64_t)
override
;
80
81
ConstantVelocityHelper
m_helper
;
//!< helper for this object
82
EventId
m_event
;
//!< stored event ID
83
Mode
m_mode
;
//!< whether in time or distance mode
84
double
m_modeDistance
;
//!< Change direction and speed after this distance
85
Time
m_modeTime
;
//!< Change current direction and speed after this delay
86
Ptr<RandomVariableStream>
m_speed
;
//!< rv for picking speed
87
Ptr<RandomVariableStream>
m_direction
;
//!< rv for picking direction
88
Rectangle
m_bounds
;
//!< Bounds of the area to cruise
89
};
90
91
}
// namespace ns3
92
93
#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:45
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition
mobility-model.h:29
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::RandomWalk2dMobilityModel
2D random walk mobility model.
Definition
random-walk-2d-mobility-model.h:41
ns3::RandomWalk2dMobilityModel::m_speed
Ptr< RandomVariableStream > m_speed
rv for picking speed
Definition
random-walk-2d-mobility-model.h:86
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:84
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:53
ns3::RandomWalk2dMobilityModel::MODE_TIME
@ MODE_TIME
Definition
random-walk-2d-mobility-model.h:55
ns3::RandomWalk2dMobilityModel::MODE_DISTANCE
@ MODE_DISTANCE
Definition
random-walk-2d-mobility-model.h:54
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:81
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:85
ns3::RandomWalk2dMobilityModel::m_bounds
Rectangle m_bounds
Bounds of the area to cruise.
Definition
random-walk-2d-mobility-model.h:88
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:87
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:83
ns3::RandomWalk2dMobilityModel::m_event
EventId m_event
stored event ID
Definition
random-walk-2d-mobility-model.h:82
ns3::Rectangle
a 2d rectangle
Definition
rectangle.h:24
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
constant-velocity-helper.h
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 Fri Dec 13 2024 18:20:46 for ns-3 by
1.11.0