create propagation module; move files from common module
authorTom Henderson <tomh@tomh.org>
Fri, 28 Jan 2011 14:11:21 -0800
changeset 6794 5dce93cfc499
parent 6793 e7db41b6b9fb
child 6795 7dfe87d4b790
create propagation module; move files from common module
src/common/cost231-propagation-loss-model.cc
src/common/cost231-propagation-loss-model.h
src/common/jakes-propagation-loss-model.cc
src/common/jakes-propagation-loss-model.h
src/common/propagation-delay-model.cc
src/common/propagation-delay-model.h
src/common/propagation-loss-model-test-suite.cc
src/common/propagation-loss-model.cc
src/common/propagation-loss-model.h
src/common/wscript
src/propagation/model/cost231-propagation-loss-model.cc
src/propagation/model/cost231-propagation-loss-model.h
src/propagation/model/jakes-propagation-loss-model.cc
src/propagation/model/jakes-propagation-loss-model.h
src/propagation/model/propagation-delay-model.cc
src/propagation/model/propagation-delay-model.h
src/propagation/model/propagation-loss-model.cc
src/propagation/model/propagation-loss-model.h
src/propagation/test/propagation-loss-model-test-suite.cc
src/propagation/wscript
src/wscript
--- a/src/common/cost231-propagation-loss-model.cc	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007,2008, 2009 INRIA, UDcast
- *
- * 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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
- *                              <amine.ismail@udcast.com>
- */
-
-#include "ns3/propagation-loss-model.h"
-#include "ns3/log.h"
-#include "ns3/mobility-model.h"
-#include "ns3/double.h"
-#include "ns3/pointer.h"
-#include <math.h>
-#include "cost231-propagation-loss-model.h"
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("Cost231PropagationLossModel");
-NS_OBJECT_ENSURE_REGISTERED (Cost231PropagationLossModel);
-
-TypeId
-Cost231PropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::Cost231PropagationLossModel")
-
-    .SetParent<PropagationLossModel> ()
-
-    .AddConstructor<Cost231PropagationLossModel> ()
-
-    .AddAttribute ("Lambda",
-                   "The wavelength  (default is 2.3 GHz at 300 000 km/s).",
-                   DoubleValue (300000000.0 / 2.3e9),
-                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_lambda),
-                   MakeDoubleChecker<double> ())
-
-    .AddAttribute ("Frequency",
-                   "The Frequency  (default is 2.3 GHz).",
-                   DoubleValue (2.3e9),
-                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_frequency),
-                   MakeDoubleChecker<double> ())
-
-    .AddAttribute ("BSAntennaHeight",
-                   " BS Antenna Height (default is 50m).",
-                   DoubleValue (50.0),
-                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_BSAntennaHeight),
-                   MakeDoubleChecker<double> ())
-
-    .AddAttribute ("SSAntennaHeight",
-                   " SS Antenna Height (default is 3m).",
-                   DoubleValue (3),
-                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_SSAntennaHeight),
-                   MakeDoubleChecker<double> ())
-
-    .AddAttribute ("MinDistance",
-                   "The distance under which the propagation model refuses to give results (m) ",
-                   DoubleValue (0.5),
-                   MakeDoubleAccessor (&Cost231PropagationLossModel::SetMinDistance, &Cost231PropagationLossModel::GetMinDistance),
-                   MakeDoubleChecker<double> ());
-  return tid;
-}
-
-Cost231PropagationLossModel::Cost231PropagationLossModel ()
-{
-  C = 0;
-  m_shadowing = 10;
-}
-
-void
-Cost231PropagationLossModel::SetLambda (double frequency, double speed)
-{
-  m_lambda = speed / frequency;
-  m_frequency = frequency;
-}
-
-double
-Cost231PropagationLossModel::GetShadowing (void)
-{
-  return m_shadowing;
-}
-void
-Cost231PropagationLossModel::SetShadowing (double shadowing)
-{
-  m_shadowing = shadowing;
-}
-
-void
-Cost231PropagationLossModel::SetLambda (double lambda)
-{
-  m_lambda = lambda;
-  m_frequency = 300000000 / lambda;
-}
-
-double
-Cost231PropagationLossModel::GetLambda (void) const
-{
-  return m_lambda;
-}
-
-void
-Cost231PropagationLossModel::SetMinDistance (double minDistance)
-{
-  m_minDistance = minDistance;
-}
-double
-Cost231PropagationLossModel::GetMinDistance (void) const
-{
-  return m_minDistance;
-}
-
-void
-Cost231PropagationLossModel::SetBSAntennaHeight (double height)
-{
-  m_BSAntennaHeight = height;
-}
-
-double
-Cost231PropagationLossModel::GetBSAntennaHeight (void) const
-{
-  return m_BSAntennaHeight;
-}
-
-void
-Cost231PropagationLossModel::SetSSAntennaHeight (double height)
-{
-  m_SSAntennaHeight = height;
-}
-
-double
-Cost231PropagationLossModel::GetSSAntennaHeight (void) const
-{
-  return m_SSAntennaHeight;
-}
-
-void
-Cost231PropagationLossModel::SetEnvironment (Environment env)
-{
-  m_environment = env;
-}
-Cost231PropagationLossModel::Environment
-Cost231PropagationLossModel::GetEnvironment (void) const
-{
-  return m_environment;
-}
-
-double
-Cost231PropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
-{
-
-  double distance = a->GetDistanceFrom (b);
-  if (distance <= m_minDistance)
-    {
-      return 0.0;
-    }
-
-  double log_f = log (m_frequency / 1000000000) / 2.302;
-  double C_H = 0.8 + ((1.11 * log_f) - 0.7) * m_SSAntennaHeight - (1.56 * log_f);
-  double log_BSH = log (m_BSAntennaHeight) / 2.303;
-
-  // from the COST231 wiki entry
-  // 2.303 is for the logarithm base change
-
-  double loss_in_db = 46.3 + (33.9 * log_f) - (13.82 * log_BSH) - C_H + ((44.9 - 6.55 * log_BSH) * log (distance)
-                                                                         / 2.303) + C + m_shadowing;
-
-  NS_LOG_DEBUG ("dist =" << distance << ", Path Loss = " << loss_in_db);
-
-  return (0 - loss_in_db);
-
-}
-
-double
-Cost231PropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
-{
-  return txPowerDbm + GetLoss (a, b);
-}
-
-}
--- a/src/common/cost231-propagation-loss-model.h	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007,2008, 2009 INRIA, UDcast
- *
- * 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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
- *                              <amine.ismail@udcast.com>
- */
-
-#ifndef COST231_PROPAGATION_LOSS_MODEL_H_
-#define COST231_PROPAGATION_LOSS_MODEL_H_
-
-#include "ns3/nstime.h"
-#include "ns3/propagation-loss-model.h"
-
-namespace ns3 {
-
-/*
- *  \brief The COST-Hata-Model is the most often cited of the COST 231 models.
- *  Also called the Hata Model PCS Extension, it is a radio propagation model
- *  that extends the Hata Model (which in turn is based on the Okumura Model)
- *  to cover a more elaborated range of frequencies. COST (COperation
- *  europ�enne dans le domaine de la recherche Scientifique et Technique)
- *  is a European Union Forum for cooperative scientific research which has
- *  developed this model accordingly to various experiments and researches.
- *  This model is applicable to urban areas. To further evaluate Path Loss
- *  in Suburban or Rural Quasi-open/Open Areas.
- *  Frequency: 1500 MHz to 2000 MHz
- *  Mobile Station Antenna Height: 1 up to 10m
- *  Base station Antenna Height: 30m to 200m
- *  Link Distance:up to 20 km
- *
- */
-
-class Cost231PropagationLossModel : public PropagationLossModel
-{
-
-public:
-  static TypeId GetTypeId (void);
-  Cost231PropagationLossModel ();
-  enum Environment
-  {
-    SubUrban, MediumCity, Metropolitan
-  };
-
-  /**
-   * \param a the mobility model of the source
-   * \param b the mobility model of the destination
-   * \returns the propagation loss (in dBm)
-   */
-  double GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
-  void SetBSAntennaHeight (double height);
-  void SetSSAntennaHeight (double height);
-  void SetEnvironment (Environment env);
-  void SetLambda (double lambda);
-  void SetMinDistance (double minDistance);
-  double GetBSAntennaHeight (void) const;
-  double GetSSAntennaHeight (void) const;
-  Environment GetEnvironment (void) const;
-  double GetMinDistance (void) const;
-  double GetLambda (void) const;
-  void SetLambda (double frequency, double speed);
-  double GetShadowing (void);
-  void SetShadowing (double shadowing);
-private:
-  virtual double DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
-  double m_BSAntennaHeight; // in meter
-  double m_SSAntennaHeight; // in meter
-  double C;
-  double m_lambda;
-  Environment m_environment;
-  double m_minDistance; // in meter
-  double m_frequency; // frequency in MHz
-  double m_shadowing;
-
-};
-
-}
-
-#endif /* COST231PROPAGATIONMODEL_H_ */
--- a/src/common/jakes-propagation-loss-model.cc	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,259 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,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: Federico Maguolo <maguolof@dei.unipd.it>
- */
-
-#include "ns3/simulator.h"
-#include "ns3/uinteger.h"
-#include "ns3/double.h"
-#include "ns3/random-variable.h"
-#include "ns3/mobility-model.h"
-#include "ns3/log.h"
-#include "jakes-propagation-loss-model.h"
-#include <math.h>
-
-NS_LOG_COMPONENT_DEFINE ("Jakes");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (JakesPropagationLossModel);
-
-class JakesPropagationLossModel::PathCoefficients 
-{
-public:
-  PathCoefficients (Ptr<const JakesPropagationLossModel> jakes,
-                    Ptr<MobilityModel> receiver, 
-                    uint8_t nRays, 
-                    uint8_t nOscillators);
-  ~PathCoefficients ();
-  double GetLoss (void);
-  Ptr<MobilityModel> GetReceiver (void);
-private:
-  void DoConstruct (void);
-  Ptr<MobilityModel> m_receiver;
-  uint8_t m_nOscillators;
-  uint8_t m_nRays;
-  double **m_phases;
-  Time m_lastUpdate;
-  Ptr<const JakesPropagationLossModel> m_jakes;
-};
-
-
-JakesPropagationLossModel::PathCoefficients::PathCoefficients (Ptr<const JakesPropagationLossModel> jakes, 
-                                                           Ptr<MobilityModel> receiver, 
-                                                           uint8_t nRays, 
-							   uint8_t nOscillators)
-  : m_receiver (receiver),
-    m_nOscillators (nOscillators),
-    m_nRays (nRays),
-    m_jakes(jakes)
-{
-  DoConstruct ();
-}
-
-JakesPropagationLossModel::PathCoefficients::~PathCoefficients ()
-{
-  for (uint8_t i = 0; i < m_nRays; i++) 
-    {
-      delete [] m_phases[i];
-    }
-  delete [] m_phases;
-}
-
-void
-JakesPropagationLossModel::PathCoefficients::DoConstruct ()
-{
-  m_phases = new double*[m_nRays];
-  for (uint8_t i = 0; i < m_nRays; i++) 
-    {
-      m_phases[i] = new double[m_nOscillators + 1];
-      for (uint8_t j = 0; j <= m_nOscillators; j++) 
-        {
-          m_phases[i][j] = 2.0 * JakesPropagationLossModel::PI * m_jakes->m_variable.GetValue ();
-        }
-    }
-  m_lastUpdate = Simulator::Now ();
-}
-
-Ptr<MobilityModel>
-JakesPropagationLossModel::PathCoefficients::GetReceiver ()
-{
-  return m_receiver;
-}
-
-double
-JakesPropagationLossModel::PathCoefficients::GetLoss (void)
-{
-  uint16_t N = 4 * m_nOscillators + 2;
-  Time interval = Simulator::Now () - m_lastUpdate;
-  ComplexNumber coef= {0.0, 0.0};
-  ComplexNumber fading;
-  double norm = 0.0;
-  for (uint8_t i = 0; i < m_nRays; i++) 
-    {
-      fading.real = 0.0;
-      fading.imag = 0.0;
-      for (uint8_t j = 0; j <= m_nOscillators; j++) 
-        {
-          m_phases[i][j] += 2.0 * JakesPropagationLossModel::PI * 
-            cos (2.0 * JakesPropagationLossModel::PI * j / N) * m_jakes->m_fd * interval.GetSeconds ();
-          m_phases[i][j] -= 2.0 * JakesPropagationLossModel::PI * 
-            floor (m_phases[i][j] / 2.0 / JakesPropagationLossModel::PI);
-          fading.real += m_jakes->m_amp[j].real * cos (m_phases[i][j]);
-          fading.imag += m_jakes->m_amp[j].imag * cos (m_phases[i][j]);
-          norm += sqrt(pow (m_jakes->m_amp[j].real, 2) + pow(m_jakes->m_amp[j].imag, 2));
-        }
-    coef.real += fading.real;
-    coef.imag += fading.imag;
-    }
-  m_lastUpdate = Simulator::Now ();
-  double k = sqrt (pow (coef.real, 2) + pow (coef.imag, 2)) / norm;
-  NS_LOG_DEBUG ("Jakes coef "<< k << " (" << 10 * log10 (k) << "dB)");
-  return 10 * log10 (k);
-}
-
-const double JakesPropagationLossModel::PI = 3.14159265358979323846;
-
-TypeId
-JakesPropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::JakesPropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<JakesPropagationLossModel> ()
-    .AddAttribute ("NumberOfRaysPerPath",
-                   "The number of rays to use by default for compute the fading coeficent for a given path (default is 1)",
-                   UintegerValue (1),
-		   MakeUintegerAccessor (&JakesPropagationLossModel::SetNRays,
-                                         &JakesPropagationLossModel::GetNRays),
-		   MakeUintegerChecker<uint8_t> ())
-    .AddAttribute ("NumberOfOscillatorsPerRay",
-                   "The number of oscillators to use by default for compute the coeficent for a given ray of a given "
-                   "path (default is 4)",
-                   UintegerValue (4),
-		   MakeUintegerAccessor (&JakesPropagationLossModel::SetNOscillators,
-                                         &JakesPropagationLossModel::GetNOscillators),
-		   MakeUintegerChecker<uint8_t> ())
-    .AddAttribute ("DopplerFreq",
-                   "The doppler frequency in Hz (f_d = v / lambda = v * f / c), the default is 0)",
-                   DoubleValue (0.0),
-		   MakeDoubleAccessor (&JakesPropagationLossModel::m_fd),
-		   MakeDoubleChecker<double> ())
-    .AddAttribute ("Distribution",
-                   "The distribution to choose the initial phases.",
-                   RandomVariableValue (ConstantVariable (1.0)),
-                   MakeRandomVariableAccessor (&JakesPropagationLossModel::m_variable),
-                   MakeRandomVariableChecker ())
-    ;
-  return tid;
-}
-
-JakesPropagationLossModel::JakesPropagationLossModel ()
-  : m_amp (0),
-    m_nRays (0),
-    m_nOscillators (0)
-{}
-
-JakesPropagationLossModel::~JakesPropagationLossModel ()
-{
-  delete [] m_amp;
-  for (PathsList::iterator i = m_paths.end (); i != m_paths.begin (); i--) 
-    {
-      PathsSet *ps = *i;
-      for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) 
-        {
-          PathCoefficients *pc = *r;
-          delete pc;
-        }
-      delete ps;
-    }
-}
-
-void
-JakesPropagationLossModel::SetNRays (uint8_t nRays)
-{
-  m_nRays = nRays;
-}
-
-void
-JakesPropagationLossModel::SetNOscillators (uint8_t nOscillators)
-{
-  m_nOscillators = nOscillators;
-  delete [] m_amp;
-  uint16_t N = 4 * m_nOscillators + 2;
-  m_amp = new ComplexNumber[m_nOscillators + 1];
-  m_amp[0].real = 2.0 * sqrt(2.0 / N) * cos (PI / 4.0);
-  m_amp[0].imag = 2.0 * sqrt(2.0 / N) * sin (PI / 4.0);
-  for (uint8_t i = 1; i <= m_nOscillators; i++) 
-    {
-      double beta = PI * (double)i / m_nOscillators;
-      m_amp[i].real = 4.0 * cos (beta) / sqrt(N);
-      m_amp[i].imag = 4.0 * sin (beta) / sqrt(N);
-    }
-}
-
-uint8_t 
-JakesPropagationLossModel::GetNRays (void) const
-{
-  return m_nRays;
-}
-uint8_t 
-JakesPropagationLossModel::GetNOscillators (void) const
-{
-  return m_nOscillators;
-}
-
-
-double 
-JakesPropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                          Ptr<MobilityModel> a,
-                                          Ptr<MobilityModel> b) const
-{
-  PathsList::iterator i = m_paths.end ();
-  while (i != m_paths.begin ()) 
-    {
-      i--;
-      PathsSet *ps = *i;
-      if (ps->sender == a) 
-        {
-          m_paths.erase (i);
-          m_paths.push_back (ps);
-          for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) 
-            {
-              PathCoefficients *pc = *r;
-              if (pc->GetReceiver () == b) 
-                {
-                  ps->receivers.erase (r);
-                  ps->receivers.push_back (pc);
-                  return txPowerDbm + pc->GetLoss ();
-                }
-            }
-          PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators);
-          ps->receivers.push_back (pc);
-          return txPowerDbm + pc->GetLoss ();
-        }
-    }
-  PathsSet *ps = new PathsSet;
-  ps->sender = a;
-  PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators);
-  ps->receivers.push_back (pc);
-  m_paths.push_back (ps);
-  return txPowerDbm + pc->GetLoss ();
-}
-
-} // namespace ns3
-
--- a/src/common/jakes-propagation-loss-model.h	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,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: Federico Maguolo <maguolof@dei.unipd.it>
- */
-#ifndef PROPAGATION_JAKES_MODEL_H
-#define PROPAGATION_JAKES_MODEL_H
-
-#include "ns3/nstime.h"
-#include "propagation-loss-model.h"
-
-namespace ns3 {
-
-
-/**
- * \brief a Jakes propagation loss model
- *
- * The Jakes propagation loss model implemented here is 
- * described in [1].
- * 
- *
- * We call path the set of rays that depart from a given 
- * transmitter and arrive to a given receiver. For each ray
- * The complex coefficient is compute as follow:
- * \f[ u(t)=u_c(t) + j u_s(t)\f]
- * \f[ u_c(t) = \frac{2}{\sqrt{N}}\sum_{n=0}^{M}a_n\cos(\omega_n t+\phi_n)\f]
- * \f[ u_s(t) = \frac{2}{\sqrt{N}}\sum_{n=0}^{M}b_n\cos(\omega_n t+\phi_n)\f]
- * where
- * \f[ a_n=\left \{ \begin{array}{ll}
- * \sqrt{2}\cos\beta_0 & n=0 \\
- * 2\cos\beta_n & n=1,2,\ldots,M
- * \end{array}
- * \right .\f]
- * \f[ b_n=\left \{ \begin{array}{ll}
- * \sqrt{2}\sin\beta_0 & n=0 \\
- * 2\sin\beta_n & n=1,2,\ldots,M
- * \end{array}
- * \right .\f]
- * \f[ \beta_n=\left \{ \begin{array}{ll}
- * \frac{\pi}{4} & n=0 \\
- * \frac{\pi n}{M} & n=1,2,\ldots,M
- * \end{array}
- * \right .\f]
- * \f[ \omega_n=\left \{ \begin{array}{ll}
- * 2\pi f_d & n=0 \\
- * 2\pi f_d \cos\frac{2\pi n}{N} & n=1,2,\ldots,M
- * \end{array}
- * \right .\f]
- *
- * The parameter \f$f_d\f$ is the doppler frequency and \f$N=4M+2\f$ where
- * \f$M\f$ is the number of oscillators per ray.
- *
- * The attenuation coefficent of the path is the magnitude of the sum of 
- * all the ray coefficients. This attenuation coefficient could be greater than
- * \f$1\f$, hence it is divide by \f$ \frac{2N_r}{\sqrt{N}} \sum_{n+0}^{M}\sqrt{a_n^2 +b_n^2}\f$
- * where \f$N_r\f$ is the number of rays.
- *
- * The initail phases \f$\phi_i\f$ are random and they are choosen according 
- * to a given distribution.
- * 
- * [1] Y. R. Zheng and C. Xiao, "Simulation Models With Correct 
- * Statistical Properties for Rayleigh Fading Channel", IEEE
- * Trans. on Communications, Vol. 51, pp 920-928, June 2003
- */
-class JakesPropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  JakesPropagationLossModel ();
-  virtual ~JakesPropagationLossModel ();
-
-  /**
-   * \param nRays Number of rays per path
-   *
-   * Set the number of rays for each path
-   */
-  void SetNRays (uint8_t nRays);
-  /**
-   * \param nOscillators Number of oscillators
-   *
-   * Set the number of oscillators to use to compute the ray coefficient
-   */
-  void SetNOscillators (uint8_t nOscillators);
-
-  uint8_t GetNRays (void) const;
-  uint8_t GetNOscillators (void) const;
-
-private:
-  JakesPropagationLossModel (const JakesPropagationLossModel &o);
-  JakesPropagationLossModel & operator = (const JakesPropagationLossModel &o);
-  void DoConstruct (void);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-
-  class PathCoefficients;
-  struct ComplexNumber {
-    double real;
-    double imag;
-  };
-  friend class PathCoefficents;
-  typedef std::vector<PathCoefficients *> DestinationList;
-  struct PathsSet {
-    Ptr<MobilityModel> sender;
-    DestinationList receivers;
-  };
-  typedef std::vector<PathsSet *> PathsList;
-
-  
-  static const double PI;
-  ComplexNumber* m_amp;
-  RandomVariable m_variable;
-  double m_fd;  
-  mutable PathsList m_paths;
-  uint8_t m_nRays;
-  uint8_t m_nOscillators;
-};
-
-} // namespace ns3
-
-#endif /* PROPAGATION_JAKES_MODEL_H */
-
-
--- a/src/common/propagation-delay-model.cc	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,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 "propagation-delay-model.h"
-#include "ns3/random-variable.h"
-#include "ns3/mobility-model.h"
-#include "ns3/double.h"
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel);
-
-TypeId 
-PropagationDelayModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::PropagationDelayModel")
-    .SetParent<Object> ()
-    ;
-  return tid;
-}
-
-PropagationDelayModel::~PropagationDelayModel ()
-{}
-
-NS_OBJECT_ENSURE_REGISTERED (RandomPropagationDelayModel);
-
-TypeId 
-RandomPropagationDelayModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomPropagationDelayModel")
-    .SetParent<PropagationDelayModel> ()
-    .AddConstructor<RandomPropagationDelayModel> ()
-    .AddAttribute ("Variable",
-                   "The random variable which generates random delays (s).",
-                   RandomVariableValue (UniformVariable (0.0, 1.0)),
-                   MakeRandomVariableAccessor (&RandomPropagationDelayModel::m_variable),
-                   MakeRandomVariableChecker ())
-    ;
-  return tid;
-}
-
-RandomPropagationDelayModel::RandomPropagationDelayModel ()
-{}
-RandomPropagationDelayModel::~RandomPropagationDelayModel ()
-{}
-Time 
-RandomPropagationDelayModel::GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
-{
-  return Seconds (m_variable.GetValue ());
-}
-
-NS_OBJECT_ENSURE_REGISTERED (ConstantSpeedPropagationDelayModel);
-
-TypeId
-ConstantSpeedPropagationDelayModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ConstantSpeedPropagationDelayModel")
-    .SetParent<PropagationDelayModel> ()
-    .AddConstructor<ConstantSpeedPropagationDelayModel> ()
-    .AddAttribute ("Speed", "The speed (m/s)",
-                   DoubleValue (300000000.0),
-                   MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-}
-
-ConstantSpeedPropagationDelayModel::ConstantSpeedPropagationDelayModel ()
-{}
-Time 
-ConstantSpeedPropagationDelayModel::GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
-{
-  double distance = a->GetDistanceFrom (b);
-  double seconds = distance / m_speed;
-  return Seconds (seconds);
-}
-void 
-ConstantSpeedPropagationDelayModel::SetSpeed (double speed)
-{
-  m_speed = speed;
-}
-double 
-ConstantSpeedPropagationDelayModel::GetSpeed (void) const
-{
-  return m_speed;
-}
-
-} // namespace ns3
--- a/src/common/propagation-delay-model.h	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,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 PROPAGATION_DELAY_MODEL_H
-#define PROPAGATION_DELAY_MODEL_H
-
-#include "ns3/ptr.h"
-#include "ns3/object.h"
-#include "ns3/nstime.h"
-#include "ns3/random-variable.h"
-
-namespace ns3 {
-
-class MobilityModel;
-
-/**
- * \brief calculate a propagation delay.
- */
-class PropagationDelayModel : public Object
-{
-public:
-  static TypeId GetTypeId (void);
-  virtual ~PropagationDelayModel ();
-  /**
-   * \param a the source
-   * \param b the destination
-   * \returns the calculated propagation delay
-   *
-   * Calculate the propagation delay between the specified
-   * source and destination.
-   */
-  virtual Time GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const = 0;
-};
-
-/**
- * \brief the propagation delay is random
- */
-class RandomPropagationDelayModel : public PropagationDelayModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  /**
-   * Use the default parameters from PropagationDelayRandomDistribution.
-   */
-  RandomPropagationDelayModel ();
-  virtual ~RandomPropagationDelayModel ();
-  virtual Time GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
-private:
-  RandomVariable m_variable;
-};
-
-/**
- * \brief the propagation speed is constant
- */
-class ConstantSpeedPropagationDelayModel : public PropagationDelayModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  /**
-   * Use the default parameters from PropagationDelayConstantSpeed.
-   */
-  ConstantSpeedPropagationDelayModel ();
-  virtual Time GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
-  /**
-   * \param speed the new speed (m/s)
-   */
-  void SetSpeed (double speed);
-  /**
-   * \returns the current propagation speed (m/s).
-   */
-  double GetSpeed (void) const;
-private:
-  double m_speed;
-};
-
-} // namespace ns3
-
-#endif /* PROPAGATION_DELAY_MODEL_H */
--- a/src/common/propagation-loss-model-test-suite.cc	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,456 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 The Boeing Company
- *
- * 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
- */
-
-#include "ns3/log.h"
-#include "ns3/abort.h"
-#include "ns3/test.h"
-#include "ns3/config.h"
-#include "ns3/double.h"
-#include "ns3/propagation-loss-model.h"
-#include "ns3/constant-position-mobility-model.h"
-#include "ns3/simulator.h"
-
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("PropagationLossModelsTest");
-
-// ===========================================================================
-// This is a simple test to validate propagation loss models of ns-3 wifi.
-// See the chapter in the ns-3 testing and validation guide for more detail
-// ===========================================================================
-//
-class FriisPropagationLossModelTestCase : public TestCase
-{
-public:
-  FriisPropagationLossModelTestCase ();
-  virtual ~FriisPropagationLossModelTestCase ();
-
-private:
-  virtual void DoRun (void);
-
-  typedef struct {
-    Vector m_position;
-    double m_pt;  // dBm
-    double m_pr;  // W
-    double m_tolerance;
-  } TestVector;
-
-  TestVectors<TestVector> m_testVectors;
-};
-
-FriisPropagationLossModelTestCase::FriisPropagationLossModelTestCase ()
-  : TestCase ("Check to see that the ns-3 Friis propagation loss model provides correct received power"), m_testVectors ()
-{
-}
-
-FriisPropagationLossModelTestCase::~FriisPropagationLossModelTestCase ()
-{
-}
-
-void
-FriisPropagationLossModelTestCase::DoRun (void)
-{
-  // The ns-3 testing manual gives more background on the values selected
-  // for this test.  First, set a few defaults. 
-
-  // wavelength at 2.4 GHz is 0.125m
-  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
-  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
-
-  // Select a reference transmit power
-  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
-  double txPowerW = 0.05035702;
-  double txPowerdBm = 10 * log10 (txPowerW) + 30;
-
-  //
-  // We want to test the propagation loss model calculations at a few chosen 
-  // distances and compare the results to those we have manually calculated
-  // according to the model documentation.  The model reference specifies, 
-  // for instance, that the received power at 100m according to the provided
-  // input power will be 4.98265e-10 W.  Since this value specifies the power
-  // to 1e-15 significance, we test the ns-3 calculated value for agreement 
-  // within 5e-16.
-  //
-  TestVector testVector;
-
-  testVector.m_position = Vector (100, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 4.98265e-10;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-
-  testVector.m_position = Vector (500, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 1.99306e-11;
-  testVector.m_tolerance = 5e-17;
-  m_testVectors.Add (testVector);
-
-  testVector.m_position = Vector (1000, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 4.98265e-12;
-  testVector.m_tolerance = 5e-18;
-  m_testVectors.Add (testVector);
-
-  testVector.m_position = Vector (2000, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 1.24566e-12;
-  testVector.m_tolerance = 5e-18;
-  m_testVectors.Add (testVector);
-
-  // Now, check that the received power values are expected
-
-  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
-  a->SetPosition (Vector (0,0,0));
-  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
-
-  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> (); 
-  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
-    {
-      testVector = m_testVectors.Get (i);
-      b->SetPosition (testVector.m_position);
-      double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
-      double resultW =   pow (10.0, resultdBm/10.0)/1000;
-      NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
-    }
-}
-
-// Added for Two-Ray Ground Model - tomhewer@mac.com
-
-class TwoRayGroundPropagationLossModelTestCase : public TestCase
-{
-public:
-  TwoRayGroundPropagationLossModelTestCase ();
-  virtual ~TwoRayGroundPropagationLossModelTestCase ();
-  
-private:
-  virtual void DoRun (void);
-  
-  typedef struct
-  {
-    Vector m_position;
-    double m_pt;  // dBm
-    double m_pr;  // W
-    double m_tolerance;
-  } TestVector;
-  
-  TestVectors<TestVector> m_testVectors;
-};
-
-TwoRayGroundPropagationLossModelTestCase::TwoRayGroundPropagationLossModelTestCase ()
-: TestCase ("Check to see that the ns-3 TwoRayGround propagation loss model provides correct received power"),
-m_testVectors ()
-{
-}
-
-TwoRayGroundPropagationLossModelTestCase::~TwoRayGroundPropagationLossModelTestCase ()
-{
-}
-
-void
-TwoRayGroundPropagationLossModelTestCase::DoRun (void)
-{
-  // wavelength at 2.4 GHz is 0.125m
-  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
-  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
-  
-  // set antenna height to 1.5m above z coordinate
-  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
-  
-  // Select a reference transmit power of 17.0206 dBm
-  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
-  double txPowerW = 0.05035702;
-  double txPowerdBm = 10 * log10 (txPowerW) + 30;
-  
-  //
-  // As with the Friis tests above, we want to test the propagation loss 
-  // model calculations at a few chosen distances and compare the results 
-  // to those we can manually calculate. Let us test the ns-3 calculated 
-  // value for agreement to be within 5e-16, as above.
-  //
-  TestVector testVector;
-  
-  // Below the Crossover distance use Friis so this test should be the same as that above
-  // Crossover = (4 * PI * TxAntennaHeight * RxAntennaHeight) / Lamdba
-  // Crossover = (4 * PI * 1.5 * 1.5) / 0.125 = 226.1946m
-  
-  testVector.m_position = Vector (100, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 4.98265e-10;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  // These values are above the crossover distance and therefore use the Two Ray calculation
-  
-  testVector.m_position = Vector (500, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 4.07891862e-12;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  testVector.m_position = Vector (1000, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 2.5493241375e-13;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  testVector.m_position = Vector (2000, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 1.593327585938e-14;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  // Repeat the tests for non-zero z coordinates
-  
-  // Pr = (0.05035702 * (1.5*1.5) * (2.5*2.5)) / (500*500*500*500) = 1.13303295e-11
-  // dCross = (4 * pi * 1.5 * 2.5) / 0.125 = 376.99m
-  testVector.m_position = Vector (500, 0, 1);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 1.13303295e-11;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  // Pr = (0.05035702 * (1.5*1.5) * (5.5*5.5)) / (1000*1000*1000*1000) = 3.42742467375e-12
-  // dCross = (4 * pi * 1.5 * 5.5) / 0.125 = 829.38m
-  testVector.m_position = Vector (1000, 0, 4);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 3.42742467375e-12;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  // Pr = (0.05035702 * (1.5*1.5) * (11.5*11.5)) / (2000*2000*2000*2000) = 9.36522547734e-13
-  // dCross = (4 * pi * 1.5 * 11.5) / 0.125 = 1734.15m
-  testVector.m_position = Vector (2000, 0, 10);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 9.36522547734e-13;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-  
-  
-  // Now, check that the received power values are expected
-  
-  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
-  a->SetPosition (Vector (0,0,0));
-  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
-  
-  Ptr<TwoRayGroundPropagationLossModel> lossModel = CreateObject<TwoRayGroundPropagationLossModel> (); 
-  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
-  {
-    testVector = m_testVectors.Get (i);
-    b->SetPosition (testVector.m_position);
-    double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
-    double resultW =   pow (10.0, resultdBm / 10.0) / 1000;
-    NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
-  }
-}
-
-
-class LogDistancePropagationLossModelTestCase : public TestCase
-{
-public:
-  LogDistancePropagationLossModelTestCase ();
-  virtual ~LogDistancePropagationLossModelTestCase ();
-
-private:
-  virtual void DoRun (void);
-
-  typedef struct {
-    Vector m_position;
-    double m_pt;  // dBm
-    double m_pr;  // W
-    double m_tolerance;
-  } TestVector;
-
-  TestVectors<TestVector> m_testVectors;
-};
-
-LogDistancePropagationLossModelTestCase::LogDistancePropagationLossModelTestCase ()
-  : TestCase ("Check to see that the ns-3 Log Distance propagation loss model provides correct received power"), m_testVectors ()
-{
-}
-
-LogDistancePropagationLossModelTestCase::~LogDistancePropagationLossModelTestCase ()
-{
-}
-
-void
-LogDistancePropagationLossModelTestCase::DoRun (void)
-{
-  // reference loss at 2.4 GHz is 40.045997
-  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
-  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
-
-  // Select a reference transmit power
-  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
-  double txPowerW = 0.05035702;
-  double txPowerdBm = 10 * log10 (txPowerW) + 30;
-
-  //
-  // We want to test the propagation loss model calculations at a few chosen 
-  // distances and compare the results to those we have manually calculated
-  // according to the model documentation.  The following "TestVector" objects
-  // will drive the test.
-  //
-  TestVector testVector;
-
-  testVector.m_position = Vector (10, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 4.98265e-9;
-  testVector.m_tolerance = 5e-15; 
-  m_testVectors.Add (testVector);
-
-  testVector.m_position = Vector (20, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 6.22831e-10;
-  testVector.m_tolerance = 5e-16;
-  m_testVectors.Add (testVector);
-
-  testVector.m_position = Vector (40, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 7.78539e-11;
-  testVector.m_tolerance = 5e-17;
-  m_testVectors.Add (testVector);
-
-  testVector.m_position = Vector (80, 0, 0);
-  testVector.m_pt = txPowerdBm;
-  testVector.m_pr = 9.73173e-12;
-  testVector.m_tolerance = 5e-17;
-  m_testVectors.Add (testVector);
-
-  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
-  a->SetPosition (Vector (0,0,0));
-  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
-
-  Ptr<LogDistancePropagationLossModel> lossModel = CreateObject<LogDistancePropagationLossModel> (); 
-  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
-    {
-      testVector = m_testVectors.Get (i);
-      b->SetPosition (testVector.m_position);
-      double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
-      double resultW =   pow (10.0, resultdBm/10.0)/1000;
-      NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
-    }
-}
-
-class MatrixPropagationLossModelTestCase : public TestCase
-{
-public:
-  MatrixPropagationLossModelTestCase ();
-  virtual ~MatrixPropagationLossModelTestCase ();
-
-private:
-  virtual void DoRun (void);
-};
-
-MatrixPropagationLossModelTestCase::MatrixPropagationLossModelTestCase ()
-  : TestCase ("Test MatrixPropagationLossModel")
-{
-}
-
-MatrixPropagationLossModelTestCase::~MatrixPropagationLossModelTestCase ()
-{
-}
-
-void
-MatrixPropagationLossModelTestCase::DoRun (void)
-{
-  Ptr<Object> n[3];
-  Ptr<MobilityModel> m[3];
-  for (int i = 0; i < 3; ++i)
-    {
-      n[i] = CreateObject<Object> ();
-      m[i] = CreateObject<ConstantPositionMobilityModel> ();
-      n[i]->AggregateObject (m[i]);
-    }
-  
-  MatrixPropagationLossModel loss;
-  // no loss by default
-  loss.SetDefaultLoss (0);       
-  // -10 dB for 0 -> 1 and 1 -> 0
-  loss.SetLoss (n[0], n[1], 10); 
-  // -30 dB from 0 to 2 and -100 dB from 2 to 0
-  loss.SetLoss (n[0], n[2], 30, /*symmetric = */false); 
-  loss.SetLoss (n[2], n[0], 100, /*symmetric = */false); 
-  // default from 1 to 2
-  
-  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[1]), -10, "Loss 0 -> 1 incorrect");
-  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[0]), -10, "Loss 1 -> 0 incorrect");
-  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[2]), -30, "Loss 0 -> 2 incorrect");
-  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[0]), -100, "Loss 2 -> 0 incorrect");
-  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[2]), 0, "Loss 1 -> 2 incorrect");
-  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[1]), 0, "Loss 2 -> 1 incorrect");
-
-  Simulator::Destroy ();
-}
-
-class RangePropagationLossModelTestCase : public TestCase
-{
-public:
-  RangePropagationLossModelTestCase ();
-  virtual ~RangePropagationLossModelTestCase ();
-
-private:
-  virtual void DoRun (void);
-};
-
-RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
-  : TestCase ("Test RangePropagationLossModel")
-{
-}
-
-RangePropagationLossModelTestCase::~RangePropagationLossModelTestCase ()
-{
-}
-
-void
-RangePropagationLossModelTestCase::DoRun (void)
-{
-  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
-  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
-  a->SetPosition (Vector (0,0,0));
-  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
-  b->SetPosition (Vector (127.1,0,0));  // within range
-
-  Ptr<RangePropagationLossModel> lossModel = CreateObject<RangePropagationLossModel> (); 
-
-  double txPwrdBm = -80.0;
-  double tolerance = 1e-6;
-  double resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
-  NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, txPwrdBm, tolerance, "Got unexpected rcv power");
-  b->SetPosition (Vector (127.25,0,0));  // beyond range
-  resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
-  NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, -1000.0, tolerance, "Got unexpected rcv power");
-  Simulator::Destroy ();
-}
-
-class PropagationLossModelsTestSuite : public TestSuite
-{
-public:
-  PropagationLossModelsTestSuite ();
-};
-
-PropagationLossModelsTestSuite::PropagationLossModelsTestSuite ()
-  : TestSuite ("propagation-loss-model", UNIT)
-{
-  AddTestCase (new FriisPropagationLossModelTestCase);
-  AddTestCase (new TwoRayGroundPropagationLossModelTestCase);
-  AddTestCase (new LogDistancePropagationLossModelTestCase);
-  AddTestCase (new MatrixPropagationLossModelTestCase);
-  AddTestCase (new RangePropagationLossModelTestCase);
-}
-
-static PropagationLossModelsTestSuite propagationLossModelsTestSuite;
--- a/src/common/propagation-loss-model.cc	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,832 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,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>
- * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
- * Contributions: Tom Hewer <tomhewer@mac.com> for Two Ray Ground Model
- *                Pavel Boyko <boyko@iitp.ru> for matrix
- */
-
-#include "propagation-loss-model.h"
-#include "ns3/log.h"
-#include "ns3/mobility-model.h"
-#include "ns3/boolean.h"
-#include "ns3/double.h"
-#include <math.h>
-
-NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
-
-namespace ns3 {
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (PropagationLossModel);
-
-TypeId 
-PropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::PropagationLossModel")
-    .SetParent<Object> ()
-    ;
-  return tid;
-}
-
-PropagationLossModel::PropagationLossModel ()
-  : m_next (0)
-{}
-
-PropagationLossModel::~PropagationLossModel ()
-{}
-
-void 
-PropagationLossModel::SetNext (Ptr<PropagationLossModel> next)
-{
-  m_next = next;
-}
-
-double 
-PropagationLossModel::CalcRxPower (double txPowerDbm,
-                                   Ptr<MobilityModel> a,
-                                   Ptr<MobilityModel> b) const
-{
-  double self = DoCalcRxPower (txPowerDbm, a, b);
-  if (m_next != 0)
-    {
-      self = m_next->CalcRxPower (self, a, b);
-    }
-  return self;
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
-
-TypeId 
-RandomPropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RandomPropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<RandomPropagationLossModel> ()
-    .AddAttribute ("Variable", "The random variable used to pick a loss everytime CalcRxPower is invoked.",
-                   RandomVariableValue (ConstantVariable (1.0)),
-                   MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable),
-                   MakeRandomVariableChecker ())
-    ;
-  return tid;
-}
-RandomPropagationLossModel::RandomPropagationLossModel ()
-  : PropagationLossModel ()
-{}
-
-RandomPropagationLossModel::~RandomPropagationLossModel ()
-{}
-
-double 
-RandomPropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                           Ptr<MobilityModel> a,
-                                           Ptr<MobilityModel> b) const
-{
-  double rxc = -m_variable.GetValue ();
-  NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
-  return txPowerDbm + rxc;
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel);
-
-const double FriisPropagationLossModel::PI = 3.14159265358979323846;
-
-TypeId 
-FriisPropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::FriisPropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<FriisPropagationLossModel> ()
-    .AddAttribute ("Lambda", 
-                   "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
-                   DoubleValue (300000000.0 / 5.150e9),
-                   MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("SystemLoss", "The system loss",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MinDistance", 
-                   "The distance under which the propagation model refuses to give results (m)",
-                   DoubleValue (0.5),
-                   MakeDoubleAccessor (&FriisPropagationLossModel::SetMinDistance,
-                                       &FriisPropagationLossModel::GetMinDistance),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-}
-
-FriisPropagationLossModel::FriisPropagationLossModel ()
-{}
-void 
-FriisPropagationLossModel::SetSystemLoss (double systemLoss)
-{
-  m_systemLoss = systemLoss;
-}
-double 
-FriisPropagationLossModel::GetSystemLoss (void) const
-{
-  return m_systemLoss;
-}
-void 
-FriisPropagationLossModel::SetMinDistance (double minDistance)
-{
-  m_minDistance = minDistance;
-}
-double 
-FriisPropagationLossModel::GetMinDistance (void) const
-{
-  return m_minDistance;
-}
-void 
-FriisPropagationLossModel::SetLambda (double frequency, double speed)
-{
-  m_lambda = speed / frequency;
-}
-void 
-FriisPropagationLossModel::SetLambda (double lambda)
-{
-  m_lambda = lambda;
-}
-double 
-FriisPropagationLossModel::GetLambda (void) const
-{
-  return m_lambda;
-}
-
-double 
-FriisPropagationLossModel::DbmToW (double dbm) const
-{
-  double mw = pow(10.0,dbm/10.0);
-  return mw / 1000.0;
-}
-
-double
-FriisPropagationLossModel::DbmFromW (double w) const
-{
-  double dbm = log10 (w * 1000.0) * 10.0;
-  return dbm;
-}
-
-double 
-FriisPropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                          Ptr<MobilityModel> a,
-                                          Ptr<MobilityModel> b) const
-{
-  /*
-   * Friis free space equation:
-   * where Pt, Gr, Gr and P are in Watt units
-   * L is in meter units.
-   *
-   *    P     Gt * Gr * (lambda^2)
-   *   --- = ---------------------
-   *    Pt     (4 * pi * d)^2 * L
-   *
-   * Gt: tx gain (unit-less)
-   * Gr: rx gain (unit-less)
-   * Pt: tx power (W)
-   * d: distance (m)
-   * L: system loss
-   * lambda: wavelength (m)
-   *
-   * Here, we ignore tx and rx gain and the input and output values 
-   * are in dB or dBm:
-   *
-   *                           lambda^2
-   * rx = tx +  10 log10 (-------------------)
-   *                       (4 * pi * d)^2 * L
-   *
-   * rx: rx power (dB)
-   * tx: tx power (dB)
-   * d: distance (m)
-   * L: system loss (unit-less)
-   * lambda: wavelength (m)
-   */
-  double distance = a->GetDistanceFrom (b);
-  if (distance <= m_minDistance)
-    {
-      return txPowerDbm;
-    }
-  double numerator = m_lambda * m_lambda;
-  double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
-  double pr = 10 * log10 (numerator / denominator);
-  NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
-  return txPowerDbm + pr;
-}
-
-// ------------------------------------------------------------------------- //
-// -- Two-Ray Ground Model ported from NS-2 -- tomhewer@mac.com -- Nov09 //
-
-NS_OBJECT_ENSURE_REGISTERED (TwoRayGroundPropagationLossModel);
-
-const double TwoRayGroundPropagationLossModel::PI = 3.14159265358979323846;
-
-TypeId 
-TwoRayGroundPropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::TwoRayGroundPropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<TwoRayGroundPropagationLossModel> ()
-    .AddAttribute ("Lambda",
-                   "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
-                   DoubleValue (300000000.0 / 5.150e9),
-                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_lambda),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("SystemLoss", "The system loss",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_systemLoss),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("MinDistance",
-                   "The distance under which the propagation model refuses to give results (m)",
-                   DoubleValue (0.5),
-                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::SetMinDistance,
-                                       &TwoRayGroundPropagationLossModel::GetMinDistance),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("HeightAboveZ",
-                   "The height of the antenna (m) above the node's Z coordinate",
-                   DoubleValue (0),
-                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_heightAboveZ),
-                   MakeDoubleChecker<double> ())
-  ;
-  return tid;
-}
-
-TwoRayGroundPropagationLossModel::TwoRayGroundPropagationLossModel ()
-{
-}
-void
-TwoRayGroundPropagationLossModel::SetSystemLoss (double systemLoss)
-{
-  m_systemLoss = systemLoss;
-}
-double
-TwoRayGroundPropagationLossModel::GetSystemLoss (void) const
-{
-  return m_systemLoss;
-}
-void
-TwoRayGroundPropagationLossModel::SetMinDistance (double minDistance)
-{
-  m_minDistance = minDistance;
-}
-double
-TwoRayGroundPropagationLossModel::GetMinDistance (void) const
-{
-  return m_minDistance;
-}
-void
-TwoRayGroundPropagationLossModel::SetHeightAboveZ (double heightAboveZ)
-{
-  m_heightAboveZ = heightAboveZ;
-}
-void 
-TwoRayGroundPropagationLossModel::SetLambda (double frequency, double speed)
-{
-  m_lambda = speed / frequency;
-}
-void 
-TwoRayGroundPropagationLossModel::SetLambda (double lambda)
-{
-  m_lambda = lambda;
-}
-double 
-TwoRayGroundPropagationLossModel::GetLambda (void) const
-{
-  return m_lambda;
-}
-
-double 
-TwoRayGroundPropagationLossModel::DbmToW (double dbm) const
-{
-  double mw = pow (10.0,dbm / 10.0);
-  return mw / 1000.0;
-}
-
-double
-TwoRayGroundPropagationLossModel::DbmFromW (double w) const
-{
-  double dbm = log10 (w * 1000.0) * 10.0;
-  return dbm;
-}
-
-double 
-TwoRayGroundPropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                                 Ptr<MobilityModel> a,
-                                                 Ptr<MobilityModel> b) const
-{
-  /*
-   * Two-Ray Ground equation:
-   *
-   * where Pt, Gt and Gr are in dBm units
-   * L, Ht and Hr are in meter units.
-   *
-   *   Pr      Gt * Gr * (Ht^2 * Hr^2)
-   *   -- =  (-------------------------)
-   *   Pt            d^4 * L
-   *
-   * Gt: tx gain (unit-less)
-   * Gr: rx gain (unit-less)
-   * Pt: tx power (dBm)
-   * d: distance (m)
-   * L: system loss
-   * Ht: Tx antenna height (m)
-   * Hr: Rx antenna height (m)
-   * lambda: wavelength (m)
-   *
-   * As with the Friis model we ignore tx and rx gain and output values
-   * are in dB or dBm
-   *
-   *                      (Ht * Ht) * (Hr * Hr)
-   * rx = tx + 10 log10 (-----------------------)
-   *                      (d * d * d * d) * L
-   */
-  double distance = a->GetDistanceFrom (b);
-  if (distance <= m_minDistance)
-    {
-      return txPowerDbm;
-    }
-
-  // Set the height of the Tx and Rx antennae
-  double txAntHeight = a->GetPosition ().z + m_heightAboveZ;
-  double rxAntHeight = b->GetPosition ().z + m_heightAboveZ;
-
-  // Calculate a crossover distance, under which we use Friis
-  /*
-   * 
-   * dCross = (4 * pi * Ht * Hr) / lambda
-   *
-   */
-
-  double dCross = (4 * PI * txAntHeight * rxAntHeight) / GetLambda ();
-  double tmp = 0;
-  if (distance <= dCross)
-    {
-      // We use Friis
-      double numerator = m_lambda * m_lambda;
-      tmp = PI * distance;
-      double denominator = 16 * tmp * tmp * m_systemLoss;
-      double pr = 10 * log10 (numerator / denominator);
-      NS_LOG_DEBUG ("Receiver within crossover (" << dCross << "m) for Two_ray path; using Friis");
-      NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << pr << "dB");
-      return txPowerDbm + pr;
-    }
-  else   // Use Two-Ray Pathloss
-    {
-      tmp = txAntHeight * rxAntHeight;
-      double rayNumerator = tmp * tmp;
-      tmp = distance * distance;
-      double rayDenominator = tmp * tmp * m_systemLoss;
-      double rayPr = 10 * log10 (rayNumerator / rayDenominator);
-      NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << rayPr << "dB");
-      return txPowerDbm + rayPr;
-
-    }
-}
-
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel);
-
-TypeId
-LogDistancePropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::LogDistancePropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<LogDistancePropagationLossModel> ()
-    .AddAttribute ("Exponent",
-                   "The exponent of the Path Loss propagation model",
-                   DoubleValue (3.0),
-                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("ReferenceDistance",
-                   "The distance at which the reference loss is calculated (m)",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("ReferenceLoss",
-                   "The reference loss at reference distance (dB). (Default is Friis at 1m with 5.15 GHz)",
-                   DoubleValue (46.6777),
-                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceLoss),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-                   
-}
-
-LogDistancePropagationLossModel::LogDistancePropagationLossModel ()
-{}
-
-void 
-LogDistancePropagationLossModel::SetPathLossExponent (double n)
-{
-  m_exponent = n;
-}
-void 
-LogDistancePropagationLossModel::SetReference (double referenceDistance, double referenceLoss)
-{
-  m_referenceDistance = referenceDistance;
-  m_referenceLoss = referenceLoss;
-}
-double 
-LogDistancePropagationLossModel::GetPathLossExponent (void) const
-{
-  return m_exponent;
-}
-  
-double 
-LogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                                Ptr<MobilityModel> a,
-                                                Ptr<MobilityModel> b) const
-{
-  double distance = a->GetDistanceFrom (b);
-  if (distance <= m_referenceDistance)
-    {
-      return txPowerDbm;
-    }
-  /**
-   * The formula is:
-   * rx = 10 * log (Pr0(tx)) - n * 10 * log (d/d0)
-   *
-   * Pr0: rx power at reference distance d0 (W)
-   * d0: reference distance: 1.0 (m)
-   * d: distance (m)
-   * tx: tx power (dB)
-   * rx: dB
-   *
-   * Which, in our case is:
-   *
-   * rx = rx0(tx) - 10 * n * log (d/d0)
-   */
-  double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
-  double rxc = -m_referenceLoss - pathLossDb;
-  NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<<-m_referenceLoss<<"dB, "<<
-		"attenuation coefficient="<<rxc<<"db");
-  return txPowerDbm + rxc;
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (ThreeLogDistancePropagationLossModel);
-
-TypeId
-ThreeLogDistancePropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::ThreeLogDistancePropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<ThreeLogDistancePropagationLossModel> ()
-    .AddAttribute ("Distance0",
-                   "Beginning of the first (near) distance field",
-                   DoubleValue (1.0),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance0),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Distance1",
-                   "Beginning of the second (middle) distance field.",
-                   DoubleValue (200.0),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance1),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Distance2",
-                   "Beginning of the third (far) distance field.",
-                   DoubleValue (500.0),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance2),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Exponent0",
-                   "The exponent for the first field.",
-                   DoubleValue (1.9),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent0),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Exponent1",
-                   "The exponent for the second field.",
-                   DoubleValue (3.8),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent1),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Exponent2",
-                   "The exponent for the third field.",
-                   DoubleValue (3.8),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent2),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("ReferenceLoss",
-                   "The reference loss at distance d0 (dB). (Default is Friis at 1m with 5.15 GHz)",
-                   DoubleValue (46.6777),
-                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_referenceLoss),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-                   
-}
-
-ThreeLogDistancePropagationLossModel::ThreeLogDistancePropagationLossModel ()
-{
-}
-
-double 
-ThreeLogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                                     Ptr<MobilityModel> a,
-                                                     Ptr<MobilityModel> b) const
-{
-  double distance = a->GetDistanceFrom (b);
-  NS_ASSERT(distance >= 0);
-
-  // See doxygen comments for the formula and explanation
-
-  double pathLossDb;
-
-  if (distance < m_distance0)
-    {
-      pathLossDb = 0;
-    }
-  else if (distance < m_distance1)
-    {
-      pathLossDb = m_referenceLoss
-        + 10 * m_exponent0 * log10(distance / m_distance0);
-    }
-  else if (distance < m_distance2)
-    {
-      pathLossDb = m_referenceLoss
-        + 10 * m_exponent0 * log10(m_distance1 / m_distance0)
-        + 10 * m_exponent1 * log10(distance / m_distance1);
-    }
-  else
-    {
-      pathLossDb = m_referenceLoss
-        + 10 * m_exponent0 * log10(m_distance1 / m_distance0)
-        + 10 * m_exponent1 * log10(m_distance2 / m_distance1)
-        + 10 * m_exponent2 * log10(distance / m_distance2);
-    }
-
-  NS_LOG_DEBUG ("ThreeLogDistance distance=" << distance << "m, " <<
-                "attenuation=" << pathLossDb << "dB");
-
-  return txPowerDbm - pathLossDb;
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (NakagamiPropagationLossModel);
-
-TypeId
-NakagamiPropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::NakagamiPropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<NakagamiPropagationLossModel> ()
-    .AddAttribute ("Distance1",
-                   "Beginning of the second distance field. Default is 80m.",
-                   DoubleValue (80.0),
-                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance1),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("Distance2",
-                   "Beginning of the third distance field. Default is 200m.",
-                   DoubleValue (200.0),
-                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance2),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("m0",
-                   "m0 for distances smaller than Distance1. Default is 1.5.",
-                   DoubleValue (1.5),
-                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m0),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("m1",
-                   "m1 for distances smaller than Distance2. Default is 0.75.",
-                   DoubleValue (0.75),
-                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m1),
-                   MakeDoubleChecker<double> ())
-    .AddAttribute ("m2",
-                   "m2 for distances greater than Distance2. Default is 0.75.",
-                   DoubleValue (0.75),
-                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m2),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-                   
-}
-
-NakagamiPropagationLossModel::NakagamiPropagationLossModel ()
-{}
-
-double 
-NakagamiPropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                             Ptr<MobilityModel> a,
-                                             Ptr<MobilityModel> b) const
-{
-  // select m parameter
-
-  double distance = a->GetDistanceFrom (b);
-  NS_ASSERT(distance >= 0);
-
-  double m;
-  if (distance < m_distance1)
-    {
-      m = m_m0;
-    }
-  else if (distance < m_distance2)
-    {
-      m = m_m1;
-    }
-  else
-    {
-      m = m_m2;
-    }
-  
-  // the current power unit is dBm, but Watt is put into the Nakagami /
-  // Rayleigh distribution.
-  double powerW = pow(10, (txPowerDbm - 30) / 10);
-
-  double resultPowerW;
-
-  // switch between Erlang- and Gamma distributions: this is only for
-  // speed. (Gamma is equal to Erlang for any positive integer m.)
-  unsigned int int_m = static_cast<unsigned int>(floor(m));
-
-  if (int_m == m)
-    {
-      resultPowerW = m_erlangRandomVariable.GetValue(int_m, powerW / m);
-    }
-  else
-    {
-      resultPowerW = m_gammaRandomVariable.GetValue(m, powerW / m);
-    }
-
-  double resultPowerDbm = 10 * log10(resultPowerW) + 30;
-
-  NS_LOG_DEBUG ("Nakagami distance=" << distance << "m, " <<
-                "power=" << powerW <<"W, " <<
-                "resultPower=" << resultPowerW << "W=" << resultPowerDbm << "dBm");
-
-  return resultPowerDbm;
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (FixedRssLossModel);
-
-TypeId 
-FixedRssLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::FixedRssLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<FixedRssLossModel> ()
-    .AddAttribute ("Rss", "The fixed receiver Rss.",
-                   DoubleValue (-150.0),
-                   MakeDoubleAccessor (&FixedRssLossModel::m_rss),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-}
-FixedRssLossModel::FixedRssLossModel ()
-  : PropagationLossModel ()
-{}
-
-FixedRssLossModel::~FixedRssLossModel ()
-{}
-
-void 
-FixedRssLossModel::SetRss (double rss)
-{
-  m_rss = rss;
-}
-
-double 
-FixedRssLossModel::DoCalcRxPower (double txPowerDbm,
-                                           Ptr<MobilityModel> a,
-                                           Ptr<MobilityModel> b) const
-{
-  return m_rss;
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (MatrixPropagationLossModel);
-
-TypeId 
-MatrixPropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::MatrixPropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<MatrixPropagationLossModel> ()
-    .AddAttribute ("DefaultLoss", "The default value for propagation loss, dB.",
-                   DoubleValue (std::numeric_limits<double>::max ()),
-                   MakeDoubleAccessor (&MatrixPropagationLossModel::m_default),
-                   MakeDoubleChecker<double> ())
-    ;
-  return tid;
-}
-
-MatrixPropagationLossModel::MatrixPropagationLossModel ()
-  : PropagationLossModel (), m_default (std::numeric_limits<double>::max ())
-{
-}
-
-MatrixPropagationLossModel::~MatrixPropagationLossModel ()
-{
-}
-
-void 
-MatrixPropagationLossModel::SetDefaultLoss (double loss)
-{
-  m_default = loss;
-}
-
-void
-MatrixPropagationLossModel::SetLoss (Ptr<Object> a, Ptr<Object> b, double loss, bool symmetric)
-{
-  Ptr<MobilityModel> ma = a->GetObject<MobilityModel> ();
-  Ptr<MobilityModel> mb = b->GetObject<MobilityModel> ();
-  NS_ASSERT (ma != 0 && mb != 0);
-
-  MobilityPair p = std::make_pair(ma, mb);
-  std::map<MobilityPair, double>::iterator i = m_loss.find (p);
-  
-  if (i == m_loss.end ())
-    {
-      m_loss.insert (std::make_pair (p, loss));
-    }
-  else
-    {
-      i->second = loss;
-    }
-
-  if (symmetric)
-    {
-      SetLoss (b, a, loss, false);
-    }
-}
-
-double 
-MatrixPropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                           Ptr<MobilityModel> a,
-                                           Ptr<MobilityModel> b) const
-{
-  std::map<MobilityPair, double>::const_iterator i = m_loss.find (std::make_pair (a, b));
-  
-  if (i != m_loss.end ())
-    {
-      return txPowerDbm - i->second;
-    }
-  else
-    {
-      return txPowerDbm - m_default;
-    }
-}
-
-// ------------------------------------------------------------------------- //
-
-NS_OBJECT_ENSURE_REGISTERED (RangePropagationLossModel);
-
-TypeId
-RangePropagationLossModel::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RangePropagationLossModel")
-    .SetParent<PropagationLossModel> ()
-    .AddConstructor<RangePropagationLossModel> ()
-    .AddAttribute ("MaxRange",
-                   "Maximum Transmission Range (meters)",
-                   DoubleValue (250),
-                   MakeDoubleAccessor (&RangePropagationLossModel::m_range),
-                   MakeDoubleChecker<double> ())
-  ;
-  return tid;
-}
-
-RangePropagationLossModel::RangePropagationLossModel ()
-{
-}
-
-double
-RangePropagationLossModel::DoCalcRxPower (double txPowerDbm,
-                                          Ptr<MobilityModel> a,
-                                          Ptr<MobilityModel> b) const
-{
-  double distance = a->GetDistanceFrom (b);
-  if (distance <= m_range)
-    {
-      return txPowerDbm;
-    }
-  else
-    {
-      return -1000;
-    }
-}
-
-// ------------------------------------------------------------------------- //
-
-} // namespace ns3
--- a/src/common/propagation-loss-model.h	Fri Jan 28 12:55:16 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,547 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,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>
- * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
- * Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS
- * Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model
- *                Pavel Boyko <boyko@iitp.ru> for matrix
- */
-
-#ifndef PROPAGATION_LOSS_MODEL_H
-#define PROPAGATION_LOSS_MODEL_H
-
-#include "ns3/object.h"
-#include "ns3/random-variable.h"
-#include <map>
-
-namespace ns3 {
-
-class MobilityModel;
-
-/**
- * \brief Modelize the propagation loss through a transmission medium
- *
- * Calculate the receive power (dbm) from a transmit power (dbm)
- * and a mobility model for the source and destination positions.
- */
-class PropagationLossModel : public Object
-{
-public:
-  static TypeId GetTypeId (void);
-
-  PropagationLossModel ();
-  virtual ~PropagationLossModel ();
-
-  /**
-   * \brief Enables a chain of loss models to act on the signal
-   * \param The next PropagationLossModel to add to the chain
-   *
-   * This method of chaining propagation loss models only works commutatively
-   * if the propagation loss of all models in the chain are independent
-   * of transmit power.
-   */
-  void SetNext (Ptr<PropagationLossModel> next);
-
-  /**
-   * \param txPowerDbm current transmission power (in dBm)
-   * \param a the mobility model of the source
-   * \param b the mobility model of the destination
-   * \returns the reception power after adding/multiplying propagation loss (in dBm)
-   */
-  double CalcRxPower (double txPowerDbm,
-                      Ptr<MobilityModel> a,
-                      Ptr<MobilityModel> b) const;
-private:
-  PropagationLossModel (const PropagationLossModel &o);
-  PropagationLossModel &operator = (const PropagationLossModel &o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const = 0;
-
-  Ptr<PropagationLossModel> m_next;
-};
-
-/**
- * \brief The propagation loss follows a random distribution.
- */ 
-class RandomPropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  RandomPropagationLossModel ();
-  virtual ~RandomPropagationLossModel ();
-
-private:
-  RandomPropagationLossModel (const RandomPropagationLossModel &o);
-  RandomPropagationLossModel & operator = (const RandomPropagationLossModel &o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-  RandomVariable m_variable;
-};
-
-/**
- * \brief a Friis propagation loss model
- *
- * The Friis propagation loss model was first described in
- * "A Note on a Simple Transmission Formula", by 
- * "Harald T. Friis".
- * 
- * The original equation was described as:
- *  \f$ \frac{P_r}{P_t} = \frac{A_r A_t}{d^2\lambda^2} \f$
- *  with the following equation for the case of an
- *  isotropic antenna with no heat loss:
- *  \f$ A_{isotr.} = \frac{\lambda^2}{4\pi} \f$
- *
- * The final equation becomes:
- * \f$ \frac{P_r}{P_t} = \frac{\lambda^2}{(4 \pi d)^2} \f$
- *
- * Modern extensions to this original equation are:
- * \f$ P_r = \frac{P_t G_t G_r \lambda^2}{(4 \pi d)^2 L}\f$
- *
- * With:
- *  - \f$ P_r \f$ : reception power (W)
- *  - \f$ P_t \f$ : transmission power (W)
- *  - \f$ G_t \f$ : transmission gain (unit-less)
- *  - \f$ G_r \f$ : reception gain (unit-less)
- *  - \f$ \lambda \f$ : wavelength (m)
- *  - \f$ d \f$ : distance (m)
- *  - \f$ L \f$ : system loss (unit-less)
- *
- *
- * This model is invalid for small distance values.
- * The current implementation returns the txpower as the rxpower
- * for any distance smaller than MinDistance.
- */
-class FriisPropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  FriisPropagationLossModel ();
-  /**
-   * \param frequency (Hz)
-   * \param speed (m/s)
-   *
-   * Set the main wavelength used in the Friis model 
-   * calculation.
-   */
-  void SetLambda (double frequency, double speed);
-  /**
-   * \param lambda (m) the wavelength
-   *
-   * Set the main wavelength used in the Friis model 
-   * calculation.
-   */
-  void SetLambda (double lambda);
-  /**
-   * \param systemLoss (dimension-less)
-   *
-   * Set the system loss used by the Friis propagation model.
-   */
-  void SetSystemLoss (double systemLoss);
-
-  /**
-   * \param minDistance the minimum distance
-   *
-   * Below this distance, the txpower is returned
-   * unmodified as the rxpower.
-   */
-  void SetMinDistance (double minDistance);
-
-  /**
-   * \returns the minimum distance.
-   */
-  double GetMinDistance (void) const;
-
-  /**
-   * \returns the current wavelength (m)
-   */
-  double GetLambda (void) const;
-  /**
-   * \returns the current system loss (dimension-less)
-   */
-  double GetSystemLoss (void) const;
-
-private:
-  FriisPropagationLossModel (const FriisPropagationLossModel &o);
-  FriisPropagationLossModel & operator = (const FriisPropagationLossModel &o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-  double DbmToW (double dbm) const;
-  double DbmFromW (double w) const;
-
-  static const double PI;
-  double m_lambda;
-  double m_systemLoss;
-  double m_minDistance;
-};
-
-/*
- *
- * \brief a Two-Ray Ground propagation loss model ported from NS2
- *
- * Two-ray ground reflection model.
- *
- * \f$ Pr = \frac{Pt * Gt * Gr * (ht^2 * hr^2)}{d^4 * L} \f$
- *
- * The original equation in Rappaport's book assumes L = 1.
- * To be consistent with the free space equation, L is added here.
- *
- * Ht and Hr are set at the respective nodes z coordinate plus a model parameter
- * set via SetHeightAboveZ.
- *
- * The two-ray model does not give a good result for short distances, due to the
- * oscillation caused by constructive and destructive combination of the two
- * rays. Instead the Friis free-space model is used for small distances. 
- *
- * The crossover distance, below which Friis is used, is calculated as follows:
- *
- * \f$ dCross = \frac{(4 * pi * Ht * Hr)}{lambda} \f$
- */
-
-class TwoRayGroundPropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  TwoRayGroundPropagationLossModel ();
-  /**
-   * \param frequency (Hz)
-   * \param speed (m/s)
-   *
-   * Set the main wavelength used in the TwoRayGround model 
-   * calculation.
-   */
-  void SetLambda (double frequency, double speed);
-  /**
-   * \param lambda (m) the wavelength
-   *
-   * Set the main wavelength used in the TwoRayGround model 
-   * calculation.
-   */
-  void SetLambda (double lambda);
-  /**
-   * \param systemLoss (dimension-less)
-   *
-   * Set the system loss used by the TwoRayGround propagation model.
-   */
-  void SetSystemLoss (double systemLoss);
-  /**
-   * \param minDistance the minimum distance
-   *
-   * Below this distance, the txpower is returned
-   * unmodified as the rxpower.
-   */
-  void SetMinDistance (double minDistance);
-  /**
-   * \returns the minimum distance.
-   */
-  double GetMinDistance (void) const;
-  /**
-   * \returns the current wavelength (m)
-   */
-  double GetLambda (void) const;
-  /**
-   * \returns the current system loss (dimension-less)
-   */
-  double GetSystemLoss (void) const;
-  /**
-   * \param heightAboveZ the model antenna height above the node's Z coordinate
-   *
-   * Set the model antenna height above the node's Z coordinate
-   */
-  void SetHeightAboveZ (double heightAboveZ);
-
-private:
-  TwoRayGroundPropagationLossModel (const TwoRayGroundPropagationLossModel &o);
-  TwoRayGroundPropagationLossModel & operator = (const TwoRayGroundPropagationLossModel &o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-  double DbmToW (double dbm) const;
-  double DbmFromW (double w) const;
-
-  static const double PI;
-  double m_lambda;
-  double m_systemLoss;
-  double m_minDistance;
-  double m_heightAboveZ;
-};
-
-/**
- * \brief a log distance propagation model.
- *
- * This model calculates the reception power with a so-called
- * log-distance propagation model:
- * \f$ L = L_0 + 10 n log_{10}(\frac{d}{d_0})\f$
- *
- * where:
- *  - \f$ n \f$ : the path loss distance exponent
- *  - \f$ d_0 \f$ : reference distance (m)
- *  - \f$ L_0 \f$ : path loss at reference distance (dB)
- *  - \f$ d \f$ : distance (m)
- *  - \f$ L \f$ : path loss (dB)
- *
- * When the path loss is requested at a distance smaller than
- * the reference distance, the tx power is returned.
- *
- */
-class LogDistancePropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  LogDistancePropagationLossModel ();
-
-  /**
-   * \param n the path loss exponent.
-   * Set the path loss exponent.
-   */
-  void SetPathLossExponent (double n);
-  /** 
-   * \returns the current path loss exponent.
-   */
-  double GetPathLossExponent (void) const;
-
-  void SetReference (double referenceDistance, double referenceLoss);
-  
-private:
-  LogDistancePropagationLossModel (const LogDistancePropagationLossModel &o);
-  LogDistancePropagationLossModel & operator = (const LogDistancePropagationLossModel &o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-  static Ptr<PropagationLossModel> CreateDefaultReference (void);
-
-  double m_exponent;
-  double m_referenceDistance;
-  double m_referenceLoss;
-};
-
-/**
- * \brief A log distance path loss propagation model with three distance
- * fields. This model is the same as ns3::LogDistancePropagationLossModel
- * except that it has three distance fields: near, middle and far with
- * different exponents.
- *
- * Within each field the reception power is calculated using the log-distance
- * propagation equation:
- * \f[ L = L_0 + 10 \cdot n_0 log_{10}(\frac{d}{d_0})\f]
- * Each field begins where the previous ends and all together form a continuous function.
- *
- * There are three valid distance fields: near, middle, far. Actually four: the
- * first from 0 to the reference distance is invalid and returns txPowerDbm.
- *
- * \f[ \underbrace{0 \cdots\cdots}_{=0} \underbrace{d_0 \cdots\cdots}_{n_0} \underbrace{d_1 \cdots\cdots}_{n_1} \underbrace{d_2 \cdots\cdots}_{n_2} \infty \f]
- *
- * Complete formula for the path loss in dB:
- *
- * \f[\displaystyle L =
-\begin{cases}
-0 & d < d_0 \\
-L_0 + 10 \cdot n_0 \log_{10}(\frac{d}{d_0}) & d_0 \leq d < d_1 \\
-L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d}{d_1}) & d_1 \leq d < d_2 \\
-L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d_2}{d_1}) + 10 \cdot n_2 \log_{10}(\frac{d}{d_2})& d_2 \leq d
-\end{cases}\f]
- *
- * where:
- *  - \f$ L \f$ : resulting path loss (dB)
- *  - \f$ d \f$ : distance (m)
- *  - \f$ d_0, d_1, d_2 \f$ : three distance fields (m)
- *  - \f$ n_0, n_1, n_2 \f$ : path loss distance exponent for each field (unitless)
- *  - \f$ L_0 \f$ : path loss at reference distance (dB)
- *
- * When the path loss is requested at a distance smaller than the reference
- * distance \f$ d_0 \f$, the tx power (with no path loss) is returned. The
- * reference distance defaults to 1m and reference loss defaults to
- * ns3::FriisPropagationLossModel with 5.15 GHz and is thus \f$ L_0 \f$ = 46.67 dB.
- */
-
-class ThreeLogDistancePropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  ThreeLogDistancePropagationLossModel ();
-
-  // Parameters are all accessible via attributes.
-
-private:
-  ThreeLogDistancePropagationLossModel (const ThreeLogDistancePropagationLossModel& o);
-  ThreeLogDistancePropagationLossModel& operator= (const ThreeLogDistancePropagationLossModel& o);
-
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-
-  double m_distance0;
-  double m_distance1;
-  double m_distance2;
-
-  double m_exponent0;
-  double m_exponent1;
-  double m_exponent2;
-
-  double m_referenceLoss;
-};
-
-/**
- * \brief Nakagami-m fast fading propagation loss model.
- *
- * The Nakagami-m distribution is applied to the power level. The probability
- * density function is defined as
- * \f[ p(x; m, \omega) = \frac{2 m^m}{\Gamma(m) \omega^m} x^{2m - 1} e^{-\frac{m}{\omega} x^2} = 2 x \cdot p_{\text{Gamma}}(x^2, m, \frac{m}{\omega}) \f]
- * with \f$ m \f$ the fading depth parameter and \f$ \omega \f$ the average received power.
- *
- * It is implemented by either a ns3::GammaVariable or a ns3::ErlangVariable
- * random variable.
- *
- * Like in ns3::ThreeLogDistancePropagationLossModel, the m parameter is varied
- * over three distance fields:
- * \f[ \underbrace{0 \cdots\cdots}_{m_0} \underbrace{d_1 \cdots\cdots}_{m_1} \underbrace{d_2 \cdots\cdots}_{m_2} \infty \f]
- *
- * For m = 1 the Nakagami-m distribution equals the Rayleigh distribution. Thus
- * this model also implements Rayleigh distribution based fast fading.
- */
-
-class NakagamiPropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  NakagamiPropagationLossModel ();
-
-  // Parameters are all accessible via attributes.
-
-private:
-  NakagamiPropagationLossModel (const NakagamiPropagationLossModel& o);
-  NakagamiPropagationLossModel& operator= (const NakagamiPropagationLossModel& o);
-
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-
-  double m_distance1;
-  double m_distance2;
-
-  double m_m0;
-  double m_m1;
-  double m_m2;
-
-  ErlangVariable        m_erlangRandomVariable;
-  GammaVariable         m_gammaRandomVariable;
-};
-
-/**
- * \brief Return a constant received power level independent of the transmit 
- *  power
- *
- * The received power is constant independent of the transmit power.  The user
- * must set received power level through the Rss attribute or public 
- * SetRss() method.  Note that if this loss model is chained to other loss
- * models via SetNext() method, it can only be the first loss model in such
- * a chain, or else it will disregard the losses computed by loss models
- * that precede it in the chain. 
- */ 
-class FixedRssLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-
-  FixedRssLossModel ();
-  virtual ~FixedRssLossModel ();
-  /**
-   * \param rss (dBm) the received signal strength
-   *
-   * Set the received signal strength (RSS) in dBm.
-   */
-  void SetRss (double rss);
-
-private:
-  FixedRssLossModel (const FixedRssLossModel &o);
-  FixedRssLossModel & operator = (const FixedRssLossModel &o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-  double m_rss;
-};
-
-/**
- * \brief The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions.
- * 
- * This is supposed to be used by synthetic tests. Note that by default propagation loss is assumed to be symmetric.
- */
-class MatrixPropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  
-  MatrixPropagationLossModel ();
-  virtual ~MatrixPropagationLossModel ();
-  
-  /**
-   * \brief Set loss (in dB, positive) between pair of ns-3 objects
-   * (typically, nodes).
-   * 
-   * \param a           Source object
-   * \param b           Destination object
-   * \param loss        a -> b path loss, positive in dB
-   * \param symmetric   If true (default), both a->b and b->a paths will be affected
-   */ 
-  void SetLoss (Ptr<Object> a, Ptr<Object> b, double loss, bool symmetric = true);
-  /// Set default loss (in dB, positive) to be used, infinity if not set
-  void SetDefaultLoss (double);
-  
-private:
-  virtual double DoCalcRxPower (double txPowerDbm,
-                               Ptr<MobilityModel> a,
-                               Ptr<MobilityModel> b) const;
-private:
-  /// default loss
-  double m_default; 
-  
-  typedef std::pair< Ptr<MobilityModel>, Ptr<MobilityModel> > MobilityPair; 
-  /// Fixed loss between pair of nodes
-  std::map<MobilityPair, double> m_loss;
-};
-
-/**
- * \brief The propagation loss depends only on the distance (range) between transmitter and receiver.
- *
- * The single MaxRange attribute (units of meters) determines path loss.
- * Receivers at or within MaxRange meters receive the transmission at the
- * transmit power level. Receivers beyond MaxRange receive at power
- * -1000 dBm (effectively zero).
-*/
-class RangePropagationLossModel : public PropagationLossModel
-{
-public:
-  static TypeId GetTypeId (void);
-  RangePropagationLossModel ();
-private:
-  RangePropagationLossModel (const RangePropagationLossModel& o);
-  RangePropagationLossModel& operator= (const RangePropagationLossModel& o);
-  virtual double DoCalcRxPower (double txPowerDbm,
-                                Ptr<MobilityModel> a,
-                                Ptr<MobilityModel> b) const;
-private:
-  double m_range;
-};
-
-} // namespace ns3
-
-#endif /* PROPAGATION_LOSS_MODEL_H */
--- a/src/common/wscript	Fri Jan 28 12:55:16 2011 -0800
+++ b/src/common/wscript	Fri Jan 28 14:11:21 2011 -0800
@@ -23,11 +23,6 @@
         'pcap-file-test-suite.cc',
         'pcap-file-wrapper.cc',
         'output-stream-wrapper.cc',
