1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
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  * Original Author: Giuseppe Piro  <g.piro@poliba.it>
19  * Modified by:     Nicola Baldo   <nbaldo@cttc.es>
20  * Modified by:     Marco Miozzo   <mmiozzo@cttc.es>
21  */
22 
23 #ifndef AMCMODULE_H
24 #define AMCMODULE_H
25 
26 #include <vector>
27 #include <ns3/ptr.h>
28 #include <ns3/object.h>
29 
30 namespace ns3 {
31 
32 class SpectrumValue;
33 
34 /**
35  * \ingroup lte
36  * Implements the Adaptive Modulation And Coding Scheme. As proposed in 3GPP
37  * TSG-RAN WG1 [R1-081483 Conveying MCS and TB size via PDCCH]
38  * (http://www.3gpp.org/ftp/tsg_ran/WG1_RL1/TSGR1_52b/Docs/R1-081483.zip).
39  */
40 class LteAmc : public Object
41 {
42 
43 public:
44   /**
45    * \brief Get the type ID.
46    * \return the object TypeId
47    */
48   static TypeId GetTypeId (void);
49 
50   LteAmc ();
51   virtual ~LteAmc();
52 
53   /// Types of AMC model.
54   enum AmcModel
55     {
56       /**
57        * \details
58        * An AMC model based on Piro, G.; Grieco, L.A; Boggia, G.; Camarda, P.,
59        * "A two-level scheduling algorithm for QoS support in the downlink of
60        * LTE cellular networks," _Wireless Conference (EW), 2010 European_,
61        * pp.246,253, 12-15 April 2010.
62        */
63       PiroEW2010,
64       /**
65        * An AMC model based on 10% of BER according to LteMiErrorModel.
66        */
67       MiErrorModel
68     };
69 
70   /**
71    * \brief Get the Modulation and Coding Scheme for
72    * a CQI value
73    * \param cqi the cqi value
74    * \return the MCS value
75    */
76   int GetMcsFromCqi (int cqi);
77 
78   /**
79   * \brief Get the Transport Block Size for a selected MCS and number of PRB (table 7.1.7.2.1-1 of 36.213)
80   * \param mcs the MCS index
81   * \param nprb the no. of PRB
82   * \return the Transport Block Size in bits
83   */
84   int GetDlTbSizeFromMcs (int mcs, int nprb);
85 
86   /**
87    * \brief Get the Transport Block Size for a selected MCS and number of PRB (table 8.6.1-1 of 36.213)
88    * \param mcs the MCS index
89    * \param nprb the no. of PRB
90    * \return the Transport Block Size in bits
91    */
92   int GetUlTbSizeFromMcs (int mcs, int nprb);
93 
94   /**
95    * \brief Get the spectral efficiency value associated
96    * to the received CQI
97    * \param cqi the cqi value
98    * \return the spectral efficiency in (bit/s)/Hz
99    */
100   double GetSpectralEfficiencyFromCqi (int cqi);
101 
102   /**
103    * \brief Create a message with CQI feedback
104    * \param sinr the SpectrumValue vector of SINR for evaluating the CQI
105    * \param rbgSize size of RB group (in RBs) for evaluating subband/wideband CQI
106    * \return a vector of CQI feedbacks
107    */
108   std::vector<int> CreateCqiFeedbacks (const SpectrumValue& sinr,
109                                                   uint8_t rbgSize = 0);
110 
111   /**
112    * \brief Get a proper CQI for the spectral efficiency value.
113    * In order to assure a lower block error rate, the AMC chooses the lower CQI value
114    * for a given spectral efficiency
115    * \param s the spectral efficiency
116    * \return the CQI value
117    */
118   int GetCqiFromSpectralEfficiency (double s);
119 
120 private:
121 
122   /**
123    * The `Ber` attribute.
124    *
125    * The requested BER in assigning MCS (default is 0.00005).
126    */
127   double m_ber;
128 
129   /**
130    * The `AmcModel` attribute.
131    *
132    * AMC model used to assign CQI.
133    */
134   AmcModel m_amcModel;
135 
136 }; // end of `class LteAmc`
137 
138 
139 }
140 
141 #endif /* AMCMODULE_H */
142