diff --git a/src/buildings/test/buildings-pathloss-test.cc b/src/buildings/test/buildings-pathloss-test.cc index c6484b224..344936c78 100644 --- a/src/buildings/test/buildings-pathloss-test.cc +++ b/src/buildings/test/buildings-pathloss-test.cc @@ -203,6 +203,7 @@ BuildingsPathlossTestCase::DoRun (void) NS_LOG_INFO ("Theoretical loss: " << m_lossRef); NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !"); + Simulator::Destroy (); } Ptr diff --git a/src/buildings/test/buildings-shadowing-test.cc b/src/buildings/test/buildings-shadowing-test.cc index 54c629df9..1bd6aa5d4 100644 --- a/src/buildings/test/buildings-shadowing-test.cc +++ b/src/buildings/test/buildings-shadowing-test.cc @@ -135,6 +135,7 @@ BuildingsShadowingTestCase::DoRun (void) NS_LOG_INFO ("Mean from simulation " << mean << ", sigma " << sigma << ", reference value " << m_sigmaRef << ", CI(99%) " << ci); NS_TEST_ASSERT_MSG_EQ_TOL (fabs (mean), 0.0, ci, "Wrong shadowing distribution !"); + Simulator::Destroy (); } diff --git a/src/lte/examples/lena-epc-first.cc b/src/lte/examples/lena-epc-first.cc index b8ec256f0..55775bf76 100644 --- a/src/lte/examples/lena-epc-first.cc +++ b/src/lte/examples/lena-epc-first.cc @@ -56,7 +56,7 @@ main (int argc, char *argv[]) Ptr lteHelper = CreateObject (); Ptr epcHelper = CreateObject (); lteHelper->SetEpcHelper (epcHelper); - //lteHelper->SetSchedulerType("ns3::RrFfMacScheduler"); + lteHelper->SetSchedulerType("ns3::RrFfMacScheduler"); ConfigStore inputConfig; inputConfig.ConfigureDefaults(); diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index cb9587af0..b375d60f1 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -539,8 +539,24 @@ LenaHelper::EnableLogComponents (void) std::string propModelStr = m_dlPathlossModelFactory.GetTypeId ().GetName ().erase (0,5).c_str (); const char* propModel = m_dlPathlossModelFactory.GetTypeId ().GetName ().erase (0,5).c_str (); - LogComponentEnable (propModel, LOG_LEVEL_ALL); - if (m_fadingModelType.compare ( "ns3::TraceFadingLossModel") == 0) + if (propModelStr.compare ("RandomPropagationLossModel") || + propModelStr.compare ("FriisPropagationLossModel")|| + propModelStr.compare ("TwoRayGroundPropagationLossModel")|| + propModelStr.compare ("LogDistancePropagationLossModel")|| + propModelStr.compare ("ThreeLogDistancePropagationLossModel")|| + propModelStr.compare ("NakagamiPropagationLossModel")|| + propModelStr.compare ("FixedRssLossModel")|| + propModelStr.compare ("MatrixPropagationLossModel")|| + propModelStr.compare ("RangePropagationLossModel")) + { + LogComponentEnable ("PropagationLossModel", LOG_LEVEL_ALL); + } + else + { + LogComponentEnable (propModel, LOG_LEVEL_ALL); + } + + if (m_fadingModelType.compare ("ns3::TraceFadingLossModel") == 0) { const char* fadingModel = m_fadingModelType.erase (0,5).c_str (); LogComponentEnable (fadingModel, LOG_LEVEL_ALL); diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index 908784358..38fc0f226 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -538,7 +538,15 @@ LteEnbMac::DoReceivePhyPdu (Ptr p) } else { - (*it).second.m_ulReception.at (tag.GetLcid () - 1) += p->GetSize (); + if ((*it).second.m_ulReception.size () < tag.GetLcid ()) + { + std::vector ::iterator itV = (*it).second.m_ulReception.begin (); + (*it).second.m_ulReception.insert (itV + (tag.GetLcid () - 1), p->GetSize ()); + } + else + { + (*it).second.m_ulReception.at (tag.GetLcid () - 1) += p->GetSize (); + } (*it).second.m_receptionStatus = UlInfoListElement_s::Ok; } diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index fefd16448..f9aae94a8 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -397,8 +397,6 @@ LteEnbPhy::StartSubFrame (void) } // trigger the MAC - Ptr macEntity = GetDevice ()->GetObject ()->GetMac (); - m_enbPhySapUser->SubframeIndication (m_nrFrames, m_nrSubFrames); diff --git a/src/lte/model/lte-ue-mac.cc b/src/lte/model/lte-ue-mac.cc index 3457e6db3..55b4e80e7 100644 --- a/src/lte/model/lte-ue-mac.cc +++ b/src/lte/model/lte-ue-mac.cc @@ -31,6 +31,7 @@ #include "lte-mac-tag.h" #include #include +#include NS_LOG_COMPONENT_DEFINE ("LteUeMac"); @@ -161,7 +162,7 @@ UeMemberLteUePhySapUser::ReceivePhyPdu (Ptr p) void UeMemberLteUePhySapUser::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) { - NS_LOG_LOGIC (this << " UE-MAC does not yet support this primitive"); + m_mac->DoSubframeIndication (frameNo, subframeNo); } void @@ -189,6 +190,9 @@ LteUeMac::GetTypeId (void) LteUeMac::LteUeMac () + : m_bsrPeriodicity (MilliSeconds (1)), // ideal behavior + m_bsrLast (MilliSeconds (0)) + { NS_LOG_FUNCTION (this); m_macSapProvider = new UeMemberLteMacSapProvider (this); @@ -263,24 +267,51 @@ void LteUeMac::DoReportBufferStatus (LteMacSapProvider::ReportBufferStatusParameters params) { NS_LOG_FUNCTION (this); - MacCeListElement_s bsr; - bsr.m_rnti = m_rnti; - bsr.m_macCeType = MacCeListElement_s::BSR; - // short BSR - int queue = params.txQueueSize; - int index = 0; - if (BufferSizeLevelBsr[63] < queue) + + std::map ::iterator it; + + + it = m_ulBsrReceived.find (params.lcid); + if (it!=m_ulBsrReceived.end ()) { - index = 63; + // update entry + (*it).second = params.txQueueSize + params.retxQueueSize + params.statusPduSize; } else { - while (BufferSizeLevelBsr[index] < queue) - { - index++; - } + m_ulBsrReceived.insert (std::pair (params.lcid, params.txQueueSize + params.retxQueueSize + params.statusPduSize)); + } +} + + +void +LteUeMac::SendReportBufferStatus (void) +{ + NS_LOG_FUNCTION (this); + MacCeListElement_s bsr; + bsr.m_rnti = m_rnti; + bsr.m_macCeType = MacCeListElement_s::BSR; + // BSR + std::map ::iterator it; + NS_ASSERT_MSG (m_ulBsrReceived.size () <=4, " Too many LCs (max is 4)"); + + for (it = m_ulBsrReceived.begin (); it != m_ulBsrReceived.end (); it++) + { + int queue = (*it).second; + int index = 0; + if (BufferSizeLevelBsr[63] < queue) + { + index = 63; + } + else + { + while (BufferSizeLevelBsr[index] < queue) + { + index++; + } + } + bsr.m_macCeValue.m_bufferStatus.push_back (index); } - bsr.m_macCeValue.m_bufferStatus.push_back (index); // create the feedback to eNB Ptr msg = Create (); @@ -336,9 +367,33 @@ LteUeMac::DoReceiveIdealControlMessage (Ptr msg) { Ptr msg2 = DynamicCast (msg); UlDciListElement_s dci = msg2->GetDci (); - std::map ::iterator it; - it = m_macSapUserMap.begin (); // use only the first LC --> UE-SCHEDULER?? - (*it).second->NotifyTxOpportunity (dci.m_tbSize); + std::map ::iterator itBsr; + NS_ASSERT_MSG (m_ulBsrReceived.size () <=4, " Too many LCs (max is 4)"); + int activeLcs = 0; + for (itBsr = m_ulBsrReceived.begin (); itBsr != m_ulBsrReceived.end (); itBsr++) + { + if ((*itBsr).second > 0) + { + activeLcs++; + } + } + if (activeLcs <= 0) + { + NS_LOG_ERROR (this << " No active flows for this UL-DCI"); + return; + } + std::map ::iterator it; + NS_LOG_FUNCTION (this << " UE: UL-CQI notified TxOpportunity of " << dci.m_tbSize); + for (it = m_macSapUserMap.begin (); it!=m_macSapUserMap.end (); it++) + { + itBsr = m_ulBsrReceived.find ((*it).first); + if (itBsr!=m_ulBsrReceived.end ()) + { + NS_LOG_FUNCTION (this << "\t" << dci.m_tbSize / m_macSapUserMap.size () << " bytes to LC " << (uint16_t)(*it).first << " queue " << (*itBsr).second); + (*it).second->NotifyTxOpportunity (dci.m_tbSize / activeLcs); + (*itBsr).second -= dci.m_tbSize / activeLcs; + } + } } else @@ -348,4 +403,16 @@ LteUeMac::DoReceiveIdealControlMessage (Ptr msg) } +void +LteUeMac::DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo) +{ + NS_LOG_FUNCTION (this); + if (Simulator::Now () >= m_bsrLast + m_bsrPeriodicity) + { + SendReportBufferStatus (); + m_bsrLast = Simulator::Now (); + } +} + + } // namespace ns3 diff --git a/src/lte/model/lte-ue-mac.h b/src/lte/model/lte-ue-mac.h index 26cba7264..1384af8b9 100644 --- a/src/lte/model/lte-ue-mac.h +++ b/src/lte/model/lte-ue-mac.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace ns3 { @@ -62,6 +63,14 @@ public: * \param s a pointer to the PHY SAP Provider */ void SetLteUePhySapProvider (LteUePhySapProvider* s); + + /** + * \brief Forwarded from LteUePhySapUser: trigger the start from a new frame + * + * \param frameNo frame number + * \param subframeNo subframe number + */ + void DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo); private: // forwarded from MAC SAP @@ -76,6 +85,8 @@ private: // forwarded from PHY SAP void DoReceivePhyPdu (Ptr p); void DoReceiveIdealControlMessage (Ptr msg); + + void SendReportBufferStatus (void); private: // end of temporary hack @@ -87,6 +98,11 @@ private: LteUePhySapProvider* m_uePhySapProvider; LteUePhySapUser* m_uePhySapUser; + + std::map m_ulBsrReceived; // BSR received from RLC (BSR up to now) + + Time m_bsrPeriodicity; + Time m_bsrLast; uint16_t m_rnti; diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 2f7f074c5..0b98c57b9 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -491,6 +491,9 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) { m_uplinkSpectrumPhy->StartTx (pb); } + + // trigger the MAC + m_uePhySapUser->SubframeIndication (frameNo, subframeNo); } diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index f556aa734..ab330ccbb 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -321,16 +321,20 @@ RrFfMacScheduler::DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::Sch { NS_LOG_FUNCTION (this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::list::iterator it; + std::list::iterator it = m_rlcBufferReq.begin (); bool newLc = true; - for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++) + while (it != m_rlcBufferReq.end ()) { // remove old entries of this UE-LC if (((*it).m_rnti == params.m_rnti)&&((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity)) { - m_rlcBufferReq.erase (it); + it = m_rlcBufferReq.erase (it); newLc = false; } + else + { + ++it; + } } // add the new parameters m_rlcBufferReq.insert (it, params); diff --git a/src/lte/test/lte-test-downlink-sinr.cc b/src/lte/test/lte-test-downlink-sinr.cc index 041d12fd9..fdcf67d23 100644 --- a/src/lte/test/lte-test-downlink-sinr.cc +++ b/src/lte/test/lte-test-downlink-sinr.cc @@ -252,7 +252,6 @@ LteDownlinkSinrTestCase::DoRun (void) Simulator::Stop (Seconds (5.0)); Simulator::Run (); - Simulator::Destroy (); /** * Check that the values passed to LteSinrChunkProcessor::EvaluateSinrChunk () correspond @@ -264,4 +263,6 @@ LteDownlinkSinrTestCase::DoRun (void) NS_LOG_INFO ("Calculated SINR: " << calculatedSinr); NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(calculatedSinr, *m_sinr, 0.0000001, "Wrong SINR !"); + dlPhy->Dispose (); + Simulator::Destroy (); } diff --git a/src/lte/test/lte-test-interference.cc b/src/lte/test/lte-test-interference.cc index cf89c3330..fa8cd127e 100644 --- a/src/lte/test/lte-test-interference.cc +++ b/src/lte/test/lte-test-interference.cc @@ -113,7 +113,7 @@ void LteInterferenceTestCase::DoRun (void) { Ptr lena = CreateObject (); - // lena->EnableLogComponents (); +// lena->EnableLogComponents (); lena->EnableMacTraces (); lena->EnableRlcTraces (); lena->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel")); @@ -163,7 +163,6 @@ LteInterferenceTestCase::DoRun (void) lena->ActivateEpsBearer (ueDevs1, bearer, LteTft::Default ()); lena->ActivateEpsBearer (ueDevs2, bearer, LteTft::Default ()); - // Use testing chunk processor in the PHY layer // It will be used to test that the SNR is as intended // we plug in two instances, one for DL and one for UL @@ -200,8 +199,9 @@ LteInterferenceTestCase::DoRun (void) MakeBoundCallback (&LteTestUlSchedulingCallback, this)); - Simulator::Stop (Seconds (0.005)); + Simulator::Stop (Seconds (0.006)); Simulator::Run (); + double dlSinr1Db = 10.0 * log10 (testDlSinr1->GetSinr ()[0]); NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)"); @@ -211,7 +211,7 @@ LteInterferenceTestCase::DoRun (void) double dlSinr2Db = 10.0 * log10 (testDlSinr2->GetSinr ()[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 ()[0]); NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)"); @@ -241,10 +241,10 @@ LteInterferenceTestCase::UlScheduling (uint32_t frameNo, uint32_t subframeNo, ui { /** * Note: - * For first 4 subframeNo in the first frameNo, the MCS cannot be properly evaluated, + * For first 5 subframeNo in the first frameNo, the MCS cannot be properly evaluated, * because CQI feedback is still not available at the eNB. */ - if ( (frameNo > 1) || (subframeNo > 4) ) + if ( (frameNo > 1) || (subframeNo > 5) ) { NS_TEST_ASSERT_MSG_EQ ((uint16_t)mcs, m_ulMcs, "Wrong UL MCS"); } diff --git a/src/lte/test/lte-test-uplink-sinr.cc b/src/lte/test/lte-test-uplink-sinr.cc index e1d35f277..11280f5b3 100644 --- a/src/lte/test/lte-test-uplink-sinr.cc +++ b/src/lte/test/lte-test-uplink-sinr.cc @@ -292,7 +292,6 @@ LteUplinkSinrTestCase::DoRun (void) Simulator::Stop (Seconds (5.0)); Simulator::Run (); - Simulator::Destroy (); /** * Check that the values passed to LteSinrChunkProcessor::EvaluateSinrChunk () correspond @@ -304,4 +303,7 @@ LteUplinkSinrTestCase::DoRun (void) NS_LOG_INFO ("Calculated SINR: " << calculatedSinr); NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL (calculatedSinr, *m_sinr, 0.0000001, "Wrong SINR !"); + ulPhy->Dispose (); + Simulator::Destroy (); + }