From 2458fcab71f6e9cf77ee989cfe700d817b96b8a3 Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Fri, 2 Nov 2012 17:12:55 +0100 Subject: [PATCH] Add lte-harq test suite and polishing of code --- src/lte/model/lte-enb-mac.cc | 19 +- src/lte/model/lte-mi-error-model.cc | 6 +- src/lte/model/lte-spectrum-phy.cc | 14 -- src/lte/model/pf-ff-mac-scheduler.cc | 2 +- src/lte/model/rr-ff-mac-scheduler.cc | 2 +- src/lte/test/lte-test-harq.cc | 258 +++++++++++++++++++++++ src/lte/test/lte-test-harq.h | 71 +++++++ src/lte/test/lte-test-phy-error-model.cc | 2 +- 8 files changed, 336 insertions(+), 38 deletions(-) create mode 100644 src/lte/test/lte-test-harq.cc create mode 100644 src/lte/test/lte-test-harq.h diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index 2d2bd666e..040bc74f0 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -511,28 +511,11 @@ LteEnbMac::DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo) m_ulInfoListReceived.clear (); } -// std::map ::iterator it; -// for (it = m_ulInfoListElements.begin (); it != m_ulInfoListElements.end (); it++) -// { -// ulparams.m_ulInfoList.push_back ((*it).second); -// } m_schedSapProvider->SchedUlTriggerReq (ulparams); - - - - // reset UL info -// for (it = m_ulInfoListElements.begin (); it != m_ulInfoListElements.end (); it++) -// { -// for (uint16_t i = 0; i < (*it).second.m_ulReception.size (); i++) -// { -// (*it).second.m_ulReception.at (i) = 0; -// } -// (*it).second.m_receptionStatus = UlInfoListElement_s::Ok; -// (*it).second.m_tpc = 0; -// } } + void LteEnbMac::DoReceiveLteControlMessage (Ptr msg) { diff --git a/src/lte/model/lte-mi-error-model.cc b/src/lte/model/lte-mi-error-model.cc index ce3da06e7..40ce85b20 100644 --- a/src/lte/model/lte-mi-error-model.cc +++ b/src/lte/model/lte-mi-error-model.cc @@ -415,7 +415,7 @@ LteMiErrorModel::MappingMiBler (double mib, uint8_t ecrId, uint16_t cbSize) cbIndex++; } cbIndex--; - NS_LOG_LOGIC (" ECR " << (uint16_t)ecrId << " CB size " << cbSize << " CB size curve " << cbMiSizeTable[cbIndex]); + NS_LOG_LOGIC (" ECRid " << (uint16_t)ecrId << " ECR " << BlerCurvesEcrMap[ecrId] << " CB size " << cbSize << " CB size curve " << cbMiSizeTable[cbIndex]); b = bEcrTable[cbIndex][ecrId]; if (b<0.0) @@ -683,7 +683,7 @@ LteMiErrorModel::GetTbDecodificationStats (const SpectrumValue& sinr, const std: { // Modulation order 4 uint8_t i = MI_16QAM_MAX_ID; - while ((BlerCurvesEcrMap[i]>Reff)&&(i>MI_QPSK_MAX_ID)) + while ((BlerCurvesEcrMap[i]>Reff)&&(i>MI_QPSK_MAX_ID + 1)) { i--; } @@ -693,7 +693,7 @@ LteMiErrorModel::GetTbDecodificationStats (const SpectrumValue& sinr, const std: { // Modulation order 6 uint8_t i = MI_64QAM_MAX_ID; - while ((BlerCurvesEcrMap[i]>Reff)&&(i>MI_16QAM_MAX_ID)) + while ((BlerCurvesEcrMap[i]>Reff)&&(i>MI_16QAM_MAX_ID + 1)) { i--; } diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 24bb00444..c4aeccbfc 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -837,23 +837,9 @@ LteSpectrumPhy::EndRxData () TbStats_t tbStats = LteMiErrorModel::GetTbDecodificationStats (m_sinrPerceived, (*itTb).second.rbBitmap, (*itTb).second.size, (*itTb).second.mcs, harqInfoList); (*itTb).second.mi = tbStats.mi; (*itTb).second.corrupt = m_random->GetValue () > tbStats.tbler ? false : true; - // DEBUG: force error for testing HARQ -// if ((*itTb).second.downlink) -// { -// // if (((*itTb).second.harqProcessId == 0)&&(Simulator::Now ().GetNanoSeconds ()<=20000000)) -// if ((errors<4) && ((*itTb).second.harqProcessId == 0) && ( ((*itTb).first.m_rnti==1)||((*itTb).first.m_rnti==3)) ) -// { -// (*itTb).second.corrupt = true; -// errors++; -// } -// } NS_LOG_DEBUG (this << "RNTI " << (*itTb).first.m_rnti << " size " << (*itTb).second.size << " mcs " << (uint32_t)(*itTb).second.mcs << " bitmap " << (*itTb).second.rbBitmap.size () << " layer " << (uint16_t)(*itTb).first.m_layer << " TBLER " << tbStats.tbler << " corrupted " << (*itTb).second.corrupt); } -// for (uint16_t i = 0; i < (*itTb).second.rbBitmap.size (); i++) -// { -// NS_LOG_DEBUG (this << " RB " << (*itTb).second.rbBitmap.at (i) << " SINR " << m_sinrPerceived[(*itTb).second.rbBitmap.at (i)]); -// } itTb++; } std::map harqDlInfoMap; diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 7607b82cd..83e83e16c 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -1380,7 +1380,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::Sched for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - rbMap.at (j) = false; + rbMap.at (j) = true; // store info on allocation for managing ul-cqi interpretation rbgAllocationMap.at (j) = (*it).first; NS_LOG_DEBUG ("\t " << j); diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index b4d40e350..da4ebcff6 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -1216,7 +1216,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::Sched for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++) { - rbMap.at (j) = false; + rbMap.at (j) = true; // store info on allocation for managing ul-cqi interpretation rbgAllocationMap.at (j) = (*it).first; NS_LOG_DEBUG ("\t " << j); diff --git a/src/lte/test/lte-test-harq.cc b/src/lte/test/lte-test-harq.cc new file mode 100644 index 000000000..2b1abd526 --- /dev/null +++ b/src/lte/test/lte-test-harq.cc @@ -0,0 +1,258 @@ +/* -*- 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lte-test-harq.h" + +NS_LOG_COMPONENT_DEFINE ("LenaTestHarq"); + +namespace ns3 { + + +LenaTestHarqSuite::LenaTestHarqSuite () + : TestSuite ("lte-harq", SYSTEM) +{ + NS_LOG_INFO ("creating LenaTestHarqTestCase"); + + + // Tests on DL/UL Data channels (PDSCH, PUSCH) + // MCS 0 TB size of 41 bytes SINR -17 expected throughput 19248 bytes + // TBLER 1st tx 1.0 + // TBLER 2nd tx 0.23 + AddTestCase (new LenaHarqTestCase (2, 4000, 41, 0.17, 19248)); + + // Tests on DL/UL Data channels (PDSCH, PUSCH) + // MCS 10 TB size of 469 bytes SINR 4 expected throughput 236096 bytes + // TBLER 1st tx 1.0 + // TBLER 2nd tx 0.0138 + AddTestCase (new LenaHarqTestCase (1, 640, 41, 0.02, 236096)); + + + +} + +static LenaTestHarqSuite lenaTestHarqSuite; + +std::string +LenaHarqTestCase::BuildNameString (uint16_t nUser, uint16_t dist) +{ + std::ostringstream oss; + oss << nUser << " UEs, distance " << dist << " m"; + return oss.str (); +} + +LenaHarqTestCase::LenaHarqTestCase (uint16_t nUser, uint16_t dist, uint16_t tbSize, double amcBer, double thrRef) + : TestCase (BuildNameString (nUser, dist)), + m_nUser (nUser), + m_dist (dist), + m_tbSize (tbSize), + m_amcBer (amcBer), + m_throughputRef (thrRef) +{ +} + +LenaHarqTestCase::~LenaHarqTestCase () +{ +} + +void +LenaHarqTestCase::DoRun (void) +{ + + Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (m_amcBer)); + 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::RrFfMacScheduler::HarqEnabled", BooleanValue (false)); +// LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL); +// LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL); +// LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL); +// LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL); +// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL); +// +// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); +// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); +// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); + +// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL); +// LogComponentEnable ("LteInterference", LOG_LEVEL_ALL); +// LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL); +// +// LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL); +// LogComponentEnable ("LossModel", LOG_LEVEL_ALL); +// LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL); +// LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL); +// LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL); +// LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL); +// +// LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL); +// LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL); +// LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL); + +// LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL); +// LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL); +// LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL); + + +// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL); +// LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL); +// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); +// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); +// LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL); +// LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL); +// LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); +// LogComponentEnable ("LteMiErrorModel", LOG_LEVEL_ALL); +// LogComponentEnable ("LteAmc", LOG_LEVEL_ALL); +// +// LogComponentDisableAll (LOG_LEVEL_ALL); + + LogComponentEnable ("LenaTestHarq", LOG_LEVEL_ALL); + + + /** + * Initialize Simulation Scenario: 1 eNB and m_nUser UEs + */ + + Ptr lena = CreateObject (); + + // Create Nodes: eNodeB and UE + NodeContainer enbNodes; + NodeContainer ueNodes; + enbNodes.Create (1); + ueNodes.Create (m_nUser); + + // Install Mobility Model + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::BuildingsMobilityModel"); + mobility.Install (enbNodes); + mobility.SetMobilityModel ("ns3::BuildingsMobilityModel"); + mobility.Install (ueNodes); + + // remove random shadowing component + lena->SetAttribute ("PathlossModel", StringValue ("ns3::HybridBuildingsPropagationLossModel")); + lena->SetPathlossModelAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); + lena->SetPathlossModelAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); + lena->SetPathlossModelAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); + + // Create Devices and install them in the Nodes (eNB and UE) + NetDeviceContainer enbDevs; + NetDeviceContainer ueDevs; + lena->SetSchedulerType ("ns3::RrFfMacScheduler"); + lena->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI)); + + enbDevs = lena->InstallEnbDevice (enbNodes); + ueDevs = lena->InstallUeDevice (ueNodes); + + // Attach a UE to a eNB + lena->Attach (ueDevs, enbDevs.Get (0)); + + // Activate an EPS bearer + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q); + lena->ActivateDataRadioBearer (ueDevs, bearer); + + + Ptr lteEnbDev = enbDevs.Get (0)->GetObject (); + Ptr enbPhy = lteEnbDev->GetPhy (); + enbPhy->SetAttribute ("TxPower", DoubleValue (43.0)); + enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0)); + // place the HeNB over the default rooftop level (20 mt.) + Ptr mm = enbNodes.Get (0)->GetObject (); + mm->SetPosition (Vector (0.0, 0.0, 30.0)); + + // Set UEs' position and power + for (int i = 0; i < m_nUser; i++) + { + Ptr mm = ueNodes.Get (i)->GetObject (); + mm->SetPosition (Vector (m_dist, 0.0, 1.0)); + Ptr lteUeDev = ueDevs.Get (i)->GetObject (); + Ptr uePhy = lteUeDev->GetPhy (); + uePhy->SetAttribute ("TxPower", DoubleValue (23.0)); + uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0)); + } + + lena->EnableRlcTraces (); + double simulationTime = 1.000; + + Simulator::Stop (Seconds (simulationTime)); + + Ptr rlcStats = lena->GetRlcStats (); + rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime))); + + + Simulator::Run (); + + /** + * Check that the assignation is done in a RR fashion + */ + NS_LOG_INFO ("\tTest on downlink data shared channels (PDSCH)"); + NS_LOG_INFO ("Test with " << m_nUser << " user(s) at distance " << m_dist << " expected Thr " << m_throughputRef); + std::vector dlDataRxed; + for (int i = 0; i < m_nUser; i++) + { + // get the imsi + uint64_t imsi = ueDevs.Get (i)->GetObject ()->GetImsi (); + // get the lcId + uint8_t lcId = ueDevs.Get (i)->GetObject ()->GetRrc ()->GetLcIdVector ().at (0); + dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId)); + double txed = rlcStats->GetDlTxData (imsi, lcId); + double tolerance = 0.1; + NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " txed " << txed << " thr Ref " << m_throughputRef << " Err " << (abs (txed - m_throughputRef)) / m_throughputRef); + // the quantiles are evaluated offline according to a Bernoulli + // ditribution with n equal to the number of packet sent and p equal + // to the BER (see /reference/bernuolliDistribution.m for details) + NS_TEST_ASSERT_MSG_EQ_TOL (txed, m_throughputRef, m_throughputRef * tolerance, " Unexpected Throughput!"); + } + + + Simulator::Destroy (); +} + + +} // namespace diff --git a/src/lte/test/lte-test-harq.h b/src/lte/test/lte-test-harq.h new file mode 100644 index 000000000..84ddea59f --- /dev/null +++ b/src/lte/test/lte-test-harq.h @@ -0,0 +1,71 @@ +/* -*- 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 + */ + +#ifndef LENA_TEST_HARQ_H +#define LENA_TEST_HARQ_H + +#include "ns3/simulator.h" +#include "ns3/test.h" + + +namespace ns3 { + + +/** + * This system test program creates different test cases with a single eNB and + * several UEs, all having the same Radio Bearer specification. In each test + * case, the UEs see the same SINR from the eNB; different test cases are + * implemented obtained by using different SINR values and different numbers of + * UEs. The test consists on ... + */ +class LenaHarqTestCase : public TestCase +{ +public: + LenaHarqTestCase (uint16_t nUser, uint16_t dist, uint16_t tbSize, double amcBer, double thrRef); + virtual ~LenaHarqTestCase (); + +private: + virtual void DoRun (void); + static std::string BuildNameString (uint16_t nUser, uint16_t dist); + uint16_t m_nUser; + uint16_t m_dist; + uint16_t m_tbSize; + double m_amcBer; + double m_throughputRef; + +}; + + + + + +class LenaTestHarqSuite : public TestSuite +{ +public: + LenaTestHarqSuite (); +}; + + + + +} // namespace ns3 + + +#endif /* LENA_TEST_HARQ_H */ diff --git a/src/lte/test/lte-test-phy-error-model.cc b/src/lte/test/lte-test-phy-error-model.cc index eac67478c..946b7dca9 100644 --- a/src/lte/test/lte-test-phy-error-model.cc +++ b/src/lte/test/lte-test-phy-error-model.cc @@ -73,7 +73,7 @@ LenaTestPhyErrorModelrSuite::LenaTestPhyErrorModelrSuite () // Tests on DL/UL Data channels (PDSCH, PUSCH) // MCS 2 TB size of 256 bits BER 0.33 SINR -5.51 - AddTestCase (new LenaDataPhyErrorModelTestCase (4, 1800, 32, 0.35, 50)); + AddTestCase (new LenaDataPhyErrorModelTestCase (4, 1800, 32, 0.33, 50)); // MCS 2 TB size of 528 bits BER 0.11 SINR -5.51 AddTestCase (new LenaDataPhyErrorModelTestCase (2, 1800, 66, 0.11, 34)); // MCS 2 TB size of 1088 bits BER 0.02 SINR -5.51