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_SIMPLE_H
23 #define LTE_FFR_SIMPLE_H
24 
25 #include <ns3/lte-ffr-algorithm.h>
26 #include <ns3/lte-ffr-sap.h>
27 #include <ns3/lte-ffr-rrc-sap.h>
28 #include <ns3/lte-rrc-sap.h>
29 
30 #include <ns3/traced-callback.h>
31 #include <map>
32 
33 namespace ns3 {
34 
35 
36 /**
37  * \ingroup lte-test
38  * \ingroup tests
39  *
40  * \brief Simple Frequency Reuse algorithm implementation which uses only 1 sub-band.
41  *                Used to test Downlink Power Allocation. When Simple FR receives UE measurements
42  *                it immediately call functions to change PdschConfigDedicated (i.e. P_A) value for
43  *                this UE.
44  */
45 class LteFfrSimple : public LteFfrAlgorithm
46 {
47 public:
48   /**
49    * \brief Creates a trivial ffr algorithm instance.
50    */
51   LteFfrSimple ();
52 
53   virtual ~LteFfrSimple ();
54 
55   /**
56    * \brief Get the type ID.
57    * \return the object TypeId
58    */
59   static TypeId GetTypeId ();
60 
61   /**
62    * \brief Callback function that is used to be connected to trace ChangePdschConfigDedicated
63    * \param change trace fired upon change of PdschConfigDedicated if true
64    */
65   void ChangePdschConfigDedicated (bool change);
66   /**
67    * \brief Set PDSCH config dedicated function
68    * \param pdschConfigDedicated LteRrcSap::PdschConfigDedicated object
69    */
70   void SetPdschConfigDedicated (LteRrcSap::PdschConfigDedicated pdschConfigDedicated);
71 
72   /**
73    * \brief Set transmission power control
74    * \param tpc TPC
75    * \param num number of TPC configurations in the test case
76    * \param acculumatedMode whether TPC accumulated mode is used
77    */
78   void SetTpc (uint32_t tpc, uint32_t num, bool acculumatedMode);
79 
80   // inherited from LteFfrAlgorithm
81   virtual void SetLteFfrSapUser (LteFfrSapUser* s);
82   virtual LteFfrSapProvider* GetLteFfrSapProvider ();
83 
84   virtual void SetLteFfrRrcSapUser (LteFfrRrcSapUser* s);
85   virtual LteFfrRrcSapProvider* GetLteFfrRrcSapProvider ();
86 
87   /// let the forwarder class access the protected and private members
88   friend class MemberLteFfrSapProvider<LteFfrSimple>;
89   /// let the forwarder class access the protected and private members
90   friend class MemberLteFfrRrcSapProvider<LteFfrSimple>;
91 
92   /**
93    * TracedCallback signature for change of PdschConfigDedicated.
94    *
95    * \param [in] rnti
96    * \param [in] pdschPa PdschConfiDedicated.pa
97    */
98   typedef void (* PdschTracedCallback)(uint16_t rnti, uint8_t pdschPa);
99 
100 protected:
101   // inherited from Object
102   virtual void DoInitialize ();
103   virtual void DoDispose ();
104 
105   virtual void Reconfigure ();
106 
107   // FFR SAP PROVIDER IMPLEMENTATION
108   virtual std::vector <bool> DoGetAvailableDlRbg ();
109   virtual bool DoIsDlRbgAvailableForUe (int i, uint16_t rnti);
110   virtual std::vector <bool> DoGetAvailableUlRbg ();
111   virtual bool DoIsUlRbgAvailableForUe (int i, uint16_t rnti);
112   virtual void DoReportDlCqiInfo (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params);
113   virtual void DoReportUlCqiInfo (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params);
114   virtual void DoReportUlCqiInfo ( std::map <uint16_t, std::vector <double> > ulCqiMap );
115   virtual uint8_t DoGetTpc (uint16_t rnti);
116   virtual uint16_t DoGetMinContinuousUlBandwidth ();
117 
118   // FFR SAP RRC PROVIDER IMPLEMENTATION
119   virtual void DoReportUeMeas (uint16_t rnti, LteRrcSap::MeasResults measResults);
120   virtual void DoRecvLoadInformation (EpcX2Sap::LoadInformationParams params);
121 
122 private:
123 
124   /// Update PDSCH config dedicated function
125   void UpdatePdschConfigDedicated ();
126 
127   // FFR SAP
128   LteFfrSapUser* m_ffrSapUser; ///< FFR SAP user
129   LteFfrSapProvider* m_ffrSapProvider; ///< FFR SAP provider
130 
131   // FFR RRF SAP
132   LteFfrRrcSapUser* m_ffrRrcSapUser; ///< FFR RRC SAP user
133   LteFfrRrcSapProvider* m_ffrRrcSapProvider; ///< FFR RRC SAP provider
134 
135   uint8_t m_dlOffset; ///< DL offset
136   uint8_t m_dlSubBand; ///< DL subband
137 
138   uint8_t m_ulOffset; ///< UL offset
139   uint8_t m_ulSubBand; ///< UL subband
140 
141   std::vector <bool> m_dlRbgMap; ///< DL RBG map
142   std::vector <bool> m_ulRbgMap; ///< UL RBG map
143 
144   std::map <uint16_t, LteRrcSap::PdschConfigDedicated> m_ues; ///< UEs
145 
146   // The expected measurement identity
147   uint8_t m_measId; ///< measure ID
148 
149   bool m_changePdschConfigDedicated; ///< PDSCH config dedicate changed?
150 
151   LteRrcSap::PdschConfigDedicated m_pdschConfigDedicated; ///< PDSCH config dedicated
152 
153   TracedCallback<uint16_t, uint8_t> m_changePdschConfigDedicatedTrace; ///< PDSCH config dedicated change trace callback
154 
155 
156   // Uplink Power Control
157   uint32_t m_tpc; ///< transmission power control to be used
158   uint32_t m_tpcNum; ///< number of TPC configurations
159   bool m_accumulatedMode; ///< whether to use the TPC accumulated mode
160 
161 }; // end of class LteFfrSimple
162 
163 
164 } // end of namespace ns3
165 
166 
167 #endif /* LTE_FFR_SIMPLE_H */
168