A Discrete-Event Network Simulator
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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef RANDOM_WALK_2D_MOBILITY_MODEL_H
20#define RANDOM_WALK_2D_MOBILITY_MODEL_H
21
23#include "mobility-model.h"
24#include "rectangle.h"
25
26#include "ns3/event-id.h"
27#include "ns3/nstime.h"
28#include "ns3/object.h"
29#include "ns3/random-variable-stream.h"
30
31namespace ns3
32{
33
34/**
35 * \ingroup mobility
36 * \brief 2D random walk mobility model.
37 *
38 * Each instance moves with a speed and direction chosen at random
39 * with the user-provided random variables until
40 * either a fixed distance has been walked or until a fixed amount
41 * of time. If we hit one of the boundaries (specified by a rectangle),
42 * of the model, we rebound on the boundary with a reflexive angle
43 * and speed. This model is often identified as a brownian motion
44 * model.
45 *
46 * The Direction random variable is used for any point strictly
47 * inside the boundaries. The points on the boundary have their
48 * direction chosen randomly, without considering the Direction
49 * Attribute.
50 */
52{
53 public:
54 /**
55 * Register this type with the TypeId system.
56 * \return the object TypeId
57 */
58 static TypeId GetTypeId();
59
60 /** An enum representing the different working modes of this module. */
61 enum Mode
62 {
65 };
66
67 private:
68 /**
69 * \brief Performs the rebound of the node if it reaches a boundary
70 * \param timeLeft The remaining time of the walk
71 */
72 void Rebound(Time timeLeft);
73 /**
74 * Walk according to position and velocity, until distance is reached,
75 * time is reached, or intersection with the bounding box
76 * \param timeLeft The remaining time of the walk
77 */
78 void DoWalk(Time timeLeft);
79 /**
80 * Perform initialization of the object before MobilityModel::DoInitialize ()
81 */
83 void DoDispose() override;
84 void DoInitialize() override;
85 Vector DoGetPosition() const override;
86 void DoSetPosition(const Vector& position) override;
87 Vector DoGetVelocity() const override;
88 int64_t DoAssignStreams(int64_t) override;
89
90 ConstantVelocityHelper m_helper; //!< helper for this object
91 EventId m_event; //!< stored event ID
92 Mode m_mode; //!< whether in time or distance mode
93 double m_modeDistance; //!< Change direction and speed after this distance
94 Time m_modeTime; //!< Change current direction and speed after this delay
95 Ptr<RandomVariableStream> m_speed; //!< rv for picking speed
96 Ptr<RandomVariableStream> m_direction; //!< rv for picking direction
97 Rectangle m_bounds; //!< Bounds of the area to cruise
98};
99
100} // namespace ns3
101
102#endif /* RANDOM_WALK_2D_MOBILITY_MODEL_H */
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition: event-id.h:55
Keep track of the current position and velocity of an object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Ptr< RandomVariableStream > m_speed
rv for picking speed
static TypeId GetTypeId()
Register this type with the TypeId system.
void DoInitialize() override
Initialize() implementation.
double m_modeDistance
Change direction and speed after this distance.
void DoInitializePrivate()
Perform initialization of the object before MobilityModel::DoInitialize ()
void DoWalk(Time timeLeft)
Walk according to position and velocity, until distance is reached, time is reached,...
Mode
An enum representing the different working modes of this module.
void Rebound(Time timeLeft)
Performs the rebound of the node if it reaches a boundary.
ConstantVelocityHelper m_helper
helper for this object
Time m_modeTime
Change current direction and speed after this delay.
Rectangle m_bounds
Bounds of the area to cruise.
void DoSetPosition(const Vector &position) override
void DoDispose() override
Destructor implementation.
Ptr< RandomVariableStream > m_direction
rv for picking direction
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Mode m_mode
whether in time or distance mode
a 2d rectangle
Definition: rectangle.h:35
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.