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 
33 {
34  uint8_t m_cellId;
35  uint8_t m_dlBandwidth;
36  uint8_t m_dlOffset;
37  uint8_t m_dlSubBand;
39  { 1, 15, 0, 4},
40  { 2, 15, 4, 4},
41  { 3, 15, 8, 6},
42  { 1, 25, 0, 8},
43  { 2, 25, 8, 8},
44  { 3, 25, 16, 9},
45  { 1, 50, 0, 16},
46  { 2, 50, 16, 16},
47  { 3, 50, 32, 18},
48  { 1, 75, 0, 24},
49  { 2, 75, 24, 24},
50  { 3, 75, 48, 27},
51  { 1, 100, 0, 32},
52  { 2, 100, 32, 32},
53  { 3, 100, 64, 36}
54 };
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 };
80 
82 const uint16_t NUM_DOWNLINK_CONFS (sizeof (g_frHardDownlinkDefaultConfiguration) / sizeof (FrHardDownlinkDefaultConfiguration));
84 const uint16_t NUM_UPLINK_CONFS (sizeof (g_frHardUplinkDefaultConfiguration) / sizeof (FrHardUplinkDefaultConfiguration));
85 
87  : m_ffrSapUser (0),
88  m_ffrRrcSapUser (0),
89  m_dlOffset (0),
90  m_dlSubBand (0),
91  m_ulOffset (0),
92  m_ulSubBand (0)
93 {
94  NS_LOG_FUNCTION (this);
97 }
98 
99 
101 {
102  NS_LOG_FUNCTION (this);
103 }
104 
105 
106 void
108 {
109  NS_LOG_FUNCTION (this);
110  delete m_ffrSapProvider;
111  delete m_ffrRrcSapProvider;
112 }
113 
114 
115 TypeId
117 {
118  static TypeId tid = TypeId ("ns3::LteFrHardAlgorithm")
120  .SetGroupName("Lte")
121  .AddConstructor<LteFrHardAlgorithm> ()
122  .AddAttribute ("UlSubBandOffset",
123  "Uplink Offset in number of Resource Block Groups",
124  UintegerValue (0),
126  MakeUintegerChecker<uint8_t> ())
127  .AddAttribute ("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 Block Groups",
139  UintegerValue (25),
141  MakeUintegerChecker<uint8_t> ())
142  ;
143  return tid;
144 }
145 
146 
147 void
149 {
150  NS_LOG_FUNCTION (this << s);
151  m_ffrSapUser = s;
152 }
153 
154 
157 {
158  NS_LOG_FUNCTION (this);
159  return m_ffrSapProvider;
160 }
161 
162 void
164 {
165  NS_LOG_FUNCTION (this << s);
166  m_ffrRrcSapUser = s;
167 }
168 
169 
172 {
173  NS_LOG_FUNCTION (this);
174  return m_ffrRrcSapProvider;
175 }
176 
177 
178 void
180 {
181  NS_LOG_FUNCTION (this);
183 
184  NS_ASSERT_MSG (m_dlBandwidth > 14,"DlBandwidth must be at least 15 to use FFR algorithms");
185  NS_ASSERT_MSG (m_ulBandwidth > 14,"UlBandwidth must be at least 15 to use FFR algorithms");
186 
187  if (m_frCellTypeId != 0)
188  {
191  }
192 
193 }
194 
195 void
197 {
198  NS_LOG_FUNCTION (this);
199  if (m_frCellTypeId != 0)
200  {
203  }
206  m_needReconfiguration = false;
207 }
208 
209 void
210 LteFrHardAlgorithm::SetDownlinkConfiguration (uint16_t cellId, uint8_t bandwidth)
211 {
212  NS_LOG_FUNCTION (this);
213  for (uint16_t i = 0; i < NUM_DOWNLINK_CONFS; ++i)
214  {
217  {
220  }
221  }
222 }
223 
224 void
225 LteFrHardAlgorithm::SetUplinkConfiguration (uint16_t cellId, uint8_t bandwidth)
226 {
227  NS_LOG_FUNCTION (this);
228  for (uint16_t i = 0; i < NUM_UPLINK_CONFS; ++i)
229  {
232  {
235  }
236  }
237 }
238 
239 void
241 {
242  m_dlRbgMap.clear ();
243 
244  int rbgSize = GetRbgSize (m_dlBandwidth);
245  m_dlRbgMap.resize (m_dlBandwidth / rbgSize, true);
246 
247  NS_ASSERT_MSG (m_dlOffset <= m_dlBandwidth,"DlOffset higher than DlBandwidth");
248  NS_ASSERT_MSG (m_dlSubBand <= m_dlBandwidth,"DlBandwidth higher than DlBandwidth");
250  "(DlOffset+DlSubBand) higher than DlBandwidth");
251 
252  for (uint8_t i = m_dlOffset / rbgSize; i < (m_dlOffset / rbgSize + m_dlSubBand / rbgSize); i++)
253  {
254  m_dlRbgMap[i] = false;
255 
256  }
257 }
258 
259 void
261 {
262  m_ulRbgMap.clear ();
263 
264  if (!m_enabledInUplink)
265  {
266  m_ulRbgMap.resize (m_ulBandwidth, false);
267  return;
268  }
269 
270  m_ulRbgMap.resize (m_ulBandwidth, true);
271 
272  NS_ASSERT_MSG (m_ulOffset <= m_ulBandwidth,"UlOffset higher than UlBandwidth");
273  NS_ASSERT_MSG (m_ulSubBand <= m_ulBandwidth,"UlBandwidth higher than UlBandwidth");
275  "(UlOffset+UlSubBand) higher than UlBandwidth");
276 
277  for (uint8_t i = m_ulOffset; i < (m_ulOffset + m_ulSubBand); i++)
278  {
279  m_ulRbgMap[i] = false;
280  }
281 }
282 
283 std::vector <bool>
285 {
286  NS_LOG_FUNCTION (this);
287 
289  {
290  Reconfigure ();
291  }
292 
293  if (m_dlRbgMap.empty ())
294  {
296  }
297 
298  return m_dlRbgMap;
299 }
300 
301 bool
303 {
304  NS_LOG_FUNCTION (this);
305  return !m_dlRbgMap[rbId];
306 }
307 
308 std::vector <bool>
310 {
311  NS_LOG_FUNCTION (this);
312 
313  if (m_ulRbgMap.empty ())
314  {
316  }
317 
318  return m_ulRbgMap;
319 }
320 
321 bool
323 {
324  NS_LOG_FUNCTION (this);
325 
326  if (!m_enabledInUplink)
327  {
328  return true;
329  }
330 
331  return !m_ulRbgMap[rbId];
332 }
333 
334 void
336 {
337  NS_LOG_FUNCTION (this);
338  NS_LOG_WARN ("Method should not be called, because it is empty");
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this);
345  NS_LOG_WARN ("Method should not be called, because it is empty");
346 }
347 
348 void
349 LteFrHardAlgorithm::DoReportUlCqiInfo (std::map <uint16_t, std::vector <double> > ulCqiMap)
350 {
351  NS_LOG_FUNCTION (this);
352  NS_LOG_WARN ("Method should not be called, because it is empty");
353 }
354 
355 uint8_t
357 {
358  NS_LOG_FUNCTION (this);
359  return 1; // 1 is mapped to 0 for Accumulated mode, and to -1 in Absolute mode TS36.213 Table 5.1.1.1-2
360 }
361 
362 uint8_t
364 {
365  NS_LOG_FUNCTION (this);
366 
367  if (!m_enabledInUplink)
368  {
369  return m_ulBandwidth;
370  }
371 
372  return m_ulSubBand;
373 }
374 
375 void
377  LteRrcSap::MeasResults measResults)
378 {
379  NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId);
380  NS_LOG_WARN ("Method should not be called, because it is empty");
381 }
382 
383 void
385 {
386  NS_LOG_FUNCTION (this);
387  NS_LOG_WARN ("Method should not be called, because it is empty");
388 }
389 
390 } // 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:138
#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:45
uint8_t m_ulSubBand
UL subband.
virtual void DoDispose()
Destructor implementation.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
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:202
virtual bool DoIsDlRbgAvailableForUe(int i, uint16_t rnti)
Implementation of LteFfrSapProvider::IsDlRbgAvailableForUe.
void InitializeDownlinkRbgMaps()
Initialize downlink rbg maps.
static const struct ns3::FrHardDownlinkDefaultConfiguration g_frHardDownlinkDefaultConfiguration[]
the hard downlink default configuration
uint8_t m_dlSubBand
DL subband.
void SetDownlinkConfiguration(uint16_t cellId, uint8_t bandwidth)
Set downlink configuration.
Template for the implementation of the LteFfrSapProvider as a member of an owner class of type C to w...
Definition: lte-ffr-sap.h:152
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...
MeasResults structure.
Definition: lte-rrc-sap.h:671
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
UL RBG Map.
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
DL RBG Map.
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
LteFfrRrcSapUser * m_ffrRrcSapUser
FFR RRC SAP user.
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.
void InitializeUplinkRbgMaps()
Initialize uplink rbg maps.
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
virtual std::vector< bool > DoGetAvailableUlRbg()
Implementation of LteFfrSapProvider::GetAvailableUlRbg.
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:673
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[]
the hard uplink default configuration
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:262
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:303
uint16_t m_cellId
cell ID
LteFfrRrcSapProvider * m_ffrRrcSapProvider
FFR RRC SAP provider.
virtual bool DoIsUlRbgAvailableForUe(int i, uint16_t rnti)
Implementation of LteFfrSapProvider::IsUlRbgAvailableForUe.
void SetUplinkConfiguration(uint16_t cellId, uint8_t bandwidth)
Set uplink configuration.
const uint16_t NUM_DOWNLINK_CONFS(sizeof(g_ffrEnhancedDownlinkDefaultConfiguration)/sizeof(FfrEnhancedDownlinkDefaultConfiguration))
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
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:915
const uint16_t NUM_UPLINK_CONFS(sizeof(g_ffrEnhancedUplinkDefaultConfiguration)/sizeof(FfrEnhancedUplinkDefaultConfiguration))
static TypeId GetTypeId()
Get the type ID.
virtual void DoReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
DoReportUlCqiInfo.