Add missing files of Hybrid and Simple BuildingsPropagationLossModel

This commit is contained in:
Marco Miozzo
2012-02-20 15:54:44 +01:00
parent 3a68ce3448
commit cd892e8a2a
6 changed files with 591 additions and 30 deletions

View File

@@ -0,0 +1,218 @@
/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#include "ns3/propagation-loss-model.h"
#include "ns3/log.h"
#include "ns3/mobility-model.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
#include <math.h>
#include "hybrid-buildings-propagation-loss-model.h"
#include "ns3/buildings-mobility-model.h"
#include "ns3/enum.h"
NS_LOG_COMPONENT_DEFINE ("HybridBuildingsPropagationLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (HybridBuildingsPropagationLossModel);
HybridBuildingsPropagationLossModel::HybridBuildingsPropagationLossModel ()
: BuildingsPropagationLossModel ()
{
}
HybridBuildingsPropagationLossModel::~HybridBuildingsPropagationLossModel ()
{
}
TypeId
HybridBuildingsPropagationLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::HybridBuildingsPropagationLossModel")
.SetParent<BuildingsPropagationLossModel> ()
.AddConstructor<HybridBuildingsPropagationLossModel> ();
return tid;
}
double
HybridBuildingsPropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
NS_ASSERT_MSG ((a->GetPosition ().z > 0) && (b->GetPosition ().z > 0), "HybridBuildingsPropagationLossModel does not support underground nodes (placed at z < 0)");
double distance = a->GetDistanceFrom (b);
if (distance <= m_minDistance)
{
return 0.0;
}
// get the BuildingsMobilityModel pointers
Ptr<BuildingsMobilityModel> a1 = DynamicCast<BuildingsMobilityModel> (a);
Ptr<BuildingsMobilityModel> b1 = DynamicCast<BuildingsMobilityModel> (b);
NS_ASSERT_MSG ((a1 != 0) && (b1 != 0), "HybridBuildingsPropagationLossModel only works with BuildingsMobilityModel");
double loss = 0.0;
if (a1->IsOutdoor ())
{
if (b1->IsOutdoor ())
{
if (distance > 1000)
{
NS_LOG_INFO (this << a1->GetPosition ().z << b1->GetPosition ().z << m_rooftopHeight);
if ((a1->GetPosition ().z < m_rooftopHeight)
&& (b1->GetPosition ().z < m_rooftopHeight))
{
// ITU limit in distance (i.e., < 2000 for small cells)
if (distance < m_itu1411DistanceThreshold)
{
// short range communication
loss = ItuR1411 (a1, b1);
NS_LOG_INFO (this << " 0-0 (>1000): down rooftop -> ITUR1411 : " << loss);
}
else
{
// out of bound
loss = std::numeric_limits<double>::infinity ();
NS_LOG_INFO (this << " 0-0 (>2000): down rooftop -> Infinity (out of bound) : " << loss);
}
}
else
{
// Over the rooftop tranmission -> Okumura Hata
loss = OkumuraHata (a1, b1);
NS_LOG_INFO (this << " O-O (>1000): Over the rooftop -> OH : " << loss);
}
}
else
{
// short range outdoor communication
loss = ItuR1411 (a1, b1);
NS_LOG_INFO (this << " 0-0 (<1000) Street canyon -> ITUR1411 : " << loss);
}
}
else
{
// b indoor
if (distance > 1000)
{
if ((a1->GetPosition ().z < m_rooftopHeight)
&& (b1->GetPosition ().z < m_rooftopHeight))
{
// ITU limit in distance (i.e., < 2000 for small cells)
if (distance < m_itu1411DistanceThreshold)
{
// short range communication
loss = ItuR1411 (a1, b1) + ExternalWallLoss (b1) + HeightLoss (a1);
NS_LOG_INFO (this << " 0-I (>1000): down rooftop -> ITUR1411 : " << loss);
}
else
{
// out of bound
loss = std::numeric_limits<double>::infinity ();
NS_LOG_INFO (this << " 0-I (>2000): down rooftop -> ITUR1411 : " << loss);
}
}
else
{
// Over the rooftop tranmission -> Okumura Hata
loss = OkumuraHata (a1, b1) + ExternalWallLoss (b1);
NS_LOG_INFO (this << " O-I (>1000): Over the rooftop -> OH : " << loss);
}
}
else
{
loss = ItuR1411 (a1, b1) + ExternalWallLoss (b1) + HeightLoss (b1);
NS_LOG_INFO (this << " 0-I (<1000) ITUR1411 + BEL : " << loss);
}
} // end b1->isIndoor ()
}
else
{
// a is indoor
if (b1->IsIndoor ())
{
if (a1->GetBuilding () == b1->GetBuilding ())
{
// nodes are in same building -> indoor communication ITU-R P.1238
loss = ItuR1238 (a1, b1) + InternalWallsLoss (a1, b1);;
NS_LOG_INFO (this << " I-I (same building) ITUR1238 : " << loss);
}
else
{
// nodes are in different buildings
loss = ItuR1411 (a1, b1) + ExternalWallLoss (a1) + ExternalWallLoss (b1);
NS_LOG_INFO (this << " I-I (different) ITUR1238 + 2*BEL : " << loss);
}
}
else
{
// b is outdoor
if (distance > 1000)
{
if ((a1->GetPosition ().z < m_rooftopHeight)
&& (b1->GetPosition ().z < m_rooftopHeight))
{
// ITU limit in distance (i.e., < 2000 for small cells)
if (distance < m_itu1411DistanceThreshold)
{
// short range communication
loss = ItuR1411 (a1, b1) + ExternalWallLoss (a1) + HeightLoss (a1);
NS_LOG_INFO (this << " I-O (>1000): down rooftop -> ITUR1411 : " << loss);
}
else
{
// out of bound
loss = std::numeric_limits<double>::infinity ();
NS_LOG_INFO (this << " I-O (>2000): down rooftop -> ITUR1411 : " << loss);
}
}
else
{
// above rooftop -> OH
loss = OkumuraHata (a1, b1) + ExternalWallLoss (a1) + HeightLoss (a1);
NS_LOG_INFO (this << " =I-O (>1000) over rooftop OH + BEL + HG: " << loss);
}
}
else
{
loss = ItuR1411 (a1, b1) + ExternalWallLoss (a1) + HeightLoss (a1);
NS_LOG_INFO (this << " I-O (<1000) ITUR1411 + BEL + HG: " << loss);
}
} // end b1->IsIndoor ()
} // end a1->IsOutdoor ()
return loss;
}
} // namespace ns3

