LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 Dan Broyles | 3 * Copyright (c) 2009 Dan Broyles |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Dan Broyles <dbroyl01@ku.edu> | 18 * Author: Dan Broyles <dbroyl01@ku.edu> |
| 19 * Thanks to Kevin Peters, faculty advisor James P.G. Sterbenz, and the ResiliNe
ts· |
| 20 * initiative at The University of Kansas, https://wiki.ittc.ku.edu/resilinets |
19 */ | 21 */ |
20 #ifndef GAUSS_MARKOV_MOBILITY_MODEL_H | 22 #ifndef GAUSS_MARKOV_MOBILITY_MODEL_H |
21 #define GAUSS_MARKOV_MOBILITY_MODEL_H | 23 #define GAUSS_MARKOV_MOBILITY_MODEL_H |
22 | 24 |
23 #include "constant-velocity-helper.h" | 25 #include "constant-velocity-helper.h" |
24 #include "mobility-model.h" | 26 #include "mobility-model.h" |
25 #include "position-allocator.h" | 27 #include "position-allocator.h" |
26 #include "ns3/ptr.h" | 28 #include "ns3/ptr.h" |
27 #include "ns3/object.h" | 29 #include "ns3/object.h" |
28 #include "ns3/nstime.h" | 30 #include "ns3/nstime.h" |
29 #include "ns3/event-id.h" | 31 #include "ns3/event-id.h" |
30 #include "ns3/box.h" | 32 #include "ns3/box.h" |
31 #include "ns3/random-variable.h" | 33 #include "ns3/random-variable.h" |
32 | 34 |
33 namespace ns3 { | 35 namespace ns3 { |
34 | 36 |
35 /** | 37 /** |
36 * \brief description of gauss markov mobility model | 38 * \brief description of gauss markov mobility model |
37 * | 39 * |
38 * Each object starts with a specific velocity (x,y,z). At each constant timeste
p,· | 40 * This is a 3D version of the Gauss-Markov mobility model described in [1].· |
39 * the velocity in each direction (x, y, and z) changes based upon the previous
velocity,· | 41 * Unlike the other mobility models in ns-3, which are memoryless, the Gauss |
40 * the mean velocity, and a gaussian random variable. | 42 * Markov model has both memory and variability. The tunable alpha parameter |
| 43 * determines the how much memory and randomness you want to model. |
| 44 * Each object starts with a specific velocity, direction (radians), and pitch· |
| 45 * angle (radians) equivalent to the mean velocity, direction, and pitch.· |
| 46 * At each timestep, a new velocity, direction, and pitch angle are generated· |
| 47 * based upon the previous value, the mean value, and a gaussian random variable
.· |
| 48 * This version is suited for simple airplane flight, where direction, velocity, |
| 49 * and pitch are the key variables. |
| 50 * The motion field is limited by a 3D bounding box (called "box") which is a 3D |
| 51 * version of the "rectangle" field that is used in 2-dimensional ns-3 mobility
models. |
41 *· | 52 *· |
| 53 * Here is an example of how to implement the model and set the initial node pos
itions: |
| 54 *· |
| 55 * MobilityHelper mobility; |
| 56 *· |
| 57 * mobility.SetMobilityModel ("ns3::GaussMarkovMobilityModel", |
| 58 * "Bounds", BoxValue (Box (0, 150000, 0, 150000, 0, 10000)), |
| 59 * "TimeStep", TimeValue (Seconds (0.5)), |
| 60 * "Alpha", DoubleValue (0.85), |
| 61 * "MeanVelocity", RandomVariableValue (UniformVariable (800, 1200)), |
| 62 * "MeanDirection", RandomVariableValue (UniformVariable (0, 6.283185307)), |
| 63 * "MeanPitch", RandomVariableValue (UniformVariable (0.05, 0.05)), |
| 64 * "NormalVelocity", RandomVariableValue (NormalVariable (0.0, 0.0, 0.0)), |
| 65 * "NormalDirection", RandomVariableValue (NormalVariable (0.0, 0.2, 0.4)), |
| 66 * "NormalPitch", RandomVariableValue (NormalVariable (0.0, 0.02, 0.04))); |
| 67 *· |
| 68 * mobility.SetPositionAllocator ("ns3::RandomBoxPositionAllocator", |
| 69 * "X", RandomVariableValue (UniformVariable (0, 150000)), |
| 70 * "Y", RandomVariableValue (UniformVariable (0, 150000)), |
| 71 * "Z", RandomVariableValue (UniformVariable (0, 10000))); |
| 72 * |
| 73 * mobility.Install (wifiStaNodes); |
| 74 * |
| 75 * [1] Tracy Camp, Jeff Boleng, Vanessa Davies, "A Survey of Mobility Models |
| 76 * for Ad Hoc Network Research", Wireless Communications and Mobile Computing, |
| 77 * Wiley, vol.2 iss.5, September 2002, pp.483-502 |
42 */ | 78 */ |
| 79 |
43 class GaussMarkovMobilityModel : public MobilityModel | 80 class GaussMarkovMobilityModel : public MobilityModel |
44 { | 81 { |
45 public: | 82 public: |
46 static TypeId GetTypeId (void); | 83 static TypeId GetTypeId (void); |
47 GaussMarkovMobilityModel (); | 84 GaussMarkovMobilityModel (); |
48 private: | 85 private: |
49 void Start (void); | 86 void Start (void); |
50 void DoWalk (Time timeLeft); | 87 void DoWalk (Time timeLeft); |
51 virtual void DoDispose (void); | 88 virtual void DoDispose (void); |
52 virtual Vector DoGetPosition (void) const; | 89 virtual Vector DoGetPosition (void) const; |
53 virtual void DoSetPosition (const Vector &position); | 90 virtual void DoSetPosition (const Vector &position); |
54 virtual Vector DoGetVelocity (void) const; | 91 virtual Vector DoGetVelocity (void) const; |
55 // void DoSetVelocity (const Vector &vel); | |
56 | |
57 ConstantVelocityHelper m_helper; | 92 ConstantVelocityHelper m_helper; |
58 // Ptr<PositionAllocator> m_position; | |
59 // Vector m_velocity; I am using the position and velocity variables from the
constant-velocity-helper object | |
60 Time m_timeStep; | 93 Time m_timeStep; |
61 double m_alpha; | 94 double m_alpha; |
62 double m_meanVelocity; | 95 double m_meanVelocity; |
63 double m_meanDirection; | 96 double m_meanDirection; |
64 double m_meanPitch; | 97 double m_meanPitch; |
65 double m_Velocity; | 98 double m_Velocity; |
66 double m_Direction; | 99 double m_Direction; |
67 double m_Pitch; | 100 double m_Pitch; |
68 RandomVariable m_rndMeanVelocity; | 101 RandomVariable m_rndMeanVelocity; |
69 RandomVariable m_normalVelocity; | 102 RandomVariable m_normalVelocity; |
70 RandomVariable m_rndMeanDirection; | 103 RandomVariable m_rndMeanDirection; |
71 RandomVariable m_normalDirection; | 104 RandomVariable m_normalDirection; |
72 RandomVariable m_rndMeanPitch; | 105 RandomVariable m_rndMeanPitch; |
73 RandomVariable m_normalPitch; | 106 RandomVariable m_normalPitch; |
74 EventId m_event; | 107 EventId m_event; |
75 Box m_bounds; | 108 Box m_bounds; |
76 }; | 109 }; |
77 | 110 |
78 } // namespace ns3 | 111 } // namespace ns3 |
79 | 112 |
80 #endif /* GAUSS_MARKOV_MOBILITY_MODEL_H */ | 113 #endif /* GAUSS_MARKOV_MOBILITY_MODEL_H */ |
LEFT | RIGHT |