diff --git a/src/lte/model/jakes-fading-loss-model.cc b/src/lte/model/jakes-fading-loss-model.cc index 40acd61a3..1e18f56a1 100644 --- a/src/lte/model/jakes-fading-loss-model.cc +++ b/src/lte/model/jakes-fading-loss-model.cc @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Giuseppe Piro + * Author: Marco Miozzo + * remove dependencies from Phy and Mobility models */ #include @@ -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 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 mobility = 0; - // this needs to be fixed, we cannot allow a propagation model to need pointers to all PHYs - // mobility = GetPhy ()->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject (); - 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 (); } diff --git a/src/lte/model/jakes-fading-loss-model.h b/src/lte/model/jakes-fading-loss-model.h index 075c541e4..4ac71a013 100644 --- a/src/lte/model/jakes-fading-loss-model.h +++ b/src/lte/model/jakes-fading-loss-model.h @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Giuseppe Piro + * Author: Marco Miozzo + * 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 diff --git a/src/lte/model/trace-fading-loss-model.cc b/src/lte/model/trace-fading-loss-model.cc new file mode 100644 index 000000000..77d9c5093 --- /dev/null +++ b/src/lte/model/trace-fading-loss-model.cc @@ -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 + * Author: Marco Miozzo + */ + + +#include "trace-fading-loss-model.h" +#include +#include +#include + +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 () + ; + return tid; +} + + + +Ptr +TraceFadingLossModel::DoCalcRxPowerSpectralDensity ( + Ptr txPsd, + Ptr a, + Ptr b) const +{ + NS_LOG_FUNCTION (this << *txPsd << a << b); + + Ptr c = GetFadingChannelRealization (a,b); + + Ptr rxPsd = Copy (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 enbMobility, Ptr ueMobility) +{ + NS_LOG_FUNCTION (this << enbMobility << ueMobility); + + Ptr c = CreateObject (); + 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 > (mobilities, c) ); + + NS_LOG_FUNCTION (this << + "m_channelRealizationMap.size () = " + << m_channelRealizationMap.size ()); + +} + + +Ptr +TraceFadingLossModel::GetFadingChannelRealization (Ptr a, Ptr b) const +{ + + NS_LOG_FUNCTION (this << a << b); + + std::map >::const_iterator it; + + ChannelRealizationId_t mobilities = std::make_pair (a,b); + it = m_channelRealizationMap.find (mobilities); + + return it->second; +} + +} // namespace ns3 diff --git a/src/lte/model/trace-fading-loss-model.h b/src/lte/model/trace-fading-loss-model.h new file mode 100644 index 000000000..25b2cac35 --- /dev/null +++ b/src/lte/model/trace-fading-loss-model.h @@ -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 + * Author: Marco Miozzo + */ + + +#ifndef TRACE_FADING_LOSS_MODEL_H +#define TRACE_FADING_LOSS_MODEL_H + + +#include +#include +#include +//#include "channel-realization.h" +#include + +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 > 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 enbMobility, Ptr 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 GetFadingChannelRealization (Ptr a, Ptr 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 DoCalcRxPowerSpectralDensity (Ptr txPsd, + Ptr a, + Ptr b) const; + + std::map > m_channelRealizationMap; +}; + + + + + + +} // namespace ns3 + +#endif /* TRACE_FADING_LOSS_MODEL_H */ diff --git a/src/lte/wscript b/src/lte/wscript index 84283a64a..541c6d518 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -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']):