From 9aeb7bbe5b8d06377ff2c6dd86ec33431588e177 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Tue, 26 Mar 2013 19:22:41 +0100 Subject: [PATCH] refactored timeouts in LteEnbRrc --- .../doc/source/figures/lte-enb-rrc-states.dot | 6 +- src/lte/model/lte-enb-rrc.cc | 101 +++++++++++++++--- src/lte/model/lte-enb-rrc.h | 41 ++++++- 3 files changed, 132 insertions(+), 16 deletions(-) diff --git a/src/lte/doc/source/figures/lte-enb-rrc-states.dot b/src/lte/doc/source/figures/lte-enb-rrc-states.dot index cd3063105..9ab3e97dd 100644 --- a/src/lte/doc/source/figures/lte-enb-rrc-states.dot +++ b/src/lte/doc/source/figures/lte-enb-rrc-states.dot @@ -17,8 +17,8 @@ CONTEXT_DESTROYED [shape="ellipse", label="context destroyed"] NO_CONTEXT -> INITIAL_RANDOM_ACCESS [label="rx RA preamble",labeldistance=0] INITIAL_RANDOM_ACCESS -> CONNECTION_REJECTED [label="rx RRC CONN REQUEST, AdmitRrcConnectionRequest = false"] -CONNECTION_REJECTED -> CONTEXT_DESTROYED [label="maxRecvConnRejectDelay timeout"] -INITIAL_RANDOM_ACCESS -> CONTEXT_DESTROYED [label="maxConnectionDelay timeout"] +CONNECTION_REJECTED -> CONTEXT_DESTROYED [label="ConnectionRejectedTimeout"] +INITIAL_RANDOM_ACCESS -> CONTEXT_DESTROYED [label="ConnectionTimeout"] INITIAL_RANDOM_ACCESS -> CONNECTION_SETUP [label="rx RRC CONN REQUEST, AdmitRrcConnectionRequest = true"] CONNECTION_SETUP -> CONNECTED_NORMALLY [label="rx RRC CONN SETUP COMPLETED"] CONNECTED_NORMALLY -> CONNECTION_RECONFIGURATION [label="reconfiguration trigger"] @@ -27,8 +27,10 @@ CONNECTED_NORMALLY -> HANDOVER_PREPARATION [label="handover trigger"] HANDOVER_PREPARATION -> CONNECTED_NORMALLY [label="rx X2 HO PREP FAILURE"] HANDOVER_PREPARATION -> HANDOVER_LEAVING [label="rx X2 HO REQUEST ACK"] HANDOVER_LEAVING -> CONTEXT_DESTROYED [label="rx X2 UE CONTEXT RELEASE"] +HANDOVER_LEAVING -> CONTEXT_DESTROYED [label="HandoverLeavingTimeout"] NO_CONTEXT -> HANDOVER_JOINING [label="rx & admit X2 HANDOVER REQUEST"] HANDOVER_JOINING -> HANDOVER_PATH_SWITCH [label="RRC CONN RECONF COMPLETED"] +HANDOVER_JOINING -> CONTEXT_DESTROYED [label="HandoverJoiningTimeout"] HANDOVER_PATH_SWITCH -> CONNECTED_NORMALLY [label="rx S1 PATH SWITCH REQUEST ACK"] diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index c736f579d..217df3068 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -241,20 +241,21 @@ UeManager::DoStart () switch (m_state) { case INITIAL_RANDOM_ACCESS: - // must account for reception of RAR and transmission of RRC CONNECTION REQUEST over UL GRANT - maxConnectionDelay = MilliSeconds (15); + m_connectionTimeout = Simulator::Schedule (m_rrc->m_connectionTimeoutDuration, + &LteEnbRrc::ConnectionTimeout, + m_rrc, m_rnti); break; + case HANDOVER_JOINING: - // must account for reception of X2 HO REQ ACK by source eNB, - // transmission of the Handover Command, and - // non-contention-based random access - maxConnectionDelay = MilliSeconds (50); + m_handoverJoiningTimeout = Simulator::Schedule (m_rrc->m_handoverJoiningTimeoutDuration, + &LteEnbRrc::HandoverJoiningTimeout, + m_rrc, m_rnti); break; + default: - NS_FATAL_ERROR ("unspecified maxConnectionDelay for state " << ToString (m_state)); + NS_FATAL_ERROR ("unexpected state " << ToString (m_state)); break; } - m_connectionTimeout = Simulator::Schedule (maxConnectionDelay, &LteEnbRrc::ConnectionTimeout, m_rrc, m_rnti); m_servingCellMeasures = CreateObject (); m_servingCellMeasures->m_cellId = m_rrc->m_cellId; @@ -580,6 +581,9 @@ UeManager::RecvHandoverRequestAck (EpcX2SapUser::HandoverRequestAckParams params LteRrcSap::RrcConnectionReconfiguration handoverCommand = m_rrc->m_rrcSapUser->DecodeHandoverCommand (encodedHandoverCommand); m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, handoverCommand); SwitchToState (HANDOVER_LEAVING); + m_handoverLeavingTimeout = Simulator::Schedule (m_rrc->m_handoverLeavingTimeoutDuration, + &LteEnbRrc::HandoverLeavingTimeout, + m_rrc, m_rnti); NS_ASSERT (handoverCommand.haveMobilityControlInfo); m_rrc->m_handoverStartTrace (m_imsi, m_rrc->m_cellId, m_rnti, handoverCommand.mobilityControlInfo.targetPhysCellId); @@ -749,6 +753,15 @@ UeManager::RecvSnStatusTransfer (EpcX2SapUser::SnStatusTransferParams params) } } +void +UeManager::RecvUeContextRelease (EpcX2SapUser::UeContextReleaseParams params) +{ + NS_LOG_FUNCTION (this); + NS_ASSERT_MSG (m_state == HANDOVER_LEAVING, "method unexpected in state " << ToString (m_state)); + m_handoverLeavingTimeout.Cancel (); +} + + // methods forwarded from RRC SAP void @@ -789,8 +802,9 @@ UeManager::RecvRrcConnectionRequest (LteRrcSap::RrcConnectionRequest msg) LteRrcSap::RrcConnectionReject rejectMsg; rejectMsg.waitTime = 3; m_rrc->m_rrcSapUser->SendRrcConnectionReject (m_rnti, rejectMsg); - Time maxRecvConnRejectDelay = MilliSeconds (30); - m_connectionTimeout = Simulator::Schedule (maxRecvConnRejectDelay, &LteEnbRrc::ConnectionTimeout, m_rrc, m_rnti); + m_connectionRejectedTimeout = Simulator::Schedule (m_rrc->m_connectionRejectedTimeoutDuration, + &LteEnbRrc::ConnectionRejectedTimeout, + m_rrc, m_rnti); SwitchToState (CONNECTION_REJECTED); } } @@ -851,7 +865,7 @@ UeManager::RecvRrcConnectionReconfigurationCompleted (LteRrcSap::RrcConnectionRe case HANDOVER_JOINING: { - m_connectionTimeout.Cancel (); + m_handoverJoiningTimeout.Cancel (); NS_LOG_INFO ("Send PATH SWITCH REQUEST to the MME"); EpcEnbS1SapProvider::PathSwitchRequestParameters params; params.rnti = m_rnti; @@ -881,6 +895,20 @@ void UeManager::RecvRrcConnectionReestablishmentRequest (LteRrcSap::RrcConnectionReestablishmentRequest msg) { NS_LOG_FUNCTION (this); + switch (m_state) + { + case CONNECTED_NORMALLY: + break; + + case HANDOVER_LEAVING: + m_handoverLeavingTimeout.Cancel (); + break; + + default: + NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); + break; + } + LteRrcSap::RrcConnectionReestablishment msg2; msg2.rrcTransactionIdentifier = GetNewRrcTransactionIdentifier (); msg2.radioResourceConfigDedicated = BuildRadioResourceConfigDedicated (); @@ -1434,7 +1462,27 @@ LteEnbRrc::GetTypeId (void) UintegerValue (40), MakeUintegerAccessor (&LteEnbRrc::SetSrsPeriodicity, &LteEnbRrc::GetSrsPeriodicity), - MakeUintegerChecker ()) + MakeUintegerChecker ()) + .AddAttribute ("ConnectionTimeoutDuration", + "After a RA attempt, if no RRC Connection Request is received before this time, the UE context is destroyed. Must account for reception of RAR and transmission of RRC CONNECTION REQUEST over UL GRANT.", + TimeValue (MilliSeconds (15)), + MakeTimeAccessor (&LteEnbRrc::m_connectionTimeoutDuration), + MakeTimeChecker ()) + .AddAttribute ("ConnectionRejectedTimeoutDuration", + "Time to wait between sending a RRC CONNECTION REJECT and destroying the UE context", + TimeValue (MilliSeconds (30)), + MakeTimeAccessor (&LteEnbRrc::m_connectionRejectedTimeoutDuration), + MakeTimeChecker ()) + .AddAttribute ("HandoverJoiningTimeoutDuration", + "After accepting a handover request, if no RRC Connection Reconfiguration Completed is received before this time, the UE context is destroyed. Must account for reception of X2 HO REQ ACK by source eNB, transmission of the Handover Command, non-contention-based random access and reception of the RRC Connection Reconfiguration Completed message.", + TimeValue (MilliSeconds (200)), + MakeTimeAccessor (&LteEnbRrc::m_handoverJoiningTimeoutDuration), + MakeTimeChecker ()) + .AddAttribute ("HandoverLeavingTimeoutDuration", + "After issuing a Handover Command, if neither RRC Connection Reestablishment nor X2 UE Context Release has been previously received, the UE context is destroyed.", + TimeValue (MilliSeconds (500)), + MakeTimeAccessor (&LteEnbRrc::m_handoverLeavingTimeoutDuration), + MakeTimeChecker ()) .AddAttribute ("AdmitHandoverRequest", "Whether to admit an X2 handover request from another eNB", BooleanValue (true), @@ -1627,9 +1675,37 @@ void LteEnbRrc::ConnectionTimeout (uint16_t rnti) { NS_LOG_FUNCTION (this << rnti); + NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::INITIAL_RANDOM_ACCESS, + "ConnectionTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ())); RemoveUe (rnti); } +void +LteEnbRrc::ConnectionRejectedTimeout (uint16_t rnti) +{ + NS_LOG_FUNCTION (this << rnti); + NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::CONNECTION_REJECTED, + "ConnectionTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ())); + RemoveUe (rnti); +} + +void +LteEnbRrc::HandoverJoiningTimeout (uint16_t rnti) +{ + NS_LOG_FUNCTION (this << rnti); + NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::HANDOVER_JOINING, + "HandoverJoiningTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ())); + RemoveUe (rnti); +} + +void +LteEnbRrc::HandoverLeavingTimeout (uint16_t rnti) +{ + NS_LOG_FUNCTION (this << rnti); + NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::HANDOVER_LEAVING, + "HandoverLeavingTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ())); + RemoveUe (rnti); +} void LteEnbRrc::SendHandoverRequest (uint16_t rnti, uint16_t cellId) @@ -1859,6 +1935,7 @@ LteEnbRrc::DoRecvUeContextRelease (EpcX2SapUser::UeContextReleaseParams params) NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId); uint16_t rnti = params.oldEnbUeX2apId; + GetUeManager (rnti)->RecvUeContextRelease (params); RemoveUe (rnti); } diff --git a/src/lte/model/lte-enb-rrc.h b/src/lte/model/lte-enb-rrc.h index 7b7635e7d..9947b52ad 100644 --- a/src/lte/model/lte-enb-rrc.h +++ b/src/lte/model/lte-enb-rrc.h @@ -252,7 +252,13 @@ public: * \param params the SN STATUS */ void RecvSnStatusTransfer (EpcX2SapUser::SnStatusTransferParams params); - + + /** + * Take the necessary actions in response to the reception of an X2 UE CONTEXT RELEASE message + * + * \param params the SN STATUS + */ + void RecvUeContextRelease (EpcX2SapUser::UeContextReleaseParams params); // methods forwarded from RRC SAP void CompleteSetupUe (LteEnbRrcSapProvider::CompleteSetupUeParameters params); @@ -426,8 +432,11 @@ private: uint16_t m_targetCellId; std::list m_drbsToBeStarted; bool m_needTransmissionModeConfiguration; - EventId m_connectionTimeout; + EventId m_connectionTimeout; + EventId m_connectionRejectedTimeout; + EventId m_handoverJoiningTimeout; + EventId m_handoverLeavingTimeout; Ptr m_servingCellMeasures; // cellid @@ -607,6 +616,29 @@ public: */ void ConnectionTimeout (uint16_t rnti); + /** + * Method triggered a while after sending RRC Connection Rejected + * + * \param rnti the T-C-RNTI whose timeout expired + */ + void ConnectionRejectedTimeout (uint16_t rnti); + + /** + * Method triggered when a UE is expected to join the cell for a handover + * but does not do so in a reasonable time + * + * \param rnti the C-RNTI whose timeout expired + */ + void HandoverJoiningTimeout (uint16_t rnti); + + /** + * Method triggered when a UE is expected to leave a cell for a handover + * but no feedback is received in a reasonable time + * + * \param rnti the C-RNTI whose timeout expired + */ + void HandoverLeavingTimeout (uint16_t rnti); + /** * Send a HandoverRequest through the X2 SAP interface * @@ -822,6 +854,11 @@ private: uint8_t m_servingCellHandoverThreshold; uint8_t m_neighbourCellHandoverOffset; + // timeouts + Time m_connectionTimeoutDuration; + Time m_connectionRejectedTimeoutDuration; + Time m_handoverJoiningTimeoutDuration; + Time m_handoverLeavingTimeoutDuration; // cellid std::map > m_neighbourRelationTable;