Add new constant spectrum propagation loss model

This commit is contained in:
mrequena
2011-05-06 15:37:28 +02:00
parent a431d95f66
commit 30f13ff284
3 changed files with 135 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
*
* 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: Manuel Requena <manuel.requena@cttc.es>
*/
#include "ns3/log.h"
#include "ns3/constant-spectrum-propagation-loss.h"
#include "ns3/double.h"
NS_LOG_COMPONENT_DEFINE ("ConstantSpectrumPropagationLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (ConstantSpectrumPropagationLossModel);
ConstantSpectrumPropagationLossModel::ConstantSpectrumPropagationLossModel ()
{
NS_LOG_FUNCTION (this);
}
ConstantSpectrumPropagationLossModel::~ConstantSpectrumPropagationLossModel ()
{
NS_LOG_FUNCTION (this);
}
TypeId
ConstantSpectrumPropagationLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::ConstantSpectrumPropagationLossModel")
.SetParent<SpectrumPropagationLossModel> ()
.AddConstructor<ConstantSpectrumPropagationLossModel> ()
.AddAttribute ("Loss",
"Path loss (dB) between transmitter and receiver",
DoubleValue (1.0),
MakeDoubleAccessor (&ConstantSpectrumPropagationLossModel::m_loss),
MakeDoubleChecker<double> ())
;
return tid;
}
Ptr<SpectrumValue>
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const
{
NS_LOG_FUNCTION (this);
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
Values::iterator vit = rxPsd->ValuesBegin ();
Bands::const_iterator fit = rxPsd->ConstBandsBegin ();
// NS_LOG_INFO ("Loss = " << m_loss);
while (vit != rxPsd->ValuesEnd ())
{
NS_ASSERT (fit != rxPsd->ConstBandsEnd ());
// NS_LOG_INFO ("Ptx = " << *vit);
*vit /= m_loss; // Prx = Ptx / loss
// NS_LOG_INFO ("Prx = " << *vit);
++vit;
++fit;
}
return rxPsd;
}
} // namespace ns3

View File

@@ -0,0 +1,48 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
*
* 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: Manuel Requena <manuel.requena@cttc.es>
*/
#ifndef CONSTANT_SPECTRUM_PROPAGATION_LOSS_H
#define CONSTANT_SPECTRUM_PROPAGATION_LOSS_H
#include "ns3/spectrum-propagation-loss-model.h"
namespace ns3 {
class ConstantSpectrumPropagationLossModel : public SpectrumPropagationLossModel
{
public:
ConstantSpectrumPropagationLossModel ();
~ConstantSpectrumPropagationLossModel ();
static TypeId GetTypeId ();
virtual Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const;
private:
double m_loss;
};
} // namespace ns3
#endif /* CONSTANT_SPECTRUM_PROPAGATION_LOSS_MODEL_H */

View File

@@ -10,6 +10,7 @@ def build(bld):
'model/spectrum-type.cc',
'model/spectrum-propagation-loss-model.cc',
'model/friis-spectrum-propagation-loss.cc',
'model/constant-spectrum-propagation-loss.cc',
'model/spectrum-phy.cc',
'model/spectrum-channel.cc',
'model/single-model-spectrum-channel.cc',
@@ -47,6 +48,7 @@ def build(bld):
'model/spectrum-type.h',
'model/spectrum-propagation-loss-model.h',
'model/friis-spectrum-propagation-loss.h',
'model/constant-spectrum-propagation-loss.h',
'model/spectrum-phy.h',
'model/spectrum-channel.h',
'model/single-model-spectrum-channel.h',