A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteFfrAlgorithm");
28 
29 namespace ns3 {
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  .AddAttribute ("FrCellTypeId",
58  "Downlink FR cell type ID for automatic configuration,"
59  "default value is 0 and it means that user needs to configure FR algorithm manually,"
60  "if it is set to 1,2 or 3 FR algorithm will be configured automatically",
61  UintegerValue (0),
63  MakeUintegerChecker<uint8_t> ())
64  .AddAttribute ("EnabledInUplink",
65  "If FR algorithm will also work in Uplink, default value true",
66  BooleanValue (true),
67  MakeBooleanAccessor (&LteFfrAlgorithm::m_enabledInUplink),
68  MakeBooleanChecker ())
69  ;
70  return tid;
71 }
72 
73 
74 void
76 {
77  NS_LOG_FUNCTION (this);
78 }
79 
80 uint8_t
82 {
83  NS_LOG_FUNCTION (this);
84  return m_ulBandwidth;
85 }
86 
87 void
89 {
90  NS_LOG_FUNCTION (this << uint16_t (bw));
91  switch (bw)
92  {
93  case 6:
94  case 15:
95  case 25:
96  case 50:
97  case 75:
98  case 100:
99  m_ulBandwidth = bw;
100  break;
101 
102  default:
103  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
104  break;
105  }
106 }
107 
108 uint8_t
110 {
111  NS_LOG_FUNCTION (this);
112  return m_dlBandwidth;
113 }
114 
115 void
117 {
118  NS_LOG_FUNCTION (this << uint16_t (bw));
119  switch (bw)
120  {
121  case 6:
122  case 15:
123  case 25:
124  case 50:
125  case 75:
126  case 100:
127  m_dlBandwidth = bw;
128  break;
129 
130  default:
131  NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) bw);
132  break;
133  }
134 }
135 
136 void
138 {
139  NS_LOG_FUNCTION (this << uint16_t (cellTypeId));
140  m_frCellTypeId = cellTypeId;
141  m_needReconfiguration = true;
142 }
143 
144 uint8_t
146 {
147  NS_LOG_FUNCTION (this);
148  return m_frCellTypeId;
149 }
150 
151 int
153 {
154  for (int i = 0; i < 4; i++)
155  {
156  if (dlbandwidth < Type0AllocationRbg[i])
157  {
158  return (i + 1);
159  }
160  }
161 
162  return (-1);
163 }
164 
165 void
167 {
168  NS_LOG_FUNCTION (this);
169  m_cellId = cellId;
170 }
171 
172 void
173 LteFfrAlgorithm::DoSetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth)
174 {
175  NS_LOG_FUNCTION (this);
176  SetDlBandwidth (dlBandwidth);
177  SetUlBandwidth (ulBandwidth);
178 }
179 
180 } // 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 "...
Hold a bool native type.
Definition: boolean.h:38
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
uint8_t GetUlBandwidth() const
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
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:46
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)
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:64
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610