00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2006,2007 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef RANDOM_WALK_2D_MOBILITY_MODEL_H 00021 #define RANDOM_WALK_2D_MOBILITY_MODEL_H 00022 00023 #include "ns3/object.h" 00024 #include "ns3/nstime.h" 00025 #include "ns3/event-id.h" 00026 #include "ns3/rectangle.h" 00027 #include "ns3/random-variable.h" 00028 #include "mobility-model.h" 00029 #include "static-speed-helper.h" 00030 00031 namespace ns3 { 00032 00033 00034 /** 00035 * \brief a 2D random walk position model 00036 * 00037 * Each instance moves with a speed and direction choosen at random 00038 * with the user-provided random variables until 00039 * either a fixed distance has been walked or until a fixed amount 00040 * of time. If we hit one of the boundaries (specified by a rectangle), 00041 * of the model, we rebound on the boundary with a reflexive angle 00042 * and speed. This model is often identified as a brownian motion 00043 * model. 00044 */ 00045 class RandomWalk2dMobilityModel : public MobilityModel 00046 { 00047 public: 00048 static TypeId GetTypeId (void); 00049 00050 enum Mode { 00051 MODE_DISTANCE, 00052 MODE_TIME 00053 }; 00054 00055 RandomWalk2dMobilityModel (); 00056 00057 private: 00058 void Start (void); 00059 void Rebound (Time timeLeft); 00060 void DoWalk (Time timeLeft); 00061 virtual void DoDispose (void); 00062 virtual Vector DoGetPosition (void) const; 00063 virtual void DoSetPosition (const Vector &position); 00064 virtual Vector DoGetVelocity (void) const; 00065 00066 StaticSpeedHelper m_helper; 00067 EventId m_event; 00068 enum Mode m_mode; 00069 double m_modeDistance; 00070 Time m_modeTime; 00071 RandomVariable m_speed; 00072 RandomVariable m_direction; 00073 Rectangle m_bounds; 00074 }; 00075 00076 00077 } // namespace ns3 00078 00079 #endif /* RANDOM_WALK_2D_MOBILITY_MODEL_H */