View File

@@ -0,0 +1,73 @@
/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#ifndef HYBRID_BUILDINGS_PROPAGATION_LOSS_MODEL_H_
#define HYBRID_BUILDINGS_PROPAGATION_LOSS_MODEL_H_
#include <ns3/buildings-propagation-loss-model.h>
namespace ns3 {
/**
* \ingroup propagation
*
* \brief The Hybrid-Building-Propagation-Model is a compound of different models able to evaluate the pathloss from 200 to 2600 MHz, in different environments and with buildings (i.e., indoor and outdoor communications).
*
* This model includes Hata model, COST231, ITU-R P.1411 (short range
* communications), ITU-R P.1238 (indoor communications).
* Building-Propagation-Model properly combines the models above in order
* to be able to evaluate the pathloss under different scenarios, in detail:
* - Environments: urban, suburban, open-areas;
* - frequency: from 200 uo to 2600 MHz
* - short range communications vs long range communications
* - Node position respect to buildings: indoor, outdoor and hybrid (indoor <-> outdoor)
* - Building penetretation loss
* - floors, etc...
*
* Frequency: 200 MHz to 2000 MHz
* Link Distance:up to 20 km
* Short/long distance commutation: 1 Km
* \warning This model works with BuildingsMobilityModel
*
*/
class HybridBuildingsPropagationLossModel : public BuildingsPropagationLossModel
{
public:
static TypeId GetTypeId (void);
HybridBuildingsPropagationLossModel ();
~HybridBuildingsPropagationLossModel ();
/**
* \param a the mobility model of the source
* \param b the mobility model of the destination
* \returns the propagation loss (in dBm)
*/
virtual double GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
};
}
#endif /* HYBRID_BUILDINGS_PROPAGATION_LOSS_MODEL_H_ */

View File

