A Discrete-Event Network Simulator
API
lte-fr-hard-algorithm.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Piotr Gawlowicz
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: Piotr Gawlowicz <gawlowicz.p@gmail.com>
19  *
20  */
21 
22 #include "lte-fr-hard-algorithm.h"
23 #include <ns3/log.h>
24 
25 namespace ns3 {
26 
27 NS_LOG_COMPONENT_DEFINE ("LteFrHardAlgorithm");
28 
29 NS_OBJECT_ENSURE_REGISTERED (LteFrHardAlgorithm);
30 
32 {
33  uint8_t m_cellId;
34  uint8_t m_dlBandwidth;
35  uint8_t m_dlOffset;
36  uint8_t m_dlSubBand;
38  { 1, 15, 0, 4},
39  { 2, 15, 4, 4},
40  { 3, 15, 8, 6},
41  { 1, 25, 0, 8},
42  { 2, 25, 8, 8},
43  { 3, 25, 16, 9},
44  { 1, 50, 0, 16},
45  { 2, 50, 16, 16},
46  { 3, 50, 32, 18},
47  { 1, 75, 0, 24},
48  { 2, 75, 24, 24},
49  { 3, 75, 48, 27},
50  { 1, 100, 0, 32},
51  { 2, 100, 32, 32},
52  { 3, 100, 64, 36}
53 };
54 
56 {
57  uint8_t m_cellId;
58  uint8_t m_ulBandwidth;
59  uint8_t m_ulOffset;
60  uint8_t m_ulSubBand;
62  { 1, 15, 0, 5},
63  { 2, 15, 5, 5},
64  { 3, 15, 10, 5},
65  { 1, 25, 0, 8},
66  { 2, 25, 8, 8},
67  { 3, 25, 16, 9},
68  { 1, 50, 0, 16},
69  { 2, 50, 16, 16},
70  { 3, 50, 32, 18},
71  { 1, 75, 0, 24},
72  { 2, 75, 24, 24},
73  { 3, 75, 48, 27},
74  { 1, 100, 0, 32},
75  { 2, 100, 32, 32},
76  { 3, 100, 64, 36}
77 };
78 
79 const uint16_t NUM_DOWNLINK_CONFS (sizeof (g_frHardDownlinkDefaultConfiguration) / sizeof (FrHardDownlinkDefaultConfiguration));
80 const uint16_t NUM_UPLINK_CONFS (sizeof (g_frHardUplinkDefaultConfiguration) / sizeof (FrHardUplinkDefaultConfiguration));
81 
83  : m_ffrSapUser (0),
84  m_ffrRrcSapUser (0),
85  m_dlOffset (0),
86  m_dlSubBand (0),
87  m_ulOffset (0),
88  m_ulSubBand (0)
89 {
90  NS_LOG_FUNCTION (this);
93 }
94 
95 
97 {
98  NS_LOG_FUNCTION (this);
99 }
100 
101 
102 void
104 {
105  NS_LOG_FUNCTION (this);
106  delete m_ffrSapProvider;
107  delete m_ffrRrcSapProvider;
108 }
109 
110 
111 TypeId
113 {
114  static TypeId tid = TypeId ("ns3::LteFrHardAlgorithm")
116  .SetGroupName("Lte")
117  .AddConstructor<LteFrHardAlgorithm> ()
118  .AddAttribute ("UlSubBandOffset",
119  "Uplink Offset in number of Resource Block Groups",
120  UintegerValue (0),
122  MakeUintegerChecker<uint8_t> ())
123  .AddAttribute ("UlSubBandwidth",
124  "Uplink Transmission SubBandwidth Configuration in number of Resource Block Groups",
125  UintegerValue (25),
127  MakeUintegerChecker<uint8_t> ())
128  .AddAttribute ("DlSubBandOffset",
129  "Downlink Offset in number of Resource Block Groups",
130  UintegerValue (0),
132  MakeUintegerChecker<uint8_t> ())
133  .AddAttribute ("DlSubBandwidth",
134  "Downlink Transmission SubBandwidth Configuration in number of Resource Block Groups",
135  UintegerValue (25),
137  MakeUintegerChecker<uint8_t> ())
138  ;
139  return tid;
140 }
141 
142 
143 void
145 {
146  NS_LOG_FUNCTION (this << s);
147  m_ffrSapUser = s;
148 }
149 
150 
153 {
154  NS_LOG_FUNCTION (this);
155  return m_ffrSapProvider;
156 }
157 
158 void
160 {
161  NS_LOG_FUNCTION (this << s);
162  m_ffrRrcSapUser = s;
163 }
164 
165 
168 {
169  NS_LOG_FUNCTION (this);
170  return m_ffrRrcSapProvider;
171 }
172 
173 
174 void
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 }
190 
191 void
193 {
194  NS_LOG_FUNCTION (this);
195  if (m_frCellTypeId != 0)
196  {
199  }
202  m_needReconfiguration = false;
203 }
204 
205 void
206 LteFrHardAlgorithm::SetDownlinkConfiguration (uint16_t cellId, uint8_t bandwidth)
207 {
208  NS_LOG_FUNCTION (this);
209  for (uint16_t i = 0; i < NUM_DOWNLINK_CONFS; ++i)
210  {
213  {
216  }
217  }
218 }
219 
220 void
221 LteFrHardAlgorithm::SetUplinkConfiguration (uint16_t cellId, uint8_t bandwidth)
222 {
223  NS_LOG_FUNCTION (this);
224  for (uint16_t i = 0; i < NUM_UPLINK_CONFS; ++i)
225  {
228  {
231  }
232  }
233 }
234 
235 void
237 {
238  m_dlRbgMap.clear ();
239 
240  int rbgSize = GetRbgSize (m_dlBandwidth);
241  m_dlRbgMap.resize (m_dlBandwidth / rbgSize, true);
242 
243  NS_ASSERT_MSG (m_dlOffset <= m_dlBandwidth,"DlOffset higher than DlBandwidth");
244  NS_ASSERT_MSG (m_dlSubBand <= m_dlBandwidth,"DlBandwidth higher than DlBandwidth");
246  "(DlOffset+DlSubBand) higher than DlBandwidth");
247 
248  for (uint8_t i = m_dlOffset / rbgSize; i < (m_dlOffset / rbgSize + m_dlSubBand / rbgSize); i++)
249  {
250  m_dlRbgMap[i] = false;
251 
252  }
253 }
254 
255 void
257 {
258  m_ulRbgMap.clear ();
259 
260  if (!m_enabledInUplink)
261  {
262  m_ulRbgMap.resize (m_ulBandwidth, false);
263  return;
264  }
265 
266  m_ulRbgMap.resize (m_ulBandwidth, true);
267 
268  NS_ASSERT_MSG (m_ulOffset <= m_ulBandwidth,"UlOffset higher than UlBandwidth");
269  NS_ASSERT_MSG (m_ulSubBand <= m_ulBandwidth,"UlBandwidth higher than UlBandwidth");
271  "(UlOffset+UlSubBand) higher than UlBandwidth");
272 
273  for (uint8_t i = m_ulOffset; i < (m_ulOffset + m_ulSubBand); i++)
274  {
275  m_ulRbgMap[i] = false;
276  }
277 }
278 
279 std::vector <bool>
281 {
282  NS_LOG_FUNCTION (this);
283 
285  {
286  Reconfigure ();
287  }
288 
289  if (m_dlRbgMap.empty ())
290  {
292  }
293 
294  return m_dlRbgMap;
295 }
296 
297 bool
299 {
300  NS_LOG_FUNCTION (this);
301  return !m_dlRbgMap[rbId];
302 }
303 
304 std::vector <bool>
306 {
307  NS_LOG_FUNCTION (this);
308 
309  if (m_ulRbgMap.empty ())
310  {
312  }
313 
314  return m_ulRbgMap;
315 }
316 
317 bool
319 {
320  NS_LOG_FUNCTION (this);
321 
322  if (!m_enabledInUplink)
323  {
324  return true;
325  }
326 
327  return !m_ulRbgMap[rbId];
328 }
329 
330 void
332 {
333  NS_LOG_FUNCTION (this);
334  NS_LOG_WARN ("Method should not be called, because it is empty");
335 }
336 
337 void
339 {
340  NS_LOG_FUNCTION (this);
341  NS_LOG_WARN ("Method should not be called, because it is empty");
342 }
343 
344 void
345 LteFrHardAlgorithm::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 
351 uint8_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 Table 5.1.1.1-2
356 }
357 
358 uint8_t
360 {
361  NS_LOG_FUNCTION (this);
362 
363  if (!m_enabledInUplink)
364  {
365  return m_ulBandwidth;
366  }
367 
368  return m_ulSubBand;
369 }
370 
371 void
373  LteRrcSap::MeasResults measResults)
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 
379 void
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
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the eNodeB RRC instan...
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
Template for the implementation of the LteFfrRrcSapProvider as a member of an owner class of type C t...
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Definition: lte-ffr-sap.h:132
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual void DoDispose()
Destructor implementation.
uint8_t m_ulBandwidth
uplink bandwidth in RBs
LteFrHardAlgorithm()
Creates a trivial ffr algorithm instance.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual bool DoIsDlRbgAvailableForUe(int i, uint16_t rnti)
Implementation of LteFfrSapProvider::IsDlRbgAvailableForUe.
static const struct ns3::FrHardDownlinkDefaultConfiguration g_frHardDownlinkDefaultConfiguration[]
void SetDownlinkConfiguration(uint16_t cellId, uint8_t bandwidth)
Template for the implementation of the LteFfrSapProvider as a member of an owner class of type C to w...
Definition: lte-ffr-sap.h:146
virtual void Reconfigure()
Automatic FR reconfiguration.
virtual void SetLteFfrRrcSapUser(LteFfrRrcSapUser *s)
Set the "user" part of the LteFfrRrcSap interface that this frequency reuse algorithm instance will i...
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Definition: lte-ffr-sap.h:39
virtual void DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults)
Implementation of LteFfrRrcSapProvider::ReportUeMeas.
Hold an unsigned integer type.
Definition: uinteger.h:44
Hard Frequency Reuse algorithm implementation which uses only 1 sub-band.
bool m_enabledInUplink
If true FR algorithm will also work in Uplink.
std::vector< bool > m_ulRbgMap
bool m_needReconfiguration
If true FR algorithm will be reconfigured.
uint8_t m_dlBandwidth
downlink bandwidth in RBs
virtual void DoInitialize()
Initialize() implementation.
std::vector< bool > m_dlRbgMap
LteFfrSapProvider * m_ffrSapProvider
LteFfrRrcSapUser * m_ffrRrcSapUser
Every class exported by the ns3 library is enclosed in the ns3 namespace.
The abstract base class of a Frequency Reuse algorithm.
virtual std::vector< bool > DoGetAvailableDlRbg()
Implementation of LteFfrSapProvider::GetAvailableDlRbg.
virtual uint8_t DoGetMinContinuousUlBandwidth()
DoGetMinContinuousUlBandwidth in number of RB.
virtual void DoReportDlCqiInfo(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
DoReportDlCqiInfo.
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
#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:90
virtual std::vector< bool > DoGetAvailableUlRbg()
Implementation of LteFfrSapProvider::GetAvailableUlRbg.
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
uint8_t m_frCellTypeId
FFR cell type ID for automatic configuration.
virtual void DoRecvLoadInformation(EpcX2Sap::LoadInformationParams params)
DoRecvLoadInformation.
virtual void SetLteFfrSapUser(LteFfrSapUser *s)
Set the "user" part of the LteFfrSap interface that this frequency reuse algorithm instance will inte...
static const struct ns3::FrHardUplinkDefaultConfiguration g_frHardUplinkDefaultConfiguration[]
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
virtual uint8_t DoGetTpc(uint16_t rnti)
DoGetTpc for UE.
virtual LteFfrRrcSapProvider * GetLteFfrRrcSapProvider()
Export the "provider" part of the LteFfrRrcSap interface.
int GetRbgSize(int dlbandwidth)
Get RBG size for DL Bandwidth according to table 7.1.6.1-1 of 36.213.
Parameters of the LOAD INFORMATION message.
Definition: epc-x2-sap.h:300
LteFfrRrcSapProvider * m_ffrRrcSapProvider
virtual bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti)
Implementation of LteFfrSapProvider::IsUlRbgAvailableForUe.
void SetUplinkConfiguration(uint16_t cellId, uint8_t bandwidth)
const uint16_t NUM_DOWNLINK_CONFS(sizeof(g_ffrEnhancedDownlinkDefaultConfiguration)/sizeof(FfrEnhancedDownlinkDefaultConfiguration))
virtual LteFfrSapProvider * GetLteFfrSapProvider()
Export the "provider" part of the LteFfrSap interface.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
const uint16_t NUM_UPLINK_CONFS(sizeof(g_ffrEnhancedUplinkDefaultConfiguration)/sizeof(FfrEnhancedUplinkDefaultConfiguration))
virtual void DoReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
DoReportUlCqiInfo.