A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
epc-sgw-application.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017-2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Manuel Requena <manuel.requena@cttc.es>
18 */
19
20#ifndef EPC_SGW_APPLICATION_H
21#define EPC_SGW_APPLICATION_H
22
23#include "epc-gtpc-header.h"
24
25#include "ns3/address.h"
26#include "ns3/application.h"
27#include "ns3/socket.h"
28
29#include <map>
30
31namespace ns3
32{
33
34/**
35 * \ingroup lte
36 *
37 * This application implements the Serving Gateway Entity (SGW)
38 * according to the 3GPP TS 23.401 document.
39 *
40 * This Application implements the SGW side of the S5 interface between
41 * the SGW node and the PGW node and the SGW side of the S11 interface between
42 * the SGW node and the MME node hosts. It supports the following functions and messages:
43 *
44 * - S5 connectivity (i.e. GTPv2-C signalling and GTP-U data plane)
45 * - Bearer management functions including dedicated bearer establishment
46 * - UL and DL bearer binding
47 * - Tunnel Management messages
48 *
49 * Others functions enumerated in section 4.4.3.2 of 3GPP TS 23.401 are not supported.
50 */
52{
53 public:
54 /**
55 * \brief Get the type ID.
56 * \return the object TypeId
57 */
58 static TypeId GetTypeId();
59 void DoDispose() override;
60
61 /**
62 * Constructor that binds callback methods of sockets.
63 *
64 * \param s1uSocket socket used to send/receive GTP-U packets to/from the eNBs
65 * \param s5Addr IPv4 address of the S5 interface
66 * \param s5uSocket socket used to send/receive GTP-U packets to/from the PGW
67 * \param s5cSocket socket used to send/receive GTP-C packets to/from the PGW
68 */
69 EpcSgwApplication(const Ptr<Socket> s1uSocket,
70 Ipv4Address s5Addr,
71 const Ptr<Socket> s5uSocket,
72 const Ptr<Socket> s5cSocket);
73
74 /** Destructor */
75 ~EpcSgwApplication() override;
76
77 /**
78 * Let the SGW be aware of an MME
79 *
80 * \param mmeS11Addr the address of the MME
81 * \param s11Socket the socket to send/receive messages from the MME
82 */
83 void AddMme(Ipv4Address mmeS11Addr, Ptr<Socket> s11Socket);
84
85 /**
86 * Let the SGW be aware of a PGW
87 *
88 * \param pgwAddr the address of the PGW
89 */
90 void AddPgw(Ipv4Address pgwAddr);
91
92 /**
93 * Let the SGW be aware of a new eNB
94 *
95 * \param cellId the cell identifier
96 * \param enbAddr the address of the eNB
97 * \param sgwAddr the address of the SGW
98 */
99 void AddEnb(uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr);
100
101 private:
102 /**
103 * Method to be assigned to the recv callback of the S11 socket.
104 * It is called when the SGW receives a control packet from the MME.
105 *
106 * \param socket pointer to the S11 socket
107 */
108 void RecvFromS11Socket(Ptr<Socket> socket);
109
110 /**
111 * Method to be assigned to the recv callback of the S5-U socket.
112 * It is called when the SGW receives a data packet from the PGW
113 * that is to be forwarded to an eNB.
114 *
115 * \param socket pointer to the S5-U socket
116 */
117 void RecvFromS5uSocket(Ptr<Socket> socket);
118
119 /**
120 * Method to be assigned to the recv callback of the S5-C socket.
121 * It is called when the SGW receives a control packet from the PGW.
122 *
123 * \param socket pointer to the S5-C socket
124 */
125 void RecvFromS5cSocket(Ptr<Socket> socket);
126
127 /**
128 * Method to be assigned to the recv callback of the S1-U socket.
129 * It is called when the SGW receives a data packet from the eNB
130 * that is to be forwarded to the PGW.
131 *
132 * \param socket pointer to the S1-U socket
133 */
134 void RecvFromS1uSocket(Ptr<Socket> socket);
135
136 /**
137 * Send a data packet to the PGW via the S5 interface
138 *
139 * \param packet packet to be sent
140 * \param pgwAddr the address of the PGW
141 * \param teid the Tunnel Endpoint Identifier
142 */
143 void SendToS5uSocket(Ptr<Packet> packet, Ipv4Address pgwAddr, uint32_t teid);
144
145 /**
146 * Send a data packet to an eNB via the S1-U interface
147 *
148 * \param packet packet to be sent
149 * \param enbS1uAddress the address of the eNB
150 * \param teid the Tunnel Endpoint Identifier
151 */
152 void SendToS1uSocket(Ptr<Packet> packet, Ipv4Address enbS1uAddress, uint32_t teid);
153
154 // Process messages received from the MME
155
156 /**
157 * Process GTP-C Create Session Request message
158 * \param packet the packet containing the message
159 */
161
162 /**
163 * Process GTP-C Modify Bearer Request message
164 * \param packet the packet containing the message
165 */
167
168 /**
169 * Process GTP-C Delete Bearer Command message
170 * \param packet the packet containing the message
171 */
173
174 /**
175 * Process GTP-C Delete Bearer Response message
176 * \param packet the packet containing the message
177 */
179
180 // Process messages received from the PGW
181
182 /**
183 * Process GTP-C Create Session Response message
184 * \param packet the packet containing the message
185 */
187
188 /**
189 * Process GTP-C Modify Bearer Response message
190 * \param packet the packet containing the message
191 */
193
194 /**
195 * Process GTP-C Delete Bearer Request message
196 * \param packet the packet containing the message
197 */
199
200 /**
201 * SGW address in the S5 interface
202 */
204
205 /**
206 * MME address in the S11 interface
207 */
209
210 /**
211 * UDP socket to send/receive control messages to/from the S11 interface
212 */
214
215 /**
216 * PGW address in the S5 interface
217 */
219
220 /**
221 * UDP socket to send/receive GTP-U packets to/from the S5 interface
222 */
224
225 /**
226 * UDP socket to send/receive GTP-C packets to/from the S5 interface
227 */
229
230 /**
231 * UDP socket to send/receive GTP-U packets to/from the S1-U interface
232 */
234
235 /**
236 * UDP port to be used for GTP-U
237 */
239
240 /**
241 * UDP port to be used for GTP-C
242 */
244
245 /**
246 * TEID count
247 */
249
250 /// EnbInfo structure
251 struct EnbInfo
252 {
253 Ipv4Address enbAddr; ///< eNB address
254 Ipv4Address sgwAddr; ///< SGW address
255 };
256
257 /**
258 * Map for eNB info by cell ID
259 */
260 std::map<uint16_t, EnbInfo> m_enbInfoByCellId;
261
262 /**
263 * Map for eNB address by TEID
264 */
265 std::map<uint32_t, Ipv4Address> m_enbByTeidMap;
266
267 /**
268 * MME S11 FTEID by SGW S5C TEID
269 */
270 std::map<uint32_t, GtpcHeader::Fteid_t> m_mmeS11FteidBySgwS5cTeid;
271};
272
273} // namespace ns3
274
275#endif // EPC_SGW_APPLICATION_H
The base class for all ns3 applications.
Definition: application.h:62
This application implements the Serving Gateway Entity (SGW) according to the 3GPP TS 23....
Ptr< Socket > m_s5cSocket
UDP socket to send/receive GTP-C packets to/from the S5 interface.
void SendToS1uSocket(Ptr< Packet > packet, Ipv4Address enbS1uAddress, uint32_t teid)
Send a data packet to an eNB via the S1-U interface.
uint16_t m_gtpuUdpPort
UDP port to be used for GTP-U.
std::map< uint32_t, GtpcHeader::Fteid_t > m_mmeS11FteidBySgwS5cTeid
MME S11 FTEID by SGW S5C TEID.
void DoRecvModifyBearerRequest(Ptr< Packet > packet)
Process GTP-C Modify Bearer Request message.
void DoRecvCreateSessionResponse(Ptr< Packet > packet)
Process GTP-C Create Session Response message.
Ipv4Address m_mmeS11Addr
MME address in the S11 interface.
void DoRecvDeleteBearerRequest(Ptr< Packet > packet)
Process GTP-C Delete Bearer Request message.
void AddMme(Ipv4Address mmeS11Addr, Ptr< Socket > s11Socket)
Let the SGW be aware of an MME.
void DoRecvDeleteBearerCommand(Ptr< Packet > packet)
Process GTP-C Delete Bearer Command message.
void RecvFromS5cSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S5-C socket.
~EpcSgwApplication() override
Destructor.
void SendToS5uSocket(Ptr< Packet > packet, Ipv4Address pgwAddr, uint32_t teid)
Send a data packet to the PGW via the S5 interface.
void DoRecvCreateSessionRequest(Ptr< Packet > packet)
Process GTP-C Create Session Request message.
void AddPgw(Ipv4Address pgwAddr)
Let the SGW be aware of a PGW.
void RecvFromS5uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S5-U socket.
std::map< uint32_t, Ipv4Address > m_enbByTeidMap
Map for eNB address by TEID.
Ptr< Socket > m_s1uSocket
UDP socket to send/receive GTP-U packets to/from the S1-U interface.
Ptr< Socket > m_s11Socket
UDP socket to send/receive control messages to/from the S11 interface.
std::map< uint16_t, EnbInfo > m_enbInfoByCellId
Map for eNB info by cell ID.
uint32_t m_teidCount
TEID count.
void RecvFromS11Socket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S11 socket.
Ipv4Address m_s5Addr
SGW address in the S5 interface.
uint16_t m_gtpcUdpPort
UDP port to be used for GTP-C.
void RecvFromS1uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S1-U socket.
void DoDispose() override
Destructor implementation.
void DoRecvDeleteBearerResponse(Ptr< Packet > packet)
Process GTP-C Delete Bearer Response message.
Ptr< Socket > m_s5uSocket
UDP socket to send/receive GTP-U packets to/from the S5 interface.
Ipv4Address m_pgwAddr
PGW address in the S5 interface.
void DoRecvModifyBearerResponse(Ptr< Packet > packet)
Process GTP-C Modify Bearer Response message.
void AddEnb(uint16_t cellId, Ipv4Address enbAddr, Ipv4Address sgwAddr)
Let the SGW be aware of a new eNB.
static TypeId GetTypeId()
Get the type ID.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.