@@ -0,0 +1,124 @@
/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#include "ns3/propagation-loss-model.h"
#include "ns3/log.h"
#include "ns3/mobility-model.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
#include <math.h>
#include "oh-buildings-propagation-loss-model.h"
#include "ns3/buildings-mobility-model.h"
#include "ns3/enum.h"
NS_LOG_COMPONENT_DEFINE ("OhBuildingsPropagationLossModel");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (OhBuildingsPropagationLossModel);
OhBuildingsPropagationLossModel::OhBuildingsPropagationLossModel ()
: BuildingsPropagationLossModel ()
{
}
OhBuildingsPropagationLossModel::~OhBuildingsPropagationLossModel ()
{
}
TypeId
OhBuildingsPropagationLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::OhBuildingsPropagationLossModel")
.SetParent<BuildingsPropagationLossModel> ()
.AddConstructor<OhBuildingsPropagationLossModel> ();
return tid;
}
double
OhBuildingsPropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
double distance = a->GetDistanceFrom (b);
if (distance <= m_minDistance)
{
return 0.0;
}
// get the BuildingsMobilityModel pointers
Ptr<BuildingsMobilityModel> a1 = DynamicCast<BuildingsMobilityModel> (a);
Ptr<BuildingsMobilityModel> b1 = DynamicCast<BuildingsMobilityModel> (b);
NS_ASSERT_MSG ((a1 != 0) && (b1 != 0), "OhBuildingsPropagationLossModel only works with BuildingsMobilityModel");
double loss = 0.0;
if (a1->IsOutdoor ())
{
if (b1->IsOutdoor ())
{
loss = OkumuraHata (a1, b1);
NS_LOG_INFO (this << " O-O : " << loss);
}
else
{
// b indoor
loss = OkumuraHata (a1, b1) + ExternalWallLoss (b1);
NS_LOG_INFO (this << " O-I : " << loss);
} // end b1->isIndoor ()
}
else
{
// a is indoor
if (b1->IsIndoor ())
{
if (a1->GetBuilding () == b1->GetBuilding ())
{
// nodes are in same building -> indoor communication ITU-R P.1238
loss = OkumuraHata (a1, b1) + InternalWallsLoss (a1, b1);;
NS_LOG_INFO (this << " I-I (same building)" << loss);
}
else
{
// nodes are in different buildings
loss = OkumuraHata (a1, b1) + ExternalWallLoss (a1) + ExternalWallLoss (b1);
NS_LOG_INFO (this << " I-O-I (different buildings): " << loss);
}
}
else
{
loss = OkumuraHata (a1, b1) + ExternalWallLoss (a1);
NS_LOG_INFO (this << " I-O : " << loss);
} // end b1->IsIndoor ()
} // end a1->IsOutdoor ()
return loss;
}
} // namespace ns3

View File

@@ -0,0 +1,75 @@
/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#ifndef OH_BUILDINGS_PROPAGATION_LOSS_MODEL_H_
#define OH_BUILDINGS_PROPAGATION_LOSS_MODEL_H_
#include <ns3/buildings-propagation-loss-model.h>
namespace ns3 {
/**
* \ingroup propagation
*
* \brief The Okumura Hata (OH)-Building-Propagation-Model is propagation module
* using only the Okumura Hata model from the one provided by
* BuildingsPropagationLossModel, in different environments and with
* buildings (i.e., indoor and outdoor communications).
*
* This model includes Hata model, COST231, ITU-R P.1411 (short range
* communications), ITU-R P.1238 (indoor communications).
* Building-Propagation-Model properly combines the models above in order
* to be able to evaluate the pathloss under different scenarios, in detail:
* - Environments: urban, suburban, open-areas;
* - frequency: from 200 uo to 2600 MHz
* - short range communications vs long range communications
* - Node position respect to buildings: indoor, outdoor and hybrid (indoor <-> outdoor)
* - Building penetretation loss
* - floors, etc...
*
* Frequency: 200 MHz to 2000 MHz
* Link Distance:up to 20 km
* \warning This model works with BuildingsMobilityModel
*
*/
class OhBuildingsPropagationLossModel : public BuildingsPropagationLossModel
{
public:
static TypeId GetTypeId (void);
OhBuildingsPropagationLossModel ();
~OhBuildingsPropagationLossModel ();
/**
* \param a the mobility model of the source
* \param b the mobility model of the destination
* \returns the propagation loss (in dBm)
*/
virtual double GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
};
}
#endif /* OH_BUILDINGS_PROPAGATION_LOSS_MODEL_H_ */

View File

