1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2009 IITP RAS 4 * 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 7 * published by the Free Software Foundation; 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 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 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 * Author: Denis Fakhriev <fakhriev@iitp.ru> 19 */ 20 #ifndef STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H 21 #define STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H 22 23 #include "constant-velocity-helper.h" 24 #include "mobility-model.h" 25 #include "position-allocator.h" 26 #include "ns3/ptr.h" 27 #include "ns3/random-variable-stream.h" 28 29 namespace ns3 { 30 31 /** 32 * \ingroup mobility 33 * \brief Steady-state random waypoint mobility model. 34 * 35 * This model based on random waypoint mobility (RWM) model for case when 36 * speed, pause and position are uniformly distributed random variables. 37 * The difference is that the initial values of this parameters are not 38 * from uniform distribution but from stationary distribution of RWM model. 39 * The implementation of this model is 2D-specific and with nonzero nodes speeds. 40 * In the 3D ns-3 coordinate system, the momement occurs on the 41 * \f$ z=\overline{Z} \f$ plane, where \f$ \overline{Z} \f$ is a constant which 42 * can be configured using the Z attribute. 43 * 44 * Based on NS-2 implementation by Toilers Research Group -- Colorado 45 * School of Mines (http://toilers.mines.edu). 46 * The papers related to this code are: 47 * W. Navidi and T. Camp, Stationary Distributions for the Random 48 * Waypoint Mobility Model, IEEE Transactions on Mobile Computing, 49 * vol. 3, no. 1, pp. 99-108, January-March 2004. 50 * W. Navidi, T. Camp, and N. Bauer, Improving the Accuracy of 51 * Random Waypoint Simulations Through Steady-State Initialization, 52 * Proceedings of the 15th International Conference on Modeling and 53 * Simulation (MS '04), pp. 319-326, March 2004. 54 */ 55 class SteadyStateRandomWaypointMobilityModel : public MobilityModel 56 { 57 public: 58 /** 59 * Register this type with the TypeId system. 60 * \return the object TypeId 61 */ 62 static TypeId GetTypeId (void); 63 SteadyStateRandomWaypointMobilityModel (); 64 protected: 65 virtual void DoInitialize (void); 66 private: 67 /** 68 * Configure random variables based on attributes; calculate the steady 69 * state probability that node is initially paused; schedule either end 70 * of pause time or initial motion of the node. 71 */ 72 void DoInitializePrivate (void); 73 /** 74 * Use provided destination to calculate travel delay, and schedule a 75 * Start() event at that time. 76 * \param destination the destination to move to 77 */ 78 void SteadyStateBeginWalk (const Vector &destination); 79 /** 80 * Start a pause period and schedule the ending of the pause 81 */ 82 void Start (void); 83 /** 84 * Start a motion period and schedule the ending of the motion 85 */ 86 void BeginWalk (void); 87 virtual Vector DoGetPosition (void) const; 88 virtual void DoSetPosition (const Vector &position); 89 virtual Vector DoGetVelocity (void) const; 90 virtual int64_t DoAssignStreams (int64_t); 91 92 ConstantVelocityHelper m_helper; //!< helper for velocity computations 93 double m_maxSpeed; //!< maximum speed value (m/s) 94 double m_minSpeed; //!< minimum speed value (m/s) 95 Ptr<UniformRandomVariable> m_speed; //!< random variable for speed values 96 double m_minX; //!< minimum x value of traveling region (m) 97 double m_maxX; //!< maximum x value of traveling region (m) 98 double m_minY; //!< minimum y value of traveling region (m) 99 double m_maxY; //!< maximum y value of traveling region (m) 100 double m_z; //!< z value of traveling region 101 Ptr<RandomBoxPositionAllocator> m_position; //!< position allocator 102 double m_minPause; //!< minimum pause value (s) 103 double m_maxPause; //!< maximum pause value (s) 104 Ptr<UniformRandomVariable> m_pause; //!< random variable for pause values 105 EventId m_event; //!< current event ID 106 bool alreadyStarted; //!< flag for starting state 107 Ptr<UniformRandomVariable> m_x1_r; //!< rv used in rejection sampling phase 108 Ptr<UniformRandomVariable> m_y1_r; //!< rv used in rejection sampling phase 109 Ptr<UniformRandomVariable> m_x2_r; //!< rv used in rejection sampling phase 110 Ptr<UniformRandomVariable> m_y2_r; //!< rv used in rejection sampling phase 111 Ptr<UniformRandomVariable> m_u_r; //!< rv used in step 5 of algorithm 112 Ptr<UniformRandomVariable> m_x; //!< rv used for position allocator 113 Ptr<UniformRandomVariable> m_y; //!< rv used for position allocator 114 }; 115 116 } // namespace ns3 117 118 #endif /* STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H */ 119