A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
gauss-markov-mobility-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 Dan Broyles
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Dan Broyles <dbroyl01@ku.edu>
7 * Thanks to Kevin Peters, faculty advisor James P.G. Sterbenz, and the ResiliNets
8 * initiative at The University of Kansas, https://resilinets.org
9 */
10#ifndef GAUSS_MARKOV_MOBILITY_MODEL_H
11#define GAUSS_MARKOV_MOBILITY_MODEL_H
12
13#include "box.h"
15#include "mobility-model.h"
16#include "position-allocator.h"
17
18#include "ns3/event-id.h"
19#include "ns3/nstime.h"
20#include "ns3/object.h"
21#include "ns3/ptr.h"
22#include "ns3/random-variable-stream.h"
23
24namespace ns3
25{
26
27/**
28 * \ingroup mobility
29 * \brief Gauss-Markov mobility model
30 *
31 * This is a 3D version of the Gauss-Markov mobility model described in [1].
32 * Unlike the other mobility models in ns-3, which are memoryless, the Gauss
33 * Markov model has both memory and variability. The tunable alpha parameter
34 * determines the how much memory and randomness you want to model.
35 * Each object starts with a specific velocity, direction (radians), and pitch
36 * angle (radians) equivalent to the mean velocity, direction, and pitch.
37 * At each timestep, a new velocity, direction, and pitch angle are generated
38 * based upon the previous value, the mean value, and a gaussian random variable.
39 * This version is suited for simple airplane flight, where direction, velocity,
40 * and pitch are the key variables.
41 * The motion field is limited by a 3D bounding box (called "box") which is a 3D
42 * version of the "rectangle" field that is used in 2-dimensional ns-3 mobility models.
43 *
44 * Here is an example of how to implement the model and set the initial node positions:
45 * \code
46 MobilityHelper mobility;
47
48 mobility.SetMobilityModel ("ns3::GaussMarkovMobilityModel",
49 "Bounds", BoxValue (Box (0, 150000, 0, 150000, 0, 10000)),
50 "TimeStep", TimeValue (Seconds (0.5)),
51 "Alpha", DoubleValue (0.85),
52 "MeanVelocity", StringValue ("ns3::UniformRandomVariable[Min=800|Max=1200]"),
53 "MeanDirection", StringValue ("ns3::UniformRandomVariable[Min=0|Max=6.283185307]"),
54 "MeanPitch", StringValue ("ns3::UniformRandomVariable[Min=0.05|Max=0.05]"),
55 "NormalVelocity", StringValue ("ns3::NormalRandomVariable[Mean=0.0|Variance=0.0|Bound=0.0]"),
56 "NormalDirection", StringValue ("ns3::NormalRandomVariable[Mean=0.0|Variance=0.2|Bound=0.4]"),
57 "NormalPitch", StringValue ("ns3::NormalRandomVariable[Mean=0.0|Variance=0.02|Bound=0.04]"));
58
59 mobility.SetPositionAllocator ("ns3::RandomBoxPositionAllocator",
60 "X", StringValue ("ns3::UniformRandomVariable[Min=0|Max=150000]"),
61 "Y", StringValue ("ns3::UniformRandomVariable[Min=0|Max=150000]"),
62 "Z", StringValue ("ns3::UniformRandomVariable[Min=0|Max=10000]"));
63
64 mobility.Install (wifiStaNodes);
65 * \endcode
66 * [1] Tracy Camp, Jeff Boleng, Vanessa Davies, "A Survey of Mobility Models
67 * for Ad Hoc Network Research", Wireless Communications and Mobile Computing,
68 * Wiley, vol.2 iss.5, September 2002, pp.483-502
69 */
71{
72 public:
73 /**
74 * Register this type with the TypeId system.
75 * \return the object TypeId
76 */
77 static TypeId GetTypeId();
80
81 private:
82 /**
83 * Initialize the model and calculate new velocity, direction, and pitch
84 */
85 void Start();
86 /**
87 * Perform a walk operation
88 * \param timeLeft time until Start method is called again
89 */
90 void DoWalk(Time timeLeft);
91 void DoDispose() override;
92 Vector DoGetPosition() const override;
93 void DoSetPosition(const Vector& position) override;
94 Vector DoGetVelocity() const override;
95 int64_t DoAssignStreams(int64_t) override;
96 ConstantVelocityHelper m_helper; //!< constant velocity helper
97 Time m_timeStep; //!< duraiton after which direction and speed should change
98 double m_alpha; //!< tunable constant in the model
99 double m_meanVelocity; //!< current mean velocity
100 double m_meanDirection; //!< current mean direction
101 double m_meanPitch; //!< current mean pitch
102 double m_Velocity; //!< current velocity
103 double m_Direction; //!< current direction
104 double m_Pitch; //!< current pitch
105 Ptr<RandomVariableStream> m_rndMeanVelocity; //!< rv used to assign avg velocity
106 Ptr<NormalRandomVariable> m_normalVelocity; //!< Gaussian rv used to for next velocity
107 Ptr<RandomVariableStream> m_rndMeanDirection; //!< rv used to assign avg direction
108 Ptr<NormalRandomVariable> m_normalDirection; //!< Gaussian rv for next direction value
109 Ptr<RandomVariableStream> m_rndMeanPitch; //!< rv used to assign avg. pitch
110 Ptr<NormalRandomVariable> m_normalPitch; //!< Gaussian rv for next pitch
111 EventId m_event; //!< event id of scheduled start
112 Box m_bounds; //!< bounding box
113};
114
115} // namespace ns3
116
117#endif /* GAUSS_MARKOV_MOBILITY_MODEL_H */
a 3d box
Definition box.h:24
Utility class used to move node with constant velocity.
An identifier for simulation events.
Definition event-id.h:45
Ptr< NormalRandomVariable > m_normalDirection
Gaussian rv for next direction value.
void DoDispose() override
Destructor implementation.
Ptr< NormalRandomVariable > m_normalPitch
Gaussian rv for next pitch.
void Start()
Initialize the model and calculate new velocity, direction, and pitch.
void DoWalk(Time timeLeft)
Perform a walk operation.
double m_meanVelocity
current mean velocity
double m_meanDirection
current mean direction
static TypeId GetTypeId()
Register this type with the TypeId system.
Ptr< NormalRandomVariable > m_normalVelocity
Gaussian rv used to for next velocity.
EventId m_event
event id of scheduled start
ConstantVelocityHelper m_helper
constant velocity helper
int64_t DoAssignStreams(int64_t) override
The default implementation does nothing but return the passed-in parameter.
Ptr< RandomVariableStream > m_rndMeanPitch
rv used to assign avg.
Ptr< RandomVariableStream > m_rndMeanVelocity
rv used to assign avg velocity
void DoSetPosition(const Vector &position) override
Ptr< RandomVariableStream > m_rndMeanDirection
rv used to assign avg direction
double m_alpha
tunable constant in the model
Time m_timeStep
duraiton after which direction and speed should change
Keep track of the current position and velocity of an object.
Smart pointer class similar to boost::intrusive_ptr.
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.