A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 {
51 
52 public:
53 
54  // inherited from Object
55  static TypeId GetTypeId (void);
56  virtual void DoDispose ();
57 
66  EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket);
67 
71  virtual ~EpcSgwPgwApplication (void);
72 
85  bool RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
86 
87 
95  void RecvFromS1uSocket (Ptr<Socket> socket);
96 
102  void SendToTunDevice (Ptr<Packet> packet, uint32_t teid);
103 
104 
112  void SendToS1uSocket (Ptr<Packet> packet, Ipv4Address enbS1uAddress, uint32_t teid);
113 
114 
120  void SetS11SapMme (EpcS11SapMme * s);
121 
127 
128 
136  void AddEnb (uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr);
137 
143  void AddUe (uint64_t imsi);
144 
151  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
152 
153 private:
154 
155  // S11 SAP SGW methods
158 
162  class UeInfo : public SimpleRefCount<UeInfo>
163  {
164  public:
165  UeInfo ();
166 
173  void AddBearer (Ptr<EpcTft> tft, uint8_t epsBearerId, uint32_t teid);
174 
184  uint32_t Classify (Ptr<Packet> p);
185 
190 
196  void SetEnbAddr (Ipv4Address addr);
197 
202 
208  void SetUeAddr (Ipv4Address addr);
209 
210 
211  private:
215  std::map<uint8_t, uint32_t> m_teidByBearerIdMap;
216  };
217 
218 
223 
229 
233  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
234 
238  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
239 
243  uint16_t m_gtpuUdpPort;
244 
245  uint32_t m_teidCount;
246 
252 
258 
259  struct EnbInfo
260  {
263  };
264 
265  std::map<uint16_t, EnbInfo> m_enbInfoByCellId;
266 };
267 
268 } //namespace ns3
269 
270 #endif /* EPC_SGW_PGW_APPLICATION_H */
271 
std::map< uint16_t, EnbInfo > m_enbInfoByCellId
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:72
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.
a polymophic address class
Definition: address.h:86
Template for the implementation of the EpcS11SapSgw as a member of an owner class of type C to which ...
Definition: epc-s11-sap.h:242
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< SampleEmitter > s
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)
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:169
std::map< uint8_t, uint32_t > m_teidByBearerIdMap
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 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:38
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:135
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()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
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:49
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:151
EpcSgwPgwApplication(const Ptr< VirtualNetDevice > tunDevice, const Ptr< Socket > s1uSocket)
Constructor that binds the tap device to the callback methods.