A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
epc-enb-application.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 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 * Authors:
18 * Jaume Nin <jnin@cttc.cat>
19 * Nicola Baldo <nbaldo@cttc.cat>
20 */
21
22#ifndef EPC_ENB_APPLICATION_H
23#define EPC_ENB_APPLICATION_H
24
25#include "epc-enb-s1-sap.h"
26#include "epc-s1ap-sap.h"
27
28#include <ns3/address.h>
29#include <ns3/application.h>
30#include <ns3/callback.h>
31#include <ns3/object.h>
32#include <ns3/ptr.h>
33#include <ns3/socket.h>
34#include <ns3/traced-callback.h>
35#include <ns3/virtual-net-device.h>
36
37#include <map>
38
39namespace ns3
40{
41class EpcEnbS1SapUser;
43
44/**
45 * \ingroup lte
46 *
47 * This application is installed inside eNBs and provides the bridge functionality for user data
48 * plane packets between the radio interface and the S1-U interface.
49 */
51{
52 /// allow MemberEpcEnbS1SapProvider<EpcEnbApplication> class friend access
54 /// allow MemberEpcS1apSapEnb<EpcEnbApplication> class friend access
56
57 public:
58 /**
59 * \brief Get the type ID.
60 * \return the object TypeId
61 */
62 static TypeId GetTypeId();
63
64 protected:
65 void DoDispose() override;
66
67 public:
68 /**
69 * Constructor
70 *
71 * \param lteSocket the socket to be used to send/receive IPv4 packets to/from the
72 * LTE radio interface
73 * \param lteSocket6 the socket to be used to send/receive IPv6 packets to/from the
74 * LTE radio interface
75 * \param cellId the identifier of the eNB
76 */
77 EpcEnbApplication(Ptr<Socket> lteSocket, Ptr<Socket> lteSocket6, uint16_t cellId);
78
79 /**
80 * Add a S1-U interface to the eNB
81 *
82 * \param s1uSocket the socket to be used to send/receive packets to/from the S1-U interface
83 * connected with the SGW
84 * \param enbS1uAddress the IPv4 address of the S1-U interface of this eNB
85 * \param sgwS1uAddress the IPv4 address at which this eNB will be able to reach its SGW for
86 * S1-U communications
87 */
88 void AddS1Interface(Ptr<Socket> s1uSocket,
89 Ipv4Address enbS1uAddress,
90 Ipv4Address sgwS1uAddress);
91
92 /**
93 * Destructor
94 *
95 */
96 ~EpcEnbApplication() override;
97
98 /**
99 * Set the S1 SAP User
100 *
101 * \param s the S1 SAP User
102 */
104
105 /**
106 *
107 * \return the S1 SAP Provider
108 */
110
111 /**
112 * Set the MME side of the S1-AP SAP
113 *
114 * \param s the MME side of the S1-AP SAP
115 */
117
118 /**
119 *
120 * \return the ENB side of the S1-AP SAP
121 */
123
124 /**
125 * Method to be assigned to the recv callback of the LTE socket. It is called when the eNB
126 * receives a data packet from the radio interface that is to be forwarded to the SGW.
127 *
128 * \param socket pointer to the LTE socket
129 */
130 void RecvFromLteSocket(Ptr<Socket> socket);
131
132 /**
133 * Method to be assigned to the recv callback of the S1-U socket. It is called when the eNB
134 * receives a data packet from the SGW that is to be forwarded to the UE.
135 *
136 * \param socket pointer to the S1-U socket
137 */
138 void RecvFromS1uSocket(Ptr<Socket> socket);
139
140 /**
141 * TracedCallback signature for data Packet reception event.
142 *
143 * \param [in] packet The data packet sent from the internet.
144 */
145 typedef void (*RxTracedCallback)(Ptr<Packet> packet);
146
147 /**
148 * EPS flow ID structure
149 */
151 {
152 uint16_t m_rnti; ///< RNTI
153 uint8_t m_bid; ///< Bid, the EPS Bearer Identifier
154
155 public:
156 EpsFlowId_t();
157 /**
158 * Constructor
159 *
160 * \param a RNTI
161 * \param b bid
162 */
163 EpsFlowId_t(const uint16_t a, const uint8_t b);
164
165 /**
166 * Comparison operator
167 *
168 * \param a first application
169 * \param b second application
170 * \returns true is the applications are "equal"
171 */
172 friend bool operator==(const EpsFlowId_t& a, const EpsFlowId_t& b);
173 /**
174 * Less than operator
175 *
176 * \param a first application
177 * \param b second application
178 * \returns true is the applications are "equal"
179 */
180 friend bool operator<(const EpsFlowId_t& a, const EpsFlowId_t& b);
181 };
182
183 private:
184 // ENB S1 SAP provider methods
185 /**
186 * Initial UE message function
187 * \param imsi the IMSI
188 * \param rnti the RNTI
189 */
190 void DoInitialUeMessage(uint64_t imsi, uint16_t rnti);
191 /**
192 * Path switch request function
193 * \param params PathSwitchRequestParameters
194 */
196 /**
197 * UE Context Release function
198 * \param rnti the RNTI
199 */
200 void DoUeContextRelease(uint16_t rnti);
201
202 // S1-AP SAP ENB methods
203 /**
204 * Initial Context Setup Request
205 * \param mmeUeS1Id the MME UE S1 ID
206 * \param enbUeS1Id the ENB UE S1 ID
207 * \param erabToBeSetupList the ERAB setup list
208 */
210 uint64_t mmeUeS1Id,
211 uint16_t enbUeS1Id,
212 std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList);
213 /**
214 * Path Switch Request Acknowledge
215 * \param mmeUeS1Id the MME UE S1 ID
216 * \param enbUeS1Id the ENB UE S1 ID
217 * \param cgi the CGI
218 * \param erabToBeSwitchedInUplinkList the ERAB switched in uplink list
219 */
221 uint64_t enbUeS1Id,
222 uint64_t mmeUeS1Id,
223 uint16_t cgi,
224 std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erabToBeSwitchedInUplinkList);
225
226 /**
227 * \brief This function accepts bearer id corresponding to a particular UE and schedules
228 * indication of bearer release towards MME
229 * \param imsi maps to mmeUeS1Id
230 * \param rnti maps to enbUeS1Id
231 * \param bearerId Bearer Identity which is to be de-activated
232 */
233 void DoReleaseIndication(uint64_t imsi, uint16_t rnti, uint8_t bearerId);
234
235 /**
236 * Send a packet to the UE via the LTE radio interface of the eNB
237 *
238 * \param packet t
239 * \param rnti maps to enbUeS1Id
240 * \param bid the EPS Bearer Identifier
241 */
242 void SendToLteSocket(Ptr<Packet> packet, uint16_t rnti, uint8_t bid);
243
244 /**
245 * Send a packet to the SGW via the S1-U interface
246 *
247 * \param packet packet to be sent
248 * \param teid the Tunnel Endpoint Identifier
249 */
250 void SendToS1uSocket(Ptr<Packet> packet, uint32_t teid);
251
252 /**
253 * internal method used for the actual setup of the S1 Bearer
254 *
255 * \param teid the Tunnel Endpoint Identifier
256 * \param rnti maps to enbUeS1Id
257 * \param bid the S1-U Bearer Identifier
258 */
259 void SetupS1Bearer(uint32_t teid, uint16_t rnti, uint8_t bid);
260
261 /**
262 * raw packet socket to send and receive the packets to and from the LTE radio interface
263 */
265
266 /**
267 * raw packet socket to send and receive the packets to and from the LTE radio interface
268 */
270
271 /**
272 * UDP socket to send and receive GTP-U the packets to and from the S1-U interface
273 */
275
276 /**
277 * address of the eNB for S1-U communications
278 */
280
281 /**
282 * address of the SGW which terminates all S1-U tunnels
283 */
285
286 /**
287 * map of maps telling for each RNTI and BID the corresponding S1-U TEID
288 *
289 */
290 std::map<uint16_t, std::map<uint8_t, uint32_t>> m_rbidTeidMap;
291
292 /**
293 * map telling for each S1-U TEID the corresponding RNTI,BID
294 *
295 */
296 std::map<uint32_t, EpsFlowId_t> m_teidRbidMap;
297
298 /**
299 * UDP port to be used for GTP
300 */
302
303 /**
304 * Provider for the S1 SAP
305 */
307
308 /**
309 * User for the S1 SAP
310 */
312
313 /**
314 * MME side of the S1-AP SAP
315 *
316 */
318
319 /**
320 * ENB side of the S1-AP SAP
321 *
322 */
324
325 /**
326 * UE context info
327 *
328 */
329 std::map<uint64_t, uint16_t> m_imsiRntiMap;
330
331 uint16_t m_cellId; ///< cell ID
332
333 /**
334 * \brief Callback to trace RX (reception) data packets from LTE Socket.
335 */
337
338 /**
339 * \brief Callback to trace RX (reception) data packets from S1-U Socket.
340 */
342};
343
344} // namespace ns3
345
346#endif /* EPC_ENB_APPLICATION_H */
The base class for all ns3 applications.
Definition: application.h:62
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
std::map< uint16_t, std::map< uint8_t, uint32_t > > m_rbidTeidMap
map of maps telling for each RNTI and BID the corresponding S1-U TEID
EpcS1apSapEnb * m_s1apSapEnb
ENB side of the S1-AP SAP.
Ipv4Address m_enbS1uAddress
address of the eNB for S1-U communications
Ptr< Socket > m_s1uSocket
UDP socket to send and receive GTP-U the packets to and from the S1-U interface.
void DoReleaseIndication(uint64_t imsi, uint16_t rnti, uint8_t bearerId)
This function accepts bearer id corresponding to a particular UE and schedules indication of bearer r...
void DoPathSwitchRequestAcknowledge(uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t cgi, std::list< EpcS1apSapEnb::ErabSwitchedInUplinkItem > erabToBeSwitchedInUplinkList)
Path Switch Request Acknowledge.
void RecvFromLteSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the LTE socket.
void AddS1Interface(Ptr< Socket > s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress)
Add a S1-U interface to the eNB.
void DoInitialContextSetupRequest(uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list< EpcS1apSapEnb::ErabToBeSetupItem > erabToBeSetupList)
Initial Context Setup Request.
void DoDispose() override
Destructor implementation.
void DoUeContextRelease(uint16_t rnti)
UE Context Release function.
Ipv4Address m_sgwS1uAddress
address of the SGW which terminates all S1-U tunnels
Ptr< Socket > m_lteSocket
raw packet socket to send and receive the packets to and from the LTE radio interface
void SendToS1uSocket(Ptr< Packet > packet, uint32_t teid)
Send a packet to the SGW via the S1-U interface.
void SetS1apSapMme(EpcS1apSapMme *s)
Set the MME side of the S1-AP SAP.
EpcEnbS1SapProvider * GetS1SapProvider()
static TypeId GetTypeId()
Get the type ID.
void SendToLteSocket(Ptr< Packet > packet, uint16_t rnti, uint8_t bid)
Send a packet to the UE via the LTE radio interface of the eNB.
EpcS1apSapEnb * GetS1apSapEnb()
TracedCallback< Ptr< Packet > > m_rxLteSocketPktTrace
Callback to trace RX (reception) data packets from LTE Socket.
void RecvFromS1uSocket(Ptr< Socket > socket)
Method to be assigned to the recv callback of the S1-U socket.
std::map< uint64_t, uint16_t > m_imsiRntiMap
UE context info.
EpcEnbS1SapUser * m_s1SapUser
User for the S1 SAP.
Ptr< Socket > m_lteSocket6
raw packet socket to send and receive the packets to and from the LTE radio interface
void SetupS1Bearer(uint32_t teid, uint16_t rnti, uint8_t bid)
internal method used for the actual setup of the S1 Bearer
void DoPathSwitchRequest(EpcEnbS1SapProvider::PathSwitchRequestParameters params)
Path switch request function.
uint16_t m_gtpuUdpPort
UDP port to be used for GTP.
void DoInitialUeMessage(uint64_t imsi, uint16_t rnti)
Initial UE message function.
std::map< uint32_t, EpsFlowId_t > m_teidRbidMap
map telling for each S1-U TEID the corresponding RNTI,BID
EpcS1apSapMme * m_s1apSapMme
MME side of the S1-AP SAP.
EpcEnbS1SapProvider * m_s1SapProvider
Provider for the S1 SAP.
void(* RxTracedCallback)(Ptr< Packet > packet)
TracedCallback signature for data Packet reception event.
void SetS1SapUser(EpcEnbS1SapUser *s)
Set the S1 SAP User.
~EpcEnbApplication() override
Destructor.
TracedCallback< Ptr< Packet > > m_rxS1uSocketPktTrace
Callback to trace RX (reception) data packets from S1-U Socket.
This class implements the Service Access Point (SAP) between the LteEnbRrc and the EpcEnbApplication.
This class implements the Service Access Point (SAP) between the LteEnbRrc and the EpcEnbApplication.
eNB side of the S1-AP Service Access Point (SAP), provides the eNB methods to be called when an S1-AP...
Definition: epc-s1ap-sap.h:144
MME side of the S1-AP Service Access Point (SAP), provides the MME methods to be called when an S1-AP...
Definition: epc-s1ap-sap.h:53
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Template for the implementation of the EpcEnbS1SapProvider as a member of an owner class of type C to...
Template for the implementation of the EpcS1apSapEnb as a member of an owner class of type C to which...
Definition: epc-s1ap-sap.h:310
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
friend bool operator==(const EpsFlowId_t &a, const EpsFlowId_t &b)
Comparison operator.
uint8_t m_bid
Bid, the EPS Bearer Identifier.
friend bool operator<(const EpsFlowId_t &a, const EpsFlowId_t &b)
Less than operator.
PathSwitchRequestParameters structure.