Add UE Context Release primitive to X2 SAP
authorManuel Requena <manuel.requena@cttc.es>
Mon, 08 Oct 2012 23:23:24 +0200
changeset 9405 ec9b557065cc
parent 9404 1f737f190823
child 9407 e261dc294165
Add UE Context Release primitive to X2 SAP
src/lte/examples/lena-x2-handover.cc
src/lte/model/epc-x2-sap.h
src/lte/model/lte-enb-rrc.cc
src/lte/model/lte-enb-rrc.h
--- a/src/lte/examples/lena-x2-handover.cc	Mon Oct 08 23:22:57 2012 +0200
+++ b/src/lte/examples/lena-x2-handover.cc	Mon Oct 08 23:23:24 2012 +0200
@@ -54,7 +54,7 @@
 
   uint16_t numberOfUes = 1;
   uint16_t numberOfEnbs = 2;
-  double simTime = 4.0;
+  double simTime = 6.0;
   double distance = 60.0;
 
   // Command line arguments
@@ -146,7 +146,7 @@
 
   // X2-based Handover
   lteHelper->HandoverRequest (Seconds (2.0), ueLteDevs.Get (0), enbLteDevs.Get (0), enbLteDevs.Get (1));
-
+  
   
   // Uncomment to enable PCAP tracing
   //p2ph.EnablePcapAll("lena-x2-handover");
--- a/src/lte/model/epc-x2-sap.h	Mon Oct 08 23:22:57 2012 +0200
+++ b/src/lte/model/epc-x2-sap.h	Mon Oct 08 23:23:24 2012 +0200
@@ -128,6 +128,16 @@
     Ptr<Packet>         rrcContext;
   };
 
+  /**
+   * \brief Parameters of the UE CONTEXT RELEASE message.
+   *
+   * See section 9.1.1.5 for further info about the parameters
+   */
+  struct UeContextReleaseParams
+  {
+    uint16_t            oldEnbUeX2apId;
+    uint16_t            newEnbUeX2apId;
+  };
 };
 
 
@@ -151,7 +161,7 @@
 // TODO
 //   virtual void SendSnStatusTransfer (const struct SnStatusTransfer& params) = 0;
 // 
-//   virtual void SendUeContextRelease (const struct UeContextRelease& params) = 0;
+  virtual void SendUeContextRelease (UeContextReleaseParams params) = 0;
 };
 
 
@@ -175,7 +185,7 @@
 // TODO
 //   virtual void RecvSnStatusTransfer (const struct SnStatusTransfer& params) = 0;
 // 
-//   virtual void RecvUeContextRelease (const struct UeContextRelease& params) = 0;
+  virtual void RecvUeContextRelease (UeContextReleaseParams params) = 0;
 };
 
 ///////////////////////////////////////
@@ -193,6 +203,8 @@
   virtual void SendHandoverRequest (HandoverRequestParams params);
 
   virtual void SendHandoverRequestAck (HandoverRequestAckParams params);
+
+  virtual void SendUeContextRelease (UeContextReleaseParams params);
   
 private:
   EpcX2SpecificEpcX2SapProvider ();
@@ -224,6 +236,13 @@
   m_x2->DoSendHandoverRequestAck (params);
 }
 
+template <class C>
+void
+EpcX2SpecificEpcX2SapProvider<C>::SendUeContextRelease (UeContextReleaseParams params)
+{
+  m_x2->DoSendUeContextRelease (params);
+}
+
 ///////////////////////////////////////
 
 template <class C>
@@ -240,6 +259,8 @@
 
   virtual void RecvHandoverRequestAck (HandoverRequestAckParams params);
   
+  virtual void RecvUeContextRelease (UeContextReleaseParams params);
+  
 private:
   EpcX2SpecificEpcX2SapUser ();
   C* m_rrc;
@@ -270,6 +291,13 @@
   m_rrc->DoRecvHandoverRequestAck (params);
 }
 
+template <class C>
+void
+EpcX2SpecificEpcX2SapUser<C>::RecvUeContextRelease (UeContextReleaseParams params)
+{
+  m_rrc->DoRecvUeContextRelease (params);
+}
+
 
 } // namespace ns3
 
