mobility module to new directory structure
authorTom Henderson <tomh@tomh.org>
Fri, 25 Feb 2011 16:06:17 -0800
changeset 6839 34074e4ed93b
parent 6838 ec300106f06f
child 6840 459dbad710ba
mobility module to new directory structure
examples/tap/tap-wifi-dumbbell.cc
examples/tap/tap-wifi-virtual-machine.cc
src/helper/mobility-helper.cc
src/helper/mobility-helper.h
src/helper/ns2-mobility-helper.cc
src/helper/ns2-mobility-helper.h
src/helper/wscript
src/mobility/box.cc
src/mobility/box.h
src/mobility/constant-acceleration-mobility-model.cc
src/mobility/constant-acceleration-mobility-model.h
src/mobility/constant-position-mobility-model.cc
src/mobility/constant-position-mobility-model.h
src/mobility/constant-velocity-helper.cc
src/mobility/constant-velocity-helper.h
src/mobility/constant-velocity-mobility-model.cc
src/mobility/constant-velocity-mobility-model.h
src/mobility/gauss-markov-mobility-model.cc
src/mobility/gauss-markov-mobility-model.h
src/mobility/helper/mobility-helper.cc
src/mobility/helper/mobility-helper.h
src/mobility/helper/ns2-mobility-helper.cc
src/mobility/helper/ns2-mobility-helper.h
src/mobility/hierarchical-mobility-model.cc
src/mobility/hierarchical-mobility-model.h
src/mobility/mobility-model.cc
src/mobility/mobility-model.h
src/mobility/mobility.h
src/mobility/model/box.cc
src/mobility/model/box.h
src/mobility/model/constant-acceleration-mobility-model.cc
src/mobility/model/constant-acceleration-mobility-model.h
src/mobility/model/constant-position-mobility-model.cc
src/mobility/model/constant-position-mobility-model.h
src/mobility/model/constant-velocity-helper.cc
src/mobility/model/constant-velocity-helper.h
src/mobility/model/constant-velocity-mobility-model.cc
src/mobility/model/constant-velocity-mobility-model.h
src/mobility/model/gauss-markov-mobility-model.cc
src/mobility/model/gauss-markov-mobility-model.h
src/mobility/model/hierarchical-mobility-model.cc
src/mobility/model/hierarchical-mobility-model.h
src/mobility/model/mobility-model.cc
src/mobility/model/mobility-model.h
src/mobility/model/mobility.h
src/mobility/model/position-allocator.cc
src/mobility/model/position-allocator.h
src/mobility/model/random-direction-2d-mobility-model.cc
src/mobility/model/random-direction-2d-mobility-model.h
src/mobility/model/random-walk-2d-mobility-model.cc
src/mobility/model/random-walk-2d-mobility-model.h
src/mobility/model/random-waypoint-mobility-model.cc
src/mobility/model/random-waypoint-mobility-model.h
src/mobility/model/rectangle.cc
src/mobility/model/rectangle.h
src/mobility/model/steady-state-random-waypoint-mobility-model.cc
src/mobility/model/steady-state-random-waypoint-mobility-model.h
src/mobility/model/waypoint-mobility-model.cc
src/mobility/model/waypoint-mobility-model.h
src/mobility/model/waypoint.cc
src/mobility/model/waypoint.h
src/mobility/position-allocator.cc
src/mobility/position-allocator.h
src/mobility/random-direction-2d-mobility-model.cc
src/mobility/random-direction-2d-mobility-model.h
src/mobility/random-walk-2d-mobility-model.cc
src/mobility/random-walk-2d-mobility-model.h
src/mobility/random-waypoint-mobility-model.cc
src/mobility/random-waypoint-mobility-model.h
src/mobility/rectangle.cc
src/mobility/rectangle.h
src/mobility/steady-state-random-waypoint-mobility-model.cc
src/mobility/steady-state-random-waypoint-mobility-model.h
src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc
src/mobility/test/waypoint-mobility-model-test.cc
src/mobility/waypoint-mobility-model.cc
src/mobility/waypoint-mobility-model.h
src/mobility/waypoint.cc
src/mobility/waypoint.h
src/mobility/wscript
--- a/examples/tap/tap-wifi-dumbbell.cc	Fri Feb 25 15:27:30 2011 -0800
+++ b/examples/tap/tap-wifi-dumbbell.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -101,7 +101,7 @@
 
 #include "ns3/core-module.h"
 #include "ns3/network-module.h"
-#include "ns3/core-module.h"
+#include "ns3/mobility-module.h"
 #include "ns3/wifi-module.h"
 #include "ns3/helper-module.h"
 #include "ns3/ipv4-global-routing-helper.h"
--- a/examples/tap/tap-wifi-virtual-machine.cc	Fri Feb 25 15:27:30 2011 -0800
+++ b/examples/tap/tap-wifi-virtual-machine.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -71,7 +71,7 @@
 
 #include "ns3/core-module.h"
 #include "ns3/network-module.h"
-#include "ns3/core-module.h"
+#include "ns3/mobility-module.h"
 #include "ns3/wifi-module.h"
 #include "ns3/helper-module.h"
 
--- a/src/helper/mobility-helper.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,248 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "ns3/mobility-helper.h"
-#include "ns3/mobility-model.h"
-#include "ns3/position-allocator.h"
-#include "ns3/hierarchical-mobility-model.h"
-#include "ns3/log.h"
-#include "ns3/pointer.h"
-#include "ns3/config.h"
-#include "ns3/simulator.h"
-#include "ns3/names.h"
-#include <iostream>
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("MobilityHelper");
-
-MobilityHelper::MobilityHelper ()
-{
-  m_position = CreateObjectWithAttributes<RandomRectanglePositionAllocator> 
-    ("X", RandomVariableValue (ConstantVariable (0.0)),
-     "Y", RandomVariableValue (ConstantVariable (0.0)));
-  m_mobility.SetTypeId ("ns3::ConstantPositionMobilityModel");
-}
-MobilityHelper::~MobilityHelper ()
-{}
-void 
-MobilityHelper::SetPositionAllocator (Ptr<PositionAllocator> allocator)
-{
-  m_position = allocator;
-}
-
-void 
-MobilityHelper::SetPositionAllocator (std::string type,
-                                      std::string n1, const AttributeValue &v1,
-                                      std::string n2, const AttributeValue &v2,
-                                      std::string n3, const AttributeValue &v3,
-                                      std::string n4, const AttributeValue &v4,
-                                      std::string n5, const AttributeValue &v5,
-                                      std::string n6, const AttributeValue &v6,
-                                      std::string n7, const AttributeValue &v7,
-                                      std::string n8, const AttributeValue &v8,
-                                      std::string n9, const AttributeValue &v9)
-{
-  ObjectFactory pos;
-  pos.SetTypeId (type);
-  pos.Set (n1, v1);
-  pos.Set (n2, v2);
-  pos.Set (n3, v3);
-  pos.Set (n4, v4);
-  pos.Set (n5, v5);
-  pos.Set (n6, v6);
-  pos.Set (n7, v7);
-  pos.Set (n8, v8);
-  pos.Set (n9, v9);
-  m_position = pos.Create ()->GetObject<PositionAllocator> ();
-}
-
-void 
-MobilityHelper::SetMobilityModel (std::string type,
-                                  std::string n1, const AttributeValue &v1,
-                                  std::string n2, const AttributeValue &v2,
-                                  std::string n3, const AttributeValue &v3,
-                                  std::string n4, const AttributeValue &v4,
-                                  std::string n5, const AttributeValue &v5,
-                                  std::string n6, const AttributeValue &v6,
-                                  std::string n7, const AttributeValue &v7,
-                                  std::string n8, const AttributeValue &v8,
-                                  std::string n9, const AttributeValue &v9)
-{
-  m_mobility.SetTypeId (type);
-  m_mobility.Set (n1, v1);
-  m_mobility.Set (n2, v2);
-  m_mobility.Set (n3, v3);
-  m_mobility.Set (n4, v4);
-  m_mobility.Set (n5, v5);
-  m_mobility.Set (n6, v6);
-  m_mobility.Set (n7, v7);
-  m_mobility.Set (n8, v8);
-  m_mobility.Set (n9, v9);
-}
-
-void 
-MobilityHelper::PushReferenceMobilityModel (Ptr<Object> reference)
-{
-  Ptr<MobilityModel> mobility = reference->GetObject<MobilityModel> ();
-  m_mobilityStack.push_back (mobility);
-}
-
-void 
-MobilityHelper::PushReferenceMobilityModel (std::string referenceName)
-{
-  Ptr<MobilityModel> mobility = Names::Find<MobilityModel> (referenceName);
-  m_mobilityStack.push_back (mobility);
-}
-
-void 
-MobilityHelper::PopReferenceMobilityModel (void)
-{
-  m_mobilityStack.pop_back ();
-}
-
-
-std::string 
-MobilityHelper::GetMobilityModelType (void) const
-{
-  return m_mobility.GetTypeId ().GetName ();
-}
-
-void
-MobilityHelper::Install (Ptr<Node> node) const
-{
-  Ptr<Object> object = node;
-  Ptr<MobilityModel> model = object->GetObject<MobilityModel> ();
-  if (model == 0)
-    {
-      model = m_mobility.Create ()->GetObject<MobilityModel> ();
-      if (model == 0)
-        {
-          NS_FATAL_ERROR ("The requested mobility model is not a mobility model: \""<< 
-                          m_mobility.GetTypeId ().GetName ()<<"\"");
-        }
-      if (m_mobilityStack.empty ())
-        {
-          NS_LOG_DEBUG ("node="<<object<<", mob="<<model);
-          object->AggregateObject (model);
-        }
-      else
-        {
-          // we need to setup a hierarchical mobility model
-          Ptr<MobilityModel> parent = m_mobilityStack.back ();
-          Ptr<MobilityModel> hierarchical = 
-            CreateObjectWithAttributes<HierarchicalMobilityModel> ("Child", PointerValue (model),
-                                                     "Parent", PointerValue (parent));
-          object->AggregateObject (hierarchical);
-          NS_LOG_DEBUG ("node="<<object<<", mob="<<hierarchical);
-        }
-    }
-  Vector position = m_position->GetNext ();
-  model->SetPosition (position);
-}
-
-void
-MobilityHelper::Install (std::string nodeName) const
-{
-  Ptr<Node> node = Names::Find<Node> (nodeName);
-  Install (node);
-}
-void 
-MobilityHelper::Install (NodeContainer c) const
-{
-  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
-    {
-      Install (*i);
-    }
-}
-
-void 
-MobilityHelper::InstallAll (void)
-{
-  Install (NodeContainer::GetGlobal ());
-}
-static double
-DoRound (double v)
-{
-  if (v <= 1e-4 && v >= -1e-4)
-    {
-      return 0.0;
-    }
-  else if (v <= 1e-3 && v >= 0)
-    {
-      return 1e-3;
-    }
-  else if (v >= -1e-3 && v <= 0)
-    {
-      return -1e-3;
-    }
-  else
-    {
-      return v;
-    }
-}
-void
-MobilityHelper::CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility)
-{
-  Ptr<Node> node = mobility->GetObject<Node> ();
-  *os << "now=" << Simulator::Now ()
-      << " node=" << node->GetId ();
-  Vector pos = mobility->GetPosition ();
-  pos.x = DoRound (pos.x);
-  pos.y = DoRound (pos.y);
-  pos.z = DoRound (pos.z);
-  Vector vel = mobility->GetVelocity ();
-  vel.x = DoRound (vel.x);
-  vel.y = DoRound (vel.y);
-  vel.z = DoRound (vel.z);
-  std::streamsize saved_precision = os->precision ();
-  std::ios::fmtflags saved_flags = os->flags ();
-  os->precision (3);
-  os->setf (std::ios::fixed,std::ios::floatfield);
-  *os << " pos=" << pos.x << ":" << pos.y << ":" << pos.z
-      << " vel=" << vel.x << ":" << vel.y << ":" << vel.z
-      << std::endl;
-  os->flags (saved_flags);
-  os->precision (saved_precision);
-}
-
-void 
-MobilityHelper::EnableAscii (std::ostream &os, uint32_t nodeid)
-{
-  std::ostringstream oss;
-  oss << "/NodeList/" << nodeid << "/$ns3::MobilityModel/CourseChange";
-  Config::ConnectWithoutContext (oss.str (), 
-                                 MakeBoundCallback (&MobilityHelper::CourseChanged, &os));
-}
-void 
-MobilityHelper::EnableAscii (std::ostream &os, NodeContainer n)
-{
-  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
-    {
-      EnableAscii (os, (*i)->GetId ());
-    }
-}
-void 
-MobilityHelper::EnableAsciiAll (std::ostream &os)
-{
-  EnableAscii (os, NodeContainer::GetGlobal ());
-}
-
-
-} // namespace ns3
--- a/src/helper/mobility-helper.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,262 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2008 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#ifndef MOBILITY_HELPER_H
-#define MOBILITY_HELPER_H
-
-#include <vector>
-#include "ns3/object-factory.h"
-#include "ns3/attribute.h"
-#include "ns3/position-allocator.h"
-#include "node-container.h"
-
-namespace ns3 {
-
-class PositionAllocator;
-class MobilityModel;
-
-/**
- * \ingroup mobility
- * \brief Helper class used to assign positions and mobility models to nodes.
- *
- * MobilityHelper::Install is the most important method here.
- */
-class MobilityHelper
-{
-public:
-  /**
-   * Construct a Mobility Helper which is used to make life easier when working
-   * with mobility models.
-   */
-  MobilityHelper ();
-
-  /**
-   * \internal
-   * Destroy a Mobility Helper
-   */
-  ~MobilityHelper ();
-
-  /**
-   * Set the position allocator which will be used to allocate the initial 
-   * position of every node initialized during MobilityModel::Install.
-   *
-   * \param allocator allocate initial node positions
-   */
-  void SetPositionAllocator (Ptr<PositionAllocator> allocator);
-
-  /**
-   * \param type the type of mobility model to use.
-   * \param n1 the name of the attribute to set in the mobility model.
-   * \param v1 the value of the attribute to set in the mobility model.
-   * \param n2 the name of the attribute to set in the mobility model.
-   * \param v2 the value of the attribute to set in the mobility model.
-   * \param n3 the name of the attribute to set in the mobility model.
-   * \param v3 the value of the attribute to set in the mobility model.
-   * \param n4 the name of the attribute to set in the mobility model.
-   * \param v4 the value of the attribute to set in the mobility model.
-   * \param n5 the name of the attribute to set in the mobility model.
-   * \param v5 the value of the attribute to set in the mobility model.
-   * \param n6 the name of the attribute to set in the mobility model.
-   * \param v6 the value of the attribute to set in the mobility model.
-   * \param n7 the name of the attribute to set in the mobility model.
-   * \param v7 the value of the attribute to set in the mobility model.
-   * \param n8 the name of the attribute to set in the mobility model.
-   * \param v8 the value of the attribute to set in the mobility model.
-   * \param n9 the name of the attribute to set in the mobility model.
-   * \param v9 the value of the attribute to set in the mobility model.
-   */
-  void SetPositionAllocator (std::string type,
-                             std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
-                             std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
-                             std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
-                             std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
-                             std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
-                             std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
-                             std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
-                             std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
-                             std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
-
-  /**
-   * \param type the type of mobility model to use.
-   * \param n1 the name of the attribute to set in the mobility model.
-   * \param v1 the value of the attribute to set in the mobility model.
-   * \param n2 the name of the attribute to set in the mobility model.
-   * \param v2 the value of the attribute to set in the mobility model.
-   * \param n3 the name of the attribute to set in the mobility model.
-   * \param v3 the value of the attribute to set in the mobility model.
-   * \param n4 the name of the attribute to set in the mobility model.
-   * \param v4 the value of the attribute to set in the mobility model.
-   * \param n5 the name of the attribute to set in the mobility model.
-   * \param v5 the value of the attribute to set in the mobility model.
-   * \param n6 the name of the attribute to set in the mobility model.
-   * \param v6 the value of the attribute to set in the mobility model.
-   * \param n7 the name of the attribute to set in the mobility model.
-   * \param v7 the value of the attribute to set in the mobility model.
-   * \param n8 the name of the attribute to set in the mobility model.
-   * \param v8 the value of the attribute to set in the mobility model.
-   * \param n9 the name of the attribute to set in the mobility model.
-   * \param v9 the value of the attribute to set in the mobility model.
-   *
-   * Calls to MobilityHelper::Install will create an instance of a matching 
-   * mobility model for each node.
-   */
-  void SetMobilityModel (std::string type,
-                         std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
-                         std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
-                         std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
-                         std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
-                         std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
-                         std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
-                         std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
-                         std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
-                         std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
-
-  /**
-   * \param reference item to push.
-   *
-   * Push an item on the top of the stack of "reference mobility models".
-   * The input item should be a node instance to which a mobility model
-   * has already been aggregated (usually by a call to Install).
-   *
-   * If this stack is not empty when MobilityHelper::Install
-   * is called, the model from the top of the stack is used
-   * to create a ns3::HierarchicalMobilityModel to make the
-   * newly-created models define their positions relative to that
-   * of the parent mobility model.
-   *
-   * This method is typically used to create hierarchical mobility
-   * patterns and positions by starting with the large-scale mobility
-   * features, and, then, defining the smaller-scale movements relative
-   * to a few reference points in the large-scale model.
-   */
-  void PushReferenceMobilityModel (Ptr<Object> reference);
-  /**
-   * \param referenceName named item to push.
-   *
-   * Push an item on the top of the stack of "reference mobility models".
-   * The input item should be a node instance to which a mobility model
-   * has already been aggregated (usually by a call to Install).
-   *
-   * If this stack is not empty when MobilityHelper::Install
-   * is called, the model from the top of the stack is used
-   * to create a ns3::HierarchicalMobilityModel to make the
-   * newly-created models define their positions relative to that
-   * of the parent mobility model.
-   *
-   * This method is typically used to create hierarchical mobility
-   * patterns and positions by starting with the large-scale mobility
-   * features, and, then, defining the smaller-scale movements relative
-   * to a few reference points in the large-scale model.
-   */
-  void PushReferenceMobilityModel (std::string referenceName);
-  /**
-   * Remove the top item from the top of the stack of
-   * "reference mobility models".
-   */
-  void PopReferenceMobilityModel (void);
-
-  /**
-   * \return a string which contains the TypeId of the currently-selected
-   *          mobility model.
-   */
-  std::string GetMobilityModelType (void) const;
-
-  /**
-   * \brief "Layout" a single node according to the current position allocator type.
-   *
-   * This method creates an instance of a ns3::MobilityModel subclass (the 
-   * type of which was set with MobilityHelper::SetMobilityModel), aggregates
-   * it to the provided node, and sets an initial position based on the current
-   * position allocator (set through MobilityHelper::SetPositionAllocator). 
-   *
-   * \param node The node to "layout."
-   */
-  void Install (Ptr<Node> node) const;
-  /**
-   * \brief "Layout" a single node according to the current position allocator type.
-   *
-   * This method creates an instance of a ns3::MobilityModel subclass (the 
-   * type of which was set with MobilityHelper::SetMobilityModel), aggregates
-   * it to the provided node, and sets an initial position based on the current
-   * position allocator (set through MobilityHelper::SetPositionAllocator). 
-   *
-   * \param nodeName The name of the node to "layout."
-   */
-  void Install (std::string nodeName) const;
-
-  /**
-   * \brief Layout a collection of nodes according to the current position allocator type.
-   *
-   * For each node in the provided NodeContainer, this method creates an instance 
-   * of a ns3::MobilityModel subclass (the type of which was set with 
-   * MobilityHelper::SetMobilityModel), aggregates it to the node, and sets an 
-   * initial position based on the current position allocator (set through 
-   * MobilityHelper::SetPositionAllocator). 
-   *
-   * \param container The set of nodes to layout.
-   */
-  void Install (NodeContainer container) const;
-
-  /**
-   * Perform the work of MobilityHelper::Install on _all_ nodes which
-   * exist in the simulation.
-   */
-  void InstallAll (void);
-
-  /**
-   * \param os output stream
-   * \param nodeid the id of the node to generate ascii output for.
-   *
-   * Enable ascii output on the mobility model associated to the
-   * specified nodeid and dump that to the specified stdc++ output 
-   * stream.
-   */
-  static void EnableAscii (std::ostream &os, uint32_t nodeid);
-  /**
-   * \param os output stream
-   * \param n node container
-   *
-   * Enable ascii output on the mobility model associated each of
-   * the nodes in the input container and dump that to the 
-   * specified stdc++ output stream.
-   */
-  static void EnableAscii (std::ostream &os, NodeContainer n);
-  /**
-   * \param os output stream
-   *
-   * Enable ascii output on the mobility model associated
-   * every node in the system and dump that to the specified 
-   * stdc++ output stream.
-   */
-  static void EnableAsciiAll (std::ostream &os);
-
-private:
-  /**
-   * \internal
-   */
-  static void CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility);
-  std::vector<Ptr<MobilityModel> > m_mobilityStack;
-  ObjectFactory m_mobility;
-  Ptr<PositionAllocator> m_position;
-};
-
-} // namespace ns3
-
-#endif /* MOBILITY_HELPER_H */
--- a/src/helper/ns2-mobility-helper.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1029 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *               2009,2010 Contributors
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- * Contributors: Thomas Waldecker <twaldecker@rocketmail.com>
- *               Martín Giachino <martin.giachino@gmail.com>
- *
- * Brief description: Implementation of a ns2 movement trace file reader.
- *
- * This implementation is based on the ns2 movement documentation of ns2
- * as described in http://www.isi.edu/nsnam/ns/doc/node174.html
- *
- * Valid trace files use the following ns2 statements:
- *
- * $node set X_ x1
- * $node set Y_ y1
- * $node set Z_ z1
- * $ns at $time $node setdest x2 y2 speed
- * $ns at $time $node set X_ x1
- * $ns at $time $node set Y_ Y1
- * $ns at $time $node set Z_ Z1
- *
- */
-
-
-#include <fstream>
-#include <sstream>
-#include <map>
-#include <algorithm>
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/node-list.h"
-#include "ns3/node.h"
-#include "ns3/constant-velocity-mobility-model.h"
-#include "ns3/test.h"
-#include "ns3/node-container.h"
-#include "ns3/names.h"
-#include "ns3/config.h"
-#include "ns2-mobility-helper.h"
-
-NS_LOG_COMPONENT_DEFINE ("Ns2MobilityHelper");
-
-using namespace std;
-
-namespace ns3 {
-
-// Constants definitions
-#define  NS2_AT       "at"
-#define  NS2_X_COORD  "X_"
-#define  NS2_Y_COORD  "Y_"
-#define  NS2_Z_COORD  "Z_"
-#define  NS2_SETDEST  "setdest"
-#define  NS2_SET      "set"
-#define  NS2_NODEID   "$node_("
-#define  NS2_NS_SCH   "$ns_"
-
-
-// Type to maintain line parsed and its values
-struct ParseResult
-{
-  vector<string> tokens; // tokens from a line
-  vector<int> ivals;     // int values for each tokens
-  vector<bool> has_ival; // points if a tokens has an int value
-  vector<double> dvals;  // double values for each tokens
-  vector<bool> has_dval; // points if a tokens has a double value
-  vector<string> svals;  // string value for each token
-};
-
-
-// Parses a line of ns2 mobility
-static ParseResult ParseNs2Line (const string& str);
-
-// Put out blank spaces at the start and end of a line
-static string TrimNs2Line (const string& str);
-
-// Checks if a string represents a number or it has others characters than digits an point.
-static bool IsNumber (const string& s);
-
-// Check if s string represents a numeric value
-template<class T>
-static bool IsVal (const string& str, T& ret);
-
-// Checks if the value between brackets is a correct nodeId number
-static bool HasNodeIdNumber (string str);
-
-// Gets nodeId number in string format from the string like $node_(4)
-static string GetNodeIdFromToken (string str);
-
-// Get node id number in int format
-static int GetNodeIdInt (ParseResult pr);
-
-// Get node id number in string format
-static string GetNodeIdString (ParseResult pr);
-
-// Add one coord to a vector position
-static Vector SetOneInitialCoord (Vector actPos, string& coord, double value);
-
-// Check if this corresponds to a line like this: $node_(0) set X_ 123
-static bool IsSetInitialPos (ParseResult pr);
-
-// Check if this corresponds to a line like this: $ns_ at 1 "$node_(0) setdest 2 3 4"
-static bool IsSchedSetPos (ParseResult pr);
-
-// Check if this corresponds to a line like this: $ns_ at 1 "$node_(0) set X_ 2"
-static bool IsSchedMobilityPos (ParseResult pr);
-
-// Set waypoints and speed for movement.
-static Vector SetMovement (Ptr<ConstantVelocityMobilityModel> model, Vector lastPos, double at,
-                           double xFinalPosition, double yFinalPosition, double speed);
-
-// Set initial position for a node
-static Vector SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, string coord, double coordVal);
-
-// Schedule a set of position for a node
-static Vector SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, string coord, double coordVal);
-
-
-Ns2MobilityHelper::Ns2MobilityHelper (std::string filename)
-  : m_filename (filename)
-{
-}
-
-Ptr<ConstantVelocityMobilityModel>
-Ns2MobilityHelper::GetMobilityModel (std::string idString, const ObjectStore &store) const
-{
-  std::istringstream iss;
-  iss.str (idString);
-  uint32_t id (0);
-  iss >> id;
-  Ptr<Object> object = store.Get (id);
-  if (object == 0)
-    {
-      return 0;
-    }
-  Ptr<ConstantVelocityMobilityModel> model = object->GetObject<ConstantVelocityMobilityModel> ();
-  if (model == 0)
-    {
-      model = CreateObject<ConstantVelocityMobilityModel> ();
-      object->AggregateObject (model);
-    }
-  return model;
-}
-
-
-void
-Ns2MobilityHelper::ConfigNodesMovements (const ObjectStore &store) const
-{
-  map<int, Vector> last_pos;    // Vector containing lasts positions for each node
-
-  std::ifstream file (m_filename.c_str (), std::ios::in);
-  if (file.is_open ())
-    {
-      while (!file.eof () )
-        {
-          int         iNodeId = 0;
-          std::string nodeId;
-          std::string line;
-
-          getline (file, line);
-
-          // ignore empty lines
-          if (line.empty ())
-            {
-              continue;
-            }
-
-          ParseResult pr = ParseNs2Line (line); // Parse line and obtain tokens
-
-          // Check if the line corresponds with one of the three types of line
-          if (pr.tokens.size () != 4 && pr.tokens.size () != 7 && pr.tokens.size () != 8)
-            {
-              NS_LOG_ERROR ("Line has not correct number of parameters (corrupted file?): " << line << "\n");
-              continue;
-            }
-
-          // Get the node Id
-          nodeId  = GetNodeIdString (pr);
-          iNodeId = GetNodeIdInt (pr);
-          if (iNodeId == -1)
-            {
-        	  NS_LOG_ERROR ("Node number couldn't be obtained (corrupted file?): " << line << "\n");
-              continue;
-            }
-
-          // get mobility model of node
-          Ptr<ConstantVelocityMobilityModel> model = GetMobilityModel (nodeId,store);
-
-          // if model not exists, continue
-          if (model == 0)
-            {
-              NS_LOG_ERROR ("Unknown node ID (corrupted file?): " << nodeId << "\n");
-              continue;
-            }
-
-
-          /*
-           * In this case a initial position is being seted
-           * line like $node_(0) set X_ 151.05190721688197
-           */
-          if (IsSetInitialPos (pr))
-            {
-              //                                            coord         coord value
-              last_pos[iNodeId] = SetInitialPosition (model, pr.tokens[2], pr.dvals[3]);
-
-              // Log new position
-              NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
-                            " x=" << last_pos[iNodeId].x << " y=" << last_pos[iNodeId].y << " z=" << last_pos[iNodeId].z);
-            }
-
-          else // NOW EVENTS TO BE SCHEDULED
-            {
-
-              // This is a scheduled event, so time at should be present
-              double at;
-
-              if (!IsNumber (pr.tokens[2]))
-                {
-                  NS_LOG_WARN ("Time is not a number: " << pr.tokens[2]);
-                  continue;
-                }
-
-              at = pr.dvals[2]; // set time at
-
-              if ( at < 0 )
-                {
-                  NS_LOG_WARN ("Time is less than cero: " << at);
-                  continue;
-                }
-
-
-
-              /*
-               * In this case a new waypoint is added
-               * line like $ns_ at 1 "$node_(0) setdest 2 3 4"
-               */
-              if (IsSchedMobilityPos (pr))
-                {
-                  //                                     last position     time  X coord     Y coord      velocity
-                  last_pos[iNodeId] = SetMovement (model, last_pos[iNodeId], at, pr.dvals[5], pr.dvals[6], pr.dvals[7]);
-
-                  // Log new position
-                  NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
-                                " x=" << last_pos[iNodeId].x << " y=" << last_pos[iNodeId].y << " z=" << last_pos[iNodeId].z);
-                }
-
-
-              /*
-               * Scheduled set position
-               * line like $ns_ at 4.634906291962 "$node_(0) set X_ 28.675920486450"
-               */
-              else if (IsSchedSetPos (pr))
-                {
-                  //                                         time  coordinate   coord value
-                  last_pos[iNodeId] = SetSchedPosition (model, at, pr.tokens[5], pr.dvals[6]);
-
-                  // Log new position
-                  NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
-                                " x=" << last_pos[iNodeId].x << " y=" << last_pos[iNodeId].y << " z=" << last_pos[iNodeId].z);
-                }
-              else
-                {
-                  NS_LOG_WARN ("Format Line is not correct: " << line << "\n");
-                }
-            }
-        }
-      file.close ();
-    }
-}
-
-
-ParseResult
-ParseNs2Line (const string& str)
-{
-  ParseResult ret;
-  istringstream s;
-  string line;
-
-  // ignore comments (#)
-  size_t pos_sharp = str.find_first_of ('#');
-  if (pos_sharp != string::npos)
-    {
-      line = str.substr (0, pos_sharp);
-    }
-  else
-    {
-      line = str;
-    }
-
-  line = TrimNs2Line (line);
-
-  // If line hasn't a correct node Id
-  if (!HasNodeIdNumber (line))
-    {
-      NS_LOG_WARN ("Line has no node Id: " << line);
-      return ret;
-    }
-
-  s.str (line);
-
-  while (!s.eof ())
-    {
-      string x;
-      s >> x;
-      ret.tokens.push_back (x);
-      int ii (0);
-      double d (0);
-      if (HasNodeIdNumber (x))
-        {
-          x = GetNodeIdFromToken (x);
-        }
-      ret.has_ival.push_back (IsVal<int> (x, ii));
-      ret.ivals.push_back (ii);
-      ret.has_dval.push_back (IsVal<double> (x, d));
-      ret.dvals.push_back (d);
-      ret.svals.push_back (x);
-    }
-
-  size_t tokensLength   = ret.tokens.size ();                 // number of tokens in line
-  size_t lasTokenLength = ret.tokens[tokensLength - 1].size (); // length of the last token
-
-  // if it is a scheduled set _[XYZ] or a setdest I need to remove the last "
-  // and re-calculate values
-  if ( (tokensLength == 7 || tokensLength == 8)
-       && (ret.tokens[tokensLength - 1][lasTokenLength - 1] == '"') )
-    {
-
-      // removes " from the last position
-      ret.tokens[tokensLength - 1] = ret.tokens[tokensLength - 1].substr (0,lasTokenLength - 1);
-
-      string x;
-      x = ret.tokens[tokensLength - 1];
-
-      if (HasNodeIdNumber (x))
-        {
-          x = GetNodeIdFromToken (x);
-        }
-
-      // Re calculate values
-      int ii (0);
-      double d (0);
-      ret.has_ival[tokensLength - 1] = IsVal<int> (x, ii);
-      ret.ivals[tokensLength - 1] = ii;
-      ret.has_dval[tokensLength - 1] = IsVal<double> (x, d);
-      ret.dvals[tokensLength - 1] = d;
-      ret.svals[tokensLength - 1] = x;
-
-    }
-  else if ( (tokensLength == 9 && ret.tokens[tokensLength - 1] == "\"")
-            || (tokensLength == 8 && ret.tokens[tokensLength - 1] == "\""))
-    {
-      // if the line has the " character in this way: $ns_ at 1 "$node_(0) setdest 2 2 1  "
-      // or in this: $ns_ at 4 "$node_(0) set X_ 2  " we need to ignore this last token
-
-      ret.tokens.erase (ret.tokens.begin () + tokensLength - 1);
-      ret.has_ival.erase (ret.has_ival.begin () + tokensLength - 1);
-      ret.ivals.erase (ret.ivals.begin () + tokensLength - 1);
-      ret.has_dval.erase (ret.has_dval.begin () + tokensLength - 1);
-      ret.dvals.erase (ret.dvals.begin () + tokensLength - 1);
-      ret.svals.erase (ret.svals.begin () + tokensLength - 1);
-
-    }
-
-
-
-  return ret;
-}
-
-
-string
-TrimNs2Line (const string& s)
-{
-  string ret = s;
-
-  while (ret.size () > 0 && isblank (ret[0]))
-    {
-      ret.erase (0, 1);    // Removes blank spaces at the begining of the line
-    }
-
-  while (ret.size () > 0 && isblank (ret[ret.size () - 1]))
-    {
-      ret.erase (ret.size () - 1, 1); // Removes blank spaces from at end of line
-    }
-
-  return ret;
-}
-
-
-bool
-IsNumber (const string& s)
-{
-  char *endp;
-  double unused;
-  unused = strtod (s.c_str (), &endp); // declared with warn_unused_result
-  return endp == s.c_str () + s.size ();
-}
-
-
-template<class T>
-bool IsVal (const string& str, T& ret)
-{
-  if (str.size () == 0)
-    {
-      return false;
-    }
-  else if (IsNumber (str))
-    {
-      string s2 = str;
-      istringstream s (s2);
-      s >> ret;
-      return true;
-    }
-  else
-    {
-      return false;
-    }
-}
-
-
-bool
-HasNodeIdNumber (string str)
-{
-
-  // find brackets
-  std::string::size_type startNodeId = str.find_first_of ("("); // index of left bracket
-  std::string::size_type endNodeId   = str.find_first_of (")"); // index of right bracket
-
-  // Get de nodeId in a string and in a int value
-  std::string nodeId;     // node id
-
-  // if no brackets, continue!
-  if (startNodeId == std::string::npos || endNodeId == std::string::npos)
-    {
-      return false;
-    }
-
-  nodeId = str.substr (startNodeId + 1, endNodeId - (startNodeId + 1)); // set node id
-
-  //   is number              is integer                                       is not negative
-  if (IsNumber (nodeId) && (nodeId.find_first_of (".") == std::string::npos) && (nodeId[0] != '-'))
-    {
-      return true;
-    }
-  else
-    {
-      return false;
-    }
-}
-
-
-string
-GetNodeIdFromToken (string str)
-{
-  if (HasNodeIdNumber (str))
-    {
-      // find brackets
-      std::string::size_type startNodeId = str.find_first_of ("(");     // index of left bracket
-      std::string::size_type endNodeId   = str.find_first_of (")");     // index of right bracket
-
-      return str.substr (startNodeId + 1, endNodeId - (startNodeId + 1)); // set node id
-    }
-  else
-    {
-      return "";
-    }
-}
-
-
-int
-GetNodeIdInt (ParseResult pr)
-{
-  int result = -1;
-  switch (pr.tokens.size ())
-    {
-    case 4:   // line like $node_(0) set X_ 11
-      result = pr.ivals[0];
-      break;
-    case 7:   // line like $ns_ at 4 "$node_(0) set X_ 28"
-      result = pr.ivals[3];
-      break;
-    case 8:   // line like $ns_ at 1 "$node_(0) setdest 2 3 4"
-      result = pr.ivals[3];
-      break;
-    default:
-      result = -1;
-    }
-  return result;
-}
-
-// Get node id number in string format
-string
-GetNodeIdString (ParseResult pr)
-{
-  switch (pr.tokens.size ())
-    {
-    case 4:   // line like $node_(0) set X_ 11
-      return pr.svals[0];
-      break;
-    case 7:   // line like $ns_ at 4 "$node_(0) set X_ 28"
-      return pr.svals[3];
-      break;
-    case 8:   // line like $ns_ at 1 "$node_(0) setdest 2 3 4"
-      return pr.svals[3];
-      break;
-    default:
-      return "";
-    }
-}
-
-
-Vector
-SetOneInitialCoord (Vector position, string& coord, double value)
-{
-
-  // set the position for the coord.
-  if (coord == NS2_X_COORD)
-    {
-      position.x = value;
-      NS_LOG_DEBUG ("X=" << value);
-    }
-  else if (coord == NS2_Y_COORD)
-    {
-      position.y = value;
-      NS_LOG_DEBUG ("Y=" << value);
-    }
-  else if (coord == NS2_Z_COORD)
-    {
-      position.z = value;
-      NS_LOG_DEBUG ("Z=" << value);
-    }
-  return position;
-}
-
-
-bool
-IsSetInitialPos (ParseResult pr)
-{
-  //        number of tokens         has $node_( ?                        has "set"           has doble for position?
-  return pr.tokens.size () == 4 && HasNodeIdNumber (pr.tokens[0]) && pr.tokens[1] == NS2_SET && pr.has_dval[3]
-         // coord name is X_, Y_ or Z_ ?
-         && (pr.tokens[2] == NS2_X_COORD || pr.tokens[2] == NS2_Y_COORD || pr.tokens[2] == NS2_Z_COORD);
-
-}
-
-
-bool
-IsSchedSetPos (ParseResult pr)
-{
-  //      correct number of tokens,    has $ns_                   and at
-  return pr.tokens.size () == 7 && pr.tokens[0] == NS2_NS_SCH && pr.tokens[1] == NS2_AT
-         && pr.tokens[4] == NS2_SET && pr.has_dval[2] && pr.has_dval[3]   // has set and double value for time and nodeid
-         && ( pr.tokens[5] == NS2_X_COORD || pr.tokens[5] == NS2_Y_COORD || pr.tokens[5] == NS2_Z_COORD) // has X_, Y_ or Z_?
-         && pr.has_dval[2]; // time is a number
-}
-
-bool
-IsSchedMobilityPos (ParseResult pr)
-{
-  //     number of tokens      and    has $ns_                and    has at
-  return pr.tokens.size () == 8 && pr.tokens[0] == NS2_NS_SCH && pr.tokens[1] == NS2_AT
-         //    time             x coord          y coord          velocity are numbers?
-         && pr.has_dval[2] && pr.has_dval[5] && pr.has_dval[6] && pr.has_dval[7]
-         && pr.tokens[4] == NS2_SETDEST; // and has setdest
-
-}
-
-Vector
-SetMovement (Ptr<ConstantVelocityMobilityModel> model, Vector last_pos, double at,
-             double xFinalPosition, double yFinalPosition, double speed)
-{
-  Vector position;
-  position.x = last_pos.x;
-  position.y = last_pos.y;
-  position.z = last_pos.z;
-
-  if (speed == 0)
-    {
-      // We have to maintain last position, and stop the movement
-      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetVelocity, model,
-                           Vector (0, 0, 0));
-    }
-  else if (speed > 0)
-    {
-      // first calculate the time; time = distance / speed
-      double time = sqrt (pow (xFinalPosition - position.x, 2) + pow (yFinalPosition - position.y, 2)) / speed;
-      NS_LOG_DEBUG ("at=" << at << " time=" << time);
-      // now calculate the xSpeed = distance / time
-      double xSpeed = (xFinalPosition - position.x) / time;
-      double ySpeed = (yFinalPosition - position.y) / time; // & same with ySpeed
-
-      // quick and dirty set zSpeed = 0
-      double zSpeed = 0;
-
-      NS_LOG_DEBUG ("Calculated Speed: X=" << xSpeed << " Y=" << ySpeed << " Z=" << zSpeed);
-
-      // Set the Values
-      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetVelocity, model,
-                           Vector (xSpeed, ySpeed, zSpeed));
-
-      if (time >= 0)
-        {
-          Simulator::Schedule (Seconds (at + time), &ConstantVelocityMobilityModel::SetVelocity,
-                               model, Vector (0, 0, 0));
-        }
-
-      position.x = xFinalPosition;
-      position.y = yFinalPosition;
-      position.z = 0;
-    }
-
-  return position;
-}
-
-
-Vector
-SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, string coord, double coordVal)
-{
-  model->SetPosition (SetOneInitialCoord (model->GetPosition (), coord, coordVal));
-
-  Vector position;
-  position.x = model->GetPosition ().x;
-  position.y = model->GetPosition ().y;
-  position.z = model->GetPosition ().z;
-
-  return position;
-}
-
-// Schedule a set of position for a node
-Vector
-SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, string coord, double coordVal)
-{
-  // update position
-  model->SetPosition (SetOneInitialCoord (model->GetPosition (), coord, coordVal));
-
-  Vector position;
-  position.x = model->GetPosition ().x;
-  position.y = model->GetPosition ().y;
-  position.z = model->GetPosition ().z;
-
-  // Chedule next positions
-  Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetPosition, model,position);
-
-  return position;
-}
-
-void
-Ns2MobilityHelper::Install (void) const
-{
-  Install (NodeList::Begin (), NodeList::End ());
-}
-
-// -----------------------------------------------------------------------------
-// Testing
-// -----------------------------------------------------------------------------
-bool operator== (Vector const & a, Vector const & b)
-{
-  return (a.x == b.x && a.y == b.y && a.z == b.z);
-}
-/**
- * Every test case is supposed to:
- *  1. Generate short mobility trace file
- *  2. Read it back using Ns2MobilityHelper
- *  3. Check initial node positions and speeds.
- *  4. Run simulation listening for all CourseChange events and compare actual mobility with the reference
- */
-class Ns2MobilityHelperTest : public TestCase
-{
-public:
-  /// Single record in mobility reference
-  struct ReferencePoint
-  {
-    std::string node;       ///< node ID as string, e.g. "1"
-    Time time;              ///< timestamp
-    Vector pos;             ///< reference position
-    Vector vel;             ///< reference velocity
-
-    ReferencePoint (std::string const & id, Time t, Vector const & p, Vector const & v)
-      : node (id),
-        time (t),
-        pos (p),
-        vel (v)
-    {
-    }
-    /// Sort by timestamp
-    bool operator< (ReferencePoint const & o) const
-    {
-      return (time < o.time);
-    }
-  };
-  /**
-   * Create new test case. To make it useful SetTrace () and AddReferencePoint () must be called
-   *
-   * \param name        Short description
-   * \param nodes       Number of nodes used in the test trace, 1 by default
-   */
-  Ns2MobilityHelperTest (std::string const & name, Time timeLimit, uint32_t nodes = 1)
-    : TestCase (name),
-      m_timeLimit (timeLimit),
-      m_nodeCount (nodes),
-      m_nextRefPoint (0)
-  {
-  }
-  /// Empty
-  virtual ~Ns2MobilityHelperTest ()
-  {
-  }
-  /// Set NS-2 trace to read as single large string (don't forget to add \n and quote ")
-  void SetTrace (std::string const & trace)
-  {
-    m_trace = trace;
-  }
-  /// Add next reference point
-  void AddReferencePoint (ReferencePoint const & r)
-  {
-    m_reference.push_back (r);
-  }
-  /// Sugar
-  void AddReferencePoint (const char * id, double sec, Vector const & p, Vector const & v)
-  {
-    AddReferencePoint (ReferencePoint (id, Seconds (sec), p, v));
-  }
-
-private:
-  /// Test time limit
-  Time m_timeLimit;
-  /// Number of nodes used in the test
-  uint32_t m_nodeCount;
-  /// Trace as string
-  std::string m_trace;
-  /// Reference mobility
-  std::vector<ReferencePoint> m_reference;
-  /// Next reference point to be checked
-  size_t m_nextRefPoint;
-  /// TMP trace file name
-  std::string m_traceFile;
-
-private:
-  /// Dump NS-2 trace to tmp file
-  bool WriteTrace ()
-  {
-    m_traceFile = GetTempDir () + "Ns2MobilityHelperTest.tcl";
-    std::ofstream of (m_traceFile.c_str ());
-    NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (of.is_open (), true, "Need to write tmp. file");
-    of << m_trace;
-    of.close ();
-    return false; // no errors
-  }
-  /// Create and name nodes
-  void CreateNodes ()
-  {
-    NodeContainer nodes;
-    nodes.Create (m_nodeCount);
-    for (uint32_t i = 0; i < m_nodeCount; ++i)
-      {
-        std::ostringstream os;
-        os << i;
-        Names::Add (os.str (), nodes.Get (i));
-      }
-  }
-  /// Check that all initial positions are correct
-  bool CheckInitialPositions ()
-  {
-    std::stable_sort (m_reference.begin (), m_reference.end ());
-    while (m_nextRefPoint < m_reference.size () && m_reference[m_nextRefPoint].time == Seconds (0))
-      {
-        ReferencePoint const & rp = m_reference[m_nextRefPoint];
-        Ptr<Node> node = Names::Find<Node> (rp.node);
-        NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (node, 0, "Can't find node with id " << rp.node);
-        Ptr<MobilityModel> mob = node->GetObject<MobilityModel> ();
-        NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (mob, 0, "Can't find mobility for node " << rp.node);
-
-        NS_TEST_EXPECT_MSG_EQ (rp.pos, mob->GetPosition (), "Initial position mismatch for node " << rp.node);
-        NS_TEST_EXPECT_MSG_EQ (rp.vel, mob->GetVelocity (), "Initial velocity mismatch for node " << rp.node);
-
-        m_nextRefPoint++;
-      }
-    return GetErrorStatus ();
-  }
-  /// Listen for course change events
-  void CourseChange (std::string context, Ptr<const MobilityModel> mobility)
-  {
-    Time time = Simulator::Now ();
-    Ptr<Node> node = mobility->GetObject<Node> ();
-    NS_ASSERT (node);
-    std::string id = Names::FindName (node);
-    NS_ASSERT (!id.empty ());
-    Vector pos = mobility->GetPosition ();
-    Vector vel = mobility->GetVelocity ();
-
-    NS_TEST_EXPECT_MSG_LT (m_nextRefPoint, m_reference.size (), "Not enough reference points");
-    if (m_nextRefPoint >= m_reference.size ())
-      {
-        return;
-      }
-
-    ReferencePoint const & ref = m_reference [m_nextRefPoint++];
-    NS_TEST_EXPECT_MSG_EQ (time, ref.time, "Time mismatch");
-    NS_TEST_EXPECT_MSG_EQ (id, ref.node, "Node ID mismatch at time " << time.GetSeconds () << " s");
-    NS_TEST_EXPECT_MSG_EQ (pos, ref.pos, "Position mismatch at time " << time.GetSeconds () << " s for node " << id);
-    NS_TEST_EXPECT_MSG_EQ (vel, ref.vel, "Velocity mismatch at time " << time.GetSeconds () << " s for node " << id);
-  }
-  /// Go
-  void DoRun ()
-  {
-    NS_TEST_ASSERT_MSG_EQ (m_trace.empty (), false, "Need trace");
-    NS_TEST_ASSERT_MSG_EQ (m_reference.empty (), false, "Need reference");
-
-    if (WriteTrace ())
-      {
-        return;
-      }
-    CreateNodes ();
-    Ns2MobilityHelper mobility (m_traceFile);
-    mobility.Install ();
-    if (CheckInitialPositions ())
-      {
-        return;
-      }
-    Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
-                     MakeCallback (&Ns2MobilityHelperTest::CourseChange, this));
-    Simulator::Stop (m_timeLimit);
-    Simulator::Run ();
-    Names::Clear ();
-    std::remove (m_traceFile.c_str ());
-    Simulator::Destroy ();
-  }
-};
-
-/// The test suite
-class Ns2MobilityHelperTestSuite : public TestSuite
-{
-public:
-  Ns2MobilityHelperTestSuite () : TestSuite ("mobility-ns2-trace-helper", UNIT)
-  {
-    // to be used as temporary variable for test cases.
-    // Note that test suite takes care of deleting all test cases.
-    Ns2MobilityHelperTest * t (0);
-
-    // Initial position
-    t = new Ns2MobilityHelperTest ("initial position", Seconds (1));
-    t->SetTrace ("$node_(0) set X_ 1.0\n"
-                 "$node_(0) set Y_ 2.0\n"
-                 "$node_(0) set Z_ 3.0\n"
-                 );
-    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // Check parsing comments, empty lines and no EOF at the end of file
-    t = new Ns2MobilityHelperTest ("comments", Seconds (1));
-    t->SetTrace ("# comment\n"
-                 "\n\n" // empty lines
-                 "$node_(0) set X_ 1.0 # comment \n"
-                 "$node_(0) set Y_ 2.0 ### \n"
-                 "$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n"
-                 "#$node_(0) set Z_ 100 #"
-                 );
-    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // Simple setdest. Arguments are interpreted as x, y, speed by default
-    t = new Ns2MobilityHelperTest ("simple setdest", Seconds (10));
-    t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
-    t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // Several set and setdest. Arguments are interpreted as x, y, speed by default
-    t = new Ns2MobilityHelperTest ("square setdest", Seconds (6));
-    t->SetTrace ("$node_(0) set X_ 0.0\n"
-                 "$node_(0) set Y_ 0.0\n"
-                 "$ns_ at 1.0 \"$node_(0) setdest 5  0  5\"\n"
-                 "$ns_ at 2.0 \"$node_(0) setdest 5  5  5\"\n"
-                 "$ns_ at 3.0 \"$node_(0) setdest 0  5  5\"\n"
-                 "$ns_ at 4.0 \"$node_(0) setdest 0  0  5\"\n"
-                 );
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5,  0, 0));
-    t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0,  5, 0));
-    t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
-    t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, -5, 0));
-    t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0,  0, 0));
-    AddTestCase (t);
-
-    // Scheduled set position
-    t = new Ns2MobilityHelperTest ("scheduled set position", Seconds (2));
-    t->SetTrace ("$ns_ at 1.0 \"$node_(0) set X_ 10\"\n"
-                 "$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n"
-                 "$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 1, Vector (10, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (10, 0, 10), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (10, 10, 10), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // Malformed lines
-    t = new Ns2MobilityHelperTest ("malformed lines", Seconds (2));
-    t->SetTrace ("$node() set X_ 1 # node id is not present\n"
-                 "$node # incoplete line\"\n"
-                 "$node this line is not correct\n"
-                 "$node_(0) set X_ 1 # line OK \n"
-                 "$node_(0) set Y_ 2 # line OK \n"
-                 "$node_(0) set Z_ 3 # line OK \n"
-                 "$ns_ at  \"$node_(0) setdest 4 4 4\" # time not present\n"
-                 "$ns_ at 1 \"$node_(0) setdest 2 2 1   \" # line OK \n");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
-    t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // Non possible values
-    t = new Ns2MobilityHelperTest ("non possible values", Seconds (2));
-    t->SetTrace ("$node_(0) set X_ 1 # line OK \n"
-                 "$node_(0) set Y_ 2 # line OK \n"
-                 "$node_(0) set Z_ 3 # line OK \n"
-                 "$node_(-22) set Y_ 3 # node id not correct\n"
-                 "$node_(3.3) set Y_ 1111 # node id not correct\n"
-                 "$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n"
-                 "$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n"
-                 "$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n"
-                 "$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\"    # speed is not a number\n"
-                 "$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n"
-                 "$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\"   # more than one non numbers\n"
-                 "$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
-    t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // More than one node
-    t = new Ns2MobilityHelperTest ("few nodes, combinations of set and setdest", Seconds (10), 3);
-    t->SetTrace ("$node_(0) set X_ 1.0\n"
-                 "$node_(0) set Y_ 2.0\n"
-                 "$node_(0) set Z_ 3.0\n"
-                 "$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n"
-                 "$node_(2) set X_ 0.0\n"
-                 "$node_(2) set Y_ 0.0\n"
-                 "$ns_ at 1.0 \"$node_(2) setdest 5  0  5\"\n"
-                 "$ns_ at 2.0 \"$node_(2) setdest 5  5  5\"\n"
-                 "$ns_ at 3.0 \"$node_(2) setdest 0  5  5\"\n"
-                 "$ns_ at 4.0 \"$node_(2) setdest 0  0  5\"\n");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
-    t->AddReferencePoint ("1", 0, Vector (0, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("1", 1, Vector (0, 0, 0), Vector (5, 0, 0));
-    t->AddReferencePoint ("1", 6, Vector (25, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("2", 0, Vector (0, 0, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("2", 1, Vector (0, 0, 0), Vector (5,  0, 0));
-    t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0,  5, 0));
-    t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
-    t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, -5, 0));
-    t->AddReferencePoint ("2", 5, Vector (0, 0, 0), Vector (0,  0, 0));
-    AddTestCase (t);
-
-    // Test for Speed == 0, that acts as stop the node.
-    t = new Ns2MobilityHelperTest ("setdest with speed cero", Seconds (10));
-    t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n"
-                 "$ns_ at 7.0 \"$node_(0) setdest 11  22  0\"\n");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
-    t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 7, Vector (25, 0, 0), Vector (0, 0, 0));
-    AddTestCase (t);
-
-
-    // Test negative positions
-    t = new Ns2MobilityHelperTest ("test negative positions", Seconds (10));
-    t->SetTrace ("$node_(0) set X_ -1.0\n"
-                 "$node_(0) set Y_ 0\n"
-                 "$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n"
-                 "$ns_ at 2.0 \"$node_(0) setdest 0  -1  1\"\n");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (-1, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 1, Vector (-1, 0, 0), Vector (1, 0, 0));
-    t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, -1, 0));
-    t->AddReferencePoint ("0", 3, Vector (0, -1, 0), Vector (0, 0, 0));
-    AddTestCase (t);
-
-    // Sqare setdest with values in the form 1.0e+2
-    t = new Ns2MobilityHelperTest ("Foalt numbers in 1.0e+2 format", Seconds (6));
-    t->SetTrace ("$node_(0) set X_ 0.0\n"
-                 "$node_(0) set Y_ 0.0\n"
-                 "$ns_ at 1.0 \"$node_(0) setdest 1.0e+2  0       1.0e+2\"\n"
-                 "$ns_ at 2.0 \"$node_(0) setdest 1.0e+2  1.0e+2  1.0e+2\"\n"
-                 "$ns_ at 3.0 \"$node_(0) setdest 0       1.0e+2  1.0e+2\"\n"
-                 "$ns_ at 4.0 \"$node_(0) setdest 0       0       1.0e+2\"\n");
-    //                     id  t  position         velocity
-    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (100,  0, 0));
-    t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0,  100, 0));
-    t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (0,  0, 0));
-    t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (-100, 0, 0));
-    t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, 0, 0));
-    t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, -100, 0));
-    t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0,  0, 0));
-    AddTestCase (t);
-
-  }
-} g_ns2TransmobilityHelperTestSuite;
-
-
-} // namespace ns3
--- a/src/helper/ns2-mobility-helper.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *               2009,2010 Contributors
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- * Contributors: Thomas Waldecker <twaldecker@rocketmail.com>
- *               Martín Giachino <martin.giachino@gmail.com>
- */
-#ifndef NS2_MOBILITY_HELPER_H
-#define NS2_MOBILITY_HELPER_H
-
-#include <string>
-#include <stdint.h>
-#include "ns3/ptr.h"
-#include "ns3/object.h"
-
-namespace ns3 {
-
-class ConstantVelocityMobilityModel;
-
-/**
- * \ingroup mobility
- * \brief Helper class which can read ns-2 movement files and configure nodes mobility.
- * 
- * This implementation is based on the ns2 movement documentation of ns2
- * as described in http://www.isi.edu/nsnam/ns/doc/node174.html
- *
- * Valid trace files use the following ns2 statements:
- \verbatim
-   $node set X_ x1
-   $node set Y_ y1
-   $node set Z_ z1
-   $ns at $time $node setdest x2 y2 speed
-   $ns at $time $node set X_ x1
-   $ns at $time $node set Y_ Y1
-   $ns at $time $node set Z_ Z1
- \endverbatim
- *
- * Following tools are known to support this format:
- *  - BonnMotion http://net.cs.uni-bonn.de/wg/cs/applications/bonnmotion/
- *  - SUMO http://sourceforge.net/apps/mediawiki/sumo/index.php?title=Main_Page
- *  - TraNS http://trans.epfl.ch/ 
- *  
- *  See usage example in examples/mobility/ns2-mobility-trace.cc
- */
-class Ns2MobilityHelper
-{
-public:
-  /**
-   * \param filename filename of file which contains the
-   *        ns2 movement trace.
-   */
-  Ns2MobilityHelper (std::string filename);
-
-  /**
-   * Read the ns2 trace file and configure the movement
-   * patterns of all nodes contained in the global ns3::NodeList
-   * whose nodeId is matches the nodeId of the nodes in the trace
-   * file.
-   */
-  void Install (void) const;
-
-  /**
-   * \param begin an iterator which points to the start of the input
-   *        object array.
-   * \param end an iterator which points to the end of the input
-   *        object array.
-   *
-   * Read the ns2 trace file and configure the movement
-   * patterns of all input objects. Each input object
-   * is identified by a unique node id which reflects
-   * the index of the object in the input array.
-   */
-  template <typename T>
-  void Install (T begin, T end) const;
-private:
-  class ObjectStore
-  {
-  public:
-    virtual ~ObjectStore () {}
-    virtual Ptr<Object> Get (uint32_t i) const = 0;
-  };
-  void ConfigNodesMovements (const ObjectStore &store) const;
-  Ptr<ConstantVelocityMobilityModel> GetMobilityModel (std::string idString, const ObjectStore &store) const;
-  std::string m_filename;
-};
-
-} // namespace ns3
-
-namespace ns3 {
-
-template <typename T>
-void 
-Ns2MobilityHelper::Install (T begin, T end) const
-{
-  class MyObjectStore : public ObjectStore
-  {
-  public:
-    MyObjectStore (T begin, T end)
-      : m_begin (begin),
-      m_end (end)
-        {}
-    virtual Ptr<Object> Get (uint32_t i) const {
-      T iterator = m_begin;
-      iterator += i;
-      if (iterator >= m_end)
-        {
-          return 0;
-        }
-      return *iterator;
-    }
-  private:
-    T m_begin;
-    T m_end;
-  };
-  ConfigNodesMovements (MyObjectStore (begin, end));
-}
-
-
-} // namespace ns3
-
-#endif /* NS2_MOBILITY_HELPER_H */
--- a/src/helper/wscript	Fri Feb 25 15:27:30 2011 -0800
+++ b/src/helper/wscript	Fri Feb 25 16:06:17 2011 -0800
@@ -6,8 +6,6 @@
         'wifi-helper.cc',
         'point-to-point-helper.cc',
         'csma-helper.cc',
-        'mobility-helper.cc',
-        'ns2-mobility-helper.cc',
         'on-off-helper.cc',
         'packet-sink-helper.cc',
         'udp-echo-helper.cc',
@@ -40,8 +38,6 @@
         'wifi-helper.h',
         'point-to-point-helper.h',
         'csma-helper.h',
-        'mobility-helper.h',
-        'ns2-mobility-helper.h',
         'on-off-helper.h',
         'packet-sink-helper.h',
         'udp-echo-helper.h',
--- a/src/mobility/box.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Dan Broyles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Dan Broyles <dbroyl01@ku.edu>
- */
-
-#include "box.h"
-#include "ns3/vector.h"
-#include "ns3/assert.h"
-#include "ns3/fatal-error.h"
-#include <cmath>
-#include <algorithm>
-#include <sstream> 
-
-namespace ns3 {
-
-Box::Box (double _xMin, double _xMax,
-          double _yMin, double _yMax,
-          double _zMin, double _zMax)
-  : xMin (_xMin),
-    xMax (_xMax),
-    yMin (_yMin),
-    yMax (_yMax),
-    zMin (_zMin),
-    zMax (_zMax)
-{}
-
-Box::Box ()
-  : xMin (0.0),
-    xMax (0.0),
-    yMin (0.0),
-    yMax (0.0),
-    zMin (0.0),
-    zMax (0.0)
-{}
-
-bool 
-Box::IsInside (const Vector &position) const
-{
-  return 
-    position.x <= this->xMax && position.x >= this->xMin &&
-    position.y <= this->yMax && position.y >= this->yMin &&
-    position.z <= this->zMax && position.z >= this->zMin;
-}
-
-Box::Side 
-Box::GetClosestSide (const Vector &position) const
-{
-  double xMinDist = std::abs (position.x - this->xMin);
-  double xMaxDist = std::abs (this->xMax - position.x);
-  double yMinDist = std::abs (position.y - this->yMin);
-  double yMaxDist = std::abs (this->yMax - position.y);
-  double zMinDist = std::abs (position.z - this->zMin);
-  double zMaxDist = std::abs (this->zMax - position.z);
-  double minX = std::min (xMinDist, xMaxDist);
-  double minY = std::min (yMinDist, yMaxDist);
-  double minZ = std::min (zMinDist, zMaxDist);
-  if (minX < minY && minX < minZ)
-    {
-      if (xMinDist < xMaxDist)
-        {
-          return LEFT;
-        }
-      else
-        {
-          return RIGHT;
-        }
-    }
-  else if (minY < minZ)
-    {
-      if (yMinDist < yMaxDist)
-        {
-          return BOTTOM;
-        }
-      else
-        {
-          return TOP;
-        }
-    }
-  else
-    {
-      if (zMinDist < zMaxDist)
-        {
-          return DOWN;
-        }
-      else
-        {
-          return UP;
-        }
-    }
-}
-
-Vector
-Box::CalculateIntersection (const Vector &current, const Vector &speed) const
-{
-  NS_ASSERT (IsInside (current));
-  double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
-  double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y;
-  double yMaxX = current.x + (this->yMax - current.y) / speed.y * speed.x;
-  double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x;
-  bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin);
-  bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin);
-  bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin);
-  bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin);
-  if (xMaxYOk && speed.x >= 0)
-    {
-      return Vector (this->xMax, xMaxY, 0.0);
-    }
-  else if (xMinYOk && speed.x <= 0)
-    {
-      return Vector (this->xMin, xMinY, 0.0);
-    }
-  else if (yMaxXOk && speed.y >= 0)
-    {
-      return Vector (yMaxX, this->yMax, 0.0);
-    }
-  else if (yMinXOk && speed.y <= 0)
-    {
-      return Vector (yMinX, this->yMin, 0.0);
-    }
-  else
-    {
-      NS_ASSERT (false);
-      // quiet compiler
-      return Vector (0.0, 0.0, 0.0);
-    }
-
-}
-
-ATTRIBUTE_HELPER_CPP (Box);
-
-std::ostream &
-operator << (std::ostream &os, const Box &box)
-{
-  os << box.xMin << "|" << box.xMax << "|" << box.yMin << "|" << box.yMax << "|" << box.zMin << "|" << box.zMax;
-  return os;
-}
-std::istream &
-operator >> (std::istream &is, Box &box)
- {
-  char c1, c2, c3, c4, c5;
-  is >> box.xMin >> c1 >> box.xMax >> c2 >> box.yMin >> c3 >> box.yMax >> c4 >> box.zMin >> c5 >> box.zMax;
-  if (c1 != '|' ||
-      c2 != '|' ||
-      c3 != '|' ||
-      c4 != '|' ||
-      c5 != '|')
-    {
-      is.setstate (std::ios_base::failbit);
-    }
-  return is;
-}
-
-
-} // namespace ns3
--- a/src/mobility/box.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Dan Broyles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Dan Broyles <dbroyl01@ku.edu>
- */
-#ifndef BOX_H
-#define BOX_H
-
-#include "ns3/attribute.h"
-#include "ns3/attribute-helper.h"
-#include "ns3/vector.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief a 3d box
- */
-class Box
-{
-public:
-  enum Side {
-    RIGHT,
-    LEFT,
-    TOP,
-    BOTTOM,
-    UP,
-    DOWN
-  };
-  /**
-   * \param _xMin x coordinates of left boundary.
-   * \param _xMax x coordinates of right boundary.
-   * \param _yMin y coordinates of bottom boundary.
-   * \param _yMax y coordinates of top boundary.
-   * \param _zMin z coordinates of down boundary.
-   * \param _zMax z coordinates of up boundary.
-   *
-   * Create a box.
-   */
-  Box (double _xMin, double _xMax,
-       double _yMin, double _yMax,
-       double _zMin, double _zMax);
-  /**
-   * Create a zero-sized box located at coordinates (0.0,0.0,0.0)
-   */
-  Box ();
-  /**
-   * \param position the position to test.
-   * \returns true if the input position is located within the box, 
-   *          false otherwise.
-   *
-   * This method compares the x, y, and z coordinates of the input position.
-   */
-  bool IsInside (const Vector &position) const;
-  /**
-   * \param position the position to test.
-   * \returns the side of the cube the input position is closest to.
-   *
-   * This method compares the x, y, and z coordinates of the input position.
-   */
-  Side GetClosestSide (const Vector &position) const;
-  /**
-   * \param current the current position
-   * \param speed the current speed
-   * \returns the intersection point between the rectangle and the current+speed vector.
-   *
-   * This method assumes that the current position is located _inside_
-   * the cube and checks for this with an assert.
-   * This method compares only the x and y coordinates of the input position
-   * and speed. It ignores the z coordinate.
-   */
-  Vector CalculateIntersection (const Vector &current, const Vector &speed) const;
-
-  /* The x coordinate of the left bound of the box */
-  double xMin;
-  /* The x coordinate of the right bound of the box */
-  double xMax;
-  /* The y coordinate of the bottom bound of the box */
-  double yMin;
-  /* The y coordinate of the top bound of the box */
-  double yMax;
-  /* The z coordinate of the down bound of the box */
-  double zMin;
-  /* The z coordinate of the up bound of the box */
-  double zMax;
-};
-
-std::ostream &operator << (std::ostream &os, const Box &box);
-std::istream &operator >> (std::istream &is, Box &box);
-
-/**
- * \class ns3::BoxValue
- * \brief hold objects of type ns3::Box
- */
-
-ATTRIBUTE_HELPER_HEADER (Box);
-
-} // namespace ns3
-
-#endif /* BOX_H */
--- a/src/mobility/constant-acceleration-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Gustavo Carneiro  <gjc@inescporto.pt>
- */
-#include "constant-acceleration-mobility-model.h"
-#include "ns3/simulator.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (ConstantAccelerationMobilityModel);
-
-TypeId ConstantAccelerationMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ConstantAccelerationMobilityModel")
-    .SetParent<MobilityModel> ()
-    .AddConstructor<ConstantAccelerationMobilityModel> ();
-  return tid;
-}
-
-ConstantAccelerationMobilityModel::ConstantAccelerationMobilityModel ()
-{}
-
-ConstantAccelerationMobilityModel::~ConstantAccelerationMobilityModel ()
-{}
-
-inline Vector
-ConstantAccelerationMobilityModel::DoGetVelocity (void) const
-{
-  double t = (Simulator::Now () - m_baseTime).GetSeconds ();
-  return Vector (m_baseVelocity.x + m_acceleration.x*t,
-                 m_baseVelocity.y + m_acceleration.y*t,
-                 m_baseVelocity.z + m_acceleration.z*t);
-}
-
-inline Vector
-ConstantAccelerationMobilityModel::DoGetPosition (void) const
-{
-  double t = (Simulator::Now () - m_baseTime).GetSeconds ();
-  double half_t_square = t*t*0.5;
-  return Vector (m_basePosition.x + m_baseVelocity.x*t + m_acceleration.x*half_t_square,
-                 m_basePosition.y + m_baseVelocity.y*t + m_acceleration.y*half_t_square,
-                 m_basePosition.z + m_baseVelocity.z*t + m_acceleration.z*half_t_square);
-}
-
-void 
-ConstantAccelerationMobilityModel::DoSetPosition (const Vector &position)
-{
-  m_baseVelocity = DoGetVelocity ();
-  m_baseTime = Simulator::Now ();
-  m_basePosition = position;
-  NotifyCourseChange ();
-}
-
-void 
-ConstantAccelerationMobilityModel::SetVelocityAndAcceleration (const Vector &velocity,
-                                                               const Vector &acceleration)
-{
-  m_basePosition = DoGetPosition ();
-  m_baseTime = Simulator::Now ();
-  m_baseVelocity = velocity;
-  m_acceleration = acceleration;
-  NotifyCourseChange ();
-}
-
-
-}; // namespace ns3
--- a/src/mobility/constant-acceleration-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Gustavo Carneiro  <gjc@inescporto.pt>
- */
-#ifndef CONSTANT_ACCELERATION_MOBILITY_MODEL_H
-#define CONSTANT_ACCELERATION_MOBILITY_MODEL_H
-
-#include "mobility-model.h"
-#include "ns3/nstime.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- *
- * \brief Mobility model for which the current acceleration does not change once it has been set and until it is set again explicitely to a new value.
- */
-class ConstantAccelerationMobilityModel : public MobilityModel 
-{
-public:
-  static TypeId GetTypeId (void);
-  /**
-   * Create position located at coordinates (0,0,0) with
-   * speed (0,0,0).
-   */
-  ConstantAccelerationMobilityModel ();
-  virtual ~ConstantAccelerationMobilityModel ();
-  void SetVelocityAndAcceleration (const Vector &velocity, const Vector &acceleration);
-
-private:
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  Time m_baseTime;
-  Vector m_basePosition;
-  Vector m_baseVelocity;
-  Vector m_acceleration;
-};
-
-}; // namespace ns3
-
-#endif /* CONSTANT_ACCELERATION_MOBILITY_MODEL_H */
--- a/src/mobility/constant-position-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "constant-position-mobility-model.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (ConstantPositionMobilityModel);
-
-TypeId
-ConstantPositionMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ConstantPositionMobilityModel")
-    .SetParent<MobilityModel> ()
-    .AddConstructor<ConstantPositionMobilityModel> ()
-    ;
-  return tid;
-}
-  
-ConstantPositionMobilityModel::ConstantPositionMobilityModel ()
-{}
-ConstantPositionMobilityModel::~ConstantPositionMobilityModel ()
-{}
-
-Vector
-ConstantPositionMobilityModel::DoGetPosition (void) const
-{
-  return m_position;
-}
-void 
-ConstantPositionMobilityModel::DoSetPosition (const Vector &position)
-{
-  m_position = position;
-  NotifyCourseChange ();
-}
-Vector
-ConstantPositionMobilityModel::DoGetVelocity (void) const
-{
-  return Vector (0.0, 0.0, 0.0);
-}
-
-}; // namespace ns3
--- a/src/mobility/constant-position-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef CONSTANT_POSITION_MOBILITY_MODEL_H
-#define CONSTANT_POSITION_MOBILITY_MODEL_H
-
-#include "mobility-model.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- *
- * \brief Mobility model for which the current position does not change once it has been set and until it is set again explicitely to a new value.
- */
-class ConstantPositionMobilityModel : public MobilityModel 
-{
-public:
-  static TypeId GetTypeId (void);
-  /**
-   * Create a position located at coordinates (0,0,0)
-   */
-  ConstantPositionMobilityModel ();
-  virtual ~ConstantPositionMobilityModel ();
-
-private:
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  Vector m_position;
-};
-
-}; // namespace ns3
-
-#endif /* CONSTANT_POSITION_MOBILITY_MODEL_H */
--- a/src/mobility/constant-velocity-helper.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "ns3/simulator.h"
-#include "ns3/rectangle.h"
-#include "ns3/box.h"
-#include "constant-velocity-helper.h"
-
-namespace ns3 {
-
-ConstantVelocityHelper::ConstantVelocityHelper ()
-  : m_paused (true)
-{}
-ConstantVelocityHelper::ConstantVelocityHelper (const Vector &position)
-  : m_position (position),
-    m_paused (true)
-{}
-ConstantVelocityHelper::ConstantVelocityHelper (const Vector &position,
-				      const Vector &vel)
-  : m_position (position),
-    m_velocity (vel),
-    m_paused (true)
-{}
-void 
-ConstantVelocityHelper::SetPosition (const Vector &position)
-{
-  m_position = position;
-  m_velocity = Vector (0.0, 0.0, 0.0);
-  m_lastUpdate = Simulator::Now ();
-}
-
-Vector
-ConstantVelocityHelper::GetCurrentPosition (void) const
-{
-  return m_position;
-}
-
-Vector 
-ConstantVelocityHelper::GetVelocity (void) const
-{
-  return m_paused? Vector (0.0, 0.0, 0.0) : m_velocity;
-}
-void 
-ConstantVelocityHelper::SetVelocity (const Vector &vel)
-{
-  m_velocity = vel;
-  m_lastUpdate = Simulator::Now ();
-}
-
-void
-ConstantVelocityHelper::Update (void) const
-{
-  Time now = Simulator::Now ();
-  NS_ASSERT (m_lastUpdate <= now);
-  Time deltaTime = now - m_lastUpdate;
-  m_lastUpdate = now;
-  if (m_paused)
-    {
-      return;
-    }
-  double deltaS = deltaTime.GetSeconds ();
-  m_position.x += m_velocity.x * deltaS;
-  m_position.y += m_velocity.y * deltaS;
-  m_position.z += m_velocity.z * deltaS;
-}
-
-void
-ConstantVelocityHelper::UpdateWithBounds (const Rectangle &bounds) const
-{
-  Update ();
-  m_position.x = std::min (bounds.xMax, m_position.x);
-  m_position.x = std::max (bounds.xMin, m_position.x);
-  m_position.y = std::min (bounds.yMax, m_position.y);
-  m_position.y = std::max (bounds.yMin, m_position.y);
-}
-
-void
-ConstantVelocityHelper::UpdateWithBounds (const Box &bounds) const
-{
-  Update ();
-  m_position.x = std::min (bounds.xMax, m_position.x);
-  m_position.x = std::max (bounds.xMin, m_position.x);
-  m_position.y = std::min (bounds.yMax, m_position.y);
-  m_position.y = std::max (bounds.yMin, m_position.y);
-  m_position.z = std::min (bounds.zMax, m_position.z);
-  m_position.z = std::max (bounds.zMin, m_position.z);
-}
-
-void 
-ConstantVelocityHelper::Pause (void)
-{
-  m_paused = true;
-}
-
-void 
-ConstantVelocityHelper::Unpause (void)
-{
-  m_paused = false;
-}
-
-} // namespace ns3
--- a/src/mobility/constant-velocity-helper.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef CONSTANT_VELOCITY_HELPER_H
-#define CONSTANT_VELOCITY_HELPER_H
-
-#include "ns3/nstime.h"
-#include "ns3/vector.h"
-#include "ns3/box.h"
-
-namespace ns3 {
-
-class Rectangle;
-
-/**
- * \ingroup mobility
- *
- * \brief Utility class used to move node with constant velocity.
- */
-class ConstantVelocityHelper
-{
- public:
-  ConstantVelocityHelper ();
-  ConstantVelocityHelper (const Vector &position);
-  ConstantVelocityHelper (const Vector &position,
-		     const Vector &vel);
-
-  void SetPosition (const Vector &position);
-  Vector GetCurrentPosition (void) const;
-  Vector GetVelocity (void) const;
-  void SetVelocity (const Vector &vel);
-  void Pause (void);
-  void Unpause (void);
-
-  void UpdateWithBounds (const Rectangle &rectangle) const;
-  void UpdateWithBounds (const Box &bounds) const;
-  void Update (void) const;
- private:
-  mutable Time m_lastUpdate;
-  mutable Vector m_position;
-  Vector m_velocity;
-  bool m_paused;
-};
-
-} // namespace ns3
-
-#endif /* CONSTANT_VELOCITY_HELPER_H */
--- a/src/mobility/constant-velocity-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006, 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "constant-velocity-mobility-model.h"
-#include "ns3/simulator.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (ConstantVelocityMobilityModel);
-
-TypeId ConstantVelocityMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ConstantVelocityMobilityModel")
-    .SetParent<MobilityModel> ()
-    .AddConstructor<ConstantVelocityMobilityModel> ();
-  return tid;
-}
-
-ConstantVelocityMobilityModel::ConstantVelocityMobilityModel ()
-{}
-
-ConstantVelocityMobilityModel::~ConstantVelocityMobilityModel ()
-{}
-
-void 
-ConstantVelocityMobilityModel::SetVelocity (const Vector &speed)
-{
-  m_helper.Update ();
-  m_helper.SetVelocity (speed);
-  m_helper.Unpause ();
-  NotifyCourseChange ();
-}
-
-
-Vector
-ConstantVelocityMobilityModel::DoGetPosition (void) const
-{
-  m_helper.Update ();
-  return m_helper.GetCurrentPosition ();
-}
-void 
-ConstantVelocityMobilityModel::DoSetPosition (const Vector &position)
-{
-  m_helper.SetPosition (position);
-  NotifyCourseChange ();
-}
-Vector
-ConstantVelocityMobilityModel::DoGetVelocity (void) const
-{
-  return m_helper.GetVelocity ();
-}
-
-}; // namespace ns3
--- a/src/mobility/constant-velocity-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006, 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef CONSTANT_VELOCITY_MOBILITY_MODEL_H
-#define CONSTANT_VELOCITY_MOBILITY_MODEL_H
-
-#include <stdint.h>
-#include "ns3/nstime.h"
-#include "mobility-model.h"
-#include "constant-velocity-helper.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- *
- * \brief Mobility model for which the current speed does not change once it has been set and until it is set again explicitely to a new value.
- */
-class ConstantVelocityMobilityModel : public MobilityModel 
-{
-public:
-  static TypeId GetTypeId (void);
-  /**
-   * Create position located at coordinates (0,0,0) with
-   * speed (0,0,0).
-   */
-  ConstantVelocityMobilityModel ();
-  virtual ~ConstantVelocityMobilityModel ();
-
-  /**
-   * \param speed the new speed to set.
-   *
-   * Set the current speed now to (dx,dy,dz)
-   * Unit is meters/s
-   */
-  void SetVelocity (const Vector &speed);
-private:
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-  void Update (void) const;
-  ConstantVelocityHelper m_helper;
-};
-
-}; // namespace ns3
-
-#endif /* CONSTANT_VELOCITY_POSITION */
--- a/src/mobility/gauss-markov-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Dan Broyles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Dan Broyles <dbroyl01@ku.edu>
- */
-#include <cmath>
-#include "ns3/simulator.h"
-#include "ns3/random-variable.h"
-#include "ns3/double.h"
-#include "ns3/pointer.h"
-#include "gauss-markov-mobility-model.h"
-#include "position-allocator.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (GaussMarkovMobilityModel);
-
-TypeId
-GaussMarkovMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::GaussMarkovMobilityModel")
-    .SetParent<MobilityModel> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<GaussMarkovMobilityModel> ()
-    .AddAttribute ("Bounds",
-                   "Bounds of the area to cruise.",
-                   BoxValue (Box (-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)),
-                   MakeBoxAccessor (&GaussMarkovMobilityModel::m_bounds),
-                   MakeBoxChecker ())
-    .AddAttribute ("TimeStep",
-                   "Change current direction and speed after moving for this time.",
-                   TimeValue (Seconds (1.0)),
-                   MakeTimeAccessor (&GaussMarkovMobilityModel::m_timeStep),
-                   MakeTimeChecker ())
-    .AddAttribute ("Alpha",
-                   "A constant representing the tunable parameter in the Gauss-Markov model.",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&GaussMarkovMobilityModel::m_alpha),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MeanVelocity",
-                   "A random variable used to assign the average velocity.",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),  
-                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_rndMeanVelocity),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("MeanDirection",
-                   "A random variable used to assign the average direction.",
-                   RandomVariableValue (UniformVariable (0.0, 6.283185307)),  
-                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_rndMeanDirection),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("MeanPitch",
-                   "A random variable used to assign the average pitch.",
-                   RandomVariableValue (ConstantVariable (0.0)),  
-                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_rndMeanPitch),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("NormalVelocity",
-                   "A gaussian random variable used to calculate the next velocity value.",
-                   RandomVariableValue (NormalVariable (0.0, 1.0, 10.0)), // Defaults to zero mean, and std dev = 1, and bound to +-10 of the mean
-                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_normalVelocity),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("NormalDirection",
-                   "A gaussian random variable used to calculate the next direction value.",
-                   RandomVariableValue (NormalVariable (0.0, 1.0, 10.0)),
-                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_normalDirection),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("NormalPitch",
-                   "A gaussian random variable used to calculate the next pitch value.",
-                   RandomVariableValue (NormalVariable (0.0, 1.0, 10.0)),
-                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_normalPitch),
-                   MakeRandomVariableChecker ());
-  
-  return tid;
-}
-
-GaussMarkovMobilityModel::GaussMarkovMobilityModel ()
-{
-  m_meanVelocity = 0.0;
-  m_meanDirection = 0.0;
-  m_meanPitch = 0.0;
-  m_event = Simulator::ScheduleNow (&GaussMarkovMobilityModel::Start, this);
-  m_helper.Unpause ();
-}
-
-void
-GaussMarkovMobilityModel::Start (void)
-{
-  if (m_meanVelocity == 0.0)
-    {
-      //Initialize the mean velocity, direction, and pitch variables
-      m_meanVelocity = m_rndMeanVelocity.GetValue ();
-      m_meanDirection = m_rndMeanDirection.GetValue ();
-      m_meanPitch = m_rndMeanPitch.GetValue ();
-      double cosD = std::cos (m_meanDirection);
-      double cosP = std::cos (m_meanPitch);
-      double sinD = std::sin (m_meanDirection);
-      double sinP = std::sin (m_meanPitch);
-      //Initialize the starting velocity, direction, and pitch to be identical to the mean ones
-      m_Velocity = m_meanVelocity;
-      m_Direction = m_meanDirection;
-      m_Pitch = m_meanPitch;
-      //Set the velocity vector to give to the constant velocity helper
-      m_helper.SetVelocity (Vector (m_Velocity*cosD*cosP, m_Velocity*sinD*cosP, m_Velocity*sinP));
-    }
-  m_helper.Update ();
-
-  //Get the next values from the gaussian distributions for velocity, direction, and pitch
-  double rv = m_normalVelocity.GetValue ();
-  double rd = m_normalDirection.GetValue ();
-  double rp = m_normalPitch.GetValue ();
-
-  //Calculate the NEW velocity, direction, and pitch values using the Gauss-Markov formula:
-  //newVal = alpha*oldVal + (1-alpha)*meanVal + sqrt(1-alpha^2)*rv  
-  //where rv is a random number from a normal (gaussian) distribution
-  double one_minus_alpha = 1 - m_alpha;
-  double sqrt_alpha = std::sqrt (1 - m_alpha*m_alpha);
-  m_Velocity  = m_alpha * m_Velocity  + one_minus_alpha * m_meanVelocity  + sqrt_alpha * rv;
-  m_Direction = m_alpha * m_Direction + one_minus_alpha * m_meanDirection + sqrt_alpha * rd;
-  m_Pitch     = m_alpha * m_Pitch     + one_minus_alpha * m_meanPitch     + sqrt_alpha * rp;
-
-  //Calculate the linear velocity vector to give to the constant velocity helper
-  double cosDir = std::cos (m_Direction);
-  double cosPit = std::cos (m_Pitch);
-  double sinDir = std::sin (m_Direction);
-  double sinPit = std::sin (m_Pitch);
-  double vx = m_Velocity * cosDir * cosPit;
-  double vy = m_Velocity * sinDir * cosPit;
-  double vz = m_Velocity * sinPit;
-  m_helper.SetVelocity (Vector (vx, vy, vz));
-
-  m_helper.Unpause ();
-
-  DoWalk (m_timeStep);
-}
-
-void
-GaussMarkovMobilityModel::DoWalk (Time delayLeft)
-{
-  m_helper.UpdateWithBounds (m_bounds);
-  Vector position = m_helper.GetCurrentPosition ();
-  Vector speed = m_helper.GetVelocity ();
-  Vector nextPosition = position;
-  nextPosition.x += speed.x * delayLeft.GetSeconds ();
-  nextPosition.y += speed.y * delayLeft.GetSeconds ();
-  nextPosition.z += speed.z * delayLeft.GetSeconds ();
-  if (delayLeft.GetSeconds () < 0.0) delayLeft = Seconds (1.0);
-
-  // Make sure that the position by the next time step is still within the boundary.
-  // If out of bounds, then alter the velocity vector and average direction to keep the position in bounds
-  if (m_bounds.IsInside (nextPosition))
-    {
-      m_event = Simulator::Schedule (delayLeft, &GaussMarkovMobilityModel::Start, this);
-    }
-  else
-    {
-      if (nextPosition.x > m_bounds.xMax || nextPosition.x < m_bounds.xMin) 
-        {
-          speed.x = - speed.x;
-          m_meanDirection = 3.14159265 - m_meanDirection;
-        }
-
-      if (nextPosition.y > m_bounds.yMax || nextPosition.y < m_bounds.yMin) 
-        {
-          speed.y = - speed.y;
-          m_meanDirection = - m_meanDirection;
-        }
-
-      if (nextPosition.z > m_bounds.zMax || nextPosition.z < m_bounds.zMin) 
-        {
-          speed.z = - speed.z;
-          m_meanPitch = - m_meanPitch;
-        }
-
-      m_Direction = m_meanDirection;
-      m_Pitch = m_meanPitch;
-      m_helper.SetVelocity (speed);
-      m_helper.Unpause ();
-      m_event = Simulator::Schedule (delayLeft, &GaussMarkovMobilityModel::Start, this);
-    }
-  NotifyCourseChange ();
-}
-
-void
-GaussMarkovMobilityModel::DoDispose (void)
-{
-  // chain up
-  MobilityModel::DoDispose ();
-}
-
-Vector
-GaussMarkovMobilityModel::DoGetPosition (void) const
-{
-  m_helper.Update ();
-  return m_helper.GetCurrentPosition ();
-}
-void 
-GaussMarkovMobilityModel::DoSetPosition (const Vector &position)
-{
-  m_helper.SetPosition (position);
-  Simulator::Remove (m_event);
-  m_event = Simulator::ScheduleNow (&GaussMarkovMobilityModel::Start, this);
-}
-Vector
-GaussMarkovMobilityModel::DoGetVelocity (void) const
-{
-  return m_helper.GetVelocity ();
-}
-
-
-} // namespace ns3
--- a/src/mobility/gauss-markov-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Dan Broyles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Dan Broyles <dbroyl01@ku.edu>
- * Thanks to Kevin Peters, faculty advisor James P.G. Sterbenz, and the ResiliNets 
- * initiative at The University of Kansas, https://wiki.ittc.ku.edu/resilinets
- */
-#ifndef GAUSS_MARKOV_MOBILITY_MODEL_H
-#define GAUSS_MARKOV_MOBILITY_MODEL_H
-
-#include "constant-velocity-helper.h"
-#include "mobility-model.h"
-#include "position-allocator.h"
-#include "ns3/ptr.h"
-#include "ns3/object.h"
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-#include "ns3/box.h"
-#include "ns3/random-variable.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Gauss-Markov mobility model
- *
- * This is a 3D version of the Gauss-Markov mobility model described in [1]. 
- * Unlike the other mobility models in ns-3, which are memoryless, the Gauss
- * Markov model has both memory and variability. The tunable alpha parameter
- * determines the how much memory and randomness you want to model.
- * Each object starts with a specific velocity, direction (radians), and pitch 
- * angle (radians) equivalent to the mean velocity, direction, and pitch. 
- * At each timestep, a new velocity, direction, and pitch angle are generated 
- * based upon the previous value, the mean value, and a gaussian random variable. 
- * This version is suited for simple airplane flight, where direction, velocity,
- * and pitch are the key variables.
- * The motion field is limited by a 3D bounding box (called "box") which is a 3D
- * version of the "rectangle" field that is used in 2-dimensional ns-3 mobility models.
- * 
- * Here is an example of how to implement the model and set the initial node positions:
- * \code
-    MobilityHelper mobility;
-  
-    mobility.SetMobilityModel ("ns3::GaussMarkovMobilityModel",
-      "Bounds", BoxValue (Box (0, 150000, 0, 150000, 0, 10000)),
-      "TimeStep", TimeValue (Seconds (0.5)),
-      "Alpha", DoubleValue (0.85),
-      "MeanVelocity", RandomVariableValue (UniformVariable (800, 1200)),
-      "MeanDirection", RandomVariableValue (UniformVariable (0, 6.283185307)),
-      "MeanPitch", RandomVariableValue (UniformVariable (0.05, 0.05)),
-      "NormalVelocity", RandomVariableValue (NormalVariable (0.0, 0.0, 0.0)),
-      "NormalDirection", RandomVariableValue (NormalVariable (0.0, 0.2, 0.4)),
-      "NormalPitch", RandomVariableValue (NormalVariable (0.0, 0.02, 0.04)));
-  
-    mobility.SetPositionAllocator ("ns3::RandomBoxPositionAllocator",
-      "X", RandomVariableValue (UniformVariable (0, 150000)),
-      "Y", RandomVariableValue (UniformVariable (0, 150000)),
-      "Z", RandomVariableValue (UniformVariable (0, 10000)));
- 
-    mobility.Install (wifiStaNodes);
- * \endcode
- * [1] Tracy Camp, Jeff Boleng, Vanessa Davies, "A Survey of Mobility Models
- * for Ad Hoc Network Research", Wireless Communications and Mobile Computing,
- * Wiley, vol.2 iss.5, September 2002, pp.483-502
- */
-class GaussMarkovMobilityModel : public MobilityModel
-{
-public:
-  static TypeId GetTypeId (void);
-  GaussMarkovMobilityModel ();
-private:
-  void Start (void);
-  void DoWalk (Time timeLeft);
-  virtual void DoDispose (void);
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-  ConstantVelocityHelper m_helper;
-  Time m_timeStep;
-  double m_alpha;
-  double m_meanVelocity;
-  double m_meanDirection;
-  double m_meanPitch;
-  double m_Velocity;
-  double m_Direction;
-  double m_Pitch;
-  RandomVariable m_rndMeanVelocity;
-  RandomVariable m_normalVelocity;
-  RandomVariable m_rndMeanDirection;
-  RandomVariable m_normalDirection;
-  RandomVariable m_rndMeanPitch;
-  RandomVariable m_normalPitch;
-  EventId m_event;
-  Box m_bounds;
-};
-
-} // namespace ns3
-
-#endif /* GAUSS_MARKOV_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/helper/mobility-helper.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,248 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "ns3/mobility-helper.h"
+#include "ns3/mobility-model.h"
+#include "ns3/position-allocator.h"
+#include "ns3/hierarchical-mobility-model.h"
+#include "ns3/log.h"
+#include "ns3/pointer.h"
+#include "ns3/config.h"
+#include "ns3/simulator.h"
+#include "ns3/names.h"
+#include <iostream>
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("MobilityHelper");
+
+MobilityHelper::MobilityHelper ()
+{
+  m_position = CreateObjectWithAttributes<RandomRectanglePositionAllocator> 
+    ("X", RandomVariableValue (ConstantVariable (0.0)),
+     "Y", RandomVariableValue (ConstantVariable (0.0)));
+  m_mobility.SetTypeId ("ns3::ConstantPositionMobilityModel");
+}
+MobilityHelper::~MobilityHelper ()
+{}
+void 
+MobilityHelper::SetPositionAllocator (Ptr<PositionAllocator> allocator)
+{
+  m_position = allocator;
+}
+
+void 
+MobilityHelper::SetPositionAllocator (std::string type,
+                                      std::string n1, const AttributeValue &v1,
+                                      std::string n2, const AttributeValue &v2,
+                                      std::string n3, const AttributeValue &v3,
+                                      std::string n4, const AttributeValue &v4,
+                                      std::string n5, const AttributeValue &v5,
+                                      std::string n6, const AttributeValue &v6,
+                                      std::string n7, const AttributeValue &v7,
+                                      std::string n8, const AttributeValue &v8,
+                                      std::string n9, const AttributeValue &v9)
+{
+  ObjectFactory pos;
+  pos.SetTypeId (type);
+  pos.Set (n1, v1);
+  pos.Set (n2, v2);
+  pos.Set (n3, v3);
+  pos.Set (n4, v4);
+  pos.Set (n5, v5);
+  pos.Set (n6, v6);
+  pos.Set (n7, v7);
+  pos.Set (n8, v8);
+  pos.Set (n9, v9);
+  m_position = pos.Create ()->GetObject<PositionAllocator> ();
+}
+
+void 
+MobilityHelper::SetMobilityModel (std::string type,
+                                  std::string n1, const AttributeValue &v1,
+                                  std::string n2, const AttributeValue &v2,
+                                  std::string n3, const AttributeValue &v3,
+                                  std::string n4, const AttributeValue &v4,
+                                  std::string n5, const AttributeValue &v5,
+                                  std::string n6, const AttributeValue &v6,
+                                  std::string n7, const AttributeValue &v7,
+                                  std::string n8, const AttributeValue &v8,
+                                  std::string n9, const AttributeValue &v9)
+{
+  m_mobility.SetTypeId (type);
+  m_mobility.Set (n1, v1);
+  m_mobility.Set (n2, v2);
+  m_mobility.Set (n3, v3);
+  m_mobility.Set (n4, v4);
+  m_mobility.Set (n5, v5);
+  m_mobility.Set (n6, v6);
+  m_mobility.Set (n7, v7);
+  m_mobility.Set (n8, v8);
+  m_mobility.Set (n9, v9);
+}
+
+void 
+MobilityHelper::PushReferenceMobilityModel (Ptr<Object> reference)
+{
+  Ptr<MobilityModel> mobility = reference->GetObject<MobilityModel> ();
+  m_mobilityStack.push_back (mobility);
+}
+
+void 
+MobilityHelper::PushReferenceMobilityModel (std::string referenceName)
+{
+  Ptr<MobilityModel> mobility = Names::Find<MobilityModel> (referenceName);
+  m_mobilityStack.push_back (mobility);
+}
+
+void 
+MobilityHelper::PopReferenceMobilityModel (void)
+{
+  m_mobilityStack.pop_back ();
+}
+
+
+std::string 
+MobilityHelper::GetMobilityModelType (void) const
+{
+  return m_mobility.GetTypeId ().GetName ();
+}
+
+void
+MobilityHelper::Install (Ptr<Node> node) const
+{
+  Ptr<Object> object = node;
+  Ptr<MobilityModel> model = object->GetObject<MobilityModel> ();
+  if (model == 0)
+    {
+      model = m_mobility.Create ()->GetObject<MobilityModel> ();
+      if (model == 0)
+        {
+          NS_FATAL_ERROR ("The requested mobility model is not a mobility model: \""<< 
+                          m_mobility.GetTypeId ().GetName ()<<"\"");
+        }
+      if (m_mobilityStack.empty ())
+        {
+          NS_LOG_DEBUG ("node="<<object<<", mob="<<model);
+          object->AggregateObject (model);
+        }
+      else
+        {
+          // we need to setup a hierarchical mobility model
+          Ptr<MobilityModel> parent = m_mobilityStack.back ();
+          Ptr<MobilityModel> hierarchical = 
+            CreateObjectWithAttributes<HierarchicalMobilityModel> ("Child", PointerValue (model),
+                                                     "Parent", PointerValue (parent));
+          object->AggregateObject (hierarchical);
+          NS_LOG_DEBUG ("node="<<object<<", mob="<<hierarchical);
+        }
+    }
+  Vector position = m_position->GetNext ();
+  model->SetPosition (position);
+}
+
+void
+MobilityHelper::Install (std::string nodeName) const
+{
+  Ptr<Node> node = Names::Find<Node> (nodeName);
+  Install (node);
+}
+void 
+MobilityHelper::Install (NodeContainer c) const
+{
+  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+    {
+      Install (*i);
+    }
+}
+
+void 
+MobilityHelper::InstallAll (void)
+{
+  Install (NodeContainer::GetGlobal ());
+}
+static double
+DoRound (double v)
+{
+  if (v <= 1e-4 && v >= -1e-4)
+    {
+      return 0.0;
+    }
+  else if (v <= 1e-3 && v >= 0)
+    {
+      return 1e-3;
+    }
+  else if (v >= -1e-3 && v <= 0)
+    {
+      return -1e-3;
+    }
+  else
+    {
+      return v;
+    }
+}
+void
+MobilityHelper::CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility)
+{
+  Ptr<Node> node = mobility->GetObject<Node> ();
+  *os << "now=" << Simulator::Now ()
+      << " node=" << node->GetId ();
+  Vector pos = mobility->GetPosition ();
+  pos.x = DoRound (pos.x);
+  pos.y = DoRound (pos.y);
+  pos.z = DoRound (pos.z);
+  Vector vel = mobility->GetVelocity ();
+  vel.x = DoRound (vel.x);
+  vel.y = DoRound (vel.y);
+  vel.z = DoRound (vel.z);
+  std::streamsize saved_precision = os->precision ();
+  std::ios::fmtflags saved_flags = os->flags ();
+  os->precision (3);
+  os->setf (std::ios::fixed,std::ios::floatfield);
+  *os << " pos=" << pos.x << ":" << pos.y << ":" << pos.z
+      << " vel=" << vel.x << ":" << vel.y << ":" << vel.z
+      << std::endl;
+  os->flags (saved_flags);
+  os->precision (saved_precision);
+}
+
+void 
+MobilityHelper::EnableAscii (std::ostream &os, uint32_t nodeid)
+{
+  std::ostringstream oss;
+  oss << "/NodeList/" << nodeid << "/$ns3::MobilityModel/CourseChange";
+  Config::ConnectWithoutContext (oss.str (), 
+                                 MakeBoundCallback (&MobilityHelper::CourseChanged, &os));
+}
+void 
+MobilityHelper::EnableAscii (std::ostream &os, NodeContainer n)
+{
+  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
+    {
+      EnableAscii (os, (*i)->GetId ());
+    }
+}
+void 
+MobilityHelper::EnableAsciiAll (std::ostream &os)
+{
+  EnableAscii (os, NodeContainer::GetGlobal ());
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/helper/mobility-helper.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,262 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#ifndef MOBILITY_HELPER_H
+#define MOBILITY_HELPER_H
+
+#include <vector>
+#include "ns3/object-factory.h"
+#include "ns3/attribute.h"
+#include "ns3/position-allocator.h"
+#include "node-container.h"
+
+namespace ns3 {
+
+class PositionAllocator;
+class MobilityModel;
+
+/**
+ * \ingroup mobility
+ * \brief Helper class used to assign positions and mobility models to nodes.
+ *
+ * MobilityHelper::Install is the most important method here.
+ */
+class MobilityHelper
+{
+public:
+  /**
+   * Construct a Mobility Helper which is used to make life easier when working
+   * with mobility models.
+   */
+  MobilityHelper ();
+
+  /**
+   * \internal
+   * Destroy a Mobility Helper
+   */
+  ~MobilityHelper ();
+
+  /**
+   * Set the position allocator which will be used to allocate the initial 
+   * position of every node initialized during MobilityModel::Install.
+   *
+   * \param allocator allocate initial node positions
+   */
+  void SetPositionAllocator (Ptr<PositionAllocator> allocator);
+
+  /**
+   * \param type the type of mobility model to use.
+   * \param n1 the name of the attribute to set in the mobility model.
+   * \param v1 the value of the attribute to set in the mobility model.
+   * \param n2 the name of the attribute to set in the mobility model.
+   * \param v2 the value of the attribute to set in the mobility model.
+   * \param n3 the name of the attribute to set in the mobility model.
+   * \param v3 the value of the attribute to set in the mobility model.
+   * \param n4 the name of the attribute to set in the mobility model.
+   * \param v4 the value of the attribute to set in the mobility model.
+   * \param n5 the name of the attribute to set in the mobility model.
+   * \param v5 the value of the attribute to set in the mobility model.
+   * \param n6 the name of the attribute to set in the mobility model.
+   * \param v6 the value of the attribute to set in the mobility model.
+   * \param n7 the name of the attribute to set in the mobility model.
+   * \param v7 the value of the attribute to set in the mobility model.
+   * \param n8 the name of the attribute to set in the mobility model.
+   * \param v8 the value of the attribute to set in the mobility model.
+   * \param n9 the name of the attribute to set in the mobility model.
+   * \param v9 the value of the attribute to set in the mobility model.
+   */
+  void SetPositionAllocator (std::string type,
+                             std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+                             std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+                             std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+                             std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+                             std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+                             std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+                             std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
+                             std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
+                             std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
+
+  /**
+   * \param type the type of mobility model to use.
+   * \param n1 the name of the attribute to set in the mobility model.
+   * \param v1 the value of the attribute to set in the mobility model.
+   * \param n2 the name of the attribute to set in the mobility model.
+   * \param v2 the value of the attribute to set in the mobility model.
+   * \param n3 the name of the attribute to set in the mobility model.
+   * \param v3 the value of the attribute to set in the mobility model.
+   * \param n4 the name of the attribute to set in the mobility model.
+   * \param v4 the value of the attribute to set in the mobility model.
+   * \param n5 the name of the attribute to set in the mobility model.
+   * \param v5 the value of the attribute to set in the mobility model.
+   * \param n6 the name of the attribute to set in the mobility model.
+   * \param v6 the value of the attribute to set in the mobility model.
+   * \param n7 the name of the attribute to set in the mobility model.
+   * \param v7 the value of the attribute to set in the mobility model.
+   * \param n8 the name of the attribute to set in the mobility model.
+   * \param v8 the value of the attribute to set in the mobility model.
+   * \param n9 the name of the attribute to set in the mobility model.
+   * \param v9 the value of the attribute to set in the mobility model.
+   *
+   * Calls to MobilityHelper::Install will create an instance of a matching 
+   * mobility model for each node.
+   */
+  void SetMobilityModel (std::string type,
+                         std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+                         std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+                         std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+                         std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+                         std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+                         std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+                         std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
+                         std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
+                         std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
+
+  /**
+   * \param reference item to push.
+   *
+   * Push an item on the top of the stack of "reference mobility models".
+   * The input item should be a node instance to which a mobility model
+   * has already been aggregated (usually by a call to Install).
+   *
+   * If this stack is not empty when MobilityHelper::Install
+   * is called, the model from the top of the stack is used
+   * to create a ns3::HierarchicalMobilityModel to make the
+   * newly-created models define their positions relative to that
+   * of the parent mobility model.
+   *
+   * This method is typically used to create hierarchical mobility
+   * patterns and positions by starting with the large-scale mobility
+   * features, and, then, defining the smaller-scale movements relative
+   * to a few reference points in the large-scale model.
+   */
+  void PushReferenceMobilityModel (Ptr<Object> reference);
+  /**
+   * \param referenceName named item to push.
+   *
+   * Push an item on the top of the stack of "reference mobility models".
+   * The input item should be a node instance to which a mobility model
+   * has already been aggregated (usually by a call to Install).
+   *
+   * If this stack is not empty when MobilityHelper::Install
+   * is called, the model from the top of the stack is used
+   * to create a ns3::HierarchicalMobilityModel to make the
+   * newly-created models define their positions relative to that
+   * of the parent mobility model.
+   *
+   * This method is typically used to create hierarchical mobility
+   * patterns and positions by starting with the large-scale mobility
+   * features, and, then, defining the smaller-scale movements relative
+   * to a few reference points in the large-scale model.
+   */
+  void PushReferenceMobilityModel (std::string referenceName);
+  /**
+   * Remove the top item from the top of the stack of
+   * "reference mobility models".
+   */
+  void PopReferenceMobilityModel (void);
+
+  /**
+   * \return a string which contains the TypeId of the currently-selected
+   *          mobility model.
+   */
+  std::string GetMobilityModelType (void) const;
+
+  /**
+   * \brief "Layout" a single node according to the current position allocator type.
+   *
+   * This method creates an instance of a ns3::MobilityModel subclass (the 
+   * type of which was set with MobilityHelper::SetMobilityModel), aggregates
+   * it to the provided node, and sets an initial position based on the current
+   * position allocator (set through MobilityHelper::SetPositionAllocator). 
+   *
+   * \param node The node to "layout."
+   */
+  void Install (Ptr<Node> node) const;
+  /**
+   * \brief "Layout" a single node according to the current position allocator type.
+   *
+   * This method creates an instance of a ns3::MobilityModel subclass (the 
+   * type of which was set with MobilityHelper::SetMobilityModel), aggregates
+   * it to the provided node, and sets an initial position based on the current
+   * position allocator (set through MobilityHelper::SetPositionAllocator). 
+   *
+   * \param nodeName The name of the node to "layout."
+   */
+  void Install (std::string nodeName) const;
+
+  /**
+   * \brief Layout a collection of nodes according to the current position allocator type.
+   *
+   * For each node in the provided NodeContainer, this method creates an instance 
+   * of a ns3::MobilityModel subclass (the type of which was set with 
+   * MobilityHelper::SetMobilityModel), aggregates it to the node, and sets an 
+   * initial position based on the current position allocator (set through 
+   * MobilityHelper::SetPositionAllocator). 
+   *
+   * \param container The set of nodes to layout.
+   */
+  void Install (NodeContainer container) const;
+
+  /**
+   * Perform the work of MobilityHelper::Install on _all_ nodes which
+   * exist in the simulation.
+   */
+  void InstallAll (void);
+
+  /**
+   * \param os output stream
+   * \param nodeid the id of the node to generate ascii output for.
+   *
+   * Enable ascii output on the mobility model associated to the
+   * specified nodeid and dump that to the specified stdc++ output 
+   * stream.
+   */
+  static void EnableAscii (std::ostream &os, uint32_t nodeid);
+  /**
+   * \param os output stream
+   * \param n node container
+   *
+   * Enable ascii output on the mobility model associated each of
+   * the nodes in the input container and dump that to the 
+   * specified stdc++ output stream.
+   */
+  static void EnableAscii (std::ostream &os, NodeContainer n);
+  /**
+   * \param os output stream
+   *
+   * Enable ascii output on the mobility model associated
+   * every node in the system and dump that to the specified 
+   * stdc++ output stream.
+   */
+  static void EnableAsciiAll (std::ostream &os);
+
+private:
+  /**
+   * \internal
+   */
+  static void CourseChanged (std::ostream *os, Ptr<const MobilityModel> mobility);
+  std::vector<Ptr<MobilityModel> > m_mobilityStack;
+  ObjectFactory m_mobility;
+  Ptr<PositionAllocator> m_position;
+};
+
+} // namespace ns3
+
+#endif /* MOBILITY_HELPER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/helper/ns2-mobility-helper.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,1029 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *               2009,2010 Contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Contributors: Thomas Waldecker <twaldecker@rocketmail.com>
+ *               Martín Giachino <martin.giachino@gmail.com>
+ *
+ * Brief description: Implementation of a ns2 movement trace file reader.
+ *
+ * This implementation is based on the ns2 movement documentation of ns2
+ * as described in http://www.isi.edu/nsnam/ns/doc/node174.html
+ *
+ * Valid trace files use the following ns2 statements:
+ *
+ * $node set X_ x1
+ * $node set Y_ y1
+ * $node set Z_ z1
+ * $ns at $time $node setdest x2 y2 speed
+ * $ns at $time $node set X_ x1
+ * $ns at $time $node set Y_ Y1
+ * $ns at $time $node set Z_ Z1
+ *
+ */
+
+
+#include <fstream>
+#include <sstream>
+#include <map>
+#include <algorithm>
+#include "ns3/log.h"
+#include "ns3/simulator.h"
+#include "ns3/node-list.h"
+#include "ns3/node.h"
+#include "ns3/constant-velocity-mobility-model.h"
+#include "ns3/test.h"
+#include "ns3/node-container.h"
+#include "ns3/names.h"
+#include "ns3/config.h"
+#include "ns2-mobility-helper.h"
+
+NS_LOG_COMPONENT_DEFINE ("Ns2MobilityHelper");
+
+using namespace std;
+
+namespace ns3 {
+
+// Constants definitions
+#define  NS2_AT       "at"
+#define  NS2_X_COORD  "X_"
+#define  NS2_Y_COORD  "Y_"
+#define  NS2_Z_COORD  "Z_"
+#define  NS2_SETDEST  "setdest"
+#define  NS2_SET      "set"
+#define  NS2_NODEID   "$node_("
+#define  NS2_NS_SCH   "$ns_"
+
+
+// Type to maintain line parsed and its values
+struct ParseResult
+{
+  vector<string> tokens; // tokens from a line
+  vector<int> ivals;     // int values for each tokens
+  vector<bool> has_ival; // points if a tokens has an int value
+  vector<double> dvals;  // double values for each tokens
+  vector<bool> has_dval; // points if a tokens has a double value
+  vector<string> svals;  // string value for each token
+};
+
+
+// Parses a line of ns2 mobility
+static ParseResult ParseNs2Line (const string& str);
+
+// Put out blank spaces at the start and end of a line
+static string TrimNs2Line (const string& str);
+
+// Checks if a string represents a number or it has others characters than digits an point.
+static bool IsNumber (const string& s);
+
+// Check if s string represents a numeric value
+template<class T>
+static bool IsVal (const string& str, T& ret);
+
+// Checks if the value between brackets is a correct nodeId number
+static bool HasNodeIdNumber (string str);
+
+// Gets nodeId number in string format from the string like $node_(4)
+static string GetNodeIdFromToken (string str);
+
+// Get node id number in int format
+static int GetNodeIdInt (ParseResult pr);
+
+// Get node id number in string format
+static string GetNodeIdString (ParseResult pr);
+
+// Add one coord to a vector position
+static Vector SetOneInitialCoord (Vector actPos, string& coord, double value);
+
+// Check if this corresponds to a line like this: $node_(0) set X_ 123
+static bool IsSetInitialPos (ParseResult pr);
+
+// Check if this corresponds to a line like this: $ns_ at 1 "$node_(0) setdest 2 3 4"
+static bool IsSchedSetPos (ParseResult pr);
+
+// Check if this corresponds to a line like this: $ns_ at 1 "$node_(0) set X_ 2"
+static bool IsSchedMobilityPos (ParseResult pr);
+
+// Set waypoints and speed for movement.
+static Vector SetMovement (Ptr<ConstantVelocityMobilityModel> model, Vector lastPos, double at,
+                           double xFinalPosition, double yFinalPosition, double speed);
+
+// Set initial position for a node
+static Vector SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, string coord, double coordVal);
+
+// Schedule a set of position for a node
+static Vector SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, string coord, double coordVal);
+
+
+Ns2MobilityHelper::Ns2MobilityHelper (std::string filename)
+  : m_filename (filename)
+{
+}
+
+Ptr<ConstantVelocityMobilityModel>
+Ns2MobilityHelper::GetMobilityModel (std::string idString, const ObjectStore &store) const
+{
+  std::istringstream iss;
+  iss.str (idString);
+  uint32_t id (0);
+  iss >> id;
+  Ptr<Object> object = store.Get (id);
+  if (object == 0)
+    {
+      return 0;
+    }
+  Ptr<ConstantVelocityMobilityModel> model = object->GetObject<ConstantVelocityMobilityModel> ();
+  if (model == 0)
+    {
+      model = CreateObject<ConstantVelocityMobilityModel> ();
+      object->AggregateObject (model);
+    }
+  return model;
+}
+
+
+void
+Ns2MobilityHelper::ConfigNodesMovements (const ObjectStore &store) const
+{
+  map<int, Vector> last_pos;    // Vector containing lasts positions for each node
+
+  std::ifstream file (m_filename.c_str (), std::ios::in);
+  if (file.is_open ())
+    {
+      while (!file.eof () )
+        {
+          int         iNodeId = 0;
+          std::string nodeId;
+          std::string line;
+
+          getline (file, line);
+
+          // ignore empty lines
+          if (line.empty ())
+            {
+              continue;
+            }
+
+          ParseResult pr = ParseNs2Line (line); // Parse line and obtain tokens
+
+          // Check if the line corresponds with one of the three types of line
+          if (pr.tokens.size () != 4 && pr.tokens.size () != 7 && pr.tokens.size () != 8)
+            {
+              NS_LOG_ERROR ("Line has not correct number of parameters (corrupted file?): " << line << "\n");
+              continue;
+            }
+
+          // Get the node Id
+          nodeId  = GetNodeIdString (pr);
+          iNodeId = GetNodeIdInt (pr);
+          if (iNodeId == -1)
+            {
+        	  NS_LOG_ERROR ("Node number couldn't be obtained (corrupted file?): " << line << "\n");
+              continue;
+            }
+
+          // get mobility model of node
+          Ptr<ConstantVelocityMobilityModel> model = GetMobilityModel (nodeId,store);
+
+          // if model not exists, continue
+          if (model == 0)
+            {
+              NS_LOG_ERROR ("Unknown node ID (corrupted file?): " << nodeId << "\n");
+              continue;
+            }
+
+
+          /*
+           * In this case a initial position is being seted
+           * line like $node_(0) set X_ 151.05190721688197
+           */
+          if (IsSetInitialPos (pr))
+            {
+              //                                            coord         coord value
+              last_pos[iNodeId] = SetInitialPosition (model, pr.tokens[2], pr.dvals[3]);
+
+              // Log new position
+              NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
+                            " x=" << last_pos[iNodeId].x << " y=" << last_pos[iNodeId].y << " z=" << last_pos[iNodeId].z);
+            }
+
+          else // NOW EVENTS TO BE SCHEDULED
+            {
+
+              // This is a scheduled event, so time at should be present
+              double at;
+
+              if (!IsNumber (pr.tokens[2]))
+                {
+                  NS_LOG_WARN ("Time is not a number: " << pr.tokens[2]);
+                  continue;
+                }
+
+              at = pr.dvals[2]; // set time at
+
+              if ( at < 0 )
+                {
+                  NS_LOG_WARN ("Time is less than cero: " << at);
+                  continue;
+                }
+
+
+
+              /*
+               * In this case a new waypoint is added
+               * line like $ns_ at 1 "$node_(0) setdest 2 3 4"
+               */
+              if (IsSchedMobilityPos (pr))
+                {
+                  //                                     last position     time  X coord     Y coord      velocity
+                  last_pos[iNodeId] = SetMovement (model, last_pos[iNodeId], at, pr.dvals[5], pr.dvals[6], pr.dvals[7]);
+
+                  // Log new position
+                  NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
+                                " x=" << last_pos[iNodeId].x << " y=" << last_pos[iNodeId].y << " z=" << last_pos[iNodeId].z);
+                }
+
+
+              /*
+               * Scheduled set position
+               * line like $ns_ at 4.634906291962 "$node_(0) set X_ 28.675920486450"
+               */
+              else if (IsSchedSetPos (pr))
+                {
+                  //                                         time  coordinate   coord value
+                  last_pos[iNodeId] = SetSchedPosition (model, at, pr.tokens[5], pr.dvals[6]);
+
+                  // Log new position
+                  NS_LOG_DEBUG ("Positions after parse for node " << iNodeId << " " << nodeId <<
+                                " x=" << last_pos[iNodeId].x << " y=" << last_pos[iNodeId].y << " z=" << last_pos[iNodeId].z);
+                }
+              else
+                {
+                  NS_LOG_WARN ("Format Line is not correct: " << line << "\n");
+                }
+            }
+        }
+      file.close ();
+    }
+}
+
+
+ParseResult
+ParseNs2Line (const string& str)
+{
+  ParseResult ret;
+  istringstream s;
+  string line;
+
+  // ignore comments (#)
+  size_t pos_sharp = str.find_first_of ('#');
+  if (pos_sharp != string::npos)
+    {
+      line = str.substr (0, pos_sharp);
+    }
+  else
+    {
+      line = str;
+    }
+
+  line = TrimNs2Line (line);
+
+  // If line hasn't a correct node Id
+  if (!HasNodeIdNumber (line))
+    {
+      NS_LOG_WARN ("Line has no node Id: " << line);
+      return ret;
+    }
+
+  s.str (line);
+
+  while (!s.eof ())
+    {
+      string x;
+      s >> x;
+      ret.tokens.push_back (x);
+      int ii (0);
+      double d (0);
+      if (HasNodeIdNumber (x))
+        {
+          x = GetNodeIdFromToken (x);
+        }
+      ret.has_ival.push_back (IsVal<int> (x, ii));
+      ret.ivals.push_back (ii);
+      ret.has_dval.push_back (IsVal<double> (x, d));
+      ret.dvals.push_back (d);
+      ret.svals.push_back (x);
+    }
+
+  size_t tokensLength   = ret.tokens.size ();                 // number of tokens in line
+  size_t lasTokenLength = ret.tokens[tokensLength - 1].size (); // length of the last token
+
+  // if it is a scheduled set _[XYZ] or a setdest I need to remove the last "
+  // and re-calculate values
+  if ( (tokensLength == 7 || tokensLength == 8)
+       && (ret.tokens[tokensLength - 1][lasTokenLength - 1] == '"') )
+    {
+
+      // removes " from the last position
+      ret.tokens[tokensLength - 1] = ret.tokens[tokensLength - 1].substr (0,lasTokenLength - 1);
+
+      string x;
+      x = ret.tokens[tokensLength - 1];
+
+      if (HasNodeIdNumber (x))
+        {
+          x = GetNodeIdFromToken (x);
+        }
+
+      // Re calculate values
+      int ii (0);
+      double d (0);
+      ret.has_ival[tokensLength - 1] = IsVal<int> (x, ii);
+      ret.ivals[tokensLength - 1] = ii;
+      ret.has_dval[tokensLength - 1] = IsVal<double> (x, d);
+      ret.dvals[tokensLength - 1] = d;
+      ret.svals[tokensLength - 1] = x;
+
+    }
+  else if ( (tokensLength == 9 && ret.tokens[tokensLength - 1] == "\"")
+            || (tokensLength == 8 && ret.tokens[tokensLength - 1] == "\""))
+    {
+      // if the line has the " character in this way: $ns_ at 1 "$node_(0) setdest 2 2 1  "
+      // or in this: $ns_ at 4 "$node_(0) set X_ 2  " we need to ignore this last token
+
+      ret.tokens.erase (ret.tokens.begin () + tokensLength - 1);
+      ret.has_ival.erase (ret.has_ival.begin () + tokensLength - 1);
+      ret.ivals.erase (ret.ivals.begin () + tokensLength - 1);
+      ret.has_dval.erase (ret.has_dval.begin () + tokensLength - 1);
+      ret.dvals.erase (ret.dvals.begin () + tokensLength - 1);
+      ret.svals.erase (ret.svals.begin () + tokensLength - 1);
+
+    }
+
+
+
+  return ret;
+}
+
+
+string
+TrimNs2Line (const string& s)
+{
+  string ret = s;
+
+  while (ret.size () > 0 && isblank (ret[0]))
+    {
+      ret.erase (0, 1);    // Removes blank spaces at the begining of the line
+    }
+
+  while (ret.size () > 0 && isblank (ret[ret.size () - 1]))
+    {
+      ret.erase (ret.size () - 1, 1); // Removes blank spaces from at end of line
+    }
+
+  return ret;
+}
+
+
+bool
+IsNumber (const string& s)
+{
+  char *endp;
+  double unused;
+  unused = strtod (s.c_str (), &endp); // declared with warn_unused_result
+  return endp == s.c_str () + s.size ();
+}
+
+
+template<class T>
+bool IsVal (const string& str, T& ret)
+{
+  if (str.size () == 0)
+    {
+      return false;
+    }
+  else if (IsNumber (str))
+    {
+      string s2 = str;
+      istringstream s (s2);
+      s >> ret;
+      return true;
+    }
+  else
+    {
+      return false;
+    }
+}
+
+
+bool
+HasNodeIdNumber (string str)
+{
+
+  // find brackets
+  std::string::size_type startNodeId = str.find_first_of ("("); // index of left bracket
+  std::string::size_type endNodeId   = str.find_first_of (")"); // index of right bracket
+
+  // Get de nodeId in a string and in a int value
+  std::string nodeId;     // node id
+
+  // if no brackets, continue!
+  if (startNodeId == std::string::npos || endNodeId == std::string::npos)
+    {
+      return false;
+    }
+
+  nodeId = str.substr (startNodeId + 1, endNodeId - (startNodeId + 1)); // set node id
+
+  //   is number              is integer                                       is not negative
+  if (IsNumber (nodeId) && (nodeId.find_first_of (".") == std::string::npos) && (nodeId[0] != '-'))
+    {
+      return true;
+    }
+  else
+    {
+      return false;
+    }
+}
+
+
+string
+GetNodeIdFromToken (string str)
+{
+  if (HasNodeIdNumber (str))
+    {
+      // find brackets
+      std::string::size_type startNodeId = str.find_first_of ("(");     // index of left bracket
+      std::string::size_type endNodeId   = str.find_first_of (")");     // index of right bracket
+
+      return str.substr (startNodeId + 1, endNodeId - (startNodeId + 1)); // set node id
+    }
+  else
+    {
+      return "";
+    }
+}
+
+
+int
+GetNodeIdInt (ParseResult pr)
+{
+  int result = -1;
+  switch (pr.tokens.size ())
+    {
+    case 4:   // line like $node_(0) set X_ 11
+      result = pr.ivals[0];
+      break;
+    case 7:   // line like $ns_ at 4 "$node_(0) set X_ 28"
+      result = pr.ivals[3];
+      break;
+    case 8:   // line like $ns_ at 1 "$node_(0) setdest 2 3 4"
+      result = pr.ivals[3];
+      break;
+    default:
+      result = -1;
+    }
+  return result;
+}
+
+// Get node id number in string format
+string
+GetNodeIdString (ParseResult pr)
+{
+  switch (pr.tokens.size ())
+    {
+    case 4:   // line like $node_(0) set X_ 11
+      return pr.svals[0];
+      break;
+    case 7:   // line like $ns_ at 4 "$node_(0) set X_ 28"
+      return pr.svals[3];
+      break;
+    case 8:   // line like $ns_ at 1 "$node_(0) setdest 2 3 4"
+      return pr.svals[3];
+      break;
+    default:
+      return "";
+    }
+}
+
+
+Vector
+SetOneInitialCoord (Vector position, string& coord, double value)
+{
+
+  // set the position for the coord.
+  if (coord == NS2_X_COORD)
+    {
+      position.x = value;
+      NS_LOG_DEBUG ("X=" << value);
+    }
+  else if (coord == NS2_Y_COORD)
+    {
+      position.y = value;
+      NS_LOG_DEBUG ("Y=" << value);
+    }
+  else if (coord == NS2_Z_COORD)
+    {
+      position.z = value;
+      NS_LOG_DEBUG ("Z=" << value);
+    }
+  return position;
+}
+
+
+bool
+IsSetInitialPos (ParseResult pr)
+{
+  //        number of tokens         has $node_( ?                        has "set"           has doble for position?
+  return pr.tokens.size () == 4 && HasNodeIdNumber (pr.tokens[0]) && pr.tokens[1] == NS2_SET && pr.has_dval[3]
+         // coord name is X_, Y_ or Z_ ?
+         && (pr.tokens[2] == NS2_X_COORD || pr.tokens[2] == NS2_Y_COORD || pr.tokens[2] == NS2_Z_COORD);
+
+}
+
+
+bool
+IsSchedSetPos (ParseResult pr)
+{
+  //      correct number of tokens,    has $ns_                   and at
+  return pr.tokens.size () == 7 && pr.tokens[0] == NS2_NS_SCH && pr.tokens[1] == NS2_AT
+         && pr.tokens[4] == NS2_SET && pr.has_dval[2] && pr.has_dval[3]   // has set and double value for time and nodeid
+         && ( pr.tokens[5] == NS2_X_COORD || pr.tokens[5] == NS2_Y_COORD || pr.tokens[5] == NS2_Z_COORD) // has X_, Y_ or Z_?
+         && pr.has_dval[2]; // time is a number
+}
+
+bool
+IsSchedMobilityPos (ParseResult pr)
+{
+  //     number of tokens      and    has $ns_                and    has at
+  return pr.tokens.size () == 8 && pr.tokens[0] == NS2_NS_SCH && pr.tokens[1] == NS2_AT
+         //    time             x coord          y coord          velocity are numbers?
+         && pr.has_dval[2] && pr.has_dval[5] && pr.has_dval[6] && pr.has_dval[7]
+         && pr.tokens[4] == NS2_SETDEST; // and has setdest
+
+}
+
+Vector
+SetMovement (Ptr<ConstantVelocityMobilityModel> model, Vector last_pos, double at,
+             double xFinalPosition, double yFinalPosition, double speed)
+{
+  Vector position;
+  position.x = last_pos.x;
+  position.y = last_pos.y;
+  position.z = last_pos.z;
+
+  if (speed == 0)
+    {
+      // We have to maintain last position, and stop the movement
+      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetVelocity, model,
+                           Vector (0, 0, 0));
+    }
+  else if (speed > 0)
+    {
+      // first calculate the time; time = distance / speed
+      double time = sqrt (pow (xFinalPosition - position.x, 2) + pow (yFinalPosition - position.y, 2)) / speed;
+      NS_LOG_DEBUG ("at=" << at << " time=" << time);
+      // now calculate the xSpeed = distance / time
+      double xSpeed = (xFinalPosition - position.x) / time;
+      double ySpeed = (yFinalPosition - position.y) / time; // & same with ySpeed
+
+      // quick and dirty set zSpeed = 0
+      double zSpeed = 0;
+
+      NS_LOG_DEBUG ("Calculated Speed: X=" << xSpeed << " Y=" << ySpeed << " Z=" << zSpeed);
+
+      // Set the Values
+      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetVelocity, model,
+                           Vector (xSpeed, ySpeed, zSpeed));
+
+      if (time >= 0)
+        {
+          Simulator::Schedule (Seconds (at + time), &ConstantVelocityMobilityModel::SetVelocity,
+                               model, Vector (0, 0, 0));
+        }
+
+      position.x = xFinalPosition;
+      position.y = yFinalPosition;
+      position.z = 0;
+    }
+
+  return position;
+}
+
+
+Vector
+SetInitialPosition (Ptr<ConstantVelocityMobilityModel> model, string coord, double coordVal)
+{
+  model->SetPosition (SetOneInitialCoord (model->GetPosition (), coord, coordVal));
+
+  Vector position;
+  position.x = model->GetPosition ().x;
+  position.y = model->GetPosition ().y;
+  position.z = model->GetPosition ().z;
+
+  return position;
+}
+
+// Schedule a set of position for a node
+Vector
+SetSchedPosition (Ptr<ConstantVelocityMobilityModel> model, double at, string coord, double coordVal)
+{
+  // update position
+  model->SetPosition (SetOneInitialCoord (model->GetPosition (), coord, coordVal));
+
+  Vector position;
+  position.x = model->GetPosition ().x;
+  position.y = model->GetPosition ().y;
+  position.z = model->GetPosition ().z;
+
+  // Chedule next positions
+  Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetPosition, model,position);
+
+  return position;
+}
+
+void
+Ns2MobilityHelper::Install (void) const
+{
+  Install (NodeList::Begin (), NodeList::End ());
+}
+
+// -----------------------------------------------------------------------------
+// Testing
+// -----------------------------------------------------------------------------
+bool operator== (Vector const & a, Vector const & b)
+{
+  return (a.x == b.x && a.y == b.y && a.z == b.z);
+}
+/**
+ * Every test case is supposed to:
+ *  1. Generate short mobility trace file
+ *  2. Read it back using Ns2MobilityHelper
+ *  3. Check initial node positions and speeds.
+ *  4. Run simulation listening for all CourseChange events and compare actual mobility with the reference
+ */
+class Ns2MobilityHelperTest : public TestCase
+{
+public:
+  /// Single record in mobility reference
+  struct ReferencePoint
+  {
+    std::string node;       ///< node ID as string, e.g. "1"
+    Time time;              ///< timestamp
+    Vector pos;             ///< reference position
+    Vector vel;             ///< reference velocity
+
+    ReferencePoint (std::string const & id, Time t, Vector const & p, Vector const & v)
+      : node (id),
+        time (t),
+        pos (p),
+        vel (v)
+    {
+    }
+    /// Sort by timestamp
+    bool operator< (ReferencePoint const & o) const
+    {
+      return (time < o.time);
+    }
+  };
+  /**
+   * Create new test case. To make it useful SetTrace () and AddReferencePoint () must be called
+   *
+   * \param name        Short description
+   * \param nodes       Number of nodes used in the test trace, 1 by default
+   */
+  Ns2MobilityHelperTest (std::string const & name, Time timeLimit, uint32_t nodes = 1)
+    : TestCase (name),
+      m_timeLimit (timeLimit),
+      m_nodeCount (nodes),
+      m_nextRefPoint (0)
+  {
+  }
+  /// Empty
+  virtual ~Ns2MobilityHelperTest ()
+  {
+  }
+  /// Set NS-2 trace to read as single large string (don't forget to add \n and quote ")
+  void SetTrace (std::string const & trace)
+  {
+    m_trace = trace;
+  }
+  /// Add next reference point
+  void AddReferencePoint (ReferencePoint const & r)
+  {
+    m_reference.push_back (r);
+  }
+  /// Sugar
+  void AddReferencePoint (const char * id, double sec, Vector const & p, Vector const & v)
+  {
+    AddReferencePoint (ReferencePoint (id, Seconds (sec), p, v));
+  }
+
+private:
+  /// Test time limit
+  Time m_timeLimit;
+  /// Number of nodes used in the test
+  uint32_t m_nodeCount;
+  /// Trace as string
+  std::string m_trace;
+  /// Reference mobility
+  std::vector<ReferencePoint> m_reference;
+  /// Next reference point to be checked
+  size_t m_nextRefPoint;
+  /// TMP trace file name
+  std::string m_traceFile;
+
+private:
+  /// Dump NS-2 trace to tmp file
+  bool WriteTrace ()
+  {
+    m_traceFile = GetTempDir () + "Ns2MobilityHelperTest.tcl";
+    std::ofstream of (m_traceFile.c_str ());
+    NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (of.is_open (), true, "Need to write tmp. file");
+    of << m_trace;
+    of.close ();
+    return false; // no errors
+  }
+  /// Create and name nodes
+  void CreateNodes ()
+  {
+    NodeContainer nodes;
+    nodes.Create (m_nodeCount);
+    for (uint32_t i = 0; i < m_nodeCount; ++i)
+      {
+        std::ostringstream os;
+        os << i;
+        Names::Add (os.str (), nodes.Get (i));
+      }
+  }
+  /// Check that all initial positions are correct
+  bool CheckInitialPositions ()
+  {
+    std::stable_sort (m_reference.begin (), m_reference.end ());
+    while (m_nextRefPoint < m_reference.size () && m_reference[m_nextRefPoint].time == Seconds (0))
+      {
+        ReferencePoint const & rp = m_reference[m_nextRefPoint];
+        Ptr<Node> node = Names::Find<Node> (rp.node);
+        NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (node, 0, "Can't find node with id " << rp.node);
+        Ptr<MobilityModel> mob = node->GetObject<MobilityModel> ();
+        NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (mob, 0, "Can't find mobility for node " << rp.node);
+
+        NS_TEST_EXPECT_MSG_EQ (rp.pos, mob->GetPosition (), "Initial position mismatch for node " << rp.node);
+        NS_TEST_EXPECT_MSG_EQ (rp.vel, mob->GetVelocity (), "Initial velocity mismatch for node " << rp.node);
+
+        m_nextRefPoint++;
+      }
+    return GetErrorStatus ();
+  }
+  /// Listen for course change events
+  void CourseChange (std::string context, Ptr<const MobilityModel> mobility)
+  {
+    Time time = Simulator::Now ();
+    Ptr<Node> node = mobility->GetObject<Node> ();
+    NS_ASSERT (node);
+    std::string id = Names::FindName (node);
+    NS_ASSERT (!id.empty ());
+    Vector pos = mobility->GetPosition ();
+    Vector vel = mobility->GetVelocity ();
+
+    NS_TEST_EXPECT_MSG_LT (m_nextRefPoint, m_reference.size (), "Not enough reference points");
+    if (m_nextRefPoint >= m_reference.size ())
+      {
+        return;
+      }
+
+    ReferencePoint const & ref = m_reference [m_nextRefPoint++];
+    NS_TEST_EXPECT_MSG_EQ (time, ref.time, "Time mismatch");
+    NS_TEST_EXPECT_MSG_EQ (id, ref.node, "Node ID mismatch at time " << time.GetSeconds () << " s");
+    NS_TEST_EXPECT_MSG_EQ (pos, ref.pos, "Position mismatch at time " << time.GetSeconds () << " s for node " << id);
+    NS_TEST_EXPECT_MSG_EQ (vel, ref.vel, "Velocity mismatch at time " << time.GetSeconds () << " s for node " << id);
+  }
+  /// Go
+  void DoRun ()
+  {
+    NS_TEST_ASSERT_MSG_EQ (m_trace.empty (), false, "Need trace");
+    NS_TEST_ASSERT_MSG_EQ (m_reference.empty (), false, "Need reference");
+
+    if (WriteTrace ())
+      {
+        return;
+      }
+    CreateNodes ();
+    Ns2MobilityHelper mobility (m_traceFile);
+    mobility.Install ();
+    if (CheckInitialPositions ())
+      {
+        return;
+      }
+    Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
+                     MakeCallback (&Ns2MobilityHelperTest::CourseChange, this));
+    Simulator::Stop (m_timeLimit);
+    Simulator::Run ();
+    Names::Clear ();
+    std::remove (m_traceFile.c_str ());
+    Simulator::Destroy ();
+  }
+};
+
+/// The test suite
+class Ns2MobilityHelperTestSuite : public TestSuite
+{
+public:
+  Ns2MobilityHelperTestSuite () : TestSuite ("mobility-ns2-trace-helper", UNIT)
+  {
+    // to be used as temporary variable for test cases.
+    // Note that test suite takes care of deleting all test cases.
+    Ns2MobilityHelperTest * t (0);
+
+    // Initial position
+    t = new Ns2MobilityHelperTest ("initial position", Seconds (1));
+    t->SetTrace ("$node_(0) set X_ 1.0\n"
+                 "$node_(0) set Y_ 2.0\n"
+                 "$node_(0) set Z_ 3.0\n"
+                 );
+    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // Check parsing comments, empty lines and no EOF at the end of file
+    t = new Ns2MobilityHelperTest ("comments", Seconds (1));
+    t->SetTrace ("# comment\n"
+                 "\n\n" // empty lines
+                 "$node_(0) set X_ 1.0 # comment \n"
+                 "$node_(0) set Y_ 2.0 ### \n"
+                 "$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n"
+                 "#$node_(0) set Z_ 100 #"
+                 );
+    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // Simple setdest. Arguments are interpreted as x, y, speed by default
+    t = new Ns2MobilityHelperTest ("simple setdest", Seconds (10));
+    t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
+    t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // Several set and setdest. Arguments are interpreted as x, y, speed by default
+    t = new Ns2MobilityHelperTest ("square setdest", Seconds (6));
+    t->SetTrace ("$node_(0) set X_ 0.0\n"
+                 "$node_(0) set Y_ 0.0\n"
+                 "$ns_ at 1.0 \"$node_(0) setdest 5  0  5\"\n"
+                 "$ns_ at 2.0 \"$node_(0) setdest 5  5  5\"\n"
+                 "$ns_ at 3.0 \"$node_(0) setdest 0  5  5\"\n"
+                 "$ns_ at 4.0 \"$node_(0) setdest 0  0  5\"\n"
+                 );
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5,  0, 0));
+    t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0,  5, 0));
+    t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
+    t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, -5, 0));
+    t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0,  0, 0));
+    AddTestCase (t);
+
+    // Scheduled set position
+    t = new Ns2MobilityHelperTest ("scheduled set position", Seconds (2));
+    t->SetTrace ("$ns_ at 1.0 \"$node_(0) set X_ 10\"\n"
+                 "$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n"
+                 "$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 1, Vector (10, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (10, 0, 10), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (10, 10, 10), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // Malformed lines
+    t = new Ns2MobilityHelperTest ("malformed lines", Seconds (2));
+    t->SetTrace ("$node() set X_ 1 # node id is not present\n"
+                 "$node # incoplete line\"\n"
+                 "$node this line is not correct\n"
+                 "$node_(0) set X_ 1 # line OK \n"
+                 "$node_(0) set Y_ 2 # line OK \n"
+                 "$node_(0) set Z_ 3 # line OK \n"
+                 "$ns_ at  \"$node_(0) setdest 4 4 4\" # time not present\n"
+                 "$ns_ at 1 \"$node_(0) setdest 2 2 1   \" # line OK \n");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
+    t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // Non possible values
+    t = new Ns2MobilityHelperTest ("non possible values", Seconds (2));
+    t->SetTrace ("$node_(0) set X_ 1 # line OK \n"
+                 "$node_(0) set Y_ 2 # line OK \n"
+                 "$node_(0) set Z_ 3 # line OK \n"
+                 "$node_(-22) set Y_ 3 # node id not correct\n"
+                 "$node_(3.3) set Y_ 1111 # node id not correct\n"
+                 "$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n"
+                 "$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n"
+                 "$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n"
+                 "$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\"    # speed is not a number\n"
+                 "$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n"
+                 "$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\"   # more than one non numbers\n"
+                 "$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
+    t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // More than one node
+    t = new Ns2MobilityHelperTest ("few nodes, combinations of set and setdest", Seconds (10), 3);
+    t->SetTrace ("$node_(0) set X_ 1.0\n"
+                 "$node_(0) set Y_ 2.0\n"
+                 "$node_(0) set Z_ 3.0\n"
+                 "$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n"
+                 "$node_(2) set X_ 0.0\n"
+                 "$node_(2) set Y_ 0.0\n"
+                 "$ns_ at 1.0 \"$node_(2) setdest 5  0  5\"\n"
+                 "$ns_ at 2.0 \"$node_(2) setdest 5  5  5\"\n"
+                 "$ns_ at 3.0 \"$node_(2) setdest 0  5  5\"\n"
+                 "$ns_ at 4.0 \"$node_(2) setdest 0  0  5\"\n");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
+    t->AddReferencePoint ("1", 0, Vector (0, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("1", 1, Vector (0, 0, 0), Vector (5, 0, 0));
+    t->AddReferencePoint ("1", 6, Vector (25, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("2", 0, Vector (0, 0, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("2", 1, Vector (0, 0, 0), Vector (5,  0, 0));
+    t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0,  5, 0));
+    t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
+    t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, -5, 0));
+    t->AddReferencePoint ("2", 5, Vector (0, 0, 0), Vector (0,  0, 0));
+    AddTestCase (t);
+
+    // Test for Speed == 0, that acts as stop the node.
+    t = new Ns2MobilityHelperTest ("setdest with speed cero", Seconds (10));
+    t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n"
+                 "$ns_ at 7.0 \"$node_(0) setdest 11  22  0\"\n");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
+    t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 7, Vector (25, 0, 0), Vector (0, 0, 0));
+    AddTestCase (t);
+
+
+    // Test negative positions
+    t = new Ns2MobilityHelperTest ("test negative positions", Seconds (10));
+    t->SetTrace ("$node_(0) set X_ -1.0\n"
+                 "$node_(0) set Y_ 0\n"
+                 "$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n"
+                 "$ns_ at 2.0 \"$node_(0) setdest 0  -1  1\"\n");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (-1, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 1, Vector (-1, 0, 0), Vector (1, 0, 0));
+    t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, -1, 0));
+    t->AddReferencePoint ("0", 3, Vector (0, -1, 0), Vector (0, 0, 0));
+    AddTestCase (t);
+
+    // Sqare setdest with values in the form 1.0e+2
+    t = new Ns2MobilityHelperTest ("Foalt numbers in 1.0e+2 format", Seconds (6));
+    t->SetTrace ("$node_(0) set X_ 0.0\n"
+                 "$node_(0) set Y_ 0.0\n"
+                 "$ns_ at 1.0 \"$node_(0) setdest 1.0e+2  0       1.0e+2\"\n"
+                 "$ns_ at 2.0 \"$node_(0) setdest 1.0e+2  1.0e+2  1.0e+2\"\n"
+                 "$ns_ at 3.0 \"$node_(0) setdest 0       1.0e+2  1.0e+2\"\n"
+                 "$ns_ at 4.0 \"$node_(0) setdest 0       0       1.0e+2\"\n");
+    //                     id  t  position         velocity
+    t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (100,  0, 0));
+    t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0,  100, 0));
+    t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (0,  0, 0));
+    t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (-100, 0, 0));
+    t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, 0, 0));
+    t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, -100, 0));
+    t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0,  0, 0));
+    AddTestCase (t);
+
+  }
+} g_ns2TransmobilityHelperTestSuite;
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/helper/ns2-mobility-helper.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,136 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *               2009,2010 Contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ * Contributors: Thomas Waldecker <twaldecker@rocketmail.com>
+ *               Martín Giachino <martin.giachino@gmail.com>
+ */
+#ifndef NS2_MOBILITY_HELPER_H
+#define NS2_MOBILITY_HELPER_H
+
+#include <string>
+#include <stdint.h>
+#include "ns3/ptr.h"
+#include "ns3/object.h"
+
+namespace ns3 {
+
+class ConstantVelocityMobilityModel;
+
+/**
+ * \ingroup mobility
+ * \brief Helper class which can read ns-2 movement files and configure nodes mobility.
+ * 
+ * This implementation is based on the ns2 movement documentation of ns2
+ * as described in http://www.isi.edu/nsnam/ns/doc/node174.html
+ *
+ * Valid trace files use the following ns2 statements:
+ \verbatim
+   $node set X_ x1
+   $node set Y_ y1
+   $node set Z_ z1
+   $ns at $time $node setdest x2 y2 speed
+   $ns at $time $node set X_ x1
+   $ns at $time $node set Y_ Y1
+   $ns at $time $node set Z_ Z1
+ \endverbatim
+ *
+ * Following tools are known to support this format:
+ *  - BonnMotion http://net.cs.uni-bonn.de/wg/cs/applications/bonnmotion/
+ *  - SUMO http://sourceforge.net/apps/mediawiki/sumo/index.php?title=Main_Page
+ *  - TraNS http://trans.epfl.ch/ 
+ *  
+ *  See usage example in examples/mobility/ns2-mobility-trace.cc
+ */
+class Ns2MobilityHelper
+{
+public:
+  /**
+   * \param filename filename of file which contains the
+   *        ns2 movement trace.
+   */
+  Ns2MobilityHelper (std::string filename);
+
+  /**
+   * Read the ns2 trace file and configure the movement
+   * patterns of all nodes contained in the global ns3::NodeList
+   * whose nodeId is matches the nodeId of the nodes in the trace
+   * file.
+   */
+  void Install (void) const;
+
+  /**
+   * \param begin an iterator which points to the start of the input
+   *        object array.
+   * \param end an iterator which points to the end of the input
+   *        object array.
+   *
+   * Read the ns2 trace file and configure the movement
+   * patterns of all input objects. Each input object
+   * is identified by a unique node id which reflects
+   * the index of the object in the input array.
+   */
+  template <typename T>
+  void Install (T begin, T end) const;
+private:
+  class ObjectStore
+  {
+  public:
+    virtual ~ObjectStore () {}
+    virtual Ptr<Object> Get (uint32_t i) const = 0;
+  };
+  void ConfigNodesMovements (const ObjectStore &store) const;
+  Ptr<ConstantVelocityMobilityModel> GetMobilityModel (std::string idString, const ObjectStore &store) const;
+  std::string m_filename;
+};
+
+} // namespace ns3
+
+namespace ns3 {
+
+template <typename T>
+void 
+Ns2MobilityHelper::Install (T begin, T end) const
+{
+  class MyObjectStore : public ObjectStore
+  {
+  public:
+    MyObjectStore (T begin, T end)
+      : m_begin (begin),
+      m_end (end)
+        {}
+    virtual Ptr<Object> Get (uint32_t i) const {
+      T iterator = m_begin;
+      iterator += i;
+      if (iterator >= m_end)
+        {
+          return 0;
+        }
+      return *iterator;
+    }
+  private:
+    T m_begin;
+    T m_end;
+  };
+  ConfigNodesMovements (MyObjectStore (begin, end));
+}
+
+
+} // namespace ns3
+
+#endif /* NS2_MOBILITY_HELPER_H */
--- a/src/mobility/hierarchical-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "hierarchical-mobility-model.h"
-#include "ns3/pointer.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (HierarchicalMobilityModel);
-
-TypeId 
-HierarchicalMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::HierarchicalMobilityModel")
-    .SetParent<MobilityModel> ()
-    .AddConstructor<HierarchicalMobilityModel> ()
-    .AddAttribute ("Child", "The child mobility model.",
-                   PointerValue (),
-                   MakePointerAccessor (&HierarchicalMobilityModel::SetChild,
-                                        &HierarchicalMobilityModel::GetChild),
-                   MakePointerChecker<MobilityModel> ())
-    .AddAttribute ("Parent", "The parent mobility model.",
-                   PointerValue (),
-                   MakePointerAccessor (&HierarchicalMobilityModel::SetParent,
-                                        &HierarchicalMobilityModel::GetParent),
-                   MakePointerChecker<MobilityModel> ())
-    ;
-  return tid;
-}
-
-HierarchicalMobilityModel::HierarchicalMobilityModel ()
-  : m_child (0),
-    m_parent (0)
-{}
-
-void 
-HierarchicalMobilityModel::SetChild (Ptr<MobilityModel> model)
-{
-  Ptr<MobilityModel> oldChild = m_child;
-  Vector pos;
-  if (m_child)
-    {
-      pos = GetPosition ();
-      m_child->TraceDisconnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
-    }
-  m_child = model;
-  m_child->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
-
-  // if we had a child before, then we had a valid position before;
-  // try to preserve the old absolute position.
-  if (oldChild)
-    {
-      SetPosition (pos);
-    }
-}
-
-void 
-HierarchicalMobilityModel::SetParent (Ptr<MobilityModel> model)
-{
-  Vector pos;
-  if (m_child)
-    {
-      pos = GetPosition ();
-    }
-  if (m_parent)
-    {
-      m_parent->TraceDisconnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
-    }
-  m_parent = model;
-  if (m_parent)
-    {
-      m_parent->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
-    }
-  // try to preserve the old position across parent changes
-  if (m_child)
-    {
-      SetPosition (pos);
-    }
-}
-
-
-Ptr<MobilityModel> 
-HierarchicalMobilityModel::GetChild (void) const
-{
-  return m_child;
-}
-
-Ptr<MobilityModel> 
-HierarchicalMobilityModel::GetParent (void) const
-{
-  return m_parent;
-}
-
-Vector
-HierarchicalMobilityModel::DoGetPosition (void) const
-{
-  if (!m_parent)
-    {
-      return m_child->GetPosition ();
-    }
-  Vector parentPosition = m_parent->GetPosition ();
-  Vector childPosition = m_child->GetPosition ();
-  return Vector (parentPosition.x + childPosition.x,
-		   parentPosition.y + childPosition.y,
-		   parentPosition.z + childPosition.z);
-}
-void 
-HierarchicalMobilityModel::DoSetPosition (const Vector &position)
-{
-  if (m_child == 0)
-    {
-      return;
-    }
-  // This implementation of DoSetPosition is really an arbitraty choice.
-  // anything else would have been ok.
-  if (m_parent)
-    {
-      Vector parentPosition = m_parent->GetPosition ();
-      Vector childPosition (position.x - parentPosition.x,
-                            position.y - parentPosition.y,
-                            position.z - parentPosition.z);
-      m_child->SetPosition (childPosition);
-    }
-  else
-    {
-      m_child->SetPosition (position);
-    }
-}
-Vector
-HierarchicalMobilityModel::DoGetVelocity (void) const
-{
-  if (m_parent)
-    {
-      Vector parentSpeed = m_parent->GetVelocity ();
-      Vector childSpeed = m_child->GetVelocity ();
-      Vector speed (parentSpeed.x + childSpeed.x,
-                    parentSpeed.y + childSpeed.y,
-                    parentSpeed.z + childSpeed.z);
-      return speed;
-    }
-  else
-    {
-      return m_child->GetVelocity ();
-    }
-}
-
-void 
-HierarchicalMobilityModel::ParentChanged (Ptr<const MobilityModel> model)
-{
-  MobilityModel::NotifyCourseChange ();
-}
-
-void 
-HierarchicalMobilityModel::ChildChanged (Ptr<const MobilityModel> model)
-{
-  MobilityModel::NotifyCourseChange ();
-}
-
-
-
-} // namespace ns3
--- a/src/mobility/hierarchical-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef HIERARCHICAL_MOBILITY_MODEL_H
-#define HIERARCHICAL_MOBILITY_MODEL_H
-
-#include "mobility-model.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Hierarchical mobility model.
- * 
- * This model allows you to specify the position of a child object
- * relative to a parent object.
- * 
- * Basically this is a mobility model that combines two other mobility
- * models: a "parent" model and a "child" model.  The position of the
- * hierarchical model is always the vector sum of the parent + child
- * positions, so that if the parent model "moves", then this model
- * will report an equal relative movement.  Useful, for instance, if
- * you want to simulate a node inside another node that moves, such as
- * a vehicle.
- *
- * Setting the position on this model is always done using world
- * absolute coordinates, and it changes only the child mobility model
- * position, never the parent.  The child mobility model always uses a
- * coordinate system relative to the parent model position.
- *
- * \note: as a special case, the parent model may be NULL, which is
- * semantically equivalent to having a ConstantPositionMobilityModel
- * as parent positioned at origin (0,0,0).  In other words, setting
- * the parent model to NULL makes the child model and the hierarchical
- * model start using world absolute coordinates.
- *
- * \warning: changing the parent/child mobility models in the middle
- * of a simulation will probably not play very well with the
- * ConfigStore APIs, so do this only if you know what you are doing.
- */
-class HierarchicalMobilityModel : public MobilityModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  HierarchicalMobilityModel ();
-
-  /**
-   * \return the child mobility model.
-   *
-   * This allows you to get access to the position of the child
-   * relative to its parent.
-   */
-  Ptr<MobilityModel> GetChild (void) const;
-  /**
-   * \return the parent mobility model.
-   *
-   * This allows you to get access to the position of the 
-   * parent mobility model which is used as the reference 
-   * position by the child mobility model.
-   */
-  Ptr<MobilityModel> GetParent (void) const;
-  /**
-   * Sets the child mobility model to a new one.  If before there
-   * already existed a child model, then the child mobility model
-   * current position is also modified to ensure that the composite
-   * position is preserved.
-   * \param model new mobility model child
-   */
-  void SetChild (Ptr<MobilityModel> model);
-  /**
-   * Sets the parent mobility model to a new one.  If before there
-   * already existed a child model, then the child mobility model
-   * current position is also modified to ensure that the composite
-   * position is preserved.
-   * \param model new mobility model parent
-   */
-  void SetParent (Ptr<MobilityModel> model);
-  
-private:
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  void ParentChanged (Ptr<const MobilityModel> model);
-  void ChildChanged (Ptr<const MobilityModel> model);
-
-  Ptr<MobilityModel> m_child;
-  Ptr<MobilityModel> m_parent;
-};
-
-
-} // namespace ns3
-
-#endif /* HIERARCHICAL_MOBILITY_MODEL_H */
--- a/src/mobility/mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-
-#include <math.h>
-
-#include "mobility-model.h"
-#include "ns3/trace-source-accessor.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (MobilityModel);
-
-TypeId 
-MobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::MobilityModel")
-    .SetParent<Object> ()
-    .AddAttribute ("Position", "The current position of the mobility model.",
-                   TypeId::ATTR_SET | TypeId::ATTR_GET,
-                   VectorValue (Vector (0.0, 0.0, 0.0)),
-                   MakeVectorAccessor (&MobilityModel::SetPosition,
-                                        &MobilityModel::GetPosition),
-                   MakeVectorChecker ())
-    .AddAttribute ("Velocity", "The current velocity of the mobility model.",
-                   TypeId::ATTR_GET,
-                   VectorValue (Vector (0.0, 0.0, 0.0)), // ignored initial value.
-                   MakeVectorAccessor (&MobilityModel::GetVelocity),
-                   MakeVectorChecker ())
-    .AddTraceSource ("CourseChange", 
-                     "The value of the position and/or velocity vector changed",
-                     MakeTraceSourceAccessor (&MobilityModel::m_courseChangeTrace))
-    ;
-  return tid;
-}
-
-MobilityModel::MobilityModel ()
-{}
-
-MobilityModel::~MobilityModel ()
-{}
-
-Vector
-MobilityModel::GetPosition (void) const
-{
-  return DoGetPosition ();
-}
-Vector
-MobilityModel::GetVelocity (void) const
-{
-  return DoGetVelocity ();
-}
-
-void 
-MobilityModel::SetPosition (const Vector &position)
-{
-  DoSetPosition (position);
-}
-
-double 
-MobilityModel::GetDistanceFrom (Ptr<const MobilityModel> other) const
-{
-  Vector oPosition = other->DoGetPosition ();
-  Vector position = DoGetPosition ();
-  return CalculateDistance (position, oPosition);
-}
-
-void
-MobilityModel::NotifyCourseChange (void) const
-{
-  m_courseChangeTrace(this);
-}
-
-} // namespace ns3
--- a/src/mobility/mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef MOBILITY_MODEL_H
-#define MOBILITY_MODEL_H
-
-#include "ns3/vector.h"
-#include "ns3/object.h"
-#include "ns3/traced-callback.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Keep track of the current position and velocity of an object.
- *
- * All space coordinates in this class and its subclasses are
- * understood to be meters or meters/s. i.e., they are all
- * metric international units.
- *
- * This is a base class for all specific mobility models.
- */
-class MobilityModel : public Object
-{
-public:
-  static TypeId GetTypeId (void);
-  MobilityModel ();
-  virtual ~MobilityModel () = 0;
-
-  /**
-   * \return the current position
-   */
-  Vector GetPosition (void) const;
-  /**
-   * \param position the position to set.
-   */
-  void SetPosition (const Vector &position);
-  /**
-   * \return the current velocity.
-   */
-  Vector GetVelocity (void) const;
-  /**
-   * \param position a reference to another mobility model
-   * \return the distance between the two objects. Unit is meters.
-   */
-  double GetDistanceFrom (Ptr<const MobilityModel> position) const;
-protected:
-  /**
-   * Must be invoked by subclasses when the course of the
-   * position changes to notify course change listeners.
-   */
-  void NotifyCourseChange (void) const;
-private:
-  /**
-   * \return the current position.
-   *
-   * Concrete subclasses of this base class must 
-   * implement this method.
-   */
-  virtual Vector DoGetPosition (void) const = 0;
-  /**
-   * \param position the position to set.
-   *
-   * Concrete subclasses of this base class must 
-   * implement this method.
-   */
-  virtual void DoSetPosition (const Vector &position) = 0;
-  /**
-   * \return the current velocity.
-   *
-   * Concrete subclasses of this base class must 
-   * implement this method.
-   */
-  virtual Vector DoGetVelocity (void) const = 0;
-
-  /**
-   * Used to alert subscribers that a change in direction, velocity,
-   * or position has occurred.
-   */
-  TracedCallback<Ptr<const MobilityModel> > m_courseChangeTrace;
-
-};
-
-}; // namespace ns3
-
-#endif /* MOBILITY_MODEL_H */
--- a/src/mobility/mobility.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/**
- * \addtogroup mobility Mobility
- *
- * The mobility support includes:
- *  - a set of mobility models which are used to track and maintain
- *    the "current" cartesian position and speed of an object.
- *
- *  - a "course change notifier" trace source which can be used to register
- *    listeners to the course changes of a mobility model
- * 
- *  - a number of helper classes which are used to place nodes and setup 
- *    mobility models (including parsers for some mobility definition formats).
- */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/box.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,169 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Dan Broyles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Dan Broyles <dbroyl01@ku.edu>
+ */
+
+#include "box.h"
+#include "ns3/vector.h"
+#include "ns3/assert.h"
+#include "ns3/fatal-error.h"
+#include <cmath>
+#include <algorithm>
+#include <sstream> 
+
+namespace ns3 {
+
+Box::Box (double _xMin, double _xMax,
+          double _yMin, double _yMax,
+          double _zMin, double _zMax)
+  : xMin (_xMin),
+    xMax (_xMax),
+    yMin (_yMin),
+    yMax (_yMax),
+    zMin (_zMin),
+    zMax (_zMax)
+{}
+
+Box::Box ()
+  : xMin (0.0),
+    xMax (0.0),
+    yMin (0.0),
+    yMax (0.0),
+    zMin (0.0),
+    zMax (0.0)
+{}
+
+bool 
+Box::IsInside (const Vector &position) const
+{
+  return 
+    position.x <= this->xMax && position.x >= this->xMin &&
+    position.y <= this->yMax && position.y >= this->yMin &&
+    position.z <= this->zMax && position.z >= this->zMin;
+}
+
+Box::Side 
+Box::GetClosestSide (const Vector &position) const
+{
+  double xMinDist = std::abs (position.x - this->xMin);
+  double xMaxDist = std::abs (this->xMax - position.x);
+  double yMinDist = std::abs (position.y - this->yMin);
+  double yMaxDist = std::abs (this->yMax - position.y);
+  double zMinDist = std::abs (position.z - this->zMin);
+  double zMaxDist = std::abs (this->zMax - position.z);
+  double minX = std::min (xMinDist, xMaxDist);
+  double minY = std::min (yMinDist, yMaxDist);
+  double minZ = std::min (zMinDist, zMaxDist);
+  if (minX < minY && minX < minZ)
+    {
+      if (xMinDist < xMaxDist)
+        {
+          return LEFT;
+        }
+      else
+        {
+          return RIGHT;
+        }
+    }
+  else if (minY < minZ)
+    {
+      if (yMinDist < yMaxDist)
+        {
+          return BOTTOM;
+        }
+      else
+        {
+          return TOP;
+        }
+    }
+  else
+    {
+      if (zMinDist < zMaxDist)
+        {
+          return DOWN;
+        }
+      else
+        {
+          return UP;
+        }
+    }
+}
+
+Vector
+Box::CalculateIntersection (const Vector &current, const Vector &speed) const
+{
+  NS_ASSERT (IsInside (current));
+  double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
+  double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y;
+  double yMaxX = current.x + (this->yMax - current.y) / speed.y * speed.x;
+  double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x;
+  bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin);
+  bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin);
+  bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin);
+  bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin);
+  if (xMaxYOk && speed.x >= 0)
+    {
+      return Vector (this->xMax, xMaxY, 0.0);
+    }
+  else if (xMinYOk && speed.x <= 0)
+    {
+      return Vector (this->xMin, xMinY, 0.0);
+    }
+  else if (yMaxXOk && speed.y >= 0)
+    {
+      return Vector (yMaxX, this->yMax, 0.0);
+    }
+  else if (yMinXOk && speed.y <= 0)
+    {
+      return Vector (yMinX, this->yMin, 0.0);
+    }
+  else
+    {
+      NS_ASSERT (false);
+      // quiet compiler
+      return Vector (0.0, 0.0, 0.0);
+    }
+
+}
+
+ATTRIBUTE_HELPER_CPP (Box);
+
+std::ostream &
+operator << (std::ostream &os, const Box &box)
+{
+  os << box.xMin << "|" << box.xMax << "|" << box.yMin << "|" << box.yMax << "|" << box.zMin << "|" << box.zMax;
+  return os;
+}
+std::istream &
+operator >> (std::istream &is, Box &box)
+ {
+  char c1, c2, c3, c4, c5;
+  is >> box.xMin >> c1 >> box.xMax >> c2 >> box.yMin >> c3 >> box.yMax >> c4 >> box.zMin >> c5 >> box.zMax;
+  if (c1 != '|' ||
+      c2 != '|' ||
+      c3 != '|' ||
+      c4 != '|' ||
+      c5 != '|')
+    {
+      is.setstate (std::ios_base::failbit);
+    }
+  return is;
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/box.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,114 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Dan Broyles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Dan Broyles <dbroyl01@ku.edu>
+ */
+#ifndef BOX_H
+#define BOX_H
+
+#include "ns3/attribute.h"
+#include "ns3/attribute-helper.h"
+#include "ns3/vector.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief a 3d box
+ */
+class Box
+{
+public:
+  enum Side {
+    RIGHT,
+    LEFT,
+    TOP,
+    BOTTOM,
+    UP,
+    DOWN
+  };
+  /**
+   * \param _xMin x coordinates of left boundary.
+   * \param _xMax x coordinates of right boundary.
+   * \param _yMin y coordinates of bottom boundary.
+   * \param _yMax y coordinates of top boundary.
+   * \param _zMin z coordinates of down boundary.
+   * \param _zMax z coordinates of up boundary.
+   *
+   * Create a box.
+   */
+  Box (double _xMin, double _xMax,
+       double _yMin, double _yMax,
+       double _zMin, double _zMax);
+  /**
+   * Create a zero-sized box located at coordinates (0.0,0.0,0.0)
+   */
+  Box ();
+  /**
+   * \param position the position to test.
+   * \returns true if the input position is located within the box, 
+   *          false otherwise.
+   *
+   * This method compares the x, y, and z coordinates of the input position.
+   */
+  bool IsInside (const Vector &position) const;
+  /**
+   * \param position the position to test.
+   * \returns the side of the cube the input position is closest to.
+   *
+   * This method compares the x, y, and z coordinates of the input position.
+   */
+  Side GetClosestSide (const Vector &position) const;
+  /**
+   * \param current the current position
+   * \param speed the current speed
+   * \returns the intersection point between the rectangle and the current+speed vector.
+   *
+   * This method assumes that the current position is located _inside_
+   * the cube and checks for this with an assert.
+   * This method compares only the x and y coordinates of the input position
+   * and speed. It ignores the z coordinate.
+   */
+  Vector CalculateIntersection (const Vector &current, const Vector &speed) const;
+
+  /* The x coordinate of the left bound of the box */
+  double xMin;
+  /* The x coordinate of the right bound of the box */
+  double xMax;
+  /* The y coordinate of the bottom bound of the box */
+  double yMin;
+  /* The y coordinate of the top bound of the box */
+  double yMax;
+  /* The z coordinate of the down bound of the box */
+  double zMin;
+  /* The z coordinate of the up bound of the box */
+  double zMax;
+};
+
+std::ostream &operator << (std::ostream &os, const Box &box);
+std::istream &operator >> (std::istream &is, Box &box);
+
+/**
+ * \class ns3::BoxValue
+ * \brief hold objects of type ns3::Box
+ */
+
+ATTRIBUTE_HELPER_HEADER (Box);
+
+} // namespace ns3
+
+#endif /* BOX_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-acceleration-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,79 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Gustavo Carneiro  <gjc@inescporto.pt>
+ */
+#include "constant-acceleration-mobility-model.h"
+#include "ns3/simulator.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (ConstantAccelerationMobilityModel);
+
+TypeId ConstantAccelerationMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ConstantAccelerationMobilityModel")
+    .SetParent<MobilityModel> ()
+    .AddConstructor<ConstantAccelerationMobilityModel> ();
+  return tid;
+}
+
+ConstantAccelerationMobilityModel::ConstantAccelerationMobilityModel ()
+{}
+
+ConstantAccelerationMobilityModel::~ConstantAccelerationMobilityModel ()
+{}
+
+inline Vector
+ConstantAccelerationMobilityModel::DoGetVelocity (void) const
+{
+  double t = (Simulator::Now () - m_baseTime).GetSeconds ();
+  return Vector (m_baseVelocity.x + m_acceleration.x*t,
+                 m_baseVelocity.y + m_acceleration.y*t,
+                 m_baseVelocity.z + m_acceleration.z*t);
+}
+
+inline Vector
+ConstantAccelerationMobilityModel::DoGetPosition (void) const
+{
+  double t = (Simulator::Now () - m_baseTime).GetSeconds ();
+  double half_t_square = t*t*0.5;
+  return Vector (m_basePosition.x + m_baseVelocity.x*t + m_acceleration.x*half_t_square,
+                 m_basePosition.y + m_baseVelocity.y*t + m_acceleration.y*half_t_square,
+                 m_basePosition.z + m_baseVelocity.z*t + m_acceleration.z*half_t_square);
+}
+
+void 
+ConstantAccelerationMobilityModel::DoSetPosition (const Vector &position)
+{
+  m_baseVelocity = DoGetVelocity ();
+  m_baseTime = Simulator::Now ();
+  m_basePosition = position;
+  NotifyCourseChange ();
+}
+
+void 
+ConstantAccelerationMobilityModel::SetVelocityAndAcceleration (const Vector &velocity,
+                                                               const Vector &acceleration)
+{
+  m_basePosition = DoGetPosition ();
+  m_baseTime = Simulator::Now ();
+  m_baseVelocity = velocity;
+  m_acceleration = acceleration;
+  NotifyCourseChange ();
+}
+
+
+}; // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-acceleration-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,56 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Gustavo Carneiro  <gjc@inescporto.pt>
+ */
+#ifndef CONSTANT_ACCELERATION_MOBILITY_MODEL_H
+#define CONSTANT_ACCELERATION_MOBILITY_MODEL_H
+
+#include "mobility-model.h"
+#include "ns3/nstime.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ *
+ * \brief Mobility model for which the current acceleration does not change once it has been set and until it is set again explicitely to a new value.
+ */
+class ConstantAccelerationMobilityModel : public MobilityModel 
+{
+public:
+  static TypeId GetTypeId (void);
+  /**
+   * Create position located at coordinates (0,0,0) with
+   * speed (0,0,0).
+   */
+  ConstantAccelerationMobilityModel ();
+  virtual ~ConstantAccelerationMobilityModel ();
+  void SetVelocityAndAcceleration (const Vector &velocity, const Vector &acceleration);
+
+private:
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  Time m_baseTime;
+  Vector m_basePosition;
+  Vector m_baseVelocity;
+  Vector m_acceleration;
+};
+
+}; // namespace ns3
+
+#endif /* CONSTANT_ACCELERATION_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-position-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,58 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "constant-position-mobility-model.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (ConstantPositionMobilityModel);
+
+TypeId
+ConstantPositionMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ConstantPositionMobilityModel")
+    .SetParent<MobilityModel> ()
+    .AddConstructor<ConstantPositionMobilityModel> ()
+    ;
+  return tid;
+}
+  
+ConstantPositionMobilityModel::ConstantPositionMobilityModel ()
+{}
+ConstantPositionMobilityModel::~ConstantPositionMobilityModel ()
+{}
+
+Vector
+ConstantPositionMobilityModel::DoGetPosition (void) const
+{
+  return m_position;
+}
+void 
+ConstantPositionMobilityModel::DoSetPosition (const Vector &position)
+{
+  m_position = position;
+  NotifyCourseChange ();
+}
+Vector
+ConstantPositionMobilityModel::DoGetVelocity (void) const
+{
+  return Vector (0.0, 0.0, 0.0);
+}
+
+}; // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-position-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,52 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef CONSTANT_POSITION_MOBILITY_MODEL_H
+#define CONSTANT_POSITION_MOBILITY_MODEL_H
+
+#include "mobility-model.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ *
+ * \brief Mobility model for which the current position does not change once it has been set and until it is set again explicitely to a new value.
+ */
+class ConstantPositionMobilityModel : public MobilityModel 
+{
+public:
+  static TypeId GetTypeId (void);
+  /**
+   * Create a position located at coordinates (0,0,0)
+   */
+  ConstantPositionMobilityModel ();
+  virtual ~ConstantPositionMobilityModel ();
+
+private:
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  Vector m_position;
+};
+
+}; // namespace ns3
+
+#endif /* CONSTANT_POSITION_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-velocity-helper.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,117 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "ns3/simulator.h"
+#include "ns3/rectangle.h"
+#include "ns3/box.h"
+#include "constant-velocity-helper.h"
+
+namespace ns3 {
+
+ConstantVelocityHelper::ConstantVelocityHelper ()
+  : m_paused (true)
+{}
+ConstantVelocityHelper::ConstantVelocityHelper (const Vector &position)
+  : m_position (position),
+    m_paused (true)
+{}
+ConstantVelocityHelper::ConstantVelocityHelper (const Vector &position,
+				      const Vector &vel)
+  : m_position (position),
+    m_velocity (vel),
+    m_paused (true)
+{}
+void 
+ConstantVelocityHelper::SetPosition (const Vector &position)
+{
+  m_position = position;
+  m_velocity = Vector (0.0, 0.0, 0.0);
+  m_lastUpdate = Simulator::Now ();
+}
+
+Vector
+ConstantVelocityHelper::GetCurrentPosition (void) const
+{
+  return m_position;
+}
+
+Vector 
+ConstantVelocityHelper::GetVelocity (void) const
+{
+  return m_paused? Vector (0.0, 0.0, 0.0) : m_velocity;
+}
+void 
+ConstantVelocityHelper::SetVelocity (const Vector &vel)
+{
+  m_velocity = vel;
+  m_lastUpdate = Simulator::Now ();
+}
+
+void
+ConstantVelocityHelper::Update (void) const
+{
+  Time now = Simulator::Now ();
+  NS_ASSERT (m_lastUpdate <= now);
+  Time deltaTime = now - m_lastUpdate;
+  m_lastUpdate = now;
+  if (m_paused)
+    {
+      return;
+    }
+  double deltaS = deltaTime.GetSeconds ();
+  m_position.x += m_velocity.x * deltaS;
+  m_position.y += m_velocity.y * deltaS;
+  m_position.z += m_velocity.z * deltaS;
+}
+
+void
+ConstantVelocityHelper::UpdateWithBounds (const Rectangle &bounds) const
+{
+  Update ();
+  m_position.x = std::min (bounds.xMax, m_position.x);
+  m_position.x = std::max (bounds.xMin, m_position.x);
+  m_position.y = std::min (bounds.yMax, m_position.y);
+  m_position.y = std::max (bounds.yMin, m_position.y);
+}
+
+void
+ConstantVelocityHelper::UpdateWithBounds (const Box &bounds) const
+{
+  Update ();
+  m_position.x = std::min (bounds.xMax, m_position.x);
+  m_position.x = std::max (bounds.xMin, m_position.x);
+  m_position.y = std::min (bounds.yMax, m_position.y);
+  m_position.y = std::max (bounds.yMin, m_position.y);
+  m_position.z = std::min (bounds.zMax, m_position.z);
+  m_position.z = std::max (bounds.zMin, m_position.z);
+}
+
+void 
+ConstantVelocityHelper::Pause (void)
+{
+  m_paused = true;
+}
+
+void 
+ConstantVelocityHelper::Unpause (void)
+{
+  m_paused = false;
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-velocity-helper.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,63 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef CONSTANT_VELOCITY_HELPER_H
+#define CONSTANT_VELOCITY_HELPER_H
+
+#include "ns3/nstime.h"
+#include "ns3/vector.h"
+#include "ns3/box.h"
+
+namespace ns3 {
+
+class Rectangle;
+
+/**
+ * \ingroup mobility
+ *
+ * \brief Utility class used to move node with constant velocity.
+ */
+class ConstantVelocityHelper
+{
+ public:
+  ConstantVelocityHelper ();
+  ConstantVelocityHelper (const Vector &position);
+  ConstantVelocityHelper (const Vector &position,
+		     const Vector &vel);
+
+  void SetPosition (const Vector &position);
+  Vector GetCurrentPosition (void) const;
+  Vector GetVelocity (void) const;
+  void SetVelocity (const Vector &vel);
+  void Pause (void);
+  void Unpause (void);
+
+  void UpdateWithBounds (const Rectangle &rectangle) const;
+  void UpdateWithBounds (const Box &bounds) const;
+  void Update (void) const;
+ private:
+  mutable Time m_lastUpdate;
+  mutable Vector m_position;
+  Vector m_velocity;
+  bool m_paused;
+};
+
+} // namespace ns3
+
+#endif /* CONSTANT_VELOCITY_HELPER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-velocity-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,69 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006, 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "constant-velocity-mobility-model.h"
+#include "ns3/simulator.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (ConstantVelocityMobilityModel);
+
+TypeId ConstantVelocityMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ConstantVelocityMobilityModel")
+    .SetParent<MobilityModel> ()
+    .AddConstructor<ConstantVelocityMobilityModel> ();
+  return tid;
+}
+
+ConstantVelocityMobilityModel::ConstantVelocityMobilityModel ()
+{}
+
+ConstantVelocityMobilityModel::~ConstantVelocityMobilityModel ()
+{}
+
+void 
+ConstantVelocityMobilityModel::SetVelocity (const Vector &speed)
+{
+  m_helper.Update ();
+  m_helper.SetVelocity (speed);
+  m_helper.Unpause ();
+  NotifyCourseChange ();
+}
+
+
+Vector
+ConstantVelocityMobilityModel::DoGetPosition (void) const
+{
+  m_helper.Update ();
+  return m_helper.GetCurrentPosition ();
+}
+void 
+ConstantVelocityMobilityModel::DoSetPosition (const Vector &position)
+{
+  m_helper.SetPosition (position);
+  NotifyCourseChange ();
+}
+Vector
+ConstantVelocityMobilityModel::DoGetVelocity (void) const
+{
+  return m_helper.GetVelocity ();
+}
+
+}; // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/constant-velocity-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,63 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006, 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef CONSTANT_VELOCITY_MOBILITY_MODEL_H
+#define CONSTANT_VELOCITY_MOBILITY_MODEL_H
+
+#include <stdint.h>
+#include "ns3/nstime.h"
+#include "mobility-model.h"
+#include "constant-velocity-helper.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ *
+ * \brief Mobility model for which the current speed does not change once it has been set and until it is set again explicitely to a new value.
+ */
+class ConstantVelocityMobilityModel : public MobilityModel 
+{
+public:
+  static TypeId GetTypeId (void);
+  /**
+   * Create position located at coordinates (0,0,0) with
+   * speed (0,0,0).
+   */
+  ConstantVelocityMobilityModel ();
+  virtual ~ConstantVelocityMobilityModel ();
+
+  /**
+   * \param speed the new speed to set.
+   *
+   * Set the current speed now to (dx,dy,dz)
+   * Unit is meters/s
+   */
+  void SetVelocity (const Vector &speed);
+private:
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+  void Update (void) const;
+  ConstantVelocityHelper m_helper;
+};
+
+}; // namespace ns3
+
+#endif /* CONSTANT_VELOCITY_POSITION */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/gauss-markov-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,222 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Dan Broyles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Dan Broyles <dbroyl01@ku.edu>
+ */
+#include <cmath>
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/double.h"
+#include "ns3/pointer.h"
+#include "gauss-markov-mobility-model.h"
+#include "position-allocator.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (GaussMarkovMobilityModel);
+
+TypeId
+GaussMarkovMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::GaussMarkovMobilityModel")
+    .SetParent<MobilityModel> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<GaussMarkovMobilityModel> ()
+    .AddAttribute ("Bounds",
+                   "Bounds of the area to cruise.",
+                   BoxValue (Box (-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)),
+                   MakeBoxAccessor (&GaussMarkovMobilityModel::m_bounds),
+                   MakeBoxChecker ())
+    .AddAttribute ("TimeStep",
+                   "Change current direction and speed after moving for this time.",
+                   TimeValue (Seconds (1.0)),
+                   MakeTimeAccessor (&GaussMarkovMobilityModel::m_timeStep),
+                   MakeTimeChecker ())
+    .AddAttribute ("Alpha",
+                   "A constant representing the tunable parameter in the Gauss-Markov model.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&GaussMarkovMobilityModel::m_alpha),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MeanVelocity",
+                   "A random variable used to assign the average velocity.",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),  
+                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_rndMeanVelocity),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("MeanDirection",
+                   "A random variable used to assign the average direction.",
+                   RandomVariableValue (UniformVariable (0.0, 6.283185307)),  
+                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_rndMeanDirection),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("MeanPitch",
+                   "A random variable used to assign the average pitch.",
+                   RandomVariableValue (ConstantVariable (0.0)),  
+                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_rndMeanPitch),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("NormalVelocity",
+                   "A gaussian random variable used to calculate the next velocity value.",
+                   RandomVariableValue (NormalVariable (0.0, 1.0, 10.0)), // Defaults to zero mean, and std dev = 1, and bound to +-10 of the mean
+                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_normalVelocity),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("NormalDirection",
+                   "A gaussian random variable used to calculate the next direction value.",
+                   RandomVariableValue (NormalVariable (0.0, 1.0, 10.0)),
+                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_normalDirection),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("NormalPitch",
+                   "A gaussian random variable used to calculate the next pitch value.",
+                   RandomVariableValue (NormalVariable (0.0, 1.0, 10.0)),
+                   MakeRandomVariableAccessor (&GaussMarkovMobilityModel::m_normalPitch),
+                   MakeRandomVariableChecker ());
+  
+  return tid;
+}
+
+GaussMarkovMobilityModel::GaussMarkovMobilityModel ()
+{
+  m_meanVelocity = 0.0;
+  m_meanDirection = 0.0;
+  m_meanPitch = 0.0;
+  m_event = Simulator::ScheduleNow (&GaussMarkovMobilityModel::Start, this);
+  m_helper.Unpause ();
+}
+
+void
+GaussMarkovMobilityModel::Start (void)
+{
+  if (m_meanVelocity == 0.0)
+    {
+      //Initialize the mean velocity, direction, and pitch variables
+      m_meanVelocity = m_rndMeanVelocity.GetValue ();
+      m_meanDirection = m_rndMeanDirection.GetValue ();
+      m_meanPitch = m_rndMeanPitch.GetValue ();
+      double cosD = std::cos (m_meanDirection);
+      double cosP = std::cos (m_meanPitch);
+      double sinD = std::sin (m_meanDirection);
+      double sinP = std::sin (m_meanPitch);
+      //Initialize the starting velocity, direction, and pitch to be identical to the mean ones
+      m_Velocity = m_meanVelocity;
+      m_Direction = m_meanDirection;
+      m_Pitch = m_meanPitch;
+      //Set the velocity vector to give to the constant velocity helper
+      m_helper.SetVelocity (Vector (m_Velocity*cosD*cosP, m_Velocity*sinD*cosP, m_Velocity*sinP));
+    }
+  m_helper.Update ();
+
+  //Get the next values from the gaussian distributions for velocity, direction, and pitch
+  double rv = m_normalVelocity.GetValue ();
+  double rd = m_normalDirection.GetValue ();
+  double rp = m_normalPitch.GetValue ();
+
+  //Calculate the NEW velocity, direction, and pitch values using the Gauss-Markov formula:
+  //newVal = alpha*oldVal + (1-alpha)*meanVal + sqrt(1-alpha^2)*rv  
+  //where rv is a random number from a normal (gaussian) distribution
+  double one_minus_alpha = 1 - m_alpha;
+  double sqrt_alpha = std::sqrt (1 - m_alpha*m_alpha);
+  m_Velocity  = m_alpha * m_Velocity  + one_minus_alpha * m_meanVelocity  + sqrt_alpha * rv;
+  m_Direction = m_alpha * m_Direction + one_minus_alpha * m_meanDirection + sqrt_alpha * rd;
+  m_Pitch     = m_alpha * m_Pitch     + one_minus_alpha * m_meanPitch     + sqrt_alpha * rp;
+
+  //Calculate the linear velocity vector to give to the constant velocity helper
+  double cosDir = std::cos (m_Direction);
+  double cosPit = std::cos (m_Pitch);
+  double sinDir = std::sin (m_Direction);
+  double sinPit = std::sin (m_Pitch);
+  double vx = m_Velocity * cosDir * cosPit;
+  double vy = m_Velocity * sinDir * cosPit;
+  double vz = m_Velocity * sinPit;
+  m_helper.SetVelocity (Vector (vx, vy, vz));
+
+  m_helper.Unpause ();
+
+  DoWalk (m_timeStep);
+}
+
+void
+GaussMarkovMobilityModel::DoWalk (Time delayLeft)
+{
+  m_helper.UpdateWithBounds (m_bounds);
+  Vector position = m_helper.GetCurrentPosition ();
+  Vector speed = m_helper.GetVelocity ();
+  Vector nextPosition = position;
+  nextPosition.x += speed.x * delayLeft.GetSeconds ();
+  nextPosition.y += speed.y * delayLeft.GetSeconds ();
+  nextPosition.z += speed.z * delayLeft.GetSeconds ();
+  if (delayLeft.GetSeconds () < 0.0) delayLeft = Seconds (1.0);
+
+  // Make sure that the position by the next time step is still within the boundary.
+  // If out of bounds, then alter the velocity vector and average direction to keep the position in bounds
+  if (m_bounds.IsInside (nextPosition))
+    {
+      m_event = Simulator::Schedule (delayLeft, &GaussMarkovMobilityModel::Start, this);
+    }
+  else
+    {
+      if (nextPosition.x > m_bounds.xMax || nextPosition.x < m_bounds.xMin) 
+        {
+          speed.x = - speed.x;
+          m_meanDirection = 3.14159265 - m_meanDirection;
+        }
+
+      if (nextPosition.y > m_bounds.yMax || nextPosition.y < m_bounds.yMin) 
+        {
+          speed.y = - speed.y;
+          m_meanDirection = - m_meanDirection;
+        }
+
+      if (nextPosition.z > m_bounds.zMax || nextPosition.z < m_bounds.zMin) 
+        {
+          speed.z = - speed.z;
+          m_meanPitch = - m_meanPitch;
+        }
+
+      m_Direction = m_meanDirection;
+      m_Pitch = m_meanPitch;
+      m_helper.SetVelocity (speed);
+      m_helper.Unpause ();
+      m_event = Simulator::Schedule (delayLeft, &GaussMarkovMobilityModel::Start, this);
+    }
+  NotifyCourseChange ();
+}
+
+void
+GaussMarkovMobilityModel::DoDispose (void)
+{
+  // chain up
+  MobilityModel::DoDispose ();
+}
+
+Vector
+GaussMarkovMobilityModel::DoGetPosition (void) const
+{
+  m_helper.Update ();
+  return m_helper.GetCurrentPosition ();
+}
+void 
+GaussMarkovMobilityModel::DoSetPosition (const Vector &position)
+{
+  m_helper.SetPosition (position);
+  Simulator::Remove (m_event);
+  m_event = Simulator::ScheduleNow (&GaussMarkovMobilityModel::Start, this);
+}
+Vector
+GaussMarkovMobilityModel::DoGetVelocity (void) const
+{
+  return m_helper.GetVelocity ();
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/gauss-markov-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,113 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Dan Broyles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Dan Broyles <dbroyl01@ku.edu>
+ * Thanks to Kevin Peters, faculty advisor James P.G. Sterbenz, and the ResiliNets 
+ * initiative at The University of Kansas, https://wiki.ittc.ku.edu/resilinets
+ */
+#ifndef GAUSS_MARKOV_MOBILITY_MODEL_H
+#define GAUSS_MARKOV_MOBILITY_MODEL_H
+
+#include "constant-velocity-helper.h"
+#include "mobility-model.h"
+#include "position-allocator.h"
+#include "ns3/ptr.h"
+#include "ns3/object.h"
+#include "ns3/nstime.h"
+#include "ns3/event-id.h"
+#include "ns3/box.h"
+#include "ns3/random-variable.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Gauss-Markov mobility model
+ *
+ * This is a 3D version of the Gauss-Markov mobility model described in [1]. 
+ * Unlike the other mobility models in ns-3, which are memoryless, the Gauss
+ * Markov model has both memory and variability. The tunable alpha parameter
+ * determines the how much memory and randomness you want to model.
+ * Each object starts with a specific velocity, direction (radians), and pitch 
+ * angle (radians) equivalent to the mean velocity, direction, and pitch. 
+ * At each timestep, a new velocity, direction, and pitch angle are generated 
+ * based upon the previous value, the mean value, and a gaussian random variable. 
+ * This version is suited for simple airplane flight, where direction, velocity,
+ * and pitch are the key variables.
+ * The motion field is limited by a 3D bounding box (called "box") which is a 3D
+ * version of the "rectangle" field that is used in 2-dimensional ns-3 mobility models.
+ * 
+ * Here is an example of how to implement the model and set the initial node positions:
+ * \code
+    MobilityHelper mobility;
+  
+    mobility.SetMobilityModel ("ns3::GaussMarkovMobilityModel",
+      "Bounds", BoxValue (Box (0, 150000, 0, 150000, 0, 10000)),
+      "TimeStep", TimeValue (Seconds (0.5)),
+      "Alpha", DoubleValue (0.85),
+      "MeanVelocity", RandomVariableValue (UniformVariable (800, 1200)),
+      "MeanDirection", RandomVariableValue (UniformVariable (0, 6.283185307)),
+      "MeanPitch", RandomVariableValue (UniformVariable (0.05, 0.05)),
+      "NormalVelocity", RandomVariableValue (NormalVariable (0.0, 0.0, 0.0)),
+      "NormalDirection", RandomVariableValue (NormalVariable (0.0, 0.2, 0.4)),
+      "NormalPitch", RandomVariableValue (NormalVariable (0.0, 0.02, 0.04)));
+  
+    mobility.SetPositionAllocator ("ns3::RandomBoxPositionAllocator",
+      "X", RandomVariableValue (UniformVariable (0, 150000)),
+      "Y", RandomVariableValue (UniformVariable (0, 150000)),
+      "Z", RandomVariableValue (UniformVariable (0, 10000)));
+ 
+    mobility.Install (wifiStaNodes);
+ * \endcode
+ * [1] Tracy Camp, Jeff Boleng, Vanessa Davies, "A Survey of Mobility Models
+ * for Ad Hoc Network Research", Wireless Communications and Mobile Computing,
+ * Wiley, vol.2 iss.5, September 2002, pp.483-502
+ */
+class GaussMarkovMobilityModel : public MobilityModel
+{
+public:
+  static TypeId GetTypeId (void);
+  GaussMarkovMobilityModel ();
+private:
+  void Start (void);
+  void DoWalk (Time timeLeft);
+  virtual void DoDispose (void);
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+  ConstantVelocityHelper m_helper;
+  Time m_timeStep;
+  double m_alpha;
+  double m_meanVelocity;
+  double m_meanDirection;
+  double m_meanPitch;
+  double m_Velocity;
+  double m_Direction;
+  double m_Pitch;
+  RandomVariable m_rndMeanVelocity;
+  RandomVariable m_normalVelocity;
+  RandomVariable m_rndMeanDirection;
+  RandomVariable m_normalDirection;
+  RandomVariable m_rndMeanPitch;
+  RandomVariable m_normalPitch;
+  EventId m_event;
+  Box m_bounds;
+};
+
+} // namespace ns3
+
+#endif /* GAUSS_MARKOV_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/hierarchical-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,177 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "hierarchical-mobility-model.h"
+#include "ns3/pointer.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (HierarchicalMobilityModel);
+
+TypeId 
+HierarchicalMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::HierarchicalMobilityModel")
+    .SetParent<MobilityModel> ()
+    .AddConstructor<HierarchicalMobilityModel> ()
+    .AddAttribute ("Child", "The child mobility model.",
+                   PointerValue (),
+                   MakePointerAccessor (&HierarchicalMobilityModel::SetChild,
+                                        &HierarchicalMobilityModel::GetChild),
+                   MakePointerChecker<MobilityModel> ())
+    .AddAttribute ("Parent", "The parent mobility model.",
+                   PointerValue (),
+                   MakePointerAccessor (&HierarchicalMobilityModel::SetParent,
+                                        &HierarchicalMobilityModel::GetParent),
+                   MakePointerChecker<MobilityModel> ())
+    ;
+  return tid;
+}
+
+HierarchicalMobilityModel::HierarchicalMobilityModel ()
+  : m_child (0),
+    m_parent (0)
+{}
+
+void 
+HierarchicalMobilityModel::SetChild (Ptr<MobilityModel> model)
+{
+  Ptr<MobilityModel> oldChild = m_child;
+  Vector pos;
+  if (m_child)
+    {
+      pos = GetPosition ();
+      m_child->TraceDisconnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
+    }
+  m_child = model;
+  m_child->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
+
+  // if we had a child before, then we had a valid position before;
+  // try to preserve the old absolute position.
+  if (oldChild)
+    {
+      SetPosition (pos);
+    }
+}
+
+void 
+HierarchicalMobilityModel::SetParent (Ptr<MobilityModel> model)
+{
+  Vector pos;
+  if (m_child)
+    {
+      pos = GetPosition ();
+    }
+  if (m_parent)
+    {
+      m_parent->TraceDisconnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
+    }
+  m_parent = model;
+  if (m_parent)
+    {
+      m_parent->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
+    }
+  // try to preserve the old position across parent changes
+  if (m_child)
+    {
+      SetPosition (pos);
+    }
+}
+
+
+Ptr<MobilityModel> 
+HierarchicalMobilityModel::GetChild (void) const
+{
+  return m_child;
+}
+
+Ptr<MobilityModel> 
+HierarchicalMobilityModel::GetParent (void) const
+{
+  return m_parent;
+}
+
+Vector
+HierarchicalMobilityModel::DoGetPosition (void) const
+{
+  if (!m_parent)
+    {
+      return m_child->GetPosition ();
+    }
+  Vector parentPosition = m_parent->GetPosition ();
+  Vector childPosition = m_child->GetPosition ();
+  return Vector (parentPosition.x + childPosition.x,
+		   parentPosition.y + childPosition.y,
+		   parentPosition.z + childPosition.z);
+}
+void 
+HierarchicalMobilityModel::DoSetPosition (const Vector &position)
+{
+  if (m_child == 0)
+    {
+      return;
+    }
+  // This implementation of DoSetPosition is really an arbitraty choice.
+  // anything else would have been ok.
+  if (m_parent)
+    {
+      Vector parentPosition = m_parent->GetPosition ();
+      Vector childPosition (position.x - parentPosition.x,
+                            position.y - parentPosition.y,
+                            position.z - parentPosition.z);
+      m_child->SetPosition (childPosition);
+    }
+  else
+    {
+      m_child->SetPosition (position);
+    }
+}
+Vector
+HierarchicalMobilityModel::DoGetVelocity (void) const
+{
+  if (m_parent)
+    {
+      Vector parentSpeed = m_parent->GetVelocity ();
+      Vector childSpeed = m_child->GetVelocity ();
+      Vector speed (parentSpeed.x + childSpeed.x,
+                    parentSpeed.y + childSpeed.y,
+                    parentSpeed.z + childSpeed.z);
+      return speed;
+    }
+  else
+    {
+      return m_child->GetVelocity ();
+    }
+}
+
+void 
+HierarchicalMobilityModel::ParentChanged (Ptr<const MobilityModel> model)
+{
+  MobilityModel::NotifyCourseChange ();
+}
+
+void 
+HierarchicalMobilityModel::ChildChanged (Ptr<const MobilityModel> model)
+{
+  MobilityModel::NotifyCourseChange ();
+}
+
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/hierarchical-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,111 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef HIERARCHICAL_MOBILITY_MODEL_H
+#define HIERARCHICAL_MOBILITY_MODEL_H
+
+#include "mobility-model.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Hierarchical mobility model.
+ * 
+ * This model allows you to specify the position of a child object
+ * relative to a parent object.
+ * 
+ * Basically this is a mobility model that combines two other mobility
+ * models: a "parent" model and a "child" model.  The position of the
+ * hierarchical model is always the vector sum of the parent + child
+ * positions, so that if the parent model "moves", then this model
+ * will report an equal relative movement.  Useful, for instance, if
+ * you want to simulate a node inside another node that moves, such as
+ * a vehicle.
+ *
+ * Setting the position on this model is always done using world
+ * absolute coordinates, and it changes only the child mobility model
+ * position, never the parent.  The child mobility model always uses a
+ * coordinate system relative to the parent model position.
+ *
+ * \note: as a special case, the parent model may be NULL, which is
+ * semantically equivalent to having a ConstantPositionMobilityModel
+ * as parent positioned at origin (0,0,0).  In other words, setting
+ * the parent model to NULL makes the child model and the hierarchical
+ * model start using world absolute coordinates.
+ *
+ * \warning: changing the parent/child mobility models in the middle
+ * of a simulation will probably not play very well with the
+ * ConfigStore APIs, so do this only if you know what you are doing.
+ */
+class HierarchicalMobilityModel : public MobilityModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  HierarchicalMobilityModel ();
+
+  /**
+   * \return the child mobility model.
+   *
+   * This allows you to get access to the position of the child
+   * relative to its parent.
+   */
+  Ptr<MobilityModel> GetChild (void) const;
+  /**
+   * \return the parent mobility model.
+   *
+   * This allows you to get access to the position of the 
+   * parent mobility model which is used as the reference 
+   * position by the child mobility model.
+   */
+  Ptr<MobilityModel> GetParent (void) const;
+  /**
+   * Sets the child mobility model to a new one.  If before there
+   * already existed a child model, then the child mobility model
+   * current position is also modified to ensure that the composite
+   * position is preserved.
+   * \param model new mobility model child
+   */
+  void SetChild (Ptr<MobilityModel> model);
+  /**
+   * Sets the parent mobility model to a new one.  If before there
+   * already existed a child model, then the child mobility model
+   * current position is also modified to ensure that the composite
+   * position is preserved.
+   * \param model new mobility model parent
+   */
+  void SetParent (Ptr<MobilityModel> model);
+  
+private:
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  void ParentChanged (Ptr<const MobilityModel> model);
+  void ChildChanged (Ptr<const MobilityModel> model);
+
+  Ptr<MobilityModel> m_child;
+  Ptr<MobilityModel> m_parent;
+};
+
+
+} // namespace ns3
+
+#endif /* HIERARCHICAL_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,90 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include <math.h>
+
+#include "mobility-model.h"
+#include "ns3/trace-source-accessor.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (MobilityModel);
+
+TypeId 
+MobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MobilityModel")
+    .SetParent<Object> ()
+    .AddAttribute ("Position", "The current position of the mobility model.",
+                   TypeId::ATTR_SET | TypeId::ATTR_GET,
+                   VectorValue (Vector (0.0, 0.0, 0.0)),
+                   MakeVectorAccessor (&MobilityModel::SetPosition,
+                                        &MobilityModel::GetPosition),
+                   MakeVectorChecker ())
+    .AddAttribute ("Velocity", "The current velocity of the mobility model.",
+                   TypeId::ATTR_GET,
+                   VectorValue (Vector (0.0, 0.0, 0.0)), // ignored initial value.
+                   MakeVectorAccessor (&MobilityModel::GetVelocity),
+                   MakeVectorChecker ())
+    .AddTraceSource ("CourseChange", 
+                     "The value of the position and/or velocity vector changed",
+                     MakeTraceSourceAccessor (&MobilityModel::m_courseChangeTrace))
+    ;
+  return tid;
+}
+
+MobilityModel::MobilityModel ()
+{}
+
+MobilityModel::~MobilityModel ()
+{}
+
+Vector
+MobilityModel::GetPosition (void) const
+{
+  return DoGetPosition ();
+}
+Vector
+MobilityModel::GetVelocity (void) const
+{
+  return DoGetVelocity ();
+}
+
+void 
+MobilityModel::SetPosition (const Vector &position)
+{
+  DoSetPosition (position);
+}
+
+double 
+MobilityModel::GetDistanceFrom (Ptr<const MobilityModel> other) const
+{
+  Vector oPosition = other->DoGetPosition ();
+  Vector position = DoGetPosition ();
+  return CalculateDistance (position, oPosition);
+}
+
+void
+MobilityModel::NotifyCourseChange (void) const
+{
+  m_courseChangeTrace(this);
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,102 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef MOBILITY_MODEL_H
+#define MOBILITY_MODEL_H
+
+#include "ns3/vector.h"
+#include "ns3/object.h"
+#include "ns3/traced-callback.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Keep track of the current position and velocity of an object.
+ *
+ * All space coordinates in this class and its subclasses are
+ * understood to be meters or meters/s. i.e., they are all
+ * metric international units.
+ *
+ * This is a base class for all specific mobility models.
+ */
+class MobilityModel : public Object
+{
+public:
+  static TypeId GetTypeId (void);
+  MobilityModel ();
+  virtual ~MobilityModel () = 0;
+
+  /**
+   * \return the current position
+   */
+  Vector GetPosition (void) const;
+  /**
+   * \param position the position to set.
+   */
+  void SetPosition (const Vector &position);
+  /**
+   * \return the current velocity.
+   */
+  Vector GetVelocity (void) const;
+  /**
+   * \param position a reference to another mobility model
+   * \return the distance between the two objects. Unit is meters.
+   */
+  double GetDistanceFrom (Ptr<const MobilityModel> position) const;
+protected:
+  /**
+   * Must be invoked by subclasses when the course of the
+   * position changes to notify course change listeners.
+   */
+  void NotifyCourseChange (void) const;
+private:
+  /**
+   * \return the current position.
+   *
+   * Concrete subclasses of this base class must 
+   * implement this method.
+   */
+  virtual Vector DoGetPosition (void) const = 0;
+  /**
+   * \param position the position to set.
+   *
+   * Concrete subclasses of this base class must 
+   * implement this method.
+   */
+  virtual void DoSetPosition (const Vector &position) = 0;
+  /**
+   * \return the current velocity.
+   *
+   * Concrete subclasses of this base class must 
+   * implement this method.
+   */
+  virtual Vector DoGetVelocity (void) const = 0;
+
+  /**
+   * Used to alert subscribers that a change in direction, velocity,
+   * or position has occurred.
+   */
+  TracedCallback<Ptr<const MobilityModel> > m_courseChangeTrace;
+
+};
+
+}; // namespace ns3
+
+#endif /* MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/mobility.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,13 @@
+/**
+ * \addtogroup mobility Mobility
+ *
+ * The mobility support includes:
+ *  - a set of mobility models which are used to track and maintain
+ *    the "current" cartesian position and speed of an object.
+ *
+ *  - a "course change notifier" trace source which can be used to register
+ *    listeners to the course changes of a mobility model
+ * 
+ *  - a number of helper classes which are used to place nodes and setup 
+ *    mobility models (including parsers for some mobility definition formats).
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/position-allocator.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,446 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "position-allocator.h"
+#include "ns3/random-variable.h"
+#include "ns3/double.h"
+#include "ns3/uinteger.h"
+#include "ns3/enum.h"
+#include "ns3/log.h"
+#include <cmath>
+
+NS_LOG_COMPONENT_DEFINE ("PositionAllocator");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (PositionAllocator);
+
+TypeId 
+PositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::PositionAllocator")
+    .SetParent<Object> ();
+  return tid;
+}
+
+PositionAllocator::PositionAllocator ()
+{
+}
+
+PositionAllocator::~PositionAllocator ()
+{}
+
+NS_OBJECT_ENSURE_REGISTERED (ListPositionAllocator);
+
+TypeId 
+ListPositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ListPositionAllocator")
+    .SetParent<PositionAllocator> ()
+    .AddConstructor<ListPositionAllocator> ()
+    ;
+  return tid;
+}
+ListPositionAllocator::ListPositionAllocator ()
+{}
+void 
+ListPositionAllocator::Add (Vector v)
+{
+  m_positions.push_back (v);
+  m_current = m_positions.begin ();
+}
+Vector 
+ListPositionAllocator::GetNext (void) const
+{
+  Vector v = *m_current;
+  m_current++;
+  if (m_current == m_positions.end()) 
+    {
+      m_current = m_positions.begin ();
+    }
+  return v;
+}
+
+NS_OBJECT_ENSURE_REGISTERED (GridPositionAllocator);
+
+TypeId 
+GridPositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::GridPositionAllocator")
+    .SetParent<PositionAllocator> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<GridPositionAllocator> ()
+    .AddAttribute ("GridWidth", "The number of objects layed out on a line.",
+                   UintegerValue (10),
+                   MakeUintegerAccessor (&GridPositionAllocator::m_n),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("MinX", "The x coordinate where the grid starts.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&GridPositionAllocator::m_xMin),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MinY", "The y coordinate where the grid starts.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&GridPositionAllocator::m_yMin),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("DeltaX", "The x space between objects.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&GridPositionAllocator::m_deltaX),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("DeltaY", "The y space between objects.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&GridPositionAllocator::m_deltaY),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("LayoutType", "The type of layout.",
+                   EnumValue (ROW_FIRST),
+                   MakeEnumAccessor (&GridPositionAllocator::m_layoutType),
+                   MakeEnumChecker (ROW_FIRST, "RowFirst",
+                                    COLUMN_FIRST, "ColumnFirst"))
+    ;
+  return tid;
+}
+GridPositionAllocator::GridPositionAllocator ()
+  : m_current (0)
+{}
+
+void 
+GridPositionAllocator::SetMinX (double xMin)
+{
+  m_xMin = xMin;
+}
+void 
+GridPositionAllocator::SetMinY (double yMin)
+{
+  m_yMin = yMin;
+}
+void 
+GridPositionAllocator::SetDeltaX (double deltaX)
+{
+  m_deltaX = deltaX;
+}
+void 
+GridPositionAllocator::SetDeltaY (double deltaY)
+{
+  m_deltaY = deltaY;
+}
+void 
+GridPositionAllocator::SetN (uint32_t n)
+{
+  m_n = n;
+}
+void 
+GridPositionAllocator::SetLayoutType (enum LayoutType layoutType)
+{
+  m_layoutType = layoutType;
+}
+
+double 
+GridPositionAllocator::GetMinX (void) const
+{
+  return m_xMin;
+}
+double 
+GridPositionAllocator::GetMinY (void) const
+{
+  return m_yMin;
+}
+double 
+GridPositionAllocator::GetDeltaX (void) const
+{
+  return m_deltaX;
+}
+double 
+GridPositionAllocator::GetDeltaY (void) const
+{
+  return m_deltaY;
+}
+uint32_t 
+GridPositionAllocator::GetN (void) const
+{
+  return m_n;
+}
+enum GridPositionAllocator::LayoutType 
+GridPositionAllocator::GetLayoutType (void) const
+{
+  return m_layoutType;
+}
+
+Vector 
+GridPositionAllocator::GetNext (void) const
+{
+  double x = 0.0, y = 0.0;
+  switch (m_layoutType) {
+  case ROW_FIRST:
+    x = m_xMin + m_deltaX * (m_current % m_n);
+    y = m_yMin + m_deltaY * (m_current / m_n);
+    break;
+  case COLUMN_FIRST:
+    x = m_xMin + m_deltaX * (m_current / m_n);
+    y = m_yMin + m_deltaY * (m_current % m_n);
+    break;
+  }
+  m_current++;
+  return Vector (x, y, 0.0);
+}
+
+
+NS_OBJECT_ENSURE_REGISTERED (RandomRectanglePositionAllocator);
+
+TypeId
+RandomRectanglePositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomRectanglePositionAllocator")
+    .SetParent<PositionAllocator> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<RandomRectanglePositionAllocator> ()
+    .AddAttribute ("X",
+                   "A random variable which represents the x coordinate of a position in a random rectangle.",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),
+                   MakeRandomVariableAccessor (&RandomRectanglePositionAllocator::m_x),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Y",
+                   "A random variable which represents the y coordinate of a position in a random rectangle.",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),
+                   MakeRandomVariableAccessor (&RandomRectanglePositionAllocator::m_y),
+                   MakeRandomVariableChecker ());
+  return tid;
+}
+
+RandomRectanglePositionAllocator::RandomRectanglePositionAllocator ()
+{}
+RandomRectanglePositionAllocator::~RandomRectanglePositionAllocator ()
+{}
+
+void 
+RandomRectanglePositionAllocator::SetX (RandomVariable x)
+{
+  m_x = x;
+}
+void 
+RandomRectanglePositionAllocator::SetY (RandomVariable y)
+{
+  m_y = y;
+}
+
+Vector
+RandomRectanglePositionAllocator::GetNext (void) const
+{
+  double x = m_x.GetValue ();
+  double y = m_y.GetValue ();
+  return Vector (x, y, 0.0);
+}
+
+
+NS_OBJECT_ENSURE_REGISTERED (RandomBoxPositionAllocator);
+
+TypeId
+RandomBoxPositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomBoxPositionAllocator")
+    .SetParent<PositionAllocator> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<RandomBoxPositionAllocator> ()
+    .AddAttribute ("X",
+                   "A random variable which represents the x coordinate of a position in a random box.",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),
+                   MakeRandomVariableAccessor (&RandomBoxPositionAllocator::m_x),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Y",
+                   "A random variable which represents the y coordinate of a position in a random box.",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),
+                   MakeRandomVariableAccessor (&RandomBoxPositionAllocator::m_y),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Z",
+                   "A random variable which represents the z coordinate of a position in a random box.",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),
+                   MakeRandomVariableAccessor (&RandomBoxPositionAllocator::m_z),
+                   MakeRandomVariableChecker ());
+  return tid;
+}
+
+RandomBoxPositionAllocator::RandomBoxPositionAllocator ()
+{}
+RandomBoxPositionAllocator::~RandomBoxPositionAllocator ()
+{}
+
+void 
+RandomBoxPositionAllocator::SetX (RandomVariable x)
+{
+  m_x = x;
+}
+void 
+RandomBoxPositionAllocator::SetY (RandomVariable y)
+{
+  m_y = y;
+}
+void 
+RandomBoxPositionAllocator::SetZ (RandomVariable z)
+{
+  m_z = z;
+}
+
+Vector
+RandomBoxPositionAllocator::GetNext (void) const
+{
+  double x = m_x.GetValue ();
+  double y = m_y.GetValue ();
+  double z = m_z.GetValue ();
+  return Vector (x, y, z);
+}
+
+
+
+NS_OBJECT_ENSURE_REGISTERED (RandomDiscPositionAllocator);
+
+TypeId
+RandomDiscPositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomDiscPositionAllocator")
+    .SetParent<PositionAllocator> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<RandomDiscPositionAllocator> ()
+    .AddAttribute ("Theta",
+                   "A random variable which represents the angle (gradients) of a position in a random disc.",
+                   RandomVariableValue (UniformVariable (0.0, 6.2830)),
+                   MakeRandomVariableAccessor (&RandomDiscPositionAllocator::m_theta),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Rho",
+                   "A random variable which represents the radius of a position in a random disc.",
+                   RandomVariableValue (UniformVariable (0.0, 200.0)),
+                   MakeRandomVariableAccessor (&RandomDiscPositionAllocator::m_rho),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("X",
+                   "The x coordinate of the center of the random position disc.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_x),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Y",
+                   "The y coordinate of the center of the random position disc.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_y),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}   
+
+RandomDiscPositionAllocator::RandomDiscPositionAllocator ()
+{}
+RandomDiscPositionAllocator::~RandomDiscPositionAllocator ()
+{}
+
+void 
+RandomDiscPositionAllocator::SetTheta (RandomVariable theta)
+{
+  m_theta = theta;
+}
+void 
+RandomDiscPositionAllocator::SetRho (RandomVariable rho)
+{
+  m_rho = rho;
+}
+void 
+RandomDiscPositionAllocator::SetX (double x)
+{
+  m_x = x;
+}
+void 
+RandomDiscPositionAllocator::SetY (double y)
+{
+  m_y = y;
+}
+Vector
+RandomDiscPositionAllocator::GetNext (void) const
+{
+  double theta = m_theta.GetValue ();
+  double rho = m_rho.GetValue ();
+  double x = m_x + std::cos (theta) * rho;
+  double y = m_y + std::sin (theta) * rho;
+  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
+  return Vector (x, y, 0.0);
+}
+
+
+
+NS_OBJECT_ENSURE_REGISTERED (UniformDiscPositionAllocator);
+
+TypeId
+UniformDiscPositionAllocator::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::UniformDiscPositionAllocator")
+    .SetParent<PositionAllocator> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<UniformDiscPositionAllocator> ()
+    .AddAttribute ("rho",
+                   "The radius of the disc",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_rho),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("X",
+                   "The x coordinate of the center of the  disc.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_x),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Y",
+                   "The y coordinate of the center of the  disc.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_y),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}   
+
+UniformDiscPositionAllocator::UniformDiscPositionAllocator ()
+{}
+UniformDiscPositionAllocator::~UniformDiscPositionAllocator ()
+{}
+
+void 
+UniformDiscPositionAllocator::SetRho (double rho)
+{
+  m_rho = rho;
+}
+void 
+UniformDiscPositionAllocator::SetX (double x)
+{
+  m_x = x;
+}
+void 
+UniformDiscPositionAllocator::SetY (double y)
+{
+  m_y = y;
+}
+Vector
+UniformDiscPositionAllocator::GetNext (void) const
+{
+  UniformVariable r (-m_rho, m_rho);
+  double x,y;
+  do
+    {
+      x = r.GetValue ();
+      y = r.GetValue ();
+    }
+  while (sqrt(x*x + y*y) > m_rho);
+  
+  x += m_x;
+  y += m_y;
+  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
+  return Vector (x, y, 0.0);
+}
+
+
+} // namespace ns3 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/position-allocator.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,280 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef POSITION_ALLOCATOR_H
+#define POSITION_ALLOCATOR_H
+
+#include "ns3/object.h"
+#include "ns3/random-variable.h"
+#include "ns3/vector.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Allocate a set of positions. The allocation strategy is implemented in subclasses.
+ *
+ * This is a pure abstract base class.
+ */
+class PositionAllocator : public Object
+{
+public:
+  static TypeId GetTypeId (void);
+  PositionAllocator ();
+  virtual ~PositionAllocator ();
+  /**
+   * \return the next chosen position.
+   *
+   * This method _must_ be implement in subclasses.
+   */
+  virtual Vector GetNext (void) const = 0;
+};
+
+/**
+ * \ingroup mobility
+ * \brief Allocate positions from a deterministic list specified by the user.
+ *
+ * The first call to ListPositionAllocator::GetNext  will return the
+ * first element of the list, the second call, the second element, and so on.
+ */
+class ListPositionAllocator : public PositionAllocator
+{
+public:
+  static TypeId GetTypeId (void);
+  ListPositionAllocator ();
+
+  /**
+   * \param v the position to append at the end of the list of positions to return from GetNext.
+   */
+  void Add (Vector v);
+  virtual Vector GetNext (void) const;
+private:
+  std::vector<Vector> m_positions;
+  mutable std::vector<Vector>::const_iterator m_current;
+};
+
+/**
+ * \ingroup mobility
+ * \brief Allocate positions on a rectangular 2d grid.
+ */
+class GridPositionAllocator : public PositionAllocator
+{
+public:
+  static TypeId GetTypeId (void);
+
+  /**
+   * Determine whether positions are allocated row first or column first.
+   */
+  enum LayoutType {
+    /**
+     * In row-first mode, positions are allocated on the first row until
+     * N positions have been allocated. Then, the second row located a yMin + yDelta
+     * is used to allocate positions.
+     */
+    ROW_FIRST,
+    /**
+     * In column-first mode, positions are allocated on the first column until
+     * N positions have been allocated. Then, the second column located a xMin + xDelta
+     * is used to allocate positions.
+     */
+    COLUMN_FIRST
+  };
+
+  GridPositionAllocator ();
+
+  /**
+   * \param xMin the x coordinate where layout will start.
+   */
+  void SetMinX (double xMin);
+  /**
+   * \param yMin the y coordinate where layout will start
+   */
+  void SetMinY (double yMin);
+  /**
+   * \param deltaX the x interval between two x-consecutive positions.
+   */
+  void SetDeltaX (double deltaX);
+  /**
+   * \param deltaY the y interval between two y-consecutive positions.
+   */
+  void SetDeltaY (double deltaY);
+  /**
+   * \param n the number of positions allocated on each row (or each column)
+   *        before switching to the next column (or row).
+   */
+  void SetN (uint32_t n);
+  /**
+   * \param layoutType the type of layout to use (row first or column first).
+   */
+  void SetLayoutType (enum LayoutType layoutType);
+
+  /**
+   * \return the x coordinate of the first allocated position.
+   */
+  double GetMinX (void) const;
+  /**
+   * \return the y coordinate of the first allocated position.
+   */
+  double GetMinY (void) const;
+  /**
+   * \return the x interval between two x-consecutive positions.
+   */
+  double GetDeltaX (void) const;
+  /**
+   * \return the y interval between two y-consecutive positions.
+   */
+  double GetDeltaY (void) const;
+  /**
+   * \return the number of positions to allocate on each row or each column.
+   */
+  uint32_t GetN (void) const;
+  /**
+   * \return the currently-selected layout type.
+   */
+  enum LayoutType GetLayoutType (void) const;
+  
+
+  virtual Vector GetNext (void) const;
+private:
+  mutable uint32_t m_current;
+  enum LayoutType m_layoutType;
+  double m_xMin;
+  double m_yMin;
+  uint32_t m_n;
+  double m_deltaX;
+  double m_deltaY;
+};
+
+/**
+ * \ingroup mobility
+ * \brief Allocate random positions within a rectangle according to a pair of random variables.
+ */
+class RandomRectanglePositionAllocator : public PositionAllocator
+{
+public:
+  static TypeId GetTypeId (void);
+  RandomRectanglePositionAllocator ();
+  virtual ~RandomRectanglePositionAllocator ();
+
+  void SetX (RandomVariable x);
+  void SetY (RandomVariable y);
+
+  virtual Vector GetNext (void) const;
+private:
+  RandomVariable m_x;
+  RandomVariable m_y;
+};
+
+/**
+ * \ingroup mobility
+ * \brief Allocate random positions within a 3D box according to a set of three random variables.
+ */
+class RandomBoxPositionAllocator : public PositionAllocator
+{
+public:
+  static TypeId GetTypeId (void);
+  RandomBoxPositionAllocator ();
+  virtual ~RandomBoxPositionAllocator ();
+
+  void SetX (RandomVariable x);
+  void SetY (RandomVariable y);
+  void SetZ (RandomVariable z);
+
+  virtual Vector GetNext (void) const;
+private:
+  RandomVariable m_x;
+  RandomVariable m_y;
+  RandomVariable m_z;
+};
+
+/**
+ * \ingroup mobility
+ * \brief Allocate random positions within a disc according to a given distribution for the polar coordinates of each node 
+          with respect to the provided center of the disc 
+ */
+class RandomDiscPositionAllocator : public PositionAllocator
+{
+public:
+  static TypeId GetTypeId (void);
+  RandomDiscPositionAllocator ();
+  virtual ~RandomDiscPositionAllocator ();
+
+  void SetTheta (RandomVariable theta);
+  void SetRho (RandomVariable rho);
+  void SetX (double x);
+  void SetY (double y);
+
+  virtual Vector GetNext (void) const;
+private:
+  RandomVariable m_theta;
+  RandomVariable m_rho;
+  double m_x;
+  double m_y;
+};
+
+
+/**
+ * \ingroup mobility
+ * \brief Allocate the positions uniformely (with constant density) randomly within a disc.
+ *
+ * UniformDiscPositionAllocator allocates the positions randomly within a disc \f$ D \f$ lying on the
+ * plane \f$ z=0 \f$ and having center at coordinates \f$ (x,y,0) \f$
+ * and radius \f$ \rho \f$. The random positions are chosen such that,
+ * for any subset \f$ S \subset D \f$, the expected value of the
+ * fraction of points which fall into \f$ S \subset D \f$ corresponds
+ * to \f$ \frac{|S|}{|D|} \f$, i.e., to the ratio of the area of the
+ * subset to the area of the whole disc. 
+ *
+ * \note using UniformDiscPositionAllocator is not equivalent to using
+ * a RandomDiscPositionAllocator with a uniformly-distributed radius,
+ * since doing that would results in a point distribution which is
+ * more dense towards the center of the disc.
+ */
+class UniformDiscPositionAllocator : public PositionAllocator
+{
+public:
+  static TypeId GetTypeId (void);
+  UniformDiscPositionAllocator ();
+  virtual ~UniformDiscPositionAllocator ();
+
+  /** 
+   * \param rho the value of the radius of the disc
+   */
+  void SetRho (double rho);
+
+  /** 
+   * \param x  the X coordinate of the center of the disc
+   */
+  void SetX (double x);
+
+  /** 
+   * \param y   the Y coordinate of the center of the disc 
+   */
+  void SetY (double y);
+
+  virtual Vector GetNext (void) const;
+private:
+  double m_rho;
+  double m_x;
+  double m_y;
+};
+
+} // namespace ns3
+
+#endif /* RANDOM_POSITION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/random-direction-2d-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,154 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "ns3/simulator.h"
+#include <algorithm>
+#include <cmath>
+#include "random-direction-2d-mobility-model.h"
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("RandomDirection2dMobilityModel");
+
+namespace ns3 {
+
+const double RandomDirection2dMobilityModel::PI = 3.14159265358979323846;
+
+NS_OBJECT_ENSURE_REGISTERED (RandomDirection2dMobilityModel);
+
+
+TypeId
+RandomDirection2dMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomDirection2dMobilityModel")
+    .SetParent<MobilityModel> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<RandomDirection2dMobilityModel> ()
+    .AddAttribute ("Bounds", "The 2d bounding area",
+                   RectangleValue (Rectangle (-100, 100, -100, 100)),
+                   MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds),
+                   MakeRectangleChecker ())
+    .AddAttribute ("Speed", "A random variable to control the speed (m/s).",
+                   RandomVariableValue (UniformVariable (1.0, 2.0)),
+                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_speed),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Pause", "A random variable to control the pause (s).",
+                   RandomVariableValue (ConstantVariable (2.0)),
+                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_pause),
+                   MakeRandomVariableChecker ())
+    ;
+  return tid;
+}
+
+void 
+RandomDirection2dMobilityModel::DoDispose (void)
+{
+  // chain up.
+  MobilityModel::DoDispose ();
+}
+void
+RandomDirection2dMobilityModel::DoStart (void)
+{
+  DoStartPrivate ();
+  MobilityModel::DoStart ();
+}
+
+void
+RandomDirection2dMobilityModel::DoStartPrivate (void)
+{
+  double direction = m_direction.GetValue (0, 2 * PI);
+  SetDirectionAndSpeed (direction);
+}
+
+void
+RandomDirection2dMobilityModel::BeginPause (void)
+{
+  m_helper.Update ();
+  m_helper.Pause ();
+  Time pause = Seconds (m_pause.GetValue ());
+  m_event.Cancel ();
+  m_event = Simulator::Schedule (pause, &RandomDirection2dMobilityModel::ResetDirectionAndSpeed, this);
+  NotifyCourseChange ();
+}
+
+void
+RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction)
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  m_helper.UpdateWithBounds (m_bounds);
+  Vector position = m_helper.GetCurrentPosition ();
+  double speed = m_speed.GetValue ();
+  const Vector vector (std::cos (direction) * speed,
+                       std::sin (direction) * speed,
+                       0.0);
+  m_helper.SetVelocity (vector);
+  m_helper.Unpause ();
+  Vector next = m_bounds.CalculateIntersection (position, vector);
+  Time delay = Seconds (CalculateDistance (position, next) / speed);
+  m_event.Cancel ();
+  m_event = Simulator::Schedule (delay,
+				 &RandomDirection2dMobilityModel::BeginPause, this);
+  NotifyCourseChange ();
+}
+void
+RandomDirection2dMobilityModel::ResetDirectionAndSpeed (void)
+{
+  double direction = m_direction.GetValue (0, PI);
+  
+  m_helper.UpdateWithBounds (m_bounds);
+  Vector position = m_helper.GetCurrentPosition ();
+  switch (m_bounds.GetClosestSide (position))
+    {
+    case Rectangle::RIGHT:
+      direction += PI / 2;
+      break;
+    case Rectangle::LEFT:
+      direction += - PI / 2;
+      break;
+    case Rectangle::TOP:
+      direction += PI;
+      break;
+    case Rectangle::BOTTOM:
+      direction += 0.0;
+      break;
+    }
+  SetDirectionAndSpeed (direction);
+}
+Vector
+RandomDirection2dMobilityModel::DoGetPosition (void) const
+{
+  m_helper.UpdateWithBounds (m_bounds);
+  return m_helper.GetCurrentPosition ();
+}
+void
+RandomDirection2dMobilityModel::DoSetPosition (const Vector &position)
+{
+  m_helper.SetPosition (position);
+  Simulator::Remove (m_event);
+  m_event.Cancel ();
+  m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::DoStartPrivate, this);
+}
+Vector
+RandomDirection2dMobilityModel::DoGetVelocity (void) const
+{
+  return m_helper.GetVelocity ();
+}
+
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/random-direction-2d-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,72 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef RANDOM_DIRECTION_MOBILITY_MODEL_H
+#define RANDOM_DIRECTION_MOBILITY_MODEL_H
+
+#include "ns3/object.h"
+#include "ns3/ptr.h"
+#include "ns3/nstime.h"
+#include "ns3/event-id.h"
+#include "ns3/rectangle.h"
+#include "ns3/random-variable.h"
+#include "mobility-model.h"
+#include "constant-velocity-helper.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Random direction mobility model.
+ *
+ * The movement of objects is based on random directions: each object
+ * pauses for a specific delay, chooses a random direction and speed and 
+ * then travels in the specific direction until it reaches one of
+ * the boundaries of the model. When it reaches the boundary, it pauses,
+ * selects a new direction and speed, aso.
+ */
+class RandomDirection2dMobilityModel : public MobilityModel
+{
+ public:
+  static TypeId GetTypeId (void);
+
+ private:
+  void ResetDirectionAndSpeed (void);
+  void BeginPause (void);
+  void SetDirectionAndSpeed (double direction);
+  void InitializeDirectionAndSpeed (void);
+  void DoStartPrivate (void);
+  virtual void DoDispose (void);
+  virtual void DoStart (void);
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  static const double PI;
+  UniformVariable m_direction;
+  Rectangle m_bounds;
+  RandomVariable m_speed;
+  RandomVariable m_pause;
+  EventId m_event;
+  ConstantVelocityHelper m_helper;
+};
+
+} // namespace ns3
+
+#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/random-walk-2d-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,179 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "random-walk-2d-mobility-model.h"
+#include "ns3/enum.h"
+#include "ns3/double.h"
+#include "ns3/simulator.h"
+#include "ns3/log.h"
+#include <cmath>
+
+NS_LOG_COMPONENT_DEFINE ("RandomWalk2d");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (RandomWalk2dMobilityModel);
+
+TypeId
+RandomWalk2dMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomWalk2dMobilityModel")
+    .SetParent<MobilityModel> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<RandomWalk2dMobilityModel> ()
+    .AddAttribute ("Bounds",
+                   "Bounds of the area to cruise.",
+                   RectangleValue (Rectangle (0.0, 0.0, 100.0, 100.0)),
+                   MakeRectangleAccessor (&RandomWalk2dMobilityModel::m_bounds),
+                   MakeRectangleChecker ())
+    .AddAttribute ("Time",
+                   "Change current direction and speed after moving for this delay.",
+                   TimeValue (Seconds (1.0)),
+                   MakeTimeAccessor (&RandomWalk2dMobilityModel::m_modeTime),
+                   MakeTimeChecker ())
+    .AddAttribute ("Distance",
+                   "Change current direction and speed after moving for this distance.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&RandomWalk2dMobilityModel::m_modeDistance),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Mode",
+                   "The mode indicates the condition used to "
+                   "change the current speed and direction",
+                   EnumValue (RandomWalk2dMobilityModel::MODE_DISTANCE),
+                   MakeEnumAccessor (&RandomWalk2dMobilityModel::m_mode),
+                   MakeEnumChecker (RandomWalk2dMobilityModel::MODE_DISTANCE, "Distance",
+                                    RandomWalk2dMobilityModel::MODE_TIME, "Time"))
+    .AddAttribute ("Direction",
+                   "A random variable used to pick the direction (gradients).",
+                   RandomVariableValue (UniformVariable (0.0, 6.283184)),
+                   MakeRandomVariableAccessor (&RandomWalk2dMobilityModel::m_direction),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Speed",
+                   "A random variable used to pick the speed (m/s).",
+                   RandomVariableValue (UniformVariable (2.0, 4.0)),
+                   MakeRandomVariableAccessor (&RandomWalk2dMobilityModel::m_speed),
+                   MakeRandomVariableChecker ());
+  return tid;
+}
+
+void
+RandomWalk2dMobilityModel::DoStart (void)
+{
+  DoStartPrivate ();
+  MobilityModel::DoStart ();
+}
+
+void
+RandomWalk2dMobilityModel::DoStartPrivate (void)
+{
+  m_helper.Update ();
+  double speed = m_speed.GetValue ();
+  double direction = m_direction.GetValue ();
+  Vector vector (std::cos (direction) * speed,
+                 std::sin (direction) * speed,
+                 0.0);
+  m_helper.SetVelocity (vector);
+  m_helper.Unpause ();
+
+  Time delayLeft;
+  if (m_mode == RandomWalk2dMobilityModel::MODE_TIME)
+    {
+      delayLeft = m_modeTime;
+    }
+  else
+    {
+      delayLeft = Seconds (m_modeDistance / speed); 
+    }
+  DoWalk (delayLeft);
+}
+
+void
+RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
+{
+  Vector position = m_helper.GetCurrentPosition ();
+  Vector speed = m_helper.GetVelocity ();
+  Vector nextPosition = position;
+  nextPosition.x += speed.x * delayLeft.GetSeconds ();
+  nextPosition.y += speed.y * delayLeft.GetSeconds ();
+  m_event.Cancel ();
+  if (m_bounds.IsInside (nextPosition))
+    {
+      m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::DoStartPrivate, this);
+    }
+  else
+    {
+      nextPosition = m_bounds.CalculateIntersection (position, speed);
+      Time delay = Seconds ((nextPosition.x - position.x) / speed.x);
+      m_event = Simulator::Schedule (delay, &RandomWalk2dMobilityModel::Rebound, this,
+                                     delayLeft - delay);      
+    }  
+  NotifyCourseChange ();
+}
+
+void
+RandomWalk2dMobilityModel::Rebound (Time delayLeft)
+{
+  m_helper.UpdateWithBounds (m_bounds);
+  Vector position = m_helper.GetCurrentPosition ();
+  Vector speed = m_helper.GetVelocity ();
+  switch (m_bounds.GetClosestSide (position))
+    {
+    case Rectangle::RIGHT:
+    case Rectangle::LEFT:
+      speed.x = - speed.x;
+      break;
+    case Rectangle::TOP:
+    case Rectangle::BOTTOM:
+      speed.y = - speed.y;
+      break;
+    }
+  m_helper.SetVelocity (speed);
+  m_helper.Unpause ();
+  DoWalk (delayLeft);
+}
+
+void
+RandomWalk2dMobilityModel::DoDispose (void)
+{
+  // chain up
+  MobilityModel::DoDispose ();
+}
+Vector
+RandomWalk2dMobilityModel::DoGetPosition (void) const
+{
+  m_helper.UpdateWithBounds (m_bounds);
+  return m_helper.GetCurrentPosition ();
+}
+void
+RandomWalk2dMobilityModel::DoSetPosition (const Vector &position)
+{
+  NS_ASSERT (m_bounds.IsInside (position));
+  m_helper.SetPosition (position);
+  Simulator::Remove (m_event);
+  m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::DoStartPrivate, this);
+}
+Vector
+RandomWalk2dMobilityModel::DoGetVelocity (void) const
+{
+  return m_helper.GetVelocity ();
+}
+
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/random-walk-2d-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,79 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2006,2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef RANDOM_WALK_2D_MOBILITY_MODEL_H
+#define RANDOM_WALK_2D_MOBILITY_MODEL_H
+
+#include "ns3/object.h"
+#include "ns3/nstime.h"
+#include "ns3/event-id.h"
+#include "ns3/rectangle.h"
+#include "ns3/random-variable.h"
+#include "mobility-model.h"
+#include "constant-velocity-helper.h"
+
+namespace ns3 {
+
+
+/**
+ * \ingroup mobility
+ * \brief 2D random walk mobility model.
+ *
+ * Each instance moves with a speed and direction choosen at random
+ * with the user-provided random variables until
+ * either a fixed distance has been walked or until a fixed amount
+ * of time. If we hit one of the boundaries (specified by a rectangle),
+ * of the model, we rebound on the boundary with a reflexive angle
+ * and speed. This model is often identified as a brownian motion
+ * model.
+ */
+class RandomWalk2dMobilityModel : public MobilityModel 
+{
+ public:
+  static TypeId GetTypeId (void);
+
+  enum Mode  {
+    MODE_DISTANCE,
+    MODE_TIME
+  };
+
+ private:
+  void Rebound (Time timeLeft);
+  void DoWalk (Time timeLeft);
+  void DoStartPrivate (void);
+  virtual void DoDispose (void);
+  virtual void DoStart (void);
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  ConstantVelocityHelper m_helper;
+  EventId m_event;
+  enum Mode m_mode;
+  double m_modeDistance;
+  Time m_modeTime;
+  RandomVariable m_speed;
+  RandomVariable m_direction;
+  Rectangle m_bounds;
+};
+
+
+} // namespace ns3
+
+#endif /* RANDOM_WALK_2D_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/random-waypoint-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,115 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include <cmath>
+#include "ns3/simulator.h"
+#include "ns3/random-variable.h"
+#include "ns3/pointer.h"
+#include "random-waypoint-mobility-model.h"
+#include "position-allocator.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (RandomWaypointMobilityModel);
+
+TypeId
+RandomWaypointMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomWaypointMobilityModel")
+    .SetParent<MobilityModel> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<RandomWaypointMobilityModel> ()
+    .AddAttribute ("Speed",
+                   "A random variable used to pick the speed of a random waypoint model.",
+                   RandomVariableValue (UniformVariable (0.3, 0.7)),
+                   MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_speed),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("Pause",
+                   "A random variable used to pick the pause of a random waypoint model.",
+                   RandomVariableValue (ConstantVariable (2.0)),
+                   MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_pause),
+                   MakeRandomVariableChecker ())
+    .AddAttribute ("PositionAllocator",
+                   "The position model used to pick a destination point.",
+                   PointerValue (),
+                   MakePointerAccessor (&RandomWaypointMobilityModel::m_position),
+                   MakePointerChecker<PositionAllocator> ());
+  
+  return tid;
+}
+
+void
+RandomWaypointMobilityModel::BeginWalk (void)
+{
+  m_helper.Update ();
+  Vector m_current = m_helper.GetCurrentPosition ();
+  Vector destination = m_position->GetNext ();
+  double speed = m_speed.GetValue ();
+  double dx = (destination.x - m_current.x);
+  double dy = (destination.y - m_current.y);
+  double dz = (destination.z - m_current.z);
+  double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
+
+  m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
+  m_helper.Unpause ();
+  Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
+  m_event.Cancel ();
+  m_event = Simulator::Schedule (travelDelay,
+				 &RandomWaypointMobilityModel::DoStartPrivate, this);
+  NotifyCourseChange ();
+}
+
+void
+RandomWaypointMobilityModel::DoStart (void)
+{
+  DoStartPrivate ();
+  MobilityModel::DoStart ();
+}
+
+void
+RandomWaypointMobilityModel::DoStartPrivate (void)
+{
+  m_helper.Update ();
+  m_helper.Pause ();
+  Time pause = Seconds (m_pause.GetValue ());
+  m_event = Simulator::Schedule (pause, &RandomWaypointMobilityModel::BeginWalk, this);
+  NotifyCourseChange ();
+}
+
+Vector
+RandomWaypointMobilityModel::DoGetPosition (void) const
+{
+  m_helper.Update ();
+  return m_helper.GetCurrentPosition ();
+}
+void 
+RandomWaypointMobilityModel::DoSetPosition (const Vector &position)
+{
+  m_helper.SetPosition (position);
+  Simulator::Remove (m_event);
+  m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::DoStartPrivate, this);
+}
+Vector
+RandomWaypointMobilityModel::DoGetVelocity (void) const
+{
+  return m_helper.GetVelocity ();
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/random-waypoint-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,67 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef RANDOM_WAYPOINT_MOBILITY_MODEL_H
+#define RANDOM_WAYPOINT_MOBILITY_MODEL_H
+
+#include "constant-velocity-helper.h"
+#include "mobility-model.h"
+#include "position-allocator.h"
+#include "ns3/ptr.h"
+#include "ns3/random-variable.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Random waypoint mobility model.
+ *
+ * Each object chooses a random destination "waypoint", a random speed,
+ * and a random pause time: it then pauses for the specified pause time,
+ * and starts moving towards the specified destination with the specified
+ * speed. Once the destination is reached the process starts again.
+ *
+ * The implementation of this model is not 2d-specific. i.e. if you provide
+ * a 3d random waypoint position model to this mobility model, the model 
+ * will still work. There is no 3d position allocator for now but it should
+ * be trivial to add one.
+ */
+class RandomWaypointMobilityModel : public MobilityModel
+{
+public:
+  static TypeId GetTypeId (void);
+protected:
+  virtual void DoStart (void);
+private:
+  void BeginWalk (void);
+  void DoStartPrivate (void);
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  ConstantVelocityHelper m_helper;
+  Ptr<PositionAllocator> m_position;
+  RandomVariable m_speed;
+  RandomVariable m_pause;
+  EventId m_event;
+};
+
+} // namespace ns3
+
+#endif /* RANDOM_WAYPOINT_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/rectangle.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,146 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#include "rectangle.h"
+#include "ns3/vector.h"
+#include "ns3/assert.h"
+#include "ns3/fatal-error.h"
+#include <cmath>
+#include <algorithm>
+#include <sstream> 
+
+namespace ns3 {
+
+Rectangle::Rectangle (double _xMin, double _xMax,
+		      double _yMin, double _yMax)
+  : xMin (_xMin),
+    xMax (_xMax),
+    yMin (_yMin),
+    yMax (_yMax)
+{}
+
+Rectangle::Rectangle ()
+  : xMin (0.0),
+    xMax (0.0),
+    yMin (0.0),
+    yMax (0.0)
+{}
+
+bool 
+Rectangle::IsInside (const Vector &position) const
+{
+  return 
+    position.x <= this->xMax && position.x >= this->xMin &&
+    position.y <= this->yMax && position.y >= this->yMin;
+}
+
+Rectangle::Side 
+Rectangle::GetClosestSide (const Vector &position) const
+{
+  double xMinDist = std::abs (position.x - this->xMin);
+  double xMaxDist = std::abs (this->xMax - position.x);
+  double yMinDist = std::abs (position.y - this->yMin);
+  double yMaxDist = std::abs (this->yMax - position.y);
+  double minX = std::min (xMinDist, xMaxDist);
+  double minY = std::min (yMinDist, yMaxDist);
+  if (minX < minY)
+    {
+      if (xMinDist < xMaxDist)
+        {
+          return LEFT;
+        }
+      else
+        {
+          return RIGHT;
+        }
+    }
+  else
+    {
+      if (yMinDist < yMaxDist)
+        {
+          return BOTTOM;
+        }
+      else
+        {
+          return TOP;
+        }
+    }
+}
+
+Vector
+Rectangle::CalculateIntersection (const Vector &current, const Vector &speed) const
+{
+  NS_ASSERT (IsInside (current));
+  double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
+  double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y;
+  double yMaxX = current.x + (this->yMax - current.y) / speed.y * speed.x;
+  double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x;
+  bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin);
+  bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin);
+  bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin);
+  bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin);
+  if (xMaxYOk && speed.x >= 0)
+    {
+      return Vector (this->xMax, xMaxY, 0.0);
+    }
+  else if (xMinYOk && speed.x <= 0)
+    {
+      return Vector (this->xMin, xMinY, 0.0);
+    }
+  else if (yMaxXOk && speed.y >= 0)
+    {
+      return Vector (yMaxX, this->yMax, 0.0);
+    }
+  else if (yMinXOk && speed.y <= 0)
+    {
+      return Vector (yMinX, this->yMin, 0.0);
+    }
+  else
+    {
+      NS_ASSERT (false);
+      // quiet compiler
+      return Vector (0.0, 0.0, 0.0);
+    }
+
+}
+
+ATTRIBUTE_HELPER_CPP (Rectangle);
+
+std::ostream &
+operator << (std::ostream &os, const Rectangle &rectangle)
+{
+  os << rectangle.xMin << "|" << rectangle.xMax << "|" << rectangle.yMin << "|" << rectangle.yMax;
+  return os;
+}
+std::istream &
+operator >> (std::istream &is, Rectangle &rectangle)
+ {
+  char c1, c2, c3;
+  is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax;
+  if (c1 != '|' ||
+      c2 != '|' ||
+      c3 != '|')
+    {
+      is.setstate (std::ios_base::failbit);
+    }
+  return is;
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/rectangle.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,107 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef RECTANGLE_H
+#define RECTANGLE_H
+
+#include "ns3/attribute.h"
+#include "ns3/attribute-helper.h"
+#include "ns3/vector.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief a 2d rectangle
+ */
+class Rectangle
+{
+public:
+  enum Side {
+    RIGHT,
+    LEFT,
+    TOP,
+    BOTTOM
+  };
+  /**
+   * \param _xMin x coordinates of left boundary.
+   * \param _xMax x coordinates of right boundary.
+   * \param _yMin y coordinates of bottom boundary.
+   * \param _yMax y coordinates of top boundary.
+   *
+   * Create a rectangle.
+   */
+  Rectangle (double _xMin, double _xMax,
+             double _yMin, double _yMax);
+  /**
+   * Create a zero-sized rectangle located at coordinates (0.0,0.0)
+   */
+  Rectangle ();
+  /**
+   * \param position the position to test.
+   * \return true if the input position is located within the rectangle, false otherwise.
+   *
+   * This method compares only the x and y coordinates of the input position.
+   * It ignores the z coordinate.
+   */
+  bool IsInside (const Vector &position) const;
+  /**
+   * \param position the position to test.
+   * \return the side of the rectangle the input position is closest to.
+   *
+   * This method compares only the x and y coordinates of the input position.
+   * It ignores the z coordinate.
+   */
+  Side GetClosestSide (const Vector &position) const;
+  /**
+   * \param current the current position
+   * \param speed the current speed
+   * \return the intersection point between the rectangle and the current+speed vector.
+   *
+   * This method assumes that the current position is located _inside_
+   * the rectangle and checks for this with an assert.
+   * This method compares only the x and y coordinates of the input position
+   * and speed. It ignores the z coordinate.
+   */
+  Vector CalculateIntersection (const Vector &current, const Vector &speed) const;
+
+  /* The x coordinate of the left bound of the rectangle */
+  double xMin;
+  /* The x coordinate of the right bound of the rectangle */
+  double xMax;
+  /* The y coordinate of the bottom bound of the rectangle */
+  double yMin;
+  /* The y coordinate of the top bound of the rectangle */
+  double yMax;
+};
+
+std::ostream &operator << (std::ostream &os, const Rectangle &rectangle);
+std::istream &operator >> (std::istream &is, Rectangle &rectangle);
+
+/**
+ * \ingroup mobility
+ * \class ns3::RectangleValue
+ * \brief hold objects of type ns3::Rectangle
+ */
+
+ATTRIBUTE_HELPER_HEADER (Rectangle);
+
+} // namespace ns3
+
+#endif /* RECTANGLE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/steady-state-random-waypoint-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,264 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 IITP RAS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Denis Fakhriev <fakhriev@iitp.ru>
+ */
+#include <cmath>
+#include "ns3/simulator.h"
+#include "ns3/double.h"
+#include "steady-state-random-waypoint-mobility-model.h"
+#include "ns3/test.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (SteadyStateRandomWaypointMobilityModel);
+
+TypeId
+SteadyStateRandomWaypointMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::SteadyStateRandomWaypointMobilityModel")
+    .SetParent<MobilityModel> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<SteadyStateRandomWaypointMobilityModel> ()
+    .AddAttribute ("MinSpeed",
+                   "Minimum speed value, [m/s]",
+                   DoubleValue (0.3),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minSpeed),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MaxSpeed",
+                   "Maximum speed value, [m/s]",
+                   DoubleValue (0.7),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxSpeed),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MinPause",
+                   "Minimum pause value, [s]",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minPause),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MaxPause",
+                   "Maximum pause value, [s]",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxPause),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MinX",
+                   "Minimum X value of traveling region, [m]",
+                   DoubleValue (1),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minX),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MaxX",
+                   "Maximum X value of traveling region, [m]",
+                   DoubleValue (1),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxX),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MinY",
+                   "Minimum Y value of traveling region, [m]",
+                   DoubleValue (1),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minY),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MaxY",
+                   "Maximum Y value of traveling region, [m]",
+                   DoubleValue (1),
+                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxY),
+                   MakeDoubleChecker<double> ());
+  
+  return tid;
+}
+
+SteadyStateRandomWaypointMobilityModel::SteadyStateRandomWaypointMobilityModel ():
+  alreadyStarted (false)
+{
+}
+
+void
+SteadyStateRandomWaypointMobilityModel::DoStart (void)
+{
+  SteadyStateStart ();
+  MobilityModel::DoStart ();
+}
+
+void
+SteadyStateRandomWaypointMobilityModel::SteadyStateStart (void)
+{
+  alreadyStarted = true;
+  NS_ASSERT (m_minSpeed >= 1e-6);
+  NS_ASSERT (m_minSpeed <= m_maxSpeed);
+  m_speed = UniformVariable (m_minSpeed, m_maxSpeed);
+  NS_ASSERT (m_minX < m_maxX);
+  NS_ASSERT (m_minY < m_maxY);
+  m_position = CreateObject<RandomRectanglePositionAllocator> ();
+  m_position->SetX (UniformVariable (m_minX, m_maxX));
+  m_position->SetY (UniformVariable (m_minY, m_maxY));
+  NS_ASSERT (m_minPause <= m_maxPause);
+  m_pause = UniformVariable (m_minPause, m_maxPause);
+  
+  m_helper.Update ();
+  m_helper.Pause ();
+  
+  // calculate the steady-state probability that a node is initially paused
+  double expectedPauseTime = (m_minPause + m_maxPause)/2;
+  double a = m_maxX - m_minX;
+  double b = m_maxY - m_minY;
+  double v0 = m_minSpeed;
+  double v1 = m_maxSpeed;
+  double log1 = b*b / a*std::log (std::sqrt ((a*a)/(b*b) + 1) + a/b);
+  double log2 = a*a / b*std::log (std::sqrt ((b*b)/(a*a) + 1) + b/a);
+  double expectedTravelTime = 1.0/6.0*(log1 + log2);
+  expectedTravelTime += 1.0/15.0*((a*a*a)/(b*b) + (b*b*b)/(a*a)) -
+                        1.0/15.0*std::sqrt(a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3);
+  if (v0 == v1)
+    {
+      expectedTravelTime /= v0;
+    }
+  else
+    {
+      expectedTravelTime *= std::log(v1/v0)/(v1 - v0);
+    }
+  double probabilityPaused = expectedPauseTime/(expectedPauseTime + expectedTravelTime);
+  NS_ASSERT (probabilityPaused >= 0 && probabilityPaused <= 1);
+  
+  UniformVariable u_r;
+  double u = u_r.GetValue(0, 1);
+  if (u < probabilityPaused) // node initially paused
+    {
+      m_helper.SetPosition (m_position->GetNext ());
+      u = u_r.GetValue(0, 1);
+      Time pause;      
+      if (m_minPause != m_maxPause)
+        {
+          if (u < (2*m_minPause/(m_minPause + m_maxPause)))
+            {
+              pause = Seconds (u*(m_minPause + m_maxPause)/2);
+            }
+          else
+            {
+              // there is an error in equation 20 in the Tech. Report MCS-03-04
+              // this error is corrected in the TMC 2004 paper and below
+              pause = Seconds (m_maxPause - sqrt ((1 - u)*(m_maxPause*m_maxPause - m_minPause*m_minPause)));
+            }
+        }
+      else // if pause is constant
+        {
+          pause = Seconds (u*expectedPauseTime);
+        }
+      NS_ASSERT (!m_event.IsRunning());
+      m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this);
+    }
+  else // node initially moving
+    {
+      UniformVariable x1_r, y1_r, x2_r, y2_r;
+      double x1, x2, y1, y2;
+      double r = 0;
+      double u1 = 1;
+      while (u1 >= r)
+        {
+          x1 = x1_r.GetValue (0, a);
+          y1 = y1_r.GetValue (0, b);
+          x2 = x2_r.GetValue (0, a);
+          y2 = y2_r.GetValue (0, b);
+          u1 = u_r.GetValue (0, 1);
+          r = std::sqrt (((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))/(a*a + b*b));
+          NS_ASSERT (r <= 1);
+        }
+      double u2 = u_r.GetValue (0, 1);
+      m_helper.SetPosition (Vector (m_minX + u2*x1 + (1 - u2)*x2, m_minY + u2*y1 + (1 - u2)*y2, 0));
+      NS_ASSERT (!m_event.IsRunning());
+      m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk, this, 
+                Vector (m_minX + x2, m_minY + y2, 0));
+    }
+  NotifyCourseChange ();
+}
+
+void
+SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk (const Vector &destination)
+{
+  m_helper.Update ();
+  Vector m_current = m_helper.GetCurrentPosition ();
+  NS_ASSERT (m_minX <= m_current.x && m_current.x <= m_maxX);
+  NS_ASSERT (m_minY <= m_current.y && m_current.y <= m_maxY);
+  NS_ASSERT (m_minX <= destination.x && destination.x <= m_maxX);
+  NS_ASSERT (m_minY <= destination.y && destination.y <= m_maxY);
+  UniformVariable u_r;
+  double u = u_r.GetValue (0, 1);
+  double speed = std::pow (m_maxSpeed, u)/std::pow (m_minSpeed, u - 1);
+  double dx = (destination.x - m_current.x);
+  double dy = (destination.y - m_current.y);
+  double dz = (destination.z - m_current.z);
+  double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
+
+  m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
+  m_helper.Unpause ();
+  Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
+  m_event = Simulator::Schedule (travelDelay, 
+                                 &SteadyStateRandomWaypointMobilityModel::Start, this);
+  NotifyCourseChange ();
+}
+
+void
+SteadyStateRandomWaypointMobilityModel::BeginWalk (void)
+{
+  m_helper.Update ();
+  Vector m_current = m_helper.GetCurrentPosition ();
+  NS_ASSERT (m_minX <= m_current.x && m_current.x <= m_maxX);
+  NS_ASSERT (m_minY <= m_current.y && m_current.y <= m_maxY);
+  Vector destination = m_position->GetNext ();
+  double speed = m_speed.GetValue ();
+  double dx = (destination.x - m_current.x);
+  double dy = (destination.y - m_current.y);
+  double dz = (destination.z - m_current.z);
+  double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
+
+  m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
+  m_helper.Unpause ();
+  Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
+  m_event = Simulator::Schedule (travelDelay,
+				 &SteadyStateRandomWaypointMobilityModel::Start, this);
+  NotifyCourseChange ();
+}
+
+void
+SteadyStateRandomWaypointMobilityModel::Start (void)
+{
+  m_helper.Update ();
+  m_helper.Pause ();
+  Time pause = Seconds (m_pause.GetValue ());
+  m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this);
+  NotifyCourseChange ();
+}
+
+Vector
+SteadyStateRandomWaypointMobilityModel::DoGetPosition (void) const
+{
+  m_helper.Update ();
+  return m_helper.GetCurrentPosition ();
+}
+void 
+SteadyStateRandomWaypointMobilityModel::DoSetPosition (const Vector &position)
+{
+  if (alreadyStarted)
+    {
+      m_helper.SetPosition (position);
+      Simulator::Remove (m_event);
+      m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::Start, this);
+    }
+}
+Vector
+SteadyStateRandomWaypointMobilityModel::DoGetVelocity (void) const
+{
+  return m_helper.GetVelocity ();
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/steady-state-random-waypoint-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,86 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 IITP RAS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ * Author: Denis Fakhriev <fakhriev@iitp.ru>
+ */
+#ifndef STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H
+#define STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H
+
+#include "constant-velocity-helper.h"
+#include "mobility-model.h"
+#include "position-allocator.h"
+#include "ns3/ptr.h"
+#include "ns3/random-variable.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Steady-state random waypoint mobility model.
+ *
+ * This model based on random waypoint mobility (RWM) model for case when 
+ * speed, pause and position are uniformly distributed random variables. 
+ * The difference is that the initial values of this parameters are not 
+ * from uniform distribution but from stationary distribution of RWM model.
+ * The implementation of this model is 2d-specific and with nonzero nodes speeds.
+ *
+ * Based on NS-2 implementation by Toilers Research Group -- Colorado
+ *      School of Mines (http://toilers.mines.edu). 
+ * The papers related to this code are:
+ *      W. Navidi and T. Camp, Stationary Distributions for the Random
+ *      Waypoint Mobility Model, IEEE Transactions on Mobile Computing,
+ *      vol. 3, no. 1, pp. 99-108, January-March 2004.
+ *      W. Navidi, T. Camp, and N. Bauer, Improving the Accuracy of
+ *      Random Waypoint Simulations Through Steady-State Initialization,
+ *      Proceedings of the 15th International Conference on Modeling and
+ *      Simulation (MS '04), pp. 319-326, March 2004.
+ */
+class SteadyStateRandomWaypointMobilityModel : public MobilityModel
+{
+public:
+  static TypeId GetTypeId (void);
+  SteadyStateRandomWaypointMobilityModel ();
+protected:
+  virtual void DoStart (void);
+private:
+  void SteadyStateStart (void);
+  void SteadyStateBeginWalk (const Vector &destination);
+  void Start (void);
+  void BeginWalk (void);
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  ConstantVelocityHelper m_helper;
+  double m_maxSpeed;
+  double m_minSpeed;
+  UniformVariable m_speed;
+  double m_minX;
+  double m_maxX;
+  double m_minY;
+  double m_maxY;
+  Ptr<RandomRectanglePositionAllocator> m_position;
+  double m_minPause;
+  double m_maxPause;
+  UniformVariable m_pause;
+  EventId m_event;
+  bool alreadyStarted;
+};
+
+} // namespace ns3
+
+#endif /* STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/waypoint-mobility-model.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,217 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Phillip Sitbon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Phillip Sitbon <phillip@sitbon.net>
+ */
+#include <limits>
+#include "ns3/abort.h"
+#include "ns3/simulator.h"
+#include "ns3/uinteger.h"
+#include "ns3/log.h"
+#include "ns3/boolean.h"
+#include "waypoint-mobility-model.h"
+#include "ns3/config.h"
+#include "ns3/test.h"
+
+NS_LOG_COMPONENT_DEFINE ("WaypointMobilityModel");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (WaypointMobilityModel);
+
+
+TypeId
+WaypointMobilityModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::WaypointMobilityModel")
+    .SetParent<MobilityModel> ()
+    .SetGroupName ("Mobility")
+    .AddConstructor<WaypointMobilityModel> ()
+    .AddAttribute ("NextWaypoint", "The next waypoint used to determine position.",
+                   TypeId::ATTR_GET,
+                   WaypointValue (),
+                   MakeWaypointAccessor (&WaypointMobilityModel::GetNextWaypoint),
+                   MakeWaypointChecker ())
+    .AddAttribute ("WaypointsLeft", "The number of waypoints remaining.",
+                   TypeId::ATTR_GET,
+                   UintegerValue (0),
+                   MakeUintegerAccessor (&WaypointMobilityModel::WaypointsLeft),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("LazyNotify", "Only call NotifyCourseChange when position is calculated.",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&WaypointMobilityModel::m_lazyNotify),
+                   MakeBooleanChecker ())
+    .AddAttribute ("InitialPositionIsWaypoint", "Calling SetPosition with no waypoints creates a waypoint.",
+                   BooleanValue (false),
+                   MakeBooleanAccessor (&WaypointMobilityModel::m_initialPositionIsWaypoint),
+                   MakeBooleanChecker ())
+  ;
+  return tid;
+}
+
+
+WaypointMobilityModel::WaypointMobilityModel ()
+  : m_first (true),
+    m_lazyNotify (false),
+    m_initialPositionIsWaypoint (false)
+{
+}
+WaypointMobilityModel::~WaypointMobilityModel ()
+{
+}
+void
+WaypointMobilityModel::DoDispose (void)
+{
+  MobilityModel::DoDispose ();
+}
+void
+WaypointMobilityModel::AddWaypoint (const Waypoint &waypoint)
+{
+  if ( m_first )
+    {
+      m_first = false;
+      m_current = m_next = waypoint;
+    }
+  else
+    {
+      NS_ABORT_MSG_IF ( !m_waypoints.empty () && (m_waypoints.back ().time >= waypoint.time),
+                        "Waypoints must be added in ascending time order");
+      m_waypoints.push_back (waypoint);
+    }
+
+  if ( !m_lazyNotify )
+    {
+      Simulator::Schedule (waypoint.time, &WaypointMobilityModel::Update, this);
+    }
+}
+Waypoint
+WaypointMobilityModel::GetNextWaypoint (void) const
+{
+  Update ();
+  return m_next;
+}
+uint32_t
+WaypointMobilityModel::WaypointsLeft (void) const
+{
+  Update ();
+  return m_waypoints.size ();
+}
+void
+WaypointMobilityModel::Update (void) const
+{
+  const Time now = Simulator::Now ();
+  bool newWaypoint = false;
+
+  if ( now < m_current.time )
+    {
+      return;
+    }
+
+  while ( now >= m_next.time  )
+    {
+      if ( m_waypoints.empty () )
+        {
+          if ( m_current.time <= m_next.time )
+            {
+              /*
+                Set m_next.time = -1 to make sure this doesn't happen more than once.
+                The comparison here still needs to be '<=' in the case of mobility with one waypoint.
+              */
+              m_next.time = Seconds (-1.0);
+              m_current.position = m_next.position;
+              m_current.time = now;
+              m_velocity = Vector (0,0,0);
+              NotifyCourseChange ();
+            }
+          else
+            {
+              m_current.time = now;
+            }
+
+          return;
+        }
+
+      m_current = m_next;
+      m_next = m_waypoints.front ();
+      m_waypoints.pop_front ();
+      newWaypoint = true;
+
+      const double t_span = (m_next.time - m_current.time).GetSeconds ();
+      NS_ASSERT (t_span > 0);
+      m_velocity.x = (m_next.position.x - m_current.position.x) / t_span;
+      m_velocity.y = (m_next.position.y - m_current.position.y) / t_span;
+      m_velocity.z = (m_next.position.z - m_current.position.z) / t_span;
+    }
+
+  if ( now > m_current.time ) // Won't ever be less, but may be equal
+    {
+      const double t_diff = (now - m_current.time).GetSeconds ();
+      m_current.position.x += m_velocity.x * t_diff;
+      m_current.position.y += m_velocity.y * t_diff;
+      m_current.position.z += m_velocity.z * t_diff;
+      m_current.time = now;
+    }
+
+  if ( newWaypoint )
+    {
+      NotifyCourseChange ();
+    }
+}
+Vector
+WaypointMobilityModel::DoGetPosition (void) const
+{
+  Update ();
+  return m_current.position;
+}
+void
+WaypointMobilityModel::DoSetPosition (const Vector &position)
+{
+  const Time now = Simulator::Now ();
+
+  if ( m_first && m_initialPositionIsWaypoint )
+    {
+      AddWaypoint (Waypoint (now, position));
+      return;
+    }
+
+  Update ();
+  m_current.time = std::max (now, m_next.time);
+  m_current.position = position;
+  m_velocity = Vector (0,0,0);
+
+  if ( !m_first && (now >= m_current.time) )
+    {
+      // This is only a course change if the node is actually moving
+      NotifyCourseChange ();
+    }
+}
+void
+WaypointMobilityModel::EndMobility (void)
+{
+  m_waypoints.clear ();
+  m_current.time = Seconds (std::numeric_limits<double>::infinity ());
+  m_next.time = m_current.time;
+  m_first = true;
+}
+Vector
+WaypointMobilityModel::DoGetVelocity (void) const
+{
+  return m_velocity;
+}
+
+} // namespace ns3
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/waypoint-mobility-model.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,146 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Phillip Sitbon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Phillip Sitbon <phillip@sitbon.net>
+ */
+#ifndef WAYPOINT_MOBILITY_MODEL_H
+#define WAYPOINT_MOBILITY_MODEL_H
+
+#include <stdint.h>
+#include <deque>
+#include "mobility-model.h"
+#include "ns3/vector.h"
+#include "waypoint.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief Waypoint-based mobility model.
+ *
+ * Each object determines its velocity and position at a given time
+ * from a set of ns3::Waypoint objects.  Past waypoints are discarded
+ * after the current simulation time greater than their time value.
+ *
+ * By default, the initial position of each object corresponds to the 
+ * position of the first waypoint, and the initial velocity of each 
+ * object is zero.  Upon reaching the last waypoint, object position 
+ * becomes static and velocity is zero.
+ *
+ * When a node is in between waypoint times, it moves with a constant
+ * velocity between the position at the previous waypoint and the position
+ * at the current waypoint. To make a node hold a certain position for a
+ * time interval, two waypoints with the same position (but different times)
+ * should be inserted sequentially.
+ *
+ * Waypoints can be added at any time, and setting the current position
+ * of an object will set its velocity to zero until the next waypoint time
+ * (at which time the object jumps to the next waypoint), unless there are
+ * no more waypoints in which case it will not change without user
+ * intervention.
+ *
+ * The model has two attributes with methods that allow clients to get 
+ * the next waypoint value (NextWaypoint) and the number of waypoints left 
+ * (WaypointsLeft) beyond (but not including) the next waypoint.  
+ *
+ * In addition, there are two attributes that govern model behavior.  The
+ * first, LazyNotify, governs how the model calls the CourseChange trace.
+ * By default, LazyNotify is false, which means that each time that a
+ * waypoint time is hit, an Update() is forced and the CourseChange 
+ * callback will be called.  When LazyNotify is true, Update() is suppressed
+ * at waypoint times, and CourseChange callbacks will only occur when
+ * there later are actual calls to Update () (typically when calling
+ * GetPosition ()).  This option may be enabled for execution run-time
+ * performance improvements, but when enabled, users should note that
+ * course change listeners will in general not be notified at waypoint
+ * times but instead at the next Update() following a waypoint time,
+ * and some waypoints may not be notified to course change listeners.
+ *
+ * The second, InitialPositionIsWaypoint, is false by default.  Recall
+ * that the first waypoint will set the initial position and set velocity
+ * equal to 0 until the first waypoint time.  In such a case, the
+ * call to SetPosition(), such as from a PositionAllocator, will be
+ * ignored.  However, if InitialPositionIsWaypoint is set to true
+ * and SetPosition() is called before any waypoints have been added,
+ * the SetPosition() call is treated as an initial waypoint at time zero.
+ * In such a case, when SetPosition() is treated as an initial waypoint,
+ * it should be noted that attempts to add a waypoint at the same time
+ * will cause the program to fail.
+ */
+class WaypointMobilityModel : public MobilityModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  /**
+   * Create a path with no waypoints at location (0,0,0).
+   */
+  WaypointMobilityModel ();
+  virtual ~WaypointMobilityModel ();
+
+  /**
+   * \param waypoint waypoint to append to the object path.
+   *
+   * Add a waypoint to the path of the object. The time must
+   * be greater than the previous waypoint added, otherwise
+   * a fatal error occurs. The first waypoint is set as the
+   * current position with a velocity of zero.
+   *
+   */
+  void AddWaypoint (const Waypoint &waypoint);
+
+  /**
+   * Get the waypoint that this object is traveling towards.
+   */
+  Waypoint GetNextWaypoint (void) const;
+
+  /**
+   * Get the number of waypoints left for this object, excluding
+   * the next one.
+   */
+  uint32_t WaypointsLeft (void) const;
+
+  /**
+   * Clear any existing waypoints and set the current waypoint
+   * time to infinity. Calling this is only an optimization and
+   * not required. After calling this function, adding waypoints
+   * behaves as it would for a new object.
+   */
+  void EndMobility (void);
+
+private:
+  friend class WaypointMobilityModelNotifyTest; // To allow Update() calls and access to m_current
+
+  void Update (void) const;
+  virtual void DoDispose (void);
+  virtual Vector DoGetPosition (void) const;
+  virtual void DoSetPosition (const Vector &position);
+  virtual Vector DoGetVelocity (void) const;
+
+  bool m_first;
+  bool m_lazyNotify;
+  bool m_initialPositionIsWaypoint;
+  mutable std::deque<Waypoint> m_waypoints;
+  mutable Waypoint m_current;
+  mutable Waypoint m_next;
+  mutable Vector m_velocity;
+};
+
+} // namespace ns3
+
+#endif /* WAYPOINT_MOBILITY_MODEL_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/waypoint.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,52 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Phillip Sitbon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Phillip Sitbon <phillip@sitbon.net>
+ */
+#include "waypoint.h"
+
+namespace ns3 {
+
+ATTRIBUTE_HELPER_CPP (Waypoint);
+
+Waypoint::Waypoint (const Time &waypointTime, const Vector &waypointPosition)
+  : time (waypointTime),
+  position (waypointPosition)
+{}
+Waypoint::Waypoint ()
+  : time (Seconds (0.0)),
+    position (0,0,0)
+{}
+
+std::ostream &operator << (std::ostream &os, const Waypoint &waypoint)
+{
+  os << waypoint.time.GetSeconds () << "$" << waypoint.position;
+  return os;
+}
+std::istream &operator >> (std::istream &is, Waypoint &waypoint)
+{
+  char separator;
+  is >> waypoint.time >> separator >> waypoint.position;
+  if (separator != '$')
+    {
+      is.setstate (std::ios_base::failbit);
+    }
+  return is;
+}
+
+} // namespace ns3
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/model/waypoint.h	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,70 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Phillip Sitbon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Phillip Sitbon <phillip@sitbon.net>
+ */
+#ifndef WAYPOINT_H
+#define WAYPOINT_H
+
+#include "ns3/attribute.h"
+#include "ns3/attribute-helper.h"
+#include "ns3/nstime.h"
+#include "ns3/vector.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup mobility
+ * \brief a (time, location) pair.
+ */
+class Waypoint
+{
+public:
+  /**
+   * \param waypointTime time of waypoint.
+   * \param waypointPosition position of waypoint corresponding to the given time.
+   *
+   * Create a waypoint.
+   */
+  Waypoint (const Time &waypointTime, const Vector &waypointPosition);
+
+  /**
+   * Create a waypoint at time 0 and position (0,0,0).
+   */
+  Waypoint ();
+  /* The waypoint time */
+  Time time;
+  /* The position of the waypoint */
+  Vector position;
+};
+
+/**
+ * \ingroup mobility
+ * \class ns3::WaypointValue
+ * \brief hold objects of type ns3::Waypoint
+ */
+ATTRIBUTE_HELPER_HEADER ( Waypoint);
+
+std::ostream &
+operator << (std::ostream &os, const Waypoint &waypoint);
+std::istream &
+operator >> (std::istream &is, Waypoint &waypoint);
+
+} // namespace ns3
+
+#endif /* WAYPOINT_H */
+
--- a/src/mobility/position-allocator.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,446 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "position-allocator.h"
-#include "ns3/random-variable.h"
-#include "ns3/double.h"
-#include "ns3/uinteger.h"
-#include "ns3/enum.h"
-#include "ns3/log.h"
-#include <cmath>
-
-NS_LOG_COMPONENT_DEFINE ("PositionAllocator");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (PositionAllocator);
-
-TypeId 
-PositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::PositionAllocator")
-    .SetParent<Object> ();
-  return tid;
-}
-
-PositionAllocator::PositionAllocator ()
-{
-}
-
-PositionAllocator::~PositionAllocator ()
-{}
-
-NS_OBJECT_ENSURE_REGISTERED (ListPositionAllocator);
-
-TypeId 
-ListPositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ListPositionAllocator")
-    .SetParent<PositionAllocator> ()
-    .AddConstructor<ListPositionAllocator> ()
-    ;
-  return tid;
-}
-ListPositionAllocator::ListPositionAllocator ()
-{}
-void 
-ListPositionAllocator::Add (Vector v)
-{
-  m_positions.push_back (v);
-  m_current = m_positions.begin ();
-}
-Vector 
-ListPositionAllocator::GetNext (void) const
-{
-  Vector v = *m_current;
-  m_current++;
-  if (m_current == m_positions.end()) 
-    {
-      m_current = m_positions.begin ();
-    }
-  return v;
-}
-
-NS_OBJECT_ENSURE_REGISTERED (GridPositionAllocator);
-
-TypeId 
-GridPositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::GridPositionAllocator")
-    .SetParent<PositionAllocator> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<GridPositionAllocator> ()
-    .AddAttribute ("GridWidth", "The number of objects layed out on a line.",
-                   UintegerValue (10),
-                   MakeUintegerAccessor (&GridPositionAllocator::m_n),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("MinX", "The x coordinate where the grid starts.",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&GridPositionAllocator::m_xMin),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MinY", "The y coordinate where the grid starts.",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&GridPositionAllocator::m_yMin),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("DeltaX", "The x space between objects.",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&GridPositionAllocator::m_deltaX),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("DeltaY", "The y space between objects.",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&GridPositionAllocator::m_deltaY),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("LayoutType", "The type of layout.",
-                   EnumValue (ROW_FIRST),
-                   MakeEnumAccessor (&GridPositionAllocator::m_layoutType),
-                   MakeEnumChecker (ROW_FIRST, "RowFirst",
-                                    COLUMN_FIRST, "ColumnFirst"))
-    ;
-  return tid;
-}
-GridPositionAllocator::GridPositionAllocator ()
-  : m_current (0)
-{}
-
-void 
-GridPositionAllocator::SetMinX (double xMin)
-{
-  m_xMin = xMin;
-}
-void 
-GridPositionAllocator::SetMinY (double yMin)
-{
-  m_yMin = yMin;
-}
-void 
-GridPositionAllocator::SetDeltaX (double deltaX)
-{
-  m_deltaX = deltaX;
-}
-void 
-GridPositionAllocator::SetDeltaY (double deltaY)
-{
-  m_deltaY = deltaY;
-}
-void 
-GridPositionAllocator::SetN (uint32_t n)
-{
-  m_n = n;
-}
-void 
-GridPositionAllocator::SetLayoutType (enum LayoutType layoutType)
-{
-  m_layoutType = layoutType;
-}
-
-double 
-GridPositionAllocator::GetMinX (void) const
-{
-  return m_xMin;
-}
-double 
-GridPositionAllocator::GetMinY (void) const
-{
-  return m_yMin;
-}
-double 
-GridPositionAllocator::GetDeltaX (void) const
-{
-  return m_deltaX;
-}
-double 
-GridPositionAllocator::GetDeltaY (void) const
-{
-  return m_deltaY;
-}
-uint32_t 
-GridPositionAllocator::GetN (void) const
-{
-  return m_n;
-}
-enum GridPositionAllocator::LayoutType 
-GridPositionAllocator::GetLayoutType (void) const
-{
-  return m_layoutType;
-}
-
-Vector 
-GridPositionAllocator::GetNext (void) const
-{
-  double x = 0.0, y = 0.0;
-  switch (m_layoutType) {
-  case ROW_FIRST:
-    x = m_xMin + m_deltaX * (m_current % m_n);
-    y = m_yMin + m_deltaY * (m_current / m_n);
-    break;
-  case COLUMN_FIRST:
-    x = m_xMin + m_deltaX * (m_current / m_n);
-    y = m_yMin + m_deltaY * (m_current % m_n);
-    break;
-  }
-  m_current++;
-  return Vector (x, y, 0.0);
-}
-
-
-NS_OBJECT_ENSURE_REGISTERED (RandomRectanglePositionAllocator);
-
-TypeId
-RandomRectanglePositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomRectanglePositionAllocator")
-    .SetParent<PositionAllocator> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<RandomRectanglePositionAllocator> ()
-    .AddAttribute ("X",
-                   "A random variable which represents the x coordinate of a position in a random rectangle.",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),
-                   MakeRandomVariableAccessor (&RandomRectanglePositionAllocator::m_x),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Y",
-                   "A random variable which represents the y coordinate of a position in a random rectangle.",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),
-                   MakeRandomVariableAccessor (&RandomRectanglePositionAllocator::m_y),
-                   MakeRandomVariableChecker ());
-  return tid;
-}
-
-RandomRectanglePositionAllocator::RandomRectanglePositionAllocator ()
-{}
-RandomRectanglePositionAllocator::~RandomRectanglePositionAllocator ()
-{}
-
-void 
-RandomRectanglePositionAllocator::SetX (RandomVariable x)
-{
-  m_x = x;
-}
-void 
-RandomRectanglePositionAllocator::SetY (RandomVariable y)
-{
-  m_y = y;
-}
-
-Vector
-RandomRectanglePositionAllocator::GetNext (void) const
-{
-  double x = m_x.GetValue ();
-  double y = m_y.GetValue ();
-  return Vector (x, y, 0.0);
-}
-
-
-NS_OBJECT_ENSURE_REGISTERED (RandomBoxPositionAllocator);
-
-TypeId
-RandomBoxPositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomBoxPositionAllocator")
-    .SetParent<PositionAllocator> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<RandomBoxPositionAllocator> ()
-    .AddAttribute ("X",
-                   "A random variable which represents the x coordinate of a position in a random box.",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),
-                   MakeRandomVariableAccessor (&RandomBoxPositionAllocator::m_x),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Y",
-                   "A random variable which represents the y coordinate of a position in a random box.",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),
-                   MakeRandomVariableAccessor (&RandomBoxPositionAllocator::m_y),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Z",
-                   "A random variable which represents the z coordinate of a position in a random box.",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),
-                   MakeRandomVariableAccessor (&RandomBoxPositionAllocator::m_z),
-                   MakeRandomVariableChecker ());
-  return tid;
-}
-
-RandomBoxPositionAllocator::RandomBoxPositionAllocator ()
-{}
-RandomBoxPositionAllocator::~RandomBoxPositionAllocator ()
-{}
-
-void 
-RandomBoxPositionAllocator::SetX (RandomVariable x)
-{
-  m_x = x;
-}
-void 
-RandomBoxPositionAllocator::SetY (RandomVariable y)
-{
-  m_y = y;
-}
-void 
-RandomBoxPositionAllocator::SetZ (RandomVariable z)
-{
-  m_z = z;
-}
-
-Vector
-RandomBoxPositionAllocator::GetNext (void) const
-{
-  double x = m_x.GetValue ();
-  double y = m_y.GetValue ();
-  double z = m_z.GetValue ();
-  return Vector (x, y, z);
-}
-
-
-
-NS_OBJECT_ENSURE_REGISTERED (RandomDiscPositionAllocator);
-
-TypeId
-RandomDiscPositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomDiscPositionAllocator")
-    .SetParent<PositionAllocator> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<RandomDiscPositionAllocator> ()
-    .AddAttribute ("Theta",
-                   "A random variable which represents the angle (gradients) of a position in a random disc.",
-                   RandomVariableValue (UniformVariable (0.0, 6.2830)),
-                   MakeRandomVariableAccessor (&RandomDiscPositionAllocator::m_theta),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Rho",
-                   "A random variable which represents the radius of a position in a random disc.",
-                   RandomVariableValue (UniformVariable (0.0, 200.0)),
-                   MakeRandomVariableAccessor (&RandomDiscPositionAllocator::m_rho),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("X",
-                   "The x coordinate of the center of the random position disc.",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_x),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Y",
-                   "The y coordinate of the center of the random position disc.",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_y),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-}   
-
-RandomDiscPositionAllocator::RandomDiscPositionAllocator ()
-{}
-RandomDiscPositionAllocator::~RandomDiscPositionAllocator ()
-{}
-
-void 
-RandomDiscPositionAllocator::SetTheta (RandomVariable theta)
-{
-  m_theta = theta;
-}
-void 
-RandomDiscPositionAllocator::SetRho (RandomVariable rho)
-{
-  m_rho = rho;
-}
-void 
-RandomDiscPositionAllocator::SetX (double x)
-{
-  m_x = x;
-}
-void 
-RandomDiscPositionAllocator::SetY (double y)
-{
-  m_y = y;
-}
-Vector
-RandomDiscPositionAllocator::GetNext (void) const
-{
-  double theta = m_theta.GetValue ();
-  double rho = m_rho.GetValue ();
-  double x = m_x + std::cos (theta) * rho;
-  double y = m_y + std::sin (theta) * rho;
-  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
-  return Vector (x, y, 0.0);
-}
-
-
-
-NS_OBJECT_ENSURE_REGISTERED (UniformDiscPositionAllocator);
-
-TypeId
-UniformDiscPositionAllocator::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::UniformDiscPositionAllocator")
-    .SetParent<PositionAllocator> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<UniformDiscPositionAllocator> ()
-    .AddAttribute ("rho",
-                   "The radius of the disc",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_rho),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("X",
-                   "The x coordinate of the center of the  disc.",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_x),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Y",
-                   "The y coordinate of the center of the  disc.",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_y),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-}   
-
-UniformDiscPositionAllocator::UniformDiscPositionAllocator ()
-{}
-UniformDiscPositionAllocator::~UniformDiscPositionAllocator ()
-{}
-
-void 
-UniformDiscPositionAllocator::SetRho (double rho)
-{
-  m_rho = rho;
-}
-void 
-UniformDiscPositionAllocator::SetX (double x)
-{
-  m_x = x;
-}
-void 
-UniformDiscPositionAllocator::SetY (double y)
-{
-  m_y = y;
-}
-Vector
-UniformDiscPositionAllocator::GetNext (void) const
-{
-  UniformVariable r (-m_rho, m_rho);
-  double x,y;
-  do
-    {
-      x = r.GetValue ();
-      y = r.GetValue ();
-    }
-  while (sqrt(x*x + y*y) > m_rho);
-  
-  x += m_x;
-  y += m_y;
-  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
-  return Vector (x, y, 0.0);
-}
-
-
-} // namespace ns3 
--- a/src/mobility/position-allocator.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,280 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef POSITION_ALLOCATOR_H
-#define POSITION_ALLOCATOR_H
-
-#include "ns3/object.h"
-#include "ns3/random-variable.h"
-#include "ns3/vector.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Allocate a set of positions. The allocation strategy is implemented in subclasses.
- *
- * This is a pure abstract base class.
- */
-class PositionAllocator : public Object
-{
-public:
-  static TypeId GetTypeId (void);
-  PositionAllocator ();
-  virtual ~PositionAllocator ();
-  /**
-   * \return the next chosen position.
-   *
-   * This method _must_ be implement in subclasses.
-   */
-  virtual Vector GetNext (void) const = 0;
-};
-
-/**
- * \ingroup mobility
- * \brief Allocate positions from a deterministic list specified by the user.
- *
- * The first call to ListPositionAllocator::GetNext  will return the
- * first element of the list, the second call, the second element, and so on.
- */
-class ListPositionAllocator : public PositionAllocator
-{
-public:
-  static TypeId GetTypeId (void);
-  ListPositionAllocator ();
-
-  /**
-   * \param v the position to append at the end of the list of positions to return from GetNext.
-   */
-  void Add (Vector v);
-  virtual Vector GetNext (void) const;
-private:
-  std::vector<Vector> m_positions;
-  mutable std::vector<Vector>::const_iterator m_current;
-};
-
-/**
- * \ingroup mobility
- * \brief Allocate positions on a rectangular 2d grid.
- */
-class GridPositionAllocator : public PositionAllocator
-{
-public:
-  static TypeId GetTypeId (void);
-
-  /**
-   * Determine whether positions are allocated row first or column first.
-   */
-  enum LayoutType {
-    /**
-     * In row-first mode, positions are allocated on the first row until
-     * N positions have been allocated. Then, the second row located a yMin + yDelta
-     * is used to allocate positions.
-     */
-    ROW_FIRST,
-    /**
-     * In column-first mode, positions are allocated on the first column until
-     * N positions have been allocated. Then, the second column located a xMin + xDelta
-     * is used to allocate positions.
-     */
-    COLUMN_FIRST
-  };
-
-  GridPositionAllocator ();
-
-  /**
-   * \param xMin the x coordinate where layout will start.
-   */
-  void SetMinX (double xMin);
-  /**
-   * \param yMin the y coordinate where layout will start
-   */
-  void SetMinY (double yMin);
-  /**
-   * \param deltaX the x interval between two x-consecutive positions.
-   */
-  void SetDeltaX (double deltaX);
-  /**
-   * \param deltaY the y interval between two y-consecutive positions.
-   */
-  void SetDeltaY (double deltaY);
-  /**
-   * \param n the number of positions allocated on each row (or each column)
-   *        before switching to the next column (or row).
-   */
-  void SetN (uint32_t n);
-  /**
-   * \param layoutType the type of layout to use (row first or column first).
-   */
-  void SetLayoutType (enum LayoutType layoutType);
-
-  /**
-   * \return the x coordinate of the first allocated position.
-   */
-  double GetMinX (void) const;
-  /**
-   * \return the y coordinate of the first allocated position.
-   */
-  double GetMinY (void) const;
-  /**
-   * \return the x interval between two x-consecutive positions.
-   */
-  double GetDeltaX (void) const;
-  /**
-   * \return the y interval between two y-consecutive positions.
-   */
-  double GetDeltaY (void) const;
-  /**
-   * \return the number of positions to allocate on each row or each column.
-   */
-  uint32_t GetN (void) const;
-  /**
-   * \return the currently-selected layout type.
-   */
-  enum LayoutType GetLayoutType (void) const;
-  
-
-  virtual Vector GetNext (void) const;
-private:
-  mutable uint32_t m_current;
-  enum LayoutType m_layoutType;
-  double m_xMin;
-  double m_yMin;
-  uint32_t m_n;
-  double m_deltaX;
-  double m_deltaY;
-};
-
-/**
- * \ingroup mobility
- * \brief Allocate random positions within a rectangle according to a pair of random variables.
- */
-class RandomRectanglePositionAllocator : public PositionAllocator
-{
-public:
-  static TypeId GetTypeId (void);
-  RandomRectanglePositionAllocator ();
-  virtual ~RandomRectanglePositionAllocator ();
-
-  void SetX (RandomVariable x);
-  void SetY (RandomVariable y);
-
-  virtual Vector GetNext (void) const;
-private:
-  RandomVariable m_x;
-  RandomVariable m_y;
-};
-
-/**
- * \ingroup mobility
- * \brief Allocate random positions within a 3D box according to a set of three random variables.
- */
-class RandomBoxPositionAllocator : public PositionAllocator
-{
-public:
-  static TypeId GetTypeId (void);
-  RandomBoxPositionAllocator ();
-  virtual ~RandomBoxPositionAllocator ();
-
-  void SetX (RandomVariable x);
-  void SetY (RandomVariable y);
-  void SetZ (RandomVariable z);
-
-  virtual Vector GetNext (void) const;
-private:
-  RandomVariable m_x;
-  RandomVariable m_y;
-  RandomVariable m_z;
-};
-
-/**
- * \ingroup mobility
- * \brief Allocate random positions within a disc according to a given distribution for the polar coordinates of each node 
-          with respect to the provided center of the disc 
- */
-class RandomDiscPositionAllocator : public PositionAllocator
-{
-public:
-  static TypeId GetTypeId (void);
-  RandomDiscPositionAllocator ();
-  virtual ~RandomDiscPositionAllocator ();
-
-  void SetTheta (RandomVariable theta);
-  void SetRho (RandomVariable rho);
-  void SetX (double x);
-  void SetY (double y);
-
-  virtual Vector GetNext (void) const;
-private:
-  RandomVariable m_theta;
-  RandomVariable m_rho;
-  double m_x;
-  double m_y;
-};
-
-
-/**
- * \ingroup mobility
- * \brief Allocate the positions uniformely (with constant density) randomly within a disc.
- *
- * UniformDiscPositionAllocator allocates the positions randomly within a disc \f$ D \f$ lying on the
- * plane \f$ z=0 \f$ and having center at coordinates \f$ (x,y,0) \f$
- * and radius \f$ \rho \f$. The random positions are chosen such that,
- * for any subset \f$ S \subset D \f$, the expected value of the
- * fraction of points which fall into \f$ S \subset D \f$ corresponds
- * to \f$ \frac{|S|}{|D|} \f$, i.e., to the ratio of the area of the
- * subset to the area of the whole disc. 
- *
- * \note using UniformDiscPositionAllocator is not equivalent to using
- * a RandomDiscPositionAllocator with a uniformly-distributed radius,
- * since doing that would results in a point distribution which is
- * more dense towards the center of the disc.
- */
-class UniformDiscPositionAllocator : public PositionAllocator
-{
-public:
-  static TypeId GetTypeId (void);
-  UniformDiscPositionAllocator ();
-  virtual ~UniformDiscPositionAllocator ();
-
-  /** 
-   * \param rho the value of the radius of the disc
-   */
-  void SetRho (double rho);
-
-  /** 
-   * \param x  the X coordinate of the center of the disc
-   */
-  void SetX (double x);
-
-  /** 
-   * \param y   the Y coordinate of the center of the disc 
-   */
-  void SetY (double y);
-
-  virtual Vector GetNext (void) const;
-private:
-  double m_rho;
-  double m_x;
-  double m_y;
-};
-
-} // namespace ns3
-
-#endif /* RANDOM_POSITION_H */
--- a/src/mobility/random-direction-2d-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "ns3/simulator.h"
-#include <algorithm>
-#include <cmath>
-#include "random-direction-2d-mobility-model.h"
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE ("RandomDirection2dMobilityModel");
-
-namespace ns3 {
-
-const double RandomDirection2dMobilityModel::PI = 3.14159265358979323846;
-
-NS_OBJECT_ENSURE_REGISTERED (RandomDirection2dMobilityModel);
-
-
-TypeId
-RandomDirection2dMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomDirection2dMobilityModel")
-    .SetParent<MobilityModel> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<RandomDirection2dMobilityModel> ()
-    .AddAttribute ("Bounds", "The 2d bounding area",
-                   RectangleValue (Rectangle (-100, 100, -100, 100)),
-                   MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds),
-                   MakeRectangleChecker ())
-    .AddAttribute ("Speed", "A random variable to control the speed (m/s).",
-                   RandomVariableValue (UniformVariable (1.0, 2.0)),
-                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_speed),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Pause", "A random variable to control the pause (s).",
-                   RandomVariableValue (ConstantVariable (2.0)),
-                   MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_pause),
-                   MakeRandomVariableChecker ())
-    ;
-  return tid;
-}
-
-void 
-RandomDirection2dMobilityModel::DoDispose (void)
-{
-  // chain up.
-  MobilityModel::DoDispose ();
-}
-void
-RandomDirection2dMobilityModel::DoStart (void)
-{
-  DoStartPrivate ();
-  MobilityModel::DoStart ();
-}
-
-void
-RandomDirection2dMobilityModel::DoStartPrivate (void)
-{
-  double direction = m_direction.GetValue (0, 2 * PI);
-  SetDirectionAndSpeed (direction);
-}
-
-void
-RandomDirection2dMobilityModel::BeginPause (void)
-{
-  m_helper.Update ();
-  m_helper.Pause ();
-  Time pause = Seconds (m_pause.GetValue ());
-  m_event.Cancel ();
-  m_event = Simulator::Schedule (pause, &RandomDirection2dMobilityModel::ResetDirectionAndSpeed, this);
-  NotifyCourseChange ();
-}
-
-void
-RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  m_helper.UpdateWithBounds (m_bounds);
-  Vector position = m_helper.GetCurrentPosition ();
-  double speed = m_speed.GetValue ();
-  const Vector vector (std::cos (direction) * speed,
-                       std::sin (direction) * speed,
-                       0.0);
-  m_helper.SetVelocity (vector);
-  m_helper.Unpause ();
-  Vector next = m_bounds.CalculateIntersection (position, vector);
-  Time delay = Seconds (CalculateDistance (position, next) / speed);
-  m_event.Cancel ();
-  m_event = Simulator::Schedule (delay,
-				 &RandomDirection2dMobilityModel::BeginPause, this);
-  NotifyCourseChange ();
-}
-void
-RandomDirection2dMobilityModel::ResetDirectionAndSpeed (void)
-{
-  double direction = m_direction.GetValue (0, PI);
-  
-  m_helper.UpdateWithBounds (m_bounds);
-  Vector position = m_helper.GetCurrentPosition ();
-  switch (m_bounds.GetClosestSide (position))
-    {
-    case Rectangle::RIGHT:
-      direction += PI / 2;
-      break;
-    case Rectangle::LEFT:
-      direction += - PI / 2;
-      break;
-    case Rectangle::TOP:
-      direction += PI;
-      break;
-    case Rectangle::BOTTOM:
-      direction += 0.0;
-      break;
-    }
-  SetDirectionAndSpeed (direction);
-}
-Vector
-RandomDirection2dMobilityModel::DoGetPosition (void) const
-{
-  m_helper.UpdateWithBounds (m_bounds);
-  return m_helper.GetCurrentPosition ();
-}
-void
-RandomDirection2dMobilityModel::DoSetPosition (const Vector &position)
-{
-  m_helper.SetPosition (position);
-  Simulator::Remove (m_event);
-  m_event.Cancel ();
-  m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::DoStartPrivate, this);
-}
-Vector
-RandomDirection2dMobilityModel::DoGetVelocity (void) const
-{
-  return m_helper.GetVelocity ();
-}
-
-
-
-} // namespace ns3
--- a/src/mobility/random-direction-2d-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef RANDOM_DIRECTION_MOBILITY_MODEL_H
-#define RANDOM_DIRECTION_MOBILITY_MODEL_H
-
-#include "ns3/object.h"
-#include "ns3/ptr.h"
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-#include "ns3/rectangle.h"
-#include "ns3/random-variable.h"
-#include "mobility-model.h"
-#include "constant-velocity-helper.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Random direction mobility model.
- *
- * The movement of objects is based on random directions: each object
- * pauses for a specific delay, chooses a random direction and speed and 
- * then travels in the specific direction until it reaches one of
- * the boundaries of the model. When it reaches the boundary, it pauses,
- * selects a new direction and speed, aso.
- */
-class RandomDirection2dMobilityModel : public MobilityModel
-{
- public:
-  static TypeId GetTypeId (void);
-
- private:
-  void ResetDirectionAndSpeed (void);
-  void BeginPause (void);
-  void SetDirectionAndSpeed (double direction);
-  void InitializeDirectionAndSpeed (void);
-  void DoStartPrivate (void);
-  virtual void DoDispose (void);
-  virtual void DoStart (void);
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  static const double PI;
-  UniformVariable m_direction;
-  Rectangle m_bounds;
-  RandomVariable m_speed;
-  RandomVariable m_pause;
-  EventId m_event;
-  ConstantVelocityHelper m_helper;
-};
-
-} // namespace ns3
-
-#endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */
--- a/src/mobility/random-walk-2d-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "random-walk-2d-mobility-model.h"
-#include "ns3/enum.h"
-#include "ns3/double.h"
-#include "ns3/simulator.h"
-#include "ns3/log.h"
-#include <cmath>
-
-NS_LOG_COMPONENT_DEFINE ("RandomWalk2d");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (RandomWalk2dMobilityModel);
-
-TypeId
-RandomWalk2dMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomWalk2dMobilityModel")
-    .SetParent<MobilityModel> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<RandomWalk2dMobilityModel> ()
-    .AddAttribute ("Bounds",
-                   "Bounds of the area to cruise.",
-                   RectangleValue (Rectangle (0.0, 0.0, 100.0, 100.0)),
-                   MakeRectangleAccessor (&RandomWalk2dMobilityModel::m_bounds),
-                   MakeRectangleChecker ())
-    .AddAttribute ("Time",
-                   "Change current direction and speed after moving for this delay.",
-                   TimeValue (Seconds (1.0)),
-                   MakeTimeAccessor (&RandomWalk2dMobilityModel::m_modeTime),
-                   MakeTimeChecker ())
-    .AddAttribute ("Distance",
-                   "Change current direction and speed after moving for this distance.",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&RandomWalk2dMobilityModel::m_modeDistance),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Mode",
-                   "The mode indicates the condition used to "
-                   "change the current speed and direction",
-                   EnumValue (RandomWalk2dMobilityModel::MODE_DISTANCE),
-                   MakeEnumAccessor (&RandomWalk2dMobilityModel::m_mode),
-                   MakeEnumChecker (RandomWalk2dMobilityModel::MODE_DISTANCE, "Distance",
-                                    RandomWalk2dMobilityModel::MODE_TIME, "Time"))
-    .AddAttribute ("Direction",
-                   "A random variable used to pick the direction (gradients).",
-                   RandomVariableValue (UniformVariable (0.0, 6.283184)),
-                   MakeRandomVariableAccessor (&RandomWalk2dMobilityModel::m_direction),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Speed",
-                   "A random variable used to pick the speed (m/s).",
-                   RandomVariableValue (UniformVariable (2.0, 4.0)),
-                   MakeRandomVariableAccessor (&RandomWalk2dMobilityModel::m_speed),
-                   MakeRandomVariableChecker ());
-  return tid;
-}
-
-void
-RandomWalk2dMobilityModel::DoStart (void)
-{
-  DoStartPrivate ();
-  MobilityModel::DoStart ();
-}
-
-void
-RandomWalk2dMobilityModel::DoStartPrivate (void)
-{
-  m_helper.Update ();
-  double speed = m_speed.GetValue ();
-  double direction = m_direction.GetValue ();
-  Vector vector (std::cos (direction) * speed,
-                 std::sin (direction) * speed,
-                 0.0);
-  m_helper.SetVelocity (vector);
-  m_helper.Unpause ();
-
-  Time delayLeft;
-  if (m_mode == RandomWalk2dMobilityModel::MODE_TIME)
-    {
-      delayLeft = m_modeTime;
-    }
-  else
-    {
-      delayLeft = Seconds (m_modeDistance / speed); 
-    }
-  DoWalk (delayLeft);
-}
-
-void
-RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
-{
-  Vector position = m_helper.GetCurrentPosition ();
-  Vector speed = m_helper.GetVelocity ();
-  Vector nextPosition = position;
-  nextPosition.x += speed.x * delayLeft.GetSeconds ();
-  nextPosition.y += speed.y * delayLeft.GetSeconds ();
-  m_event.Cancel ();
-  if (m_bounds.IsInside (nextPosition))
-    {
-      m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::DoStartPrivate, this);
-    }
-  else
-    {
-      nextPosition = m_bounds.CalculateIntersection (position, speed);
-      Time delay = Seconds ((nextPosition.x - position.x) / speed.x);
-      m_event = Simulator::Schedule (delay, &RandomWalk2dMobilityModel::Rebound, this,
-                                     delayLeft - delay);      
-    }  
-  NotifyCourseChange ();
-}
-
-void
-RandomWalk2dMobilityModel::Rebound (Time delayLeft)
-{
-  m_helper.UpdateWithBounds (m_bounds);
-  Vector position = m_helper.GetCurrentPosition ();
-  Vector speed = m_helper.GetVelocity ();
-  switch (m_bounds.GetClosestSide (position))
-    {
-    case Rectangle::RIGHT:
-    case Rectangle::LEFT:
-      speed.x = - speed.x;
-      break;
-    case Rectangle::TOP:
-    case Rectangle::BOTTOM:
-      speed.y = - speed.y;
-      break;
-    }
-  m_helper.SetVelocity (speed);
-  m_helper.Unpause ();
-  DoWalk (delayLeft);
-}
-
-void
-RandomWalk2dMobilityModel::DoDispose (void)
-{
-  // chain up
-  MobilityModel::DoDispose ();
-}
-Vector
-RandomWalk2dMobilityModel::DoGetPosition (void) const
-{
-  m_helper.UpdateWithBounds (m_bounds);
-  return m_helper.GetCurrentPosition ();
-}
-void
-RandomWalk2dMobilityModel::DoSetPosition (const Vector &position)
-{
-  NS_ASSERT (m_bounds.IsInside (position));
-  m_helper.SetPosition (position);
-  Simulator::Remove (m_event);
-  m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::DoStartPrivate, this);
-}
-Vector
-RandomWalk2dMobilityModel::DoGetVelocity (void) const
-{
-  return m_helper.GetVelocity ();
-}
-
-
-
-} // namespace ns3
--- a/src/mobility/random-walk-2d-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006,2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef RANDOM_WALK_2D_MOBILITY_MODEL_H
-#define RANDOM_WALK_2D_MOBILITY_MODEL_H
-
-#include "ns3/object.h"
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-#include "ns3/rectangle.h"
-#include "ns3/random-variable.h"
-#include "mobility-model.h"
-#include "constant-velocity-helper.h"
-
-namespace ns3 {
-
-
-/**
- * \ingroup mobility
- * \brief 2D random walk mobility model.
- *
- * Each instance moves with a speed and direction choosen at random
- * with the user-provided random variables until
- * either a fixed distance has been walked or until a fixed amount
- * of time. If we hit one of the boundaries (specified by a rectangle),
- * of the model, we rebound on the boundary with a reflexive angle
- * and speed. This model is often identified as a brownian motion
- * model.
- */
-class RandomWalk2dMobilityModel : public MobilityModel 
-{
- public:
-  static TypeId GetTypeId (void);
-
-  enum Mode  {
-    MODE_DISTANCE,
-    MODE_TIME
-  };
-
- private:
-  void Rebound (Time timeLeft);
-  void DoWalk (Time timeLeft);
-  void DoStartPrivate (void);
-  virtual void DoDispose (void);
-  virtual void DoStart (void);
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  ConstantVelocityHelper m_helper;
-  EventId m_event;
-  enum Mode m_mode;
-  double m_modeDistance;
-  Time m_modeTime;
-  RandomVariable m_speed;
-  RandomVariable m_direction;
-  Rectangle m_bounds;
-};
-
-
-} // namespace ns3
-
-#endif /* RANDOM_WALK_2D_MOBILITY_MODEL_H */
--- a/src/mobility/random-waypoint-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include <cmath>
-#include "ns3/simulator.h"
-#include "ns3/random-variable.h"
-#include "ns3/pointer.h"
-#include "random-waypoint-mobility-model.h"
-#include "position-allocator.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (RandomWaypointMobilityModel);
-
-TypeId
-RandomWaypointMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomWaypointMobilityModel")
-    .SetParent<MobilityModel> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<RandomWaypointMobilityModel> ()
-    .AddAttribute ("Speed",
-                   "A random variable used to pick the speed of a random waypoint model.",
-                   RandomVariableValue (UniformVariable (0.3, 0.7)),
-                   MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_speed),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("Pause",
-                   "A random variable used to pick the pause of a random waypoint model.",
-                   RandomVariableValue (ConstantVariable (2.0)),
-                   MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_pause),
-                   MakeRandomVariableChecker ())
-    .AddAttribute ("PositionAllocator",
-                   "The position model used to pick a destination point.",
-                   PointerValue (),
-                   MakePointerAccessor (&RandomWaypointMobilityModel::m_position),
-                   MakePointerChecker<PositionAllocator> ());
-  
-  return tid;
-}
-
-void
-RandomWaypointMobilityModel::BeginWalk (void)
-{
-  m_helper.Update ();
-  Vector m_current = m_helper.GetCurrentPosition ();
-  Vector destination = m_position->GetNext ();
-  double speed = m_speed.GetValue ();
-  double dx = (destination.x - m_current.x);
-  double dy = (destination.y - m_current.y);
-  double dz = (destination.z - m_current.z);
-  double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
-
-  m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
-  m_helper.Unpause ();
-  Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
-  m_event.Cancel ();
-  m_event = Simulator::Schedule (travelDelay,
-				 &RandomWaypointMobilityModel::DoStartPrivate, this);
-  NotifyCourseChange ();
-}
-
-void
-RandomWaypointMobilityModel::DoStart (void)
-{
-  DoStartPrivate ();
-  MobilityModel::DoStart ();
-}
-
-void
-RandomWaypointMobilityModel::DoStartPrivate (void)
-{
-  m_helper.Update ();
-  m_helper.Pause ();
-  Time pause = Seconds (m_pause.GetValue ());
-  m_event = Simulator::Schedule (pause, &RandomWaypointMobilityModel::BeginWalk, this);
-  NotifyCourseChange ();
-}
-
-Vector
-RandomWaypointMobilityModel::DoGetPosition (void) const
-{
-  m_helper.Update ();
-  return m_helper.GetCurrentPosition ();
-}
-void 
-RandomWaypointMobilityModel::DoSetPosition (const Vector &position)
-{
-  m_helper.SetPosition (position);
-  Simulator::Remove (m_event);
-  m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::DoStartPrivate, this);
-}
-Vector
-RandomWaypointMobilityModel::DoGetVelocity (void) const
-{
-  return m_helper.GetVelocity ();
-}
-
-
-} // namespace ns3
--- a/src/mobility/random-waypoint-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef RANDOM_WAYPOINT_MOBILITY_MODEL_H
-#define RANDOM_WAYPOINT_MOBILITY_MODEL_H
-
-#include "constant-velocity-helper.h"
-#include "mobility-model.h"
-#include "position-allocator.h"
-#include "ns3/ptr.h"
-#include "ns3/random-variable.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Random waypoint mobility model.
- *
- * Each object chooses a random destination "waypoint", a random speed,
- * and a random pause time: it then pauses for the specified pause time,
- * and starts moving towards the specified destination with the specified
- * speed. Once the destination is reached the process starts again.
- *
- * The implementation of this model is not 2d-specific. i.e. if you provide
- * a 3d random waypoint position model to this mobility model, the model 
- * will still work. There is no 3d position allocator for now but it should
- * be trivial to add one.
- */
-class RandomWaypointMobilityModel : public MobilityModel
-{
-public:
-  static TypeId GetTypeId (void);
-protected:
-  virtual void DoStart (void);
-private:
-  void BeginWalk (void);
-  void DoStartPrivate (void);
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  ConstantVelocityHelper m_helper;
-  Ptr<PositionAllocator> m_position;
-  RandomVariable m_speed;
-  RandomVariable m_pause;
-  EventId m_event;
-};
-
-} // namespace ns3
-
-#endif /* RANDOM_WAYPOINT_MOBILITY_MODEL_H */
--- a/src/mobility/rectangle.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "rectangle.h"
-#include "ns3/vector.h"
-#include "ns3/assert.h"
-#include "ns3/fatal-error.h"
-#include <cmath>
-#include <algorithm>
-#include <sstream> 
-
-namespace ns3 {
-
-Rectangle::Rectangle (double _xMin, double _xMax,
-		      double _yMin, double _yMax)
-  : xMin (_xMin),
-    xMax (_xMax),
-    yMin (_yMin),
-    yMax (_yMax)
-{}
-
-Rectangle::Rectangle ()
-  : xMin (0.0),
-    xMax (0.0),
-    yMin (0.0),
-    yMax (0.0)
-{}
-
-bool 
-Rectangle::IsInside (const Vector &position) const
-{
-  return 
-    position.x <= this->xMax && position.x >= this->xMin &&
-    position.y <= this->yMax && position.y >= this->yMin;
-}
-
-Rectangle::Side 
-Rectangle::GetClosestSide (const Vector &position) const
-{
-  double xMinDist = std::abs (position.x - this->xMin);
-  double xMaxDist = std::abs (this->xMax - position.x);
-  double yMinDist = std::abs (position.y - this->yMin);
-  double yMaxDist = std::abs (this->yMax - position.y);
-  double minX = std::min (xMinDist, xMaxDist);
-  double minY = std::min (yMinDist, yMaxDist);
-  if (minX < minY)
-    {
-      if (xMinDist < xMaxDist)
-        {
-          return LEFT;
-        }
-      else
-        {
-          return RIGHT;
-        }
-    }
-  else
-    {
-      if (yMinDist < yMaxDist)
-        {
-          return BOTTOM;
-        }
-      else
-        {
-          return TOP;
-        }
-    }
-}
-
-Vector
-Rectangle::CalculateIntersection (const Vector &current, const Vector &speed) const
-{
-  NS_ASSERT (IsInside (current));
-  double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
-  double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y;
-  double yMaxX = current.x + (this->yMax - current.y) / speed.y * speed.x;
-  double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x;
-  bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin);
-  bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin);
-  bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin);
-  bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin);
-  if (xMaxYOk && speed.x >= 0)
-    {
-      return Vector (this->xMax, xMaxY, 0.0);
-    }
-  else if (xMinYOk && speed.x <= 0)
-    {
-      return Vector (this->xMin, xMinY, 0.0);
-    }
-  else if (yMaxXOk && speed.y >= 0)
-    {
-      return Vector (yMaxX, this->yMax, 0.0);
-    }
-  else if (yMinXOk && speed.y <= 0)
-    {
-      return Vector (yMinX, this->yMin, 0.0);
-    }
-  else
-    {
-      NS_ASSERT (false);
-      // quiet compiler
-      return Vector (0.0, 0.0, 0.0);
-    }
-
-}
-
-ATTRIBUTE_HELPER_CPP (Rectangle);
-
-std::ostream &
-operator << (std::ostream &os, const Rectangle &rectangle)
-{
-  os << rectangle.xMin << "|" << rectangle.xMax << "|" << rectangle.yMin << "|" << rectangle.yMax;
-  return os;
-}
-std::istream &
-operator >> (std::istream &is, Rectangle &rectangle)
- {
-  char c1, c2, c3;
-  is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax;
-  if (c1 != '|' ||
-      c2 != '|' ||
-      c3 != '|')
-    {
-      is.setstate (std::ios_base::failbit);
-    }
-  return is;
-}
-
-
-} // namespace ns3
--- a/src/mobility/rectangle.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef RECTANGLE_H
-#define RECTANGLE_H
-
-#include "ns3/attribute.h"
-#include "ns3/attribute-helper.h"
-#include "ns3/vector.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief a 2d rectangle
- */
-class Rectangle
-{
-public:
-  enum Side {
-    RIGHT,
-    LEFT,
-    TOP,
-    BOTTOM
-  };
-  /**
-   * \param _xMin x coordinates of left boundary.
-   * \param _xMax x coordinates of right boundary.
-   * \param _yMin y coordinates of bottom boundary.
-   * \param _yMax y coordinates of top boundary.
-   *
-   * Create a rectangle.
-   */
-  Rectangle (double _xMin, double _xMax,
-             double _yMin, double _yMax);
-  /**
-   * Create a zero-sized rectangle located at coordinates (0.0,0.0)
-   */
-  Rectangle ();
-  /**
-   * \param position the position to test.
-   * \return true if the input position is located within the rectangle, false otherwise.
-   *
-   * This method compares only the x and y coordinates of the input position.
-   * It ignores the z coordinate.
-   */
-  bool IsInside (const Vector &position) const;
-  /**
-   * \param position the position to test.
-   * \return the side of the rectangle the input position is closest to.
-   *
-   * This method compares only the x and y coordinates of the input position.
-   * It ignores the z coordinate.
-   */
-  Side GetClosestSide (const Vector &position) const;
-  /**
-   * \param current the current position
-   * \param speed the current speed
-   * \return the intersection point between the rectangle and the current+speed vector.
-   *
-   * This method assumes that the current position is located _inside_
-   * the rectangle and checks for this with an assert.
-   * This method compares only the x and y coordinates of the input position
-   * and speed. It ignores the z coordinate.
-   */
-  Vector CalculateIntersection (const Vector &current, const Vector &speed) const;
-
-  /* The x coordinate of the left bound of the rectangle */
-  double xMin;
-  /* The x coordinate of the right bound of the rectangle */
-  double xMax;
-  /* The y coordinate of the bottom bound of the rectangle */
-  double yMin;
-  /* The y coordinate of the top bound of the rectangle */
-  double yMax;
-};
-
-std::ostream &operator << (std::ostream &os, const Rectangle &rectangle);
-std::istream &operator >> (std::istream &is, Rectangle &rectangle);
-
-/**
- * \ingroup mobility
- * \class ns3::RectangleValue
- * \brief hold objects of type ns3::Rectangle
- */
-
-ATTRIBUTE_HELPER_HEADER (Rectangle);
-
-} // namespace ns3
-
-#endif /* RECTANGLE_H */
--- a/src/mobility/steady-state-random-waypoint-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,375 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 IITP RAS
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Denis Fakhriev <fakhriev@iitp.ru>
- */
-#include <cmath>
-#include "ns3/simulator.h"
-#include "ns3/double.h"
-#include "steady-state-random-waypoint-mobility-model.h"
-#include "ns3/test.h"
-#include "ns3/simulator.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (SteadyStateRandomWaypointMobilityModel);
-
-TypeId
-SteadyStateRandomWaypointMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::SteadyStateRandomWaypointMobilityModel")
-    .SetParent<MobilityModel> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<SteadyStateRandomWaypointMobilityModel> ()
-    .AddAttribute ("MinSpeed",
-                   "Minimum speed value, [m/s]",
-                   DoubleValue (0.3),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minSpeed),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MaxSpeed",
-                   "Maximum speed value, [m/s]",
-                   DoubleValue (0.7),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxSpeed),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MinPause",
-                   "Minimum pause value, [s]",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minPause),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MaxPause",
-                   "Maximum pause value, [s]",
-                   DoubleValue (0.0),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxPause),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MinX",
-                   "Minimum X value of traveling region, [m]",
-                   DoubleValue (1),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minX),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MaxX",
-                   "Maximum X value of traveling region, [m]",
-                   DoubleValue (1),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxX),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MinY",
-                   "Minimum Y value of traveling region, [m]",
-                   DoubleValue (1),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_minY),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MaxY",
-                   "Maximum Y value of traveling region, [m]",
-                   DoubleValue (1),
-                   MakeDoubleAccessor (&SteadyStateRandomWaypointMobilityModel::m_maxY),
-                   MakeDoubleChecker<double> ());
-  
-  return tid;
-}
-
-SteadyStateRandomWaypointMobilityModel::SteadyStateRandomWaypointMobilityModel ():
-  alreadyStarted (false)
-{
-}
-
-void
-SteadyStateRandomWaypointMobilityModel::DoStart (void)
-{
-  SteadyStateStart ();
-  MobilityModel::DoStart ();
-}
-
-void
-SteadyStateRandomWaypointMobilityModel::SteadyStateStart (void)
-{
-  alreadyStarted = true;
-  NS_ASSERT (m_minSpeed >= 1e-6);
-  NS_ASSERT (m_minSpeed <= m_maxSpeed);
-  m_speed = UniformVariable (m_minSpeed, m_maxSpeed);
-  NS_ASSERT (m_minX < m_maxX);
-  NS_ASSERT (m_minY < m_maxY);
-  m_position = CreateObject<RandomRectanglePositionAllocator> ();
-  m_position->SetX (UniformVariable (m_minX, m_maxX));
-  m_position->SetY (UniformVariable (m_minY, m_maxY));
-  NS_ASSERT (m_minPause <= m_maxPause);
-  m_pause = UniformVariable (m_minPause, m_maxPause);
-  
-  m_helper.Update ();
-  m_helper.Pause ();
-  
-  // calculate the steady-state probability that a node is initially paused
-  double expectedPauseTime = (m_minPause + m_maxPause)/2;
-  double a = m_maxX - m_minX;
-  double b = m_maxY - m_minY;
-  double v0 = m_minSpeed;
-  double v1 = m_maxSpeed;
-  double log1 = b*b / a*std::log (std::sqrt ((a*a)/(b*b) + 1) + a/b);
-  double log2 = a*a / b*std::log (std::sqrt ((b*b)/(a*a) + 1) + b/a);
-  double expectedTravelTime = 1.0/6.0*(log1 + log2);
-  expectedTravelTime += 1.0/15.0*((a*a*a)/(b*b) + (b*b*b)/(a*a)) -
-                        1.0/15.0*std::sqrt(a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3);
-  if (v0 == v1)
-    {
-      expectedTravelTime /= v0;
-    }
-  else
-    {
-      expectedTravelTime *= std::log(v1/v0)/(v1 - v0);
-    }
-  double probabilityPaused = expectedPauseTime/(expectedPauseTime + expectedTravelTime);
-  NS_ASSERT (probabilityPaused >= 0 && probabilityPaused <= 1);
-  
-  UniformVariable u_r;
-  double u = u_r.GetValue(0, 1);
-  if (u < probabilityPaused) // node initially paused
-    {
-      m_helper.SetPosition (m_position->GetNext ());
-      u = u_r.GetValue(0, 1);
-      Time pause;      
-      if (m_minPause != m_maxPause)
-        {
-          if (u < (2*m_minPause/(m_minPause + m_maxPause)))
-            {
-              pause = Seconds (u*(m_minPause + m_maxPause)/2);
-            }
-          else
-            {
-              // there is an error in equation 20 in the Tech. Report MCS-03-04
-              // this error is corrected in the TMC 2004 paper and below
-              pause = Seconds (m_maxPause - sqrt ((1 - u)*(m_maxPause*m_maxPause - m_minPause*m_minPause)));
-            }
-        }
-      else // if pause is constant
-        {
-          pause = Seconds (u*expectedPauseTime);
-        }
-      NS_ASSERT (!m_event.IsRunning());
-      m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this);
-    }
-  else // node initially moving
-    {
-      UniformVariable x1_r, y1_r, x2_r, y2_r;
-      double x1, x2, y1, y2;
-      double r = 0;
-      double u1 = 1;
-      while (u1 >= r)
-        {
-          x1 = x1_r.GetValue (0, a);
-          y1 = y1_r.GetValue (0, b);
-          x2 = x2_r.GetValue (0, a);
-          y2 = y2_r.GetValue (0, b);
-          u1 = u_r.GetValue (0, 1);
-          r = std::sqrt (((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))/(a*a + b*b));
-          NS_ASSERT (r <= 1);
-        }
-      double u2 = u_r.GetValue (0, 1);
-      m_helper.SetPosition (Vector (m_minX + u2*x1 + (1 - u2)*x2, m_minY + u2*y1 + (1 - u2)*y2, 0));
-      NS_ASSERT (!m_event.IsRunning());
-      m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk, this, 
-                Vector (m_minX + x2, m_minY + y2, 0));
-    }
-  NotifyCourseChange ();
-}
-
-void
-SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk (const Vector &destination)
-{
-  m_helper.Update ();
-  Vector m_current = m_helper.GetCurrentPosition ();
-  NS_ASSERT (m_minX <= m_current.x && m_current.x <= m_maxX);
-  NS_ASSERT (m_minY <= m_current.y && m_current.y <= m_maxY);
-  NS_ASSERT (m_minX <= destination.x && destination.x <= m_maxX);
-  NS_ASSERT (m_minY <= destination.y && destination.y <= m_maxY);
-  UniformVariable u_r;
-  double u = u_r.GetValue (0, 1);
-  double speed = std::pow (m_maxSpeed, u)/std::pow (m_minSpeed, u - 1);
-  double dx = (destination.x - m_current.x);
-  double dy = (destination.y - m_current.y);
-  double dz = (destination.z - m_current.z);
-  double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
-
-  m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
-  m_helper.Unpause ();
-  Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
-  m_event = Simulator::Schedule (travelDelay, 
-                                 &SteadyStateRandomWaypointMobilityModel::Start, this);
-  NotifyCourseChange ();
-}
-
-void
-SteadyStateRandomWaypointMobilityModel::BeginWalk (void)
-{
-  m_helper.Update ();
-  Vector m_current = m_helper.GetCurrentPosition ();
-  NS_ASSERT (m_minX <= m_current.x && m_current.x <= m_maxX);
-  NS_ASSERT (m_minY <= m_current.y && m_current.y <= m_maxY);
-  Vector destination = m_position->GetNext ();
-  double speed = m_speed.GetValue ();
-  double dx = (destination.x - m_current.x);
-  double dy = (destination.y - m_current.y);
-  double dz = (destination.z - m_current.z);
-  double k = speed / std::sqrt (dx*dx + dy*dy + dz*dz);
-
-  m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
-  m_helper.Unpause ();
-  Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
-  m_event = Simulator::Schedule (travelDelay,
-				 &SteadyStateRandomWaypointMobilityModel::Start, this);
-  NotifyCourseChange ();
-}
-
-void
-SteadyStateRandomWaypointMobilityModel::Start (void)
-{
-  m_helper.Update ();
-  m_helper.Pause ();
-  Time pause = Seconds (m_pause.GetValue ());
-  m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this);
-  NotifyCourseChange ();
-}
-
-Vector
-SteadyStateRandomWaypointMobilityModel::DoGetPosition (void) const
-{
-  m_helper.Update ();
-  return m_helper.GetCurrentPosition ();
-}
-void 
-SteadyStateRandomWaypointMobilityModel::DoSetPosition (const Vector &position)
-{
-  if (alreadyStarted)
-    {
-      m_helper.SetPosition (position);
-      Simulator::Remove (m_event);
-      m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::Start, this);
-    }
-}
-Vector
-SteadyStateRandomWaypointMobilityModel::DoGetVelocity (void) const
-{
-  return m_helper.GetVelocity ();
-}
-
-class SteadyStateRandomWaypointTest : public TestCase
-{
-public:
-  SteadyStateRandomWaypointTest ()
-    : TestCase ("Check steady-state rwp mobility model velocity and position distributions") {}
-  virtual ~SteadyStateRandomWaypointTest () {}
-
-private:
-  std::vector<Ptr<MobilityModel> > mobilityStack;
-  double count;
-private:
-  virtual void DoRun (void);
-  void DistribCompare ();
-};
-
-void
-SteadyStateRandomWaypointTest::DoRun (void)
-{
-  SeedManager::SetSeed(123);
-
-  // Total simulation time, seconds
-  double totalTime = 1000;
-
-  ObjectFactory mobilityFactory;
-  mobilityFactory.SetTypeId ("ns3::SteadyStateRandomWaypointMobilityModel");
-  mobilityFactory.Set ("MinSpeed", DoubleValue (0.01));
-  mobilityFactory.Set ("MaxSpeed", DoubleValue (20.0));
-  mobilityFactory.Set ("MinPause", DoubleValue (0.0));
-  mobilityFactory.Set ("MaxPause", DoubleValue (0.0));
-  mobilityFactory.Set ("MinX", DoubleValue (0));
-  mobilityFactory.Set ("MaxX", DoubleValue (1000));
-  mobilityFactory.Set ("MinY", DoubleValue (0));
-  mobilityFactory.Set ("MaxY", DoubleValue (600));
-
-  // Populate the vector of mobility models.
-  count = 10000;
-  for (uint32_t i = 0; i < count; i++)
-    {
-      // Create a new mobility model.
-      Ptr<MobilityModel> model = mobilityFactory.Create ()->GetObject<MobilityModel> ();
-
-      // Add this mobility model to the stack.
-      mobilityStack.push_back (model);
-      Simulator::Schedule (Seconds (0.0), &Object::Start, model);
-    } 
-
-  Simulator::Schedule (Seconds (0.001), & SteadyStateRandomWaypointTest::DistribCompare, this);
-  Simulator::Schedule (Seconds (totalTime), & SteadyStateRandomWaypointTest::DistribCompare, this);
-  Simulator::Stop (Seconds (totalTime));
-  Simulator::Run ();
-  Simulator::Destroy ();
-}
-
-void
-SteadyStateRandomWaypointTest::DistribCompare ()
-{
-  double velocity;
-  double sum_x = 0;
-  double sum_y = 0;
-  double sum_v = 0;
-  std::vector<Ptr<MobilityModel> >::iterator i;
-  Ptr<MobilityModel> model;
-  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
-    {
-      model = (*i);
-      velocity = sqrt (pow (model->GetVelocity().x, 2) + pow (model->GetVelocity().y, 2));
-      sum_x += model->GetPosition().x;
-      sum_y += model->GetPosition().y;
-      sum_v += velocity;
-    }
-  double mean_x = sum_x / count;
-  double mean_y = sum_y / count;
-  double mean_v = sum_v / count;
-
-  NS_TEST_EXPECT_MSG_EQ_TOL (mean_x, 500, 25.0, "Got unexpected x-position mean value");
-  NS_TEST_EXPECT_MSG_EQ_TOL (mean_y, 300, 15.0, "Got unexpected y-position mean value");
-  NS_TEST_EXPECT_MSG_EQ_TOL (mean_v, 2.6, 0.13, "Got unexpected velocity mean value");
-
-  sum_x = 0;
-  sum_y = 0;
-  sum_v = 0;
-  double tmp;
-  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
-    {
-      model = (*i);
-      velocity = sqrt (pow (model->GetVelocity().x, 2) + pow (model->GetVelocity().y, 2));
-      tmp = model->GetPosition().x - mean_x;
-      sum_x += tmp * tmp;
-      tmp = model->GetPosition().y - mean_y;
-      sum_y += tmp * tmp;
-      tmp = velocity - mean_v;
-      sum_v += tmp * tmp;
-    }
-  double dev_x = std::sqrt (sum_x / (count - 1));
-  double dev_y = std::sqrt (sum_y / (count - 1));
-  double dev_v = std::sqrt (sum_v / (count - 1));
-
-  NS_TEST_EXPECT_MSG_EQ_TOL (dev_x, 230, 10.0, "Got unexpected x-position standard deviation");
-  NS_TEST_EXPECT_MSG_EQ_TOL (dev_y, 140, 7.0, "Got unexpected y-position standard deviation");
-  NS_TEST_EXPECT_MSG_EQ_TOL (dev_v, 4.4, 0.22, "Got unexpected velocity standard deviation");
-}
-
-struct SteadyStateRandomWaypointTestSuite : public TestSuite
-{
-  SteadyStateRandomWaypointTestSuite () : TestSuite ("steady-state-rwp-mobility-model", UNIT)
-  {
-    AddTestCase (new SteadyStateRandomWaypointTest);
-  }
-} g_steadyStateRandomWaypointTestSuite;
-
-} // namespace ns3
--- a/src/mobility/steady-state-random-waypoint-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 IITP RAS
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- * 
- * Author: Denis Fakhriev <fakhriev@iitp.ru>
- */
-#ifndef STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H
-#define STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H
-
-#include "constant-velocity-helper.h"
-#include "mobility-model.h"
-#include "position-allocator.h"
-#include "ns3/ptr.h"
-#include "ns3/random-variable.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Steady-state random waypoint mobility model.
- *
- * This model based on random waypoint mobility (RWM) model for case when 
- * speed, pause and position are uniformly distributed random variables. 
- * The difference is that the initial values of this parameters are not 
- * from uniform distribution but from stationary distribution of RWM model.
- * The implementation of this model is 2d-specific and with nonzero nodes speeds.
- *
- * Based on NS-2 implementation by Toilers Research Group -- Colorado
- *      School of Mines (http://toilers.mines.edu). 
- * The papers related to this code are:
- *      W. Navidi and T. Camp, Stationary Distributions for the Random
- *      Waypoint Mobility Model, IEEE Transactions on Mobile Computing,
- *      vol. 3, no. 1, pp. 99-108, January-March 2004.
- *      W. Navidi, T. Camp, and N. Bauer, Improving the Accuracy of
- *      Random Waypoint Simulations Through Steady-State Initialization,
- *      Proceedings of the 15th International Conference on Modeling and
- *      Simulation (MS '04), pp. 319-326, March 2004.
- */
-class SteadyStateRandomWaypointMobilityModel : public MobilityModel
-{
-public:
-  static TypeId GetTypeId (void);
-  SteadyStateRandomWaypointMobilityModel ();
-protected:
-  virtual void DoStart (void);
-private:
-  void SteadyStateStart (void);
-  void SteadyStateBeginWalk (const Vector &destination);
-  void Start (void);
-  void BeginWalk (void);
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  ConstantVelocityHelper m_helper;
-  double m_maxSpeed;
-  double m_minSpeed;
-  UniformVariable m_speed;
-  double m_minX;
-  double m_maxX;
-  double m_minY;
-  double m_maxY;
-  Ptr<RandomRectanglePositionAllocator> m_position;
-  double m_minPause;
-  double m_maxPause;
-  UniformVariable m_pause;
-  EventId m_event;
-  bool alreadyStarted;
-};
-
-} // namespace ns3
-
-#endif /* STEADY_STATE_RANDOM_WAYPOINT_MOBILITY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,140 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 IITP RAS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Denis Fakhriev <fakhriev@iitp.ru>
+ */
+#include <cmath>
+#include "ns3/simulator.h"
+#include "ns3/boolean.h"
+#include "ns3/double.h"
+#include "ns3/test.h"
+#include "ns3/config.h"
+#include "ns3/steady-state-random-waypoint-mobility-model.h"
+
+namespace ns3 {
+
+class SteadyStateRandomWaypointTest : public TestCase
+{
+public:
+  SteadyStateRandomWaypointTest ()
+    : TestCase ("Check steady-state rwp mobility model velocity and position distributions") {}
+  virtual ~SteadyStateRandomWaypointTest () {}
+
+private:
+  std::vector<Ptr<MobilityModel> > mobilityStack;
+  double count;
+private:
+  virtual void DoRun (void);
+  void DistribCompare ();
+};
+
+void
+SteadyStateRandomWaypointTest::DoRun (void)
+{
+  SeedManager::SetSeed(123);
+
+  // Total simulation time, seconds
+  double totalTime = 1000;
+
+  ObjectFactory mobilityFactory;
+  mobilityFactory.SetTypeId ("ns3::SteadyStateRandomWaypointMobilityModel");
+  mobilityFactory.Set ("MinSpeed", DoubleValue (0.01));
+  mobilityFactory.Set ("MaxSpeed", DoubleValue (20.0));
+  mobilityFactory.Set ("MinPause", DoubleValue (0.0));
+  mobilityFactory.Set ("MaxPause", DoubleValue (0.0));
+  mobilityFactory.Set ("MinX", DoubleValue (0));
+  mobilityFactory.Set ("MaxX", DoubleValue (1000));
+  mobilityFactory.Set ("MinY", DoubleValue (0));
+  mobilityFactory.Set ("MaxY", DoubleValue (600));
+
+  // Populate the vector of mobility models.
+  count = 10000;
+  for (uint32_t i = 0; i < count; i++)
+    {
+      // Create a new mobility model.
+      Ptr<MobilityModel> model = mobilityFactory.Create ()->GetObject<MobilityModel> ();
+
+      // Add this mobility model to the stack.
+      mobilityStack.push_back (model);
+      Simulator::Schedule (Seconds (0.0), &Object::Start, model);
+    } 
+
+  Simulator::Schedule (Seconds (0.001), & SteadyStateRandomWaypointTest::DistribCompare, this);
+  Simulator::Schedule (Seconds (totalTime), & SteadyStateRandomWaypointTest::DistribCompare, this);
+  Simulator::Stop (Seconds (totalTime));
+  Simulator::Run ();
+  Simulator::Destroy ();
+}
+
+void
+SteadyStateRandomWaypointTest::DistribCompare ()
+{
+  double velocity;
+  double sum_x = 0;
+  double sum_y = 0;
+  double sum_v = 0;
+  std::vector<Ptr<MobilityModel> >::iterator i;
+  Ptr<MobilityModel> model;
+  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
+    {
+      model = (*i);
+      velocity = sqrt (pow (model->GetVelocity().x, 2) + pow (model->GetVelocity().y, 2));
+      sum_x += model->GetPosition().x;
+      sum_y += model->GetPosition().y;
+      sum_v += velocity;
+    }
+  double mean_x = sum_x / count;
+  double mean_y = sum_y / count;
+  double mean_v = sum_v / count;
+
+  NS_TEST_EXPECT_MSG_EQ_TOL (mean_x, 500, 25.0, "Got unexpected x-position mean value");
+  NS_TEST_EXPECT_MSG_EQ_TOL (mean_y, 300, 15.0, "Got unexpected y-position mean value");
+  NS_TEST_EXPECT_MSG_EQ_TOL (mean_v, 2.6, 0.13, "Got unexpected velocity mean value");
+
+  sum_x = 0;
+  sum_y = 0;
+  sum_v = 0;
+  double tmp;
+  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
+    {
+      model = (*i);
+      velocity = sqrt (pow (model->GetVelocity().x, 2) + pow (model->GetVelocity().y, 2));
+      tmp = model->GetPosition().x - mean_x;
+      sum_x += tmp * tmp;
+      tmp = model->GetPosition().y - mean_y;
+      sum_y += tmp * tmp;
+      tmp = velocity - mean_v;
+      sum_v += tmp * tmp;
+    }
+  double dev_x = std::sqrt (sum_x / (count - 1));
+  double dev_y = std::sqrt (sum_y / (count - 1));
+  double dev_v = std::sqrt (sum_v / (count - 1));
+
+  NS_TEST_EXPECT_MSG_EQ_TOL (dev_x, 230, 10.0, "Got unexpected x-position standard deviation");
+  NS_TEST_EXPECT_MSG_EQ_TOL (dev_y, 140, 7.0, "Got unexpected y-position standard deviation");
+  NS_TEST_EXPECT_MSG_EQ_TOL (dev_v, 4.4, 0.22, "Got unexpected velocity standard deviation");
+}
+
+struct SteadyStateRandomWaypointTestSuite : public TestSuite
+{
+  SteadyStateRandomWaypointTestSuite () : TestSuite ("steady-state-rwp-mobility-model", UNIT)
+  {
+    AddTestCase (new SteadyStateRandomWaypointTest);
+  }
+} g_steadyStateRandomWaypointTestSuite;
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mobility/test/waypoint-mobility-model-test.cc	Fri Feb 25 16:06:17 2011 -0800
@@ -0,0 +1,151 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 Phillip Sitbon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Phillip Sitbon <phillip@sitbon.net>
+ */
+
+#include "ns3/simulator.h"
+#include "ns3/boolean.h"
+#include "ns3/config.h"
+#include "ns3/waypoint-mobility-model.h"
+#include "ns3/test.h"
+
+namespace ns3 {
+
+class WaypointMobilityModelNotifyTest : public TestCase
+{
+public:
+  WaypointMobilityModelNotifyTest (bool lazy)
+    : TestCase (lazy ? "Check Waypoint Mobility Model LAZY notification accuracy"
+                  : "Check Waypoint Mobility Model NON-LAZY notification accuracy"),
+      lazyNotify (lazy)
+  {
+  }
+  virtual ~WaypointMobilityModelNotifyTest ()
+  {
+  }
+
+private:
+  std::vector<Ptr<MobilityModel> > mobilityStack;
+  uint32_t mobilityCount;
+  uint32_t waypointCount;
+  std::deque<Waypoint> waypoints;
+  bool lazyNotify;
+private:
+  virtual void DoRun (void);
+  void ForceUpdates (void);
+  void CourseChangeCallback (std::string path, Ptr<const MobilityModel> model);
+};
+void
+WaypointMobilityModelNotifyTest::DoRun (void)
+{
+  mobilityCount = 1;
+  waypointCount = 100;
+
+  ObjectFactory mobilityFactory;
+  mobilityFactory.SetTypeId ("ns3::WaypointMobilityModel");
+  mobilityFactory.Set ("LazyNotify", BooleanValue (lazyNotify));
+
+  // Populate the vector of mobility models.
+  for (uint32_t i = 0; i < mobilityCount; i++)
+    {
+      // Create a new mobility model.
+      Ptr<MobilityModel> model = mobilityFactory.Create ()->GetObject<MobilityModel> ();
+
+      // Add this mobility model to the stack.
+      mobilityStack.push_back (model);
+      Simulator::Schedule (Seconds (0.0), &Object::Start, model);
+    } 
+
+  Waypoint wpt (Seconds (0.0), Vector (0.0, 0.0, 0.0));
+
+  // Create waypoints
+  for ( uint32_t iw = 0; iw < waypointCount; ++iw )
+    {
+      wpt.time += Seconds (1.0);
+      waypoints.push_back (wpt);
+    }
+
+  // Add the same waypoints to each node
+  std::vector<Ptr<MobilityModel> >::iterator i;
+  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
+    {
+      Ptr<WaypointMobilityModel> mob = (*i)->GetObject<WaypointMobilityModel> ();
+
+      for ( std::deque<Waypoint>::iterator w = waypoints.begin (); w != waypoints.end (); ++w )
+        {
+          mob->AddWaypoint (*w);
+        }
+    }
+
+  // Schedule updates at non-waypoint times to make sure lazy notifications don't happen
+  for ( double updateTime = 0.5; updateTime <= ((double)waypointCount + 1.5); updateTime += 1.0 )
+    {
+      Simulator::Schedule (Seconds (updateTime), &WaypointMobilityModelNotifyTest::ForceUpdates, this);
+    }
+
+  Config::Connect ("/NodeList/*/$ns3::WaypointMobilityModel/CourseChange",
+                   MakeCallback (&WaypointMobilityModelNotifyTest::CourseChangeCallback, this));
+
+  Simulator::Stop (Seconds ((double)waypointCount + 2.0));
+  Simulator::Run ();
+  Simulator::Destroy ();
+}
+void
+WaypointMobilityModelNotifyTest::ForceUpdates (void)
+{
+  std::vector<Ptr<MobilityModel> >::iterator i;
+  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
+    {
+      Ptr<WaypointMobilityModel> mob = (*i)->GetObject<WaypointMobilityModel> ();
+      mob->Update ();
+    }
+}
+void
+WaypointMobilityModelNotifyTest::CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
+{
+  const Time now = Simulator::Now ();
+  const double sec = now.GetSeconds ();
+  Ptr<const WaypointMobilityModel> mob = model->GetObject<WaypointMobilityModel> ();
+
+  NS_TEST_EXPECT_MSG_EQ (now, mob->m_current.time, "Waypoint time not properly updated");
+
+  if ( !lazyNotify )
+    {
+      // All waypoints are on second boundaries only
+      NS_TEST_EXPECT_MSG_EQ (sec - ((double)((int)sec)) + sec, sec,
+                             "Course didn't change on one second time boundary with NON-LAZY notifcations");
+    }
+  else
+    {
+      // Updates should happen at the times they are forced, in between waypoints.
+      NS_TEST_EXPECT_MSG_EQ (sec - ((double)((int)sec)), 0.5,
+                             "Course didn't change between waypoints with LAZY notifications");
+    }
+}
+
+static struct WaypointMobilityModelTestSuite : public TestSuite
+{
+  WaypointMobilityModelTestSuite () : TestSuite ("waypoint-mobility-model", UNIT)
+  {
+    AddTestCase (new WaypointMobilityModelNotifyTest (true));
+    AddTestCase (new WaypointMobilityModelNotifyTest (false));
+  }
+} g_waypointMobilityModelTestSuite;
+
+} // namespace ns3
+
--- a/src/mobility/waypoint-mobility-model.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,339 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Phillip Sitbon
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Phillip Sitbon <phillip@sitbon.net>
- */
-#include <limits>
-#include "ns3/abort.h"
-#include "ns3/simulator.h"
-#include "ns3/uinteger.h"
-#include "ns3/log.h"
-#include "ns3/boolean.h"
-#include "waypoint-mobility-model.h"
-#include "ns3/config.h"
-#include "ns3/test.h"
-
-NS_LOG_COMPONENT_DEFINE ("WaypointMobilityModel");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (WaypointMobilityModel);
-
-
-TypeId
-WaypointMobilityModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::WaypointMobilityModel")
-    .SetParent<MobilityModel> ()
-    .SetGroupName ("Mobility")
-    .AddConstructor<WaypointMobilityModel> ()
-    .AddAttribute ("NextWaypoint", "The next waypoint used to determine position.",
-                   TypeId::ATTR_GET,
-                   WaypointValue (),
-                   MakeWaypointAccessor (&WaypointMobilityModel::GetNextWaypoint),
-                   MakeWaypointChecker ())
-    .AddAttribute ("WaypointsLeft", "The number of waypoints remaining.",
-                   TypeId::ATTR_GET,
-                   UintegerValue (0),
-                   MakeUintegerAccessor (&WaypointMobilityModel::WaypointsLeft),
-                   MakeUintegerChecker<uint32_t> ())
-    .AddAttribute ("LazyNotify", "Only call NotifyCourseChange when position is calculated.",
-                   BooleanValue (false),
-                   MakeBooleanAccessor (&WaypointMobilityModel::m_lazyNotify),
-                   MakeBooleanChecker ())
-    .AddAttribute ("InitialPositionIsWaypoint", "Calling SetPosition with no waypoints creates a waypoint.",
-                   BooleanValue (false),
-                   MakeBooleanAccessor (&WaypointMobilityModel::m_initialPositionIsWaypoint),
-                   MakeBooleanChecker ())
-  ;
-  return tid;
-}
-
-
-WaypointMobilityModel::WaypointMobilityModel ()
-  : m_first (true),
-    m_lazyNotify (false),
-    m_initialPositionIsWaypoint (false)
-{
-}
-WaypointMobilityModel::~WaypointMobilityModel ()
-{
-}
-void
-WaypointMobilityModel::DoDispose (void)
-{
-  MobilityModel::DoDispose ();
-}
-void
-WaypointMobilityModel::AddWaypoint (const Waypoint &waypoint)
-{
-  if ( m_first )
-    {
-      m_first = false;
-      m_current = m_next = waypoint;
-    }
-  else
-    {
-      NS_ABORT_MSG_IF ( !m_waypoints.empty () && (m_waypoints.back ().time >= waypoint.time),
-                        "Waypoints must be added in ascending time order");
-      m_waypoints.push_back (waypoint);
-    }
-
-  if ( !m_lazyNotify )
-    {
-      Simulator::Schedule (waypoint.time, &WaypointMobilityModel::Update, this);
-    }
-}
-Waypoint
-WaypointMobilityModel::GetNextWaypoint (void) const
-{
-  Update ();
-  return m_next;
-}
-uint32_t
-WaypointMobilityModel::WaypointsLeft (void) const
-{
-  Update ();
-  return m_waypoints.size ();
-}
-void
-WaypointMobilityModel::Update (void) const
-{
-  const Time now = Simulator::Now ();
-  bool newWaypoint = false;
-
-  if ( now < m_current.time )
-    {
-      return;
-    }
-
-  while ( now >= m_next.time  )
-    {
-      if ( m_waypoints.empty () )
-        {
-          if ( m_current.time <= m_next.time )
-            {
-              /*
-                Set m_next.time = -1 to make sure this doesn't happen more than once.
-                The comparison here still needs to be '<=' in the case of mobility with one waypoint.
-              */
-              m_next.time = Seconds (-1.0);
-              m_current.position = m_next.position;
-              m_current.time = now;
-              m_velocity = Vector (0,0,0);
-              NotifyCourseChange ();
-            }
-          else
-            {
-              m_current.time = now;
-            }
-
-          return;
-        }
-
-      m_current = m_next;
-      m_next = m_waypoints.front ();
-      m_waypoints.pop_front ();
-      newWaypoint = true;
-
-      const double t_span = (m_next.time - m_current.time).GetSeconds ();
-      NS_ASSERT (t_span > 0);
-      m_velocity.x = (m_next.position.x - m_current.position.x) / t_span;
-      m_velocity.y = (m_next.position.y - m_current.position.y) / t_span;
-      m_velocity.z = (m_next.position.z - m_current.position.z) / t_span;
-    }
-
-  if ( now > m_current.time ) // Won't ever be less, but may be equal
-    {
-      const double t_diff = (now - m_current.time).GetSeconds ();
-      m_current.position.x += m_velocity.x * t_diff;
-      m_current.position.y += m_velocity.y * t_diff;
-      m_current.position.z += m_velocity.z * t_diff;
-      m_current.time = now;
-    }
-
-  if ( newWaypoint )
-    {
-      NotifyCourseChange ();
-    }
-}
-Vector
-WaypointMobilityModel::DoGetPosition (void) const
-{
-  Update ();
-  return m_current.position;
-}
-void
-WaypointMobilityModel::DoSetPosition (const Vector &position)
-{
-  const Time now = Simulator::Now ();
-
-  if ( m_first && m_initialPositionIsWaypoint )
-    {
-      AddWaypoint (Waypoint (now, position));
-      return;
-    }
-
-  Update ();
-  m_current.time = std::max (now, m_next.time);
-  m_current.position = position;
-  m_velocity = Vector (0,0,0);
-
-  if ( !m_first && (now >= m_current.time) )
-    {
-      // This is only a course change if the node is actually moving
-      NotifyCourseChange ();
-    }
-}
-void
-WaypointMobilityModel::EndMobility (void)
-{
-  m_waypoints.clear ();
-  m_current.time = Seconds (std::numeric_limits<double>::infinity ());
-  m_next.time = m_current.time;
-  m_first = true;
-}
-Vector
-WaypointMobilityModel::DoGetVelocity (void) const
-{
-  return m_velocity;
-}
-
-class WaypointMobilityModelNotifyTest : public TestCase
-{
-public:
-  WaypointMobilityModelNotifyTest (bool lazy)
-    : TestCase (lazy ? "Check Waypoint Mobility Model LAZY notification accuracy"
-                  : "Check Waypoint Mobility Model NON-LAZY notification accuracy"),
-      lazyNotify (lazy)
-  {
-  }
-  virtual ~WaypointMobilityModelNotifyTest ()
-  {
-  }
-
-private:
-  std::vector<Ptr<MobilityModel> > mobilityStack;
-  uint32_t mobilityCount;
-  uint32_t waypointCount;
-  std::deque<Waypoint> waypoints;
-  bool lazyNotify;
-private:
-  virtual void DoRun (void);
-  void ForceUpdates (void);
-  void CourseChangeCallback (std::string path, Ptr<const MobilityModel> model);
-};
-void
-WaypointMobilityModelNotifyTest::DoRun (void)
-{
-  mobilityCount = 1;
-  waypointCount = 100;
-
-  ObjectFactory mobilityFactory;
-  mobilityFactory.SetTypeId ("ns3::WaypointMobilityModel");
-  mobilityFactory.Set ("LazyNotify", BooleanValue (lazyNotify));
-
-  // Populate the vector of mobility models.
-  for (uint32_t i = 0; i < mobilityCount; i++)
-    {
-      // Create a new mobility model.
-      Ptr<MobilityModel> model = mobilityFactory.Create ()->GetObject<MobilityModel> ();
-
-      // Add this mobility model to the stack.
-      mobilityStack.push_back (model);
-      Simulator::Schedule (Seconds (0.0), &Object::Start, model);
-    } 
-
-  Waypoint wpt (Seconds (0.0), Vector (0.0, 0.0, 0.0));
-
-  // Create waypoints
-  for ( uint32_t iw = 0; iw < waypointCount; ++iw )
-    {
-      wpt.time += Seconds (1.0);
-      waypoints.push_back (wpt);
-    }
-
-  // Add the same waypoints to each node
-  std::vector<Ptr<MobilityModel> >::iterator i;
-  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
-    {
-      Ptr<WaypointMobilityModel> mob = (*i)->GetObject<WaypointMobilityModel> ();
-
-      for ( std::deque<Waypoint>::iterator w = waypoints.begin (); w != waypoints.end (); ++w )
-        {
-          mob->AddWaypoint (*w);
-        }
-    }
-
-  // Schedule updates at non-waypoint times to make sure lazy notifications don't happen
-  for ( double updateTime = 0.5; updateTime <= ((double)waypointCount + 1.5); updateTime += 1.0 )
-    {
-      Simulator::Schedule (Seconds (updateTime), &WaypointMobilityModelNotifyTest::ForceUpdates, this);
-    }
-
-  Config::Connect ("/NodeList/*/$ns3::WaypointMobilityModel/CourseChange",
-                   MakeCallback (&WaypointMobilityModelNotifyTest::CourseChangeCallback, this));
-
-  Simulator::Stop (Seconds ((double)waypointCount + 2.0));
-  Simulator::Run ();
-  Simulator::Destroy ();
-}
-void
-WaypointMobilityModelNotifyTest::ForceUpdates (void)
-{
-  std::vector<Ptr<MobilityModel> >::iterator i;
-  for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
-    {
-      Ptr<WaypointMobilityModel> mob = (*i)->GetObject<WaypointMobilityModel> ();
-      mob->Update ();
-    }
-}
-void
-WaypointMobilityModelNotifyTest::CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
-{
-  const Time now = Simulator::Now ();
-  const double sec = now.GetSeconds ();
-  Ptr<const WaypointMobilityModel> mob = model->GetObject<WaypointMobilityModel> ();
-
-  NS_TEST_EXPECT_MSG_EQ (now, mob->m_current.time, "Waypoint time not properly updated");
-
-  if ( !lazyNotify )
-    {
-      // All waypoints are on second boundaries only
-      NS_TEST_EXPECT_MSG_EQ (sec - ((double)((int)sec)) + sec, sec,
-                             "Course didn't change on one second time boundary with NON-LAZY notifcations");
-    }
-  else
-    {
-      // Updates should happen at the times they are forced, in between waypoints.
-      NS_TEST_EXPECT_MSG_EQ (sec - ((double)((int)sec)), 0.5,
-                             "Course didn't change between waypoints with LAZY notifications");
-    }
-}
-
-static struct WaypointMobilityModelTestSuite : public TestSuite
-{
-  WaypointMobilityModelTestSuite () : TestSuite ("waypoint-mobility-model", UNIT)
-  {
-    AddTestCase (new WaypointMobilityModelNotifyTest (true));
-    AddTestCase (new WaypointMobilityModelNotifyTest (false));
-  }
-} g_waypointMobilityModelTestSuite;
-
-
-} // namespace ns3
-
--- a/src/mobility/waypoint-mobility-model.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Phillip Sitbon
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Phillip Sitbon <phillip@sitbon.net>
- */
-#ifndef WAYPOINT_MOBILITY_MODEL_H
-#define WAYPOINT_MOBILITY_MODEL_H
-
-#include <stdint.h>
-#include <deque>
-#include "mobility-model.h"
-#include "ns3/vector.h"
-#include "waypoint.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief Waypoint-based mobility model.
- *
- * Each object determines its velocity and position at a given time
- * from a set of ns3::Waypoint objects.  Past waypoints are discarded
- * after the current simulation time greater than their time value.
- *
- * By default, the initial position of each object corresponds to the 
- * position of the first waypoint, and the initial velocity of each 
- * object is zero.  Upon reaching the last waypoint, object position 
- * becomes static and velocity is zero.
- *
- * When a node is in between waypoint times, it moves with a constant
- * velocity between the position at the previous waypoint and the position
- * at the current waypoint. To make a node hold a certain position for a
- * time interval, two waypoints with the same position (but different times)
- * should be inserted sequentially.
- *
- * Waypoints can be added at any time, and setting the current position
- * of an object will set its velocity to zero until the next waypoint time
- * (at which time the object jumps to the next waypoint), unless there are
- * no more waypoints in which case it will not change without user
- * intervention.
- *
- * The model has two attributes with methods that allow clients to get 
- * the next waypoint value (NextWaypoint) and the number of waypoints left 
- * (WaypointsLeft) beyond (but not including) the next waypoint.  
- *
- * In addition, there are two attributes that govern model behavior.  The
- * first, LazyNotify, governs how the model calls the CourseChange trace.
- * By default, LazyNotify is false, which means that each time that a
- * waypoint time is hit, an Update() is forced and the CourseChange 
- * callback will be called.  When LazyNotify is true, Update() is suppressed
- * at waypoint times, and CourseChange callbacks will only occur when
- * there later are actual calls to Update () (typically when calling
- * GetPosition ()).  This option may be enabled for execution run-time
- * performance improvements, but when enabled, users should note that
- * course change listeners will in general not be notified at waypoint
- * times but instead at the next Update() following a waypoint time,
- * and some waypoints may not be notified to course change listeners.
- *
- * The second, InitialPositionIsWaypoint, is false by default.  Recall
- * that the first waypoint will set the initial position and set velocity
- * equal to 0 until the first waypoint time.  In such a case, the
- * call to SetPosition(), such as from a PositionAllocator, will be
- * ignored.  However, if InitialPositionIsWaypoint is set to true
- * and SetPosition() is called before any waypoints have been added,
- * the SetPosition() call is treated as an initial waypoint at time zero.
- * In such a case, when SetPosition() is treated as an initial waypoint,
- * it should be noted that attempts to add a waypoint at the same time
- * will cause the program to fail.
- */
-class WaypointMobilityModel : public MobilityModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  /**
-   * Create a path with no waypoints at location (0,0,0).
-   */
-  WaypointMobilityModel ();
-  virtual ~WaypointMobilityModel ();
-
-  /**
-   * \param waypoint waypoint to append to the object path.
-   *
-   * Add a waypoint to the path of the object. The time must
-   * be greater than the previous waypoint added, otherwise
-   * a fatal error occurs. The first waypoint is set as the
-   * current position with a velocity of zero.
-   *
-   */
-  void AddWaypoint (const Waypoint &waypoint);
-
-  /**
-   * Get the waypoint that this object is traveling towards.
-   */
-  Waypoint GetNextWaypoint (void) const;
-
-  /**
-   * Get the number of waypoints left for this object, excluding
-   * the next one.
-   */
-  uint32_t WaypointsLeft (void) const;
-
-  /**
-   * Clear any existing waypoints and set the current waypoint
-   * time to infinity. Calling this is only an optimization and
-   * not required. After calling this function, adding waypoints
-   * behaves as it would for a new object.
-   */
-  void EndMobility (void);
-
-private:
-  friend class WaypointMobilityModelNotifyTest; // To allow Update() calls and access to m_current
-
-  void Update (void) const;
-  virtual void DoDispose (void);
-  virtual Vector DoGetPosition (void) const;
-  virtual void DoSetPosition (const Vector &position);
-  virtual Vector DoGetVelocity (void) const;
-
-  bool m_first;
-  bool m_lazyNotify;
-  bool m_initialPositionIsWaypoint;
-  mutable std::deque<Waypoint> m_waypoints;
-  mutable Waypoint m_current;
-  mutable Waypoint m_next;
-  mutable Vector m_velocity;
-};
-
-} // namespace ns3
-
-#endif /* WAYPOINT_MOBILITY_MODEL_H */
-
--- a/src/mobility/waypoint.cc	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Phillip Sitbon
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Phillip Sitbon <phillip@sitbon.net>
- */
-#include "waypoint.h"
-
-namespace ns3 {
-
-ATTRIBUTE_HELPER_CPP (Waypoint);
-
-Waypoint::Waypoint (const Time &waypointTime, const Vector &waypointPosition)
-  : time (waypointTime),
-  position (waypointPosition)
-{}
-Waypoint::Waypoint ()
-  : time (Seconds (0.0)),
-    position (0,0,0)
-{}
-
-std::ostream &operator << (std::ostream &os, const Waypoint &waypoint)
-{
-  os << waypoint.time.GetSeconds () << "$" << waypoint.position;
-  return os;
-}
-std::istream &operator >> (std::istream &is, Waypoint &waypoint)
-{
-  char separator;
-  is >> waypoint.time >> separator >> waypoint.position;
-  if (separator != '$')
-    {
-      is.setstate (std::ios_base::failbit);
-    }
-  return is;
-}
-
-} // namespace ns3
-
--- a/src/mobility/waypoint.h	Fri Feb 25 15:27:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 Phillip Sitbon
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Phillip Sitbon <phillip@sitbon.net>
- */
-#ifndef WAYPOINT_H
-#define WAYPOINT_H
-
-#include "ns3/attribute.h"
-#include "ns3/attribute-helper.h"
-#include "ns3/nstime.h"
-#include "ns3/vector.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- * \brief a (time, location) pair.
- */
-class Waypoint
-{
-public:
-  /**
-   * \param waypointTime time of waypoint.
-   * \param waypointPosition position of waypoint corresponding to the given time.
-   *
-   * Create a waypoint.
-   */
-  Waypoint (const Time &waypointTime, const Vector &waypointPosition);
-
-  /**
-   * Create a waypoint at time 0 and position (0,0,0).
-   */
-  Waypoint ();
-  /* The waypoint time */
-  Time time;
-  /* The position of the waypoint */
-  Vector position;
-};
-
-/**
- * \ingroup mobility
- * \class ns3::WaypointValue
- * \brief hold objects of type ns3::Waypoint
- */
-ATTRIBUTE_HELPER_HEADER ( Waypoint);
-
-std::ostream &
-operator << (std::ostream &os, const Waypoint &waypoint);
-std::istream &
-operator >> (std::istream &is, Waypoint &waypoint);
-
-} // namespace ns3
-
-#endif /* WAYPOINT_H */
-
--- a/src/mobility/wscript	Fri Feb 25 15:27:30 2011 -0800
+++ b/src/mobility/wscript	Fri Feb 25 16:06:17 2011 -0800
@@ -1,43 +1,49 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
 def build(bld):
-    mobility = bld.create_ns3_module('mobility', ['core'])
+    mobility = bld.create_ns3_module('mobility', ['network'])
     mobility.source = [
-        'hierarchical-mobility-model.cc',
-        'mobility-model.cc',
-        'position-allocator.cc',
-        'rectangle.cc',
-        'box.cc',
-        'constant-position-mobility-model.cc',
-        'constant-velocity-helper.cc',
-        'constant-velocity-mobility-model.cc',
-        'gauss-markov-mobility-model.cc',
-        'random-waypoint-mobility-model.cc',
-        'steady-state-random-waypoint-mobility-model.cc',
-        'random-walk-2d-mobility-model.cc',
-        'random-direction-2d-mobility-model.cc',
-        'constant-acceleration-mobility-model.cc',
-        'waypoint.cc',
-        'waypoint-mobility-model.cc',
+        'model/box.cc',
+        'model/constant-acceleration-mobility-model.cc',
+        'model/constant-position-mobility-model.cc',
+        'model/constant-velocity-helper.cc',
+        'model/constant-velocity-mobility-model.cc',
+        'model/gauss-markov-mobility-model.cc',
+        'model/hierarchical-mobility-model.cc',
+        'model/mobility-model.cc',
+        'model/position-allocator.cc',
+        'model/random-direction-2d-mobility-model.cc',
+        'model/random-walk-2d-mobility-model.cc',
+        'model/random-waypoint-mobility-model.cc',
+        'model/rectangle.cc',
+        'model/steady-state-random-waypoint-mobility-model.cc',
+        'model/waypoint.cc',
+        'model/waypoint-mobility-model.cc',
+        'helper/mobility-helper.cc',
+        'helper/ns2-mobility-helper.cc',
+        'test/steady-state-random-waypoint-mobility-model-test.cc',
+        'test/waypoint-mobility-model-test.cc',
         ]
 
     headers = bld.new_task_gen('ns3header')
     headers.module = 'mobility'
     headers.source = [
-        'hierarchical-mobility-model.h',
-        'mobility-model.h',
-        'position-allocator.h',
-        'rectangle.h',
-        'box.h',
-        'constant-position-mobility-model.h',
-        'constant-velocity-helper.h',
-        'constant-velocity-mobility-model.h',
-        'gauss-markov-mobility-model.h',
-        'random-waypoint-mobility-model.h',
-        'steady-state-random-waypoint-mobility-model.h',
-        'random-walk-2d-mobility-model.h',
-        'random-direction-2d-mobility-model.h',
-        'constant-acceleration-mobility-model.h',
-        'waypoint.h',
-        'waypoint-mobility-model.h',
+        'model/box.h',
+        'model/constant-acceleration-mobility-model.h',
+        'model/constant-position-mobility-model.h',
+        'model/constant-velocity-helper.h',
+        'model/constant-velocity-mobility-model.h',
+        'model/gauss-markov-mobility-model.h',
+        'model/hierarchical-mobility-model.h',
+        'model/mobility-model.h',
+        'model/position-allocator.h',
+        'model/rectangle.h',
+        'model/random-direction-2d-mobility-model.h',
+        'model/random-walk-2d-mobility-model.h',
+        'model/random-waypoint-mobility-model.h',
+        'model/steady-state-random-waypoint-mobility-model.h',
+        'model/waypoint.h',
+        'model/waypoint-mobility-model.h',
+        'helper/mobility-helper.h',
+        'helper/ns2-mobility-helper.h',
         ]