diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index 5307c632c..9bcd6be4b 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -78,6 +78,13 @@ TypeId LteUeNetDevice::GetTypeId (void) UintegerValue (0), // not used because the attribute is read-only MakeUintegerAccessor (&LteUeNetDevice::m_imsi), MakeUintegerChecker ()) + .AddAttribute ("DlEarfcn", + "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) " + "as per 3GPP 36.101 Section 5.7.3. ", + UintegerValue (100), + MakeUintegerAccessor (&LteUeNetDevice::SetDlEarfcn, + &LteUeNetDevice::GetDlEarfcn), + MakeUintegerChecker (0, 6149)) ; return tid; @@ -91,7 +98,7 @@ LteUeNetDevice::LteUeNetDevice (void) } - LteUeNetDevice::LteUeNetDevice (Ptr node, Ptr phy, Ptr mac, Ptr rrc, Ptr nas, uint64_t imsi) +LteUeNetDevice::LteUeNetDevice (Ptr node, Ptr phy, Ptr mac, Ptr rrc, Ptr nas, uint64_t imsi) { NS_LOG_FUNCTION (this); m_phy = phy; @@ -129,7 +136,7 @@ LteUeNetDevice::UpdateConfig (void) NS_LOG_FUNCTION (this); m_nas->SetImsi (m_imsi); m_rrc->SetImsi (m_imsi); - + } @@ -171,6 +178,20 @@ LteUeNetDevice::GetImsi () const return m_imsi; } +uint16_t +LteUeNetDevice::GetDlEarfcn () const +{ + return m_dlEarfcn; +} + +void +LteUeNetDevice::SetDlEarfcn (uint16_t earfcn) +{ + m_rrc->SetDlEarfcn (earfcn); + m_phy->SetDlEarfcn (earfcn); + m_dlEarfcn = earfcn; +} + void LteUeNetDevice::SetTargetEnb (Ptr enb) { @@ -201,7 +222,7 @@ LteUeNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocol { NS_LOG_FUNCTION (this << dest << protocolNumber); NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported"); - + return m_nas->Send (packet); } diff --git a/src/lte/model/lte-ue-net-device.h b/src/lte/model/lte-ue-net-device.h index 87d63a689..ae3e74531 100644 --- a/src/lte/model/lte-ue-net-device.h +++ b/src/lte/model/lte-ue-net-device.h @@ -73,25 +73,40 @@ public: // inherited from NetDevice virtual bool Send (Ptr packet, const Address& dest, uint16_t protocolNumber); - + Ptr GetMac (void) const; - Ptr GetRrc () const ; + Ptr GetRrc () const; Ptr GetPhy (void) const; - + Ptr GetNas (void) const; uint64_t GetImsi () const; - + /** + * \return the downlink carrier frequency (EARFCN) + * + * Note that real-life handset typically supports more than one EARFCN, but + * the sake of simplicity we assume only one EARFCN is supported. + */ + uint16_t GetDlEarfcn () const; + + /** + * \param bw the downlink carrier frequency (EARFCN) + * + * Note that real-life handset typically supports more than one EARFCN, but + * the sake of simplicity we assume only one EARFCN is supported. + */ + void SetDlEarfcn (uint16_t earfcn); + /** * \brief Set the targer eNB where the UE is registered * \param enb */ void SetTargetEnb (Ptr enb); - + /** * \brief Get the targer eNB where the UE is registered * \return the pointer to the enb @@ -124,7 +139,9 @@ private: Ptr m_nas; uint64_t m_imsi; - + + uint16_t m_dlEarfcn; /**< downlink carrier frequency */ + }; } // namespace ns3 diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index d1b9abacd..50d7d0c08 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -107,11 +107,11 @@ UeMemberLteUePhySapProvider::SendRachPreamble (uint32_t prachId, uint32_t raRnti //////////////////////////////////////// const char* g_uePhyStateName[LteUePhy::NUM_STATES] = - { - "CELL_SEARCH", - "DECODING_BCH", - "ATTACHED" - }; +{ + "CELL_SEARCH", + "DECODING_BCH", + "ATTACHED" +}; std::string ToString (LteUePhy::State s) { @@ -280,6 +280,8 @@ LteUePhy::DoInitialize () { NS_LOG_FUNCTION (this); LtePhy::DoInitialize (); + DoSetDlBandwidth (6); // configure DL for receiving PSS + SwitchToState (CELL_SEARCH); } void @@ -419,6 +421,12 @@ LteUePhy::CreateTxPowerSpectralDensity () return psd; } +void +LteUePhy::SetDlEarfcn (uint16_t earfcn) +{ + m_dlEarfcn = earfcn; +} + void LteUePhy::GenerateCtrlCqiReport (const SpectrumValue& sinr) { @@ -683,8 +691,8 @@ LteUePhy::ReportUeMeasurements () double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum; double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum; NS_LOG_DEBUG (this << " CellId " << (*it).first - << " RSRP " << avg_rsrp << " (nSamples " << (uint16_t)(*it).second.rsrpNum - << ") RSRQ " << avg_rsrq << " (nSamples " << (uint16_t)(*it).second.rsrpNum << ")"); + << " RSRP " << avg_rsrp << " (nSamples " << (uint16_t)(*it).second.rsrpNum + << ") RSRQ " << avg_rsrq << " (nSamples " << (uint16_t)(*it).second.rsrpNum << ")"); if ((m_state == CELL_SEARCH) && (maxRsrp < avg_rsrp)) { @@ -1114,20 +1122,13 @@ LteUePhy::DoReset () m_downlinkSpectrumPhy->Reset (); m_uplinkSpectrumPhy->Reset (); - // configure DL for receiving PSS - m_dlEarfcn = 100; // TODO hardcoded value - m_noiseFigure = 9.0; // TODO hardcoded value - NS_ASSERT (m_downlinkSpectrumPhy->GetChannel () != 0); - DoSetDlBandwidth (6); - - SwitchToState (CELL_SEARCH); - } // end of void LteUePhy::DoReset () void LteUePhy::DoRetryCellSearch () { NS_LOG_FUNCTION (this); + DoSetDlBandwidth (6); // configure DL for receiving PSS SwitchToState (CELL_SEARCH); } diff --git a/src/lte/model/lte-ue-phy.h b/src/lte/model/lte-ue-phy.h index b69a7eaa3..8ad9bb503 100644 --- a/src/lte/model/lte-ue-phy.h +++ b/src/lte/model/lte-ue-phy.h @@ -143,6 +143,10 @@ public: */ Ptr GetUlSpectrumPhy () const; + /** + * \param bw the downlink carrier frequency (EARFCN) + */ + void SetDlEarfcn (uint16_t earfcn); /** * \brief Create the PSD for the TX @@ -210,18 +214,18 @@ public: /** - * \brief Send the SRS signal in the last symbols of the frame - */ + * \brief Send the SRS signal in the last symbols of the frame + */ void SendSrs (); - /** - * \brief PhySpectrum generated a new DL HARQ feedback - */ + /** + * \brief PhySpectrum generated a new DL HARQ feedback + */ virtual void ReceiveLteDlHarqFeedback (DlInfoListElement_s mes); /** - * \brief Set the HARQ PHY module - */ + * \brief Set the HARQ PHY module + */ void SetHarqPhyModule (Ptr harq); /** @@ -249,10 +253,10 @@ private: void SwitchToState (State s); // UE CPHY SAP methods - void DoReset (); + void DoReset (); void DoRetryCellSearch (); void DoAttach (); - void DoSyncronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn); + void DoSyncronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn); void DoSetDlBandwidth (uint8_t ulBandwidth); void DoConfigureUplink (uint16_t ulEarfcn, uint8_t ulBandwidth); void DoSetRnti (uint16_t rnti); diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 4d42a9105..b108b366e 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -324,12 +324,18 @@ LteUeRrc::GetDlBandwidth () const return m_dlBandwidth; } -uint16_t +uint16_t LteUeRrc::GetDlEarfcn () const { return m_dlEarfcn; } +void +LteUeRrc::SetDlEarfcn (uint16_t earfcn) +{ + m_dlEarfcn = earfcn; +} + uint16_t LteUeRrc::GetUlEarfcn () const { @@ -337,6 +343,11 @@ LteUeRrc::GetUlEarfcn () const return m_ulEarfcn; } +void +LteUeRrc::SetUlEarfcn (uint16_t earfcn) +{ + m_ulEarfcn = earfcn; +} LteUeRrc::State LteUeRrc::GetState (void) @@ -544,10 +555,9 @@ LteUeRrc::DoConnect () // CPHY SAP methods void -LteUeRrc::DoRecvMasterInformationBlock (LteRrcSap::MasterInformationBlock msg) +LteUeRrc::DoRecvMasterInformationBlock (LteRrcSap::MasterInformationBlock msg) { NS_LOG_FUNCTION (this); - // TODO may speed up a bit if only execute the following when bandwidth changes? m_dlBandwidth = msg.dlBandwidth; m_cphySapProvider->SetDlBandwidth (msg.dlBandwidth); m_receivedMib = true; @@ -590,14 +600,14 @@ LteUeRrc::DoReportUeMeasurements (LteUeCphySapUser::UeMeasurementsParameters par std::vector ::iterator newMeasIt; for (newMeasIt = params.m_ueMeasurementsList.begin (); - newMeasIt != params.m_ueMeasurementsList.end (); ++newMeasIt) + newMeasIt != params.m_ueMeasurementsList.end (); ++newMeasIt) { Layer3Filtering (newMeasIt->m_cellId, newMeasIt->m_rsrp, newMeasIt->m_rsrq); } std::map::iterator measIdIt; for (measIdIt = m_varMeasConfig.measIdList.begin (); - measIdIt != m_varMeasConfig.measIdList.end (); ++measIdIt) + measIdIt != m_varMeasConfig.measIdList.end (); ++measIdIt) { MeasurementReportTriggering (measIdIt->first); } @@ -637,14 +647,14 @@ LteUeRrc::DoRecvSystemInformation (LteRrcSap::SystemInformation msg) } if (m_state == IDLE_WAIT_SYSTEM_INFO && m_receivedMib && m_receivedSib2) { - SwitchToState (IDLE_CAMPED_NORMALLY); + SwitchToState (IDLE_CAMPED_NORMALLY); } } void LteUeRrc::DoRecvRrcConnectionSetup (LteRrcSap::RrcConnectionSetup msg) -{ +{ NS_LOG_FUNCTION (this); switch (m_state) { diff --git a/src/lte/model/lte-ue-rrc.h b/src/lte/model/lte-ue-rrc.h index 127a54b1a..217ef46a7 100644 --- a/src/lte/model/lte-ue-rrc.h +++ b/src/lte/model/lte-ue-rrc.h @@ -221,16 +221,26 @@ public: */ uint8_t GetDlBandwidth () const; - /** + /** * \return the downlink carrier frequency (EARFCN) */ uint16_t GetDlEarfcn () const; + /** + * \param bw the downlink carrier frequency (EARFCN) + */ + void SetDlEarfcn (uint16_t earfcn); + /** * \return the uplink carrier frequency (EARFCN) */ uint16_t GetUlEarfcn () const; + /** + * \param bw the uplink carrier frequency (EARFCN) + */ + void SetUlEarfcn (uint16_t earfcn); + /** * * \return the current state