# HG changeset patch # User Mathieu Lacage # Date 1225196237 -3600 # Node ID 56e477db65b234942257a4307442f635fd6f5346 # Parent 01acc159ffb1f35fa476a88b4371435fd814adb3 add composite capability to PropagationLossModel base class. diff -r 01acc159ffb1 -r 56e477db65b2 bindings/python/ns3_module_wifi.py --- 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 next) [member function] + cls.add_method('SetNext', + 'void', + [param('ns3::Ptr< ns3::PropagationLossModel >', 'next')]) ## propagation-loss-model.h: double ns3::PropagationLossModel::GetLoss(ns3::Ptr a, ns3::Ptr 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 a, ns3::Ptr 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 a, ns3::Ptr b) const [member function] - cls.add_method('GetLoss', + ## propagation-loss-model.h: double ns3::RandomPropagationLossModel::DoGetLoss(ns3::Ptr a, ns3::Ptr 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 a, ns3::Ptr 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 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 a, ns3::Ptr b) const [member function] - cls.add_method('GetLoss', + ## propagation-loss-model.h: double ns3::FriisPropagationLossModel::DoGetLoss(ns3::Ptr a, ns3::Ptr 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 a, ns3::Ptr 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 a, ns3::Ptr 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 a, ns3::Ptr b) const [member function] - cls.add_method('GetLoss', + ## propagation-loss-model.h: double ns3::LogDistancePropagationLossModel::DoGetLoss(ns3::Ptr a, ns3::Ptr 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): diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/composite-propagation-loss-model.cc --- 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 - */ - -#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 - -namespace ns3 { - - - -NS_OBJECT_ENSURE_REGISTERED (CompositePropagationLossModel); - -TypeId -CompositePropagationLossModel::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::CompositePropagationLossModel") - .SetParent () - .AddConstructor () - ; - return tid; -} - -CompositePropagationLossModel::CompositePropagationLossModel () -{ - AddDefaults (); -} - -CompositePropagationLossModel::~CompositePropagationLossModel () -{} - -void -CompositePropagationLossModel::AddDefaults () -{} - -void -CompositePropagationLossModel::AddPropagationLossModel (Ptr pl) -{ - m_propagationModels.push_back (pl); -} - -double -CompositePropagationLossModel::GetLoss (Ptr a, - Ptr 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 - diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/composite-propagation-loss-model.h --- 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 - */ -#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 a, - Ptr b) const; - /** - * \param pl the propagation loss model to add - * - * Insert a propagation loss model to the composite. - */ - void AddPropagationLossModel (Ptr pl); -protected: - virtual void AddDefaults (void); -private: - typedef std::vector > PropagationModelList; - PropagationModelList m_propagationModels; -}; - - -} // namespace ns3 - -#endif /* PROPAGATION_COMP_MODEL_H */ - - diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/jakes-propagation-loss-model.cc --- 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 jakes, Ptr receiver, @@ -198,7 +199,7 @@ } double -JakesPropagationLossModel::GetLoss (Ptr a, +JakesPropagationLossModel::DoGetLoss (Ptr a, Ptr b) const { PathsList::iterator i = m_paths.end (); diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/jakes-propagation-loss-model.h --- 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 a, - Ptr 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 a, + Ptr 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 DestinationList; struct PathsSet { Ptr sender; DestinationList receivers; }; typedef std::vector 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; diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/propagation-loss-model.cc --- 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 a, + Ptr 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 a, +RandomPropagationLossModel::DoGetLoss (Ptr a, Ptr b) const { double rxc = -m_variable.GetValue (); @@ -158,7 +174,7 @@ double -FriisPropagationLossModel::GetLoss (Ptr a, +FriisPropagationLossModel::DoGetLoss (Ptr a, Ptr b) const { /* @@ -255,7 +271,7 @@ } double -LogDistancePropagationLossModel::GetLoss (Ptr a, +LogDistancePropagationLossModel::DoGetLoss (Ptr a, Ptr b) const { double distance = a->GetDistanceFrom (b); diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/propagation-loss-model.h --- 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 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 a, - Ptr b) const = 0; + double GetLoss (Ptr a, + Ptr b) const; +private: + PropagationLossModel (const PropagationLossModel &o); + PropagationLossModel &operator = (const PropagationLossModel &o); + virtual double DoGetLoss (Ptr a, + Ptr b) const = 0; + + Ptr m_next; }; /** @@ -59,9 +70,9 @@ RandomPropagationLossModel (); virtual ~RandomPropagationLossModel (); - virtual double GetLoss (Ptr a, +private: + virtual double DoGetLoss (Ptr a, Ptr b) const; -private: RandomVariable m_variable; }; @@ -147,9 +158,9 @@ */ double GetSystemLoss (void) const; - virtual double GetLoss (Ptr a, - Ptr b) const; private: + virtual double DoGetLoss (Ptr a, + Ptr b) const; double DbmToW (double dbm) const; double DbmFromW (double w) const; @@ -200,9 +211,9 @@ void SetReferenceDistance (double referenceDistance); - virtual double GetLoss (Ptr a, - Ptr b) const; private: + virtual double DoGetLoss (Ptr a, + Ptr b) const; static Ptr CreateDefaultReference (void); double m_exponent; diff -r 01acc159ffb1 -r 56e477db65b2 src/devices/wifi/wscript --- 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',