25 #include "ns3/mac48-address.h" 28 #include "ns3/ipv6-header.h" 29 #include "ns3/inet-socket-address.h" 30 #include "ns3/epc-gtpu-header.h" 31 #include "ns3/abort.h" 51 m_teidByBearerIdMap[bearerId] = teid;
52 return m_tftClassifier.Add (tft, teid);
59 m_teidByBearerIdMap.erase (bearerId);
116 static TypeId tid =
TypeId (
"ns3::EpcSgwPgwApplication")
119 .AddTraceSource (
"RxFromTun",
120 "Receive data packets from internet in Tunnel net device",
122 "ns3::EpcSgwPgwApplication::RxTracedCallback")
123 .AddTraceSource (
"RxFromS1u",
124 "Receive data packets from S1 U Socket",
126 "ns3::EpcSgwPgwApplication::RxTracedCallback")
169 ipType = (ipType>>4) & 0x0f;
175 pCopy->RemoveHeader (ipv4Header);
179 std::map<Ipv4Address, Ptr<UeInfo> >::iterator it =
m_ueInfoByAddrMap.find (ueAddr);
187 uint32_t teid = it->second->Classify (packet);
190 NS_LOG_WARN (
"no matching bearer for this packet");
198 else if (ipType == 0x06)
201 pCopy->RemoveHeader (ipv6Header);
213 uint32_t teid = it->second->Classify (packet);
216 NS_LOG_WARN (
"no matching bearer for this packet");
226 NS_ABORT_MSG (
"EpcSgwPgwApplication::RecvFromTunDevice - Unknown IP type...");
232 const bool succeeded =
true;
244 uint32_t teid = gtpu.
GetTeid ();
259 ipType = (ipType>>4) & 0x0f;
265 else if (ipType == 0x06)
271 NS_ABORT_MSG (
"EpcSgwPgwApplication::SendToTunDevice - Unknown IP type...");
328 ueit->second->SetUeAddr (ueAddr);
338 ueit->second->SetUeAddr6 (ueAddr);
347 uint16_t cellId = req.
uli.
gci;
351 ueit->second->SetEnbAddr (enbAddr);
365 ueit->second->AddBearer (bit->tft, bit->epsBearerId, teid);
372 bearerContext.
tft = bit->tft;
383 uint64_t imsi = req.
teid;
386 uint16_t cellId = req.
uli.gci;
390 ueit->second->SetEnbAddr (enbAddr);
402 uint64_t imsi = req.teid;
415 res.bearerContextsRemoved.push_back (bearerContext);
425 uint64_t imsi = req.teid;
429 for (std::list<EpcS11SapSgw::BearerContextRemovedSgwPgw>::iterator bit = req.
bearerContextsRemoved.begin ();
434 ueit->second->RemoveBearer (bit->epsBearerId);
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
std::map< uint16_t, EnbInfo > m_enbInfoByCellId
eNB info by cell ID
enum ns3::EpcS11SapMme::ModifyBearerResponseMessage::Cause cause
the cause
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
3GPP TS 29.274 version 8.3.1 Release 8 section 8.28
Delete Bearer Command message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.17.1.
Ipv4Address address
IP address.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
MME side of the S11 Service Access Point (SAP), provides the MME methods to be called when an S11 mes...
uint16_t m_gtpuUdpPort
UDP port to be used for GTP.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint8_t epsBearerId
EPS bearer ID.
void SetS11SapMme(EpcS11SapMme *s)
Set the MME side of the S11 SAP.
TracedCallback< Ptr< Packet > > m_rxTunPktTrace
Callback to trace RX (reception) data packets at Tun Net Device from internet.
EpcS11SapMme * m_s11SapMme
MME side of the S11 SAP.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Delete Bearer Request message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.9.2.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
std::list< BearerContextRemovedSgwPgw > bearerContextsRemoved
list of bearer contexts removed
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Callback< R > MakeNullCallback(void)
std::list< BearerContextToBeRemoved > bearerContextsToBeRemoved
list of bearer contexts to be removed
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a packet to the internet via the Gi interface of the SGW/PGW.
virtual void DeleteBearerRequest(DeleteBearerRequestMessage msg)=0
As per 3GPP TS 29.274 Release 9 V9.3.0, a Delete Bearer Request message shall be sent on the S11 inte...
Delete Bearer Response message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.10.2.
a polymophic address class
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
EpcS11Sap::Fteid sgwFteid
EPC FTEID.
Ptr< EpcTft > tft
traffic flow template
Template for the implementation of the EpcS11SapSgw as a member of an owner class of type C to which ...
EpsBearer bearerLevelQos
EPS bearer.
uint32_t m_teidCount
TEID count.
TracedCallback< Ptr< Packet > > m_rxS1uPktTrace
Callback to trace RX (reception) data packets from S1-U socket.
void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr)
set the address of a previously added UE
void RemoveBearer(uint8_t bearerId)
Function, deletes contexts of bearer on SGW and PGW side.
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Method to be assigned to the callback of the Gi TUN VirtualNetDevice.
uint8_t epsBearerId
EPS bearer ID.
Ptr< VirtualNetDevice > m_tunDevice
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP...
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
Map telling for each IMSI the corresponding UE info.
void DoCreateSessionRequest(EpcS11SapSgw::CreateSessionRequestMessage msg)
Create session request function.
void SetUeAddr(Ipv4Address addr)
set the IPv4 address of the UE
virtual void ModifyBearerResponse(ModifyBearerResponseMessage msg)=0
send a Modify Bearer Response message
uint32_t Classify(Ptr< Packet > p)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Modify Bearer Request message, see 3GPP TS 29.274 7.2.7
Bearer Context Removed structure.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AddBearer(Ptr< EpcTft > tft, uint8_t epsBearerId, uint32_t teid)
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
std::list< BearerContextCreated > bearerContextsCreated
bearer contexts created
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
set the address of a previously added UE
void DoDeleteBearerResponse(EpcS11SapSgw::DeleteBearerResponseMessage req)
Delete bearer response function.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
static TypeId GetTypeId(void)
Get the type ID.
virtual Address GetAddress(void) const
void SetUeAddr6(Ipv6Address addr)
set the IPv6 address of the UE
void AddUe(uint64_t imsi)
Let the SGW be aware of a new UE.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ipv4Address enbAddr
eNB IPv4 address
void SendToS1uSocket(Ptr< Packet > packet, Ipv4Address enbS1uAddress, uint32_t teid)
Send a packet to the SGW via the S1-U interface.
Ptr< Socket > m_s1uSocket
UDP socket to send and receive GTP-U packets to and from the S1-U interface.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
Map telling for each UE IPv4 address the corresponding UE info.
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
void DoDeleteBearerCommand(EpcS11SapSgw::DeleteBearerCommandMessage req)
Delete bearer command function.
SGW side of the S11 Service Access Point (SAP), provides the SGW methods to be called when an S11 mes...
std::list< BearerContextToBeCreated > bearerContextsToBeCreated
list of bearer contexts to be created
virtual void CreateSessionResponse(CreateSessionResponseMessage msg)=0
send a Create Session Response message
void SetEnbAddr(Ipv4Address addr)
set the address of the eNB to which the UE is connected
#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.
virtual void DoDispose()
Destructor implementation.
EpcS11SapSgw * GetS11SapSgw()
void RecvFromS1uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S1-U socket.
virtual ~EpcSgwPgwApplication(void)
Destructor.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
A base class which provides memory management and object aggregation.
Modify Bearer Response message, see 3GPP TS 29.274 7.2.7
void DoModifyBearerRequest(EpcS11SapSgw::ModifyBearerRequestMessage msg)
Modify bearer request function.
EpcS11SapSgw * m_s11SapSgw
SGW side of the S11 SAP.
a unique identifier for an interface.
Ipv4Address sgwAddr
SGW IPV4 address.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void AddEnb(uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr)
Let the SGW be aware of a new eNB.
std::map< Ipv6Address, Ptr< UeInfo > > m_ueInfoByAddrMap6
Map telling for each UE IPv6 address the corresponding UE info.
void AddHeader(const Header &header)
Add header to this packet.
Create Session Request message, see 3GPP TS 29.274 7.2.1
EpcSgwPgwApplication(const Ptr< VirtualNetDevice > tunDevice, const Ptr< Socket > s1uSocket)
Constructor that binds the tap device to the callback methods.
Create Session Response message, see 3GPP TS 29.274 7.2.2