add composite capability to PropagationLossModel base class.

This commit is contained in:
Mathieu Lacage
2008-10-28 13:17:17 +01:00
parent 40dc133bc7
commit 8246114a8d
8 changed files with 77 additions and 214 deletions

View File

@@ -73,8 +73,6 @@ def register_types(module):
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 @@ def register_methods(root_module):
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 @@ def register_Ns3PropagationDelayModel_methods(root_module, cls):
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 @@ def register_Ns3RandomPropagationLossModel_methods(root_module, cls):
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 @@ def register_Ns3ArfWifiManager_methods(root_module, cls):
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 @@ def register_Ns3FriisPropagationLossModel_methods(root_module, cls):
'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 @@ def register_Ns3JakesPropagationLossModel_methods(root_module, cls):
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 @@ def register_Ns3JakesPropagationLossModel_methods(root_module, cls):
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 @@ def register_Ns3LogDistancePropagationLossModel_methods(root_module, cls):
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):

View File

@@ -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

View File

@@ -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 */

View File

@@ -33,7 +33,8 @@ namespace ns3 {
class JakesPropagationLossModel::PathCoefficients {
class JakesPropagationLossModel::PathCoefficients
{
public:
PathCoefficients (Ptr<const JakesPropagationLossModel> jakes,
Ptr<MobilityModel> receiver,
@@ -198,7 +199,7 @@ JakesPropagationLossModel::SetNOscillators (uint8_t nOscillators)
}
double
JakesPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
JakesPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
PathsList::iterator i = m_paths.end ();

View File

@@ -83,8 +83,6 @@ public:
JakesPropagationLossModel ();
virtual ~JakesPropagationLossModel ();
virtual double GetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const;
/**
* \param nRays Number of rays per path
*
@@ -99,27 +97,29 @@ public:
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;

View File

@@ -43,10 +43,26 @@ PropagationLossModel::GetTypeId (void)
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 @@ RandomPropagationLossModel::~RandomPropagationLossModel ()
{}
double
RandomPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
RandomPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
double rxc = -m_variable.GetValue ();
@@ -158,7 +174,7 @@ FriisPropagationLossModel::DbmFromW (double w) const
double
FriisPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
FriisPropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
/*
@@ -255,7 +271,7 @@ LogDistancePropagationLossModel::GetPathLossExponent (void) const
}
double
LogDistancePropagationLossModel::GetLoss (Ptr<MobilityModel> a,
LogDistancePropagationLossModel::DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
double distance = a->GetDistanceFrom (b);

View File

@@ -38,14 +38,25 @@ class PropagationLossModel : public Object
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 @@ public:
RandomPropagationLossModel ();
virtual ~RandomPropagationLossModel ();
virtual double GetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const;
private:
virtual double DoGetLoss (Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const;
RandomVariable m_variable;
};
@@ -147,9 +158,9 @@ public:
*/
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 @@ public:
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;

View File

@@ -5,7 +5,6 @@ def build(bld):
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 @@ def build(bld):
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',