diff --git a/src/lte/examples/lena-first-sim.cc b/src/lte/examples/lena-first-sim.cc index 8cb130595..e7c1d0aef 100644 --- a/src/lte/examples/lena-first-sim.cc +++ b/src/lte/examples/lena-first-sim.cc @@ -48,10 +48,11 @@ int main (int argc, char *argv[]) //lena->EnableLogComponents (); - // LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL); LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); // LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); -// LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL); + LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL); + LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL); LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL); LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); @@ -60,7 +61,7 @@ int main (int argc, char *argv[]) NodeContainer enbNodes; NodeContainer ueNodes; enbNodes.Create (1); - ueNodes.Create (1); + ueNodes.Create (3); // Install Mobility Model MobilityHelper mobility; @@ -72,8 +73,8 @@ int main (int argc, char *argv[]) // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; - //lena->SetSchedulerType ("ns3::RrFfMacScheduler"); - lena->SetSchedulerType ("ns3::PfFfMacScheduler"); + lena->SetSchedulerType ("ns3::RrFfMacScheduler"); +// lena->SetSchedulerType ("ns3::PfFfMacScheduler"); enbDevs = lena->InstallEnbDevice (enbNodes); ueDevs = lena->InstallUeDevice (ueNodes); @@ -83,7 +84,11 @@ int main (int argc, char *argv[]) // Activate an EPS bearer enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); + EpsBearer bearer1 (q); + EpsBearer bearer2 (q); lena->ActivateEpsBearer (ueDevs, bearer); + lena->ActivateEpsBearer (ueDevs, bearer1); + lena->ActivateEpsBearer (ueDevs, bearer2); Simulator::Stop (Seconds (0.005)); @@ -96,3 +101,4 @@ int main (int argc, char *argv[]) Simulator::Destroy (); return 0; } + diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index fefd16448..856bf442f 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -381,6 +381,14 @@ LteEnbPhy::StartSubFrame (void) else { (*it2).second->ReceiveIdealControlMessage (msg); + // send info of TB to LteSpectrumPhy + // translate to allocation map + std::vector rbMap; + for (int i = dci->GetDci ().m_rbStart; i < dci->GetDci ().m_rbStart + dci->GetDci ().m_rbLen; i++) + { + rbMap.push_back (i); + } + m_uplinkSpectrumPhy->AddExpectedTb (dci->GetDci ().m_rnti, dci->GetDci ().m_tbSize, dci->GetDci ().m_mcs, rbMap); } } ctrlMsg.pop_front (); diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index c82f4c865..c22684be7 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -50,6 +50,7 @@ LteSpectrumPhy::LteSpectrumPhy () LteSpectrumPhy::~LteSpectrumPhy () { NS_LOG_FUNCTION (this); + m_expectedTbs.clear (); } void LteSpectrumPhy::DoDispose () @@ -223,6 +224,24 @@ LteSpectrumPhy::ChangeState (State newState) m_state = newState; } +void +LteSpectrumPhy::AddExpectedTb (uint16_t rnti, uint16_t size, uint8_t mcs, std::vector map) +{ + NS_LOG_LOGIC (this << " rnti: " << rnti << " size " << size << " mcs " << mcs); + expectedTbs_t::iterator it; + it = m_expectedTbs.find (rnti); + if (it == m_expectedTbs.end ()) + { + // insert new entry + tbInfo_t tbInfo = {size, mcs, map, false}; + m_expectedTbs.insert (std::pair (rnti,tbInfo )); + } + else + { + NS_FATAL_ERROR ("Expectd two TBs from the same UE"); + } +} + bool LteSpectrumPhy::StartTx (Ptr pb) @@ -404,14 +423,22 @@ LteSpectrumPhy::EndRx () // this will trigger CQI calculation and Error Model evaluation // as a side effect, the error model should update the error status of all TBs m_interference->EndRx (); - + NS_LOG_INFO (this << " No. of burts " << m_rxPacketBurstList.size ()); + NS_LOG_DEBUG (this << " Expected TBs " << m_expectedTbs.size ()); + expectedTbs_t::iterator itTb = m_expectedTbs.begin (); + while (itTb!=m_expectedTbs.end ()) + { + NS_LOG_DEBUG (this << "RNTI " << (*itTb).first << " size " << (*itTb).second.size << " mcs " << (*itTb).second.mcs); + itTb++; + } + m_expectedTbs.clear (); // DEBUG for (std::list >::const_iterator i = m_rxPacketBurstList.begin (); i != m_rxPacketBurstList.end (); ++i) { // here we should determine whether this TB has been received // correctly or not bool tbRxOk = true; - + NS_LOG_INFO (this << " Burst of " << (*i)->GetNPackets ()); if (tbRxOk) { m_phyRxEndOkTrace (*i); diff --git a/src/lte/model/lte-spectrum-phy.h b/src/lte/model/lte-spectrum-phy.h index 7f0b7b464..dee9e3f87 100644 --- a/src/lte/model/lte-spectrum-phy.h +++ b/src/lte/model/lte-spectrum-phy.h @@ -35,9 +35,21 @@ #include #include #include +#include namespace ns3 { + +struct tbInfo_t +{ + uint16_t size; + uint8_t mcs; + std::vector rbBitmap; + bool corrupt; +}; + +typedef std::map expectedTbs_t; + class LteNetDevice; /** @@ -143,6 +155,16 @@ public: * \param p the new LteSinrChunkProcessor to be added to the processing chain */ void AddSinrChunkProcessor (Ptr p); + + /** + * + * + * \param rnti the rnti of the source of the TB + * \param size the size of the TB + * \param mcs the MCS of the TB + * \param map the map of RB(s) used + */ + void AddExpectedTb (uint16_t rnti, uint16_t size, uint8_t mcs, std::vector map); private: void ChangeState (State newState); @@ -175,7 +197,9 @@ private: Ptr m_interference; - uint16_t m_cellId; + uint16_t m_cellId; + + expectedTbs_t m_expectedTbs; }; diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 2f7f074c5..a76e3cd7a 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -433,6 +433,9 @@ LteUePhy::ReceiveIdealControlMessage (Ptr msg) } mask = (mask << 1); } + + // send TB info to LteSpectrumPhy + m_downlinkSpectrumPhy->AddExpectedTb (dci.m_rnti, dci.m_tbsSize.at (0), dci.m_mcs.at (0), dlRb); // SISO mode SetSubChannelsForReception (dlRb);