A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteFrHardAlgorithm");
26 
27 namespace ns3 {
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  .AddConstructor<LteFrHardAlgorithm> ()
117  .AddAttribute ("UlSubBandOffset",
118  "Uplink Offset in number of Resource Block Groups",
119  UintegerValue (0),
120  MakeUintegerAccessor (&LteFrHardAlgorithm::m_ulOffset),
121  MakeUintegerChecker<uint8_t> ())
122  .AddAttribute ("UlSubBandwidth",
123  "Uplink Transmission SubBandwidth Configuration in number of Resource Block Groups",
124  UintegerValue (25),
125  MakeUintegerAccessor (&LteFrHardAlgorithm::m_ulSubBand),
126  MakeUintegerChecker<uint8_t> ())
127  .AddAttribute ("DlSubBandOffset",
128  "Downlink Offset in number of Resource Block Groups",
129  UintegerValue (0),
130  MakeUintegerAccessor (&LteFrHardAlgorithm::m_dlOffset),
131  MakeUintegerChecker<uint8_t> ())
132  .AddAttribute ("DlSubBandwidth",
133  "Downlink Transmission SubBandwidth Configuration in number of Resource Block Groups",
134  UintegerValue (25),
135  MakeUintegerAccessor (&LteFrHardAlgorithm::m_dlSubBand),
136  MakeUintegerChecker<uint8_t> ())
137  ;
138  return tid;
139 }
140 
141 
142 void
144 {
145  NS_LOG_FUNCTION (this << s);
146  m_ffrSapUser = s;
147 }
148 
149 
152 {
153  NS_LOG_FUNCTION (this);
154  return m_ffrSapProvider;
155 }
156 
157 void
159 {
160  NS_LOG_FUNCTION (this << s);
161  m_ffrRrcSapUser = s;
162 }
163 
164 
167 {
168  NS_LOG_FUNCTION (this);
169  return m_ffrRrcSapProvider;
170 }
171 
172 
173 void
175 {
176  NS_LOG_FUNCTION (this);
178 
179  NS_ASSERT_MSG (m_dlBandwidth > 14,"DlBandwidth must be at least 15 to use FFR algorithms");
180  NS_ASSERT_MSG (m_ulBandwidth > 14,"UlBandwidth must be at least 15 to use FFR algorithms");
181 
182  if (m_frCellTypeId != 0)
183  {
186  }
187 
188 }
189 
190 void
192 {
193  NS_LOG_FUNCTION (this);
194  if (m_frCellTypeId != 0)
195  {
198  }
201  m_needReconfiguration = false;
202 }
203 
204 void
205 LteFrHardAlgorithm::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 
219 void
220 LteFrHardAlgorithm::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  {
227  {
230  }
231  }
232 }
233 
234 void
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 (uint8_t i = m_dlOffset / rbgSize; i < (m_dlOffset / rbgSize + m_dlSubBand / rbgSize); i++)
248  {
249  m_dlRbgMap[i] = false;
250 
251  }
252 }
253 
254 void
256 {
257  m_ulRbgMap.clear ();
258 
259  if (!m_enabledInUplink)
260  {
261  m_ulRbgMap.resize (m_ulBandwidth, false);
262  return;
263  }
264 
265  m_ulRbgMap.resize (m_ulBandwidth, true);
266 
267  NS_ASSERT_MSG (m_ulOffset <= m_ulBandwidth,"UlOffset higher than UlBandwidth");
268  NS_ASSERT_MSG (m_ulSubBand <= m_ulBandwidth,"UlBandwidth higher than UlBandwidth");
270  "(UlOffset+UlSubBand) higher than UlBandwidth");
271 
272  for (uint8_t i = m_ulOffset; i < (m_ulOffset + m_ulSubBand); i++)
273  {
274  m_ulRbgMap[i] = false;
275  }
276 }
277 
278 std::vector <bool>
280 {
281  NS_LOG_FUNCTION (this);
282 
284  {
285  Reconfigure ();
286  }
287 
288  if (m_dlRbgMap.empty ())
289  {
291  }
292 
293  return m_dlRbgMap;
294 }
295 
296 bool
298 {
299  NS_LOG_FUNCTION (this);
300  return !m_dlRbgMap[rbId];
301 }
302 
303 std::vector <bool>
305 {
306  NS_LOG_FUNCTION (this);
307 
308  if (m_ulRbgMap.empty ())
309  {
311  }
312 
313  return m_ulRbgMap;
314 }
315 
316 bool
318 {
319  NS_LOG_FUNCTION (this);
320 
321  if (!m_enabledInUplink)
322  {
323  return true;
324  }
325 
326  return !m_ulRbgMap[rbId];
327 }
328 
329 void
331 {
332  NS_LOG_FUNCTION (this);
333  NS_LOG_WARN ("Method should not be called, because it is empty");
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION (this);
340  NS_LOG_WARN ("Method should not be called, because it is empty");
341 }
342 
343 void
344 LteFrHardAlgorithm::DoReportUlCqiInfo (std::map <uint16_t, std::vector <double> > ulCqiMap)
345 {
346  NS_LOG_FUNCTION (this);
347  NS_LOG_WARN ("Method should not be called, because it is empty");
348 }
349 
350 uint8_t
352 {
353  NS_LOG_FUNCTION (this);
354  return 1; // 1 is mapped to 0 for Accumulated mode, and to -1 in Absolute mode TS36.213 Table 5.1.1.1-2
355 }
356 
357 uint8_t
359 {
360  NS_LOG_FUNCTION (this);
361 
362  if (!m_enabledInUplink)
363  {
364  return m_ulBandwidth;
365  }
366 
367  return m_ulSubBand;
368 }
369 
370 void
372  LteRrcSap::MeasResults measResults)
373 {
374  NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId);
375  NS_LOG_WARN ("Method should not be called, because it is empty");
376 }
377 
378 void
380 {
381  NS_LOG_FUNCTION (this);
382  NS_LOG_WARN ("Method should not be called, because it is empty");
383 }
384 
385 } // end of namespace ns3
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the eNodeB RRC instan...
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 the class in the ns-3 factory.
Definition: object-base.h:38
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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:170
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:46
Ptr< SampleEmitter > s
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()
This method is called only once by Object::Initialize.
std::vector< bool > m_dlRbgMap
LteFfrSapProvider * m_ffrSapProvider
LteFfrRrcSapUser * m_ffrRrcSapUser
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:84
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:203
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.
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
const uint16_t NUM_UPLINK_CONFS(sizeof(g_ffrEnhancedUplinkDefaultConfiguration)/sizeof(FfrEnhancedUplinkDefaultConfiguration))
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: object.cc:342
virtual void DoReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
DoReportUlCqiInfo.