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 #ifndef LTE_FFR_ALGORITHM_H
23 #define LTE_FFR_ALGORITHM_H
24 
25 #include <ns3/object.h>
26 #include <ns3/lte-rrc-sap.h>
27 #include <ns3/epc-x2-sap.h>
28 #include <ns3/ff-mac-sched-sap.h>
29 #include <map>
30 
31 namespace ns3 {
32 
33 class LteFfrSapUser;
34 class LteFfrSapProvider;
35 
36 class LteFfrRrcSapUser;
37 class LteFfrRrcSapProvider;
38 
39 /**
40  * \brief The abstract base class of a Frequency Reuse algorithm
41  *
42  * Generally Frequency reuse algorithm tells the Scheduler which RB can be allocated
43  * and which can not. FR policy depend on its implementation.
44  *
45  * The communication with the eNodeB MAC Scheduler instance is done through
46  * the *LteFfrSap* interface. The frequency reuse algorithm instance corresponds to the
47  * "provider" part of this interface, while the eNodeB MAC Scheduler instance takes the
48  * role of the "user" part.
49  *
50  * The communication with the eNodeB RRC instance is done through the *LteFfrRrcSap*
51  * interface. The frequency reuse algorithm instance corresponds to the
52  * "provider" part of this interface, while the eNodeB RRC instance takes the
53  * role of the "user" part.
54  *
55  */
56 
57 class LteFfrAlgorithm : public Object
58 {
59 public:
60   LteFfrAlgorithm ();
61   virtual ~LteFfrAlgorithm ();
62 
63   /**
64    * \brief Get the type ID.
65    * \return the object TypeId
66    */
67   static TypeId GetTypeId ();
68 
69   /**
70    * \brief Set the "user" part of the LteFfrSap interface that
71    *        this frequency reuse algorithm instance will interact with.
72    * \param s a reference to the "user" part of the interface, typically a
73    *          member of an Scheduler instance
74    */
75   virtual void SetLteFfrSapUser (LteFfrSapUser* s) = 0;
76 
77   /**
78    * \brief Set the "user" part of the LteFfrRrcSap interface that
79    *        this frequency reuse algorithm instance will interact with.
80    * \param s a reference to the "user" part of the interface, typically a
81    *          member of an LteEnbRrc instance
82    */
83   virtual void SetLteFfrRrcSapUser (LteFfrRrcSapUser* s) = 0;
84 
85   /**
86    * \brief Export the "provider" part of the LteFfrSap interface.
87    * \return the reference to the "provider" part of the interface, typically to
88    *         be kept by an Scheduler instance
89    */
90   virtual LteFfrSapProvider* GetLteFfrSapProvider () = 0;
91 
92   /**
93    * \brief Export the "provider" part of the LteFfrRrcSap interface.
94    * \return the reference to the "provider" part of the interface, typically to
95    *         be kept by an LteEnbRrc instance
96    */
97   virtual LteFfrRrcSapProvider* GetLteFfrRrcSapProvider () = 0;
98 
99   /**
100    * \return the uplink bandwidth in RBs
101    */
102   uint16_t GetUlBandwidth () const;
103 
104   /**
105    * \param bw the uplink bandwidth in RBs
106    */
107   void SetUlBandwidth (uint16_t bw);
108 
109   /**
110    * \return the downlink bandwidth in RBs
111    */
112   uint16_t GetDlBandwidth () const;
113 
114   /**
115    * \param bw the downlink bandwidth in RBs
116    */
117   void SetDlBandwidth (uint16_t bw);
118 
119   /**
120    * \param cellTypeId for automatic FR configuration
121    */
122   void SetFrCellTypeId (uint8_t cellTypeId);
123 
124   /**
125    * \return cellTypeId which is used for automatic FR configuration
126    */
127   uint8_t GetFrCellTypeId () const;
128 
129 protected:
130 
131   // inherited from Object
132   virtual void DoDispose ();
133 
134   /**
135    * \brief Automatic FR reconfiguration
136    */
137   virtual void Reconfigure () = 0;
138 
139   // FFR SAP PROVIDER IMPLEMENTATION
140 
141   /**
142    * \brief Implementation of LteFfrSapProvider::GetAvailableDlRbg
143    * \return vector of size (m_dlBandwidth/RbgSize); false indicates
144    *                    that RBG is free to use, true otherwise
145    */
146   virtual std::vector <bool> DoGetAvailableDlRbg () = 0;
147 
148   /**
149    * \brief Implementation of LteFfrSapProvider::IsDlRbgAvailableForUe
150    * \param rbId
151    * \param rnti Radio Network Temporary Identity, an integer identifying the UE
152    *             where the report originates from
153    * \return true if UE can be served on i-th RB, false otherwise
154    */
155   virtual bool DoIsDlRbgAvailableForUe (int rbId, uint16_t rnti) = 0;
156 
157   /**
158    * \brief Implementation of LteFfrSapProvider::GetAvailableUlRbg.
159    * \return vector of size m_ulBandwidth; false indicates
160    *                    that RB is free to use, true otherwise
161    */
162   virtual std::vector <bool> DoGetAvailableUlRbg () = 0;
163 
164   /**
165    * \brief Implementation of LteFfrSapProvider::IsUlRbgAvailableForUe.
166    * \param rbId
167    * \param rnti Radio Network Temporary Identity, an integer identifying the UE
168    *             where the report originates from
169    * \return true if UE can be served on i-th RB, false otherwise
170    */
171   virtual bool DoIsUlRbgAvailableForUe (int rbId, uint16_t rnti) = 0;
172 
173   /**
174    * \brief DoReportDlCqiInfo
175    * \param params
176    *
177    */
178   virtual void DoReportDlCqiInfo (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params) = 0;
179 
180   /**
181    * \brief DoReportUlCqiInfo
182    * \param params
183    *
184    */
185   virtual void DoReportUlCqiInfo (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) = 0;
186 
187   /**
188    * \brief DoReportUlCqiInfo
189    * \param ulCqiMap
190    *
191    */
192   virtual void DoReportUlCqiInfo ( std::map <uint16_t, std::vector <double> > ulCqiMap ) = 0;
193 
194   /**
195    * \brief DoGetTpc for UE
196    * \param rnti
197    * \return TPC value
198    */
199   virtual uint8_t DoGetTpc (uint16_t rnti) = 0;
200 
201   /**
202    * \brief DoGetMinContinuousUlBandwidth in number of RB
203    * \return number of RB in min continuous UL Bandwidth
204    */
205   virtual uint16_t DoGetMinContinuousUlBandwidth () = 0;
206 
207   // FFR SAP RRC PROVIDER IMPLEMENTATION
208 
209   /**
210    * \brief SetCellId
211    * \param cellId the Cell Identifier
212    */
213   virtual void DoSetCellId (uint16_t cellId);
214 
215   /**
216    * \brief Implementation of LteFfrRrcSapProvider::SetBandwidth.
217    * \param ulBandwidth UL bandwidth in number of RB
218    * \param dlBandwidth DL bandwidth in number of RB
219    */
220   virtual void DoSetBandwidth (uint16_t ulBandwidth, uint16_t dlBandwidth);
221 
222   /**
223    * \brief Implementation of LteFfrRrcSapProvider::ReportUeMeas.
224    * \param rnti Radio Network Temporary Identity, an integer identifying the UE
225    *             where the report originates from
226    * \param measResults a single report of one measurement identity
227    */
228   virtual void DoReportUeMeas (uint16_t rnti, LteRrcSap::MeasResults measResults) = 0;
229 
230   /**
231    * \brief DoRecvLoadInformation
232    * \param params
233    *
234    */
235   virtual void DoRecvLoadInformation (EpcX2Sap::LoadInformationParams params) = 0;
236 
237   /**
238   * \brief Get RBG size for DL Bandwidth according to table 7.1.6.1-1 of 36.213
239   * \param dlbandwidth
240   * \return size of RBG in number of RB
241   */
242   int GetRbgSize (int dlbandwidth);
243 
244 
245   uint16_t m_cellId; /**< cell ID */
246 
247   uint8_t m_dlBandwidth; /**< downlink bandwidth in RBs */
248   uint8_t m_ulBandwidth; /**< uplink bandwidth in RBs */
249 
250   uint8_t m_frCellTypeId; /**< FFR cell type ID for automatic configuration */
251 
252   bool m_enabledInUplink; /**< If true FR algorithm will also work in Uplink*/
253 
254   bool m_needReconfiguration; /**< If true FR algorithm will be reconfigured*/
255 
256 }; // end of class LteFfrAlgorithm
257 
258 
259 } // end of namespace ns3
260 
261 
262 #endif /* LTE_FFR_ALGORITHM_H */
263