From 2c43de144e09e927127c13e25c523fbb2df0afcf Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Fri, 14 Dec 2012 10:26:01 +0100 Subject: [PATCH 1/2] moved LteGlobalPathlossDatabase from example program to separate helper --- src/lte/examples/lena-pathloss-traces.cc | 101 ++---------------- .../helper/lte-global-pathloss-database.cc | 98 +++++++++++++++++ src/lte/helper/lte-global-pathloss-database.h | 98 +++++++++++++++++ src/lte/wscript | 2 + 4 files changed, 205 insertions(+), 94 deletions(-) create mode 100644 src/lte/helper/lte-global-pathloss-database.cc create mode 100644 src/lte/helper/lte-global-pathloss-database.h diff --git a/src/lte/examples/lena-pathloss-traces.cc b/src/lte/examples/lena-pathloss-traces.cc index d06a5efa1..7866be2a3 100644 --- a/src/lte/examples/lena-pathloss-traces.cc +++ b/src/lte/examples/lena-pathloss-traces.cc @@ -26,6 +26,7 @@ #include "ns3/lte-module.h" #include "ns3/config-store.h" #include "ns3/radio-bearer-stats-calculator.h" +#include "ns3/lte-global-pathloss-database.h" #include #include @@ -35,97 +36,9 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE ("InterCellInterference"); +NS_LOG_COMPONENT_DEFINE ("LenaPathlossTraces"); -/** - * Store the last pathloss value for each TX-RX pair. This is an - * example of how the PathlossTrace (provided by some SpectrumChannel - * implementations) work. - * - */ -class GlobalPathlossDatabase -{ -public: - - /** - * update the pathloss value - * - * \param context - * \param txPhy the transmitting PHY - * \param rxPhy the receiving PHY - * \param lossDb the loss in dB - */ - virtual void UpdatePathloss (std::string context, Ptr txPhy, Ptr rxPhy, double lossDb) = 0; - - /** - * print the stored pathloss values to standard output - * - */ - void Print (); - -protected: - - // CELL ID IMSI PATHLOSS - std::map > m_pathlossMap; -}; - -void -GlobalPathlossDatabase::Print () -{ - NS_LOG_FUNCTION (this); - for (std::map >::const_iterator cellIdIt = m_pathlossMap.begin (); - cellIdIt != m_pathlossMap.end (); - ++cellIdIt) - { - for (std::map::const_iterator imsiIt = cellIdIt->second.begin (); - imsiIt != cellIdIt->second.end (); - ++imsiIt) - { - std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl; - } - } -} - -class DownlinkGlobalPathlossDatabase : public GlobalPathlossDatabase -{ -public: - // inherited from GlobalPathlossDatabase - virtual void UpdatePathloss (std::string context, Ptr txPhy, Ptr rxPhy, double lossDb); -}; - -void -DownlinkGlobalPathlossDatabase::UpdatePathloss (std::string context, - Ptr txPhy, - Ptr rxPhy, - double lossDb) -{ - NS_LOG_FUNCTION (this << lossDb); - uint16_t cellId = txPhy->GetDevice ()->GetObject ()->GetCellId (); - uint16_t imsi = rxPhy->GetDevice ()->GetObject ()->GetImsi (); - m_pathlossMap[cellId][imsi] = lossDb; -} - - -class UplinkGlobalPathlossDatabase : public GlobalPathlossDatabase -{ -public: - // inherited from GlobalPathlossDatabase - virtual void UpdatePathloss (std::string context, Ptr txPhy, Ptr rxPhy, double lossDb); -}; - -void -UplinkGlobalPathlossDatabase::UpdatePathloss (std::string context, - Ptr txPhy, - Ptr rxPhy, - double lossDb) -{ - NS_LOG_FUNCTION (this << lossDb); - uint16_t imsi = txPhy->GetDevice ()->GetObject ()->GetImsi (); - uint16_t cellId = rxPhy->GetDevice ()->GetObject ()->GetCellId (); - m_pathlossMap[cellId][imsi] = lossDb; -} - int main (int argc, char *argv[]) { @@ -242,15 +155,15 @@ int main (int argc, char *argv[]) - // keep track of all path loss values in a global object - DownlinkGlobalPathlossDatabase dlPathlossDb; - UplinkGlobalPathlossDatabase ulPathlossDb; + // keep track of all path loss values in two centralized objects + DownlinkLteGlobalPathlossDatabase dlPathlossDb; + UplinkLteGlobalPathlossDatabase ulPathlossDb; // we rely on the fact that LteHelper creates the DL channel object first, then the UL channel object, // hence the former will have index 0 and the latter 1 Config::Connect ("/ChannelList/0/PathLoss", - MakeCallback (&DownlinkGlobalPathlossDatabase::UpdatePathloss, &dlPathlossDb)); + MakeCallback (&DownlinkLteGlobalPathlossDatabase::UpdatePathloss, &dlPathlossDb)); Config::Connect ("/ChannelList/1/PathLoss", - MakeCallback (&UplinkGlobalPathlossDatabase::UpdatePathloss, &ulPathlossDb)); + MakeCallback (&UplinkLteGlobalPathlossDatabase::UpdatePathloss, &ulPathlossDb)); Simulator::Run (); diff --git a/src/lte/helper/lte-global-pathloss-database.cc b/src/lte/helper/lte-global-pathloss-database.cc new file mode 100644 index 000000000..8fd463cfc --- /dev/null +++ b/src/lte/helper/lte-global-pathloss-database.cc @@ -0,0 +1,98 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011,2012 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: Nicola Baldo + */ + + +#include "lte-global-pathloss-database.h" +#include "ns3/lte-enb-net-device.h" +#include "ns3/lte-ue-net-device.h" +#include "ns3/lte-spectrum-phy.h" + +#include + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("LteGlobalPathlossDatabase"); + + + +void +LteGlobalPathlossDatabase::Print () +{ + NS_LOG_FUNCTION (this); + for (std::map >::const_iterator cellIdIt = m_pathlossMap.begin (); + cellIdIt != m_pathlossMap.end (); + ++cellIdIt) + { + for (std::map::const_iterator imsiIt = cellIdIt->second.begin (); + imsiIt != cellIdIt->second.end (); + ++imsiIt) + { + std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl; + } + } +} + + +double +LteGlobalPathlossDatabase::GetPathloss (uint16_t cellId, uint64_t imsi) +{ + NS_LOG_FUNCTION (this); + std::map >::iterator cellIt = m_pathlossMap.find (cellId); + if (cellIt == m_pathlossMap.end()) + { + return std::numeric_limits::infinity (); + } + std::map::iterator ueIt = cellIt->second.find (imsi); + if (ueIt == cellIt->second.end()) + { + return std::numeric_limits::infinity (); + } + return ueIt->second; +} + + +void +DownlinkLteGlobalPathlossDatabase::UpdatePathloss (std::string context, + Ptr txPhy, + Ptr rxPhy, + double lossDb) +{ + NS_LOG_FUNCTION (this << lossDb); + uint16_t cellId = txPhy->GetDevice ()->GetObject ()->GetCellId (); + uint16_t imsi = rxPhy->GetDevice ()->GetObject ()->GetImsi (); + m_pathlossMap[cellId][imsi] = lossDb; +} + + +void +UplinkLteGlobalPathlossDatabase::UpdatePathloss (std::string context, + Ptr txPhy, + Ptr rxPhy, + double lossDb) +{ + NS_LOG_FUNCTION (this << lossDb); + uint16_t imsi = txPhy->GetDevice ()->GetObject ()->GetImsi (); + uint16_t cellId = rxPhy->GetDevice ()->GetObject ()->GetCellId (); + m_pathlossMap[cellId][imsi] = lossDb; +} + + + +} // namespace ns3 diff --git a/src/lte/helper/lte-global-pathloss-database.h b/src/lte/helper/lte-global-pathloss-database.h new file mode 100644 index 000000000..1d3ac9cfc --- /dev/null +++ b/src/lte/helper/lte-global-pathloss-database.h @@ -0,0 +1,98 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011,2012 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: Nicola Baldo + */ + + +#ifndef LTE_GLOBAL_PATHLOSS_DATABASE_H +#define LTE_GLOBAL_PATHLOSS_DATABASE_H + +#include +#include +#include +#include + +namespace ns3 { + +class SpectrumPhy; + +/** + * Store the last pathloss value for each TX-RX pair. This is an + * example of how the PathlossTrace (provided by some SpectrumChannel + * implementations) work. + * + */ +class LteGlobalPathlossDatabase +{ +public: + + /** + * update the pathloss value + * + * \param context + * \param txPhy the transmitting PHY + * \param rxPhy the receiving PHY + * \param lossDb the loss in dB + */ + virtual void UpdatePathloss (std::string context, Ptr txPhy, Ptr rxPhy, double lossDb) = 0; + + /** + * + * + * \param cellId the id of the eNB + * \param imsi the id of the UE + * + * \return the pathloss value bewteen the UE and the eNB + */ + double GetPathloss (uint16_t cellId, uint64_t imsi); + + /** + * print the stored pathloss values to standard output + * + */ + void Print (); + +protected: + + // CELL ID IMSI PATHLOSS + std::map > m_pathlossMap; +}; + + +class DownlinkLteGlobalPathlossDatabase : public LteGlobalPathlossDatabase +{ +public: + // inherited from LteGlobalPathlossDatabase + virtual void UpdatePathloss (std::string context, Ptr txPhy, Ptr rxPhy, double lossDb); +}; + + +class UplinkLteGlobalPathlossDatabase : public LteGlobalPathlossDatabase +{ +public: + // inherited from LteGlobalPathlossDatabase + virtual void UpdatePathloss (std::string context, Ptr txPhy, Ptr rxPhy, double lossDb); +}; + + +} // namespace ns3 + + + + +#endif // LTE_GLOBAL_PATHLOSS_DATABASE_H diff --git a/src/lte/wscript b/src/lte/wscript index 1da8986d5..8fadcdf87 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -47,6 +47,7 @@ def build(bld): 'helper/phy-rx-stats-calculator.cc', 'helper/radio-environment-map-helper.cc', 'helper/lte-hex-grid-enb-topology-helper.cc', + 'helper/lte-global-pathloss-database.cc', 'model/rem-spectrum-phy.cc', 'model/ff-mac-common.cc', 'model/ff-mac-csched-sap.cc', @@ -170,6 +171,7 @@ def build(bld): 'helper/radio-bearer-stats-connector.h', 'helper/radio-environment-map-helper.h', 'helper/lte-hex-grid-enb-topology-helper.h', + 'helper/lte-global-pathloss-database.h', 'model/rem-spectrum-phy.h', 'model/ff-mac-common.h', 'model/ff-mac-csched-sap.h', From 2f0f5a7d721fda20d8e68abe3ac749d39f8f2eb3 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Fri, 14 Dec 2012 10:54:12 +0100 Subject: [PATCH 2/2] updated tests for RRC real/ideal: interference antenna mimo harq --- src/lte/test/lte-test-harq.cc | 1 + src/lte/test/lte-test-interference.cc | 35 ++++++++------- src/lte/test/lte-test-mimo.cc | 26 ++++++++--- src/lte/test/lte-test-mimo.h | 5 ++- src/lte/test/test-lte-antenna.cc | 64 +++++++++++++++++++-------- 5 files changed, 89 insertions(+), 42 deletions(-) diff --git a/src/lte/test/lte-test-harq.cc b/src/lte/test/lte-test-harq.cc index 2fd7d9dfb..76e8fd679 100644 --- a/src/lte/test/lte-test-harq.cc +++ b/src/lte/test/lte-test-harq.cc @@ -110,6 +110,7 @@ LenaHarqTestCase::DoRun (void) Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false)); Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (true)); + Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true)); // Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false)); // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL); // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL); diff --git a/src/lte/test/lte-test-interference.cc b/src/lte/test/lte-test-interference.cc index 8d4d0518a..def0f3a9a 100644 --- a/src/lte/test/lte-test-interference.cc +++ b/src/lte/test/lte-test-interference.cc @@ -68,8 +68,6 @@ LteTestUlSchedulingCallback (LteInterferenceTestCase *testcase, std::string path LteInterferenceTestSuite::LteInterferenceTestSuite () : TestSuite ("lte-interference", SYSTEM) { - NS_LOG_INFO ("Creating LteInterferenceTestSuite"); - AddTestCase (new LteInterferenceTestCase ("d1=3000, d2=6000", 3000.000000, 6000.000000, 3.844681, 1.714583, 0.761558, 0.389662, 6, 4)); AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10", 50.000000, 10.000000, 0.040000, 0.040000, 0.010399, 0.010399, 0, 0)); AddTestCase (new LteInterferenceTestCase ("d1=50, d2=20", 50.000000, 20.000000, 0.160000, 0.159998, 0.041154, 0.041153, 0, 0)); @@ -114,12 +112,15 @@ LteInterferenceTestCase::~LteInterferenceTestCase () void LteInterferenceTestCase::DoRun (void) { + NS_LOG_INFO (this << GetName ()); + Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false)); Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false)); Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005)); Ptr lteHelper = CreateObject (); lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel")); + lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (false)); // Create Nodes: eNodeB and UE NodeContainer enbNodes; @@ -203,21 +204,25 @@ LteInterferenceTestCase::DoRun (void) MakeBoundCallback (&LteTestUlSchedulingCallback, this)); // need to allow for RRC connection establishment + SRS - Simulator::Stop (Seconds (0.040)); + Simulator::Stop (Seconds (0.100)); Simulator::Run (); + if (m_dlMcs > 0) + { + double dlSinr1Db = 10.0 * log10 (testDlSinr1->GetSinr ()->operator[] (0)); + NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)"); - double dlSinr1Db = 10.0 * log10 (testDlSinr1->GetSinr ()->operator[] (0)); - NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)"); - - double ulSinr1Db = 10.0 * log10 (testUlSinr1->GetSinr ()->operator[] (0)); - NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)"); - - double dlSinr2Db = 10.0 * log10 (testDlSinr2->GetSinr ()->operator[] (0)); - NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)"); - - double ulSinr2Db = 10.0 * log10 (testUlSinr2->GetSinr ()->operator[] (0)); - NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)"); + double dlSinr2Db = 10.0 * log10 (testDlSinr2->GetSinr ()->operator[] (0)); + NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)"); + } + if (m_ulMcs > 0) + { + double ulSinr1Db = 10.0 * log10 (testUlSinr1->GetSinr ()->operator[] (0)); + NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)"); + + double ulSinr2Db = 10.0 * log10 (testUlSinr2->GetSinr ()->operator[] (0)); + NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)"); + } Simulator::Destroy (); @@ -240,7 +245,7 @@ LteInterferenceTestCase::UlScheduling (uint32_t frameNo, uint32_t subframeNo, ui uint8_t mcs, uint16_t sizeTb) { // need to allow for RRC connection establishment + SRS transmission - if (Simulator::Now () > MilliSeconds (35)) + if (Simulator::Now () > MilliSeconds (50)) { NS_TEST_ASSERT_MSG_EQ ((uint32_t)mcs, (uint32_t)m_ulMcs, "Wrong UL MCS"); } diff --git a/src/lte/test/lte-test-mimo.cc b/src/lte/test/lte-test-mimo.cc index 4eb8f4b17..0adac1916 100644 --- a/src/lte/test/lte-test-mimo.cc +++ b/src/lte/test/lte-test-mimo.cc @@ -74,8 +74,10 @@ LenaTestMimoSuite::LenaTestMimoSuite () estThrDl.push_back (119100); // TTI 1 estimated throughput for TxMode 1 estThrDl.push_back (183600); // TTI 2 estimated throughput for TxMode 2 estThrDl.push_back (193400); // TTI 3 estimated throughput for TxMode 3 - AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler")); - AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler")); + AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", true)); + AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", true)); + AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", false)); + AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", false)); } @@ -83,18 +85,27 @@ LenaTestMimoSuite::LenaTestMimoSuite () static LenaTestMimoSuite lenaTestMimoSuite; std::string -LenaMimoTestCase::BuildNameString (uint16_t dist, std::string schedulerType) +LenaMimoTestCase::BuildNameString (uint16_t dist, std::string schedulerType, bool useIdealRrc) { std::ostringstream oss; oss << " UE distance " << dist << " m" << " Scheduler " << schedulerType; + if (useIdealRrc) + { + oss << ", ideal RRC"; + } + else + { + oss << ", real RRC"; + } return oss.str (); } -LenaMimoTestCase::LenaMimoTestCase (uint16_t dist, std::vector estThrDl, std::string schedulerType) - : TestCase (BuildNameString (dist, schedulerType)), +LenaMimoTestCase::LenaMimoTestCase (uint16_t dist, std::vector estThrDl, std::string schedulerType, bool useIdealRrc) + : TestCase (BuildNameString (dist, schedulerType, useIdealRrc)), m_dist (dist), m_estThrDl (estThrDl), - m_schedulerType (schedulerType) + m_schedulerType (schedulerType), + m_useIdealRrc (useIdealRrc) { } @@ -105,9 +116,10 @@ LenaMimoTestCase::~LenaMimoTestCase () void LenaMimoTestCase::DoRun (void) { + NS_LOG_FUNCTION (this << GetName ()); Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false)); Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010)); - + Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (m_useIdealRrc)); /** * Initialize Simulation Scenario: 1 eNB and m_nUser UEs diff --git a/src/lte/test/lte-test-mimo.h b/src/lte/test/lte-test-mimo.h index 91c43dee1..59400c979 100644 --- a/src/lte/test/lte-test-mimo.h +++ b/src/lte/test/lte-test-mimo.h @@ -34,7 +34,7 @@ namespace ns3 { class LenaMimoTestCase : public TestCase { public: - LenaMimoTestCase (uint16_t dist, std::vector estThrDl, std::string schedulerType); + LenaMimoTestCase (uint16_t dist, std::vector estThrDl, std::string schedulerType, bool useIdealRrc); virtual ~LenaMimoTestCase (); private: @@ -42,12 +42,13 @@ private: void GetRlcBufferSample (Ptr rlcStats, uint64_t imsi, uint8_t rnti); - static std::string BuildNameString (uint16_t dist, std::string schedulerType); + static std::string BuildNameString (uint16_t dist, std::string schedulerType, bool useIdealRrc); uint16_t m_nUser; uint16_t m_nLc; uint16_t m_dist; std::vector m_estThrDl; std::string m_schedulerType; + bool m_useIdealRrc; std::vector m_dlDataRxed; diff --git a/src/lte/test/test-lte-antenna.cc b/src/lte/test/test-lte-antenna.cc index 67605540b..d81ce24b5 100644 --- a/src/lte/test/test-lte-antenna.cc +++ b/src/lte/test/test-lte-antenna.cc @@ -35,6 +35,8 @@ #include "ns3/lte-enb-net-device.h" #include "ns3/ff-mac-scheduler.h" +#include "ns3/lte-global-pathloss-database.h" + #include "lte-test-sinr-chunk-processor.h" NS_LOG_COMPONENT_DEFINE ("LteAntennaTest"); @@ -149,34 +151,60 @@ LteEnbAntennaTestCase::DoRun (void) enbphy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr); + // keep track of all path loss values in two centralized objects + DownlinkLteGlobalPathlossDatabase dlPathlossDb; + UplinkLteGlobalPathlossDatabase ulPathlossDb; + // we rely on the fact that LteHelper creates the DL channel object first, then the UL channel object, + // hence the former will have index 0 and the latter 1 + Config::Connect ("/ChannelList/0/PathLoss", + MakeCallback (&DownlinkLteGlobalPathlossDatabase::UpdatePathloss, &dlPathlossDb)); + Config::Connect ("/ChannelList/1/PathLoss", + MakeCallback (&UplinkLteGlobalPathlossDatabase::UpdatePathloss, &ulPathlossDb)); + Simulator::Stop (Seconds (0.035)); Simulator::Run (); - const double enbTxPowerDbm = 30; // default eNB TX power over whole bandwdith const double ueTxPowerDbm = 10; // default UE TX power over whole bandwdith const double ktDbm = -174; // reference LTE noise PSD const double noisePowerDbm = ktDbm + 10 * log10 (25 * 180000); // corresponds to kT*bandwidth in linear units const double ueNoiseFigureDb = 9.0; // default UE noise figure const double enbNoiseFigureDb = 5.0; // default eNB noise figure - - double calculatedSinrDbDl = -INFINITY; - if (testDlSinr->GetSinr () != 0) - { - calculatedSinrDbDl = 10.0 * log10 (testDlSinr->GetSinr ()->operator[] (0)); - } - double calculatedSinrDbUl = -INFINITY; - if (testUlSinr->GetSinr () != 0) - { - calculatedSinrDbUl = 10.0 * log10 (testUlSinr->GetSinr ()->operator[] (0)); - } - - // remember that propagation loss is 0dB - double calculatedAntennaGainDbDl = - (enbTxPowerDbm - calculatedSinrDbDl - noisePowerDbm - ueNoiseFigureDb); - double calculatedAntennaGainDbUl = - (ueTxPowerDbm - calculatedSinrDbUl - noisePowerDbm - enbNoiseFigureDb); double tolerance = (m_antennaGainDb != 0) ? abs (m_antennaGainDb)*0.001 : 0.001; - NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbDl, m_antennaGainDb, tolerance, "Wrong DL antenna gain!"); - NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbUl, m_antennaGainDb, tolerance, "Wrong UL antenna gain!"); + + // first test with SINR from LteTestSinrChunkProcessor + // this can only be done for not-too-bad SINR otherwise the measurement won't be available + double expectedSinrDl = enbTxPowerDbm + m_antennaGainDb - noisePowerDbm + ueNoiseFigureDb; + if (expectedSinrDl > 0) + { + double calculatedSinrDbDl = -INFINITY; + if (testDlSinr->GetSinr () != 0) + { + calculatedSinrDbDl = 10.0 * log10 (testDlSinr->GetSinr ()->operator[] (0)); + } + // remember that propagation loss is 0dB + double calculatedAntennaGainDbDl = - (enbTxPowerDbm - calculatedSinrDbDl - noisePowerDbm - ueNoiseFigureDb); + NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbDl, m_antennaGainDb, tolerance, "Wrong DL antenna gain!"); + } + double expectedSinrUl = ueTxPowerDbm + m_antennaGainDb - noisePowerDbm + enbNoiseFigureDb; + if (expectedSinrUl > 0) + { + double calculatedSinrDbUl = -INFINITY; + if (testUlSinr->GetSinr () != 0) + { + calculatedSinrDbUl = 10.0 * log10 (testUlSinr->GetSinr ()->operator[] (0)); + } + double calculatedAntennaGainDbUl = - (ueTxPowerDbm - calculatedSinrDbUl - noisePowerDbm - enbNoiseFigureDb); + NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbUl, m_antennaGainDb, tolerance, "Wrong UL antenna gain!"); + } + + + // repeat the same tests with the LteGlobalPathlossDatabases + double measuredLossDl = dlPathlossDb.GetPathloss (1, 1); + NS_TEST_ASSERT_MSG_EQ_TOL (measuredLossDl, -m_antennaGainDb, tolerance, "Wrong DL loss!"); + double measuredLossUl = ulPathlossDb.GetPathloss (1, 1); + NS_TEST_ASSERT_MSG_EQ_TOL (measuredLossUl, -m_antennaGainDb, tolerance, "Wrong UL loss!"); + Simulator::Destroy (); }