A Discrete-Event Network Simulator
API
lte-ffr-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-ffr-algorithm.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/boolean.h"
25 #include <ns3/log.h>
26 
27 namespace ns3 {
28 
29 NS_LOG_COMPONENT_DEFINE ("LteFfrAlgorithm");
30 
31 static const int Type0AllocationRbg[4] = {
32  10, // RGB size 1
33  26, // RGB size 2
34  63, // RGB size 3
35  110 // RGB size 4
36 }; // see table 7.1.6.1-1 of 3GPP TS 36.213
37 
38 NS_OBJECT_ENSURE_REGISTERED (LteFfrAlgorithm);
39 
40 
42  m_needReconfiguration (true)
43 {
44 }
45 
46 
48 {
49 }
50 
51 
52 TypeId
54 {
55  static TypeId tid = 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 algorithm manually,"
61  "if it is set to 1,2 or 3 FR algorithm will be configured automatically",
62  UintegerValue (0),
64  MakeUintegerChecker<uint8_t> ())
65  .AddAttribute ("EnabledInUplink",
66  "If FR algorithm will also work in Uplink, default value true",
67  BooleanValue (true),
70  ;
71  return tid;
72 }
73 
74 
75 void
77 {
78  NS_LOG_FUNCTION (this);
79 }
80 
81 uint8_t
83 {
84  NS_LOG_FUNCTION (this);
85  return m_ulBandwidth;
86 }
87 
88 void
90 {
91  NS_LOG_FUNCTION (this << uint16_t (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 " << (uint16_t) bw);
105  break;
106  }
107 }
108 
109 uint8_t
111 {
112  NS_LOG_FUNCTION (this);
113  return m_dlBandwidth;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION (this << uint16_t (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 " << (uint16_t) 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 (uint8_t ulBandwidth, uint8_t dlBandwidth)
175 {
176  NS_LOG_FUNCTION (this);
177  SetDlBandwidth (dlBandwidth);
178  SetUlBandwidth (ulBandwidth);
179 }
180 
181 } // end of namespace ns3
uint8_t GetFrCellTypeId() const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
Definition: boolean.h:34
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual void DoDispose()
Destructor implementation.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:81
uint8_t m_ulBandwidth
uplink bandwidth in RBs
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint8_t GetUlBandwidth() const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual void DoSetCellId(uint16_t cellId)
SetCellId.
virtual void DoSetBandwidth(uint8_t ulBandwidth, uint8_t dlBandwidth)
Implementation of LteFfrRrcSapProvider::SetBandwidth.
static const int Type0AllocationRbg[4]
Hold an unsigned integer type.
Definition: uinteger.h:44
bool m_enabledInUplink
If true FR algorithm will also work in Uplink.
bool m_needReconfiguration
If true FR algorithm will be reconfigured.
uint8_t m_dlBandwidth
downlink bandwidth in RBs
void SetFrCellTypeId(uint8_t cellTypeId)
static TypeId GetTypeId()
uint8_t GetDlBandwidth() const
void SetDlBandwidth(uint8_t bw)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint8_t m_frCellTypeId
FFR cell type ID for automatic configuration.
void SetUlBandwidth(uint8_t bw)
int GetRbgSize(int dlbandwidth)
Get RBG size for DL Bandwidth according to table 7.1.6.1-1 of 36.213.
A base class which provides memory management and object aggregation.
Definition: object.h:87
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