A Discrete-Event Network Simulator
API
epc-pgw-application.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Manuel Requena <manuel.requena@cttc.es>
19  * (based on epc-sgw-pgw-application.h)
20  */
21 
22 #ifndef EPC_PGW_APPLICATION_H
23 #define EPC_PGW_APPLICATION_H
24 
25 #include "ns3/virtual-net-device.h"
26 #include "ns3/socket.h"
27 #include "ns3/application.h"
28 #include "ns3/epc-tft-classifier.h"
29 #include "ns3/epc-gtpc-header.h"
30 
31 namespace ns3 {
32 
52 {
53 public:
54 
59  static TypeId GetTypeId (void);
60  virtual void DoDispose ();
61 
72  EpcPgwApplication (const Ptr<VirtualNetDevice> tunDevice, Ipv4Address s5Addr,
73  const Ptr<Socket> s5uSocket, const Ptr<Socket> s5cSocket);
74 
76  virtual ~EpcPgwApplication (void);
77 
90  bool RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
91 
99  void RecvFromS5uSocket (Ptr<Socket> socket);
100 
107  void RecvFromS5cSocket (Ptr<Socket> socket);
108 
115  void SendToTunDevice (Ptr<Packet> packet, uint32_t teid);
116 
124  void SendToS5uSocket (Ptr<Packet> packet, Ipv4Address sgwS5uAddress, uint32_t teid);
125 
126 
132  void AddSgw (Ipv4Address sgwS5Addr);
133 
139  void AddUe (uint64_t imsi);
140 
147  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
148 
155  void SetUeAddress6 (uint64_t imsi, Ipv6Address ueAddr);
156 
162  typedef void (* RxTracedCallback)
163  (Ptr<Packet> packet);
164 
165 private:
166 
172 
178 
184 
190 
191 
195  class UeInfo : public SimpleRefCount<UeInfo>
196  {
197  public:
198  UeInfo ();
199 
207  void AddBearer (uint8_t bearerId, uint32_t teid, Ptr<EpcTft> tft);
208 
214  void RemoveBearer (uint8_t bearerId);
215 
227  uint32_t Classify (Ptr<Packet> p, uint16_t protocolNumber);
228 
235 
241  void SetSgwAddr (Ipv4Address addr);
242 
249 
255  void SetUeAddr (Ipv4Address addr);
256 
263 
269  void SetUeAddr6 (Ipv6Address addr);
270 
271  private:
276  std::map<uint8_t, uint32_t> m_teidByBearerIdMap;
277  };
278 
283 
288 
293 
299 
303  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
304 
308  std::map<Ipv6Address, Ptr<UeInfo> > m_ueInfoByAddrMap6;
309 
313  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
314 
318  uint16_t m_gtpuUdpPort;
319 
323  uint16_t m_gtpcUdpPort;
324 
329 
334 
339 };
340 
341 } // namespace ns3
342 
343 #endif // EPC_PGW_APPLICATION_H
ns3::EpcPgwApplication::AddUe
void AddUe(uint64_t imsi)
Let the PGW be aware of a new UE.
Definition: epc-pgw-application.cc:483
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::EpcPgwApplication::DoRecvDeleteBearerCommand
void DoRecvDeleteBearerCommand(Ptr< Packet > packet)
Process Delete Bearer Command message.
Definition: epc-pgw-application.cc:386
ns3::EpcPgwApplication::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition: epc-pgw-application.cc:134
ns3::EpcPgwApplication::m_ueInfoByImsiMap
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
UeInfo stored by IMSI.
Definition: epc-pgw-application.h:313
ns3::EpcPgwApplication::UeInfo::Classify
uint32_t Classify(Ptr< Packet > p, uint16_t protocolNumber)
Classify the packet according to TFTs of this UE.
Definition: epc-pgw-application.cc:66
ns3::EpcPgwApplication::DoRecvDeleteBearerResponse
void DoRecvDeleteBearerResponse(Ptr< Packet > packet)
Process Delete Bearer Response message.
Definition: epc-pgw-application.cc:412
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::EpcPgwApplication::UeInfo::UeInfo
UeInfo()
Definition: epc-pgw-application.cc:43
ns3::EpcPgwApplication::m_rxTunPktTrace
TracedCallback< Ptr< Packet > > m_rxTunPktTrace
Callback to trace received data packets at Tun NetDevice from internet.
Definition: epc-pgw-application.h:333
ns3::EpcPgwApplication::m_tunDevice
Ptr< VirtualNetDevice > m_tunDevice
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP...
Definition: epc-pgw-application.h:298
ns3::EpcPgwApplication::m_sgwS5Addr
Ipv4Address m_sgwS5Addr
SGW address of the S5 interface.
Definition: epc-pgw-application.h:328
ns3::SimpleRefCount
A template-based reference counting class.
Definition: simple-ref-count.h:74
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::EpcPgwApplication::UeInfo::RemoveBearer
void RemoveBearer(uint8_t bearerId)
Delete context of bearer for this UE on PGW side.
Definition: epc-pgw-application.cc:57
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::EpcPgwApplication::UeInfo::GetUeAddr
Ipv4Address GetUeAddr()
Get the IPv4 address of the UE.
Definition: epc-pgw-application.cc:88
ns3::EpcPgwApplication::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: epc-pgw-application.cc:116
ns3::EpcPgwApplication::m_ueInfoByAddrMap6
std::map< Ipv6Address, Ptr< UeInfo > > m_ueInfoByAddrMap6
UeInfo stored by UE IPv6 address.
Definition: epc-pgw-application.h:308
ns3::EpcPgwApplication::RxTracedCallback
void(* RxTracedCallback)(Ptr< Packet > packet)
TracedCallback signature for data Packet reception event.
Definition: epc-pgw-application.h:163
ns3::EpcPgwApplication::UeInfo::m_ueAddr
Ipv4Address m_ueAddr
UE IPv4 address.
Definition: epc-pgw-application.h:272
ns3::EpcPgwApplication::DoRecvCreateSessionRequest
void DoRecvCreateSessionRequest(Ptr< Packet > packet)
Process Create Session Request message.
Definition: epc-pgw-application.cc:285
ns3::EpcPgwApplication::SendToTunDevice
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a data packet to the internet via the SGi interface of the PGW.
Definition: epc-pgw-application.cc:433
ns3::EpcPgwApplication::SendToS5uSocket
void SendToS5uSocket(Ptr< Packet > packet, Ipv4Address sgwS5uAddress, uint32_t teid)
Send a data packet to the SGW via the S5-U interface.
Definition: epc-pgw-application.cc:460
ns3::EpcPgwApplication::RecvFromS5uSocket
void RecvFromS5uSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-U socket.
Definition: epc-pgw-application.cc:236
ns3::EpcPgwApplication::RecvFromS5cSocket
void RecvFromS5cSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-C socket.
Definition: epc-pgw-application.cc:251
ns3::EpcPgwApplication::UeInfo::m_tftClassifier
EpcTftClassifier m_tftClassifier
TFT classifier.
Definition: epc-pgw-application.h:275
ns3::EpcPgwApplication::m_pgwS5Addr
Ipv4Address m_pgwS5Addr
PGW address of the S5 interface.
Definition: epc-pgw-application.h:282
ns3::Ptr< VirtualNetDevice >
ns3::EpcPgwApplication::UeInfo::AddBearer
void AddBearer(uint8_t bearerId, uint32_t teid, Ptr< EpcTft > tft)
Add a bearer for this UE on PGW side.
Definition: epc-pgw-application.cc:49
ns3::EpcPgwApplication::~EpcPgwApplication
virtual ~EpcPgwApplication(void)
Destructor.
Definition: epc-pgw-application.cc:157
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::EpcPgwApplication
This application implements the Packet Data Network (PDN) Gateway Entity (PGW) according to the 3GPP ...
Definition: epc-pgw-application.h:52
ns3::EpcTftClassifier
classifies IP packets according to Traffic Flow Templates (TFTs)
Definition: epc-tft-classifier.h:55
ns3::EpcPgwApplication::UeInfo::SetUeAddr6
void SetUeAddr6(Ipv6Address addr)
Set the IPv6 address of the UE.
Definition: epc-pgw-application.cc:106
ns3::EpcPgwApplication::UeInfo::GetUeAddr6
Ipv6Address GetUeAddr6()
Get the IPv6 address of the UE.
Definition: epc-pgw-application.cc:100
ns3::EpcPgwApplication::m_gtpcUdpPort
uint16_t m_gtpcUdpPort
UDP port to be used for GTPv2-C.
Definition: epc-pgw-application.h:323
ns3::EpcPgwApplication::UeInfo::GetSgwAddr
Ipv4Address GetSgwAddr()
Get the address of the SGW to which the UE is connected.
Definition: epc-pgw-application.cc:76
ns3::EpcPgwApplication::UeInfo::SetUeAddr
void SetUeAddr(Ipv4Address addr)
Set the IPv4 address of the UE.
Definition: epc-pgw-application.cc:94
ns3::EpcPgwApplication::SetUeAddress
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
Set the address of a previously added UE.
Definition: epc-pgw-application.cc:491
ns3::EpcPgwApplication::RecvFromTunDevice
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.
Definition: epc-pgw-application.cc:163
ns3::EpcPgwApplication::UeInfo
store info for each UE connected to this PGW
Definition: epc-pgw-application.h:196
ns3::EpcPgwApplication::m_rxS5PktTrace
TracedCallback< Ptr< Packet > > m_rxS5PktTrace
Callback to trace received data packets from S5 socket.
Definition: epc-pgw-application.h:338
ns3::EpcPgwApplication::m_s5uSocket
Ptr< Socket > m_s5uSocket
UDP socket to send/receive GTP-U packets to/from the S5 interface.
Definition: epc-pgw-application.h:287
ns3::EpcPgwApplication::SetUeAddress6
void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr)
set the address of a previously added UE
Definition: epc-pgw-application.cc:501
ns3::EpcPgwApplication::DoRecvModifyBearerRequest
void DoRecvModifyBearerRequest(Ptr< Packet > packet)
Process Modify Bearer Request message.
Definition: epc-pgw-application.cc:348
ns3::EpcPgwApplication::m_gtpuUdpPort
uint16_t m_gtpuUdpPort
UDP port to be used for GTP-U.
Definition: epc-pgw-application.h:318
ns3::EpcPgwApplication::AddSgw
void AddSgw(Ipv4Address sgwS5Addr)
Let the PGW be aware of a new SGW.
Definition: epc-pgw-application.cc:476
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::EpcPgwApplication::UeInfo::SetSgwAddr
void SetSgwAddr(Ipv4Address addr)
Set the address of the eNB to which the UE is connected.
Definition: epc-pgw-application.cc:82
ns3::Application
The base class for all ns3 applications.
Definition: application.h:61
ns3::EpcPgwApplication::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.
Definition: epc-pgw-application.cc:143
ns3::EpcPgwApplication::m_ueInfoByAddrMap
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
UeInfo stored by UE IPv4 address.
Definition: epc-pgw-application.h:303
ns3::EpcPgwApplication::m_s5cSocket
Ptr< Socket > m_s5cSocket
UDP socket to send/receive GTPv2-C packets to/from the S5 interface.
Definition: epc-pgw-application.h:292
ns3::EpcPgwApplication::UeInfo::m_teidByBearerIdMap
std::map< uint8_t, uint32_t > m_teidByBearerIdMap
TEID By bearer ID Map.
Definition: epc-pgw-application.h:276
ns3::EpcPgwApplication::UeInfo::m_sgwAddr
Ipv4Address m_sgwAddr
SGW IPv4 address.
Definition: epc-pgw-application.h:274
ns3::EpcPgwApplication::UeInfo::m_ueAddr6
Ipv6Address m_ueAddr6
UE IPv6 address.
Definition: epc-pgw-application.h:273