A Discrete-Event Network Simulator
API
epc-pgw-application.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Manuel Requena <manuel.requena@cttc.es>
18  * (based on epc-sgw-pgw-application.h)
19  */
20 
21 #ifndef EPC_PGW_APPLICATION_H
22 #define EPC_PGW_APPLICATION_H
23 
24 #include "epc-gtpc-header.h"
25 #include "epc-tft-classifier.h"
26 
27 #include "ns3/application.h"
28 #include "ns3/socket.h"
29 #include "ns3/virtual-net-device.h"
30 
31 namespace ns3
32 {
33 
53 {
54  public:
59  static TypeId GetTypeId();
60  void DoDispose() override;
61 
73  Ipv4Address s5Addr,
74  const Ptr<Socket> s5uSocket,
75  const Ptr<Socket> s5cSocket);
76 
78  ~EpcPgwApplication() override;
79 
92  bool RecvFromTunDevice(Ptr<Packet> packet,
93  const Address& source,
94  const Address& dest,
95  uint16_t protocolNumber);
96 
104  void RecvFromS5uSocket(Ptr<Socket> socket);
105 
112  void RecvFromS5cSocket(Ptr<Socket> socket);
113 
120  void SendToTunDevice(Ptr<Packet> packet, uint32_t teid);
121 
129  void SendToS5uSocket(Ptr<Packet> packet, Ipv4Address sgwS5uAddress, uint32_t teid);
130 
136  void AddSgw(Ipv4Address sgwS5Addr);
137 
143  void AddUe(uint64_t imsi);
144 
151  void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr);
152 
159  void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr);
160 
166  typedef void (*RxTracedCallback)(Ptr<Packet> packet);
167 
168  private:
174 
180 
186 
192 
196  class UeInfo : public SimpleRefCount<UeInfo>
197  {
198  public:
199  UeInfo();
200 
208  void AddBearer(uint8_t bearerId, uint32_t teid, Ptr<EpcTft> tft);
209 
215  void RemoveBearer(uint8_t bearerId);
216 
228  uint32_t Classify(Ptr<Packet> p, uint16_t protocolNumber);
229 
236 
242  void SetSgwAddr(Ipv4Address addr);
243 
250 
256  void SetUeAddr(Ipv4Address addr);
257 
264 
270  void SetUeAddr6(Ipv6Address addr);
271 
272  private:
277  std::map<uint8_t, uint32_t> m_teidByBearerIdMap;
278  };
279 
284 
289 
294 
300 
304  std::map<Ipv4Address, Ptr<UeInfo>> m_ueInfoByAddrMap;
305 
309  std::map<Ipv6Address, Ptr<UeInfo>> m_ueInfoByAddrMap6;
310 
314  std::map<uint64_t, Ptr<UeInfo>> m_ueInfoByImsiMap;
315 
319  uint16_t m_gtpuUdpPort;
320 
324  uint16_t m_gtpcUdpPort;
325 
330 
335 
340 };
341 
342 } // namespace ns3
343 
344 #endif // EPC_PGW_APPLICATION_H
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
store info for each UE connected to this PGW
Ipv6Address GetUeAddr6()
Get the IPv6 address of the UE.
uint32_t Classify(Ptr< Packet > p, uint16_t protocolNumber)
Classify the packet according to TFTs of this UE.
void SetUeAddr(Ipv4Address addr)
Set the IPv4 address of the UE.
Ipv4Address GetSgwAddr()
Get the address of the SGW to which the UE is connected.
EpcTftClassifier m_tftClassifier
TFT classifier.
void RemoveBearer(uint8_t bearerId)
Delete context of bearer for this UE on PGW side.
Ipv4Address m_sgwAddr
SGW IPv4 address.
Ipv4Address m_ueAddr
UE IPv4 address.
std::map< uint8_t, uint32_t > m_teidByBearerIdMap
TEID By bearer ID Map.
Ipv6Address m_ueAddr6
UE IPv6 address.
Ipv4Address GetUeAddr()
Get the IPv4 address of the UE.
void SetUeAddr6(Ipv6Address addr)
Set the IPv6 address of the UE.
void SetSgwAddr(Ipv4Address addr)
Set the address of the eNB to which the UE is connected.
void AddBearer(uint8_t bearerId, uint32_t teid, Ptr< EpcTft > tft)
Add a bearer for this UE on PGW side.
This application implements the Packet Data Network (PDN) Gateway Entity (PGW) according to the 3GPP ...
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.
void SendToS5uSocket(Ptr< Packet > packet, Ipv4Address sgwS5uAddress, uint32_t teid)
Send a data packet to the SGW via the S5-U interface.
void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr)
set the address of a previously added UE
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a data packet to the internet via the SGi interface of the PGW.
void AddSgw(Ipv4Address sgwS5Addr)
Let the PGW be aware of a new SGW.
TracedCallback< Ptr< Packet > > m_rxTunPktTrace
Callback to trace received data packets at Tun NetDevice from internet.
TracedCallback< Ptr< Packet > > m_rxS5PktTrace
Callback to trace received data packets from S5 socket.
std::map< Ipv6Address, Ptr< UeInfo > > m_ueInfoByAddrMap6
UeInfo stored by UE IPv6 address.
void RecvFromS5uSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-U socket.
void DoRecvDeleteBearerResponse(Ptr< Packet > packet)
Process Delete Bearer Response message.
void RecvFromS5cSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-C socket.
void DoRecvDeleteBearerCommand(Ptr< Packet > packet)
Process Delete Bearer Command message.
void AddUe(uint64_t imsi)
Let the PGW be aware of a new UE.
Ptr< Socket > m_s5uSocket
UDP socket to send/receive GTP-U packets to/from the S5 interface.
void DoDispose() override
Destructor implementation.
uint16_t m_gtpuUdpPort
UDP port to be used for GTP-U.
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::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
UeInfo stored by IMSI.
Ipv4Address m_pgwS5Addr
PGW address of the S5 interface.
Ipv4Address m_sgwS5Addr
SGW address of the S5 interface.
~EpcPgwApplication() override
Destructor.
Ptr< VirtualNetDevice > m_tunDevice
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP...
void DoRecvModifyBearerRequest(Ptr< Packet > packet)
Process Modify Bearer Request message.
void DoRecvCreateSessionRequest(Ptr< Packet > packet)
Process Create Session Request message.
uint16_t m_gtpcUdpPort
UDP port to be used for GTPv2-C.
static TypeId GetTypeId()
Get the type ID.
Ptr< Socket > m_s5cSocket
UDP socket to send/receive GTPv2-C packets to/from the S5 interface.
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
UeInfo stored by UE IPv4 address.
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
Set the address of a previously added UE.
void(* RxTracedCallback)(Ptr< Packet > packet)
TracedCallback signature for data Packet reception event.
classifies IP packets according to Traffic Flow Templates (TFTs)
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
A template-based reference counting class.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.