A Discrete-Event Network Simulator
API
lte-fr-hard-algorithm.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Piotr Gawlowicz
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: Piotr Gawlowicz <gawlowicz.p@gmail.com>
18 *
19 */
20
22
23#include <ns3/log.h>
24
25namespace ns3
26{
27
28NS_LOG_COMPONENT_DEFINE("LteFrHardAlgorithm");
29
30NS_OBJECT_ENSURE_REGISTERED(LteFrHardAlgorithm);
31
34{
35 uint8_t m_cellId;
36 uint8_t m_dlBandwidth;
37 uint8_t m_dlOffset;
38 uint8_t m_dlSubBand;
40 {1, 15, 0, 4},
41 {2, 15, 4, 4},
42 {3, 15, 8, 6},
43 {1, 25, 0, 8},
44 {2, 25, 8, 8},
45 {3, 25, 16, 9},
46 {1, 50, 0, 16},
47 {2, 50, 16, 16},
48 {3, 50, 32, 18},
49 {1, 75, 0, 24},
50 {2, 75, 24, 24},
51 {3, 75, 48, 27},
52 {1, 100, 0, 32},
53 {2, 100, 32, 32},
54 {3, 100, 64, 36}};
55
58{
59 uint8_t m_cellId;
60 uint8_t m_ulBandwidth;
61 uint8_t m_ulOffset;
62 uint8_t m_ulSubBand;
64 {1, 15, 0, 5},
65 {2, 15, 5, 5},
66 {3, 15, 10, 5},
67 {1, 25, 0, 8},
68 {2, 25, 8, 8},
69 {3, 25, 16, 9},
70 {1, 50, 0, 16},
71 {2, 50, 16, 16},
72 {3, 50, 32, 18},
73 {1, 75, 0, 24},
74 {2, 75, 24, 24},
75 {3, 75, 48, 27},
76 {1, 100, 0, 32},
77 {2, 100, 32, 32},
78 {3, 100, 64, 36}};
79
86
88 : m_ffrSapUser(nullptr),
89 m_ffrRrcSapUser(nullptr),
90 m_dlOffset(0),
91 m_dlSubBand(0),
92 m_ulOffset(0),
93 m_ulSubBand(0)
94{
95 NS_LOG_FUNCTION(this);
98}
99
101{
102 NS_LOG_FUNCTION(this);
103}
104
105void
107{
108 NS_LOG_FUNCTION(this);
109 delete m_ffrSapProvider;
110 delete m_ffrRrcSapProvider;
111}
112
113TypeId
115{
116 static TypeId tid =
117 TypeId("ns3::LteFrHardAlgorithm")
119 .SetGroupName("Lte")
120 .AddConstructor<LteFrHardAlgorithm>()
121 .AddAttribute("UlSubBandOffset",
122 "Uplink Offset in number of Resource Block Groups",
123 UintegerValue(0),
125 MakeUintegerChecker<uint8_t>())
126 .AddAttribute(
127 "UlSubBandwidth",
128 "Uplink Transmission SubBandwidth Configuration in number of Resource Block Groups",
129 UintegerValue(25),
131 MakeUintegerChecker<uint8_t>())
132 .AddAttribute("DlSubBandOffset",
133 "Downlink Offset in number of Resource Block Groups",
134 UintegerValue(0),
136 MakeUintegerChecker<uint8_t>())
137 .AddAttribute("DlSubBandwidth",
138 "Downlink Transmission SubBandwidth Configuration in number of Resource "
139 "Block Groups",
140 UintegerValue(25),
142 MakeUintegerChecker<uint8_t>());
143 return tid;
144}
145
146void
148{
149 NS_LOG_FUNCTION(this << s);
150 m_ffrSapUser = s;
151}
152
155{
156 NS_LOG_FUNCTION(this);
157 return m_ffrSapProvider;
158}
159
160void
162{
163 NS_LOG_FUNCTION(this << s);
164 m_ffrRrcSapUser = s;
165}
166
169{
170 NS_LOG_FUNCTION(this);
171 return m_ffrRrcSapProvider;
172}
173
174void
176{
177 NS_LOG_FUNCTION(this);
179
180 NS_ASSERT_MSG(m_dlBandwidth > 14, "DlBandwidth must be at least 15 to use FFR algorithms");
181 NS_ASSERT_MSG(m_ulBandwidth > 14, "UlBandwidth must be at least 15 to use FFR algorithms");
182
183 if (m_frCellTypeId != 0)
184 {
187 }
188}
189
190void
192{
193 NS_LOG_FUNCTION(this);
194 if (m_frCellTypeId != 0)
195 {
198 }
201 m_needReconfiguration = false;
202}
203
204void
205LteFrHardAlgorithm::SetDownlinkConfiguration(uint16_t cellId, uint8_t bandwidth)
206{
207 NS_LOG_FUNCTION(this);
208 for (uint16_t i = 0; i < NUM_DOWNLINK_CONFS; ++i)
209 {
212 {
215 }
216 }
217}
218
219void
220LteFrHardAlgorithm::SetUplinkConfiguration(uint16_t cellId, uint8_t bandwidth)
221{
222 NS_LOG_FUNCTION(this);
223 for (uint16_t i = 0; i < NUM_UPLINK_CONFS; ++i)
224 {
225 if ((g_frHardUplinkDefaultConfiguration[i].m_cellId == cellId) &&
227 {
230 }
231 }
232}
233
234void
236{
237 m_dlRbgMap.clear();
238
239 int rbgSize = GetRbgSize(m_dlBandwidth);
240 m_dlRbgMap.resize(m_dlBandwidth / rbgSize, true);
241
242 NS_ASSERT_MSG(m_dlOffset <= m_dlBandwidth, "DlOffset higher than DlBandwidth");
243 NS_ASSERT_MSG(m_dlSubBand <= m_dlBandwidth, "DlBandwidth higher than DlBandwidth");
245 "(DlOffset+DlSubBand) higher than DlBandwidth");
246
247 for (int i = m_dlOffset / rbgSize; i < (m_dlOffset / rbgSize + m_dlSubBand / rbgSize); i++)
248 {
249 m_dlRbgMap[i] = false;
250 }
251}
252
253void
255{
256 m_ulRbgMap.clear();
257
259 {
260 m_ulRbgMap.resize(m_ulBandwidth, false);
261 return;
262 }
263
264 m_ulRbgMap.resize(m_ulBandwidth, true);
265
266 NS_ASSERT_MSG(m_ulOffset <= m_ulBandwidth, "UlOffset higher than UlBandwidth");
267 NS_ASSERT_MSG(m_ulSubBand <= m_ulBandwidth, "UlBandwidth higher than UlBandwidth");
269 "(UlOffset+UlSubBand) higher than UlBandwidth");
270
271 for (uint8_t i = m_ulOffset; i < (m_ulOffset + m_ulSubBand); i++)
272 {
273 m_ulRbgMap[i] = false;
274 }
275}
276
277std::vector<bool>
279{
280 NS_LOG_FUNCTION(this);
281
283 {
284 Reconfigure();
285 }
286
287 if (m_dlRbgMap.empty())
288 {
290 }
291
292 return m_dlRbgMap;
293}
294
295bool
297{
298 NS_LOG_FUNCTION(this);
299 return !m_dlRbgMap[rbId];
300}
301
302std::vector<bool>
304{
305 NS_LOG_FUNCTION(this);
306
307 if (m_ulRbgMap.empty())
308 {
310 }
311
312 return m_ulRbgMap;
313}
314
315bool
317{
318 NS_LOG_FUNCTION(this);
319
321 {
322 return true;
323 }
324
325 return !m_ulRbgMap[rbId];
326}
327
328void
331{
332 NS_LOG_FUNCTION(this);
333 NS_LOG_WARN("Method should not be called, because it is empty");
334}
335
336void
339{
340 NS_LOG_FUNCTION(this);
341 NS_LOG_WARN("Method should not be called, because it is empty");
342}
343
344void
345LteFrHardAlgorithm::DoReportUlCqiInfo(std::map<uint16_t, std::vector<double>> ulCqiMap)
346{
347 NS_LOG_FUNCTION(this);
348 NS_LOG_WARN("Method should not be called, because it is empty");
349}
350
351uint8_t
353{
354 NS_LOG_FUNCTION(this);
355 return 1; // 1 is mapped to 0 for Accumulated mode, and to -1 in Absolute mode TS36.213
356 // Table 5.1.1.1-2
357}
358
359uint16_t
361{
362 NS_LOG_FUNCTION(this);
363
365 {
366 return m_ulBandwidth;
367 }
368
369 return m_ulSubBand;
370}
371
372void
374{
375 NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
376 NS_LOG_WARN("Method should not be called, because it is empty");
377}
378
379void
381{
382 NS_LOG_FUNCTION(this);
383 NS_LOG_WARN("Method should not be called, because it is empty");
384}
385
386} // end of namespace ns3
The abstract base class of a Frequency Reuse algorithm.
uint16_t m_cellId
cell ID
bool m_needReconfiguration
If true FR algorithm will be reconfigured.
uint8_t m_frCellTypeId
FFR cell type ID for automatic configuration.
int GetRbgSize(int dlbandwidth)
Get RBG size for DL Bandwidth according to table 7.1.6.1-1 of 36.213.
bool m_enabledInUplink
If true FR algorithm will also work in Uplink.
uint8_t m_dlBandwidth
downlink bandwidth in RBs
uint8_t m_ulBandwidth
uplink bandwidth in RBs
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the eNodeB RRC instan...
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Definition: lte-ffr-sap.h:41
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Definition: lte-ffr-sap.h:141
Hard Frequency Reuse algorithm implementation which uses only 1 sub-band.
void SetDownlinkConfiguration(uint16_t cellId, uint8_t bandwidth)
Set downlink configuration.
uint16_t DoGetMinContinuousUlBandwidth() override
DoGetMinContinuousUlBandwidth in number of RB.
void DoDispose() override
Destructor implementation.
std::vector< bool > m_dlRbgMap
DL RBG Map.
void InitializeDownlinkRbgMaps()
Initialize downlink rbg maps.
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
void InitializeUplinkRbgMaps()
Initialize uplink rbg maps.
bool DoIsDlRbgAvailableForUe(int i, uint16_t rnti) override
Implementation of LteFfrSapProvider::IsDlRbgAvailableForUe.
void DoReportDlCqiInfo(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params) override
DoReportDlCqiInfo.
static TypeId GetTypeId()
Get the type ID.
friend class MemberLteFfrSapProvider< LteFrHardAlgorithm >
let the forwarder class access the protected and private members
uint8_t DoGetTpc(uint16_t rnti) override
DoGetTpc for UE.
void SetUplinkConfiguration(uint16_t cellId, uint8_t bandwidth)
Set uplink configuration.
void DoInitialize() override
Initialize() implementation.
void DoRecvLoadInformation(EpcX2Sap::LoadInformationParams params) override
DoRecvLoadInformation.
uint8_t m_ulSubBand
UL subband.
void DoReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params) override
DoReportUlCqiInfo.
std::vector< bool > DoGetAvailableUlRbg() override
Implementation of LteFfrSapProvider::GetAvailableUlRbg.
LteFfrSapProvider * GetLteFfrSapProvider() override
Export the "provider" part of the LteFfrSap interface.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
friend class MemberLteFfrRrcSapProvider< LteFrHardAlgorithm >
let the forwarder class access the protected and private members
LteFfrRrcSapUser * m_ffrRrcSapUser
FFR RRC SAP user.
std::vector< bool > m_ulRbgMap
UL RBG Map.
LteFrHardAlgorithm()
Creates a trivial ffr algorithm instance.
void SetLteFfrSapUser(LteFfrSapUser *s) override
Set the "user" part of the LteFfrSap interface that this frequency reuse algorithm instance will inte...
std::vector< bool > DoGetAvailableDlRbg() override
Implementation of LteFfrSapProvider::GetAvailableDlRbg.
LteFfrRrcSapProvider * m_ffrRrcSapProvider
FFR RRC SAP provider.
bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti) override
Implementation of LteFfrSapProvider::IsUlRbgAvailableForUe.
void DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults) override
Implementation of LteFfrRrcSapProvider::ReportUeMeas.
LteFfrRrcSapProvider * GetLteFfrRrcSapProvider() override
Export the "provider" part of the LteFfrRrcSap interface.
void Reconfigure() override
Automatic FR reconfiguration.
uint8_t m_dlSubBand
DL subband.
void SetLteFfrRrcSapUser(LteFfrRrcSapUser *s) override
Set the "user" part of the LteFfrRrcSap interface that this frequency reuse algorithm instance will i...
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const uint16_t NUM_DOWNLINK_CONFS(sizeof(g_ffrEnhancedDownlinkDefaultConfiguration)/sizeof(FfrEnhancedDownlinkDefaultConfiguration))
const uint16_t NUM_UPLINK_CONFS(sizeof(g_ffrEnhancedUplinkDefaultConfiguration)/sizeof(FfrEnhancedUplinkDefaultConfiguration))
static const struct ns3::FrHardDownlinkDefaultConfiguration g_frHardDownlinkDefaultConfiguration[]
the hard downlink default configuration
static const struct ns3::FrHardUplinkDefaultConfiguration g_frHardUplinkDefaultConfiguration[]
the hard uplink default configuration
Parameters of the LOAD INFORMATION message.
Definition: epc-x2-sap.h:305
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
MeasResults structure.
Definition: lte-rrc-sap.h:703
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:704