--- a/src/lte/model/lte-enb-rrc.cc	Mon Oct 08 23:22:57 2012 +0200
+++ b/src/lte/model/lte-enb-rrc.cc	Mon Oct 08 23:23:24 2012 +0200
@@ -616,7 +616,7 @@
   NS_ASSERT_MSG (it != m_ueMap.end (), "RNTI " << rnti << " not found in eNB with cellId " << m_cellId);
 
   EpcX2SapProvider::HandoverRequestParams params;
-  params.oldEnbUeX2apId = rnti;
+  params.oldEnbUeX2apId = 100 + rnti;
   params.cause          = EpcX2SapProvider::HandoverDesirableForRadioReason;
   params.sourceCellId   = m_cellId;
   params.targetCellId   = cellId;
@@ -648,11 +648,11 @@
   NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
   NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
   NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
-  
-  // this crashes, apparently EpcX2 is not correctly filling in the params yet
-  //  uint8_t rrcData [100];
-  // params.rrcContext->CopyData (rrcData, params.rrcContext->GetSize ());
-  // NS_LOG_LOGIC ("rrcContext   = " << rrcData);
+
+  // RRC message 
+  uint8_t rrcData [100];
+  params.rrcContext->CopyData (rrcData, params.rrcContext->GetSize ());
+  NS_LOG_LOGIC ("rrcContext   = " << rrcData);
 
   uint16_t rnti = AddUe ();
 
@@ -667,7 +667,7 @@
 
   EpcX2SapProvider::HandoverRequestAckParams ackParams;
   ackParams.oldEnbUeX2apId = params.oldEnbUeX2apId;
-  ackParams.newEnbUeX2apId = params.oldEnbUeX2apId + 100;
+  ackParams.newEnbUeX2apId = params.oldEnbUeX2apId + 1;
   ackParams.sourceCellId = params.sourceCellId;
   ackParams.targetCellId = params.targetCellId;
 
@@ -677,6 +677,21 @@
   NS_LOG_LOGIC ("targetCellId = " << ackParams.targetCellId);
 
   m_x2SapProvider->SendHandoverRequestAck (ackParams);
+
+
+  // TODO: This is just an example how to send the UE CONTEXT RELEASE msg
+  //
+  // Send UE CONTEXT RELEASE from target eNB to source eNB
+  //
+  EpcX2SapProvider::UeContextReleaseParams ueCtxReleaseParams;
+  ueCtxReleaseParams.oldEnbUeX2apId = ackParams.oldEnbUeX2apId;
+  ueCtxReleaseParams.newEnbUeX2apId = ackParams.newEnbUeX2apId;
+  Simulator::Schedule (Seconds (2.0),
+                       &EpcX2SapProvider::SendUeContextRelease,
+                       m_x2SapProvider,
+                       ueCtxReleaseParams);
+
+
 }
 
 void
@@ -692,6 +707,17 @@
   NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
 }
 
+void
+LteEnbRrc::DoRecvUeContextRelease (EpcX2SapUser::UeContextReleaseParams params)
+{
+  NS_LOG_FUNCTION (this);
+  
+  NS_LOG_LOGIC ("Recv X2 message: UE CONTEXT RELEASE");
+  
+  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
+  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
+}
+
 
 void
 LteEnbRrc::DoReceiveRrcPdu (LtePdcpSapUser::ReceiveRrcPduParameters params)
--- a/src/lte/model/lte-enb-rrc.h	Mon Oct 08 23:22:57 2012 +0200
+++ b/src/lte/model/lte-enb-rrc.h	Mon Oct 08 23:23:24 2012 +0200
@@ -356,10 +356,10 @@
    */
   uint8_t SetupRadioBearer (uint16_t rnti, EpsBearer bearer, uint32_t teid);
 
-
+  // X2 SAP methods
   void DoRecvHandoverRequest (EpcX2SapUser::HandoverRequestParams params);
   void DoRecvHandoverRequestAck (EpcX2SapUser::HandoverRequestAckParams params);
-
+  void DoRecvUeContextRelease (EpcX2SapUser::UeContextReleaseParams params);
 
   LtePdcpSapProvider* GetLtePdcpSapProvider (uint16_t rnti, uint8_t lcid);