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
27namespace ns3 {
28
29NS_LOG_COMPONENT_DEFINE ("LteFfrAlgorithm");
30
32static 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
39NS_OBJECT_ENSURE_REGISTERED (LteFfrAlgorithm);
40
41
43 m_needReconfiguration (true)
44{
45}
46
47
49{
50}
51
52
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
76void
78{
79 NS_LOG_FUNCTION (this);
80}
81
82uint16_t
84{
85 NS_LOG_FUNCTION (this);
86 return m_ulBandwidth;
87}
88
89void
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
110uint16_t
112{
113 NS_LOG_FUNCTION (this);
114 return m_dlBandwidth;
115}
116
117void
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
138void
140{
141 NS_LOG_FUNCTION (this << uint16_t (cellTypeId));
142 m_frCellTypeId = cellTypeId;
144}
145
146uint8_t
148{
149 NS_LOG_FUNCTION (this);
150 return m_frCellTypeId;
151}
152
153int
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
167void
169{
170 NS_LOG_FUNCTION (this);
171 m_cellId = cellId;
172}
173
174void
175LteFfrAlgorithm::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
AttributeValue implementation for Boolean.
Definition: boolean.h:37
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.
virtual void DoDispose()
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:88
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.