From acdf6835697a465ddcc241cdc13fad68d8710cd4 Mon Sep 17 00:00:00 2001 From: Manuel Requena Date: Mon, 8 Oct 2012 23:23:24 +0200 Subject: [PATCH] Add UE Context Release primitive to X2 SAP --- src/lte/examples/lena-x2-handover.cc | 4 +-- src/lte/model/epc-x2-sap.h | 32 ++++++++++++++++++++-- src/lte/model/lte-enb-rrc.cc | 40 +++++++++++++++++++++++----- src/lte/model/lte-enb-rrc.h | 4 +-- 4 files changed, 67 insertions(+), 13 deletions(-) diff --git a/src/lte/examples/lena-x2-handover.cc b/src/lte/examples/lena-x2-handover.cc index 43b5117a1..c94b19e8e 100644 --- a/src/lte/examples/lena-x2-handover.cc +++ b/src/lte/examples/lena-x2-handover.cc @@ -54,7 +54,7 @@ main (int argc, char *argv[]) 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 @@ main (int argc, char *argv[]) // 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"); diff --git a/src/lte/model/epc-x2-sap.h b/src/lte/model/epc-x2-sap.h index ce8c01ff8..a26cd41c8 100644 --- a/src/lte/model/epc-x2-sap.h +++ b/src/lte/model/epc-x2-sap.h @@ -128,6 +128,16 @@ public: Ptr 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 @@ public: // 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 @@ public: // 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 @@ public: virtual void SendHandoverRequest (HandoverRequestParams params); virtual void SendHandoverRequestAck (HandoverRequestAckParams params); + + virtual void SendUeContextRelease (UeContextReleaseParams params); private: EpcX2SpecificEpcX2SapProvider (); @@ -224,6 +236,13 @@ EpcX2SpecificEpcX2SapProvider::SendHandoverRequestAck (HandoverRequestAckPara m_x2->DoSendHandoverRequestAck (params); } +template +void +EpcX2SpecificEpcX2SapProvider::SendUeContextRelease (UeContextReleaseParams params) +{ + m_x2->DoSendUeContextRelease (params); +} + /////////////////////////////////////// template @@ -240,6 +259,8 @@ public: virtual void RecvHandoverRequestAck (HandoverRequestAckParams params); + virtual void RecvUeContextRelease (UeContextReleaseParams params); + private: EpcX2SpecificEpcX2SapUser (); C* m_rrc; @@ -270,6 +291,13 @@ EpcX2SpecificEpcX2SapUser::RecvHandoverRequestAck (HandoverRequestAckParams p m_rrc->DoRecvHandoverRequestAck (params); } +template +void +EpcX2SpecificEpcX2SapUser::RecvUeContextRelease (UeContextReleaseParams params) +{ + m_rrc->DoRecvUeContextRelease (params); +} + } // namespace ns3 diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index bdb6caf04..9f0edce8f 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -616,7 +616,7 @@ LteEnbRrc::SendHandoverRequest (uint16_t rnti, uint16_t cellId) 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 @@ LteEnbRrc::DoRecvHandoverRequest (EpcX2SapUser::HandoverRequestParams params) 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 @@ LteEnbRrc::DoRecvHandoverRequest (EpcX2SapUser::HandoverRequestParams params) 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 @@ LteEnbRrc::DoRecvHandoverRequest (EpcX2SapUser::HandoverRequestParams params) 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 @@ LteEnbRrc::DoRecvHandoverRequestAck (EpcX2SapUser::HandoverRequestAckParams para 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) diff --git a/src/lte/model/lte-enb-rrc.h b/src/lte/model/lte-enb-rrc.h index 903a23035..6aa24e767 100644 --- a/src/lte/model/lte-enb-rrc.h +++ b/src/lte/model/lte-enb-rrc.h @@ -356,10 +356,10 @@ private: */ 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);