26 #include "ns3/inet-socket-address.h"
29 #include "ns3/mac48-address.h"
30 #include "ns3/uinteger.h"
63 TypeId(
"ns3::EpcEnbApplication")
66 .AddTraceSource(
"RxFromEnb",
67 "Receive data packets from LTE Enb Net Device",
69 "ns3::EpcEnbApplication::RxTracedCallback")
70 .AddTraceSource(
"RxFromS1u",
71 "Receive data packets from S1-U Net Device",
73 "ns3::EpcEnbApplication::RxTracedCallback");
159 uint16_t enbUeS1Id =
params.rnti;
160 uint64_t mmeUeS1Id =
params.mmeUeS1Id;
161 uint64_t imsi = mmeUeS1Id;
165 uint16_t gci =
params.cellId;
166 std::list<EpcS1apSapMme::ErabSwitchedInDownlinkItem> erabToBeSwitchedInDownlinkList;
167 for (
auto bit =
params.bearersToBeSwitched.begin(); bit !=
params.bearersToBeSwitched.end();
172 flowId.
m_bid = bit->epsBearerId;
173 uint32_t teid = bit->teid;
181 erab.
erabId = bit->epsBearerId;
185 erabToBeSwitchedInDownlinkList.push_back(erab);
197 for (
auto bidIt = rntiIt->second.begin(); bidIt != rntiIt->second.end(); ++bidIt)
199 uint32_t teid = bidIt->second;
204 NS_LOG_INFO(
"RNTI: " << rntiIt->first <<
" erased");
212 std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList)
216 uint64_t imsi = mmeUeS1Id;
219 uint16_t rnti = imsiIt->second;
221 for (
auto erabIt = erabToBeSetupList.begin(); erabIt != erabToBeSetupList.end(); ++erabIt)
226 params.bearer = erabIt->erabLevelQosParameters;
227 params.bearerId = erabIt->erabId;
228 params.gtpTeid = erabIt->sgwTeid;
248 std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erabToBeSwitchedInUplinkList)
252 uint64_t imsi = mmeUeS1Id;
255 uint16_t rnti = imsiIt->second;
279 uint8_t bid = tag.
GetBid();
280 NS_LOG_INFO(
"Received packet with RNTI: " << rnti <<
", BID: " << +bid);
284 NS_LOG_WARN(
"UE context not found, discarding packet");
288 auto bidIt = rntiIt->second.find(bid);
289 NS_ASSERT(bidIt != rntiIt->second.end());
290 uint32_t teid = bidIt->second;
304 uint32_t teid = gtpu.
GetTeid();
305 NS_LOG_INFO(
"Received packet from S1-U interface with GTP TEID: " << teid);
324 NS_LOG_INFO(
"Add EpsBearerTag with RNTI " << rnti <<
" and bearer ID " << +bid);
328 ipType = (ipType >> 4) & 0x0f;
333 NS_LOG_INFO(
"Forward packet from eNB's S1-U to LTE stack via IPv4 socket.");
336 else if (ipType == 0x06)
338 NS_LOG_INFO(
"Forward packet from eNB's S1-U to LTE stack via IPv6 socket.");
343 NS_ABORT_MSG(
"EpcEnbApplication::SendToLteSocket - Unknown IP type...");
360 NS_LOG_INFO(
"Forward packet from eNB's LTE to S1-U stack with TEID: " << teid);
368 std::list<EpcS1apSapMme::ErabToBeReleasedIndication> erabToBeReleaseIndication;
371 erabToBeReleaseIndication.push_back(erab);
std::map< uint16_t, std::map< uint8_t, uint32_t > > m_rbidTeidMap
map of maps telling for each RNTI and BID the corresponding S1-U TEID
EpcS1apSapEnb * m_s1apSapEnb
ENB side of the S1-AP SAP.
Ipv4Address m_enbS1uAddress
address of the eNB for S1-U communications
Ptr< Socket > m_s1uSocket
UDP socket to send and receive GTP-U the packets to and from the S1-U interface.
void DoReleaseIndication(uint64_t imsi, uint16_t rnti, uint8_t bearerId)
This function accepts bearer id corresponding to a particular UE and schedules indication of bearer r...
void DoPathSwitchRequestAcknowledge(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t cgi, std::list< EpcS1apSapEnb::ErabSwitchedInUplinkItem > erabToBeSwitchedInUplinkList)
Path Switch Request Acknowledge.
void RecvFromLteSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the LTE socket.
void AddS1Interface(Ptr< Socket > s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress)
Add a S1-U interface to the eNB.
void DoInitialContextSetupRequest(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapEnb::ErabToBeSetupItem > erabToBeSetupList)
Initial Context Setup Request.
void DoDispose() override
Destructor implementation.
void DoUeContextRelease(uint16_t rnti)
UE Context Release function.
Ipv4Address m_sgwS1uAddress
address of the SGW which terminates all S1-U tunnels
Ptr< Socket > m_lteSocket
raw packet socket to send and receive the packets to and from the LTE radio interface
void SendToS1uSocket(Ptr< Packet > packet, uint32_t teid)
Send a packet to the SGW via the S1-U interface.
void SetS1apSapMme(EpcS1apSapMme *s)
Set the MME side of the S1-AP SAP.
EpcEnbS1SapProvider * GetS1SapProvider()
static TypeId GetTypeId()
Get the type ID.
void SendToLteSocket(Ptr< Packet > packet, uint16_t rnti, uint8_t bid)
Send a packet to the UE via the LTE radio interface of the eNB.
EpcS1apSapEnb * GetS1apSapEnb()
TracedCallback< Ptr< Packet > > m_rxLteSocketPktTrace
Callback to trace RX (reception) data packets from LTE Socket.
void RecvFromS1uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S1-U socket.
friend class MemberEpcEnbS1SapProvider< EpcEnbApplication >
allow MemberEpcEnbS1SapProvider<EpcEnbApplication> class friend access
std::map< uint64_t, uint16_t > m_imsiRntiMap
UE context info.
EpcEnbS1SapUser * m_s1SapUser
User for the S1 SAP.
Ptr< Socket > m_lteSocket6
raw packet socket to send and receive the packets to and from the LTE radio interface
void DoPathSwitchRequest(EpcEnbS1SapProvider::PathSwitchRequestParameters params)
Path switch request function.
uint16_t m_gtpuUdpPort
UDP port to be used for GTP.
void DoInitialUeMessage(uint64_t imsi, uint16_t rnti)
Initial UE message function.
std::map< uint32_t, EpsFlowId_t > m_teidRbidMap
map telling for each S1-U TEID the corresponding RNTI,BID
friend class MemberEpcS1apSapEnb< EpcEnbApplication >
allow MemberEpcS1apSapEnb<EpcEnbApplication> class friend access
EpcS1apSapMme * m_s1apSapMme
MME side of the S1-AP SAP.
EpcEnbApplication(Ptr< Socket > lteSocket, Ptr< Socket > lteSocket6, uint16_t cellId)
Constructor.
EpcEnbS1SapProvider * m_s1SapProvider
Provider for the S1 SAP.
void SetS1SapUser(EpcEnbS1SapUser *s)
Set the S1 SAP User.
~EpcEnbApplication() override
Destructor.
TracedCallback< Ptr< Packet > > m_rxS1uSocketPktTrace
Callback to trace RX (reception) data packets from S1-U Socket.
This class implements the Service Access Point (SAP) between the LteEnbRrc and the EpcEnbApplication.
This class implements the Service Access Point (SAP) between the LteEnbRrc and the EpcEnbApplication.
virtual void PathSwitchRequestAcknowledge(PathSwitchRequestAcknowledgeParameters params)=0
Request a path switch acknowledge.
virtual void DataRadioBearerSetupRequest(DataRadioBearerSetupRequestParameters params)=0
Request the setup of a DataRadioBearer.
virtual void InitialContextSetupRequest(InitialContextSetupRequestParameters params)=0
Initial context setup request.
eNB side of the S1-AP Service Access Point (SAP), provides the eNB methods to be called when an S1-AP...
MME side of the S1-AP Service Access Point (SAP), provides the MME methods to be called when an S1-AP...
virtual void InitialUeMessage(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t stmsi, uint16_t ecgi)=0
Initial UE message.
virtual void ErabReleaseIndication(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< ErabToBeReleasedIndication > erabToBeReleaseIndication)=0
As per 3GPP TS 36.413 version 9.8.0 section 8.2.3.2.2, the eNB indicates bearer release by sending an...
virtual void PathSwitchRequest(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t gci, std::list< ErabSwitchedInDownlinkItem > erabToBeSwitchedInDownlinkList)=0
PATH SWITCH REQUEST message, see 3GPP TS 36.413 9.1.5.8.
Tag used to define the RNTI and EPS bearer ID for packets interchanged between the EpcEnbApplication ...
uint8_t GetBid() const
Get Bearer Id function.
uint16_t GetRnti() const
Get RNTI function.
Ipv4 addresses are stored in host order in this class.
A base class which provides memory management and object aggregation.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#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_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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...
bool operator==(const EventId &a, const EventId &b)
bool operator<(const EventId &a, const EventId &b)
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
uint8_t m_bid
Bid, the EPS Bearer Identifier.
PathSwitchRequestParameters structure.
Parameters passed to DataRadioBearerSetupRequest ()
Parameters passed to InitialContextSetupRequest ()
PathSwitchRequestAcknowledgeParameters structure.
E-RABs Switched in Downlink Item IE, see 3GPP TS 36.413 9.1.5.8.
Ipv4Address enbTransportLayerAddress
address
E-RAB Release Indication Item IEs, 3GPP TS 36.413 version 9.8.0 section 9.1.3.7.