-        'propagation-delay-model.cc',
-        'propagation-loss-model.cc',
-        'propagation-loss-model-test-suite.cc',
-        'jakes-propagation-loss-model.cc',
-        'cost231-propagation-loss-model.cc',
         'spectrum-model.cc',
         'spectrum-value.cc',
         'spectrum-value-test.cc',
@@ -59,10 +54,6 @@
         'pcap-file.h',
         'pcap-file-wrapper.h',
         'output-stream-wrapper.h',
-        'propagation-delay-model.h',
-        'propagation-loss-model.h',
-        'jakes-propagation-loss-model.h',
-        'cost231-propagation-loss-model.h',
         'spectrum-model.h',
         'spectrum-value.h',
         'spectrum-converter.h',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/cost231-propagation-loss-model.cc	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,191 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007,2008, 2009 INRIA, UDcast
+ *
+ * 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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
+ *                              <amine.ismail@udcast.com>
+ */
+
+#include "ns3/propagation-loss-model.h"
+#include "ns3/log.h"
+#include "ns3/mobility-model.h"
+#include "ns3/double.h"
+#include "ns3/pointer.h"
+#include <math.h>
+#include "cost231-propagation-loss-model.h"
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("Cost231PropagationLossModel");
+NS_OBJECT_ENSURE_REGISTERED (Cost231PropagationLossModel);
+
+TypeId
+Cost231PropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::Cost231PropagationLossModel")
+
+    .SetParent<PropagationLossModel> ()
+
+    .AddConstructor<Cost231PropagationLossModel> ()
+
+    .AddAttribute ("Lambda",
+                   "The wavelength  (default is 2.3 GHz at 300 000 km/s).",
+                   DoubleValue (300000000.0 / 2.3e9),
+                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_lambda),
+                   MakeDoubleChecker<double> ())
+
+    .AddAttribute ("Frequency",
+                   "The Frequency  (default is 2.3 GHz).",
+                   DoubleValue (2.3e9),
+                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_frequency),
+                   MakeDoubleChecker<double> ())
+
+    .AddAttribute ("BSAntennaHeight",
+                   " BS Antenna Height (default is 50m).",
+                   DoubleValue (50.0),
+                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_BSAntennaHeight),
+                   MakeDoubleChecker<double> ())
+
+    .AddAttribute ("SSAntennaHeight",
+                   " SS Antenna Height (default is 3m).",
+                   DoubleValue (3),
+                   MakeDoubleAccessor (&Cost231PropagationLossModel::m_SSAntennaHeight),
+                   MakeDoubleChecker<double> ())
+
+    .AddAttribute ("MinDistance",
+                   "The distance under which the propagation model refuses to give results (m) ",
+                   DoubleValue (0.5),
+                   MakeDoubleAccessor (&Cost231PropagationLossModel::SetMinDistance, &Cost231PropagationLossModel::GetMinDistance),
+                   MakeDoubleChecker<double> ());
+  return tid;
+}
+
+Cost231PropagationLossModel::Cost231PropagationLossModel ()
+{
+  C = 0;
+  m_shadowing = 10;
+}
+
+void
+Cost231PropagationLossModel::SetLambda (double frequency, double speed)
+{
+  m_lambda = speed / frequency;
+  m_frequency = frequency;
+}
+
+double
+Cost231PropagationLossModel::GetShadowing (void)
+{
+  return m_shadowing;
+}
+void
+Cost231PropagationLossModel::SetShadowing (double shadowing)
+{
+  m_shadowing = shadowing;
+}
+
+void
+Cost231PropagationLossModel::SetLambda (double lambda)
+{
+  m_lambda = lambda;
+  m_frequency = 300000000 / lambda;
+}
+
+double
+Cost231PropagationLossModel::GetLambda (void) const
+{
+  return m_lambda;
+}
+
+void
+Cost231PropagationLossModel::SetMinDistance (double minDistance)
+{
+  m_minDistance = minDistance;
+}
+double
+Cost231PropagationLossModel::GetMinDistance (void) const
+{
+  return m_minDistance;
+}
+
+void
+Cost231PropagationLossModel::SetBSAntennaHeight (double height)
+{
+  m_BSAntennaHeight = height;
+}
+
+double
+Cost231PropagationLossModel::GetBSAntennaHeight (void) const
+{
+  return m_BSAntennaHeight;
+}
+
+void
+Cost231PropagationLossModel::SetSSAntennaHeight (double height)
+{
+  m_SSAntennaHeight = height;
+}
+
+double
+Cost231PropagationLossModel::GetSSAntennaHeight (void) const
+{
+  return m_SSAntennaHeight;
+}
+
+void
+Cost231PropagationLossModel::SetEnvironment (Environment env)
+{
+  m_environment = env;
+}
+Cost231PropagationLossModel::Environment
+Cost231PropagationLossModel::GetEnvironment (void) const
+{
+  return m_environment;
+}
+
+double
+Cost231PropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
+{
+
+  double distance = a->GetDistanceFrom (b);
+  if (distance <= m_minDistance)
+    {
+      return 0.0;
+    }
+
+  double log_f = log (m_frequency / 1000000000) / 2.302;
+  double C_H = 0.8 + ((1.11 * log_f) - 0.7) * m_SSAntennaHeight - (1.56 * log_f);
+  double log_BSH = log (m_BSAntennaHeight) / 2.303;
+
+  // from the COST231 wiki entry
+  // 2.303 is for the logarithm base change
+
+  double loss_in_db = 46.3 + (33.9 * log_f) - (13.82 * log_BSH) - C_H + ((44.9 - 6.55 * log_BSH) * log (distance)
+                                                                         / 2.303) + C + m_shadowing;
+
+  NS_LOG_DEBUG ("dist =" << distance << ", Path Loss = " << loss_in_db);
+
+  return (0 - loss_in_db);
+
+}
+
+double
+Cost231PropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
+{
+  return txPowerDbm + GetLoss (a, b);
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/cost231-propagation-loss-model.h	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,92 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007,2008, 2009 INRIA, UDcast
+ *
+ * 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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
+ *                              <amine.ismail@udcast.com>
+ */
+
+#ifndef COST231_PROPAGATION_LOSS_MODEL_H_
+#define COST231_PROPAGATION_LOSS_MODEL_H_
+
+#include "ns3/nstime.h"
+#include "ns3/propagation-loss-model.h"
+
+namespace ns3 {
+
+/*
+ *  \brief The COST-Hata-Model is the most often cited of the COST 231 models.
+ *  Also called the Hata Model PCS Extension, it is a radio propagation model
+ *  that extends the Hata Model (which in turn is based on the Okumura Model)
+ *  to cover a more elaborated range of frequencies. COST (COperation
+ *  europ�enne dans le domaine de la recherche Scientifique et Technique)
+ *  is a European Union Forum for cooperative scientific research which has
+ *  developed this model accordingly to various experiments and researches.
+ *  This model is applicable to urban areas. To further evaluate Path Loss
+ *  in Suburban or Rural Quasi-open/Open Areas.
+ *  Frequency: 1500 MHz to 2000 MHz
+ *  Mobile Station Antenna Height: 1 up to 10m
+ *  Base station Antenna Height: 30m to 200m
+ *  Link Distance:up to 20 km
+ *
+ */
+
+class Cost231PropagationLossModel : public PropagationLossModel
+{
+
+public:
+  static TypeId GetTypeId (void);
+  Cost231PropagationLossModel ();
+  enum Environment
+  {
+    SubUrban, MediumCity, Metropolitan
+  };
+
+  /**
+   * \param a the mobility model of the source
+   * \param b the mobility model of the destination
+   * \returns the propagation loss (in dBm)
+   */
+  double GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
+  void SetBSAntennaHeight (double height);
+  void SetSSAntennaHeight (double height);
+  void SetEnvironment (Environment env);
+  void SetLambda (double lambda);
+  void SetMinDistance (double minDistance);
+  double GetBSAntennaHeight (void) const;
+  double GetSSAntennaHeight (void) const;
+  Environment GetEnvironment (void) const;
+  double GetMinDistance (void) const;
+  double GetLambda (void) const;
+  void SetLambda (double frequency, double speed);
+  double GetShadowing (void);
+  void SetShadowing (double shadowing);
+private:
+  virtual double DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
+  double m_BSAntennaHeight; // in meter
+  double m_SSAntennaHeight; // in meter
+  double C;
+  double m_lambda;
+  Environment m_environment;
+  double m_minDistance; // in meter
+  double m_frequency; // frequency in MHz
+  double m_shadowing;
+
+};
+
+}
+
+#endif /* COST231PROPAGATIONMODEL_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/jakes-propagation-loss-model.cc	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,259 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,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: Federico Maguolo <maguolof@dei.unipd.it>
+ */
+
+#include "ns3/simulator.h"
+#include "ns3/uinteger.h"
+#include "ns3/double.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-model.h"
+#include "ns3/log.h"
+#include "jakes-propagation-loss-model.h"
+#include <math.h>
+
+NS_LOG_COMPONENT_DEFINE ("Jakes");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (JakesPropagationLossModel);
+
+class JakesPropagationLossModel::PathCoefficients 
+{
+public:
+  PathCoefficients (Ptr<const JakesPropagationLossModel> jakes,
+                    Ptr<MobilityModel> receiver, 
+                    uint8_t nRays, 
+                    uint8_t nOscillators);
+  ~PathCoefficients ();
+  double GetLoss (void);
+  Ptr<MobilityModel> GetReceiver (void);
+private:
+  void DoConstruct (void);
+  Ptr<MobilityModel> m_receiver;
+  uint8_t m_nOscillators;
+  uint8_t m_nRays;
+  double **m_phases;
+  Time m_lastUpdate;
+  Ptr<const JakesPropagationLossModel> m_jakes;
+};
+
+
+JakesPropagationLossModel::PathCoefficients::PathCoefficients (Ptr<const JakesPropagationLossModel> jakes, 
+                                                           Ptr<MobilityModel> receiver, 
+                                                           uint8_t nRays, 
+							   uint8_t nOscillators)
+  : m_receiver (receiver),
+    m_nOscillators (nOscillators),
+    m_nRays (nRays),
+    m_jakes(jakes)
+{
+  DoConstruct ();
+}
+
+JakesPropagationLossModel::PathCoefficients::~PathCoefficients ()
+{
+  for (uint8_t i = 0; i < m_nRays; i++) 
+    {
+      delete [] m_phases[i];
+    }
+  delete [] m_phases;
+}
+
+void
+JakesPropagationLossModel::PathCoefficients::DoConstruct ()
+{
+  m_phases = new double*[m_nRays];
+  for (uint8_t i = 0; i < m_nRays; i++) 
+    {
+      m_phases[i] = new double[m_nOscillators + 1];
+      for (uint8_t j = 0; j <= m_nOscillators; j++) 
+        {
+          m_phases[i][j] = 2.0 * JakesPropagationLossModel::PI * m_jakes->m_variable.GetValue ();
+        }
+    }
+  m_lastUpdate = Simulator::Now ();
+}
+
+Ptr<MobilityModel>
+JakesPropagationLossModel::PathCoefficients::GetReceiver ()
+{
+  return m_receiver;
+}
+
+double
+JakesPropagationLossModel::PathCoefficients::GetLoss (void)
+{
+  uint16_t N = 4 * m_nOscillators + 2;
+  Time interval = Simulator::Now () - m_lastUpdate;
+  ComplexNumber coef= {0.0, 0.0};
+  ComplexNumber fading;
+  double norm = 0.0;
+  for (uint8_t i = 0; i < m_nRays; i++) 
+    {
+      fading.real = 0.0;
+      fading.imag = 0.0;
+      for (uint8_t j = 0; j <= m_nOscillators; j++) 
+        {
+          m_phases[i][j] += 2.0 * JakesPropagationLossModel::PI * 
+            cos (2.0 * JakesPropagationLossModel::PI * j / N) * m_jakes->m_fd * interval.GetSeconds ();
+          m_phases[i][j] -= 2.0 * JakesPropagationLossModel::PI * 
+            floor (m_phases[i][j] / 2.0 / JakesPropagationLossModel::PI);
+          fading.real += m_jakes->m_amp[j].real * cos (m_phases[i][j]);
+          fading.imag += m_jakes->m_amp[j].imag * cos (m_phases[i][j]);
+          norm += sqrt(pow (m_jakes->m_amp[j].real, 2) + pow(m_jakes->m_amp[j].imag, 2));
+        }
+    coef.real += fading.real;
+    coef.imag += fading.imag;
+    }
+  m_lastUpdate = Simulator::Now ();
+  double k = sqrt (pow (coef.real, 2) + pow (coef.imag, 2)) / norm;
+  NS_LOG_DEBUG ("Jakes coef "<< k << " (" << 10 * log10 (k) << "dB)");
+  return 10 * log10 (k);
+}
+
+const double JakesPropagationLossModel::PI = 3.14159265358979323846;
+
+TypeId
+JakesPropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::JakesPropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<JakesPropagationLossModel> ()
+    .AddAttribute ("NumberOfRaysPerPath",
+                   "The number of rays to use by default for compute the fading coeficent for a given path (default is 1)",
+                   UintegerValue (1),
+		   MakeUintegerAccessor (&JakesPropagationLossModel::SetNRays,
+                                         &JakesPropagationLossModel::GetNRays),
+		   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("NumberOfOscillatorsPerRay",
+                   "The number of oscillators to use by default for compute the coeficent for a given ray of a given "
+                   "path (default is 4)",
+                   UintegerValue (4),
+		   MakeUintegerAccessor (&JakesPropagationLossModel::SetNOscillators,
+                                         &JakesPropagationLossModel::GetNOscillators),
+		   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("DopplerFreq",
+                   "The doppler frequency in Hz (f_d = v / lambda = v * f / c), the default is 0)",
+                   DoubleValue (0.0),
+		   MakeDoubleAccessor (&JakesPropagationLossModel::m_fd),
+		   MakeDoubleChecker<double> ())
+    .AddAttribute ("Distribution",
+                   "The distribution to choose the initial phases.",
+                   RandomVariableValue (ConstantVariable (1.0)),
+                   MakeRandomVariableAccessor (&JakesPropagationLossModel::m_variable),
+                   MakeRandomVariableChecker ())
+    ;
+  return tid;
+}
+
+JakesPropagationLossModel::JakesPropagationLossModel ()
+  : m_amp (0),
+    m_nRays (0),
+    m_nOscillators (0)
+{}
+
+JakesPropagationLossModel::~JakesPropagationLossModel ()
+{
+  delete [] m_amp;
+  for (PathsList::iterator i = m_paths.end (); i != m_paths.begin (); i--) 
+    {
+      PathsSet *ps = *i;
+      for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) 
+        {
+          PathCoefficients *pc = *r;
+          delete pc;
+        }
+      delete ps;
+    }
+}
+
+void
+JakesPropagationLossModel::SetNRays (uint8_t nRays)
+{
+  m_nRays = nRays;
+}
+
+void
+JakesPropagationLossModel::SetNOscillators (uint8_t nOscillators)
+{
+  m_nOscillators = nOscillators;
+  delete [] m_amp;
+  uint16_t N = 4 * m_nOscillators + 2;
+  m_amp = new ComplexNumber[m_nOscillators + 1];
+  m_amp[0].real = 2.0 * sqrt(2.0 / N) * cos (PI / 4.0);
+  m_amp[0].imag = 2.0 * sqrt(2.0 / N) * sin (PI / 4.0);
+  for (uint8_t i = 1; i <= m_nOscillators; i++) 
+    {
+      double beta = PI * (double)i / m_nOscillators;
+      m_amp[i].real = 4.0 * cos (beta) / sqrt(N);
+      m_amp[i].imag = 4.0 * sin (beta) / sqrt(N);
+    }
+}
+
+uint8_t 
+JakesPropagationLossModel::GetNRays (void) const
+{
+  return m_nRays;
+}
+uint8_t 
+JakesPropagationLossModel::GetNOscillators (void) const
+{
+  return m_nOscillators;
+}
+
+
+double 
+JakesPropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                          Ptr<MobilityModel> a,
+                                          Ptr<MobilityModel> b) const
+{
+  PathsList::iterator i = m_paths.end ();
+  while (i != m_paths.begin ()) 
+    {
+      i--;
+      PathsSet *ps = *i;
+      if (ps->sender == a) 
+        {
+          m_paths.erase (i);
+          m_paths.push_back (ps);
+          for (DestinationList::iterator r = ps->receivers.begin (); r != ps->receivers.end (); r++) 
+            {
+              PathCoefficients *pc = *r;
+              if (pc->GetReceiver () == b) 
+                {
+                  ps->receivers.erase (r);
+                  ps->receivers.push_back (pc);
+                  return txPowerDbm + pc->GetLoss ();
+                }
+            }
+          PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators);
+          ps->receivers.push_back (pc);
+          return txPowerDbm + pc->GetLoss ();
+        }
+    }
+  PathsSet *ps = new PathsSet;
+  ps->sender = a;
+  PathCoefficients *pc = new PathCoefficients (this, b, m_nRays, m_nOscillators);
+  ps->receivers.push_back (pc);
+  m_paths.push_back (ps);
+  return txPowerDbm + pc->GetLoss ();
+}
+
+} // namespace ns3
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/jakes-propagation-loss-model.h	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,137 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,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: Federico Maguolo <maguolof@dei.unipd.it>
+ */
+#ifndef PROPAGATION_JAKES_MODEL_H
+#define PROPAGATION_JAKES_MODEL_H
+
+#include "ns3/nstime.h"
+#include "propagation-loss-model.h"
+
+namespace ns3 {
+
+
+/**
+ * \brief a Jakes propagation loss model
+ *
+ * The Jakes propagation loss model implemented here is 
+ * described in [1].
+ * 
+ *
+ * We call path the set of rays that depart from a given 
+ * transmitter and arrive to a given receiver. For each ray
+ * The complex coefficient is compute as follow:
+ * \f[ u(t)=u_c(t) + j u_s(t)\f]
+ * \f[ u_c(t) = \frac{2}{\sqrt{N}}\sum_{n=0}^{M}a_n\cos(\omega_n t+\phi_n)\f]
+ * \f[ u_s(t) = \frac{2}{\sqrt{N}}\sum_{n=0}^{M}b_n\cos(\omega_n t+\phi_n)\f]
+ * where
+ * \f[ a_n=\left \{ \begin{array}{ll}
+ * \sqrt{2}\cos\beta_0 & n=0 \\
+ * 2\cos\beta_n & n=1,2,\ldots,M
+ * \end{array}
+ * \right .\f]
+ * \f[ b_n=\left \{ \begin{array}{ll}
+ * \sqrt{2}\sin\beta_0 & n=0 \\
+ * 2\sin\beta_n & n=1,2,\ldots,M
+ * \end{array}
+ * \right .\f]
+ * \f[ \beta_n=\left \{ \begin{array}{ll}
+ * \frac{\pi}{4} & n=0 \\
+ * \frac{\pi n}{M} & n=1,2,\ldots,M
+ * \end{array}
+ * \right .\f]
+ * \f[ \omega_n=\left \{ \begin{array}{ll}
+ * 2\pi f_d & n=0 \\
+ * 2\pi f_d \cos\frac{2\pi n}{N} & n=1,2,\ldots,M
+ * \end{array}
+ * \right .\f]
+ *
+ * The parameter \f$f_d\f$ is the doppler frequency and \f$N=4M+2\f$ where
+ * \f$M\f$ is the number of oscillators per ray.
+ *
+ * The attenuation coefficent of the path is the magnitude of the sum of 
+ * all the ray coefficients. This attenuation coefficient could be greater than
+ * \f$1\f$, hence it is divide by \f$ \frac{2N_r}{\sqrt{N}} \sum_{n+0}^{M}\sqrt{a_n^2 +b_n^2}\f$
+ * where \f$N_r\f$ is the number of rays.
+ *
+ * The initail phases \f$\phi_i\f$ are random and they are choosen according 
+ * to a given distribution.
+ * 
+ * [1] Y. R. Zheng and C. Xiao, "Simulation Models With Correct 
+ * Statistical Properties for Rayleigh Fading Channel", IEEE
+ * Trans. on Communications, Vol. 51, pp 920-928, June 2003
+ */
+class JakesPropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  JakesPropagationLossModel ();
+  virtual ~JakesPropagationLossModel ();
+
+  /**
+   * \param nRays Number of rays per path
+   *
+   * Set the number of rays for each path
+   */
+  void SetNRays (uint8_t nRays);
+  /**
+   * \param nOscillators Number of oscillators
+   *
+   * Set the number of oscillators to use to compute the ray coefficient
+   */
+  void SetNOscillators (uint8_t nOscillators);
+
+  uint8_t GetNRays (void) const;
+  uint8_t GetNOscillators (void) const;
+
+private:
+  JakesPropagationLossModel (const JakesPropagationLossModel &o);
+  JakesPropagationLossModel & operator = (const JakesPropagationLossModel &o);
+  void DoConstruct (void);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+
+  class PathCoefficients;
+  struct ComplexNumber {
+    double real;
+    double imag;
+  };
+  friend class PathCoefficents;
+  typedef std::vector<PathCoefficients *> DestinationList;
+  struct PathsSet {
+    Ptr<MobilityModel> sender;
+    DestinationList receivers;
+  };
+  typedef std::vector<PathsSet *> PathsList;
+
+  
+  static const double PI;
+  ComplexNumber* m_amp;
+  RandomVariable m_variable;
+  double m_fd;  
+  mutable PathsList m_paths;
+  uint8_t m_nRays;
+  uint8_t m_nOscillators;
+};
+
+} // namespace ns3
+
+#endif /* PROPAGATION_JAKES_MODEL_H */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/propagation-delay-model.cc	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,104 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,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 "propagation-delay-model.h"
+#include "ns3/random-variable.h"
+#include "ns3/mobility-model.h"
+#include "ns3/double.h"
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel);
+
+TypeId 
+PropagationDelayModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::PropagationDelayModel")
+    .SetParent<Object> ()
+    ;
+  return tid;
+}
+
+PropagationDelayModel::~PropagationDelayModel ()
+{}
+
+NS_OBJECT_ENSURE_REGISTERED (RandomPropagationDelayModel);
+
+TypeId 
+RandomPropagationDelayModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomPropagationDelayModel")
+    .SetParent<PropagationDelayModel> ()
+    .AddConstructor<RandomPropagationDelayModel> ()
+    .AddAttribute ("Variable",
+                   "The random variable which generates random delays (s).",
+                   RandomVariableValue (UniformVariable (0.0, 1.0)),
+                   MakeRandomVariableAccessor (&RandomPropagationDelayModel::m_variable),
+                   MakeRandomVariableChecker ())
+    ;
+  return tid;
+}
+
+RandomPropagationDelayModel::RandomPropagationDelayModel ()
+{}
+RandomPropagationDelayModel::~RandomPropagationDelayModel ()
+{}
+Time 
+RandomPropagationDelayModel::GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
+{
+  return Seconds (m_variable.GetValue ());
+}
+
+NS_OBJECT_ENSURE_REGISTERED (ConstantSpeedPropagationDelayModel);
+
+TypeId
+ConstantSpeedPropagationDelayModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ConstantSpeedPropagationDelayModel")
+    .SetParent<PropagationDelayModel> ()
+    .AddConstructor<ConstantSpeedPropagationDelayModel> ()
+    .AddAttribute ("Speed", "The speed (m/s)",
+                   DoubleValue (300000000.0),
+                   MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}
+
+ConstantSpeedPropagationDelayModel::ConstantSpeedPropagationDelayModel ()
+{}
+Time 
+ConstantSpeedPropagationDelayModel::GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
+{
+  double distance = a->GetDistanceFrom (b);
+  double seconds = distance / m_speed;
+  return Seconds (seconds);
+}
+void 
+ConstantSpeedPropagationDelayModel::SetSpeed (double speed)
+{
+  m_speed = speed;
+}
+double 
+ConstantSpeedPropagationDelayModel::GetSpeed (void) const
+{
+  return m_speed;
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/propagation-delay-model.h	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,96 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,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 PROPAGATION_DELAY_MODEL_H
+#define PROPAGATION_DELAY_MODEL_H
+
+#include "ns3/ptr.h"
+#include "ns3/object.h"
+#include "ns3/nstime.h"
+#include "ns3/random-variable.h"
+
+namespace ns3 {
+
+class MobilityModel;
+
+/**
+ * \brief calculate a propagation delay.
+ */
+class PropagationDelayModel : public Object
+{
+public:
+  static TypeId GetTypeId (void);
+  virtual ~PropagationDelayModel ();
+  /**
+   * \param a the source
+   * \param b the destination
+   * \returns the calculated propagation delay
+   *
+   * Calculate the propagation delay between the specified
+   * source and destination.
+   */
+  virtual Time GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const = 0;
+};
+
+/**
+ * \brief the propagation delay is random
+ */
+class RandomPropagationDelayModel : public PropagationDelayModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  /**
+   * Use the default parameters from PropagationDelayRandomDistribution.
+   */
+  RandomPropagationDelayModel ();
+  virtual ~RandomPropagationDelayModel ();
+  virtual Time GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
+private:
+  RandomVariable m_variable;
+};
+
+/**
+ * \brief the propagation speed is constant
+ */
+class ConstantSpeedPropagationDelayModel : public PropagationDelayModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  /**
+   * Use the default parameters from PropagationDelayConstantSpeed.
+   */
+  ConstantSpeedPropagationDelayModel ();
+  virtual Time GetDelay (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
+  /**
+   * \param speed the new speed (m/s)
+   */
+  void SetSpeed (double speed);
+  /**
+   * \returns the current propagation speed (m/s).
+   */
+  double GetSpeed (void) const;
+private:
+  double m_speed;
+};
+
+} // namespace ns3
+
+#endif /* PROPAGATION_DELAY_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/propagation-loss-model.cc	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,832 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,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>
+ * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
+ * Contributions: Tom Hewer <tomhewer@mac.com> for Two Ray Ground Model
+ *                Pavel Boyko <boyko@iitp.ru> for matrix
+ */
+
+#include "propagation-loss-model.h"
+#include "ns3/log.h"
+#include "ns3/mobility-model.h"
+#include "ns3/boolean.h"
+#include "ns3/double.h"
+#include <math.h>
+
+NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
+
+namespace ns3 {
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (PropagationLossModel);
+
+TypeId 
+PropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::PropagationLossModel")
+    .SetParent<Object> ()
+    ;
+  return tid;
+}
+
+PropagationLossModel::PropagationLossModel ()
+  : m_next (0)
+{}
+
+PropagationLossModel::~PropagationLossModel ()
+{}
+
+void 
+PropagationLossModel::SetNext (Ptr<PropagationLossModel> next)
+{
+  m_next = next;
+}
+
+double 
+PropagationLossModel::CalcRxPower (double txPowerDbm,
+                                   Ptr<MobilityModel> a,
+                                   Ptr<MobilityModel> b) const
+{
+  double self = DoCalcRxPower (txPowerDbm, a, b);
+  if (m_next != 0)
+    {
+      self = m_next->CalcRxPower (self, a, b);
+    }
+  return self;
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
+
+TypeId 
+RandomPropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RandomPropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<RandomPropagationLossModel> ()
+    .AddAttribute ("Variable", "The random variable used to pick a loss everytime CalcRxPower is invoked.",
+                   RandomVariableValue (ConstantVariable (1.0)),
+                   MakeRandomVariableAccessor (&RandomPropagationLossModel::m_variable),
+                   MakeRandomVariableChecker ())
+    ;
+  return tid;
+}
+RandomPropagationLossModel::RandomPropagationLossModel ()
+  : PropagationLossModel ()
+{}
+
+RandomPropagationLossModel::~RandomPropagationLossModel ()
+{}
+
+double 
+RandomPropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                           Ptr<MobilityModel> a,
+                                           Ptr<MobilityModel> b) const
+{
+  double rxc = -m_variable.GetValue ();
+  NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
+  return txPowerDbm + rxc;
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (FriisPropagationLossModel);
+
+const double FriisPropagationLossModel::PI = 3.14159265358979323846;
+
+TypeId 
+FriisPropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::FriisPropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<FriisPropagationLossModel> ()
+    .AddAttribute ("Lambda", 
+                   "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
+                   DoubleValue (300000000.0 / 5.150e9),
+                   MakeDoubleAccessor (&FriisPropagationLossModel::m_lambda),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("SystemLoss", "The system loss",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MinDistance", 
+                   "The distance under which the propagation model refuses to give results (m)",
+                   DoubleValue (0.5),
+                   MakeDoubleAccessor (&FriisPropagationLossModel::SetMinDistance,
+                                       &FriisPropagationLossModel::GetMinDistance),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}
+
+FriisPropagationLossModel::FriisPropagationLossModel ()
+{}
+void 
+FriisPropagationLossModel::SetSystemLoss (double systemLoss)
+{
+  m_systemLoss = systemLoss;
+}
+double 
+FriisPropagationLossModel::GetSystemLoss (void) const
+{
+  return m_systemLoss;
+}
+void 
+FriisPropagationLossModel::SetMinDistance (double minDistance)
+{
+  m_minDistance = minDistance;
+}
+double 
+FriisPropagationLossModel::GetMinDistance (void) const
+{
+  return m_minDistance;
+}
+void 
+FriisPropagationLossModel::SetLambda (double frequency, double speed)
+{
+  m_lambda = speed / frequency;
+}
+void 
+FriisPropagationLossModel::SetLambda (double lambda)
+{
+  m_lambda = lambda;
+}
+double 
+FriisPropagationLossModel::GetLambda (void) const
+{
+  return m_lambda;
+}
+
+double 
+FriisPropagationLossModel::DbmToW (double dbm) const
+{
+  double mw = pow(10.0,dbm/10.0);
+  return mw / 1000.0;
+}
+
+double
+FriisPropagationLossModel::DbmFromW (double w) const
+{
+  double dbm = log10 (w * 1000.0) * 10.0;
+  return dbm;
+}
+
+double 
+FriisPropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                          Ptr<MobilityModel> a,
+                                          Ptr<MobilityModel> b) const
+{
+  /*
+   * Friis free space equation:
+   * where Pt, Gr, Gr and P are in Watt units
+   * L is in meter units.
+   *
+   *    P     Gt * Gr * (lambda^2)
+   *   --- = ---------------------
+   *    Pt     (4 * pi * d)^2 * L
+   *
+   * Gt: tx gain (unit-less)
+   * Gr: rx gain (unit-less)
+   * Pt: tx power (W)
+   * d: distance (m)
+   * L: system loss
+   * lambda: wavelength (m)
+   *
+   * Here, we ignore tx and rx gain and the input and output values 
+   * are in dB or dBm:
+   *
+   *                           lambda^2
+   * rx = tx +  10 log10 (-------------------)
+   *                       (4 * pi * d)^2 * L
+   *
+   * rx: rx power (dB)
+   * tx: tx power (dB)
+   * d: distance (m)
+   * L: system loss (unit-less)
+   * lambda: wavelength (m)
+   */
+  double distance = a->GetDistanceFrom (b);
+  if (distance <= m_minDistance)
+    {
+      return txPowerDbm;
+    }
+  double numerator = m_lambda * m_lambda;
+  double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
+  double pr = 10 * log10 (numerator / denominator);
+  NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
+  return txPowerDbm + pr;
+}
+
+// ------------------------------------------------------------------------- //
+// -- Two-Ray Ground Model ported from NS-2 -- tomhewer@mac.com -- Nov09 //
+
+NS_OBJECT_ENSURE_REGISTERED (TwoRayGroundPropagationLossModel);
+
+const double TwoRayGroundPropagationLossModel::PI = 3.14159265358979323846;
+
+TypeId 
+TwoRayGroundPropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::TwoRayGroundPropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<TwoRayGroundPropagationLossModel> ()
+    .AddAttribute ("Lambda",
+                   "The wavelength  (default is 5.15 GHz at 300 000 km/s).",
+                   DoubleValue (300000000.0 / 5.150e9),
+                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_lambda),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("SystemLoss", "The system loss",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_systemLoss),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("MinDistance",
+                   "The distance under which the propagation model refuses to give results (m)",
+                   DoubleValue (0.5),
+                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::SetMinDistance,
+                                       &TwoRayGroundPropagationLossModel::GetMinDistance),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("HeightAboveZ",
+                   "The height of the antenna (m) above the node's Z coordinate",
+                   DoubleValue (0),
+                   MakeDoubleAccessor (&TwoRayGroundPropagationLossModel::m_heightAboveZ),
+                   MakeDoubleChecker<double> ())
+  ;
+  return tid;
+}
+
+TwoRayGroundPropagationLossModel::TwoRayGroundPropagationLossModel ()
+{
+}
+void
+TwoRayGroundPropagationLossModel::SetSystemLoss (double systemLoss)
+{
+  m_systemLoss = systemLoss;
+}
+double
+TwoRayGroundPropagationLossModel::GetSystemLoss (void) const
+{
+  return m_systemLoss;
+}
+void
+TwoRayGroundPropagationLossModel::SetMinDistance (double minDistance)
+{
+  m_minDistance = minDistance;
+}
+double
+TwoRayGroundPropagationLossModel::GetMinDistance (void) const
+{
+  return m_minDistance;
+}
+void
+TwoRayGroundPropagationLossModel::SetHeightAboveZ (double heightAboveZ)
+{
+  m_heightAboveZ = heightAboveZ;
+}
+void 
+TwoRayGroundPropagationLossModel::SetLambda (double frequency, double speed)
+{
+  m_lambda = speed / frequency;
+}
+void 
+TwoRayGroundPropagationLossModel::SetLambda (double lambda)
+{
+  m_lambda = lambda;
+}
+double 
+TwoRayGroundPropagationLossModel::GetLambda (void) const
+{
+  return m_lambda;
+}
+
+double 
+TwoRayGroundPropagationLossModel::DbmToW (double dbm) const
+{
+  double mw = pow (10.0,dbm / 10.0);
+  return mw / 1000.0;
+}
+
+double
+TwoRayGroundPropagationLossModel::DbmFromW (double w) const
+{
+  double dbm = log10 (w * 1000.0) * 10.0;
+  return dbm;
+}
+
+double 
+TwoRayGroundPropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                                 Ptr<MobilityModel> a,
+                                                 Ptr<MobilityModel> b) const
+{
+  /*
+   * Two-Ray Ground equation:
+   *
+   * where Pt, Gt and Gr are in dBm units
+   * L, Ht and Hr are in meter units.
+   *
+   *   Pr      Gt * Gr * (Ht^2 * Hr^2)
+   *   -- =  (-------------------------)
+   *   Pt            d^4 * L
+   *
+   * Gt: tx gain (unit-less)
+   * Gr: rx gain (unit-less)
+   * Pt: tx power (dBm)
+   * d: distance (m)
+   * L: system loss
+   * Ht: Tx antenna height (m)
+   * Hr: Rx antenna height (m)
+   * lambda: wavelength (m)
+   *
+   * As with the Friis model we ignore tx and rx gain and output values
+   * are in dB or dBm
+   *
+   *                      (Ht * Ht) * (Hr * Hr)
+   * rx = tx + 10 log10 (-----------------------)
+   *                      (d * d * d * d) * L
+   */
+  double distance = a->GetDistanceFrom (b);
+  if (distance <= m_minDistance)
+    {
+      return txPowerDbm;
+    }
+
+  // Set the height of the Tx and Rx antennae
+  double txAntHeight = a->GetPosition ().z + m_heightAboveZ;
+  double rxAntHeight = b->GetPosition ().z + m_heightAboveZ;
+
+  // Calculate a crossover distance, under which we use Friis
+  /*
+   * 
+   * dCross = (4 * pi * Ht * Hr) / lambda
+   *
+   */
+
+  double dCross = (4 * PI * txAntHeight * rxAntHeight) / GetLambda ();
+  double tmp = 0;
+  if (distance <= dCross)
+    {
+      // We use Friis
+      double numerator = m_lambda * m_lambda;
+      tmp = PI * distance;
+      double denominator = 16 * tmp * tmp * m_systemLoss;
+      double pr = 10 * log10 (numerator / denominator);
+      NS_LOG_DEBUG ("Receiver within crossover (" << dCross << "m) for Two_ray path; using Friis");
+      NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << pr << "dB");
+      return txPowerDbm + pr;
+    }
+  else   // Use Two-Ray Pathloss
+    {
+      tmp = txAntHeight * rxAntHeight;
+      double rayNumerator = tmp * tmp;
+      tmp = distance * distance;
+      double rayDenominator = tmp * tmp * m_systemLoss;
+      double rayPr = 10 * log10 (rayNumerator / rayDenominator);
+      NS_LOG_DEBUG ("distance=" << distance << "m, attenuation coefficient=" << rayPr << "dB");
+      return txPowerDbm + rayPr;
+
+    }
+}
+
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (LogDistancePropagationLossModel);
+
+TypeId
+LogDistancePropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::LogDistancePropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<LogDistancePropagationLossModel> ()
+    .AddAttribute ("Exponent",
+                   "The exponent of the Path Loss propagation model",
+                   DoubleValue (3.0),
+                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_exponent),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("ReferenceDistance",
+                   "The distance at which the reference loss is calculated (m)",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceDistance),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("ReferenceLoss",
+                   "The reference loss at reference distance (dB). (Default is Friis at 1m with 5.15 GHz)",
+                   DoubleValue (46.6777),
+                   MakeDoubleAccessor (&LogDistancePropagationLossModel::m_referenceLoss),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+                   
+}
+
+LogDistancePropagationLossModel::LogDistancePropagationLossModel ()
+{}
+
+void 
+LogDistancePropagationLossModel::SetPathLossExponent (double n)
+{
+  m_exponent = n;
+}
+void 
+LogDistancePropagationLossModel::SetReference (double referenceDistance, double referenceLoss)
+{
+  m_referenceDistance = referenceDistance;
+  m_referenceLoss = referenceLoss;
+}
+double 
+LogDistancePropagationLossModel::GetPathLossExponent (void) const
+{
+  return m_exponent;
+}
+  
+double 
+LogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                                Ptr<MobilityModel> a,
+                                                Ptr<MobilityModel> b) const
+{
+  double distance = a->GetDistanceFrom (b);
+  if (distance <= m_referenceDistance)
+    {
+      return txPowerDbm;
+    }
+  /**
+   * The formula is:
+   * rx = 10 * log (Pr0(tx)) - n * 10 * log (d/d0)
+   *
+   * Pr0: rx power at reference distance d0 (W)
+   * d0: reference distance: 1.0 (m)
+   * d: distance (m)
+   * tx: tx power (dB)
+   * rx: dB
+   *
+   * Which, in our case is:
+   *
+   * rx = rx0(tx) - 10 * n * log (d/d0)
+   */
+  double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
+  double rxc = -m_referenceLoss - pathLossDb;
+  NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<<-m_referenceLoss<<"dB, "<<
+		"attenuation coefficient="<<rxc<<"db");
+  return txPowerDbm + rxc;
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (ThreeLogDistancePropagationLossModel);
+
+TypeId
+ThreeLogDistancePropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ThreeLogDistancePropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<ThreeLogDistancePropagationLossModel> ()
+    .AddAttribute ("Distance0",
+                   "Beginning of the first (near) distance field",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance0),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Distance1",
+                   "Beginning of the second (middle) distance field.",
+                   DoubleValue (200.0),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance1),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Distance2",
+                   "Beginning of the third (far) distance field.",
+                   DoubleValue (500.0),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_distance2),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Exponent0",
+                   "The exponent for the first field.",
+                   DoubleValue (1.9),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent0),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Exponent1",
+                   "The exponent for the second field.",
+                   DoubleValue (3.8),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent1),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Exponent2",
+                   "The exponent for the third field.",
+                   DoubleValue (3.8),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_exponent2),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("ReferenceLoss",
+                   "The reference loss at distance d0 (dB). (Default is Friis at 1m with 5.15 GHz)",
+                   DoubleValue (46.6777),
+                   MakeDoubleAccessor (&ThreeLogDistancePropagationLossModel::m_referenceLoss),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+                   
+}
+
+ThreeLogDistancePropagationLossModel::ThreeLogDistancePropagationLossModel ()
+{
+}
+
+double 
+ThreeLogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                                     Ptr<MobilityModel> a,
+                                                     Ptr<MobilityModel> b) const
+{
+  double distance = a->GetDistanceFrom (b);
+  NS_ASSERT(distance >= 0);
+
+  // See doxygen comments for the formula and explanation
+
+  double pathLossDb;
+
+  if (distance < m_distance0)
+    {
+      pathLossDb = 0;
+    }
+  else if (distance < m_distance1)
+    {
+      pathLossDb = m_referenceLoss
+        + 10 * m_exponent0 * log10(distance / m_distance0);
+    }
+  else if (distance < m_distance2)
+    {
+      pathLossDb = m_referenceLoss
+        + 10 * m_exponent0 * log10(m_distance1 / m_distance0)
+        + 10 * m_exponent1 * log10(distance / m_distance1);
+    }
+  else
+    {
+      pathLossDb = m_referenceLoss
+        + 10 * m_exponent0 * log10(m_distance1 / m_distance0)
+        + 10 * m_exponent1 * log10(m_distance2 / m_distance1)
+        + 10 * m_exponent2 * log10(distance / m_distance2);
+    }
+
+  NS_LOG_DEBUG ("ThreeLogDistance distance=" << distance << "m, " <<
+                "attenuation=" << pathLossDb << "dB");
+
+  return txPowerDbm - pathLossDb;
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (NakagamiPropagationLossModel);
+
+TypeId
+NakagamiPropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::NakagamiPropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<NakagamiPropagationLossModel> ()
+    .AddAttribute ("Distance1",
+                   "Beginning of the second distance field. Default is 80m.",
+                   DoubleValue (80.0),
+                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance1),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("Distance2",
+                   "Beginning of the third distance field. Default is 200m.",
+                   DoubleValue (200.0),
+                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_distance2),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("m0",
+                   "m0 for distances smaller than Distance1. Default is 1.5.",
+                   DoubleValue (1.5),
+                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m0),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("m1",
+                   "m1 for distances smaller than Distance2. Default is 0.75.",
+                   DoubleValue (0.75),
+                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m1),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("m2",
+                   "m2 for distances greater than Distance2. Default is 0.75.",
+                   DoubleValue (0.75),
+                   MakeDoubleAccessor (&NakagamiPropagationLossModel::m_m2),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+                   
+}
+
+NakagamiPropagationLossModel::NakagamiPropagationLossModel ()
+{}
+
+double 
+NakagamiPropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                             Ptr<MobilityModel> a,
+                                             Ptr<MobilityModel> b) const
+{
+  // select m parameter
+
+  double distance = a->GetDistanceFrom (b);
+  NS_ASSERT(distance >= 0);
+
+  double m;
+  if (distance < m_distance1)
+    {
+      m = m_m0;
+    }
+  else if (distance < m_distance2)
+    {
+      m = m_m1;
+    }
+  else
+    {
+      m = m_m2;
+    }
+  
+  // the current power unit is dBm, but Watt is put into the Nakagami /
+  // Rayleigh distribution.
+  double powerW = pow(10, (txPowerDbm - 30) / 10);
+
+  double resultPowerW;
+
+  // switch between Erlang- and Gamma distributions: this is only for
+  // speed. (Gamma is equal to Erlang for any positive integer m.)
+  unsigned int int_m = static_cast<unsigned int>(floor(m));
+
+  if (int_m == m)
+    {
+      resultPowerW = m_erlangRandomVariable.GetValue(int_m, powerW / m);
+    }
+  else
+    {
+      resultPowerW = m_gammaRandomVariable.GetValue(m, powerW / m);
+    }
+
+  double resultPowerDbm = 10 * log10(resultPowerW) + 30;
+
+  NS_LOG_DEBUG ("Nakagami distance=" << distance << "m, " <<
+                "power=" << powerW <<"W, " <<
+                "resultPower=" << resultPowerW << "W=" << resultPowerDbm << "dBm");
+
+  return resultPowerDbm;
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (FixedRssLossModel);
+
+TypeId 
+FixedRssLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::FixedRssLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<FixedRssLossModel> ()
+    .AddAttribute ("Rss", "The fixed receiver Rss.",
+                   DoubleValue (-150.0),
+                   MakeDoubleAccessor (&FixedRssLossModel::m_rss),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}
+FixedRssLossModel::FixedRssLossModel ()
+  : PropagationLossModel ()
+{}
+
+FixedRssLossModel::~FixedRssLossModel ()
+{}
+
+void 
+FixedRssLossModel::SetRss (double rss)
+{
+  m_rss = rss;
+}
+
+double 
+FixedRssLossModel::DoCalcRxPower (double txPowerDbm,
+                                           Ptr<MobilityModel> a,
+                                           Ptr<MobilityModel> b) const
+{
+  return m_rss;
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (MatrixPropagationLossModel);
+
+TypeId 
+MatrixPropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MatrixPropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<MatrixPropagationLossModel> ()
+    .AddAttribute ("DefaultLoss", "The default value for propagation loss, dB.",
+                   DoubleValue (std::numeric_limits<double>::max ()),
+                   MakeDoubleAccessor (&MatrixPropagationLossModel::m_default),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}
+
+MatrixPropagationLossModel::MatrixPropagationLossModel ()
+  : PropagationLossModel (), m_default (std::numeric_limits<double>::max ())
+{
+}
+
+MatrixPropagationLossModel::~MatrixPropagationLossModel ()
+{
+}
+
+void 
+MatrixPropagationLossModel::SetDefaultLoss (double loss)
+{
+  m_default = loss;
+}
+
+void
+MatrixPropagationLossModel::SetLoss (Ptr<Object> a, Ptr<Object> b, double loss, bool symmetric)
+{
+  Ptr<MobilityModel> ma = a->GetObject<MobilityModel> ();
+  Ptr<MobilityModel> mb = b->GetObject<MobilityModel> ();
+  NS_ASSERT (ma != 0 && mb != 0);
+
+  MobilityPair p = std::make_pair(ma, mb);
+  std::map<MobilityPair, double>::iterator i = m_loss.find (p);
+  
+  if (i == m_loss.end ())
+    {
+      m_loss.insert (std::make_pair (p, loss));
+    }
+  else
+    {
+      i->second = loss;
+    }
+
+  if (symmetric)
+    {
+      SetLoss (b, a, loss, false);
+    }
+}
+
+double 
+MatrixPropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                           Ptr<MobilityModel> a,
+                                           Ptr<MobilityModel> b) const
+{
+  std::map<MobilityPair, double>::const_iterator i = m_loss.find (std::make_pair (a, b));
+  
+  if (i != m_loss.end ())
+    {
+      return txPowerDbm - i->second;
+    }
+  else
+    {
+      return txPowerDbm - m_default;
+    }
+}
+
+// ------------------------------------------------------------------------- //
+
+NS_OBJECT_ENSURE_REGISTERED (RangePropagationLossModel);
+
+TypeId
+RangePropagationLossModel::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RangePropagationLossModel")
+    .SetParent<PropagationLossModel> ()
+    .AddConstructor<RangePropagationLossModel> ()
+    .AddAttribute ("MaxRange",
+                   "Maximum Transmission Range (meters)",
+                   DoubleValue (250),
+                   MakeDoubleAccessor (&RangePropagationLossModel::m_range),
+                   MakeDoubleChecker<double> ())
+  ;
+  return tid;
+}
+
+RangePropagationLossModel::RangePropagationLossModel ()
+{
+}
+
+double
+RangePropagationLossModel::DoCalcRxPower (double txPowerDbm,
+                                          Ptr<MobilityModel> a,
+                                          Ptr<MobilityModel> b) const
+{
+  double distance = a->GetDistanceFrom (b);
+  if (distance <= m_range)
+    {
+      return txPowerDbm;
+    }
+  else
+    {
+      return -1000;
+    }
+}
+
+// ------------------------------------------------------------------------- //
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/model/propagation-loss-model.h	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,547 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,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>
+ * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
+ * Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS
+ * Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model
+ *                Pavel Boyko <boyko@iitp.ru> for matrix
+ */
+
+#ifndef PROPAGATION_LOSS_MODEL_H
+#define PROPAGATION_LOSS_MODEL_H
+
+#include "ns3/object.h"
+#include "ns3/random-variable.h"
+#include <map>
+
+namespace ns3 {
+
+class MobilityModel;
+
+/**
+ * \brief Modelize the propagation loss through a transmission medium
+ *
+ * Calculate the receive power (dbm) from a transmit power (dbm)
+ * and a mobility model for the source and destination positions.
+ */
+class PropagationLossModel : public Object
+{
+public:
+  static TypeId GetTypeId (void);
+
+  PropagationLossModel ();
+  virtual ~PropagationLossModel ();
+
+  /**
+   * \brief Enables a chain of loss models to act on the signal
+   * \param The next PropagationLossModel to add to the chain
+   *
+   * This method of chaining propagation loss models only works commutatively
+   * if the propagation loss of all models in the chain are independent
+   * of transmit power.
+   */
+  void SetNext (Ptr<PropagationLossModel> next);
+
+  /**
+   * \param txPowerDbm current transmission power (in dBm)
+   * \param a the mobility model of the source
+   * \param b the mobility model of the destination
+   * \returns the reception power after adding/multiplying propagation loss (in dBm)
+   */
+  double CalcRxPower (double txPowerDbm,
+                      Ptr<MobilityModel> a,
+                      Ptr<MobilityModel> b) const;
+private:
+  PropagationLossModel (const PropagationLossModel &o);
+  PropagationLossModel &operator = (const PropagationLossModel &o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const = 0;
+
+  Ptr<PropagationLossModel> m_next;
+};
+
+/**
+ * \brief The propagation loss follows a random distribution.
+ */ 
+class RandomPropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  RandomPropagationLossModel ();
+  virtual ~RandomPropagationLossModel ();
+
+private:
+  RandomPropagationLossModel (const RandomPropagationLossModel &o);
+  RandomPropagationLossModel & operator = (const RandomPropagationLossModel &o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+  RandomVariable m_variable;
+};
+
+/**
+ * \brief a Friis propagation loss model
+ *
+ * The Friis propagation loss model was first described in
+ * "A Note on a Simple Transmission Formula", by 
+ * "Harald T. Friis".
+ * 
+ * The original equation was described as:
+ *  \f$ \frac{P_r}{P_t} = \frac{A_r A_t}{d^2\lambda^2} \f$
+ *  with the following equation for the case of an
+ *  isotropic antenna with no heat loss:
+ *  \f$ A_{isotr.} = \frac{\lambda^2}{4\pi} \f$
+ *
+ * The final equation becomes:
+ * \f$ \frac{P_r}{P_t} = \frac{\lambda^2}{(4 \pi d)^2} \f$
+ *
+ * Modern extensions to this original equation are:
+ * \f$ P_r = \frac{P_t G_t G_r \lambda^2}{(4 \pi d)^2 L}\f$
+ *
+ * With:
+ *  - \f$ P_r \f$ : reception power (W)
+ *  - \f$ P_t \f$ : transmission power (W)
+ *  - \f$ G_t \f$ : transmission gain (unit-less)
+ *  - \f$ G_r \f$ : reception gain (unit-less)
+ *  - \f$ \lambda \f$ : wavelength (m)
+ *  - \f$ d \f$ : distance (m)
+ *  - \f$ L \f$ : system loss (unit-less)
+ *
+ *
+ * This model is invalid for small distance values.
+ * The current implementation returns the txpower as the rxpower
+ * for any distance smaller than MinDistance.
+ */
+class FriisPropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  FriisPropagationLossModel ();
+  /**
+   * \param frequency (Hz)
+   * \param speed (m/s)
+   *
+   * Set the main wavelength used in the Friis model 
+   * calculation.
+   */
+  void SetLambda (double frequency, double speed);
+  /**
+   * \param lambda (m) the wavelength
+   *
+   * Set the main wavelength used in the Friis model 
+   * calculation.
+   */
+  void SetLambda (double lambda);
+  /**
+   * \param systemLoss (dimension-less)
+   *
+   * Set the system loss used by the Friis propagation model.
+   */
+  void SetSystemLoss (double systemLoss);
+
+  /**
+   * \param minDistance the minimum distance
+   *
+   * Below this distance, the txpower is returned
+   * unmodified as the rxpower.
+   */
+  void SetMinDistance (double minDistance);
+
+  /**
+   * \returns the minimum distance.
+   */
+  double GetMinDistance (void) const;
+
+  /**
+   * \returns the current wavelength (m)
+   */
+  double GetLambda (void) const;
+  /**
+   * \returns the current system loss (dimension-less)
+   */
+  double GetSystemLoss (void) const;
+
+private:
+  FriisPropagationLossModel (const FriisPropagationLossModel &o);
+  FriisPropagationLossModel & operator = (const FriisPropagationLossModel &o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+  double DbmToW (double dbm) const;
+  double DbmFromW (double w) const;
+
+  static const double PI;
+  double m_lambda;
+  double m_systemLoss;
+  double m_minDistance;
+};
+
+/*
+ *
+ * \brief a Two-Ray Ground propagation loss model ported from NS2
+ *
+ * Two-ray ground reflection model.
+ *
+ * \f$ Pr = \frac{Pt * Gt * Gr * (ht^2 * hr^2)}{d^4 * L} \f$
+ *
+ * The original equation in Rappaport's book assumes L = 1.
+ * To be consistent with the free space equation, L is added here.
+ *
+ * Ht and Hr are set at the respective nodes z coordinate plus a model parameter
+ * set via SetHeightAboveZ.
+ *
+ * The two-ray model does not give a good result for short distances, due to the
+ * oscillation caused by constructive and destructive combination of the two
+ * rays. Instead the Friis free-space model is used for small distances. 
+ *
+ * The crossover distance, below which Friis is used, is calculated as follows:
+ *
+ * \f$ dCross = \frac{(4 * pi * Ht * Hr)}{lambda} \f$
+ */
+
+class TwoRayGroundPropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  TwoRayGroundPropagationLossModel ();
+  /**
+   * \param frequency (Hz)
+   * \param speed (m/s)
+   *
+   * Set the main wavelength used in the TwoRayGround model 
+   * calculation.
+   */
+  void SetLambda (double frequency, double speed);
+  /**
+   * \param lambda (m) the wavelength
+   *
+   * Set the main wavelength used in the TwoRayGround model 
+   * calculation.
+   */
+  void SetLambda (double lambda);
+  /**
+   * \param systemLoss (dimension-less)
+   *
+   * Set the system loss used by the TwoRayGround propagation model.
+   */
+  void SetSystemLoss (double systemLoss);
+  /**
+   * \param minDistance the minimum distance
+   *
+   * Below this distance, the txpower is returned
+   * unmodified as the rxpower.
+   */
+  void SetMinDistance (double minDistance);
+  /**
+   * \returns the minimum distance.
+   */
+  double GetMinDistance (void) const;
+  /**
+   * \returns the current wavelength (m)
+   */
+  double GetLambda (void) const;
+  /**
+   * \returns the current system loss (dimension-less)
+   */
+  double GetSystemLoss (void) const;
+  /**
+   * \param heightAboveZ the model antenna height above the node's Z coordinate
+   *
+   * Set the model antenna height above the node's Z coordinate
+   */
+  void SetHeightAboveZ (double heightAboveZ);
+
+private:
+  TwoRayGroundPropagationLossModel (const TwoRayGroundPropagationLossModel &o);
+  TwoRayGroundPropagationLossModel & operator = (const TwoRayGroundPropagationLossModel &o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+  double DbmToW (double dbm) const;
+  double DbmFromW (double w) const;
+
+  static const double PI;
+  double m_lambda;
+  double m_systemLoss;
+  double m_minDistance;
+  double m_heightAboveZ;
+};
+
+/**
+ * \brief a log distance propagation model.
+ *
+ * This model calculates the reception power with a so-called
+ * log-distance propagation model:
+ * \f$ L = L_0 + 10 n log_{10}(\frac{d}{d_0})\f$
+ *
+ * where:
+ *  - \f$ n \f$ : the path loss distance exponent
+ *  - \f$ d_0 \f$ : reference distance (m)
+ *  - \f$ L_0 \f$ : path loss at reference distance (dB)
+ *  - \f$ d \f$ : distance (m)
+ *  - \f$ L \f$ : path loss (dB)
+ *
+ * When the path loss is requested at a distance smaller than
+ * the reference distance, the tx power is returned.
+ *
+ */
+class LogDistancePropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  LogDistancePropagationLossModel ();
+
+  /**
+   * \param n the path loss exponent.
+   * Set the path loss exponent.
+   */
+  void SetPathLossExponent (double n);
+  /** 
+   * \returns the current path loss exponent.
+   */
+  double GetPathLossExponent (void) const;
+
+  void SetReference (double referenceDistance, double referenceLoss);
+  
+private:
+  LogDistancePropagationLossModel (const LogDistancePropagationLossModel &o);
+  LogDistancePropagationLossModel & operator = (const LogDistancePropagationLossModel &o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+  static Ptr<PropagationLossModel> CreateDefaultReference (void);
+
+  double m_exponent;
+  double m_referenceDistance;
+  double m_referenceLoss;
+};
+
+/**
+ * \brief A log distance path loss propagation model with three distance
+ * fields. This model is the same as ns3::LogDistancePropagationLossModel
+ * except that it has three distance fields: near, middle and far with
+ * different exponents.
+ *
+ * Within each field the reception power is calculated using the log-distance
+ * propagation equation:
+ * \f[ L = L_0 + 10 \cdot n_0 log_{10}(\frac{d}{d_0})\f]
+ * Each field begins where the previous ends and all together form a continuous function.
+ *
+ * There are three valid distance fields: near, middle, far. Actually four: the
+ * first from 0 to the reference distance is invalid and returns txPowerDbm.
+ *
+ * \f[ \underbrace{0 \cdots\cdots}_{=0} \underbrace{d_0 \cdots\cdots}_{n_0} \underbrace{d_1 \cdots\cdots}_{n_1} \underbrace{d_2 \cdots\cdots}_{n_2} \infty \f]
+ *
+ * Complete formula for the path loss in dB:
+ *
+ * \f[\displaystyle L =
+\begin{cases}
+0 & d < d_0 \\
+L_0 + 10 \cdot n_0 \log_{10}(\frac{d}{d_0}) & d_0 \leq d < d_1 \\
+L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d}{d_1}) & d_1 \leq d < d_2 \\
+L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d_2}{d_1}) + 10 \cdot n_2 \log_{10}(\frac{d}{d_2})& d_2 \leq d
+\end{cases}\f]
+ *
+ * where:
+ *  - \f$ L \f$ : resulting path loss (dB)
+ *  - \f$ d \f$ : distance (m)
+ *  - \f$ d_0, d_1, d_2 \f$ : three distance fields (m)
+ *  - \f$ n_0, n_1, n_2 \f$ : path loss distance exponent for each field (unitless)
+ *  - \f$ L_0 \f$ : path loss at reference distance (dB)
+ *
+ * When the path loss is requested at a distance smaller than the reference
+ * distance \f$ d_0 \f$, the tx power (with no path loss) is returned. The
+ * reference distance defaults to 1m and reference loss defaults to
+ * ns3::FriisPropagationLossModel with 5.15 GHz and is thus \f$ L_0 \f$ = 46.67 dB.
+ */
+
+class ThreeLogDistancePropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  ThreeLogDistancePropagationLossModel ();
+
+  // Parameters are all accessible via attributes.
+
+private:
+  ThreeLogDistancePropagationLossModel (const ThreeLogDistancePropagationLossModel& o);
+  ThreeLogDistancePropagationLossModel& operator= (const ThreeLogDistancePropagationLossModel& o);
+
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+
+  double m_distance0;
+  double m_distance1;
+  double m_distance2;
+
+  double m_exponent0;
+  double m_exponent1;
+  double m_exponent2;
+
+  double m_referenceLoss;
+};
+
+/**
+ * \brief Nakagami-m fast fading propagation loss model.
+ *
+ * The Nakagami-m distribution is applied to the power level. The probability
+ * density function is defined as
+ * \f[ p(x; m, \omega) = \frac{2 m^m}{\Gamma(m) \omega^m} x^{2m - 1} e^{-\frac{m}{\omega} x^2} = 2 x \cdot p_{\text{Gamma}}(x^2, m, \frac{m}{\omega}) \f]
+ * with \f$ m \f$ the fading depth parameter and \f$ \omega \f$ the average received power.
+ *
+ * It is implemented by either a ns3::GammaVariable or a ns3::ErlangVariable
+ * random variable.
+ *
+ * Like in ns3::ThreeLogDistancePropagationLossModel, the m parameter is varied
+ * over three distance fields:
+ * \f[ \underbrace{0 \cdots\cdots}_{m_0} \underbrace{d_1 \cdots\cdots}_{m_1} \underbrace{d_2 \cdots\cdots}_{m_2} \infty \f]
+ *
+ * For m = 1 the Nakagami-m distribution equals the Rayleigh distribution. Thus
+ * this model also implements Rayleigh distribution based fast fading.
+ */
+
+class NakagamiPropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  NakagamiPropagationLossModel ();
+
+  // Parameters are all accessible via attributes.
+
+private:
+  NakagamiPropagationLossModel (const NakagamiPropagationLossModel& o);
+  NakagamiPropagationLossModel& operator= (const NakagamiPropagationLossModel& o);
+
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+
+  double m_distance1;
+  double m_distance2;
+
+  double m_m0;
+  double m_m1;
+  double m_m2;
+
+  ErlangVariable        m_erlangRandomVariable;
+  GammaVariable         m_gammaRandomVariable;
+};
+
+/**
+ * \brief Return a constant received power level independent of the transmit 
+ *  power
+ *
+ * The received power is constant independent of the transmit power.  The user
+ * must set received power level through the Rss attribute or public 
+ * SetRss() method.  Note that if this loss model is chained to other loss
+ * models via SetNext() method, it can only be the first loss model in such
+ * a chain, or else it will disregard the losses computed by loss models
+ * that precede it in the chain. 
+ */ 
+class FixedRssLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+
+  FixedRssLossModel ();
+  virtual ~FixedRssLossModel ();
+  /**
+   * \param rss (dBm) the received signal strength
+   *
+   * Set the received signal strength (RSS) in dBm.
+   */
+  void SetRss (double rss);
+
+private:
+  FixedRssLossModel (const FixedRssLossModel &o);
+  FixedRssLossModel & operator = (const FixedRssLossModel &o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+  double m_rss;
+};
+
+/**
+ * \brief The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions.
+ * 
+ * This is supposed to be used by synthetic tests. Note that by default propagation loss is assumed to be symmetric.
+ */
+class MatrixPropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  
+  MatrixPropagationLossModel ();
+  virtual ~MatrixPropagationLossModel ();
+  
+  /**
+   * \brief Set loss (in dB, positive) between pair of ns-3 objects
+   * (typically, nodes).
+   * 
+   * \param a           Source object
+   * \param b           Destination object
+   * \param loss        a -> b path loss, positive in dB
+   * \param symmetric   If true (default), both a->b and b->a paths will be affected
+   */ 
+  void SetLoss (Ptr<Object> a, Ptr<Object> b, double loss, bool symmetric = true);
+  /// Set default loss (in dB, positive) to be used, infinity if not set
+  void SetDefaultLoss (double);
+  
+private:
+  virtual double DoCalcRxPower (double txPowerDbm,
+                               Ptr<MobilityModel> a,
+                               Ptr<MobilityModel> b) const;
+private:
+  /// default loss
+  double m_default; 
+  
+  typedef std::pair< Ptr<MobilityModel>, Ptr<MobilityModel> > MobilityPair; 
+  /// Fixed loss between pair of nodes
+  std::map<MobilityPair, double> m_loss;
+};
+
+/**
+ * \brief The propagation loss depends only on the distance (range) between transmitter and receiver.
+ *
+ * The single MaxRange attribute (units of meters) determines path loss.
+ * Receivers at or within MaxRange meters receive the transmission at the
+ * transmit power level. Receivers beyond MaxRange receive at power
+ * -1000 dBm (effectively zero).
+*/
+class RangePropagationLossModel : public PropagationLossModel
+{
+public:
+  static TypeId GetTypeId (void);
+  RangePropagationLossModel ();
+private:
+  RangePropagationLossModel (const RangePropagationLossModel& o);
+  RangePropagationLossModel& operator= (const RangePropagationLossModel& o);
+  virtual double DoCalcRxPower (double txPowerDbm,
+                                Ptr<MobilityModel> a,
+                                Ptr<MobilityModel> b) const;
+private:
+  double m_range;
+};
+
+} // namespace ns3
+
+#endif /* PROPAGATION_LOSS_MODEL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/test/propagation-loss-model-test-suite.cc	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,456 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 The Boeing Company
+ *
+ * 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
+ */
+
+#include "ns3/log.h"
+#include "ns3/abort.h"
+#include "ns3/test.h"
+#include "ns3/config.h"
+#include "ns3/double.h"
+#include "ns3/propagation-loss-model.h"
+#include "ns3/constant-position-mobility-model.h"
+#include "ns3/simulator.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("PropagationLossModelsTest");
+
+// ===========================================================================
+// This is a simple test to validate propagation loss models of ns-3 wifi.
+// See the chapter in the ns-3 testing and validation guide for more detail
+// ===========================================================================
+//
+class FriisPropagationLossModelTestCase : public TestCase
+{
+public:
+  FriisPropagationLossModelTestCase ();
+  virtual ~FriisPropagationLossModelTestCase ();
+
+private:
+  virtual void DoRun (void);
+
+  typedef struct {
+    Vector m_position;
+    double m_pt;  // dBm
+    double m_pr;  // W
+    double m_tolerance;
+  } TestVector;
+
+  TestVectors<TestVector> m_testVectors;
+};
+
+FriisPropagationLossModelTestCase::FriisPropagationLossModelTestCase ()
+  : TestCase ("Check to see that the ns-3 Friis propagation loss model provides correct received power"), m_testVectors ()
+{
+}
+
+FriisPropagationLossModelTestCase::~FriisPropagationLossModelTestCase ()
+{
+}
+
+void
+FriisPropagationLossModelTestCase::DoRun (void)
+{
+  // The ns-3 testing manual gives more background on the values selected
+  // for this test.  First, set a few defaults. 
+
+  // wavelength at 2.4 GHz is 0.125m
+  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
+  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
+
+  // Select a reference transmit power
+  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
+  double txPowerW = 0.05035702;
+  double txPowerdBm = 10 * log10 (txPowerW) + 30;
+
+  //
+  // We want to test the propagation loss model calculations at a few chosen 
+  // distances and compare the results to those we have manually calculated
+  // according to the model documentation.  The model reference specifies, 
+  // for instance, that the received power at 100m according to the provided
+  // input power will be 4.98265e-10 W.  Since this value specifies the power
+  // to 1e-15 significance, we test the ns-3 calculated value for agreement 
+  // within 5e-16.
+  //
+  TestVector testVector;
+
+  testVector.m_position = Vector (100, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 4.98265e-10;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+
+  testVector.m_position = Vector (500, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 1.99306e-11;
+  testVector.m_tolerance = 5e-17;
+  m_testVectors.Add (testVector);
+
+  testVector.m_position = Vector (1000, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 4.98265e-12;
+  testVector.m_tolerance = 5e-18;
+  m_testVectors.Add (testVector);
+
+  testVector.m_position = Vector (2000, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 1.24566e-12;
+  testVector.m_tolerance = 5e-18;
+  m_testVectors.Add (testVector);
+
+  // Now, check that the received power values are expected
+
+  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
+  a->SetPosition (Vector (0,0,0));
+  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
+
+  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> (); 
+  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
+    {
+      testVector = m_testVectors.Get (i);
+      b->SetPosition (testVector.m_position);
+      double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
+      double resultW =   pow (10.0, resultdBm/10.0)/1000;
+      NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
+    }
+}
+
+// Added for Two-Ray Ground Model - tomhewer@mac.com
+
+class TwoRayGroundPropagationLossModelTestCase : public TestCase
+{
+public:
+  TwoRayGroundPropagationLossModelTestCase ();
+  virtual ~TwoRayGroundPropagationLossModelTestCase ();
+  
+private:
+  virtual void DoRun (void);
+  
+  typedef struct
+  {
+    Vector m_position;
+    double m_pt;  // dBm
+    double m_pr;  // W
+    double m_tolerance;
+  } TestVector;
+  
+  TestVectors<TestVector> m_testVectors;
+};
+
+TwoRayGroundPropagationLossModelTestCase::TwoRayGroundPropagationLossModelTestCase ()
+: TestCase ("Check to see that the ns-3 TwoRayGround propagation loss model provides correct received power"),
+m_testVectors ()
+{
+}
+
+TwoRayGroundPropagationLossModelTestCase::~TwoRayGroundPropagationLossModelTestCase ()
+{
+}
+
+void
+TwoRayGroundPropagationLossModelTestCase::DoRun (void)
+{
+  // wavelength at 2.4 GHz is 0.125m
+  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
+  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
+  
+  // set antenna height to 1.5m above z coordinate
+  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
+  
+  // Select a reference transmit power of 17.0206 dBm
+  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
+  double txPowerW = 0.05035702;
+  double txPowerdBm = 10 * log10 (txPowerW) + 30;
+  
+  //
+  // As with the Friis tests above, we want to test the propagation loss 
+  // model calculations at a few chosen distances and compare the results 
+  // to those we can manually calculate. Let us test the ns-3 calculated 
+  // value for agreement to be within 5e-16, as above.
+  //
+  TestVector testVector;
+  
+  // Below the Crossover distance use Friis so this test should be the same as that above
+  // Crossover = (4 * PI * TxAntennaHeight * RxAntennaHeight) / Lamdba
+  // Crossover = (4 * PI * 1.5 * 1.5) / 0.125 = 226.1946m
+  
+  testVector.m_position = Vector (100, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 4.98265e-10;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  // These values are above the crossover distance and therefore use the Two Ray calculation
+  
+  testVector.m_position = Vector (500, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 4.07891862e-12;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  testVector.m_position = Vector (1000, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 2.5493241375e-13;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  testVector.m_position = Vector (2000, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 1.593327585938e-14;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  // Repeat the tests for non-zero z coordinates
+  
+  // Pr = (0.05035702 * (1.5*1.5) * (2.5*2.5)) / (500*500*500*500) = 1.13303295e-11
+  // dCross = (4 * pi * 1.5 * 2.5) / 0.125 = 376.99m
+  testVector.m_position = Vector (500, 0, 1);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 1.13303295e-11;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  // Pr = (0.05035702 * (1.5*1.5) * (5.5*5.5)) / (1000*1000*1000*1000) = 3.42742467375e-12
+  // dCross = (4 * pi * 1.5 * 5.5) / 0.125 = 829.38m
+  testVector.m_position = Vector (1000, 0, 4);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 3.42742467375e-12;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  // Pr = (0.05035702 * (1.5*1.5) * (11.5*11.5)) / (2000*2000*2000*2000) = 9.36522547734e-13
+  // dCross = (4 * pi * 1.5 * 11.5) / 0.125 = 1734.15m
+  testVector.m_position = Vector (2000, 0, 10);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 9.36522547734e-13;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+  
+  
+  // Now, check that the received power values are expected
+  
+  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
+  a->SetPosition (Vector (0,0,0));
+  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
+  
+  Ptr<TwoRayGroundPropagationLossModel> lossModel = CreateObject<TwoRayGroundPropagationLossModel> (); 
+  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
+  {
+    testVector = m_testVectors.Get (i);
+    b->SetPosition (testVector.m_position);
+    double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
+    double resultW =   pow (10.0, resultdBm / 10.0) / 1000;
+    NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
+  }
+}
+
+
+class LogDistancePropagationLossModelTestCase : public TestCase
+{
+public:
+  LogDistancePropagationLossModelTestCase ();
+  virtual ~LogDistancePropagationLossModelTestCase ();
+
+private:
+  virtual void DoRun (void);
+
+  typedef struct {
+    Vector m_position;
+    double m_pt;  // dBm
+    double m_pr;  // W
+    double m_tolerance;
+  } TestVector;
+
+  TestVectors<TestVector> m_testVectors;
+};
+
+LogDistancePropagationLossModelTestCase::LogDistancePropagationLossModelTestCase ()
+  : TestCase ("Check to see that the ns-3 Log Distance propagation loss model provides correct received power"), m_testVectors ()
+{
+}
+
+LogDistancePropagationLossModelTestCase::~LogDistancePropagationLossModelTestCase ()
+{
+}
+
+void
+LogDistancePropagationLossModelTestCase::DoRun (void)
+{
+  // reference loss at 2.4 GHz is 40.045997
+  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
+  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
+
+  // Select a reference transmit power
+  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
+  double txPowerW = 0.05035702;
+  double txPowerdBm = 10 * log10 (txPowerW) + 30;
+
+  //
+  // We want to test the propagation loss model calculations at a few chosen 
+  // distances and compare the results to those we have manually calculated
+  // according to the model documentation.  The following "TestVector" objects
+  // will drive the test.
+  //
+  TestVector testVector;
+
+  testVector.m_position = Vector (10, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 4.98265e-9;
+  testVector.m_tolerance = 5e-15; 
+  m_testVectors.Add (testVector);
+
+  testVector.m_position = Vector (20, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 6.22831e-10;
+  testVector.m_tolerance = 5e-16;
+  m_testVectors.Add (testVector);
+
+  testVector.m_position = Vector (40, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 7.78539e-11;
+  testVector.m_tolerance = 5e-17;
+  m_testVectors.Add (testVector);
+
+  testVector.m_position = Vector (80, 0, 0);
+  testVector.m_pt = txPowerdBm;
+  testVector.m_pr = 9.73173e-12;
+  testVector.m_tolerance = 5e-17;
+  m_testVectors.Add (testVector);
+
+  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
+  a->SetPosition (Vector (0,0,0));
+  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
+
+  Ptr<LogDistancePropagationLossModel> lossModel = CreateObject<LogDistancePropagationLossModel> (); 
+  for (uint32_t i = 0; i < m_testVectors.GetN (); ++i)
+    {
+      testVector = m_testVectors.Get (i);
+      b->SetPosition (testVector.m_position);
+      double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b);
+      double resultW =   pow (10.0, resultdBm/10.0)/1000;
+      NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power");
+    }
+}
+
+class MatrixPropagationLossModelTestCase : public TestCase
+{
+public:
+  MatrixPropagationLossModelTestCase ();
+  virtual ~MatrixPropagationLossModelTestCase ();
+
+private:
+  virtual void DoRun (void);
+};
+
+MatrixPropagationLossModelTestCase::MatrixPropagationLossModelTestCase ()
+  : TestCase ("Test MatrixPropagationLossModel")
+{
+}
+
+MatrixPropagationLossModelTestCase::~MatrixPropagationLossModelTestCase ()
+{
+}
+
+void
+MatrixPropagationLossModelTestCase::DoRun (void)
+{
+  Ptr<Object> n[3];
+  Ptr<MobilityModel> m[3];
+  for (int i = 0; i < 3; ++i)
+    {
+      n[i] = CreateObject<Object> ();
+      m[i] = CreateObject<ConstantPositionMobilityModel> ();
+      n[i]->AggregateObject (m[i]);
+    }
+  
+  MatrixPropagationLossModel loss;
+  // no loss by default
+  loss.SetDefaultLoss (0);       
+  // -10 dB for 0 -> 1 and 1 -> 0
+  loss.SetLoss (n[0], n[1], 10); 
+  // -30 dB from 0 to 2 and -100 dB from 2 to 0
+  loss.SetLoss (n[0], n[2], 30, /*symmetric = */false); 
+  loss.SetLoss (n[2], n[0], 100, /*symmetric = */false); 
+  // default from 1 to 2
+  
+  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[1]), -10, "Loss 0 -> 1 incorrect");
+  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[0]), -10, "Loss 1 -> 0 incorrect");
+  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[2]), -30, "Loss 0 -> 2 incorrect");
+  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[0]), -100, "Loss 2 -> 0 incorrect");
+  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[2]), 0, "Loss 1 -> 2 incorrect");
+  NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[1]), 0, "Loss 2 -> 1 incorrect");
+
+  Simulator::Destroy ();
+}
+
+class RangePropagationLossModelTestCase : public TestCase
+{
+public:
+  RangePropagationLossModelTestCase ();
+  virtual ~RangePropagationLossModelTestCase ();
+
+private:
+  virtual void DoRun (void);
+};
+
+RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
+  : TestCase ("Test RangePropagationLossModel")
+{
+}
+
+RangePropagationLossModelTestCase::~RangePropagationLossModelTestCase ()
+{
+}
+
+void
+RangePropagationLossModelTestCase::DoRun (void)
+{
+  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
+  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
+  a->SetPosition (Vector (0,0,0));
+  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
+  b->SetPosition (Vector (127.1,0,0));  // within range
+
+  Ptr<RangePropagationLossModel> lossModel = CreateObject<RangePropagationLossModel> (); 
+
+  double txPwrdBm = -80.0;
+  double tolerance = 1e-6;
+  double resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
+  NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, txPwrdBm, tolerance, "Got unexpected rcv power");
+  b->SetPosition (Vector (127.25,0,0));  // beyond range
+  resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
+  NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, -1000.0, tolerance, "Got unexpected rcv power");
+  Simulator::Destroy ();
+}
+
+class PropagationLossModelsTestSuite : public TestSuite
+{
+public:
+  PropagationLossModelsTestSuite ();
+};
+
+PropagationLossModelsTestSuite::PropagationLossModelsTestSuite ()
+  : TestSuite ("propagation-loss-model", UNIT)
+{
+  AddTestCase (new FriisPropagationLossModelTestCase);
+  AddTestCase (new TwoRayGroundPropagationLossModelTestCase);
+  AddTestCase (new LogDistancePropagationLossModelTestCase);
+  AddTestCase (new MatrixPropagationLossModelTestCase);
+  AddTestCase (new RangePropagationLossModelTestCase);
+}
+
+static PropagationLossModelsTestSuite propagationLossModelsTestSuite;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/propagation/wscript	Fri Jan 28 14:11:21 2011 -0800
@@ -0,0 +1,22 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    module = bld.create_ns3_module('propagation', ['node', 'mobility'])
+    module.includes = '.'
+    module.source = [
+        'model/propagation-delay-model.cc',
+        'model/propagation-loss-model.cc',
+        'model/jakes-propagation-loss-model.cc',
+        'model/cost231-propagation-loss-model.cc',
+        'test/propagation-loss-model-test-suite.cc',
+        ]
+
+    headers = bld.new_task_gen('ns3header')
+    headers.module = 'propagation'
+    headers.source = [
+        'model/propagation-delay-model.h',
+        'model/propagation-loss-model.h',
+        'model/jakes-propagation-loss-model.h',
+        'model/cost231-propagation-loss-model.h',
+        ]
+
--- a/src/wscript	Fri Jan 28 12:55:16 2011 -0800
+++ b/src/wscript	Fri Jan 28 14:11:21 2011 -0800
@@ -24,6 +24,7 @@
     'contrib',
     'node',
     'internet-stack',
+    'propagation',
     'devices/point-to-point',
     'devices/csma',
     'devices/emu',