A Discrete-Event Network Simulator
API
epc-sgw-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) 2011 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: Jaume Nin <jnin@cttc.cat>
19  * Nicola Baldo <nbaldo@cttc.cat>
20  */
21 
22 #ifndef EPC_SGW_PGW_APPLICATION_H
23 #define EPC_SGW_PGW_APPLICATION_H
24 
25 #include <ns3/address.h>
26 #include <ns3/socket.h>
27 #include <ns3/virtual-net-device.h>
28 #include <ns3/traced-callback.h>
29 #include <ns3/callback.h>
30 #include <ns3/ptr.h>
31 #include <ns3/object.h>
32 #include <ns3/eps-bearer.h>
33 #include <ns3/epc-tft.h>
34 #include <ns3/epc-tft-classifier.h>
35 #include <ns3/lte-common.h>
36 #include <ns3/application.h>
37 #include <ns3/epc-s1ap-sap.h>
38 #include <ns3/epc-s11-sap.h>
39 #include <map>
40 
41 namespace ns3 {
42 
49 {
52 
53 public:
54 
59  static TypeId GetTypeId (void);
60  virtual void DoDispose ();
61 
71  EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket);
72 
76  virtual ~EpcSgwPgwApplication (void);
77 
90  bool RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
91 
92 
100  void RecvFromS1uSocket (Ptr<Socket> socket);
101 
108  void SendToTunDevice (Ptr<Packet> packet, uint32_t teid);
109 
110 
118  void SendToS1uSocket (Ptr<Packet> packet, Ipv4Address enbS1uAddress, uint32_t teid);
119 
120 
126  void SetS11SapMme (EpcS11SapMme * s);
127 
133 
134 
142  void AddEnb (uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr);
143 
149  void AddUe (uint64_t imsi);
150 
157  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
158 
165  void SetUeAddress6 (uint64_t imsi, Ipv6Address ueAddr);
166 
172  typedef void (* RxTracedCallback)
173  (Ptr<Packet> packet);
174 
175 private:
176 
177  // S11 SAP SGW methods
188 
199 
200 
204  class UeInfo : public SimpleRefCount<UeInfo>
205  {
206 public:
207  UeInfo ();
208 
215  void AddBearer (Ptr<EpcTft> tft, uint8_t epsBearerId, uint32_t teid);
216 
221  void RemoveBearer (uint8_t bearerId);
222 
232  uint32_t Classify (Ptr<Packet> p);
233 
238 
244  void SetEnbAddr (Ipv4Address addr);
245 
250 
256  void SetUeAddr (Ipv4Address addr);
257 
262 
268  void SetUeAddr6 (Ipv6Address addr);
269 
270  private:
275  std::map<uint8_t, uint32_t> m_teidByBearerIdMap;
276  };
277 
278 
283 
289 
293  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
294 
298  std::map<Ipv6Address, Ptr<UeInfo> > m_ueInfoByAddrMap6;
299 
303  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
304 
308  uint16_t m_gtpuUdpPort;
309 
313  uint32_t m_teidCount;
314 
320 
326 
328  struct EnbInfo
329  {
332  };
333 
334  std::map<uint16_t, EnbInfo> m_enbInfoByCellId;
335 
340 
345 };
346 
347 } //namespace ns3
348 
349 #endif /* EPC_SGW_PGW_APPLICATION_H */
350 
std::map< uint16_t, EnbInfo > m_enbInfoByCellId
eNB info by cell ID
Delete Bearer Command message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.17.1.
Definition: epc-s11-sap.h:206
MME side of the S11 Service Access Point (SAP), provides the MME methods to be called when an S11 mes...
Definition: epc-s11-sap.h:78
uint16_t m_gtpuUdpPort
UDP port to be used for GTP.
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.
store info for each UE connected to this SGW
Forward calls to a chain of Callback.
classifies IP packets according to Traffic Flow Templates (TFTs)
EpcS11SapMme * m_s11SapMme
MME side of the S11 SAP.
Ipv4Address m_enbAddr
ENB IPv4 address.
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a packet to the internet via the Gi interface of the SGW/PGW.
Delete Bearer Response message, see 3GPP TS 29.274 Release 9 V9.3.0 section 7.2.10.2.
Definition: epc-s11-sap.h:226
a polymophic address class
Definition: address.h:90
Template for the implementation of the EpcS11SapSgw as a member of an owner class of type C to which ...
Definition: epc-s11-sap.h:330
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.
The base class for all ns3 applications.
Definition: application.h:60
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.
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
Modify Bearer Request message, see 3GPP TS 29.274 7.2.7
Definition: epc-s11-sap.h:240
std::map< uint8_t, uint32_t > m_teidByBearerIdMap
TEID By bearer ID Map.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AddBearer(Ptr< EpcTft > tft, uint8_t epsBearerId, uint32_t teid)
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
set the address of a previously added UE
void DoDeleteBearerResponse(EpcS11SapSgw::DeleteBearerResponseMessage req)
Delete bearer response function.
EpcTftClassifier m_tftClassifier
TFT classifier.
static TypeId GetTypeId(void)
Get the type ID.
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.
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.
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
Map telling for each UE IPv4 address the corresponding UE info.
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
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...
Definition: epc-s11-sap.h:166
This application implements the SGW/PGW functionality.
void SetEnbAddr(Ipv4Address addr)
set the address of the eNB to which the UE is connected
Ipv6Address m_ueAddr6
UE IPv6 address.
virtual void DoDispose()
Destructor implementation.
void RecvFromS1uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S1-U socket.
virtual ~EpcSgwPgwApplication(void)
Destructor.
void DoModifyBearerRequest(EpcS11SapSgw::ModifyBearerRequestMessage msg)
Modify bearer request function.
void(* RxTracedCallback)(Ptr< Packet > packet)
TracedCallback signature for data Packet reception event.
EpcS11SapSgw * m_s11SapSgw
SGW side of the S11 SAP.
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:58
Ipv4Address sgwAddr
SGW IPV4 address.
Ipv4Address m_ueAddr
UE IPv4 address.
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.
Create Session Request message, see 3GPP TS 29.274 7.2.1
Definition: epc-s11-sap.h:183
EpcSgwPgwApplication(const Ptr< VirtualNetDevice > tunDevice, const Ptr< Socket > s1uSocket)
Constructor that binds the tap device to the callback methods.