Add class for managing fading based on traces

This commit is contained in:
Marco Miozzo
2011-09-07 12:39:16 +02:00
parent 2fb7094e1a
commit bf6d33abae
5 changed files with 261 additions and 21 deletions

View File

@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
* Author: Marco Miozzo <marco.miozzo@cttc.es>
* remove dependencies from Phy and Mobility models
*/
#include <cmath>
@@ -57,7 +59,7 @@ NS_OBJECT_ENSURE_REGISTERED (JakesFadingLossModel);
JakesFadingLossModel::JakesFadingLossModel ()
: m_nbOfPaths (1, 4),
m_startJakes (1, 2000),
m_startJakes (1, 2500),
m_phy (0)
{
NS_LOG_FUNCTION (this);
@@ -88,7 +90,7 @@ JakesFadingLossModel::SetPhy (Ptr<LtePhy> phy)
NS_LOG_FUNCTION (this);
m_phy = phy;
SetValue ();
//SetValue ();
}
@@ -101,24 +103,14 @@ JakesFadingLossModel::GetPhy (void)
void
JakesFadingLossModel::SetValue (void)
JakesFadingLossModel::SetValue (double speed)
{
NS_LOG_FUNCTION (this);
NS_LOG_FUNCTION (this << speed);
m_multipath.clear ();
int downlinkSubChannels = GetPhy ()->GetDownlinkSubChannels ().size ();
Ptr<MobilityModel> mobility = 0;
// this needs to be fixed, we cannot allow a propagation model to need pointers to all PHYs
// mobility = GetPhy ()->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject<MobilityModel> ();
Vector speedVector = mobility->GetVelocity ();
double speed = sqrt (pow (speedVector.x,2) + pow (speedVector.y,2));
NS_LOG_FUNCTION (this << mobility << speedVector << speed);
/*
* Several 3GPP standards propose a simulation scenario to use duirng the
* LTE performance evaluation. In particular they suggest to consider these
@@ -142,8 +134,6 @@ JakesFadingLossModel::SetValue (void)
speed = 120;
}
NS_LOG_FUNCTION (this << mobility << speedVector << speed);
/*
* Jackes Model.
@@ -308,12 +298,12 @@ JakesFadingLossModel::SetValue (void)
}
double
JakesFadingLossModel::GetValue (int subChannel)
JakesFadingLossModel::GetValue (int subChannel, double speed)
{
NS_LOG_FUNCTION (this);
if (NeedForUpdate ())
{
SetValue ();
SetValue (speed);
SetLastUpdate ();
}

View File

@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Giuseppe Piro <g.piro@poliba.it>
* Author: Marco Miozzo <marco.miozzo@cttc.es>
* remove dependencies from Phy and Mobility models
*/
#ifndef MULTIPATH_LOSS_MODEL_H
@@ -46,15 +48,24 @@ public:
static TypeId GetTypeId (void);
/**
* \brief Set the value of the considered loss model
*/
void SetValue (void);
* \brief Set the value of the considered loss model
* \param speed the relative speed of the two devices
*/
void SetValue (double speed);
/**
* \brief Get the value for a particular sub channel
* \param subChannel the sub channel for which a value is requested
* \return the loss for a particular sub channel
*/
double GetValue (int subChannel);
/**
* \brief Get the value for a particular sub channel and a given speed
* \param subChannel the sub channel for which a value is requested
* \param speed the relative speed of the two devices
* \return the loss for a particular sub channel
*/
double GetValue (int subChannel, double speed);
/**
* \brief Set the physical layer

View File

@@ -0,0 +1,140 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* 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: Giuseppe Piro <g.piro@poliba.it>
* Author: Marco Miozzo <marco.miozzo@cttc.es>
*/
#include "trace-fading-loss-model.h"
#include <ns3/mobility-model.h>
#include <ns3/spectrum-value.h>
#include <ns3/log.h>
NS_LOG_COMPONENT_DEFINE ("TraceFadingLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (TraceFadingLossModel);
TraceFadingLossModel::TraceFadingLossModel ()
{
SetNext (NULL);
}
TraceFadingLossModel::~TraceFadingLossModel ()
{
}
TypeId
TraceFadingLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::TraceFadingLossModel")
.SetParent<SpectrumPropagationLossModel> ()
;
return tid;
}
Ptr<SpectrumValue>
TraceFadingLossModel::DoCalcRxPowerSpectralDensity (
Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const
{
NS_LOG_FUNCTION (this << *txPsd << a << b);
Ptr<JakesFadingLossModel> c = GetFadingChannelRealization (a,b);
Ptr<SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
Values::iterator vit = rxPsd->ValuesBegin ();
Vector aSpeedVector = a->GetVelocity ();
Vector bSpeedVector = b->GetVelocity ();
double speed = sqrt (pow (aSpeedVector.x-bSpeedVector.x,2) + pow (aSpeedVector.y-bSpeedVector.y,2));
NS_LOG_FUNCTION (this << *rxPsd);
int subChannel = 0;
while (vit != rxPsd->ValuesEnd ())
{
NS_ASSERT (subChannel < 100);
if (*vit != 0.)
{
double fading = c->GetValue (subChannel, speed);
double power = *vit; // in Watt/Hz
power = 10 * log10 (180000 * power); // in dB
NS_LOG_FUNCTION (this << subChannel << *vit << power << fading);
*vit = pow (10., ((power + fading) / 10)) / 180000; // in Watt
NS_LOG_FUNCTION (this << subChannel << *vit);
}
++vit;
++subChannel;
}
NS_LOG_FUNCTION (this << *rxPsd);
return rxPsd;
}
void
TraceFadingLossModel::CreateFadingChannelRealization (Ptr<const MobilityModel> enbMobility, Ptr<const MobilityModel> ueMobility)
{
NS_LOG_FUNCTION (this << enbMobility << ueMobility);
Ptr<JakesFadingLossModel> c = CreateObject<JakesFadingLossModel> ();
ChannelRealizationId_t mobilities = std::make_pair (enbMobility, ueMobility);
NS_LOG_FUNCTION (this <<
"insert new channel realization, m_channelRealizationMap.size () = "
<< m_channelRealizationMap.size ());
m_channelRealizationMap.insert ( std::pair<ChannelRealizationId_t,Ptr<JakesFadingLossModel> > (mobilities, c) );
NS_LOG_FUNCTION (this <<
"m_channelRealizationMap.size () = "
<< m_channelRealizationMap.size ());
}
Ptr<JakesFadingLossModel>
TraceFadingLossModel::GetFadingChannelRealization (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b) const
{
NS_LOG_FUNCTION (this << a << b);
std::map <ChannelRealizationId_t, Ptr<JakesFadingLossModel> >::const_iterator it;
ChannelRealizationId_t mobilities = std::make_pair (a,b);
it = m_channelRealizationMap.find (mobilities);
return it->second;
}
} // namespace ns3

View File

@@ -0,0 +1,95 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
*
* 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: Giuseppe Piro <g.piro@poliba.it>
* Author: Marco Miozzo <mmiozzo@cttc.es>
*/
#ifndef TRACE_FADING_LOSS_MODEL_H
#define TRACE_FADING_LOSS_MODEL_H
#include <ns3/object.h>
#include <ns3/spectrum-propagation-loss-model.h>
#include <map>
//#include "channel-realization.h"
#include <ns3/jakes-fading-loss-model.h>
namespace ns3 {
class MobilityModel;
/**
* \ingroup lte
*
* \brief fading loss model based on precalculated fading traces
*/
class TraceFadingLossModel : public SpectrumPropagationLossModel
{
public:
TraceFadingLossModel ();
virtual ~TraceFadingLossModel ();
static TypeId GetTypeId ();
/**
* \brief The couple of mobility mnode that form a fading channel realization
*/
typedef std::pair<Ptr<const MobilityModel>, Ptr<const MobilityModel> > ChannelRealizationId_t;
/**
* \brief Create a fading channel realization among two device
* \param enbMobility mobility object of the enb
* \param ueMobility mobility object of the ue
*/
void CreateFadingChannelRealization (Ptr<const MobilityModel> enbMobility, Ptr<const MobilityModel> ueMobility);
/**
* \brief Get a fading channel realization among two device
* \param a the mobility object of the enb
* \param b the mobility object of the ue
* \return the pointer to the channel realization
*/
Ptr<JakesFadingLossModel> GetFadingChannelRealization (Ptr<const MobilityModel> a, Ptr<const MobilityModel> b) const;
private:
/**
* @param txPower set of values vs frequency representing the
* transmission power. See SpectrumChannel for details.
*
* @param a sender mobility
* @param b receiver mobility
*
* @return set of values vs frequency representing the received
* power in the same units used for the txPower parameter.
*/
Ptr<SpectrumValue> DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const;
std::map <ChannelRealizationId_t, Ptr<JakesFadingLossModel> > m_channelRealizationMap;
};
} // namespace ns3
#endif /* TRACE_FADING_LOSS_MODEL_H */

View File

@@ -47,6 +47,7 @@ def build(bld):
'model/lte-sinr-chunk-processor.cc',
'model/pf-ff-mac-scheduler.cc',
'model/epc-gtpu-v1.cc',
'model/trace-fading-loss-model.cc'
]
module_test = bld.create_ns3_module_test_library('lte')
@@ -64,6 +65,7 @@ def build(bld):
'test/lte-test-pathloss-model.cc',
'test/epc-test-gtpu-v1.cc',
'test/lte-test-shadowing.cc',
'test/lte-test-fading.cc',
]
headers = bld.new_task_gen('ns3header')
@@ -113,6 +115,7 @@ def build(bld):
'model/lte-sinr-chunk-processor.h',
'model/pf-ff-mac-scheduler.h',
'model/epc-gtpu-v1.h',
'model/trace-fading-loss-model.h',
'test/lte-test-downlink-sinr.h',
'test/lte-test-uplink-sinr.h',
'test/lte-test-link-adaptation.h',
@@ -125,6 +128,7 @@ def build(bld):
'test/lte-test-pathloss-model.h',
'test/epc-test-gtpu-v1.h',
'test/lte-test-shadowing.h',
'test/lte-test-fading.h',
]
if (bld.env['ENABLE_EXAMPLES']):