From 4de9269e2e9f608f7b15443f2d7ac748016f1c9a Mon Sep 17 00:00:00 2001 From: ZorazeAli Date: Tue, 26 Mar 2019 08:22:32 +0100 Subject: [PATCH] lte: Handle handover joining timeout Upon HO joining timeout, the target eNB sends the HO preparation failure message to the source eNB and deletes the UE context. On the other hand, the source eNB after receiving this msg releases the resources towards a UE by sending the RRC connection release msg in an ideal way irrespective of the RRC protocol used; and also requests the core network to delete that UE. --- src/lte/model/lte-enb-rrc.cc | 35 ++++++++++++++++++++++++++ src/lte/model/lte-enb-rrc.h | 15 +++++++++++ src/lte/model/lte-rrc-protocol-real.cc | 14 +++++++++++ src/lte/model/lte-ue-rrc.cc | 10 ++++++++ 4 files changed, 74 insertions(+) diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index b1867cd18..c2638f0c8 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -996,6 +996,12 @@ UeManager::RecvHandoverPreparationFailure (uint16_t cellId) NS_LOG_INFO ("target eNB sent HO preparation failure, aborting HO"); SwitchToState (CONNECTED_NORMALLY); break; + case HANDOVER_LEAVING: //case added to tackle HO joining timer expiration + NS_ASSERT (cellId == m_targetCellId); + NS_LOG_INFO ("target eNB sent HO preparation failure, aborting HO"); + m_handoverLeavingTimeout.Cancel (); + SendRrcConnectionRelease (); + break; default: NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); @@ -1030,6 +1036,24 @@ UeManager::RecvUeContextRelease (EpcX2SapUser::UeContextReleaseParams params) m_handoverLeavingTimeout.Cancel (); } +void +UeManager::SendRrcConnectionRelease () +{ + // TODO implement in the 3gpp way, see Section 5.3.8 of 3GPP TS 36.331. + NS_LOG_FUNCTION (this << (uint32_t) m_rnti); + // De-activation towards UE, it will deactivate all bearers + LteRrcSap::RrcConnectionRelease msg; + msg.rrcTransactionIdentifier = this->GetNewRrcTransactionIdentifier (); + m_rrc->m_rrcSapUser->SendRrcConnectionRelease (m_rnti, msg); + + /** + * Bearer de-activation indication towards epc-enb application + * and removal of UE context at the eNodeB + * + */ + m_rrc->DoRecvIdealUeContextRemoveRequest (m_rnti); +} + // methods forwarded from RRC SAP @@ -2505,6 +2529,17 @@ LteEnbRrc::HandoverJoiningTimeout (uint16_t rnti) "HandoverJoiningTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ())); m_rrcTimeoutTrace (GetUeManager (rnti)->GetImsi (), rnti, ComponentCarrierToCellId (GetUeManager (rnti)->GetComponentCarrierId ()), "HandoverJoiningTimeout"); + + /** + * When the handover joining timer expires at the target cell, + * then notify the source cell to release the RRC connection and + * delete the UE context at eNodeB and SGW/PGW. The + * HandoverPreparationFailure message is reused to notify the source cell + * through the X2 interface instead of creating a new message. + */ + Ptr ueManger = GetUeManager (rnti); + EpcX2Sap::HandoverPreparationFailureParams msg = ueManger->BuildHoPrepFailMsg (); + m_x2SapProvider->SendHandoverPreparationFailure (msg); RemoveUe (rnti); } diff --git a/src/lte/model/lte-enb-rrc.h b/src/lte/model/lte-enb-rrc.h index 3a2b0181e..08d4e651a 100644 --- a/src/lte/model/lte-enb-rrc.h +++ b/src/lte/model/lte-enb-rrc.h @@ -380,6 +380,13 @@ public: */ void CancelPendingEvents (); + /** + * \brief This function acts as an interface to trigger the connection + * release towards eNB, EPC and UE. + * + */ + void SendRrcConnectionRelease (); + /** * \brief build handover preparation failure message */ @@ -1048,6 +1055,14 @@ public: */ void DoSendReleaseDataRadioBearer (uint64_t imsi, uint16_t rnti, uint8_t bearerId); + /** + * \brief Send RRC connection release function + * + * This function acts as an interface to trigger the connection + * release towards eNB, EPC and UE. + */ + void SendRrcConnectionRelease (); + /** * Identifies how EPS Bearer parameters are mapped to different RLC types * diff --git a/src/lte/model/lte-rrc-protocol-real.cc b/src/lte/model/lte-rrc-protocol-real.cc index 9468f5d4b..62118780a 100644 --- a/src/lte/model/lte-rrc-protocol-real.cc +++ b/src/lte/model/lte-rrc-protocol-real.cc @@ -657,6 +657,8 @@ LteEnbRrcProtocolReal::DoSendRrcConnectionReestablishmentReject (uint16_t rnti, void LteEnbRrcProtocolReal::DoSendRrcConnectionRelease (uint16_t rnti, LteRrcSap::RrcConnectionRelease msg) { + //The code below is commented so RRC connection release can be sent in an ideal way + /* Ptr packet = Create (); RrcConnectionReleaseHeader rrcConnectionReleaseHeader; @@ -670,6 +672,18 @@ LteEnbRrcProtocolReal::DoSendRrcConnectionRelease (uint16_t rnti, LteRrcSap::Rrc transmitPdcpSduParameters.lcid = 1; m_setupUeParametersMap[rnti].srb1SapProvider->TransmitPdcpSdu (transmitPdcpSduParameters); + */ + /** + * Send RRC connection release in an idle way to ensure UE goes + * to idle mode during handover failure and connection setup timeout. + * Implemented to avoid unnecessary triggering of assert msgs due to reception of + * msgs (SRS CQI reports) from UE after UE context is deleted at eNodeB. + * TODO: Detection of handover failure and connection setup timeout at UE, + * so that the RRC connection release can be sent through the physical channel again. + */ + NS_LOG_FUNCTION(this<SendIdealUeContextRemoveRequest (m_rnti); + m_asSapUser->NotifyConnectionReleased (); + } } void