A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
epc-sgw-pgw-application.h
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 {
50  friend class MemberEpcS11SapSgw<EpcSgwPgwApplication>;
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 
135  void AddEnb (uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr);
136 
142  void AddUe (uint64_t imsi);
143 
150  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
151 
152 private:
153 
154  // S11 SAP SGW methods
155  void DoCreateSessionRequest (EpcS11SapSgw::CreateSessionRequestMessage msg);
156  void DoModifyBearerRequest (EpcS11SapSgw::ModifyBearerRequestMessage msg);
157 
161  class UeInfo : public SimpleRefCount<UeInfo>
162  {
163  public:
164  UeInfo ();
165 
172  void AddBearer (Ptr<EpcTft> tft, uint8_t epsBearerId, uint32_t teid);
173 
183  uint32_t Classify (Ptr<Packet> p);
184 
189 
195  void SetEnbAddr (Ipv4Address addr);
196 
201 
207  void SetUeAddr (Ipv4Address addr);
208 
209 
210  private:
211  EpcTftClassifier m_tftClassifier;
212  Ipv4Address m_enbAddr;
213  Ipv4Address m_ueAddr;
214  std::map<uint8_t, uint32_t> m_teidByBearerIdMap;
215  };
216 
217 
222 
228 
232  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
233 
237  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
238 
242  uint16_t m_gtpuUdpPort;
243 
244  uint32_t m_teidCount;
245 
251 
257 
258  struct EnbInfo
259  {
260  Ipv4Address enbAddr;
261  Ipv4Address sgwAddr;
262  };
263 
264  std::map<uint16_t, EnbInfo> m_enbInfoByCellId;
265 };
266 
267 } //namespace ns3
268 
269 #endif /* EPC_SGW_PGW_APPLICATION_H */
270 
void SetS11SapMme(EpcS11SapMme *s)
classifies IP packets accoding to Traffic Flow Templates (TFTs)
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
a polymophic address class
Definition: address.h:86
The base class for all ns3 applications.
Definition: application.h:61
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Ptr< VirtualNetDevice > m_tunDevice
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
void AddBearer(Ptr< EpcTft > tft, uint8_t epsBearerId, uint32_t teid)
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
void SendToS1uSocket(Ptr< Packet > packet, Ipv4Address enbS1uAddress, uint32_t teid)
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
void RecvFromS1uSocket(Ptr< Socket > socket)
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:44
void AddEnb(uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr)
EpcSgwPgwApplication(const Ptr< VirtualNetDevice > tunDevice, const Ptr< Socket > s1uSocket)