20#include "ns3/epc-x2.h"
22#include "ns3/epc-gtpu-header.h"
23#include "ns3/epc-x2-header.h"
24#include "ns3/inet-socket-address.h"
27#include "ns3/packet.h"
62 : m_localCellIds{localCellIds},
63 m_remoteCellIds{remoteCellIds}
132 std::vector<uint16_t> remoteCellIds,
135 uint16_t remoteCellId = remoteCellIds.at(0);
136 NS_LOG_FUNCTION(
this << localCellId << localX2Address << remoteCellId << remoteX2Address);
157 std::vector<uint16_t> localCellIds;
158 localCellIds.push_back(localCellId);
161 "Mapping for remoteCellId = " << remoteCellId <<
" is already known");
162 for (uint16_t remoteCellId : remoteCellIds)
165 Create<X2IfaceInfo>(remoteX2Address, localX2cSocket, localX2uSocket);
169 "Mapping for control plane localSocket = " << localX2cSocket
170 <<
" is already known");
174 "Mapping for data plane localSocket = " << localX2uSocket <<
" is already known");
188 "Missing infos of local and remote CellId");
192 packet->RemoveHeader(x2Header);
206 packet->RemoveHeader(x2HoReqHeader);
208 NS_LOG_INFO(
"X2 HandoverRequest header: " << x2HoReqHeader);
212 params.cause = x2HoReqHeader.
GetCause();
213 params.sourceCellId = cellsInfo->m_remoteCellIds.at(0);
219 params.rrcContext = packet;
221 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
225 NS_LOG_LOGIC(
"cellsInfo->m_localCellId = " << cellsInfo->m_localCellIds.at(0));
234 packet->RemoveHeader(x2HoReqAckHeader);
236 NS_LOG_INFO(
"X2 HandoverRequestAck header: " << x2HoReqAckHeader);
241 params.sourceCellId = cellsInfo->m_localCellIds.at(0);
242 params.targetCellId = cellsInfo->m_remoteCellIds.at(0);
245 params.rrcContext = packet;
247 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
248 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
256 NS_LOG_LOGIC(
"Recv X2 message: HANDOVER PREPARATION FAILURE");
259 packet->RemoveHeader(x2HoPrepFailHeader);
261 NS_LOG_INFO(
"X2 HandoverPreparationFailure header: " << x2HoPrepFailHeader);
265 params.sourceCellId = cellsInfo->m_localCellIds.at(0);
266 params.targetCellId = cellsInfo->m_remoteCellIds.at(0);
267 params.cause = x2HoPrepFailHeader.
GetCause();
270 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
274 NS_LOG_LOGIC(
"criticalityDiagnostics = " << params.criticalityDiagnostics);
286 packet->RemoveHeader(x2LoadInfoHeader);
288 NS_LOG_INFO(
"X2 LoadInformation header: " << x2LoadInfoHeader);
293 NS_LOG_LOGIC(
"cellInformationList size = " << params.cellInformationList.size());
305 packet->RemoveHeader(x2SnStatusXferHeader);
307 NS_LOG_INFO(
"X2 SnStatusTransfer header: " << x2SnStatusXferHeader);
312 params.sourceCellId = cellsInfo->m_remoteCellIds.at(0);
313 params.targetCellId = cellsInfo->m_localCellIds.at(0);
314 params.erabsSubjectToStatusTransferList =
317 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
318 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
321 NS_LOG_LOGIC(
"erabsList size = " << params.erabsSubjectToStatusTransferList.size());
333 packet->RemoveHeader(x2UeCtxReleaseHeader);
335 NS_LOG_INFO(
"X2 UeContextRelease header: " << x2UeCtxReleaseHeader);
341 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
342 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
351 NS_LOG_LOGIC(
"Recv X2 message: RESOURCE STATUS UPDATE");
354 packet->RemoveHeader(x2ResStatUpdHeader);
356 NS_LOG_INFO(
"X2 ResourceStatusUpdate header: " << x2ResStatUpdHeader);
359 params.targetCellId = 0;
364 NS_LOG_LOGIC(
"enb1MeasurementId = " << params.enb1MeasurementId);
365 NS_LOG_LOGIC(
"enb2MeasurementId = " << params.enb2MeasurementId);
367 "cellMeasurementResultList size = " << params.cellMeasurementResultList.size());
379 packet->RemoveHeader(x2HoCancelHeader);
381 NS_LOG_INFO(
"X2 HandoverCancel header: " << x2HoCancelHeader);
386 params.sourceCellId = cellsInfo->m_localCellIds.at(0);
387 params.targetCellId = cellsInfo->m_remoteCellIds.at(0);
388 params.cause = x2HoCancelHeader.
GetCause();
390 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
391 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
410 NS_LOG_LOGIC(
"Recv UE DATA through X2-U interface from Socket");
415 "Missing infos of local and remote CellId");
419 packet->RemoveHeader(gtpu);
424 params.sourceCellId = cellsInfo->m_remoteCellIds.at(0);
425 params.targetCellId = cellsInfo->m_localCellIds.at(0);
426 params.gtpTeid = gtpu.
GetTeid();
427 params.ueData = packet;
440 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
446 "Missing infos for targetCellId = " << params.targetCellId);
448 Ptr<Socket> sourceSocket = socketInfo->m_localCtrlPlaneSocket;
449 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
459 x2HoReqHeader.
SetCause(params.cause);
473 NS_LOG_INFO(
"X2 HandoverRequest header: " << x2HoReqHeader);
476 Ptr<Packet> packet = (params.rrcContext) ? (params.rrcContext) : (Create<Packet>());
477 packet->AddHeader(x2HoReqHeader);
478 packet->AddHeader(x2Header);
490 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
491 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
496 "Socket infos not defined for sourceCellId = " << params.sourceCellId);
504 NS_LOG_INFO(
"Send X2 message: HANDOVER REQUEST ACK");
520 NS_LOG_INFO(
"X2 HandoverAck header: " << x2HoAckHeader);
524 Ptr<Packet> packet = (params.rrcContext) ? (params.rrcContext) : (Create<Packet>());
525 packet->AddHeader(x2HoAckHeader);
526 packet->AddHeader(x2Header);
538 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
542 NS_LOG_LOGIC(
"criticalityDiagnostics = " << params.criticalityDiagnostics);
545 "Socket infos not defined for sourceCellId = " << params.sourceCellId);
553 NS_LOG_INFO(
"Send X2 message: HANDOVER PREPARATION FAILURE");
558 x2HoPrepFailHeader.
SetCause(params.cause);
568 NS_LOG_INFO(
"X2 HandoverPrepFail header: " << x2HoPrepFailHeader);
572 packet->AddHeader(x2HoPrepFailHeader);
573 packet->AddHeader(x2Header);
585 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
586 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
589 NS_LOG_LOGIC(
"erabsList size = " << params.erabsSubjectToStatusTransferList.size());
592 "Socket infos not defined for targetCellId = " << params.targetCellId);
600 NS_LOG_INFO(
"Send X2 message: SN STATUS TRANSFER");
607 params.erabsSubjectToStatusTransferList);
616 NS_LOG_INFO(
"X2 SnStatusTransfer header: " << x2SnStatusXferHeader);
620 packet->AddHeader(x2SnStatusXferHeader);
621 packet->AddHeader(x2Header);
633 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
634 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
638 "Socket infos not defined for sourceCellId = " << params.sourceCellId);
646 NS_LOG_INFO(
"Send X2 message: UE CONTEXT RELEASE");
660 NS_LOG_INFO(
"X2 UeContextRelease header: " << x2UeCtxReleaseHeader);
664 packet->AddHeader(x2UeCtxReleaseHeader);
665 packet->AddHeader(x2Header);
678 NS_LOG_LOGIC(
"cellInformationList size = " << params.cellInformationList.size());
681 "Missing infos for targetCellId = " << params.targetCellId);
683 Ptr<Socket> sourceSocket = socketInfo->m_localCtrlPlaneSocket;
684 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
702 NS_LOG_INFO(
"X2 LoadInformation header: " << x2LoadInfoHeader);
706 packet->AddHeader(x2LoadInfoHeader);
707 packet->AddHeader(x2Header);
720 NS_LOG_LOGIC(
"enb1MeasurementId = " << params.enb1MeasurementId);
721 NS_LOG_LOGIC(
"enb2MeasurementId = " << params.enb2MeasurementId);
722 NS_LOG_LOGIC(
"cellMeasurementResultList size = " << params.cellMeasurementResultList.size());
725 "Missing infos for targetCellId = " << params.targetCellId);
727 Ptr<Socket> sourceSocket = socketInfo->m_localCtrlPlaneSocket;
728 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
733 NS_LOG_INFO(
"Send X2 message: RESOURCE STATUS UPDATE");
748 NS_LOG_INFO(
"X2 ResourceStatusUpdate header: " << x2ResourceStatUpdHeader);
752 packet->AddHeader(x2ResourceStatUpdHeader);
753 packet->AddHeader(x2Header);
770 "Missing infos for targetCellId = " << params.targetCellId);
772 Ptr<Socket> sourceSocket = socketInfo->m_localUserPlaneSocket;
773 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
785 packet->AddHeader(gtpu);
787 NS_LOG_INFO(
"Forward UE DATA through X2 interface");
796 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
797 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
802 "Socket infos not defined for targetCellId = " << params.targetCellId);
816 x2HandoverCancelHeader.
SetCause(params.cause);
825 NS_LOG_INFO(
"X2 UeContextRelease header: " << x2HandoverCancelHeader);
829 packet->AddHeader(x2HandoverCancelHeader);
830 packet->AddHeader(x2Header);
EpcX2HandoverCancelHeader.
uint16_t GetNewEnbUeX2apId() const
Get new ENB UE X2 AP ID function.
void SetOldEnbUeX2apId(uint16_t x2apId)
Set old ENB UE X2 AP ID function.
uint32_t GetLengthOfIes() const
Get length of IEs function.
uint16_t GetOldEnbUeX2apId() const
Get old ENB UE X2 AP ID function.
void SetCause(uint16_t cause)
Set cause function.
uint16_t GetCause() const
Get cause function.
uint32_t GetNumberOfIes() const
Get number of IEs function.
void SetNewEnbUeX2apId(uint16_t x2apId)
Set new ENB UE X2 AP ID function.
EpcX2HandoverPreparationFailureHeader.
void SetCriticalityDiagnostics(uint16_t criticalityDiagnostics)
Set criticality diagnostics function.
void SetCause(uint16_t cause)
Set cause function.
uint16_t GetOldEnbUeX2apId() const
Get old ENB UE X2 AP ID function.
uint16_t GetCause() const
Get cause function.
uint32_t GetLengthOfIes() const
Get length of IEs function.
uint16_t GetCriticalityDiagnostics() const
Get criticality diagnostics function.
void SetOldEnbUeX2apId(uint16_t x2apId)
Set old ENB UE X2 AP ID function.
uint32_t GetNumberOfIes() const
Get number of IEs function.
EpcX2HandoverRequestAckHeader.
uint16_t GetNewEnbUeX2apId() const
Get new ENB UE X2 AP ID function.
uint32_t GetLengthOfIes() const
Get length of IEs function.
std::vector< EpcX2Sap::ErabNotAdmittedItem > GetNotAdmittedBearers() const
Get not admitted bearers function.
uint16_t GetOldEnbUeX2apId() const
Get old ENB UE X2 AP ID function.
std::vector< EpcX2Sap::ErabAdmittedItem > GetAdmittedBearers() const
Get admittied bearers function.
void SetNotAdmittedBearers(std::vector< EpcX2Sap::ErabNotAdmittedItem > bearers)
Set not admitted bearers function.
void SetNewEnbUeX2apId(uint16_t x2apId)
Set new ENB UE X2 AP ID function.
void SetOldEnbUeX2apId(uint16_t x2apId)
Set old ENB UE X2 AP ID function.
uint32_t GetNumberOfIes() const
Get number of IEs function.
void SetAdmittedBearers(std::vector< EpcX2Sap::ErabAdmittedItem > bearers)
Set admitted bearers function.
EpcX2HandoverRequestHeader.
uint16_t GetCause() const
Get cause function.
void SetCause(uint16_t cause)
Set cause function.
void SetMmeUeS1apId(uint32_t mmeUeS1apId)
Set MME UE S1 AP ID function.
uint32_t GetMmeUeS1apId() const
Get MME UE S1 AP ID function.
void SetTargetCellId(uint16_t targetCellId)
Set target cell id function.
void SetUeAggregateMaxBitRateUplink(uint64_t bitRate)
Set UE Aggregate Max Bit Rate Uplik function.
uint64_t GetUeAggregateMaxBitRateUplink() const
Get UE Aggregate Max Bit Rate Uplik function.
uint16_t GetTargetCellId() const
Get target cell id function.
void SetBearers(std::vector< EpcX2Sap::ErabToBeSetupItem > bearers)
Set bearers function.
uint64_t GetUeAggregateMaxBitRateDownlink() const
Get UE Aggregate Max Bit Rate Downlink function.
void SetUeAggregateMaxBitRateDownlink(uint64_t bitRate)
Set UE Aggregate Max Bit Rate Downlink function.
void SetOldEnbUeX2apId(uint16_t x2apId)
Set old ENB X2 AP ID function.
uint32_t GetNumberOfIes() const
Get number of IEs.
uint16_t GetOldEnbUeX2apId() const
Get old ENB X2 AP ID function.
uint32_t GetLengthOfIes() const
Get length of IEs.
std::vector< EpcX2Sap::ErabToBeSetupItem > GetBearers() const
Get bearers function.
This entity is installed inside an eNB and provides the functionality for the X2 interface.
EpcX2SapUser * m_x2SapUser
X2 SAP user.
virtual void DoSendHandoverRequestAck(EpcX2SapProvider::HandoverRequestAckParams params)
Send handover request ack function.
EpcX2SapProvider * m_x2SapProvider
X2 SAP provider.
virtual void DoSendUeContextRelease(EpcX2SapProvider::UeContextReleaseParams params)
Send UE context release function.
void DoDispose() override
Destructor implementation.
void AddX2Interface(uint16_t enb1CellId, Ipv4Address enb1X2Address, std::vector< uint16_t > enb2CellIds, Ipv4Address enb2X2Address)
Add an X2 interface to this EPC X2 entity.
std::map< uint16_t, Ptr< X2IfaceInfo > > m_x2InterfaceSockets
Map the targetCellId to the corresponding (sourceSocket, remoteIpAddr) to be used to send the X2 mess...
virtual void DoSendResourceStatusUpdate(EpcX2SapProvider::ResourceStatusUpdateParams params)
Send resource status update function.
friend class EpcX2SpecificEpcX2SapProvider< EpcX2 >
allow EpcX2SpecificEpcX2SapProvider<EpcX2> class friend access
virtual void DoSendHandoverPreparationFailure(EpcX2SapProvider::HandoverPreparationFailureParams params)
Send handover preparation failure function.
void RecvFromX2cSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the X2-C (X2 Control Plane) socket.
~EpcX2() override
Destructor.
virtual void DoSendHandoverRequest(EpcX2SapProvider::HandoverRequestParams params)
Send handover request function.
static TypeId GetTypeId()
Get the type ID.
std::map< Ptr< Socket >, Ptr< X2CellInfo > > m_x2InterfaceCellIds
Map the localSocket (the one receiving the X2 message) to the corresponding (sourceCellId,...
virtual void DoSendUeData(EpcX2SapProvider::UeDataParams params)
Send UE data function.
EpcX2SapProvider * GetEpcX2SapProvider()
uint16_t m_x2uUdpPort
UDP ports to be used for the X2-U interface.
uint16_t m_x2cUdpPort
UDP ports to be used for the X2-C interface.
virtual void DoSendLoadInformation(EpcX2SapProvider::LoadInformationParams params)
Send load information function.
virtual void DoSendSnStatusTransfer(EpcX2SapProvider::SnStatusTransferParams params)
Send SN status transfer function.
void SetEpcX2SapUser(EpcX2SapUser *s)
virtual void DoSendHandoverCancel(EpcX2SapProvider::HandoverCancelParams params)
Send Handover Cancel function.
void RecvFromX2uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the X2-U (X2 User Plane) socket.
These service primitives of this part of the X2 SAP are provided by the X2 entity and issued by RRC e...
These service primitives of this part of the X2 SAP are provided by the RRC entity and issued by the ...
virtual void RecvUeData(UeDataParams params)=0
Receive UE data function.
virtual void RecvUeContextRelease(UeContextReleaseParams params)=0
Receive UE context release function.
virtual void RecvHandoverCancel(HandoverCancelParams params)=0
Receive handover cancel function.
virtual void RecvSnStatusTransfer(SnStatusTransferParams params)=0
Receive SN status transfer function.
virtual void RecvLoadInformation(LoadInformationParams params)=0
Receive load information function.
virtual void RecvHandoverRequestAck(HandoverRequestAckParams params)=0
Receive handover request ack function.
virtual void RecvResourceStatusUpdate(ResourceStatusUpdateParams params)=0
Receive resource status update function.
virtual void RecvHandoverPreparationFailure(HandoverPreparationFailureParams params)=0
Receive handover preparation failure function.
virtual void RecvHandoverRequest(HandoverRequestParams params)=0
Receive handover request function.
Ipv4 addresses are stored in host order in this class.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
X2CellInfo & operator=(const X2CellInfo &value)
Assignment operator.
std::vector< uint16_t > m_remoteCellIds
remote cell IDs
X2CellInfo(std::vector< uint16_t > localCellIds, std::vector< uint16_t > remoteCellIds)
Constructor.
std::vector< uint16_t > m_localCellIds
local cell IDs
Ptr< Socket > m_localCtrlPlaneSocket
local control plane socket
Ipv4Address m_remoteIpAddr
remote IP address
X2IfaceInfo & operator=(const X2IfaceInfo &value)
Assignment operator.
X2IfaceInfo(Ipv4Address remoteIpAddr, Ptr< Socket > localCtrlPlaneSocket, Ptr< Socket > localUserPlaneSocket)
Constructor.
Ptr< Socket > m_localUserPlaneSocket
local user plane socket
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Parameters of the HANDOVER CANCEL message.
Parameters of the HANDOVER PREPARATION FAILURE message.
Parameters of the HANDOVER REQUEST ACKNOWLEDGE message.
Parameters of the HANDOVER REQUEST message.
Parameters of the RESOURCE STATUS UPDATE message.
Parameters of the SN STATUS TRANSFER message.
Parameters of the UE CONTEXT RELEASE message.
Parameters of the UE DATA primitive.