@@ -27,6 +27,8 @@
#include <math.h>
#include <ns3/spectrum-value.h>
#include <ns3/double.h>
#include "ns3/enum.h"
#include <ns3/lte-mi-error-model.h>
#ifdef __FreeBSD__
#define log2(x) (log(x)/M_LN2)
@@ -223,7 +225,13 @@ LteAmc::GetTypeId (void)
"The requested BER in assigning MCS (default is 0.00005).",
DoubleValue (0.00005),
MakeDoubleAccessor (&LteAmc::m_ber),
MakeDoubleChecker<double> ());
MakeDoubleChecker<double> ())
.AddAttribute ("AmcModel",
"AMC model used to assign CQI",
EnumValue (LteAmc::Vienna),
MakeEnumAccessor (&LteAmc::m_amcModel),
MakeEnumChecker (LteAmc::Vienna, "Vienna",
LteAmc::Piro, "Piro"));
return tid;
}
@@ -282,43 +290,97 @@ LteAmc::GetSpectralEfficiencyFromCqi (int cqi)
std::vector<int>
LteAmc::CreateCqiFeedbacks (const SpectrumValue& sinr)
LteAmc::CreateCqiFeedbacks (const SpectrumValue& sinr, uint8_t rbgSize)
{
NS_LOG_FUNCTION (this);
std::vector<int> cqi;
Values::const_iterator it;
for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
if (m_amcModel == Piro)
{
double sinr_ = (*it);
if (sinr_ == 0.0)
for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
{
cqi.push_back (-1); // SINR == 0 (linear units) means no signal in this RB
double sinr_ = (*it);
if (sinr_ == 0.0)
{
cqi.push_back (-1); // SINR == 0 (linear units) means no signal in this RB
}
else
{
/*
* Compute the spectral efficiency from the SINR
* SINR
* spectralEfficiency = log2 (1 + -------------------- )
* -ln(5*BER)/1.5
* NB: SINR must be expressed in linear units
*/
double s = log2 ( 1 + ( sinr_ /
( (-log (5.0 * m_ber )) / 1.5) ));
int cqi_ = GetCqiFromSpectralEfficiency (s);
NS_LOG_LOGIC (" PRB =" << cqi.size ()
<< ", sinr = " << sinr_
<< " (=" << pow (10.0, sinr_ / 10.0) << " dB)"
<< ", spectral efficiency =" << s
<< ", CQI = " << cqi_ << ", BER = " << m_ber);
cqi.push_back (cqi_);
}
}
else
{
/*
* Compute the spectral efficiency from the SINR
* SINR
* spectralEfficiency = log2 (1 + -------------------- )
* -ln(5*BER)/1.5
* NB: SINR must be expressed in linear units
*/
}
else if (m_amcModel == Vienna)
{
uint8_t rbgNum = 1;//ceil ((double)sinr.length () / (double)rbgSize);
double s = log2 ( 1 + ( sinr_ /
( (-log (5.0 * m_ber )) / 1.5) ));
int cqi_ = GetCqiFromSpectralEfficiency (s);
NS_LOG_LOGIC (" PRB =" << cqi.size ()
<< ", sinr = " << sinr_
<< " (=" << pow (10.0, sinr_ / 10.0) << " dB)"
<< ", spectral efficiency =" << s
<< ", CQI = " << cqi_ << ", BER = " << m_ber);
cqi.push_back (cqi_);
}
for (uint8_t i = 0; i < rbgNum; i++)
{
std::vector <int> rbgMap;
for (uint8_t j = 0; j < rbgSize; j++)
{
rbgMap.push_back ((i * rbgSize) + j);
}
uint8_t mcs = 0;
double ber = 0.0;
while (mcs < 28)
{
// ber = LteMiErrorModel::GetTbError (sinr, rbgMap, GetTbSizeFromMcs (mcs, rbgSize), mcs);
if (ber > 0.1)
break;
mcs++;
}
int rbgCqi = 0;
if ((ber > 0.1)&&(mcs==0))
{
rbgCqi = 0; // any MCS can guarantee the 10 % of BER
}
else if (mcs == 28)
{
rbgCqi = 15; // best MCS
}
else
{
double s = SpectralEfficiencyForMcs[mcs];
rbgCqi = 0;
while ((rbgCqi < 15) && (SpectralEfficiencyForCqi[rbgCqi + 1] < s))
{
++rbgCqi;
}
}
// fill the cqi vector (per RB basis)
for (uint8_t j = 0; j < rbgSize; j++)
{
cqi.push_back (rbgCqi);
}
}
}
return cqi;

View File

@@ -49,6 +49,12 @@ public:
LteAmc ();
virtual ~LteAmc();
enum AmcModel
{
Piro, // model based on GSoC code from 3GPP R1-081483 "Conveying MCS and TB size via PDCCH")
Vienna // model based on 10% of BER according to LteMiErrorModel based on Lte Vienna link level simulator BLER curves
};
/**
* \brief Get the Modulation anc Coding Scheme for
* a CQI value
@@ -75,9 +81,11 @@ public:
/**
* \brief Create a message with CQI feedback
* \param sinr the SpectrumValue vector of SINR for evaluating the CQI
* \param rbgSize size of RB group (in RBs) for evaluating subband/wideband CQI
*
*/
/*static*/ std::vector<int> CreateCqiFeedbacks (const SpectrumValue& sinr);
/*static*/ std::vector<int> CreateCqiFeedbacks (const SpectrumValue& sinr, uint8_t rbgSize = 0);
/**
* \brief Get a proper CQI for the spectrale efficiency value.
@@ -91,6 +99,7 @@ public:
private:
double m_ber;
AmcModel m_amcModel;