diff --git a/src/lte/helper/lte-helper.cc b/src/lte/helper/lte-helper.cc index 47bbb55a8..d39b98961 100644 --- a/src/lte/helper/lte-helper.cc +++ b/src/lte/helper/lte-helper.cc @@ -484,7 +484,7 @@ LteHelper::Attach (Ptr ueDevice, Ptr enbDevice) // connect at the PHY layer Ptr enbPhy = enbDevice->GetObject ()->GetPhy (); Ptr uePhy = ueDevice->GetObject ()->GetPhy (); - enbPhy->AddUePhy (rnti, uePhy); + enbPhy->AddUePhy (rnti); // // WILD HACK - should be done through PHY SAP, probably passing by RRC diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index aa9908079..239011b36 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -42,6 +42,14 @@ NS_LOG_COMPONENT_DEFINE ("LteEnbPhy"); namespace ns3 { +// duration of the data part of a subframe in DL +// = 0.001 / 14 * 11 (fixed to 11 symbols) -1ns as margin to avoid overlapping simulator events +static const Time DL_DATA_DURATION = NanoSeconds (785714 -1); + +// delay from subframe start to transmission of the data in DL +// = 0.001 / 14 * 3 (ctrl fixed to 3 symbols) +static const Time DL_CTRL_DELAY_FROM_SUBFRAME_START = NanoSeconds (214286); + //////////////////////////////////////// // member SAP forwarders //////////////////////////////////////// @@ -267,13 +275,13 @@ LteEnbPhy::GetMacChDelay (void) const } bool -LteEnbPhy::AddUePhy (uint16_t rnti, Ptr phy) +LteEnbPhy::AddUePhy (uint16_t rnti) { - std::map >::iterator it; + std::set ::iterator it; it = m_ueAttached.find (rnti); if (it == m_ueAttached.end ()) { - m_ueAttached.insert (std::pair > (rnti, phy)); + m_ueAttached.insert (rnti); return (true); } else @@ -286,7 +294,7 @@ LteEnbPhy::AddUePhy (uint16_t rnti, Ptr phy) bool LteEnbPhy::DeleteUePhy (uint16_t rnti) { - std::map >::iterator it; + std::set ::iterator it; it = m_ueAttached.find (rnti); if (it == m_ueAttached.end ()) { @@ -422,7 +430,7 @@ LteEnbPhy::StartSubFrame (void) NS_LOG_DEBUG (this << " eNB Expected TBs " << uldcilist.size ()); for (dciIt = uldcilist.begin (); dciIt!=uldcilist.end (); dciIt++) { - std::map >::iterator it2; + std::set ::iterator it2; it2 = m_ueAttached.find ((*dciIt).GetDci ().m_rnti); if (it2 == m_ueAttached.end ()) @@ -493,7 +501,7 @@ LteEnbPhy::StartSubFrame (void) Ptr pb = GetPacketBurst (); if (pb) { - Simulator::Schedule (Seconds (0.000214286), // ctrl frame fixed to 3 symbols + Simulator::Schedule (DL_CTRL_DELAY_FROM_SUBFRAME_START, // ctrl frame fixed to 3 symbols &LteEnbPhy::SendDataChannels, this,pb); } @@ -501,15 +509,6 @@ LteEnbPhy::StartSubFrame (void) // trigger the MAC m_enbPhySapUser->SubframeIndication (m_nrFrames, m_nrSubFrames); - - // trigger the UE(s) - std::map >::iterator it; - for (it = m_ueAttached.begin (); it != m_ueAttached.end (); it++) - { - (*it).second->SubframeIndication (m_nrFrames, m_nrSubFrames); - } - - Simulator::Schedule (Seconds (GetTti ()), &LteEnbPhy::EndSubFrame, this); @@ -539,10 +538,9 @@ LteEnbPhy::SendDataChannels (Ptr pb) SetDownlinkSubChannels (m_dlDataRbMap); // send the current burts of packets NS_LOG_LOGIC (this << " eNB start TX DATA"); - double dlDataFrame = 0.000785714; // 0.001 / 14 * 11 (fixed to 11 symbols) std::list > ctrlMsgList; ctrlMsgList.clear (); - m_downlinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsgList, dlDataFrame); + m_downlinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsgList, DL_DATA_DURATION); } diff --git a/src/lte/model/lte-enb-phy.h b/src/lte/model/lte-enb-phy.h index e84a5be09..4485dfbd4 100644 --- a/src/lte/model/lte-enb-phy.h +++ b/src/lte/model/lte-enb-phy.h @@ -23,11 +23,15 @@ #define ENB_LTE_PHY_H -#include "lte-phy.h" #include -#include +#include #include +#include +#include + + + namespace ns3 { class PacketBurst; @@ -173,7 +177,7 @@ public: void DoSendLteControlMessage (Ptr msg); - bool AddUePhy (uint16_t rnti, Ptr phy); + bool AddUePhy (uint16_t rnti); bool DeleteUePhy (uint16_t rnti); @@ -233,7 +237,7 @@ public: private: - std::map > m_ueAttached; + std::set m_ueAttached; std::vector m_listOfDownlinkSubchannel; diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 5012358f2..8db7ef91e 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -41,7 +41,19 @@ NS_LOG_COMPONENT_DEFINE ("LteSpectrumPhy"); namespace ns3 { - + + + +// duration of SRS portion of UL subframe +// = 1 symbol for SRS -1ns as margin to avoid overlapping simulator events +static const Time UL_SRS_DURATION = NanoSeconds (71429 -1); + +// duration of the control portion of a subframe +// = 0.001 / 14 * 3 (ctrl fixed to 3 symbols) -1ns as margin to avoid overlapping simulator events +static const Time DL_CTRL_DURATION = NanoSeconds (214286 -1); + + + TbId_t::TbId_t () { @@ -130,7 +142,6 @@ std::ostream& operator<< (std::ostream& os, LteSpectrumPhy::State s) return os; } - TypeId LteSpectrumPhy::GetTypeId (void) { @@ -300,70 +311,9 @@ LteSpectrumPhy::ChangeState (State newState) } -bool -LteSpectrumPhy::StartTx (Ptr pb) -{ - NS_LOG_WARN (this << " Obsolete Function"); - NS_LOG_FUNCTION (this << pb); - NS_LOG_LOGIC (this << " state: " << m_state); - - m_phyTxStartTrace (pb); - - switch (m_state) - { - case RX_DATA: - case RX_CTRL: - NS_FATAL_ERROR ("cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception"); - break; - - case TX: - NS_FATAL_ERROR ("cannot TX while already TX: the MAC should avoid this"); - break; - - case IDLE: - { - /* - m_txPsd must be setted by the device, according to - (i) the available subchannel for transmission - (ii) the power transmission - */ - NS_ASSERT (m_txPsd); - m_txPacketBurst = pb; - - // we need to convey some PHY meta information to the receiver - // to be used for simulation purposes (e.g., the CellId). This - // is done by adding an LtePhyTag to the first packet in the - // burst. - NS_ASSERT (pb->Begin () != pb->End ()); - LtePhyTag tag (m_cellId); - Ptr firstPacketInBurst = *(pb->Begin ()); - firstPacketInBurst->AddPacketTag (tag); - - ChangeState (TX); - NS_ASSERT (m_channel); - double tti = 0.001; - Ptr txParams = Create (); - txParams->duration = Seconds (tti); - txParams->txPhy = GetObject (); - txParams->txAntenna = m_antenna; - txParams->psd = m_txPsd; - txParams->packetBurst = pb; - m_channel->StartTx (txParams); - Simulator::Schedule (Seconds (tti), &LteSpectrumPhy::EndTx, this); - } - return false; - break; - - default: - NS_FATAL_ERROR ("unknown state"); - return true; - break; - } -} - bool -LteSpectrumPhy::StartTxDataFrame (Ptr pb, std::list > ctrlMsgList, double duration) +LteSpectrumPhy::StartTxDataFrame (Ptr pb, std::list > ctrlMsgList, Time duration) { NS_LOG_FUNCTION (this << pb); NS_LOG_LOGIC (this << " state: " << m_state); @@ -398,7 +348,7 @@ LteSpectrumPhy::StartTxDataFrame (Ptr pb, std::list txParams = Create (); - txParams->duration = Seconds (duration); + txParams->duration = duration; txParams->txPhy = GetObject (); txParams->txAntenna = m_antenna; txParams->psd = m_txPsd; @@ -406,7 +356,7 @@ LteSpectrumPhy::StartTxDataFrame (Ptr pb, std::listctrlMsgList = ctrlMsgList; txParams->cellId = m_cellId; m_channel->StartTx (txParams); - Simulator::Schedule (Seconds (duration), &LteSpectrumPhy::EndTx, this); + Simulator::Schedule (duration, &LteSpectrumPhy::EndTx, this); } return false; break; @@ -452,16 +402,16 @@ LteSpectrumPhy::StartTxDlCtrlFrame (std::list > ctrlMsgLi // LteSpectrumSignalParametersDlCtrlFrame ChangeState (TX); NS_ASSERT (m_channel); - double dlCtrlFrame = 0.000214286; // 0.001 / 14 * 3 (fixed to 3 symbols) + Ptr txParams = Create (); - txParams->duration = Seconds (dlCtrlFrame); + txParams->duration = DL_CTRL_DURATION; txParams->txPhy = GetObject (); txParams->txAntenna = m_antenna; txParams->psd = m_txPsd; txParams->cellId = m_cellId; txParams->ctrlMsgList = ctrlMsgList; m_channel->StartTx (txParams); - Simulator::Schedule (Seconds (dlCtrlFrame), &LteSpectrumPhy::EndTx, this); + Simulator::Schedule (DL_CTRL_DURATION, &LteSpectrumPhy::EndTx, this); } return false; break; @@ -508,15 +458,14 @@ LteSpectrumPhy::StartTxUlSrsFrame () // LteSpectrumSignalParametersDlCtrlFrame ChangeState (TX); NS_ASSERT (m_channel); - double ulCtrlFrame = 0.000071429; // 0.001 / 14 * 1 (fixed to 1 symbols) Ptr txParams = Create (); - txParams->duration = Seconds (ulCtrlFrame); + txParams->duration = UL_SRS_DURATION; txParams->txPhy = GetObject (); txParams->txAntenna = m_antenna; txParams->psd = m_txPsd; txParams->cellId = m_cellId; m_channel->StartTx (txParams); - Simulator::Schedule (Seconds (ulCtrlFrame), &LteSpectrumPhy::EndTx, this); + Simulator::Schedule (UL_SRS_DURATION, &LteSpectrumPhy::EndTx, this); } return false; break; @@ -622,7 +571,7 @@ LteSpectrumPhy::StartRxData (Ptr params) // start RX m_firstRxStart = Simulator::Now (); m_firstRxDuration = params->duration; - NS_LOG_LOGIC (this << " scheduling EndRx with delay " << params->duration); + NS_LOG_LOGIC (this << " scheduling EndRx with delay " << params->duration.GetSeconds () << "s"); Simulator::Schedule (params->duration, &LteSpectrumPhy::EndRxData, this); } else diff --git a/src/lte/model/lte-spectrum-phy.h b/src/lte/model/lte-spectrum-phy.h index 5381b889e..ddab72fa6 100644 --- a/src/lte/model/lte-spectrum-phy.h +++ b/src/lte/model/lte-spectrum-phy.h @@ -174,17 +174,6 @@ public: * \param a the Antenna Model */ void SetAntenna (Ptr a); - - /** - * Start a transmission - * - * - * @param pb the burst of packets to be transmitted - * - * @return true if an error occurred and the transmission was not - * started, false otherwise. - */ - bool StartTx (Ptr pb); /** * Start a transmission of data frame in DL and UL @@ -192,12 +181,12 @@ public: * * @param pb the burst of packets to be transmitted in PDSCH/PUSCH * @param ctrlMsgList the list of LteControlMessage to send - * @param duration the duration of the data frame (in sec.) + * @param duration the duration of the data frame * * @return true if an error occurred and the transmission was not * started, false otherwise. */ - bool StartTxDataFrame (Ptr pb, std::list > ctrlMsgList, double duration); + bool StartTxDataFrame (Ptr pb, std::list > ctrlMsgList, Time duration); /** * Start a transmission of control frame in DL diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 6c3e33a22..1a87d46ef 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -42,6 +42,22 @@ NS_LOG_COMPONENT_DEFINE ("LteUePhy"); namespace ns3 { + + + +// duration of data portion of UL subframe +// = TTI - 1 symbol for SRS - 1ns as margin to avoid overlapping simulator events +// (symbol duration in nanoseconds = TTI / 14 (rounded)) +// in other words, duration of data portion of UL subframe = TTI*(13/14) -1ns +static const Time UL_DATA_DURATION = NanoSeconds (1e6 - 71429 - 1); + +// delay from subframe start to transmission of SRS +// = TTI - 1 symbol for SRS +static const Time UL_SRS_DELAY_FROM_SUBFRAME_START = NanoSeconds (1e6 - 71429); + + + + //////////////////////////////////////// // member SAP forwarders //////////////////////////////////////// @@ -99,6 +115,7 @@ UeMemberLteUePhySapProvider::SetSrsConfigurationIndex (uint16_t srcCi) m_phy->DoSetSrsConfigurationIndex (srcCi); } + //////////////////////////////////////// // generic LteUePhy methods //////////////////////////////////////// @@ -136,6 +153,8 @@ LteUePhy::LteUePhy (Ptr dlPhy, Ptr ulPhy) } std::vector ulRb; m_subChannelsForTransmissionQueue.resize (m_macChTtiDelay, ulRb); + + Simulator::ScheduleNow (&LteUePhy::SubframeIndication, this, 1, 1); } @@ -577,7 +596,7 @@ LteUePhy::QueueSubChannelsForTransmission (std::vector rbMap) void LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) { - // trigger from eNB + NS_LOG_LOGIC (this << frameNo << subframeNo); // update uplink transmission mask according to previous UL-CQIs SetSubChannelsForTransmission (m_subChannelsForTransmissionQueue.at (0)); @@ -599,11 +618,12 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) { m_srsCounter--; } - double dataFrame = 0.001 - 0.000071429; // 0.001 - 1 symbol for SRS + if (srs) { - Simulator::Schedule (Seconds (0.000928572), // (0.001/14) * 13 - &LteUePhy::SendSrs, this); + Simulator::Schedule (UL_SRS_DELAY_FROM_SUBFRAME_START, + &LteUePhy::SendSrs, + this); } @@ -614,7 +634,7 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) if (pb) { NS_LOG_LOGIC (this << " UE - start TX PUSCH + PUCCH"); - m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, dataFrame); + m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION); } else { @@ -627,7 +647,7 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) dlRb.push_back (i); } SetSubChannelsForTransmission (dlRb); - m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, dataFrame); + m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION); } } @@ -635,6 +655,16 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) // trigger the MAC m_uePhySapUser->SubframeIndication (frameNo, subframeNo); + + ++subframeNo; + if (subframeNo > 10) + { + ++frameNo; + subframeNo = 1; + } + + // schedule next subframe indication + Simulator::Schedule (Seconds (GetTti ()), &LteUePhy::SubframeIndication, this, frameNo, subframeNo); } void