refactored timeouts in LteEnbRrc
authorNicola Baldo <nbaldo@cttc.es>
Tue, 26 Mar 2013 19:22:41 +0100
changeset 10022 4942b556f517
parent 10021 768c6d90a55c
child 10023 d0cec03b1409
refactored timeouts in LteEnbRrc
src/lte/doc/source/figures/lte-enb-rrc-states.dot
src/lte/model/lte-enb-rrc.cc
src/lte/model/lte-enb-rrc.h
--- a/src/lte/doc/source/figures/lte-enb-rrc-states.dot	Tue Mar 26 10:45:41 2013 +0100
+++ b/src/lte/doc/source/figures/lte-enb-rrc-states.dot	Tue Mar 26 19:22:41 2013 +0100
@@ -17,8 +17,8 @@
 
 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 @@
 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"]
 
 
--- a/src/lte/model/lte-enb-rrc.cc	Tue Mar 26 10:45:41 2013 +0100
+++ b/src/lte/model/lte-enb-rrc.cc	Tue Mar 26 19:22:41 2013 +0100
@@ -241,20 +241,21 @@
   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<UeMeasure> ();
   m_servingCellMeasures->m_cellId = m_rrc->m_cellId;
@@ -580,6 +581,9 @@
   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 @@
     }
 }
 
+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 @@
             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 @@
       
     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 @@
 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 @@
                    UintegerValue (40),  
                    MakeUintegerAccessor (&LteEnbRrc::SetSrsPeriodicity, 
                                          &LteEnbRrc::GetSrsPeriodicity),
-                   MakeUintegerChecker<uint32_t> ())   
+                   MakeUintegerChecker<uint32_t> ())
+    .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 @@
 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 @@
   NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
 
   uint16_t rnti = params.oldEnbUeX2apId;
+  GetUeManager (rnti)->RecvUeContextRelease (params);
   RemoveUe (rnti);
 }
 
--- a/src/lte/model/lte-enb-rrc.h	Tue Mar 26 10:45:41 2013 +0100
+++ b/src/lte/model/lte-enb-rrc.h	Tue Mar 26 19:22:41 2013 +0100
@@ -252,7 +252,13 @@
    * \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 @@
   uint16_t m_targetCellId;
   std::list<uint8_t> m_drbsToBeStarted;
   bool m_needTransmissionModeConfiguration;
+
   EventId m_connectionTimeout;
-
+  EventId m_connectionRejectedTimeout;
+  EventId m_handoverJoiningTimeout;
+  EventId m_handoverLeavingTimeout;
 
   Ptr<UeMeasure> m_servingCellMeasures;
   //       cellid
@@ -608,6 +617,29 @@
   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
    * 
    * This method will trigger a handover which is started by the RRC
@@ -822,6 +854,11 @@
   uint8_t m_servingCellHandoverThreshold;
   uint8_t m_neighbourCellHandoverOffset;
 
+  // timeouts
+  Time m_connectionTimeoutDuration;
+  Time m_connectionRejectedTimeoutDuration;
+  Time m_handoverJoiningTimeoutDuration;
+  Time m_handoverLeavingTimeoutDuration;  
 
   //       cellid
   std::map<uint16_t, Ptr<NeighbourRelation> > m_neighbourRelationTable;