add composite capability to PropagationLossModel base class.
--- a/bindings/python/ns3_module_wifi.py Tue Oct 28 11:26:58 2008 +0100
+++ b/bindings/python/ns3_module_wifi.py Tue Oct 28 13:17:17 2008 +0100
@@ -73,8 +73,6 @@
module.add_class('AmrrWifiManager', parent=root_module['ns3::WifiRemoteStationManager'])
## arf-wifi-manager.h: ns3::ArfWifiManager [class]
module.add_class('ArfWifiManager', parent=root_module['ns3::WifiRemoteStationManager'])
- ## composite-propagation-loss-model.h: ns3::CompositePropagationLossModel [class]
- module.add_class('CompositePropagationLossModel', parent=root_module['ns3::PropagationLossModel'])
## constant-rate-wifi-manager.h: ns3::ConstantRateWifiManager [class]
module.add_class('ConstantRateWifiManager', parent=root_module['ns3::WifiRemoteStationManager'])
## propagation-delay-model.h: ns3::ConstantSpeedPropagationDelayModel [class]
@@ -176,7 +174,6 @@
register_Ns3AdhocWifiMac_methods(root_module, root_module['ns3::AdhocWifiMac'])
register_Ns3AmrrWifiManager_methods(root_module, root_module['ns3::AmrrWifiManager'])
register_Ns3ArfWifiManager_methods(root_module, root_module['ns3::ArfWifiManager'])
- register_Ns3CompositePropagationLossModel_methods(root_module, root_module['ns3::CompositePropagationLossModel'])
register_Ns3ConstantRateWifiManager_methods(root_module, root_module['ns3::ConstantRateWifiManager'])
register_Ns3ConstantSpeedPropagationDelayModel_methods(root_module, root_module['ns3::ConstantSpeedPropagationDelayModel'])
register_Ns3FriisPropagationLossModel_methods(root_module, root_module['ns3::FriisPropagationLossModel'])
@@ -1004,20 +1001,27 @@
return
def register_Ns3PropagationLossModel_methods(root_module, cls):
- ## propagation-loss-model.h: ns3::PropagationLossModel::PropagationLossModel(ns3::PropagationLossModel const & arg0) [copy constructor]
- cls.add_constructor([param('ns3::PropagationLossModel const &', 'arg0')])
- ## propagation-loss-model.h: ns3::PropagationLossModel::PropagationLossModel() [constructor]
- cls.add_constructor([])
## propagation-loss-model.h: static ns3::TypeId ns3::PropagationLossModel::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
+ ## propagation-loss-model.h: ns3::PropagationLossModel::PropagationLossModel() [constructor]
+ cls.add_constructor([])
+ ## propagation-loss-model.h: void ns3::PropagationLossModel::SetNext(ns3::Ptr<ns3::PropagationLossModel> next) [member function]
+ cls.add_method('SetNext',
+ 'void',
+ [param('ns3::Ptr< ns3::PropagationLossModel >', 'next')])
## propagation-loss-model.h: double ns3::PropagationLossModel::GetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
cls.add_method('GetLoss',
'double',
[param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
- is_pure_virtual=True, is_const=True, is_virtual=True)
+ is_const=True)
+ ## propagation-loss-model.h: double ns3::PropagationLossModel::DoGetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
+ cls.add_method('DoGetLoss',
+ 'double',
+ [param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
+ is_pure_virtual=True, is_const=True, visibility='private', is_virtual=True)
return
def register_Ns3RandomPropagationDelayModel_methods(root_module, cls):
@@ -1047,11 +1051,11 @@
is_static=True)
## propagation-loss-model.h: ns3::RandomPropagationLossModel::RandomPropagationLossModel() [constructor]
cls.add_constructor([])
- ## propagation-loss-model.h: double ns3::RandomPropagationLossModel::GetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
- cls.add_method('GetLoss',
+ ## propagation-loss-model.h: double ns3::RandomPropagationLossModel::DoGetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
+ cls.add_method('DoGetLoss',
'double',
[param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
- is_const=True, is_virtual=True)
+ is_const=True, visibility='private', is_virtual=True)
return
def register_Ns3RraaWifiRemoteStation_methods(root_module, cls):
@@ -1973,32 +1977,6 @@
visibility='private', is_virtual=True)
return
-def register_Ns3CompositePropagationLossModel_methods(root_module, cls):
- ## composite-propagation-loss-model.h: ns3::CompositePropagationLossModel::CompositePropagationLossModel(ns3::CompositePropagationLossModel const & arg0) [copy constructor]
- cls.add_constructor([param('ns3::CompositePropagationLossModel const &', 'arg0')])
- ## composite-propagation-loss-model.h: static ns3::TypeId ns3::CompositePropagationLossModel::GetTypeId() [member function]
- cls.add_method('GetTypeId',
- 'ns3::TypeId',
- [],
- is_static=True)
- ## composite-propagation-loss-model.h: ns3::CompositePropagationLossModel::CompositePropagationLossModel() [constructor]
- cls.add_constructor([])
- ## composite-propagation-loss-model.h: double ns3::CompositePropagationLossModel::GetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
- cls.add_method('GetLoss',
- 'double',
- [param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
- is_const=True, is_virtual=True)
- ## composite-propagation-loss-model.h: void ns3::CompositePropagationLossModel::AddPropagationLossModel(ns3::Ptr<ns3::PropagationLossModel> pl) [member function]
- cls.add_method('AddPropagationLossModel',
- 'void',
- [param('ns3::Ptr< ns3::PropagationLossModel >', 'pl')])
- ## composite-propagation-loss-model.h: void ns3::CompositePropagationLossModel::AddDefaults() [member function]
- cls.add_method('AddDefaults',
- 'void',
- [],
- visibility='protected', is_virtual=True)
- return
-
def register_Ns3ConstantRateWifiManager_methods(root_module, cls):
## constant-rate-wifi-manager.h: ns3::ConstantRateWifiManager::ConstantRateWifiManager(ns3::ConstantRateWifiManager const & arg0) [copy constructor]
cls.add_constructor([param('ns3::ConstantRateWifiManager const &', 'arg0')])
@@ -2093,11 +2071,11 @@
'double',
[],
is_const=True)
- ## propagation-loss-model.h: double ns3::FriisPropagationLossModel::GetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
- cls.add_method('GetLoss',
+ ## propagation-loss-model.h: double ns3::FriisPropagationLossModel::DoGetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
+ cls.add_method('DoGetLoss',
'double',
[param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
- is_const=True, is_virtual=True)
+ is_const=True, visibility='private', is_virtual=True)
return
def register_Ns3IdealWifiManager_methods(root_module, cls):
@@ -2141,11 +2119,6 @@
is_static=True)
## jakes-propagation-loss-model.h: ns3::JakesPropagationLossModel::JakesPropagationLossModel() [constructor]
cls.add_constructor([])
- ## jakes-propagation-loss-model.h: double ns3::JakesPropagationLossModel::GetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
- cls.add_method('GetLoss',
- 'double',
- [param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
- is_const=True, is_virtual=True)
## jakes-propagation-loss-model.h: void ns3::JakesPropagationLossModel::SetNRays(uint8_t nRays) [member function]
cls.add_method('SetNRays',
'void',
@@ -2154,6 +2127,11 @@
cls.add_method('SetNOscillators',
'void',
[param('uint8_t', 'nOscillators')])
+ ## jakes-propagation-loss-model.h: double ns3::JakesPropagationLossModel::DoGetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
+ cls.add_method('DoGetLoss',
+ 'double',
+ [param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
+ is_const=True, visibility='private', is_virtual=True)
return
def register_Ns3LogDistancePropagationLossModel_methods(root_module, cls):
@@ -2183,11 +2161,11 @@
cls.add_method('SetReferenceDistance',
'void',
[param('double', 'referenceDistance')])
- ## propagation-loss-model.h: double ns3::LogDistancePropagationLossModel::GetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
- cls.add_method('GetLoss',
+ ## propagation-loss-model.h: double ns3::LogDistancePropagationLossModel::DoGetLoss(ns3::Ptr<ns3::MobilityModel> a, ns3::Ptr<ns3::MobilityModel> b) const [member function]
+ cls.add_method('DoGetLoss',
'double',
[param('ns3::Ptr< ns3::MobilityModel >', 'a'), param('ns3::Ptr< ns3::MobilityModel >', 'b')],
- is_const=True, is_virtual=True)
+ is_const=True, visibility='private', is_virtual=True)
return
def register_Ns3NqapWifiMac_methods(root_module, cls):
--- a/src/devices/wifi/composite-propagation-loss-model.cc Tue Oct 28 11:26:58 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +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 "composite-propagation-loss-model.h"
-#include <math.h>
-
-namespace ns3 {
-
-
-
-NS_OBJECT_ENSURE_REGISTERED (CompositePropagationLossModel);
-
-TypeId
-CompositePropagationLossModel::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::CompositePropagationLossModel")
- .SetParent<PropagationLossModel> ()
- .AddConstructor<CompositePropagationLossModel> ()
- ;
- return tid;
-}
-
-CompositePropagationLossModel::CompositePropagationLossModel ()
-{
- AddDefaults ();
-}
-
-CompositePropagationLossModel::~CompositePropagationLossModel ()
-{}
-
-void
-CompositePropagationLossModel::AddDefaults ()
-{}
-
-void
-CompositePropagationLossModel::AddPropagationLossModel (Ptr<PropagationLossModel> pl)
-{
- m_propagationModels.push_back (pl);
-}
-
-double
-CompositePropagationLossModel::GetLoss (Ptr<MobilityModel> a,
- Ptr<MobilityModel> b) const
-{
- double rxc = 0.0;
- for(PropagationModelList::const_iterator i = m_propagationModels.begin ();
- i != m_propagationModels.end ();
- i++) {
- rxc += (*i)->GetLoss (a, b);
- }
-
- return rxc;
-}
-
-} // namespace ns3
-
--- a/src/devices/wifi/composite-propagation-loss-model.h Tue Oct 28 11:26:58 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 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_COMP_MODEL_H
-#define PROPAGATION_COMP_MODEL_H
-
-#include "ns3/nstime.h"
-#include "propagation-loss-model.h"
-
-namespace ns3 {
-
-/**
- * \brief a Composite propagation loss model
- *
- * This model is use to compute the receivng power
- * using more than one propagation loss model (e.g. distance loss
- * and jakes).
- *
- * The received power is computed considering the cascade of the models
- */
-class CompositePropagationLossModel : public PropagationLossModel {
-public:
- static TypeId GetTypeId (void);
- CompositePropagationLossModel ();
- virtual ~CompositePropagationLossModel ();
-
- virtual double GetLoss (Ptr<MobilityModel> a,
- Ptr<MobilityModel> b) const;
- /**
- * \param pl the propagation loss model to add
- *
- * Insert a propagation loss model to the composite.
- */
- void AddPropagationLossModel (Ptr<PropagationLossModel> pl);
-protected:
- virtual void AddDefaults (void);
-private:
- typedef std::vector<Ptr<PropagationLossModel> > PropagationModelList;
- PropagationModelList m_propagationModels;
-};
-
-
-} // namespace ns3
-
-#endif /* PROPAGATION_COMP_MODEL_H */
-
-
--- a/src/devices/wifi/jakes-propagation-loss-model.cc Tue Oct 28 11:26:58 2008 +0100
+++ b/src/devices/wifi/jakes-propagation-loss-model.cc Tue Oct 28 13:17:17 2008 +0100
@@ -33,7 +33,8 @@
-class JakesPropagationLossModel::PathCoefficients {
+class JakesPropagationLossModel::PathCoefficients
+{
public:
PathCoefficients (Ptr<const JakesPropagationLossModel> jakes,
Ptr<MobilityModel> receiver,
@@ -198,7 +199,7 @@
}
double
-JakesPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
+JakesPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
PathsList::iterator i = m_paths.end ();
--- a/src/devices/wifi/jakes-propagation-loss-model.h Tue Oct 28 11:26:58 2008 +0100
+++ b/src/devices/wifi/jakes-propagation-loss-model.h Tue Oct 28 13:17:17 2008 +0100
@@ -83,8 +83,6 @@
JakesPropagationLossModel ();
virtual ~JakesPropagationLossModel ();
- virtual double GetLoss (Ptr<MobilityModel> a,
- Ptr<MobilityModel> b) const;
/**
* \param nRays Number of rays per path
*
@@ -99,27 +97,29 @@
void SetNOscillators (uint8_t nOscillators);
private:
+ void DoConstruct (void);
+ virtual double DoGetLoss (Ptr<MobilityModel> a,
+ Ptr<MobilityModel> b) const;
+
+
class PathCoefficients;
struct ComplexNumber {
double real;
double imag;
};
friend class PathCoefficents;
-
- static const double PI;
- ComplexNumber* m_amp;
- RandomVariable m_variable;
- double m_fd;
-
typedef std::vector<PathCoefficients *> DestinationList;
struct PathsSet {
Ptr<MobilityModel> sender;
DestinationList receivers;
};
typedef std::vector<PathsSet *> PathsList;
+
- void DoConstruct (void);
-
+ 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;
--- a/src/devices/wifi/propagation-loss-model.cc Tue Oct 28 11:26:58 2008 +0100
+++ b/src/devices/wifi/propagation-loss-model.cc Tue Oct 28 13:17:17 2008 +0100
@@ -43,10 +43,26 @@
return tid;
}
+PropagationLossModel::PropagationLossModel ()
+ : m_next (0)
+{}
PropagationLossModel::~PropagationLossModel ()
{}
+double
+PropagationLossModel::GetLoss (Ptr<MobilityModel> a,
+ Ptr<MobilityModel> b) const
+{
+ double self = DoGetLoss (a, b);
+ if (m_next != 0)
+ {
+ self += m_next->GetLoss (a, b);
+ }
+ return self;
+}
+
+
NS_OBJECT_ENSURE_REGISTERED (RandomPropagationLossModel);
TypeId
@@ -69,7 +85,7 @@
{}
double
-RandomPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
+RandomPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
double rxc = -m_variable.GetValue ();
@@ -158,7 +174,7 @@
double
-FriisPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
+FriisPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
/*
@@ -255,7 +271,7 @@
}
double
-LogDistancePropagationLossModel::GetLoss (Ptr<MobilityModel> a,
+LogDistancePropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
double distance = a->GetDistanceFrom (b);
--- a/src/devices/wifi/propagation-loss-model.h Tue Oct 28 11:26:58 2008 +0100
+++ b/src/devices/wifi/propagation-loss-model.h Tue Oct 28 13:17:17 2008 +0100
@@ -38,14 +38,25 @@
public:
static TypeId GetTypeId (void);
+ PropagationLossModel ();
virtual ~PropagationLossModel ();
+
+ void SetNext (Ptr<PropagationLossModel> next);
+
/**
* \param a the mobility model of the source
* \param b the mobility model of the destination
* \returns the attenuation coefficient (dB)
*/
- virtual double GetLoss (Ptr<MobilityModel> a,
- Ptr<MobilityModel> b) const = 0;
+ double GetLoss (Ptr<MobilityModel> a,
+ Ptr<MobilityModel> b) const;
+private:
+ PropagationLossModel (const PropagationLossModel &o);
+ PropagationLossModel &operator = (const PropagationLossModel &o);
+ virtual double DoGetLoss (Ptr<MobilityModel> a,
+ Ptr<MobilityModel> b) const = 0;
+
+ Ptr<PropagationLossModel> m_next;
};
/**
@@ -59,9 +70,9 @@
RandomPropagationLossModel ();
virtual ~RandomPropagationLossModel ();
- virtual double GetLoss (Ptr<MobilityModel> a,
+private:
+ virtual double DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const;
-private:
RandomVariable m_variable;
};
@@ -147,9 +158,9 @@
*/
double GetSystemLoss (void) const;
- virtual double GetLoss (Ptr<MobilityModel> a,
- Ptr<MobilityModel> b) const;
private:
+ virtual double DoGetLoss (Ptr<MobilityModel> a,
+ Ptr<MobilityModel> b) const;
double DbmToW (double dbm) const;
double DbmFromW (double w) const;
@@ -200,9 +211,9 @@
void SetReferenceDistance (double referenceDistance);
- virtual double GetLoss (Ptr<MobilityModel> a,
- Ptr<MobilityModel> b) const;
private:
+ virtual double DoGetLoss (Ptr<MobilityModel> a,
+ Ptr<MobilityModel> b) const;
static Ptr<PropagationLossModel> CreateDefaultReference (void);
double m_exponent;
--- a/src/devices/wifi/wscript Tue Oct 28 11:26:58 2008 +0100
+++ b/src/devices/wifi/wscript Tue Oct 28 13:17:17 2008 +0100
@@ -5,7 +5,6 @@
obj.source = [
'propagation-delay-model.cc',
'propagation-loss-model.cc',
- 'composite-propagation-loss-model.cc',
'jakes-propagation-loss-model.cc',
'wifi-channel.cc',
'wifi-mode.cc',
@@ -50,7 +49,6 @@
headers.source = [
'propagation-delay-model.h',
'propagation-loss-model.h',
- 'composite-propagation-loss-model.h',
'jakes-propagation-loss-model.h',
'wifi-net-device.h',
'wifi-channel.h',