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