20 #include "ns3/epc-mme-application.h"
22 #include "ns3/epc-gtpc-header.h"
83 enbInfo->s1uAddr = enbS1uAddr;
84 enbInfo->s1apSapEnb = enbS1apSap;
94 ueInfo->mmeUeS1Id = imsi;
95 ueInfo->bearerCounter = 0;
103 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
106 "too many bearers already! " << it->second->bearerCounter);
108 bearerInfo.
bearerId = ++(it->second->bearerCounter);
109 bearerInfo.
tft = tft;
110 bearerInfo.
bearer = bearer;
111 it->second->bearersToBeActivated.push_back(bearerInfo);
124 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
126 it->second->cellId = gci;
134 mmeS11Fteid.
teid = imsi;
138 std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts;
139 for (std::list<BearerInfo>::iterator bit = it->second->bearersToBeActivated.begin();
140 bit != it->second->bearersToBeActivated.end();
145 bearerContext.
tft = bit->tft;
147 bearerContexts.push_back(bearerContext);
149 NS_LOG_DEBUG(
"BearerContextToBeCreated size = " << bearerContexts.size());
165 std::list<EpcS1apSapMme::ErabSetupItem> erabSetupList)
176 std::list<EpcS1apSapMme::ErabSwitchedInDownlinkItem> erabToBeSwitchedInDownlinkList)
179 uint64_t imsi = mmeUeS1Id;
180 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
182 NS_LOG_INFO(
"IMSI " << imsi <<
" old eNB: " << it->second->cellId <<
", new eNB: " << gci);
183 it->second->cellId = gci;
184 it->second->enbUeS1Id = enbUeS1Id;
190 std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts;
191 for (
auto& erab : erabToBeSwitchedInDownlinkList)
193 NS_LOG_DEBUG(
"erabId " << erab.erabId <<
" eNB " << erab.enbTransportLayerAddress
194 <<
" TEID " << erab.enbTeid);
199 bearerContext.
fteid.
addr = erab.enbTransportLayerAddress;
201 bearerContexts.push_back(bearerContext);
217 std::list<EpcS1apSapMme::ErabToBeReleasedIndication> erabToBeReleaseIndication)
220 uint64_t imsi = mmeUeS1Id;
221 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
225 std::list<GtpcDeleteBearerCommandMessage::BearerContext> bearerContexts;
226 for (
auto& erab : erabToBeReleaseIndication)
231 bearerContexts.push_back(bearerContext);
247 std::list<BearerInfo>::iterator bit = ueInfo->bearersToBeActivated.begin();
248 while (bit != ueInfo->bearersToBeActivated.end())
250 if (bit->bearerId == epsBearerId)
252 ueInfo->bearersToBeActivated.erase(bit);
253 ueInfo->bearerCounter = ueInfo->bearerCounter - 1;
294 uint64_t imsi = header.
GetTeid();
296 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
298 uint16_t cellId = it->second->cellId;
299 uint16_t enbUeS1Id = it->second->enbUeS1Id;
300 uint64_t mmeUeS1Id = it->second->mmeUeS1Id;
301 NS_LOG_DEBUG(
"cellId " << cellId <<
" mmeUeS1Id " << mmeUeS1Id <<
" enbUeS1Id " << enbUeS1Id);
302 std::map<uint16_t, Ptr<EnbInfo>>::iterator jt =
m_enbInfoMap.find(cellId);
308 std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList;
309 std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContexts =
311 NS_LOG_DEBUG(
"BearerContextsCreated size = " << bearerContexts.size());
312 for (
auto& bearerContext : bearerContexts)
315 erab.
erabId = bearerContext.epsBearerId;
318 erab.
sgwTeid = bearerContext.fteid.teid;
320 erabToBeSetupList.push_back(erab);
323 NS_LOG_DEBUG(
"Send InitialContextSetupRequest to eNB " << jt->second->s1apSapEnb);
324 jt->second->s1apSapEnb->InitialContextSetupRequest(mmeUeS1Id, enbUeS1Id, erabToBeSetupList);
335 uint64_t imsi = header.
GetTeid();
337 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
339 uint16_t cellId = it->second->cellId;
340 uint16_t enbUeS1Id = it->second->enbUeS1Id;
341 uint64_t mmeUeS1Id = it->second->mmeUeS1Id;
342 NS_LOG_DEBUG(
"cellId " << cellId <<
" mmeUeS1Id " << mmeUeS1Id <<
" enbUeS1Id " << enbUeS1Id);
343 std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem>
344 erabToBeSwitchedInUplinkList;
345 std::map<uint16_t, Ptr<EnbInfo>>::iterator jt =
m_enbInfoMap.find(cellId);
348 NS_LOG_DEBUG(
"Send PathSwitchRequestAcknowledge to eNB " << jt->second->s1apSapEnb);
349 jt->second->s1apSapEnb->PathSwitchRequestAcknowledge(enbUeS1Id,
352 erabToBeSwitchedInUplinkList);
359 uint64_t imsi = header.
GetTeid();
361 std::map<uint64_t, Ptr<UeInfo>>::iterator it =
m_ueInfoMap.find(imsi);
369 std::list<uint8_t> epsBearerIds;
372 epsBearerIds.push_back(ebid);
381 if (it->second->cellId == 0)
This application implements the Mobility Management Entity (MME) according to the 3GPP TS 23....
EpcMmeApplication()
Constructor.
void AddUe(uint64_t imsi)
Add a new UE to the MME.
void DoPathSwitchRequest(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t cgi, std::list< EpcS1apSapMme::ErabSwitchedInDownlinkItem > erabToBeSwitchedInDownlinkList)
Process the S1 Path Switch Request received from an eNB.
void AddEnb(uint16_t ecgi, Ipv4Address enbS1UAddr, EpcS1apSapEnb *enbS1apSap)
Add a new eNB to the MME.
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoMap
UeInfo stored by IMSI.
void AddSgw(Ipv4Address sgwS11Addr, Ipv4Address mmeS11Addr, Ptr< Socket > mmeS11Socket)
Add a new SGW to the MME.
Ptr< Socket > m_s11Socket
Socket to send/receive messages in the S11 interface.
friend class MemberEpcS1apSapMme< EpcMmeApplication >
allow MemberEpcS1apSapMme<EpcMme> class friend access
EpcS1apSapMme * m_s1apSapMme
EpcS1apSapMme.
Ipv4Address m_mmeS11Addr
IPv4 address of the MME S11 interface.
Ipv4Address m_sgwS11Addr
IPv4 address of the SGW S11 interface.
~EpcMmeApplication() override
Destructor.
void DoInitialContextSetupResponse(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapMme::ErabSetupItem > erabSetupList)
Process the S1 Initial Context Setup Response received from an eNB.
void DoInitialUeMessage(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, uint64_t imsi, uint16_t ecgi)
Process the S1 Initial UE Message received from an eNB.
static TypeId GetTypeId()
Get the type ID.
void DoErabReleaseIndication(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapMme::ErabToBeReleasedIndication > erabToBeReleaseIndication)
Process ERAB Release Indication received from an eNB.
void DoRecvCreateSessionResponse(GtpcHeader &header, Ptr< Packet > packet)
Process GTP-C Create Session Response message.
void DoRecvDeleteBearerRequest(GtpcHeader &header, Ptr< Packet > packet)
Process GTP-C Delete Bearer Request message.
void DoRecvModifyBearerResponse(GtpcHeader &header, Ptr< Packet > packet)
Process GTP-C Modify Bearer Response message.
std::map< uint16_t, Ptr< EnbInfo > > m_enbInfoMap
EnbInfo stored by EGCI.
void RemoveBearer(Ptr< UeInfo > ueInfo, uint8_t epsBearerId)
This Function erases all contexts of bearer from MME side.
uint8_t AddBearer(uint64_t imsi, Ptr< EpcTft > tft, EpsBearer bearer)
Add an EPS bearer to the list of bearers to be activated for this UE.
uint16_t m_gtpcUdpPort
UDP port for GTP-C protocol. Fixed by the standard to port 2123.
void DoDispose() override
Destructor implementation.
EpcS1apSapMme * GetS1apSapMme()
void RecvFromS11Socket(Ptr< Socket > socket)
Reads the S11 messages from a socket.
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...
This class contains the specification of EPS Bearers.
GTP-C Create Session Request Message.
void SetUliEcgi(uint32_t uliEcgi)
Set the UliEcgi.
void SetBearerContextsToBeCreated(std::list< BearerContextToBeCreated > bearerContexts)
Set the Bearer Contexts.
void SetImsi(uint64_t imsi)
Set the IMSI.
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Set the Sender CpFteid.
GTP-C Create Session Response Message.
std::list< BearerContextCreated > GetBearerContextsCreated() const
Get the Container of Bearer Contexts.
GTP-C Delete Bearer Command Message.
void SetBearerContexts(std::list< BearerContext > bearerContexts)
Set the Bearer contexts.
GTP-C Delete Bearer Request Message.
std::list< uint8_t > GetEpsBearerIds() const
Get the Bearers IDs.
GTP-C Delete Bearer Response Message.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Set the Bearers IDs.
GTP-C Modify Bearer Request Message.
void SetBearerContextsToBeModified(std::list< BearerContextToBeModified > bearerContexts)
Set the Bearer Contexts.
void SetUliEcgi(uint32_t uliEcgi)
Set the UliEcgi.
void SetImsi(uint64_t imsi)
Set the IMSI.
GTP-C Modify Bearer Response Message.
Cause_t GetCause() const
Get the Cause.
Ipv4 addresses are stored in host order in this class.
A base class which provides memory management and object aggregation.
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 PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
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_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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...
Hold info on an EPS bearer to be activated.
uint8_t bearerId
bearer ID
EpsBearer bearer
bearer QOS characteristics
Ptr< EpcTft > tft
traffic flow template
ErabToBeSetupItem structure.
EpsBearer erabLevelQosParameters
Level QOS parameters.
Ipv4Address transportLayerAddress
transport layer address
Bearer Context structure.
EpsBearer bearerLevelQos
bearer QOS level
uint8_t epsBearerId
EPS bearer ID.
Ptr< EpcTft > tft
traffic flow template
uint8_t m_epsBearerId
EPS bearer ID.
Bearer Context structure.
uint8_t epsBearerId
EPS bearer ID.
GtpcHeader::Fteid_t fteid
FTEID.