This application implements the Packet Data Network (PDN) Gateway Entity (PGW) according to the 3GPP TS 23.401 document. More...
#include "epc-pgw-application.h"
Classes | |
class | UeInfo |
store info for each UE connected to this PGW More... | |
Public Types | |
typedef void(* | RxTracedCallback) (Ptr< Packet > packet) |
TracedCallback signature for data Packet reception event. | |
Public Types inherited from ns3::Application | |
typedef void(* | DelayAddressCallback) (const Time &delay, const Address &from) |
Common callback signature for packet delay and address. | |
typedef void(* | StateTransitionCallback) (const std::string &oldState, const std::string &newState) |
Common signature used by callbacks to application's state transition trace source. | |
Public Member Functions | |
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. | |
~EpcPgwApplication () override | |
Destructor. | |
void | AddSgw (Ipv4Address sgwS5Addr) |
Let the PGW be aware of a new SGW. | |
void | AddUe (uint64_t imsi) |
Let the PGW be aware of a new UE. | |
void | DoDispose () override |
Destructor implementation. | |
void | RecvFromS5cSocket (Ptr< Socket > socket) |
Method to be assigned to the receiver callback of the S5-C socket. | |
void | RecvFromS5uSocket (Ptr< Socket > socket) |
Method to be assigned to the receiver callback of the S5-U socket. | |
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. | |
void | SendToS5uSocket (Ptr< Packet > packet, Ipv4Address sgwS5uAddress, uint32_t teid) |
Send a data packet to the SGW via the S5-U interface. | |
void | SendToTunDevice (Ptr< Packet > packet, uint32_t teid) |
Send a data packet to the internet via the SGi interface of the PGW. | |
void | SetUeAddress (uint64_t imsi, Ipv4Address ueAddr) |
Set the address of a previously added UE. | |
void | SetUeAddress6 (uint64_t imsi, Ipv6Address ueAddr) |
set the address of a previously added UE | |
Public Member Functions inherited from ns3::Application | |
Application () | |
~Application () override | |
Ptr< Node > | GetNode () const |
void | SetNode (Ptr< Node > node) |
void | SetStartTime (Time start) |
Specify application start time. | |
void | SetStopTime (Time stop) |
Specify application stop time. | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. | |
bool | IsInitialized () const |
Check if the object has been initialized. | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
virtual TypeId | GetInstanceTypeId () const =0 |
Get the most derived TypeId for this Object. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Application | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Private Member Functions | |
void | DoRecvCreateSessionRequest (Ptr< Packet > packet) |
Process Create Session Request message. | |
void | DoRecvDeleteBearerCommand (Ptr< Packet > packet) |
Process Delete Bearer Command message. | |
void | DoRecvDeleteBearerResponse (Ptr< Packet > packet) |
Process Delete Bearer Response message. | |
void | DoRecvModifyBearerRequest (Ptr< Packet > packet) |
Process Modify Bearer Request message. | |
Private Attributes | |
uint16_t | m_gtpcUdpPort |
UDP port to be used for GTPv2-C. | |
uint16_t | m_gtpuUdpPort |
UDP port to be used for GTP-U. | |
Ipv4Address | m_pgwS5Addr |
PGW address of the S5 interface. | |
TracedCallback< Ptr< Packet > > | m_rxS5PktTrace |
Callback to trace received data packets from S5 socket. | |
TracedCallback< Ptr< Packet > > | m_rxTunPktTrace |
Callback to trace received data packets at Tun NetDevice from internet. | |
Ptr< Socket > | m_s5cSocket |
UDP socket to send/receive GTPv2-C packets to/from the S5 interface. | |
Ptr< Socket > | m_s5uSocket |
UDP socket to send/receive GTP-U packets to/from the S5 interface. | |
Ipv4Address | m_sgwS5Addr |
SGW address of the S5 interface. | |
Ptr< VirtualNetDevice > | m_tunDevice |
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP on the S5 interface. | |
std::map< Ipv4Address, Ptr< UeInfo > > | m_ueInfoByAddrMap |
UeInfo stored by UE IPv4 address. | |
std::map< Ipv6Address, Ptr< UeInfo > > | m_ueInfoByAddrMap6 |
UeInfo stored by UE IPv6 address. | |
std::map< uint64_t, Ptr< UeInfo > > | m_ueInfoByImsiMap |
UeInfo stored by IMSI. | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::Application | |
void | DoDispose () override |
Destructor implementation. | |
void | DoInitialize () override |
Initialize() implementation. | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | DoDispose () |
Destructor implementation. | |
virtual void | DoInitialize () |
Initialize() implementation. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Protected Attributes inherited from ns3::Application | |
Ptr< Node > | m_node |
The node that this application is installed on. | |
EventId | m_startEvent |
The event that will fire at m_startTime to start the application. | |
Time | m_startTime |
The simulation time that the application will start. | |
EventId | m_stopEvent |
The event that will fire at m_stopTime to end the application. | |
Time | m_stopTime |
The simulation time that the application will end. | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
This application implements the Packet Data Network (PDN) Gateway Entity (PGW) according to the 3GPP TS 23.401 document.
This Application implements the PGW side of the S5 interface between the PGW node and the SGW nodes and the PGW side of the SGi interface between the PGW node and the internet hosts. It supports the following functions and messages:
Others functions enumerated in section 4.4.3.3 of 3GPP TS 23.401 are not supported.
Definition at line 52 of file epc-pgw-application.h.
TracedCallback signature for data Packet reception event.
[in] | packet | The data packet sent from the internet. |
Definition at line 166 of file epc-pgw-application.h.
ns3::EpcPgwApplication::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.
tunDevice | TUN VirtualNetDevice used to tunnel IP packets from the SGi interface of the PGW in the internet over GTP-U/UDP/IP on the S5 interface |
s5Addr | IP address of the PGW S5 interface |
s5uSocket | socket used to send GTP-U packets to the peer SGW |
s5cSocket | socket used to send GTP-C packets to the peer SGW |
Definition at line 144 of file epc-pgw-application.cc.
References m_s5cSocket, m_s5uSocket, ns3::MakeCallback(), NS_LOG_FUNCTION, RecvFromS5cSocket(), RecvFromS5uSocket(), and ns3::Socket::SetRecvCallback().
|
override |
void ns3::EpcPgwApplication::AddSgw | ( | Ipv4Address | sgwS5Addr | ) |
Let the PGW be aware of a new SGW.
sgwS5Addr | the address of the SGW S5 interface |
Definition at line 483 of file epc-pgw-application.cc.
References m_sgwS5Addr, and NS_LOG_FUNCTION.
void ns3::EpcPgwApplication::AddUe | ( | uint64_t | imsi | ) |
Let the PGW be aware of a new UE.
imsi | the unique identifier of the UE |
Definition at line 490 of file epc-pgw-application.cc.
References m_ueInfoByImsiMap, and NS_LOG_FUNCTION.
|
overridevirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.
It is safe to call GetObject() from within this method.
Reimplemented from ns3::Object.
Definition at line 135 of file epc-pgw-application.cc.
References m_s5cSocket, m_s5uSocket, ns3::MakeNullCallback(), NS_LOG_FUNCTION, and ns3::Socket::SetRecvCallback().
Process Create Session Request message.
packet | GTPv2-C Create Session Request message |
Definition at line 291 of file epc-pgw-application.cc.
References ns3::GtpcHeader::Fteid_t::addr, ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::bearerLevelQos, ns3::GtpcHeader::ComputeMessageLength(), ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::epsBearerId, ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::fteid, ns3::GtpcCreateSessionRequestMessage::GetBearerContextsToBeCreated(), ns3::GtpcCreateSessionRequestMessage::GetImsi(), ns3::GtpcCreateSessionRequestMessage::GetSenderCpFteid(), ns3::GtpcCreateSessionRequestMessage::GetUliEcgi(), ns3::GtpcHeader::Fteid_t::interfaceType, m_gtpcUdpPort, m_pgwS5Addr, m_s5cSocket, m_sgwS5Addr, m_ueInfoByImsiMap, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::GtpcIes::REQUEST_ACCEPTED, ns3::GtpcHeader::S5_PGW_GTPC, ns3::GtpcHeader::S5_PGW_GTPU, ns3::GtpcHeader::S5_SGW_GTPC, ns3::Socket::SendTo(), ns3::GtpcCreateSessionResponseMessage::SetBearerContextsCreated(), ns3::GtpcCreateSessionResponseMessage::SetCause(), ns3::GtpcCreateSessionResponseMessage::SetSenderCpFteid(), ns3::GtpcHeader::SetTeid(), ns3::GtpcHeader::Fteid_t::teid, and ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::tft.
Referenced by RecvFromS5cSocket().
Process Delete Bearer Command message.
packet | GTPv2-C Delete Bearer Command message |
Definition at line 391 of file epc-pgw-application.cc.
References ns3::GtpcHeader::ComputeMessageLength(), ns3::GtpcDeleteBearerCommandMessage::GetBearerContexts(), ns3::GtpcHeader::GetTeid(), m_gtpcUdpPort, m_s5cSocket, m_sgwS5Addr, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::Socket::SendTo(), ns3::GtpcDeleteBearerRequestMessage::SetEpsBearerIds(), and ns3::GtpcHeader::SetTeid().
Referenced by RecvFromS5cSocket().
Process Delete Bearer Response message.
packet | GTPv2-C Delete Bearer Response message |
Definition at line 417 of file epc-pgw-application.cc.
References ns3::GtpcDeleteBearerResponseMessage::GetEpsBearerIds(), ns3::GtpcHeader::GetTeid(), m_ueInfoByImsiMap, NS_ASSERT_MSG, NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by RecvFromS5cSocket().
Process Modify Bearer Request message.
packet | GTPv2-C Modify Bearer Request message |
Definition at line 353 of file epc-pgw-application.cc.
References ns3::GtpcHeader::ComputeMessageLength(), ns3::GtpcModifyBearerRequestMessage::GetBearerContextsToBeModified(), ns3::GtpcModifyBearerRequestMessage::GetImsi(), ns3::GtpcModifyBearerRequestMessage::GetUliEcgi(), m_gtpcUdpPort, m_s5cSocket, m_sgwS5Addr, m_ueInfoByImsiMap, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::GtpcIes::REQUEST_ACCEPTED, ns3::Socket::SendTo(), ns3::GtpcModifyBearerResponseMessage::SetCause(), and ns3::GtpcHeader::SetTeid().
Referenced by RecvFromS5cSocket().
|
static |
Get the type ID.
Definition at line 117 of file epc-pgw-application.cc.
References m_rxS5PktTrace, m_rxTunPktTrace, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
Method to be assigned to the receiver callback of the S5-C socket.
It is called when the PGW receives a control packet from the SGW.
socket | pointer to the S5-C socket |
Definition at line 257 of file epc-pgw-application.cc.
References ns3::GtpcHeader::CreateSessionRequest, ns3::GtpcHeader::DeleteBearerCommand, ns3::GtpcHeader::DeleteBearerResponse, DoRecvCreateSessionRequest(), DoRecvDeleteBearerCommand(), DoRecvDeleteBearerResponse(), DoRecvModifyBearerRequest(), ns3::GtpcHeader::GetMessageType(), m_s5cSocket, ns3::GtpcHeader::ModifyBearerRequest, NS_ASSERT, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by EpcPgwApplication().
Method to be assigned to the receiver callback of the S5-U socket.
It is called when the PGW receives a data packet from the SGW that is to be forwarded to the internet.
socket | pointer to the S5-U socket |
Definition at line 242 of file epc-pgw-application.cc.
References ns3::GtpuHeader::GetTeid(), m_rxS5PktTrace, m_s5uSocket, NS_ASSERT, NS_LOG_FUNCTION, and SendToTunDevice().
Referenced by EpcPgwApplication().
bool ns3::EpcPgwApplication::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.
It is called when the PGW receives a data packet from the internet (including IP headers) that is to be sent to the UE via its associated SGW and eNB, tunneling IP over GTP-U/UDP/IP.
packet | |
source | |
dest | |
protocolNumber |
Definition at line 166 of file epc-pgw-application.cc.
References ns3::Ipv4Header::GetDestination(), ns3::Ipv6Header::GetDestination(), m_rxTunPktTrace, m_ueInfoByAddrMap, m_ueInfoByAddrMap6, NS_ABORT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Ipv4L3Protocol::PROT_NUMBER, ns3::Ipv6L3Protocol::PROT_NUMBER, and SendToS5uSocket().
Referenced by ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper().
void ns3::EpcPgwApplication::SendToS5uSocket | ( | Ptr< Packet > | packet, |
Ipv4Address | sgwS5uAddress, | ||
uint32_t | teid | ||
) |
Send a data packet to the SGW via the S5-U interface.
packet | packet to be sent |
sgwS5uAddress | the address of the SGW |
teid | the Tunnel Endpoint Identifier |
Definition at line 468 of file epc-pgw-application.cc.
References ns3::GtpuHeader::GetSerializedSize(), m_gtpuUdpPort, m_s5uSocket, NS_LOG_FUNCTION, ns3::Socket::SendTo(), ns3::GtpuHeader::SetLength(), and ns3::GtpuHeader::SetTeid().
Referenced by RecvFromTunDevice().
Send a data packet to the internet via the SGi interface of the PGW.
packet | packet to be sent |
teid | the Tunnel Endpoint Identifier |
Definition at line 437 of file epc-pgw-application.cc.
References ns3::VirtualNetDevice::GetAddress(), m_tunDevice, NS_ABORT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::NetDevice::PACKET_HOST, and ns3::VirtualNetDevice::Receive().
Referenced by RecvFromS5uSocket().
void ns3::EpcPgwApplication::SetUeAddress | ( | uint64_t | imsi, |
Ipv4Address | ueAddr | ||
) |
Set the address of a previously added UE.
imsi | the unique identifier of the UE |
ueAddr | the IPv4 address of the UE |
Definition at line 498 of file epc-pgw-application.cc.
References m_ueInfoByAddrMap, m_ueInfoByImsiMap, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
void ns3::EpcPgwApplication::SetUeAddress6 | ( | uint64_t | imsi, |
Ipv6Address | ueAddr | ||
) |
set the address of a previously added UE
imsi | the unique identifier of the UE |
ueAddr | the IPv6 address of the UE |
Definition at line 508 of file epc-pgw-application.cc.
References m_ueInfoByAddrMap6, m_ueInfoByImsiMap, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
|
private |
UDP port to be used for GTPv2-C.
Definition at line 324 of file epc-pgw-application.h.
Referenced by DoRecvCreateSessionRequest(), DoRecvDeleteBearerCommand(), and DoRecvModifyBearerRequest().
|
private |
UDP port to be used for GTP-U.
Definition at line 319 of file epc-pgw-application.h.
Referenced by SendToS5uSocket().
|
private |
PGW address of the S5 interface.
Definition at line 283 of file epc-pgw-application.h.
Referenced by DoRecvCreateSessionRequest().
|
private |
Callback to trace received data packets from S5 socket.
Definition at line 339 of file epc-pgw-application.h.
Referenced by GetTypeId(), and RecvFromS5uSocket().
|
private |
Callback to trace received data packets at Tun NetDevice from internet.
Definition at line 334 of file epc-pgw-application.h.
Referenced by GetTypeId(), and RecvFromTunDevice().
UDP socket to send/receive GTPv2-C packets to/from the S5 interface.
Definition at line 293 of file epc-pgw-application.h.
Referenced by EpcPgwApplication(), DoDispose(), DoRecvCreateSessionRequest(), DoRecvDeleteBearerCommand(), DoRecvModifyBearerRequest(), and RecvFromS5cSocket().
UDP socket to send/receive GTP-U packets to/from the S5 interface.
Definition at line 288 of file epc-pgw-application.h.
Referenced by EpcPgwApplication(), DoDispose(), RecvFromS5uSocket(), and SendToS5uSocket().
|
private |
SGW address of the S5 interface.
Definition at line 329 of file epc-pgw-application.h.
Referenced by AddSgw(), DoRecvCreateSessionRequest(), DoRecvDeleteBearerCommand(), and DoRecvModifyBearerRequest().
|
private |
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP on the S5 interface.
Definition at line 299 of file epc-pgw-application.h.
Referenced by SendToTunDevice().
|
private |
UeInfo stored by UE IPv4 address.
Definition at line 304 of file epc-pgw-application.h.
Referenced by RecvFromTunDevice(), and SetUeAddress().
|
private |
UeInfo stored by UE IPv6 address.
Definition at line 309 of file epc-pgw-application.h.
Referenced by RecvFromTunDevice(), and SetUeAddress6().
UeInfo stored by IMSI.
Definition at line 314 of file epc-pgw-application.h.
Referenced by AddUe(), DoRecvCreateSessionRequest(), DoRecvDeleteBearerResponse(), DoRecvModifyBearerRequest(), SetUeAddress(), and SetUeAddress6().