|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #include "ns3/abort.h"
24 #include "ns3/mac48-address.h"
26 #include "ns3/ipv4-l3-protocol.h"
28 #include "ns3/ipv6-header.h"
29 #include "ns3/ipv6-l3-protocol.h"
30 #include "ns3/inet-socket-address.h"
31 #include "ns3/epc-gtpu-header.h"
32 #include "ns3/epc-pgw-application.h"
52 m_teidByBearerIdMap[bearerId] = teid;
53 return m_tftClassifier.Add (tft, teid);
60 std::map<uint8_t, uint32_t >::iterator it = m_teidByBearerIdMap.find (bearerId);
61 m_tftClassifier.Delete (it->second);
62 m_teidByBearerIdMap.erase (bearerId);
120 .SetGroupName (
"Lte")
121 .AddTraceSource (
"RxFromTun",
122 "Receive data packets from internet in Tunnel NetDevice",
124 "ns3::EpcPgwApplication::RxTracedCallback")
125 .AddTraceSource (
"RxFromS1u",
126 "Receive data packets from S5 Socket",
128 "ns3::EpcPgwApplication::RxTracedCallback")
152 NS_LOG_FUNCTION (
this << tunDevice << s5Addr << s5uSocket << s5cSocket);
177 std::map<Ipv4Address, Ptr<UeInfo> >::iterator it =
m_ueInfoByAddrMap.find (ueAddr);
185 uint32_t teid = it->second->Classify (packet, protocolNumber);
188 NS_LOG_WARN (
"no matching bearer for this packet");
212 uint32_t teid = it->second->Classify (packet, protocolNumber);
215 NS_LOG_WARN (
"no matching bearer for this packet");
231 const bool succeeded =
true;
245 uint32_t teid = gtpu.
GetTeid ();
291 uint64_t imsi = msg.
GetImsi ();
301 "Wrong interface type");
309 pgwS5cFteid.
teid = sgwS5cFteid.
teid;
313 std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts =
315 NS_LOG_DEBUG (
"BearerContextsToBeCreated size = " << bearerContexts.size ());
317 std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContextsCreated;
318 for (
auto &bearerContext : bearerContexts)
320 uint32_t teid = bearerContext.sgwS5uFteid.teid;
321 NS_LOG_DEBUG (
"bearerId " << (uint16_t)bearerContext.epsBearerId <<
322 " SGW " << bearerContext.sgwS5uFteid.addr <<
" TEID " << teid);
324 ueit->second->AddBearer (bearerContext.epsBearerId, teid, bearerContext.tft);
330 bearerContextOut.
epsBearerId = bearerContext.epsBearerId;
332 bearerContextOut.
tft = bearerContext.tft;
333 bearerContextsCreated.push_back (bearerContextOut);
336 NS_LOG_DEBUG (
"BearerContextsCreated size = " << bearerContextsCreated.size ());
354 uint64_t imsi = msg.
GetImsi ();
362 std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts =
364 NS_LOG_DEBUG (
"BearerContextsToBeModified size = " << bearerContexts.size ());
366 for (
auto &bearerContext : bearerContexts)
369 uint32_t teid = bearerContext.fteid.teid;
370 NS_LOG_DEBUG (
"bearerId " << (uint16_t)bearerContext.epsBearerId <<
371 " SGW " << sgwAddr <<
" TEID " << teid);
393 std::list<uint8_t> epsBearerIds;
396 NS_LOG_DEBUG (
"ebid " << (uint16_t) bearerContext.m_epsBearerId);
397 epsBearerIds.push_back (bearerContext.m_epsBearerId);
419 uint64_t imsi = msg.
GetTeid ();
426 NS_LOG_INFO (
"PGW removing bearer " << (uint16_t) epsBearerId <<
" of IMSI " << imsi);
427 ueit->second->RemoveBearer (epsBearerId);
440 ipType = (ipType>>4) & 0x0f;
442 uint16_t protocol = 0;
447 else if (ipType == 0x06)
496 ueit->second->SetUeAddr (ueAddr);
507 ueit->second->SetUeAddr6 (ueAddr);
void AddUe(uint64_t imsi)
Let the PGW be aware of a new UE.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void DoRecvDeleteBearerCommand(Ptr< Packet > packet)
Process Delete Bearer Command message.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
virtual void DoDispose()
Destructor implementation.
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
UeInfo stored by IMSI.
uint32_t Classify(Ptr< Packet > p, uint16_t protocolNumber)
Classify the packet according to TFTs of this UE.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void DoRecvDeleteBearerResponse(Ptr< Packet > packet)
Process Delete Bearer Response message.
void AddHeader(const Header &header)
Add header to this packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< BearerContextToBeCreated > GetBearerContextsToBeCreated() const
TracedCallback< Ptr< Packet > > m_rxTunPktTrace
Callback to trace received data packets at Tun NetDevice from internet.
Ptr< VirtualNetDevice > m_tunDevice
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP...
EpsBearer bearerLevelQos
Bearer QOS level.
uint32_t GetUliEcgi() const
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Ipv4Address m_sgwS5Addr
SGW address of the S5 interface.
Ipv4 addresses are stored in host order in this class.
void RemoveBearer(uint8_t bearerId)
Delete context of bearer for this UE on PGW side.
Describes an IPv6 address.
Ipv4Address GetUeAddr()
Get the IPv4 address of the UE.
@ PACKET_HOST
Packet addressed oo us.
static TypeId GetTypeId(void)
Get the type ID.
std::map< Ipv6Address, Ptr< UeInfo > > m_ueInfoByAddrMap6
UeInfo stored by UE IPv6 address.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
virtual Address GetAddress(void) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Callback< R, Ts... > MakeNullCallback(void)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void DoRecvCreateSessionRequest(Ptr< Packet > packet)
Process Create Session Request message.
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a data packet to the internet via the SGi interface of the PGW.
GtpcHeader::Fteid_t GetSenderCpFteid() const
void SendToS5uSocket(Ptr< Packet > packet, Ipv4Address sgwS5uAddress, uint32_t teid)
Send a data packet to the SGW via the S5-U interface.
void RecvFromS5uSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-U socket.
void RecvFromS5cSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-C socket.
Ipv4Address m_pgwS5Addr
PGW address of the S5 interface.
Ptr< EpcTft > tft
Bearer traffic flow template.
Smart pointer class similar to boost::intrusive_ptr.
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
void AddBearer(uint8_t bearerId, uint32_t teid, Ptr< EpcTft > tft)
Add a bearer for this UE on PGW side.
virtual ~EpcPgwApplication(void)
Destructor.
a polymophic address class
A base class which provides memory management and object aggregation.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void SetUeAddr6(Ipv6Address addr)
Set the IPv6 address of the UE.
Ipv6Address GetUeAddr6()
Get the IPv6 address of the UE.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void SetCause(Cause_t cause)
uint16_t m_gtpcUdpPort
UDP port to be used for GTPv2-C.
std::list< uint8_t > GetEpsBearerIds() const
Ipv4Address GetSgwAddr()
Get the address of the SGW to which the UE is connected.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void SetBearerContextsCreated(std::list< BearerContextCreated > bearerContexts)
void SetUeAddr(Ipv4Address addr)
Set the IPv4 address of the UE.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
uint32_t GetUliEcgi() const
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
Set the address of a previously added UE.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Method to be assigned to the callback of the SGi TUN VirtualNetDevice.
std::list< BearerContextToBeModified > GetBearerContextsToBeModified() const
std::list< BearerContext > GetBearerContexts() const
void SetCause(Cause_t cause)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
TracedCallback< Ptr< Packet > > m_rxS5PktTrace
Callback to trace received data packets from S5 socket.
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Ptr< Socket > m_s5uSocket
UDP socket to send/receive GTP-U packets to/from the S5 interface.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr)
set the address of a previously added UE
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void DoRecvModifyBearerRequest(Ptr< Packet > packet)
Process Modify Bearer Request message.
uint16_t m_gtpuUdpPort
UDP port to be used for GTP-U.
uint8_t epsBearerId
EPS bearer ID.
void AddSgw(Ipv4Address sgwS5Addr)
Let the PGW be aware of a new SGW.
void SetSgwAddr(Ipv4Address addr)
Set the address of the eNB to which the UE is connected.
GtpcHeader::Fteid_t fteid
FTEID.
EpcPgwApplication(const Ptr< VirtualNetDevice > tunDevice, Ipv4Address s5Addr, const Ptr< Socket > s5uSocket, const Ptr< Socket > s5cSocket)
Constructor that binds the tap device to the callback methods.
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
UeInfo stored by UE IPv4 address.
Ptr< Socket > m_s5cSocket
UDP socket to send/receive GTPv2-C packets to/from the S5 interface.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.