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 
32 static const int Type0AllocationRbg[4] = {
33  10, // RGB size 1
34  26, // RGB size 2
35  63, // RGB size 3
36  110 // RGB size 4
37 }; // see table 7.1.6.1-1 of 3GPP TS 36.213
38 
39 NS_OBJECT_ENSURE_REGISTERED (LteFfrAlgorithm);
40 
41 
43  m_needReconfiguration (true)
44 {
45 }
46 
47 
49 {
50 }
51 
52 
53 TypeId
55 {
56  static TypeId tid = TypeId ("ns3::LteFfrAlgorithm")
57  .SetParent<Object> ()
58  .SetGroupName("Lte")
59  .AddAttribute ("FrCellTypeId",
60  "Downlink FR cell type ID for automatic configuration,"
61  "default value is 0 and it means that user needs to configure FR algorithm manually,"
62  "if it is set to 1,2 or 3 FR algorithm will be configured automatically",
63  UintegerValue (0),
65  MakeUintegerChecker<uint8_t> ())
66  .AddAttribute ("EnabledInUplink",
67  "If FR algorithm will also work in Uplink, default value true",
68  BooleanValue (true),
71  ;
72  return tid;
73 }
74 
75 
76 void
78 {
79  NS_LOG_FUNCTION (this);
80 }
81 
82 uint16_t
84 {
85  NS_LOG_FUNCTION (this);
86  return m_ulBandwidth;
87 }
88 
89 void
91 {
92  NS_LOG_FUNCTION (this << bw);
93  switch (bw)
94  {
95  case 6:
96  case 15:
97  case 25:
98  case 50:
99  case 75:
100  case 100:
101  m_ulBandwidth = bw;
102  break;
103 
104  default:
105  NS_FATAL_ERROR ("invalid bandwidth value " << bw);
106  break;
107  }
108 }
109 
110 uint16_t
112 {
113  NS_LOG_FUNCTION (this);
114  return m_dlBandwidth;
115 }
116 
117 void
119 {
120  NS_LOG_FUNCTION (this << bw);
121  switch (bw)
122  {
123  case 6:
124  case 15:
125  case 25:
126  case 50:
127  case 75:
128  case 100:
129  m_dlBandwidth = bw;
130  break;
131 
132  default:
133  NS_FATAL_ERROR ("invalid bandwidth value " << bw);
134  break;
135  }
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION (this << uint16_t (cellTypeId));
142  m_frCellTypeId = cellTypeId;
143  m_needReconfiguration = true;
144 }
145 
146 uint8_t
148 {
149  NS_LOG_FUNCTION (this);
150  return m_frCellTypeId;
151 }
152 
153 int
155 {
156  for (int i = 0; i < 4; i++)
157  {
158  if (dlbandwidth < Type0AllocationRbg[i])
159  {
160  return (i + 1);
161  }
162  }
163 
164  return (-1);
165 }
166 
167 void
169 {
170  NS_LOG_FUNCTION (this);
171  m_cellId = cellId;
172 }
173 
174 void
175 LteFfrAlgorithm::DoSetBandwidth (uint16_t ulBandwidth, uint16_t dlBandwidth)
176 {
177  NS_LOG_FUNCTION (this);
178  SetDlBandwidth (dlBandwidth);
179  SetUlBandwidth (ulBandwidth);
180 }
181 
182 } // end of namespace ns3
#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:36
uint16_t GetDlBandwidth() const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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:85
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:205
void SetDlBandwidth(uint16_t bw)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual void DoSetBandwidth(uint16_t ulBandwidth, uint16_t dlBandwidth)
Implementation of LteFfrRrcSapProvider::SetBandwidth.
virtual void DoSetCellId(uint16_t cellId)
SetCellId.
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.
uint16_t GetUlBandwidth() const
uint8_t GetFrCellTypeId() const
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()
Get the type ID.
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.
int GetRbgSize(int dlbandwidth)
Get RBG size for DL Bandwidth according to table 7.1.6.1-1 of 36.213.
uint16_t m_cellId
cell ID
A base class which provides memory management and object aggregation.
Definition: object.h:87
void SetUlBandwidth(uint16_t bw)
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:923