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 
70  EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket);
71 
75  virtual ~EpcSgwPgwApplication (void);
76 
89  bool RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
90 
91 
99  void RecvFromS1uSocket (Ptr<Socket> socket);
100 
107  void SendToTunDevice (Ptr<Packet> packet, uint32_t teid);
108 
109 
117  void SendToS1uSocket (Ptr<Packet> packet, Ipv4Address enbS1uAddress, uint32_t teid);
118 
119 
125  void SetS11SapMme (EpcS11SapMme * s);
126 
132 
133 
141  void AddEnb (uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr);
142 
148  void AddUe (uint64_t imsi);
149 
156  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
157 
158 private:
159 
160  // S11 SAP SGW methods
171 
182 
183 
187  class UeInfo : public SimpleRefCount<UeInfo>
188  {
189 public:
190  UeInfo ();
191 
198  void AddBearer (Ptr<EpcTft> tft, uint8_t epsBearerId, uint32_t teid);
199 
204  void RemoveBearer (uint8_t bearerId);
205 
215  uint32_t Classify (Ptr<Packet> p);
216 
221 
227  void SetEnbAddr (Ipv4Address addr);
228 
233 
239  void SetUeAddr (Ipv4Address addr);
240 
241 
242  private:
246  std::map<uint8_t, uint32_t> m_teidByBearerIdMap;
247  };
248 
249 
254 
260 
264  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
265 
269  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
270 
274  uint16_t m_gtpuUdpPort;
275 
279  uint32_t m_teidCount;
280 
286 
292 
294  struct EnbInfo
295  {
298  };
299 
300  std::map<uint16_t, EnbInfo> m_enbInfoByCellId;
301 };
302 
303 } //namespace ns3
304 
305 #endif /* EPC_SGW_PGW_APPLICATION_H */
306 
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.
store info for each UE connected to this SGW
classifies IP packets accoding to Traffic Flow Templates (TFTs)
EpcS11SapMme * m_s11SapMme
MME side of the S11 SAP.
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
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 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 AddUe(uint64_t imsi)
Let the SGW be aware of a new UE.
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 address the corresponding UE info.
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
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.
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
void AddEnb(uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr)
Let the SGW be aware of a new eNB.
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.