A Discrete-Event Network Simulator
API
lte-ffr-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 
21 #include "lte-ffr-algorithm.h"
22 
23 #include "ns3/boolean.h"
24 #include "ns3/uinteger.h"
25 #include <ns3/log.h>
26 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("LteFfrAlgorithm");
31 
33 static const int Type0AllocationRbg[4] = {
34  10, // RGB size 1
35  26, // RGB size 2
36  63, // RGB size 3
37  110, // RGB size 4
38 }; // see table 7.1.6.1-1 of 3GPP TS 36.213
39 
40 NS_OBJECT_ENSURE_REGISTERED(LteFfrAlgorithm);
41 
43  : m_needReconfiguration(true)
44 {
45 }
46 
48 {
49 }
50 
51 TypeId
53 {
54  static TypeId tid =
55  TypeId("ns3::LteFfrAlgorithm")
56  .SetParent<Object>()
57  .SetGroupName("Lte")
58  .AddAttribute("FrCellTypeId",
59  "Downlink FR cell type ID for automatic configuration,"
60  "default value is 0 and it means that user needs to configure FR "
61  "algorithm manually,"
62  "if it is set to 1,2 or 3 FR algorithm will be configured automatically",
63  UintegerValue(0),
66  MakeUintegerChecker<uint8_t>())
67  .AddAttribute("EnabledInUplink",
68  "If FR algorithm will also work in Uplink, default value true",
69  BooleanValue(true),
72  return tid;
73 }
74 
75 void
77 {
78  NS_LOG_FUNCTION(this);
79 }
80 
81 uint16_t
83 {
84  NS_LOG_FUNCTION(this);
85  return m_ulBandwidth;
86 }
87 
88 void
90 {
91  NS_LOG_FUNCTION(this << bw);
92  switch (bw)
93  {
94  case 6:
95  case 15:
96  case 25:
97  case 50:
98  case 75:
99  case 100:
100  m_ulBandwidth = bw;
101  break;
102 
103  default:
104  NS_FATAL_ERROR("invalid bandwidth value " << bw);
105  break;
106  }
107 }
108 
109 uint16_t
111 {
112  NS_LOG_FUNCTION(this);
113  return m_dlBandwidth;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION(this << bw);
120  switch (bw)
121  {
122  case 6:
123  case 15:
124  case 25:
125  case 50:
126  case 75:
127  case 100:
128  m_dlBandwidth = bw;
129  break;
130 
131  default:
132  NS_FATAL_ERROR("invalid bandwidth value " << bw);
133  break;
134  }
135 }
136 
137 void
139 {
140  NS_LOG_FUNCTION(this << uint16_t(cellTypeId));
141  m_frCellTypeId = cellTypeId;
142  m_needReconfiguration = true;
143 }
144 
145 uint8_t
147 {
148  NS_LOG_FUNCTION(this);
149  return m_frCellTypeId;
150 }
151 
152 int
154 {
155  for (int i = 0; i < 4; i++)
156  {
157  if (dlbandwidth < Type0AllocationRbg[i])
158  {
159  return i + 1;
160  }
161  }
162 
163  return -1;
164 }
165 
166 void
168 {
169  NS_LOG_FUNCTION(this);
170  m_cellId = cellId;
171 }
172 
173 void
174 LteFfrAlgorithm::DoSetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth)
175 {
176  NS_LOG_FUNCTION(this);
177  SetDlBandwidth(dlBandwidth);
178  SetUlBandwidth(ulBandwidth);
179 }
180 
181 } // end of namespace ns3
uint16_t m_cellId
cell ID
static TypeId GetTypeId()
Get the type ID.
bool m_needReconfiguration
If true FR algorithm will be reconfigured.
void SetFrCellTypeId(uint8_t cellTypeId)
uint8_t GetFrCellTypeId() const
uint8_t m_frCellTypeId
FFR cell type ID for automatic configuration.
void DoDispose() override
Destructor implementation.
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.
virtual void DoSetCellId(uint16_t cellId)
SetCellId.
uint8_t m_dlBandwidth
downlink bandwidth in RBs
uint16_t GetUlBandwidth() const
void SetDlBandwidth(uint16_t bw)
uint8_t m_ulBandwidth
uplink bandwidth in RBs
virtual void DoSetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth)
Implementation of LteFfrRrcSapProvider::SetBandwidth.
void SetUlBandwidth(uint16_t bw)
uint16_t GetDlBandwidth() const
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.