14#include "ns3/inet-socket-address.h"
17#include "ns3/packet.h"
52 : m_localCellIds{localCellIds},
53 m_remoteCellIds{remoteCellIds}
122 std::vector<uint16_t> remoteCellIds,
125 uint16_t remoteCellId = remoteCellIds.at(0);
126 NS_LOG_FUNCTION(
this << localCellId << localX2Address << remoteCellId << remoteX2Address);
147 std::vector<uint16_t> localCellIds;
148 localCellIds.push_back(localCellId);
151 "Mapping for remoteCellId = " << remoteCellId <<
" is already known");
152 for (uint16_t remoteCellId : remoteCellIds)
159 "Mapping for control plane localSocket = " << localX2cSocket
160 <<
" is already known");
164 "Mapping for data plane localSocket = " << localX2uSocket <<
" is already known");
178 "Missing infos of local and remote CellId");
182 packet->RemoveHeader(x2Header);
196 packet->RemoveHeader(x2HoReqHeader);
198 NS_LOG_INFO(
"X2 HandoverRequest header: " << x2HoReqHeader);
202 params.cause = x2HoReqHeader.
GetCause();
203 params.sourceCellId = cellsInfo->m_remoteCellIds.at(0);
209 params.rrcContext = packet;
211 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
215 NS_LOG_LOGIC(
"cellsInfo->m_localCellId = " << cellsInfo->m_localCellIds.at(0));
224 packet->RemoveHeader(x2HoReqAckHeader);
226 NS_LOG_INFO(
"X2 HandoverRequestAck header: " << x2HoReqAckHeader);
231 params.sourceCellId = cellsInfo->m_localCellIds.at(0);
232 params.targetCellId = cellsInfo->m_remoteCellIds.at(0);
235 params.rrcContext = packet;
237 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
238 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
246 NS_LOG_LOGIC(
"Recv X2 message: HANDOVER PREPARATION FAILURE");
249 packet->RemoveHeader(x2HoPrepFailHeader);
251 NS_LOG_INFO(
"X2 HandoverPreparationFailure header: " << x2HoPrepFailHeader);
255 params.sourceCellId = cellsInfo->m_localCellIds.at(0);
256 params.targetCellId = cellsInfo->m_remoteCellIds.at(0);
257 params.cause = x2HoPrepFailHeader.
GetCause();
260 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
264 NS_LOG_LOGIC(
"criticalityDiagnostics = " << params.criticalityDiagnostics);
276 packet->RemoveHeader(x2LoadInfoHeader);
278 NS_LOG_INFO(
"X2 LoadInformation header: " << x2LoadInfoHeader);
283 NS_LOG_LOGIC(
"cellInformationList size = " << params.cellInformationList.size());
295 packet->RemoveHeader(x2SnStatusXferHeader);
297 NS_LOG_INFO(
"X2 SnStatusTransfer header: " << x2SnStatusXferHeader);
302 params.sourceCellId = cellsInfo->m_remoteCellIds.at(0);
303 params.targetCellId = cellsInfo->m_localCellIds.at(0);
304 params.erabsSubjectToStatusTransferList =
307 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
308 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
311 NS_LOG_LOGIC(
"erabsList size = " << params.erabsSubjectToStatusTransferList.size());
323 packet->RemoveHeader(x2UeCtxReleaseHeader);
325 NS_LOG_INFO(
"X2 UeContextRelease header: " << x2UeCtxReleaseHeader);
331 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
332 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
341 NS_LOG_LOGIC(
"Recv X2 message: RESOURCE STATUS UPDATE");
344 packet->RemoveHeader(x2ResStatUpdHeader);
346 NS_LOG_INFO(
"X2 ResourceStatusUpdate header: " << x2ResStatUpdHeader);
349 params.targetCellId = 0;
354 NS_LOG_LOGIC(
"enb1MeasurementId = " << params.enb1MeasurementId);
355 NS_LOG_LOGIC(
"enb2MeasurementId = " << params.enb2MeasurementId);
357 "cellMeasurementResultList size = " << params.cellMeasurementResultList.size());
369 packet->RemoveHeader(x2HoCancelHeader);
371 NS_LOG_INFO(
"X2 HandoverCancel header: " << x2HoCancelHeader);
376 params.sourceCellId = cellsInfo->m_localCellIds.at(0);
377 params.targetCellId = cellsInfo->m_remoteCellIds.at(0);
378 params.cause = x2HoCancelHeader.
GetCause();
380 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
381 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
400 NS_LOG_LOGIC(
"Recv UE DATA through X2-U interface from Socket");
405 "Missing infos of local and remote CellId");
409 packet->RemoveHeader(gtpu);
414 params.sourceCellId = cellsInfo->m_remoteCellIds.at(0);
415 params.targetCellId = cellsInfo->m_localCellIds.at(0);
416 params.gtpTeid = gtpu.
GetTeid();
417 params.ueData = packet;
430 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
436 "Missing infos for targetCellId = " << params.targetCellId);
438 Ptr<Socket> sourceSocket = socketInfo->m_localCtrlPlaneSocket;
439 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
449 x2HoReqHeader.
SetCause(params.cause);
463 NS_LOG_INFO(
"X2 HandoverRequest header: " << x2HoReqHeader);
467 packet->AddHeader(x2HoReqHeader);
468 packet->AddHeader(x2Header);
480 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
481 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
486 "Socket infos not defined for sourceCellId = " << params.sourceCellId);
494 NS_LOG_INFO(
"Send X2 message: HANDOVER REQUEST ACK");
510 NS_LOG_INFO(
"X2 HandoverAck header: " << x2HoAckHeader);
515 packet->AddHeader(x2HoAckHeader);
516 packet->AddHeader(x2Header);
528 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
532 NS_LOG_LOGIC(
"criticalityDiagnostics = " << params.criticalityDiagnostics);
535 "Socket infos not defined for sourceCellId = " << params.sourceCellId);
543 NS_LOG_INFO(
"Send X2 message: HANDOVER PREPARATION FAILURE");
548 x2HoPrepFailHeader.
SetCause(params.cause);
558 NS_LOG_INFO(
"X2 HandoverPrepFail header: " << x2HoPrepFailHeader);
562 packet->AddHeader(x2HoPrepFailHeader);
563 packet->AddHeader(x2Header);
575 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
576 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
579 NS_LOG_LOGIC(
"erabsList size = " << params.erabsSubjectToStatusTransferList.size());
582 "Socket infos not defined for targetCellId = " << params.targetCellId);
590 NS_LOG_INFO(
"Send X2 message: SN STATUS TRANSFER");
597 params.erabsSubjectToStatusTransferList);
606 NS_LOG_INFO(
"X2 SnStatusTransfer header: " << x2SnStatusXferHeader);
610 packet->AddHeader(x2SnStatusXferHeader);
611 packet->AddHeader(x2Header);
623 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
624 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
628 "Socket infos not defined for sourceCellId = " << params.sourceCellId);
636 NS_LOG_INFO(
"Send X2 message: UE CONTEXT RELEASE");
650 NS_LOG_INFO(
"X2 UeContextRelease header: " << x2UeCtxReleaseHeader);
654 packet->AddHeader(x2UeCtxReleaseHeader);
655 packet->AddHeader(x2Header);
668 NS_LOG_LOGIC(
"cellInformationList size = " << params.cellInformationList.size());
671 "Missing infos for targetCellId = " << params.targetCellId);
673 Ptr<Socket> sourceSocket = socketInfo->m_localCtrlPlaneSocket;
674 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
692 NS_LOG_INFO(
"X2 LoadInformation header: " << x2LoadInfoHeader);
696 packet->AddHeader(x2LoadInfoHeader);
697 packet->AddHeader(x2Header);
710 NS_LOG_LOGIC(
"enb1MeasurementId = " << params.enb1MeasurementId);
711 NS_LOG_LOGIC(
"enb2MeasurementId = " << params.enb2MeasurementId);
712 NS_LOG_LOGIC(
"cellMeasurementResultList size = " << params.cellMeasurementResultList.size());
715 "Missing infos for targetCellId = " << params.targetCellId);
717 Ptr<Socket> sourceSocket = socketInfo->m_localCtrlPlaneSocket;
718 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
723 NS_LOG_INFO(
"Send X2 message: RESOURCE STATUS UPDATE");
738 NS_LOG_INFO(
"X2 ResourceStatusUpdate header: " << x2ResourceStatUpdHeader);
742 packet->AddHeader(x2ResourceStatUpdHeader);
743 packet->AddHeader(x2Header);
760 "Missing infos for targetCellId = " << params.targetCellId);
762 Ptr<Socket> sourceSocket = socketInfo->m_localUserPlaneSocket;
763 Ipv4Address targetIpAddr = socketInfo->m_remoteIpAddr;
775 packet->AddHeader(gtpu);
777 NS_LOG_INFO(
"Forward UE DATA through X2 interface");
786 NS_LOG_LOGIC(
"oldEnbUeX2apId = " << params.oldEnbUeX2apId);
787 NS_LOG_LOGIC(
"newEnbUeX2apId = " << params.newEnbUeX2apId);
792 "Socket infos not defined for targetCellId = " << params.targetCellId);
806 x2HandoverCancelHeader.
SetCause(params.cause);
815 NS_LOG_INFO(
"X2 UeContextRelease header: " << x2HandoverCancelHeader);
819 packet->AddHeader(x2HandoverCancelHeader);
820 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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.