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 * 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
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
20namespace 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 */
41{
42 public:
43 /**
44 * Register this type with the TypeId system.
45 * @return the object TypeId
46 */
47 static TypeId GetTypeId();
48
50
51 /** An enum representing the different working modes of this module. */
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 */
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 */
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.
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 DrawRandomVelocityAndDistance()
Draw a new random velocity and distance to travel, and call DoWalk()
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:24
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.