1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * Copyright (c) 2015 Danilo Abrignani
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: Danilo Abrignani <danilo.abrignani@unibo.it>
19 *
20 */
21
22 #ifndef LTE_CCM_RRC_SAP_H
23 #define LTE_CCM_RRC_SAP_H
24
25 #include <ns3/lte-rrc-sap.h>
26 #include <ns3/eps-bearer.h>
27 #include <ns3/lte-enb-cmac-sap.h>
28 #include <ns3/lte-mac-sap.h>
29 #include <map>
30
31
32 namespace ns3 {
33 class LteUeCmacSapProvider;
34 class UeManager;
35 class LteEnbCmacSapProvider;
36 class LteMacSapUser;
37 class LteRrcSap;
38
39 /**
40 * \brief Service Access Point (SAP) offered by the Component Carrier Manager (CCM)
41 * instance to the eNodeB RRC instance.
42 *
43 * This is the *Component Carrier Manager SAP Provider*, i.e., the part of the SAP
44 * that contains the CCM methods called by the eNodeB RRC instance.
45 */
46 class LteCcmRrcSapProvider
47 {
48
49 /// allow UeManager class friend access
50 friend class UeManager;
51 /// allow LteMacSapUser class friend access
52 friend class LteMacSapUser;
53
54 public:
55
56 virtual ~LteCcmRrcSapProvider ();
57
58 /// LcsConfig structure
59 struct LcsConfig
60 {
61 uint16_t componentCarrierId; ///< component carrier ID
62 LteEnbCmacSapProvider::LcInfo lc; ///< LC info
63 LteMacSapUser *msu; ///< MSU
64 };
65
66 /**
67 * \brief Reports UE measurements to the component carrier manager.
68 * \param rnti Radio Network Temporary Identity, an integer identifying
69 * the UE where the measurement report originates from.
70 * \param measResults a single report of one measurement identity
71 *
72 * The received measurement report is a result of the UE measurements configuration
73 * previously configured by calling LteCcmRrcSapProvider::AddUeMeasReportConfigForComponentCarrier.
74 * The report may be stored and utilized for the purpose of making decision if and when
75 * to use the secondary carriers.
76 */
77 virtual void ReportUeMeas (uint16_t rnti, LteRrcSap::MeasResults measResults) = 0;
78
79 /**
80 * \brief Add a new UE in the LteEnbComponentCarrierManager.
81 * \param rnti Radio Network Temporary Identity, an integer identifying the UE.
82 * \param state The current rrc state of the UE.
83 */
84 virtual void AddUe (uint16_t rnti, uint8_t state) = 0;
85
86 /**
87 * \brief Add a new logical channel.
88 * \param lcInfo - information about newly created logical channel
89 * \param msu - pointer to corresponding rlc interface
90 *
91 */
92 virtual void AddLc (LteEnbCmacSapProvider::LcInfo lcInfo, LteMacSapUser* msu) = 0;
93
94 /**
95 * \brief Remove an existing UE.
96 * \param rnti Radio Network Temporary Identity, an integer identifying the UE
97 * where the report originates from
98 */
99 virtual void RemoveUe (uint16_t rnti) = 0;
100
101 /**
102 * \brief Add a new Bearer for the Ue in the LteEnbComponentCarrierManager.
103 * \param bearer a pointer to the EpsBearer object
104 * \param bearerId a unique identifier for the bearer
105 * \param rnti Radio Network Temporary Identity, an integer identifying the UE
106 * where the report originates from
107 * \param lcid the Logical Channel id
108 * \param lcGroup the Logical Channel group
109 * \param msu a pointer to the LteMacSapUser, the LteEnbComponentCarrierManager
110 * has to store a LteMacSapUser for each Rlc istance, in order to
111 * properly redirect the packet
112 * \return vector of LcsConfig contains the lc configuration for each Mac
113 * the size of the vector is equal to the number of component
114 * carrier enabled.
115 *
116 * The Logical Channel configurations for each component carrier depend on the
117 * algorithm used to split the traffic between the component carriers themself.
118 */
119 virtual std::vector<LteCcmRrcSapProvider::LcsConfig> SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint16_t rnti, uint8_t lcid, uint8_t lcGroup, LteMacSapUser *msu) = 0;
120
121 /**
122 * \brief Release an existing Data Radio Bearer for a Ue in the LteEnbComponentCarrierManager
123 * \param rnti Radio Network Temporary Identity, an integer identifying the UE
124 * where the report originates from
125 * \param lcid the Logical Channel Id
126 * \return vector of integer the componentCarrierId of the componentCarrier
127 * where the bearer is enabled
128 */
129
130 virtual std::vector<uint8_t> ReleaseDataRadioBearer (uint16_t rnti, uint8_t lcid) = 0;
131
132 /**
133 * \brief Add the Signal Bearer for a specific Ue in LteEnbComponenCarrierManager
134 * \param lcInfo this structure it is hard-coded in the LteEnbRrc
135 * \param rlcMacSapUser it is the MacSapUser of the Rlc istance
136 * \return the LteMacSapUser of the ComponentCarrierManager
137 *
138 */
139 virtual LteMacSapUser* ConfigureSignalBearer(LteEnbCmacSapProvider::LcInfo lcInfo, LteMacSapUser* rlcMacSapUser) = 0;
140
141 }; // end of class LteCcmRrcSapProvider
142
143
144 /**
145 * \brief Service Access Point (SAP) offered by the eNodeB RRC instance to the
146 * component carrier manager (CCM) instance.
147 *
148 * This is the *Component Carrier Management SAP User*, i.e., the part of the SAP that
149 * contains the eNodeB RRC methods called by the CCM.
150 */
151 class LteCcmRrcSapUser
152 {
153 /// allow LteEnbRrc class friend access
154 friend class LteEnbRrc;
155 public:
156 virtual ~LteCcmRrcSapUser ();
157
158 /**
159 * \brief Request a certain reporting configuration to be fulfilled by the UEs
160 * attached to the eNodeB entity.
161 * \param reportConfig the UE measurement reporting configuration
162 * \return the measurement identity associated with this newly added
163 * reporting configuration
164 *
165 * The eNodeB RRC entity is expected to configure the same reporting
166 * configuration in each of the attached UEs. When later in the simulation a
167 * UE measurement report is received from a UE as a result of this
168 * configuration, the eNodeB RRC entity shall forward this report to the
169 * ComponentCarrier algorithm through the LteCcmRrcSapProvider::ReportUeMeas
170 * SAP function.
171 *
172 * \note This function is only valid before the simulation begins.
173 */
174 virtual uint8_t AddUeMeasReportConfigForComponentCarrier (LteRrcSap::ReportConfigEutra reportConfig) = 0;
175
176 /**
177 * \brief Instruct the eNodeB RRC entity to prepare a component carrier.
178 * \param rnti Radio Network Temporary Identity, an integer identifying the
179 * UE which shall perform the ComponentCarrier
180 * \param targetCellId the cell ID of the target eNodeB
181 *
182 * This function is used by the ComponentCarrier manager when a decision on
183 * component carriers configurations.
184 *
185 * The process to produce the decision is up to the implementation of ComponentCarrier
186 * algorithm. It is typically based on the reported UE measurements, which are
187 * received through the LteCcmRrcSapProvider::ReportUeMeas function.
188 */
189 virtual void TriggerComponentCarrier (uint16_t rnti, uint16_t targetCellId) = 0;
190
191 /**
192 * add a new Logical Channel (LC)
193 *
194 * \param lcConfig is a single structure contains logical Channel Id, Logical Channel config and Component Carrier Id
195 */
196 virtual void AddLcs (std::vector<LteEnbRrcSapProvider::LogicalChannelConfig> lcConfig) = 0;
197
198 /**
199 * remove an existing LC
200 *
201 * \param rnti
202 * \param lcid
203 */
204 virtual void ReleaseLcs (uint16_t rnti, uint8_t lcid) = 0;
205
206 /**
207 * Get UE manager by RNTI
208 *
209 * \param rnti RNTI
210 * \return UE manager
211 */
212 virtual Ptr<UeManager> GetUeManager (uint16_t rnti) = 0;
213
214 /**
215 * \brief Set the number of component carriers
216 *
217 * \param noOfComponentCarriers The number of component carriers
218 */
219 virtual void SetNumberOfComponentCarriers (uint16_t noOfComponentCarriers) = 0;
220
221 }; // end of class LteCcmRrcSapUser
222
223 /// MemberLteCcmRrcSapProvider class
224 template <class C>
225 class MemberLteCcmRrcSapProvider : public LteCcmRrcSapProvider
226 {
227 public:
228 /**
229 * Constructor
230 *
231 * \param owner the owner class
232 */
233 MemberLteCcmRrcSapProvider (C* owner);
234
235 // inherited from LteCcmRrcSapProvider
236 virtual void ReportUeMeas (uint16_t rnti, LteRrcSap::MeasResults measResults);
237 virtual void AddUe (uint16_t rnti, uint8_t state);
238 virtual void AddLc (LteEnbCmacSapProvider::LcInfo lcInfo, LteMacSapUser* msu);
239 virtual void RemoveUe (uint16_t rnti);
240 virtual std::vector<LteCcmRrcSapProvider::LcsConfig> SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint16_t rnti, uint8_t lcid, uint8_t lcGroup, LteMacSapUser *msu);
241 virtual std::vector<uint8_t> ReleaseDataRadioBearer (uint16_t rnti, uint8_t lcid);
242 virtual LteMacSapUser* ConfigureSignalBearer(LteEnbCmacSapProvider::LcInfo lcInfo, LteMacSapUser* rlcMacSapUser);
243
244 private:
245 C* m_owner; ///< the owner class
246 };
247
248 template <class C>
MemberLteCcmRrcSapProvider(C * owner)249 MemberLteCcmRrcSapProvider<C>::MemberLteCcmRrcSapProvider (C* owner)
250 : m_owner (owner)
251 {
252 }
253
254 template <class C>
ReportUeMeas(uint16_t rnti,LteRrcSap::MeasResults measResults)255 void MemberLteCcmRrcSapProvider<C>::ReportUeMeas (uint16_t rnti, LteRrcSap::MeasResults measResults)
256 {
257 m_owner->DoReportUeMeas (rnti, measResults);
258 }
259
260 template <class C>
AddUe(uint16_t rnti,uint8_t state)261 void MemberLteCcmRrcSapProvider<C>::AddUe (uint16_t rnti, uint8_t state)
262 {
263 m_owner->DoAddUe (rnti, state);
264 }
265
266 template <class C>
AddLc(LteEnbCmacSapProvider::LcInfo lcInfo,LteMacSapUser * msu)267 void MemberLteCcmRrcSapProvider<C>::AddLc (LteEnbCmacSapProvider::LcInfo lcInfo, LteMacSapUser* msu)
268 {
269 m_owner->DoAddLc (lcInfo, msu);
270 }
271
272 template <class C>
RemoveUe(uint16_t rnti)273 void MemberLteCcmRrcSapProvider<C>::RemoveUe (uint16_t rnti)
274 {
275 m_owner->DoRemoveUe (rnti);
276 }
277
278 template <class C>
SetupDataRadioBearer(EpsBearer bearer,uint8_t bearerId,uint16_t rnti,uint8_t lcid,uint8_t lcGroup,LteMacSapUser * msu)279 std::vector<LteCcmRrcSapProvider::LcsConfig> MemberLteCcmRrcSapProvider<C>::SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint16_t rnti, uint8_t lcid, uint8_t lcGroup, LteMacSapUser *msu)
280 {
281 return m_owner->DoSetupDataRadioBearer (bearer, bearerId, rnti, lcid, lcGroup, msu);
282 }
283
284 template <class C>
ReleaseDataRadioBearer(uint16_t rnti,uint8_t lcid)285 std::vector<uint8_t> MemberLteCcmRrcSapProvider<C>::ReleaseDataRadioBearer (uint16_t rnti, uint8_t lcid)
286 {
287 return m_owner->DoReleaseDataRadioBearer (rnti, lcid);
288 }
289
290 template <class C>
ConfigureSignalBearer(LteEnbCmacSapProvider::LcInfo lcInfo,LteMacSapUser * rlcMacSapUser)291 LteMacSapUser* MemberLteCcmRrcSapProvider<C>::ConfigureSignalBearer(LteEnbCmacSapProvider::LcInfo lcInfo, LteMacSapUser* rlcMacSapUser)
292 {
293 return m_owner->DoConfigureSignalBearer (lcInfo, rlcMacSapUser);
294 }
295
296
297 /// MemberLteCcmRrcSapUser class
298 template <class C>
299 class MemberLteCcmRrcSapUser : public LteCcmRrcSapUser
300 {
301 public:
302 /**
303 * Constructor
304 *
305 * \param owner the owner class
306 */
307 MemberLteCcmRrcSapUser (C* owner);
308
309 // inherited from LteCcmRrcSapUser
310 virtual void AddLcs (std::vector<LteEnbRrcSapProvider::LogicalChannelConfig> lcConfig);
311 virtual void ReleaseLcs (uint16_t rnti, uint8_t lcid);
312 virtual uint8_t AddUeMeasReportConfigForComponentCarrier (LteRrcSap::ReportConfigEutra reportConfig);
313 virtual void TriggerComponentCarrier (uint16_t rnti, uint16_t targetCellId);
314 virtual Ptr<UeManager> GetUeManager (uint16_t rnti);
315 virtual void SetNumberOfComponentCarriers (uint16_t noOfComponentCarriers);
316
317 private:
318 C* m_owner; ///< the owner class
319 };
320
321 template <class C>
MemberLteCcmRrcSapUser(C * owner)322 MemberLteCcmRrcSapUser<C>::MemberLteCcmRrcSapUser (C* owner)
323 : m_owner (owner)
324 {
325 }
326
327 template <class C>
AddLcs(std::vector<LteEnbRrcSapProvider::LogicalChannelConfig> lcConfig)328 void MemberLteCcmRrcSapUser<C>::AddLcs (std::vector<LteEnbRrcSapProvider::LogicalChannelConfig> lcConfig)
329 {
330 NS_FATAL_ERROR ("Function should not be called because it is not implemented.");
331 //m_owner->DoAddLcs (lcConfig);
332 }
333
334 template <class C>
ReleaseLcs(uint16_t rnti,uint8_t lcid)335 void MemberLteCcmRrcSapUser<C>::ReleaseLcs (uint16_t rnti, uint8_t lcid)
336 {
337 NS_FATAL_ERROR ("Function should not be called because it is not implemented.");
338 //m_owner->DoReleaseLcs (rnti, lcid);
339
340 }
341
342 template <class C>
343 uint8_t
AddUeMeasReportConfigForComponentCarrier(LteRrcSap::ReportConfigEutra reportConfig)344 MemberLteCcmRrcSapUser<C>::AddUeMeasReportConfigForComponentCarrier (LteRrcSap::ReportConfigEutra reportConfig)
345 {
346 return m_owner->DoAddUeMeasReportConfigForComponentCarrier (reportConfig);
347 }
348
349
350 template <class C>
351 void
TriggerComponentCarrier(uint16_t rnti,uint16_t targetCellId)352 MemberLteCcmRrcSapUser<C>::TriggerComponentCarrier (uint16_t rnti, uint16_t targetCellId)
353 {
354 NS_FATAL_ERROR ("Function should not be called because it is not implemented.");
355 }
356
357 template <class C>
358 Ptr<UeManager>
GetUeManager(uint16_t rnti)359 MemberLteCcmRrcSapUser<C>::GetUeManager (uint16_t rnti)
360 {
361 return m_owner->GetUeManager (rnti);
362 }
363
364 template <class C>
365 void
SetNumberOfComponentCarriers(uint16_t noOfComponentCarriers)366 MemberLteCcmRrcSapUser<C>::SetNumberOfComponentCarriers (uint16_t noOfComponentCarriers)
367 {
368 return m_owner->DoSetNumberOfComponentCarriers (noOfComponentCarriers);
369 }
370
371 } // end of namespace ns3
372
373
374 #endif /* LTE_CCM_RRC_SAP_H */
375
376