1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
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;
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.
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
18
* Author: Giuseppe Piro <g.piro@poliba.it>
22
#include "amc-module.h"
26
NS_LOG_COMPONENT_DEFINE ("AmcModule");
31
NS_OBJECT_ENSURE_REGISTERED (AmcModule);
36
1, 2, 3, 4, 5, 6, // QAM
38
10, 11, 12, 13, 14, 15 // 16QAM
42
double SpectralEfficiencyForCqiIndex[15] = {
43
0.15, 0.23, 0.38, 0.6, 0.88, 1.18,
45
2.73, 3.32, 3.9, 4.52, 5.12, 5.55
50
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, // QAM
51
12, 13, 14, 15, 16, 17, 18, // 4-QAM
52
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, // 16-QAM
57
int ModulationSchemeForMcsIndex[32] = {
59
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
61
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
66
double SpectralEfficiencyForMcsIndex[32] = {
68
0.15, 0.19, 0.23, 0.31, 0.38, 0.49, 0.6, 0.74, 0.88, 1.03, 1.18,
69
1.33, 1.48, 1.7, 1.91, 2.16, 2.41, 2.57,
70
2.73, 3.03, 3.32, 3.61, 3.9, 4.21, 4.52, 4.82, 5.12, 5.33, 5.55,
75
int TransportBlockSize[32] = {
77
18, 23, 28, 37, 45, 59, 72, 89, 105, 123, 141,
78
159, 177, 203, 230, 259, 289, 288,
79
308, 328, 363, 399, 433, 468, 506, 543, 578, 614, 640,
85
AmcModule::AmcModule ()
92
AmcModule::GetTypeId (void)
94
static TypeId tid = TypeId ("ns3::AmcModule")
96
.AddConstructor<AmcModule> ()
102
AmcModule::~AmcModule ()
108
AmcModule::Initialize ()
110
NS_LOG_FUNCTION (this);
115
AmcModule::GetCqiFromSpectralEfficiency (double s)
117
NS_LOG_FUNCTION (this << s);
118
int cqi = 1; // == CqiIndex[0]
119
while (SpectralEfficiencyForCqiIndex[cqi] < s && cqi <= 14)
123
NS_LOG_FUNCTION (this << s << cqi);
129
AmcModule::GetMcsFromCqi (int cqi)
131
NS_LOG_FUNCTION (this << cqi);
132
double spectralEfficiency = SpectralEfficiencyForCqiIndex[cqi - 1];
134
while (SpectralEfficiencyForMcsIndex[mcs] < spectralEfficiency && mcs < 30)
138
NS_LOG_FUNCTION (this << cqi << mcs);
144
AmcModule::GetTbSizeFromMcs (int mcs)
146
NS_LOG_FUNCTION (this << mcs);
147
NS_LOG_FUNCTION (this << mcs << TransportBlockSize[mcs]);
148
return TransportBlockSize[mcs];
153
AmcModule::GetSpectralEfficiencyFromCqi (int cqi)
155
NS_LOG_FUNCTION (this << cqi);
156
NS_LOG_FUNCTION (this << cqi << SpectralEfficiencyForCqiIndex[cqi - 1]);
157
return SpectralEfficiencyForCqiIndex[cqi - 1];
162
AmcModule::CreateCqiFeedbacks (std::vector<double> sinr)
164
NS_LOG_FUNCTION (this);
166
std::vector<int> cqi;
167
std::vector<double>::iterator it;
169
for (it = sinr.begin (); it != sinr.end (); it++)
171
double sinr_ = (*it);
174
* Compute the spectral efficiency from the SINR
176
* spectralEfficiency = log2 (1 + -------------------- )
178
* NB: SINR must be expressed in natural unit:
179
* (SINR)dB => 10 ^ (SINR/10)
182
double s = log2 ( 1 + (
183
pow (10, sinr_ / 10 ) /
184
( (-log (5.0 * 0.00005 )) / 1.5) ));
186
int cqi_ = GetCqiFromSpectralEfficiency (s);
188
NS_LOG_FUNCTION (this << "channel_id = " << cqi.size ()
189
<< "sinr = " << sinr_
190
<< "spectral efficiency =" << s
191
<< " ---- CQI = " << cqi_ );
193
cqi.push_back (cqi_);