diff --git a/src/lte/model/lte-ue-cphy-sap.h b/src/lte/model/lte-ue-cphy-sap.h index a8510e170..e0516f4cc 100644 --- a/src/lte/model/lte-ue-cphy-sap.h +++ b/src/lte/model/lte-ue-cphy-sap.h @@ -47,6 +47,12 @@ public: */ virtual ~LteUeCphySapProvider (); + /** + * reset the PHY + * + */ + virtual void Reset () = 0; + /** * tell the PHY to synchronize with a given eNB for communication purposes * @@ -125,6 +131,7 @@ public: MemberLteUeCphySapProvider (C* owner); // inherited from LteUeCphySapProvider + virtual void Reset (); virtual void SyncronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn); virtual void SetDlBandwidth (uint8_t ulBandwidth); virtual void ConfigureUplink (uint16_t ulEarfcn, uint8_t ulBandwidth); @@ -148,6 +155,13 @@ MemberLteUeCphySapProvider::MemberLteUeCphySapProvider () { } +template +void +MemberLteUeCphySapProvider::Reset () +{ + m_owner->DoReset (); +} + template void MemberLteUeCphySapProvider::SyncronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn) diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 7d5db7d46..82de81a4a 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -117,42 +117,21 @@ LteUePhy::LteUePhy () LteUePhy::LteUePhy (Ptr dlPhy, Ptr ulPhy) : LtePhy (dlPhy, ulPhy), - m_p10CqiPeriocity (MilliSeconds (1)), - // ideal behavior - m_p10CqiLast (MilliSeconds (0)), - m_a30CqiPeriocity (MilliSeconds (1)), - // ideal behavior - m_a30CqiLast (MilliSeconds (0)), + m_p10CqiPeriocity (MilliSeconds (1)), // ideal behavior + m_a30CqiPeriocity (MilliSeconds (1)), // ideal behavior m_uePhySapUser (0), - m_ueCphySapUser (0), - m_rnti (0), - m_transmissionMode (0), - m_srsPeriodicity (0), - m_srsConfigured (false), - m_dlConfigured (false), - m_ulConfigured (false), - m_addedToDlChannel (false), - m_raPreambleId (255), // value out of range - m_raRnti (11), // value out of range - m_rsrpRsrqSampleCounter (0) + m_ueCphySapUser (0) { m_amc = CreateObject (); m_uePhySapProvider = new UeMemberLteUePhySapProvider (this); m_ueCphySapProvider = new MemberLteUeCphySapProvider (this); m_macChTtiDelay = UL_PUSCH_TTIS_DELAY; - for (int i = 0; i < m_macChTtiDelay; i++) - { - Ptr pb = CreateObject (); - m_packetBurstQueue.push_back (pb); - std::list > l; - m_controlMessagesQueue.push_back (l); - } - std::vector ulRb; - m_subChannelsForTransmissionQueue.resize (m_macChTtiDelay, ulRb); - + NS_ASSERT_MSG (Simulator::Now ().GetNanoSeconds () == 0, "Cannot create UE devices after simulation started"); Simulator::ScheduleNow (&LteUePhy::SubframeIndication, this, 1, 1); + + DoReset (); } @@ -709,9 +688,9 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) if ((((frameNo-1)*10 + (subframeNo-1)) % m_srsPeriodicity) == m_srsSubframeOffset) { NS_LOG_INFO ("frame " << frameNo << " subframe " << subframeNo << " sending SRS (offset=" << m_srsSubframeOffset << ", period=" << m_srsPeriodicity << ")"); - Simulator::Schedule (UL_SRS_DELAY_FROM_SUBFRAME_START, - &LteUePhy::SendSrs, - this); + m_sendSrsEvent = Simulator::Schedule (UL_SRS_DELAY_FROM_SUBFRAME_START, + &LteUePhy::SendSrs, + this); } } @@ -772,6 +751,38 @@ LteUePhy::SendSrs () } +void +LteUePhy::DoReset () +{ + NS_LOG_FUNCTION (this); + + m_rnti = 0; + m_transmissionMode = 0; + m_srsPeriodicity = 0; + m_srsConfigured = false; + m_dlConfigured = false; + m_ulConfigured = false; + m_raPreambleId = 255; // value out of range + m_raRnti = 11; // value out of range + m_rsrpRsrqSampleCounter = 0; + m_p10CqiLast = Simulator::Now (); + m_a30CqiLast = Simulator::Now (); + + m_packetBurstQueue.clear (); + m_controlMessagesQueue.clear (); + m_subChannelsForTransmissionQueue.clear (); + for (int i = 0; i < m_macChTtiDelay; i++) + { + Ptr pb = CreateObject (); + m_packetBurstQueue.push_back (pb); + std::list > l; + m_controlMessagesQueue.push_back (l); + } + std::vector ulRb; + m_subChannelsForTransmissionQueue.resize (m_macChTtiDelay, ulRb); + + m_sendSrsEvent.Cancel (); +} void LteUePhy::DoSyncronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn) diff --git a/src/lte/model/lte-ue-phy.h b/src/lte/model/lte-ue-phy.h index 773f53616..0b302c91c 100644 --- a/src/lte/model/lte-ue-phy.h +++ b/src/lte/model/lte-ue-phy.h @@ -216,6 +216,7 @@ private: void QueueSubChannelsForTransmission (std::vector rbMap); // UE CPHY SAP methods + void DoReset (); void DoSyncronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn); void DoSetDlBandwidth (uint8_t ulBandwidth); void DoConfigureUplink (uint16_t ulEarfcn, uint8_t ulBandwidth); @@ -262,7 +263,6 @@ private: bool m_dlConfigured; bool m_ulConfigured; - bool m_addedToDlChannel; Ptr m_harqPhyModule; @@ -277,6 +277,8 @@ private: uint16_t m_rsrpRsrqSamplePeriod; uint16_t m_rsrpRsrqSampleCounter; + EventId m_sendSrsEvent; + }; diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 9a001c1dd..97db3ea47 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -608,6 +608,8 @@ LteUeRrc::DoRecvRrcConnectionReconfiguration (LteRrcSap::RrcConnectionReconfigur SwitchToState (CONNECTED_HANDOVER); const LteRrcSap::MobilityControlInfo& mci = msg.mobilityControlInfo; m_handoverStartTrace (m_imsi, m_cellId, m_rnti, mci.targetPhysCellId); + m_cmacSapProvider->Reset (); + m_cphySapProvider->Reset (); m_cellId = mci.targetPhysCellId; NS_ASSERT (mci.haveCarrierFreq); NS_ASSERT (mci.haveCarrierBandwidth); @@ -616,7 +618,6 @@ LteUeRrc::DoRecvRrcConnectionReconfiguration (LteRrcSap::RrcConnectionReconfigur m_cphySapProvider->ConfigureUplink (mci.carrierFreq.ulCarrierFreq, mci.carrierBandwidth.ulBandwidth); m_rnti = msg.mobilityControlInfo.newUeIdentity; m_srb0->m_rlc->SetRnti (m_rnti); - m_cmacSapProvider->Reset (); NS_ASSERT_MSG (mci.haveRachConfigDedicated, "handover is only supported with non-contention-based random access procedure"); m_cmacSapProvider->StartNonContentionBasedRandomAccessProcedure (m_rnti, mci.rachConfigDedicated.raPreambleIndex, mci.rachConfigDedicated.raPrachMaskIndex); m_cphySapProvider->SetRnti (m_rnti);