A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tdtbfq-ff-mac-scheduler.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Marco Miozzo <marco.miozzo@cttc.es>
19  * Modification: Dizhi Zhou <dizhi.zhou@gmail.com> // modify codes related to downlink scheduler
20  */
21 
22 #ifndef TDTBFQ_FF_MAC_SCHEDULER_H
23 #define TDTBFQ_FF_MAC_SCHEDULER_H
24 
25 #include <ns3/lte-common.h>
26 #include <ns3/ff-mac-csched-sap.h>
27 #include <ns3/ff-mac-sched-sap.h>
28 #include <ns3/ff-mac-scheduler.h>
29 #include <vector>
30 #include <map>
31 #include <ns3/nstime.h>
32 #include <ns3/lte-amc.h>
33 
34 
35 // value for SINR outside the range defined by FF-API, used to indicate that there
36 // is no CQI for this element
37 #define NO_SINR -5000
38 
39 
40 #define HARQ_PROC_NUM 8
41 #define HARQ_DL_TIMEOUT 11
42 
43 namespace ns3 {
44 
45 
46 typedef std::vector < uint8_t > DlHarqProcessesStatus_t;
47 typedef std::vector < uint8_t > DlHarqProcessesTimer_t;
48 typedef std::vector < DlDciListElement_s > DlHarqProcessesDciBuffer_t;
49 typedef std::vector < std::vector <struct RlcPduListElement_s> > RlcPduList_t; // vector of the LCs and layers per UE
50 typedef std::vector < RlcPduList_t > DlHarqRlcPduListBuffer_t; // vector of the 8 HARQ processes per UE
51 
52 typedef std::vector < UlDciListElement_s > UlHarqProcessesDciBuffer_t;
53 typedef std::vector < uint8_t > UlHarqProcessesStatus_t;
54 
55 
60 {
61  Time flowStart;
62  uint64_t packetArrivalRate;
64  uint32_t tokenPoolSize;
65  uint32_t maxTokenPoolSize;
66  int counter;
67  uint32_t burstCredit;
68  int debtLimit;
70 };
71 
84 {
85 public:
92 
96  virtual ~TdTbfqFfMacScheduler ();
97 
98  // inherited from Object
99  virtual void DoDispose (void);
100  static TypeId GetTypeId (void);
101 
102  // inherited from FfMacScheduler
103  virtual void SetFfMacCschedSapUser (FfMacCschedSapUser* s);
104  virtual void SetFfMacSchedSapUser (FfMacSchedSapUser* s);
107 
110 
111  void TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode);
112 
113 private:
114  //
115  // Implementation of the CSCHED API primitives
116  // (See 4.1 for description of the primitives)
117  //
118 
119  void DoCschedCellConfigReq (const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params);
120 
121  void DoCschedUeConfigReq (const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params);
122 
123  void DoCschedLcConfigReq (const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params);
124 
125  void DoCschedLcReleaseReq (const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params);
126 
127  void DoCschedUeReleaseReq (const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params);
128 
129  //
130  // Implementation of the SCHED API primitives
131  // (See 4.2 for description of the primitives)
132  //
133 
134  void DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params);
135 
136  void DoSchedDlPagingBufferReq (const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params);
137 
138  void DoSchedDlMacBufferReq (const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params);
139 
140  void DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params);
141 
142  void DoSchedDlRachInfoReq (const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params);
143 
144  void DoSchedDlCqiInfoReq (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params);
145 
146  void DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params);
147 
148  void DoSchedUlNoiseInterferenceReq (const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params);
149 
150  void DoSchedUlSrInfoReq (const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params);
151 
152  void DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params);
153 
154  void DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params);
155 
156 
157  int GetRbgSize (int dlbandwidth);
158 
159  int LcActivePerFlow (uint16_t rnti);
160 
161  double EstimateUlSinr (uint16_t rnti, uint16_t rb);
162 
163  void RefreshDlCqiMaps (void);
164  void RefreshUlCqiMaps (void);
165 
166  void UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size);
167  void UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size);
168 
175  uint8_t UpdateHarqProcessId (uint16_t rnti);
176 
183  uint8_t HarqProcessAvailability (uint16_t rnti);
184 
189  void RefreshHarqProcesses ();
190 
191  Ptr<LteAmc> m_amc;
192 
193  /*
194  * Vectors of UE's LC info
195  */
196  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> m_rlcBufferReq;
197 
198 
199  /*
200  * Map of UE statistics (per RNTI basis) in downlink
201  */
202  std::map <uint16_t, tdtbfqsFlowPerf_t> m_flowStatsDl;
203 
204  /*
205  * Map of UE statistics (per RNTI basis)
206  */
207  std::map <uint16_t, tdtbfqsFlowPerf_t> m_flowStatsUl;
208 
209 
210  /*
211  * Map of UE's DL CQI P01 received
212  */
213  std::map <uint16_t,uint8_t> m_p10CqiRxed;
214  /*
215  * Map of UE's timers on DL CQI P01 received
216  */
217  std::map <uint16_t,uint32_t> m_p10CqiTimers;
218 
219  /*
220  * Map of UE's DL CQI A30 received
221  */
222  std::map <uint16_t,SbMeasResult_s> m_a30CqiRxed;
223  /*
224  * Map of UE's timers on DL CQI A30 received
225  */
226  std::map <uint16_t,uint32_t> m_a30CqiTimers;
227 
228  /*
229  * Map of previous allocated UE per RBG
230  * (used to retrieve info from UL-CQI)
231  */
232  std::map <uint16_t, std::vector <uint16_t> > m_allocationMaps;
233 
234  /*
235  * Map of UEs' UL-CQI per RBG
236  */
237  std::map <uint16_t, std::vector <double> > m_ueCqi;
238  /*
239  * Map of UEs' timers on UL-CQI per RBG
240  */
241  std::map <uint16_t, uint32_t> m_ueCqiTimers;
242 
243  /*
244  * Map of UE's buffer status reports received
245  */
246  std::map <uint16_t,uint32_t> m_ceBsrRxed;
247 
248  // MAC SAPs
249  FfMacCschedSapUser* m_cschedSapUser;
250  FfMacSchedSapUser* m_schedSapUser;
251  FfMacCschedSapProvider* m_cschedSapProvider;
252  FfMacSchedSapProvider* m_schedSapProvider;
253 
254 
255  // Internal parameters
257 
258 
259  double m_timeWindow;
260 
261  uint16_t m_nextRntiUl; // RNTI of the next user to be served next scheduling in UL
262 
263  uint32_t m_cqiTimersThreshold; // # of TTIs for which a CQI canbe considered valid
264 
265  std::map <uint16_t,uint8_t> m_uesTxMode; // txMode of the UEs
266 
267  uint64_t bankSize; // the number of bytes in token bank
268 
269  int m_debtLimit; // flow debt limit (byte)
270 
271  uint32_t m_creditLimit; // flow credit limit (byte)
272 
273  uint32_t m_tokenPoolSize; // maximum size of token pool (byte)
274 
275  uint32_t m_creditableThreshold; // threshold of flow credit
276 
277  // HARQ attributes
281  bool m_harqOn;
282  std::map <uint16_t, uint8_t> m_dlHarqCurrentProcessId;
283  //HARQ status
284  // 0: process Id available
285  // x>0: process Id equal to `x` trasmission count
286  std::map <uint16_t, DlHarqProcessesStatus_t> m_dlHarqProcessesStatus;
287  std::map <uint16_t, DlHarqProcessesTimer_t> m_dlHarqProcessesTimer;
288  std::map <uint16_t, DlHarqProcessesDciBuffer_t> m_dlHarqProcessesDciBuffer;
289  std::map <uint16_t, DlHarqRlcPduListBuffer_t> m_dlHarqProcessesRlcPduListBuffer;
290  std::vector <DlInfoListElement_s> m_dlInfoListBuffered; // HARQ retx buffered
291 
292  std::map <uint16_t, uint8_t> m_ulHarqCurrentProcessId;
293  //HARQ status
294  // 0: process Id available
295  // x>0: process Id equal to `x` trasmission count
296  std::map <uint16_t, UlHarqProcessesStatus_t> m_ulHarqProcessesStatus;
297  std::map <uint16_t, UlHarqProcessesDciBuffer_t> m_ulHarqProcessesDciBuffer;
298 
299 
300  // RACH attributes
301  std::vector <struct RachListElement_s> m_rachList;
302  std::vector <uint16_t> m_rachAllocationMap;
303  uint8_t m_ulGrantMcs; // MCS for UL grant (default 0)
304 };
305 
306 } // namespace ns3
307 
308 #endif /* TDTBFQ_FF_MAC_SCHEDULER_H */
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
uint32_t burstCredit
the number of token borrow or given to token bank
uint32_t maxTokenPoolSize
current size of token pool (byte)
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
Provides the CSCHED SAP.
int counter
maximum size of token pool (byte)
Implements the SCHED SAP and CSCHED SAP for a Time Domain Token Bank Fair Queue scheduler.
int debtLimit
the maximum number of tokens connection i can borrow from the bank each time
Provides the SCHED SAP.
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
uint64_t tokenGenerationRate
packet arrival rate( byte/s)
uint32_t creditableThreshold
counter threshold that the flow cannot further borrow tokens from bank
uint32_t tokenPoolSize
token generation rate ( byte/s )
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
a unique identifier for an interface.
Definition: type-id.h:44