A Discrete-Event Network Simulator
API
tdtbfq-ff-mac-scheduler.cc
Go to the documentation of this file.
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 #include <ns3/log.h>
23 #include <ns3/pointer.h>
24 #include <ns3/math.h>
25 
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/tdtbfq-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
31 #include <ns3/integer.h>
32 #include <set>
33 #include <cfloat>
34 
35 namespace ns3 {
36 
37 NS_LOG_COMPONENT_DEFINE ("TdTbfqFfMacScheduler");
38 
40 static const int TdTbfqType0AllocationRbg[4] = {
41  10, // RGB size 1
42  26, // RGB size 2
43  63, // RGB size 3
44  110 // RGB size 4
45 }; // see table 7.1.6.1-1 of 36.213
46 
47 
48 NS_OBJECT_ENSURE_REGISTERED (TdTbfqFfMacScheduler);
49 
50 
51 
53  : m_cschedSapUser (0),
54  m_schedSapUser (0),
55  m_nextRntiUl (0),
56  bankSize (0)
57 {
58  m_amc = CreateObject <LteAmc> ();
61  m_ffrSapProvider = 0;
63 }
64 
66 {
67  NS_LOG_FUNCTION (this);
68 }
69 
70 void
72 {
73  NS_LOG_FUNCTION (this);
75  m_dlHarqProcessesTimer.clear ();
77  m_dlInfoListBuffered.clear ();
78  m_ulHarqCurrentProcessId.clear ();
79  m_ulHarqProcessesStatus.clear ();
81  delete m_cschedSapProvider;
82  delete m_schedSapProvider;
83  delete m_ffrSapUser;
84 }
85 
86 TypeId
88 {
89  static TypeId tid = TypeId ("ns3::TdTbfqFfMacScheduler")
91  .SetGroupName("Lte")
92  .AddConstructor<TdTbfqFfMacScheduler> ()
93  .AddAttribute ("CqiTimerThreshold",
94  "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
95  UintegerValue (1000),
97  MakeUintegerChecker<uint32_t> ())
98  .AddAttribute ("DebtLimit",
99  "Flow debt limit (default -625000 bytes)",
100  IntegerValue (-625000),
102  MakeIntegerChecker<int> ())
103  .AddAttribute ("CreditLimit",
104  "Flow credit limit (default 625000 bytes)",
105  UintegerValue (625000),
107  MakeUintegerChecker<uint32_t> ())
108  .AddAttribute ("TokenPoolSize",
109  "The maximum value of flow token pool (default 1 bytes)",
110  UintegerValue (1),
112  MakeUintegerChecker<uint32_t> ())
113  .AddAttribute ("CreditableThreshold",
114  "Threshold of flow credit (default 0 bytes)",
115  UintegerValue (0),
117  MakeUintegerChecker<uint32_t> ())
118 
119  .AddAttribute ("HarqEnabled",
120  "Activate/Deactivate the HARQ [by default is active].",
121  BooleanValue (true),
124  .AddAttribute ("UlGrantMcs",
125  "The MCS of the UL grant, must be [0..15] (default 0)",
126  UintegerValue (0),
128  MakeUintegerChecker<uint8_t> ())
129  ;
130  return tid;
131 }
132 
133 
134 
135 void
137 {
138  m_cschedSapUser = s;
139 }
140 
141 void
143 {
144  m_schedSapUser = s;
145 }
146 
149 {
150  return m_cschedSapProvider;
151 }
152 
155 {
156  return m_schedSapProvider;
157 }
158 
159 void
161 {
162  m_ffrSapProvider = s;
163 }
164 
167 {
168  return m_ffrSapUser;
169 }
170 
171 void
173 {
174  NS_LOG_FUNCTION (this);
175  // Read the subset of parameters used
176  m_cschedCellConfig = params;
179  cnf.m_result = SUCCESS;
181  return;
182 }
183 
184 void
186 {
187  NS_LOG_FUNCTION (this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode);
188  std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
189  if (it == m_uesTxMode.end ())
190  {
191  m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
192  // generate HARQ buffers
193  m_dlHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
194  DlHarqProcessesStatus_t dlHarqPrcStatus;
195  dlHarqPrcStatus.resize (8,0);
196  m_dlHarqProcessesStatus.insert (std::pair <uint16_t, DlHarqProcessesStatus_t> (params.m_rnti, dlHarqPrcStatus));
197  DlHarqProcessesTimer_t dlHarqProcessesTimer;
198  dlHarqProcessesTimer.resize (8,0);
199  m_dlHarqProcessesTimer.insert (std::pair <uint16_t, DlHarqProcessesTimer_t> (params.m_rnti, dlHarqProcessesTimer));
200  DlHarqProcessesDciBuffer_t dlHarqdci;
201  dlHarqdci.resize (8);
202  m_dlHarqProcessesDciBuffer.insert (std::pair <uint16_t, DlHarqProcessesDciBuffer_t> (params.m_rnti, dlHarqdci));
203  DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
204  dlHarqRlcPdu.resize (2);
205  dlHarqRlcPdu.at (0).resize (8);
206  dlHarqRlcPdu.at (1).resize (8);
207  m_dlHarqProcessesRlcPduListBuffer.insert (std::pair <uint16_t, DlHarqRlcPduListBuffer_t> (params.m_rnti, dlHarqRlcPdu));
208  m_ulHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
209  UlHarqProcessesStatus_t ulHarqPrcStatus;
210  ulHarqPrcStatus.resize (8,0);
211  m_ulHarqProcessesStatus.insert (std::pair <uint16_t, UlHarqProcessesStatus_t> (params.m_rnti, ulHarqPrcStatus));
212  UlHarqProcessesDciBuffer_t ulHarqdci;
213  ulHarqdci.resize (8);
214  m_ulHarqProcessesDciBuffer.insert (std::pair <uint16_t, UlHarqProcessesDciBuffer_t> (params.m_rnti, ulHarqdci));
215  }
216  else
217  {
218  (*it).second = params.m_transmissionMode;
219  }
220  return;
221 }
222 
223 void
225 {
226  NS_LOG_FUNCTION (this << " New LC, rnti: " << params.m_rnti);
227 
228  std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
229  for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++)
230  {
231  it = m_flowStatsDl.find (params.m_rnti);
232 
233  if (it == m_flowStatsDl.end ())
234  {
235  uint64_t mbrDlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabMaximulBitrateDl / 8; // byte/s
236  uint64_t mbrUlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabMaximulBitrateUl / 8; // byte/s
237 
238  tdtbfqsFlowPerf_t flowStatsDl;
239  flowStatsDl.flowStart = Simulator::Now ();
240  flowStatsDl.packetArrivalRate = 0;
241  flowStatsDl.tokenGenerationRate = mbrDlInBytes;
242  flowStatsDl.tokenPoolSize = 0;
243  flowStatsDl.maxTokenPoolSize = m_tokenPoolSize;
244  flowStatsDl.counter = 0;
245  flowStatsDl.burstCredit = m_creditLimit; // bytes
246  flowStatsDl.debtLimit = m_debtLimit; // bytes
248  m_flowStatsDl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.m_rnti, flowStatsDl));
249  tdtbfqsFlowPerf_t flowStatsUl;
250  flowStatsUl.flowStart = Simulator::Now ();
251  flowStatsUl.packetArrivalRate = 0;
252  flowStatsUl.tokenGenerationRate = mbrUlInBytes;
253  flowStatsUl.tokenPoolSize = 0;
254  flowStatsUl.maxTokenPoolSize = m_tokenPoolSize;
255  flowStatsUl.counter = 0;
256  flowStatsUl.burstCredit = m_creditLimit; // bytes
257  flowStatsUl.debtLimit = m_debtLimit; // bytes
259  m_flowStatsUl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.m_rnti, flowStatsUl));
260  }
261  else
262  {
263  // update MBR and GBR from UeManager::SetupDataRadioBearer ()
264  uint64_t mbrDlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabMaximulBitrateDl / 8; // byte/s
265  uint64_t mbrUlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabMaximulBitrateUl / 8; // byte/s
266  m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
267  m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
268 
269  }
270  }
271 
272  return;
273 }
274 
275 void
277 {
278  NS_LOG_FUNCTION (this);
279  for (uint16_t i = 0; i < params.m_logicalChannelIdentity.size (); i++)
280  {
281  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
282  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
283  while (it!=m_rlcBufferReq.end ())
284  {
285  if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at (i)))
286  {
287  temp = it;
288  it++;
289  m_rlcBufferReq.erase (temp);
290  }
291  else
292  {
293  it++;
294  }
295  }
296  }
297  return;
298 }
299 
300 void
302 {
303  NS_LOG_FUNCTION (this);
304 
305  m_uesTxMode.erase (params.m_rnti);
306  m_dlHarqCurrentProcessId.erase (params.m_rnti);
307  m_dlHarqProcessesStatus.erase (params.m_rnti);
308  m_dlHarqProcessesTimer.erase (params.m_rnti);
309  m_dlHarqProcessesDciBuffer.erase (params.m_rnti);
311  m_ulHarqCurrentProcessId.erase (params.m_rnti);
312  m_ulHarqProcessesStatus.erase (params.m_rnti);
313  m_ulHarqProcessesDciBuffer.erase (params.m_rnti);
314  m_flowStatsDl.erase (params.m_rnti);
315  m_flowStatsUl.erase (params.m_rnti);
316  m_ceBsrRxed.erase (params.m_rnti);
317  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
318  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
319  while (it!=m_rlcBufferReq.end ())
320  {
321  if ((*it).first.m_rnti == params.m_rnti)
322  {
323  temp = it;
324  it++;
325  m_rlcBufferReq.erase (temp);
326  }
327  else
328  {
329  it++;
330  }
331  }
332  if (m_nextRntiUl == params.m_rnti)
333  {
334  m_nextRntiUl = 0;
335  }
336 
337  return;
338 }
339 
340 
341 void
343 {
344  NS_LOG_FUNCTION (this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
345  // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
346 
347  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
348 
349  LteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity);
350 
351  it = m_rlcBufferReq.find (flow);
352 
353  if (it == m_rlcBufferReq.end ())
354  {
355  m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
356  }
357  else
358  {
359  (*it).second = params;
360  }
361 
362  return;
363 }
364 
365 void
367 {
368  NS_LOG_FUNCTION (this);
369  NS_FATAL_ERROR ("method not implemented");
370  return;
371 }
372 
373 void
375 {
376  NS_LOG_FUNCTION (this);
377  NS_FATAL_ERROR ("method not implemented");
378  return;
379 }
380 
381 int
383 {
384  for (int i = 0; i < 4; i++)
385  {
386  if (dlbandwidth < TdTbfqType0AllocationRbg[i])
387  {
388  return (i + 1);
389  }
390  }
391 
392  return (-1);
393 }
394 
395 
396 unsigned int
398 {
399  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
400  unsigned int lcActive = 0;
401  for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
402  {
403  if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
404  || ((*it).second.m_rlcRetransmissionQueueSize > 0)
405  || ((*it).second.m_rlcStatusPduSize > 0) ))
406  {
407  lcActive++;
408  }
409  if ((*it).first.m_rnti > rnti)
410  {
411  break;
412  }
413  }
414  return (lcActive);
415 
416 }
417 
418 
419 uint8_t
421 {
422  NS_LOG_FUNCTION (this << rnti);
423 
424  std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
425  if (it == m_dlHarqCurrentProcessId.end ())
426  {
427  NS_FATAL_ERROR ("No Process Id found for this RNTI " << rnti);
428  }
429  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
430  if (itStat == m_dlHarqProcessesStatus.end ())
431  {
432  NS_FATAL_ERROR ("No Process Id Statusfound for this RNTI " << rnti);
433  }
434  uint8_t i = (*it).second;
435  do
436  {
437  i = (i + 1) % HARQ_PROC_NUM;
438  }
439  while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
440  if ((*itStat).second.at (i) == 0)
441  {
442  return (true);
443  }
444  else
445  {
446  return (false); // return a not valid harq proc id
447  }
448 }
449 
450 
451 
452 uint8_t
454 {
455  NS_LOG_FUNCTION (this << rnti);
456 
457  if (m_harqOn == false)
458  {
459  return (0);
460  }
461 
462 
463  std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
464  if (it == m_dlHarqCurrentProcessId.end ())
465  {
466  NS_FATAL_ERROR ("No Process Id found for this RNTI " << rnti);
467  }
468  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
469  if (itStat == m_dlHarqProcessesStatus.end ())
470  {
471  NS_FATAL_ERROR ("No Process Id Statusfound for this RNTI " << rnti);
472  }
473  uint8_t i = (*it).second;
474  do
475  {
476  i = (i + 1) % HARQ_PROC_NUM;
477  }
478  while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
479  if ((*itStat).second.at (i) == 0)
480  {
481  (*it).second = i;
482  (*itStat).second.at (i) = 1;
483  }
484  else
485  {
486  NS_FATAL_ERROR ("No HARQ process available for RNTI " << rnti << " check before update with HarqProcessAvailability");
487  }
488 
489  return ((*it).second);
490 }
491 
492 
493 void
495 {
496  NS_LOG_FUNCTION (this);
497 
498  std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
499  for (itTimers = m_dlHarqProcessesTimer.begin (); itTimers != m_dlHarqProcessesTimer.end (); itTimers ++)
500  {
501  for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
502  {
503  if ((*itTimers).second.at (i) == HARQ_DL_TIMEOUT)
504  {
505  // reset HARQ process
506 
507  NS_LOG_DEBUG (this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first);
508  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find ((*itTimers).first);
509  if (itStat == m_dlHarqProcessesStatus.end ())
510  {
511  NS_FATAL_ERROR ("No Process Id Status found for this RNTI " << (*itTimers).first);
512  }
513  (*itStat).second.at (i) = 0;
514  (*itTimers).second.at (i) = 0;
515  }
516  else
517  {
518  (*itTimers).second.at (i)++;
519  }
520  }
521  }
522 
523 }
524 
525 
526 void
528 {
529  NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
530  // API generated by RLC for triggering the scheduling of a DL subframe
531 
532 
533  // evaluate the relative channel quality indicator for each UE per each RBG
534  // (since we are using allocation type 0 the small unit of allocation is RBG)
535  // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
536 
537  RefreshDlCqiMaps ();
538 
540  int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
541  std::map <uint16_t, std::vector <uint16_t> > allocationMap; // RBs map per RNTI
542  std::vector <bool> rbgMap; // global RBGs map
543  uint16_t rbgAllocatedNum = 0;
544  std::set <uint16_t> rntiAllocated;
545  rbgMap.resize (m_cschedCellConfig.m_dlBandwidth / rbgSize, false);
546 
547  rbgMap = m_ffrSapProvider->GetAvailableDlRbg ();
548  for (std::vector<bool>::iterator it = rbgMap.begin (); it != rbgMap.end (); it++)
549  {
550  if ((*it) == true )
551  {
552  rbgAllocatedNum++;
553  }
554  }
555 
557 
558  // update UL HARQ proc id
559  std::map <uint16_t, uint8_t>::iterator itProcId;
560  for (itProcId = m_ulHarqCurrentProcessId.begin (); itProcId != m_ulHarqCurrentProcessId.end (); itProcId++)
561  {
562  (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
563  }
564 
565  // RACH Allocation
566  uint16_t rbAllocatedNum = 0;
567  std::vector <bool> ulRbMap;
568  ulRbMap.resize (m_cschedCellConfig.m_ulBandwidth, false);
569  ulRbMap = m_ffrSapProvider->GetAvailableUlRbg ();
570  uint8_t maxContinuousUlBandwidth = 0;
571  uint8_t tmpMinBandwidth = 0;
572  uint16_t ffrRbStartOffset = 0;
573  uint16_t tmpFfrRbStartOffset = 0;
574  uint16_t index = 0;
575 
576  for (std::vector<bool>::iterator it = ulRbMap.begin (); it != ulRbMap.end (); it++)
577  {
578  if ((*it) == true )
579  {
580  rbAllocatedNum++;
581  if (tmpMinBandwidth > maxContinuousUlBandwidth)
582  {
583  maxContinuousUlBandwidth = tmpMinBandwidth;
584  ffrRbStartOffset = tmpFfrRbStartOffset;
585  }
586  tmpMinBandwidth = 0;
587  }
588  else
589  {
590  if (tmpMinBandwidth == 0)
591  {
592  tmpFfrRbStartOffset = index;
593  }
594  tmpMinBandwidth++;
595  }
596  index++;
597  }
598 
599  if (tmpMinBandwidth > maxContinuousUlBandwidth)
600  {
601  maxContinuousUlBandwidth = tmpMinBandwidth;
602  ffrRbStartOffset = tmpFfrRbStartOffset;
603  }
604 
606  uint16_t rbStart = 0;
607  rbStart = ffrRbStartOffset;
608  std::vector <struct RachListElement_s>::iterator itRach;
609  for (itRach = m_rachList.begin (); itRach != m_rachList.end (); itRach++)
610  {
611  NS_ASSERT_MSG (m_amc->GetUlTbSizeFromMcs (m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, " Default UL Grant MCS does not allow to send RACH messages");
612  BuildRarListElement_s newRar;
613  newRar.m_rnti = (*itRach).m_rnti;
614  // DL-RACH Allocation
615  // Ideal: no needs of configuring m_dci
616  // UL-RACH Allocation
617  newRar.m_grant.m_rnti = newRar.m_rnti;
618  newRar.m_grant.m_mcs = m_ulGrantMcs;
619  uint16_t rbLen = 1;
620  uint16_t tbSizeBits = 0;
621  // find lowest TB size that fits UL grant estimated size
622  while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < (ffrRbStartOffset + maxContinuousUlBandwidth)))
623  {
624  rbLen++;
625  tbSizeBits = m_amc->GetUlTbSizeFromMcs (m_ulGrantMcs, rbLen);
626  }
627  if (tbSizeBits < (*itRach).m_estimatedSize)
628  {
629  // no more allocation space: finish allocation
630  break;
631  }
632  newRar.m_grant.m_rbStart = rbStart;
633  newRar.m_grant.m_rbLen = rbLen;
634  newRar.m_grant.m_tbSize = tbSizeBits / 8;
635  newRar.m_grant.m_hopping = false;
636  newRar.m_grant.m_tpc = 0;
637  newRar.m_grant.m_cqiRequest = false;
638  newRar.m_grant.m_ulDelay = false;
639  NS_LOG_INFO (this << " UL grant allocated to RNTI " << (*itRach).m_rnti << " rbStart " << rbStart << " rbLen " << rbLen << " MCS " << m_ulGrantMcs << " tbSize " << newRar.m_grant.m_tbSize);
640  for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
641  {
642  m_rachAllocationMap.at (i) = (*itRach).m_rnti;
643  }
644 
645  if (m_harqOn == true)
646  {
647  // generate UL-DCI for HARQ retransmissions
648  UlDciListElement_s uldci;
649  uldci.m_rnti = newRar.m_rnti;
650  uldci.m_rbLen = rbLen;
651  uldci.m_rbStart = rbStart;
652  uldci.m_mcs = m_ulGrantMcs;
653  uldci.m_tbSize = tbSizeBits / 8;
654  uldci.m_ndi = 1;
655  uldci.m_cceIndex = 0;
656  uldci.m_aggrLevel = 1;
657  uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
658  uldci.m_hopping = false;
659  uldci.m_n2Dmrs = 0;
660  uldci.m_tpc = 0; // no power control
661  uldci.m_cqiRequest = false; // only period CQI at this stage
662  uldci.m_ulIndex = 0; // TDD parameter
663  uldci.m_dai = 1; // TDD parameter
664  uldci.m_freqHopping = 0;
665  uldci.m_pdcchPowerOffset = 0; // not used
666 
667  uint8_t harqId = 0;
668  std::map <uint16_t, uint8_t>::iterator itProcId;
669  itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
670  if (itProcId == m_ulHarqCurrentProcessId.end ())
671  {
672  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << uldci.m_rnti);
673  }
674  harqId = (*itProcId).second;
675  std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
676  if (itDci == m_ulHarqProcessesDciBuffer.end ())
677  {
678  NS_FATAL_ERROR ("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
679  }
680  (*itDci).second.at (harqId) = uldci;
681  }
682 
683  rbStart = rbStart + rbLen;
684  ret.m_buildRarList.push_back (newRar);
685  }
686  m_rachList.clear ();
687 
688 
689  // Process DL HARQ feedback
691  // retrieve past HARQ retx buffered
692  if (m_dlInfoListBuffered.size () > 0)
693  {
694  if (params.m_dlInfoList.size () > 0)
695  {
696  NS_LOG_INFO (this << " Received DL-HARQ feedback");
697  m_dlInfoListBuffered.insert (m_dlInfoListBuffered.end (), params.m_dlInfoList.begin (), params.m_dlInfoList.end ());
698  }
699  }
700  else
701  {
702  if (params.m_dlInfoList.size () > 0)
703  {
705  }
706  }
707  if (m_harqOn == false)
708  {
709  // Ignore HARQ feedback
710  m_dlInfoListBuffered.clear ();
711  }
712  std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
713  for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
714  {
715  std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
716  if (itRnti != rntiAllocated.end ())
717  {
718  // RNTI already allocated for retx
719  continue;
720  }
721  uint8_t nLayers = m_dlInfoListBuffered.at (i).m_harqStatus.size ();
722  std::vector <bool> retx;
723  NS_LOG_INFO (this << " Processing DLHARQ feedback");
724  if (nLayers == 1)
725  {
726  retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
727  retx.push_back (false);
728  }
729  else
730  {
731  retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
732  retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (1) == DlInfoListElement_s::NACK);
733  }
734  if (retx.at (0) || retx.at (1))
735  {
736  // retrieve HARQ process information
737  uint16_t rnti = m_dlInfoListBuffered.at (i).m_rnti;
738  uint8_t harqId = m_dlInfoListBuffered.at (i).m_harqProcessId;
739  NS_LOG_INFO (this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
740  std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq = m_dlHarqProcessesDciBuffer.find (rnti);
741  if (itHarq == m_dlHarqProcessesDciBuffer.end ())
742  {
743  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << rnti);
744  }
745 
746  DlDciListElement_s dci = (*itHarq).second.at (harqId);
747  int rv = 0;
748  if (dci.m_rv.size () == 1)
749  {
750  rv = dci.m_rv.at (0);
751  }
752  else
753  {
754  rv = (dci.m_rv.at (0) > dci.m_rv.at (1) ? dci.m_rv.at (0) : dci.m_rv.at (1));
755  }
756 
757  if (rv == 3)
758  {
759  // maximum number of retx reached -> drop process
760  NS_LOG_INFO ("Maximum number of retransmissions reached -> drop process");
761  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (rnti);
762  if (it == m_dlHarqProcessesStatus.end ())
763  {
764  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at (i).m_rnti);
765  }
766  (*it).second.at (harqId) = 0;
767  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
768  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
769  {
770  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
771  }
772  for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
773  {
774  (*itRlcPdu).second.at (k).at (harqId).clear ();
775  }
776  continue;
777  }
778  // check the feasibility of retransmitting on the same RBGs
779  // translate the DCI to Spectrum framework
780  std::vector <int> dciRbg;
781  uint32_t mask = 0x1;
782  NS_LOG_INFO ("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
783  for (int j = 0; j < 32; j++)
784  {
785  if (((dci.m_rbBitmap & mask) >> j) == 1)
786  {
787  dciRbg.push_back (j);
788  NS_LOG_INFO ("\t" << j);
789  }
790  mask = (mask << 1);
791  }
792  bool free = true;
793  for (uint8_t j = 0; j < dciRbg.size (); j++)
794  {
795  if (rbgMap.at (dciRbg.at (j)) == true)
796  {
797  free = false;
798  break;
799  }
800  }
801  if (free)
802  {
803  // use the same RBGs for the retx
804  // reserve RBGs
805  for (uint8_t j = 0; j < dciRbg.size (); j++)
806  {
807  rbgMap.at (dciRbg.at (j)) = true;
808  NS_LOG_INFO ("RBG " << dciRbg.at (j) << " assigned");
809  rbgAllocatedNum++;
810  }
811 
812  NS_LOG_INFO (this << " Send retx in the same RBGs");
813  }
814  else
815  {
816  // find RBGs for sending HARQ retx
817  uint8_t j = 0;
818  uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
819  uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
820  std::vector <bool> rbgMapCopy = rbgMap;
821  while ((j < dciRbg.size ())&&(startRbg != rbgId))
822  {
823  if (rbgMapCopy.at (rbgId) == false)
824  {
825  rbgMapCopy.at (rbgId) = true;
826  dciRbg.at (j) = rbgId;
827  j++;
828  }
829  rbgId = (rbgId + 1) % rbgNum;
830  }
831  if (j == dciRbg.size ())
832  {
833  // find new RBGs -> update DCI map
834  uint32_t rbgMask = 0;
835  for (uint16_t k = 0; k < dciRbg.size (); k++)
836  {
837  rbgMask = rbgMask + (0x1 << dciRbg.at (k));
838  rbgAllocatedNum++;
839  }
840  dci.m_rbBitmap = rbgMask;
841  rbgMap = rbgMapCopy;
842  NS_LOG_INFO (this << " Move retx in RBGs " << dciRbg.size ());
843  }
844  else
845  {
846  // HARQ retx cannot be performed on this TTI -> store it
847  dlInfoListUntxed.push_back (m_dlInfoListBuffered.at (i));
848  NS_LOG_INFO (this << " No resource for this retx -> buffer it");
849  }
850  }
851  // retrieve RLC PDU list for retx TBsize and update DCI
853  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
854  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
855  {
856  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
857  }
858  for (uint8_t j = 0; j < nLayers; j++)
859  {
860  if (retx.at (j))
861  {
862  if (j >= dci.m_ndi.size ())
863  {
864  // for avoiding errors in MIMO transient phases
865  dci.m_ndi.push_back (0);
866  dci.m_rv.push_back (0);
867  dci.m_mcs.push_back (0);
868  dci.m_tbsSize.push_back (0);
869  NS_LOG_INFO (this << " layer " << (uint16_t)j << " no txed (MIMO transition)");
870  }
871  else
872  {
873  dci.m_ndi.at (j) = 0;
874  dci.m_rv.at (j)++;
875  (*itHarq).second.at (harqId).m_rv.at (j)++;
876  NS_LOG_INFO (this << " layer " << (uint16_t)j << " RV " << (uint16_t)dci.m_rv.at (j));
877  }
878  }
879  else
880  {
881  // empty TB of layer j
882  dci.m_ndi.at (j) = 0;
883  dci.m_rv.at (j) = 0;
884  dci.m_mcs.at (j) = 0;
885  dci.m_tbsSize.at (j) = 0;
886  NS_LOG_INFO (this << " layer " << (uint16_t)j << " no retx");
887  }
888  }
889  for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.m_harqProcess).size (); k++)
890  {
891  std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
892  for (uint8_t j = 0; j < nLayers; j++)
893  {
894  if (retx.at (j))
895  {
896  if (j < dci.m_ndi.size ())
897  {
898  NS_LOG_INFO (" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at (j));
899  rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.m_harqProcess).at (k));
900  }
901  }
902  else
903  { // if no retx needed on layer j, push an RlcPduListElement_s object with m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
904  NS_LOG_INFO (" layer " << (uint16_t)j << " tb size "<<dci.m_tbsSize.at (j));
905  RlcPduListElement_s emptyElement;
906  emptyElement.m_logicalChannelIdentity = (*itRlcPdu).second.at (j).at (dci.m_harqProcess).at (k).m_logicalChannelIdentity;
907  emptyElement.m_size = 0;
908  rlcPduListPerLc.push_back (emptyElement);
909  }
910  }
911 
912  if (rlcPduListPerLc.size () > 0)
913  {
914  newEl.m_rlcPduList.push_back (rlcPduListPerLc);
915  }
916  }
917  newEl.m_rnti = rnti;
918  newEl.m_dci = dci;
919  (*itHarq).second.at (harqId).m_rv = dci.m_rv;
920  // refresh timer
921  std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (rnti);
922  if (itHarqTimer== m_dlHarqProcessesTimer.end ())
923  {
924  NS_FATAL_ERROR ("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
925  }
926  (*itHarqTimer).second.at (harqId) = 0;
927  ret.m_buildDataList.push_back (newEl);
928  rntiAllocated.insert (rnti);
929  }
930  else
931  {
932  // update HARQ process status
933  NS_LOG_INFO (this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at (i).m_rnti);
934  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (m_dlInfoListBuffered.at (i).m_rnti);
935  if (it == m_dlHarqProcessesStatus.end ())
936  {
937  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at (i).m_rnti);
938  }
939  (*it).second.at (m_dlInfoListBuffered.at (i).m_harqProcessId) = 0;
940  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (m_dlInfoListBuffered.at (i).m_rnti);
941  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
942  {
943  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
944  }
945  for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
946  {
947  (*itRlcPdu).second.at (k).at (m_dlInfoListBuffered.at (i).m_harqProcessId).clear ();
948  }
949  }
950  }
951  m_dlInfoListBuffered.clear ();
952  m_dlInfoListBuffered = dlInfoListUntxed;
953 
954  if (rbgAllocatedNum == rbgNum)
955  {
956  // all the RBGs are already allocated -> exit
957  if ((ret.m_buildDataList.size () > 0) || (ret.m_buildRarList.size () > 0))
958  {
960  }
961  return;
962  }
963 
964 
965  // update token pool, counter and bank size
966  std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
967  for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
968  {
969  if ( (*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
970  {
971  (*itStats).second.counter += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
972  (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
973  bankSize += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
974  }
975  else
976  {
977  (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
978  }
979  }
980 
981 
982  // select UE with largest metric
983  std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
984  std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itMax = m_flowStatsDl.end ();
985  double metricMax = 0.0;
986  bool firstRnti = true;
987  for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++)
988  {
989  std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
990  if ((itRnti != rntiAllocated.end ())||(!HarqProcessAvailability ((*it).first)))
991  {
992  // UE already allocated for HARQ or without HARQ process available -> drop it
993  if (itRnti != rntiAllocated.end ())
994  {
995  NS_LOG_DEBUG (this << " RNTI discared for HARQ tx" << (uint16_t)(*it).first);
996  }
997  if (!HarqProcessAvailability ((*it).first))
998  {
999  NS_LOG_DEBUG (this << " RNTI discared for HARQ id" << (uint16_t)(*it).first);
1000  }
1001  continue;
1002  }
1003 
1004 
1005  // check first the channel conditions for this UE, if CQI!=0
1006  std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1007  itCqi = m_a30CqiRxed.find ((*it).first);
1008  std::map <uint16_t,uint8_t>::iterator itTxMode;
1009  itTxMode = m_uesTxMode.find ((*it).first);
1010  if (itTxMode == m_uesTxMode.end ())
1011  {
1012  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).first);
1013  }
1014  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1015 
1016  uint8_t cqiSum = 0;
1017  for (int k = 0; k < rbgNum; k++)
1018  {
1019  for (uint8_t j = 0; j < nLayer; j++)
1020  {
1021  if (itCqi == m_a30CqiRxed.end ())
1022  {
1023  cqiSum += 1; // no info on this user -> lowest MCS
1024  }
1025  else
1026  {
1027  cqiSum += (*itCqi).second.m_higherLayerSelected.at (k).m_sbCqi.at(j);
1028  }
1029  }
1030  }
1031 
1032  if (cqiSum == 0)
1033  {
1034  NS_LOG_INFO ("Skip this flow, CQI==0, rnti:"<<(*it).first);
1035  continue;
1036  }
1037 
1038 
1039  /*
1040  if (LcActivePerFlow ((*it).first) == 0)
1041  {
1042  continue;
1043  }
1044  */
1045 
1046  double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
1047 
1048  if (firstRnti == true)
1049  {
1050  metricMax = metric;
1051  itMax = it;
1052  firstRnti = false;
1053  continue;
1054  }
1055  if (metric > metricMax)
1056  {
1057  metricMax = metric;
1058  itMax = it;
1059  }
1060  } // end for m_flowStatsDl
1061 
1062  if (itMax == m_flowStatsDl.end ())
1063  {
1064  // all UEs are allocated RBG or all UEs already allocated for HARQ or without HARQ process available
1065  return;
1066  }
1067  else
1068  {
1069  // assign all RBGs to this UE
1070  std::vector <uint16_t> tempMap;
1071  for (int i = 0; i < rbgNum; i++)
1072  {
1073  if ( rbgMap.at (i) == true) // this RBG is allocated in RACH procedure
1074  continue;
1075 
1076  if ((m_ffrSapProvider->IsDlRbgAvailableForUe (i, (*itMax).first)) == false)
1077  continue;
1078 
1079  tempMap.push_back (i);
1080  rbgMap.at (i) = true;
1081  }
1082  allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1083  }
1084 
1085 
1086 
1087  // generate the transmission opportunities by grouping the RBGs of the same RNTI and
1088  // creating the correspondent DCIs
1089  std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1090  while (itMap != allocationMap.end ())
1091  {
1092  // create new BuildDataListElement_s for this LC
1093  BuildDataListElement_s newEl;
1094  newEl.m_rnti = (*itMap).first;
1095  // create the DlDciListElement_s
1096  DlDciListElement_s newDci;
1097  newDci.m_rnti = (*itMap).first;
1098  newDci.m_harqProcess = UpdateHarqProcessId ((*itMap).first);
1099 
1100  uint16_t lcActives = LcActivePerFlow ((*itMap).first);
1101  NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
1102  if (lcActives == 0)
1103  {
1104  // Set to max value, to avoid divide by 0 below
1105  lcActives = (uint16_t)65535; // UINT16_MAX;
1106  }
1107  uint16_t RgbPerRnti = (*itMap).second.size ();
1108  std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1109  itCqi = m_a30CqiRxed.find ((*itMap).first);
1110  std::map <uint16_t,uint8_t>::iterator itTxMode;
1111  itTxMode = m_uesTxMode.find ((*itMap).first);
1112  if (itTxMode == m_uesTxMode.end ())
1113  {
1114  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*itMap).first);
1115  }
1116  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1117  std::vector <uint8_t> worstCqi (2, 15);
1118  if (itCqi != m_a30CqiRxed.end ())
1119  {
1120  for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1121  {
1122  if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1123  {
1124  for (uint8_t j = 0; j < nLayer; j++)
1125  {
1126  if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1127  {
1128  if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1129  {
1130  worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1131  }
1132  }
1133  else
1134  {
1135  // no CQI for this layer of this suband -> worst one
1136  worstCqi.at (j) = 1;
1137  }
1138  }
1139  }
1140  else
1141  {
1142  for (uint8_t j = 0; j < nLayer; j++)
1143  {
1144  worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
1145  }
1146  }
1147  }
1148  }
1149  else
1150  {
1151  for (uint8_t j = 0; j < nLayer; j++)
1152  {
1153  worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
1154  }
1155  }
1156  uint32_t bytesTxed = 0;
1157  for (uint8_t j = 0; j < nLayer; j++)
1158  {
1159  newDci.m_mcs.push_back (m_amc->GetMcsFromCqi (worstCqi.at (j)));
1160  int tbSize = (m_amc->GetDlTbSizeFromMcs (newDci.m_mcs.at (j), RgbPerRnti * rbgSize) / 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
1161  newDci.m_tbsSize.push_back (tbSize);
1162  bytesTxed += tbSize;
1163  }
1164 
1165  newDci.m_resAlloc = 0; // only allocation type 0 at this stage
1166  newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
1167  uint32_t rbgMask = 0;
1168  for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1169  {
1170  rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1171  NS_LOG_INFO (this << " Allocated RBG " << (*itMap).second.at (k));
1172  }
1173  newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1174 
1175  // create the rlc PDUs -> equally divide resources among actives LCs
1176  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1177  for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
1178  {
1179  if (((*itBufReq).first.m_rnti == (*itMap).first)
1180  && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1181  || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1182  || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1183  {
1184  std::vector <struct RlcPduListElement_s> newRlcPduLe;
1185  for (uint8_t j = 0; j < nLayer; j++)
1186  {
1187  RlcPduListElement_s newRlcEl;
1188  newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1189  newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
1190  NS_LOG_INFO (this << " LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
1191  newRlcPduLe.push_back (newRlcEl);
1192  UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
1193  if (m_harqOn == true)
1194  {
1195  // store RLC PDU list for HARQ
1196  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find ((*itMap).first);
1197  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
1198  {
1199  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1200  }
1201  (*itRlcPdu).second.at (j).at (newDci.m_harqProcess).push_back (newRlcEl);
1202  }
1203  }
1204  newEl.m_rlcPduList.push_back (newRlcPduLe);
1205  }
1206  if ((*itBufReq).first.m_rnti > (*itMap).first)
1207  {
1208  break;
1209  }
1210  }
1211  for (uint8_t j = 0; j < nLayer; j++)
1212  {
1213  newDci.m_ndi.push_back (1);
1214  newDci.m_rv.push_back (0);
1215  }
1216 
1217  newDci.m_tpc = m_ffrSapProvider->GetTpc ((*itMap).first);
1218 
1219  newEl.m_dci = newDci;
1220 
1221  if (m_harqOn == true)
1222  {
1223  // store DCI for HARQ
1224  std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci = m_dlHarqProcessesDciBuffer.find (newEl.m_rnti);
1225  if (itDci == m_dlHarqProcessesDciBuffer.end ())
1226  {
1227  NS_FATAL_ERROR ("Unable to find RNTI entry in DCI HARQ buffer for RNTI " << newEl.m_rnti);
1228  }
1229  (*itDci).second.at (newDci.m_harqProcess) = newDci;
1230  // refresh timer
1231  std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (newEl.m_rnti);
1232  if (itHarqTimer== m_dlHarqProcessesTimer.end ())
1233  {
1234  NS_FATAL_ERROR ("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1235  }
1236  (*itHarqTimer).second.at (newDci.m_harqProcess) = 0;
1237  }
1238 
1239 
1240  // update UE stats
1241  if ( bytesTxed <= (*itMax).second.tokenPoolSize )
1242  {
1243  (*itMax).second.tokenPoolSize -= bytesTxed;
1244  }
1245  else
1246  {
1247  (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
1248  (*itMax).second.tokenPoolSize = 0;
1249  if (bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
1250  bankSize = 0;
1251  else
1252  bankSize = bankSize - ( bytesTxed - (*itMax).second.tokenPoolSize );
1253  }
1254 
1255 
1256  // ...more parameters -> ignored in this version
1257 
1258  ret.m_buildDataList.push_back (newEl);
1259 
1260  itMap++;
1261  } // end while allocation
1262  ret.m_nrOfPdcchOfdmSymbols = 1;
1263 
1265 
1266 
1267  return;
1268 }
1269 
1270 void
1272 {
1273  NS_LOG_FUNCTION (this);
1274 
1275  m_rachList = params.m_rachList;
1276 
1277  return;
1278 }
1279 
1280 void
1282 {
1283  NS_LOG_FUNCTION (this);
1285 
1286  for (unsigned int i = 0; i < params.m_cqiList.size (); i++)
1287  {
1288  if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
1289  {
1290  NS_LOG_LOGIC ("wideband CQI " << (uint32_t) params.m_cqiList.at (i).m_wbCqi.at (0) << " reported");
1291  std::map <uint16_t,uint8_t>::iterator it;
1292  uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1293  it = m_p10CqiRxed.find (rnti);
1294  if (it == m_p10CqiRxed.end ())
1295  {
1296  // create the new entry
1297  m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) ); // only codeword 0 at this stage (SISO)
1298  // generate correspondent timer
1299  m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1300  }
1301  else
1302  {
1303  // update the CQI value and refresh correspondent timer
1304  (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
1305  // update correspondent timer
1306  std::map <uint16_t,uint32_t>::iterator itTimers;
1307  itTimers = m_p10CqiTimers.find (rnti);
1308  (*itTimers).second = m_cqiTimersThreshold;
1309  }
1310  }
1311  else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
1312  {
1313  // subband CQI reporting high layer configured
1314  std::map <uint16_t,SbMeasResult_s>::iterator it;
1315  uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1316  it = m_a30CqiRxed.find (rnti);
1317  if (it == m_a30CqiRxed.end ())
1318  {
1319  // create the new entry
1320  m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
1321  m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1322  }
1323  else
1324  {
1325  // update the CQI value and refresh correspondent timer
1326  (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
1327  std::map <uint16_t,uint32_t>::iterator itTimers;
1328  itTimers = m_a30CqiTimers.find (rnti);
1329  (*itTimers).second = m_cqiTimersThreshold;
1330  }
1331  }
1332  else
1333  {
1334  NS_LOG_ERROR (this << " CQI type unknown");
1335  }
1336  }
1337 
1338  return;
1339 }
1340 
1341 
1342 double
1343 TdTbfqFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
1344 {
1345  std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
1346  if (itCqi == m_ueCqi.end ())
1347  {
1348  // no cqi info about this UE
1349  return (NO_SINR);
1350 
1351  }
1352  else
1353  {
1354  // take the average SINR value among the available
1355  double sinrSum = 0;
1356  unsigned int sinrNum = 0;
1357  for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1358  {
1359  double sinr = (*itCqi).second.at (i);
1360  if (sinr != NO_SINR)
1361  {
1362  sinrSum += sinr;
1363  sinrNum++;
1364  }
1365  }
1366  double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1367  // store the value
1368  (*itCqi).second.at (rb) = estimatedSinr;
1369  return (estimatedSinr);
1370  }
1371 }
1372 
1373 void
1375 {
1376  NS_LOG_FUNCTION (this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size ());
1377 
1378  RefreshUlCqiMaps ();
1380 
1381  // Generate RBs map
1383  std::vector <bool> rbMap;
1384  uint16_t rbAllocatedNum = 0;
1385  std::set <uint16_t> rntiAllocated;
1386  std::vector <uint16_t> rbgAllocationMap;
1387  // update with RACH allocation map
1388  rbgAllocationMap = m_rachAllocationMap;
1389  //rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1390  m_rachAllocationMap.clear ();
1392 
1393  rbMap.resize (m_cschedCellConfig.m_ulBandwidth, false);
1394 
1395  rbMap = m_ffrSapProvider->GetAvailableUlRbg ();
1396 
1397  for (std::vector<bool>::iterator it = rbMap.begin (); it != rbMap.end (); it++)
1398  {
1399  if ((*it) == true )
1400  {
1401  rbAllocatedNum++;
1402  }
1403  }
1404 
1405  uint8_t minContinuousUlBandwidth = m_ffrSapProvider->GetMinContinuousUlBandwidth ();
1406  uint8_t ffrUlBandwidth = m_cschedCellConfig.m_ulBandwidth - rbAllocatedNum;
1407 
1408  // remove RACH allocation
1409  for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1410  {
1411  if (rbgAllocationMap.at (i) != 0)
1412  {
1413  rbMap.at (i) = true;
1414  NS_LOG_DEBUG (this << " Allocated for RACH " << i);
1415  }
1416  }
1417 
1418 
1419  if (m_harqOn == true)
1420  {
1421  // Process UL HARQ feedback
1422  for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
1423  {
1424  if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
1425  {
1426  // retx correspondent block: retrieve the UL-DCI
1427  uint16_t rnti = params.m_ulInfoList.at (i).m_rnti;
1428  std::map <uint16_t, uint8_t>::iterator itProcId = m_ulHarqCurrentProcessId.find (rnti);
1429  if (itProcId == m_ulHarqCurrentProcessId.end ())
1430  {
1431  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1432  }
1433  uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1434  NS_LOG_INFO (this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size ());
1435  std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
1436  if (itHarq == m_ulHarqProcessesDciBuffer.end ())
1437  {
1438  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1439  continue;
1440  }
1441  UlDciListElement_s dci = (*itHarq).second.at (harqId);
1442  std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (rnti);
1443  if (itStat == m_ulHarqProcessesStatus.end ())
1444  {
1445  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1446  }
1447  if ((*itStat).second.at (harqId) >= 3)
1448  {
1449  NS_LOG_INFO ("Max number of retransmissions reached (UL)-> drop process");
1450  continue;
1451  }
1452  bool free = true;
1453  for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1454  {
1455  if (rbMap.at (j) == true)
1456  {
1457  free = false;
1458  NS_LOG_INFO (this << " BUSY " << j);
1459  }
1460  }
1461  if (free)
1462  {
1463  // retx on the same RBs
1464  for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1465  {
1466  rbMap.at (j) = true;
1467  rbgAllocationMap.at (j) = dci.m_rnti;
1468  NS_LOG_INFO ("\tRB " << j);
1469  rbAllocatedNum++;
1470  }
1471  NS_LOG_INFO (this << " Send retx in the same RBs " << (uint16_t)dci.m_rbStart << " to " << dci.m_rbStart + dci.m_rbLen << " RV " << (*itStat).second.at (harqId) + 1);
1472  }
1473  else
1474  {
1475  NS_LOG_INFO ("Cannot allocate retx due to RACH allocations for UE " << rnti);
1476  continue;
1477  }
1478  dci.m_ndi = 0;
1479  // Update HARQ buffers with new HarqId
1480  (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1481  (*itStat).second.at (harqId) = 0;
1482  (*itHarq).second.at ((*itProcId).second) = dci;
1483  ret.m_dciList.push_back (dci);
1484  rntiAllocated.insert (dci.m_rnti);
1485  }
1486  else
1487  {
1488  NS_LOG_INFO (this << " HARQ-ACK feedback from RNTI " << params.m_ulInfoList.at (i).m_rnti);
1489  }
1490  }
1491  }
1492 
1493  std::map <uint16_t,uint32_t>::iterator it;
1494  int nflows = 0;
1495 
1496  for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1497  {
1498  std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1499  // select UEs with queues not empty and not yet allocated for HARQ
1500  if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1501  {
1502  nflows++;
1503  }
1504  }
1505 
1506  if (nflows == 0)
1507  {
1508  if (ret.m_dciList.size () > 0)
1509  {
1510  m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1512  }
1513 
1514  return; // no flows to be scheduled
1515  }
1516 
1517 
1518  // Divide the remaining resources equally among the active users starting from the subsequent one served last scheduling trigger
1519  uint16_t tempRbPerFlow = (ffrUlBandwidth) / (nflows + rntiAllocated.size ());
1520  uint16_t rbPerFlow = (minContinuousUlBandwidth < tempRbPerFlow) ? minContinuousUlBandwidth : tempRbPerFlow;
1521 
1522  if (rbPerFlow < 3)
1523  {
1524  rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity >= 7 bytes
1525  }
1526  int rbAllocated = 0;
1527 
1528  std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1529  if (m_nextRntiUl != 0)
1530  {
1531  for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1532  {
1533  if ((*it).first == m_nextRntiUl)
1534  {
1535  break;
1536  }
1537  }
1538  if (it == m_ceBsrRxed.end ())
1539  {
1540  NS_LOG_ERROR (this << " no user found");
1541  }
1542  }
1543  else
1544  {
1545  it = m_ceBsrRxed.begin ();
1546  m_nextRntiUl = (*it).first;
1547  }
1548  do
1549  {
1550  std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1551  if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1552  {
1553  // UE already allocated for UL-HARQ -> skip it
1554  NS_LOG_DEBUG (this << " UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1555  it++;
1556  if (it == m_ceBsrRxed.end ())
1557  {
1558  // restart from the first
1559  it = m_ceBsrRxed.begin ();
1560  }
1561  continue;
1562  }
1563  if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1564  {
1565  // limit to physical resources last resource assignment
1566  rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1567  // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1568  if (rbPerFlow < 3)
1569  {
1570  // terminate allocation
1571  rbPerFlow = 0;
1572  }
1573  }
1574 
1575  rbAllocated = 0;
1576  UlDciListElement_s uldci;
1577  uldci.m_rnti = (*it).first;
1578  uldci.m_rbLen = rbPerFlow;
1579  bool allocated = false;
1580  NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows);
1581  while ((!allocated)&&((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) && (rbPerFlow != 0))
1582  {
1583  // check availability
1584  bool free = true;
1585  for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1586  {
1587  if (rbMap.at (j) == true)
1588  {
1589  free = false;
1590  break;
1591  }
1592  if ((m_ffrSapProvider->IsUlRbgAvailableForUe (j, (*it).first)) == false)
1593  {
1594  free = false;
1595  break;
1596  }
1597  }
1598  if (free)
1599  {
1600  NS_LOG_INFO (this << "RNTI: "<< (*it).first<< " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows);
1601  uldci.m_rbStart = rbAllocated;
1602 
1603  for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1604  {
1605  rbMap.at (j) = true;
1606  // store info on allocation for managing ul-cqi interpretation
1607  rbgAllocationMap.at (j) = (*it).first;
1608  }
1609  rbAllocated += rbPerFlow;
1610  allocated = true;
1611  break;
1612  }
1613  rbAllocated++;
1614  if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1615  {
1616  // limit to physical resources last resource assignment
1617  rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1618  // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1619  if (rbPerFlow < 3)
1620  {
1621  // terminate allocation
1622  rbPerFlow = 0;
1623  }
1624  }
1625  }
1626  if (!allocated)
1627  {
1628  // unable to allocate new resource: finish scheduling
1629 // m_nextRntiUl = (*it).first;
1630 // if (ret.m_dciList.size () > 0)
1631 // {
1632 // m_schedSapUser->SchedUlConfigInd (ret);
1633 // }
1634 // m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1635 // return;
1636  break;
1637  }
1638 
1639 
1640 
1641  std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
1642  int cqi = 0;
1643  if (itCqi == m_ueCqi.end ())
1644  {
1645  // no cqi info about this UE
1646  uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1647  }
1648  else
1649  {
1650  // take the lowest CQI value (worst RB)
1651  double minSinr = (*itCqi).second.at (uldci.m_rbStart);
1652  if (minSinr == NO_SINR)
1653  {
1654  minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
1655  }
1656  for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1657  {
1658  double sinr = (*itCqi).second.at (i);
1659  if (sinr == NO_SINR)
1660  {
1661  sinr = EstimateUlSinr ((*it).first, i);
1662  }
1663  if (sinr < minSinr)
1664  {
1665  minSinr = sinr;
1666  }
1667  }
1668 
1669  // translate SINR -> cqi: WILD ACK: same as DL
1670  double s = log2 ( 1 + (
1671  std::pow (10, minSinr / 10 ) /
1672  ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1673  cqi = m_amc->GetCqiFromSpectralEfficiency (s);
1674  if (cqi == 0)
1675  {
1676  it++;
1677  if (it == m_ceBsrRxed.end ())
1678  {
1679  // restart from the first
1680  it = m_ceBsrRxed.begin ();
1681  }
1682  NS_LOG_DEBUG (this << " UE discared for CQI=0, RNTI " << uldci.m_rnti);
1683  // remove UE from allocation map
1684  for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1685  {
1686  rbgAllocationMap.at (i) = 0;
1687  }
1688  continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1689  }
1690  uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
1691  }
1692 
1693  uldci.m_tbSize = (m_amc->GetUlTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
1694  UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
1695  uldci.m_ndi = 1;
1696  uldci.m_cceIndex = 0;
1697  uldci.m_aggrLevel = 1;
1698  uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1699  uldci.m_hopping = false;
1700  uldci.m_n2Dmrs = 0;
1701  uldci.m_tpc = 0; // no power control
1702  uldci.m_cqiRequest = false; // only period CQI at this stage
1703  uldci.m_ulIndex = 0; // TDD parameter
1704  uldci.m_dai = 1; // TDD parameter
1705  uldci.m_freqHopping = 0;
1706  uldci.m_pdcchPowerOffset = 0; // not used
1707  ret.m_dciList.push_back (uldci);
1708  // store DCI for HARQ_PERIOD
1709  uint8_t harqId = 0;
1710  if (m_harqOn == true)
1711  {
1712  std::map <uint16_t, uint8_t>::iterator itProcId;
1713  itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
1714  if (itProcId == m_ulHarqCurrentProcessId.end ())
1715  {
1716  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << uldci.m_rnti);
1717  }
1718  harqId = (*itProcId).second;
1719  std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
1720  if (itDci == m_ulHarqProcessesDciBuffer.end ())
1721  {
1722  NS_FATAL_ERROR ("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
1723  }
1724  (*itDci).second.at (harqId) = uldci;
1725  // Update HARQ process status (RV 0)
1726  std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (uldci.m_rnti);
1727  if (itStat == m_ulHarqProcessesStatus.end ())
1728  {
1729  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << uldci.m_rnti);
1730  }
1731  (*itStat).second.at (harqId) = 0;
1732  }
1733 
1734  NS_LOG_INFO (this << " UE Allocation RNTI " << (*it).first << " startPRB " << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize " << uldci.m_tbSize << " RbAlloc " << rbAllocated << " harqId " << (uint16_t)harqId);
1735 
1736  it++;
1737  if (it == m_ceBsrRxed.end ())
1738  {
1739  // restart from the first
1740  it = m_ceBsrRxed.begin ();
1741  }
1742  if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1743  {
1744  // Stop allocation: no more PRBs
1745  m_nextRntiUl = (*it).first;
1746  break;
1747  }
1748  }
1749  while (((*it).first != m_nextRntiUl)&&(rbPerFlow!=0));
1750 
1751 
1752  m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1754 
1755  return;
1756 }
1757 
1758 void
1760 {
1761  NS_LOG_FUNCTION (this);
1762  return;
1763 }
1764 
1765 void
1767 {
1768  NS_LOG_FUNCTION (this);
1769  return;
1770 }
1771 
1772 void
1774 {
1775  NS_LOG_FUNCTION (this);
1776 
1777  std::map <uint16_t,uint32_t>::iterator it;
1778 
1779  for (unsigned int i = 0; i < params.m_macCeList.size (); i++)
1780  {
1781  if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
1782  {
1783  // buffer status report
1784  // note that this scheduler does not differentiate the
1785  // allocation according to which LCGs have more/less bytes
1786  // to send.
1787  // Hence the BSR of different LCGs are just summed up to get
1788  // a total queue size that is used for allocation purposes.
1789 
1790  uint32_t buffer = 0;
1791  for (uint8_t lcg = 0; lcg < 4; ++lcg)
1792  {
1793  uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1794  buffer += BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
1795  }
1796 
1797  uint16_t rnti = params.m_macCeList.at (i).m_rnti;
1798  NS_LOG_LOGIC (this << "RNTI=" << rnti << " buffer=" << buffer);
1799  it = m_ceBsrRxed.find (rnti);
1800  if (it == m_ceBsrRxed.end ())
1801  {
1802  // create the new entry
1803  m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1804  }
1805  else
1806  {
1807  // update the buffer size value
1808  (*it).second = buffer;
1809  }
1810  }
1811  }
1812 
1813  return;
1814 }
1815 
1816 void
1818 {
1819  NS_LOG_FUNCTION (this);
1820 // retrieve the allocation for this subframe
1821  switch (m_ulCqiFilter)
1822  {
1824  {
1825  // filter all the CQIs that are not SRS based
1826  if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1827  {
1828  return;
1829  }
1830  }
1831  break;
1833  {
1834  // filter all the CQIs that are not SRS based
1835  if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1836  {
1837  return;
1838  }
1839  }
1841  break;
1842 
1843  default:
1844  NS_FATAL_ERROR ("Unknown UL CQI type");
1845  }
1846 
1847  switch (params.m_ulCqi.m_type)
1848  {
1849  case UlCqi_s::PUSCH:
1850  {
1851  std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1852  std::map <uint16_t, std::vector <double> >::iterator itCqi;
1853  NS_LOG_DEBUG (this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
1854  itMap = m_allocationMaps.find (params.m_sfnSf);
1855  if (itMap == m_allocationMaps.end ())
1856  {
1857  return;
1858  }
1859  for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1860  {
1861  // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1862  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
1863  itCqi = m_ueCqi.find ((*itMap).second.at (i));
1864  if (itCqi == m_ueCqi.end ())
1865  {
1866  // create a new entry
1867  std::vector <double> newCqi;
1868  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1869  {
1870  if (i == j)
1871  {
1872  newCqi.push_back (sinr);
1873  }
1874  else
1875  {
1876  // initialize with NO_SINR value.
1877  newCqi.push_back (NO_SINR);
1878  }
1879 
1880  }
1881  m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
1882  // generate correspondent timer
1883  m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
1884  }
1885  else
1886  {
1887  // update the value
1888  (*itCqi).second.at (i) = sinr;
1889  NS_LOG_DEBUG (this << " RNTI " << (*itMap).second.at (i) << " RB " << i << " SINR " << sinr);
1890  // update correspondent timer
1891  std::map <uint16_t, uint32_t>::iterator itTimers;
1892  itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
1893  (*itTimers).second = m_cqiTimersThreshold;
1894 
1895  }
1896 
1897  }
1898  // remove obsolete info on allocation
1899  m_allocationMaps.erase (itMap);
1900  }
1901  break;
1902  case UlCqi_s::SRS:
1903  {
1904  // get the RNTI from vendor specific parameters
1905  uint16_t rnti = 0;
1906  NS_ASSERT (params.m_vendorSpecificList.size () > 0);
1907  for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
1908  {
1909  if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
1910  {
1911  Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
1912  rnti = vsp->GetRnti ();
1913  }
1914  }
1915  std::map <uint16_t, std::vector <double> >::iterator itCqi;
1916  itCqi = m_ueCqi.find (rnti);
1917  if (itCqi == m_ueCqi.end ())
1918  {
1919  // create a new entry
1920  std::vector <double> newCqi;
1921  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1922  {
1923  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1924  newCqi.push_back (sinr);
1925  NS_LOG_INFO (this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value " << sinr);
1926 
1927  }
1928  m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
1929  // generate correspondent timer
1930  m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1931  }
1932  else
1933  {
1934  // update the values
1935  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1936  {
1937  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1938  (*itCqi).second.at (j) = sinr;
1939  NS_LOG_INFO (this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value " << sinr);
1940  }
1941  // update correspondent timer
1942  std::map <uint16_t, uint32_t>::iterator itTimers;
1943  itTimers = m_ueCqiTimers.find (rnti);
1944  (*itTimers).second = m_cqiTimersThreshold;
1945 
1946  }
1947 
1948 
1949  }
1950  break;
1951  case UlCqi_s::PUCCH_1:
1952  case UlCqi_s::PUCCH_2:
1953  case UlCqi_s::PRACH:
1954  {
1955  NS_FATAL_ERROR ("TdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1956  }
1957  break;
1958  default:
1959  NS_FATAL_ERROR ("Unknown type of UL-CQI");
1960  }
1961  return;
1962 }
1963 
1964 void
1966 {
1967  // refresh DL CQI P01 Map
1968  std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
1969  while (itP10 != m_p10CqiTimers.end ())
1970  {
1971  NS_LOG_INFO (this << " P10-CQI for user " << (*itP10).first << " is " << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1972  if ((*itP10).second == 0)
1973  {
1974  // delete correspondent entries
1975  std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
1976  NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (), " Does not find CQI report for user " << (*itP10).first);
1977  NS_LOG_INFO (this << " P10-CQI expired for user " << (*itP10).first);
1978  m_p10CqiRxed.erase (itMap);
1979  std::map <uint16_t,uint32_t>::iterator temp = itP10;
1980  itP10++;
1981  m_p10CqiTimers.erase (temp);
1982  }
1983  else
1984  {
1985  (*itP10).second--;
1986  itP10++;
1987  }
1988  }
1989 
1990  // refresh DL CQI A30 Map
1991  std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
1992  while (itA30 != m_a30CqiTimers.end ())
1993  {
1994  NS_LOG_INFO (this << " A30-CQI for user " << (*itA30).first << " is " << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1995  if ((*itA30).second == 0)
1996  {
1997  // delete correspondent entries
1998  std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
1999  NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (), " Does not find CQI report for user " << (*itA30).first);
2000  NS_LOG_INFO (this << " A30-CQI expired for user " << (*itA30).first);
2001  m_a30CqiRxed.erase (itMap);
2002  std::map <uint16_t,uint32_t>::iterator temp = itA30;
2003  itA30++;
2004  m_a30CqiTimers.erase (temp);
2005  }
2006  else
2007  {
2008  (*itA30).second--;
2009  itA30++;
2010  }
2011  }
2012 
2013  return;
2014 }
2015 
2016 
2017 void
2019 {
2020  // refresh UL CQI Map
2021  std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
2022  while (itUl != m_ueCqiTimers.end ())
2023  {
2024  NS_LOG_INFO (this << " UL-CQI for user " << (*itUl).first << " is " << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2025  if ((*itUl).second == 0)
2026  {
2027  // delete correspondent entries
2028  std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
2029  NS_ASSERT_MSG (itMap != m_ueCqi.end (), " Does not find CQI report for user " << (*itUl).first);
2030  NS_LOG_INFO (this << " UL-CQI exired for user " << (*itUl).first);
2031  (*itMap).second.clear ();
2032  m_ueCqi.erase (itMap);
2033  std::map <uint16_t,uint32_t>::iterator temp = itUl;
2034  itUl++;
2035  m_ueCqiTimers.erase (temp);
2036  }
2037  else
2038  {
2039  (*itUl).second--;
2040  itUl++;
2041  }
2042  }
2043 
2044  return;
2045 }
2046 
2047 void
2048 TdTbfqFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
2049 {
2050  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2051  LteFlowId_t flow (rnti, lcid);
2052  it = m_rlcBufferReq.find (flow);
2053  if (it != m_rlcBufferReq.end ())
2054  {
2055  NS_LOG_INFO (this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " << (*it).second.m_rlcTransmissionQueueSize << " retxqueue " << (*it).second.m_rlcRetransmissionQueueSize << " status " << (*it).second.m_rlcStatusPduSize << " decrease " << size);
2056  // Update queues: RLC tx order Status, ReTx, Tx
2057  // Update status queue
2058  if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2059  {
2060  (*it).second.m_rlcStatusPduSize = 0;
2061  }
2062  else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2063  {
2064  (*it).second.m_rlcRetransmissionQueueSize = 0;
2065  }
2066  else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2067  {
2068  uint32_t rlcOverhead;
2069  if (lcid == 1)
2070  {
2071  // for SRB1 (using RLC AM) it's better to
2072  // overestimate RLC overhead rather than
2073  // underestimate it and risk unneeded
2074  // segmentation which increases delay
2075  rlcOverhead = 4;
2076  }
2077  else
2078  {
2079  // minimum RLC overhead due to header
2080  rlcOverhead = 2;
2081  }
2082  // update transmission queue
2083  if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2084  {
2085  (*it).second.m_rlcTransmissionQueueSize = 0;
2086  }
2087  else
2088  {
2089  (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2090  }
2091  }
2092  }
2093  else
2094  {
2095  NS_LOG_ERROR (this << " Does not find DL RLC Buffer Report of UE " << rnti);
2096  }
2097 }
2098 
2099 void
2100 TdTbfqFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
2101 {
2102 
2103  size = size - 2; // remove the minimum RLC overhead
2104  std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
2105  if (it != m_ceBsrRxed.end ())
2106  {
2107  NS_LOG_INFO (this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
2108  if ((*it).second >= size)
2109  {
2110  (*it).second -= size;
2111  }
2112  else
2113  {
2114  (*it).second = 0;
2115  }
2116  }
2117  else
2118  {
2119  NS_LOG_ERROR (this << " Does not find BSR report info of UE " << rnti);
2120  }
2121 
2122 }
2123 
2124 void
2126 {
2127  NS_LOG_FUNCTION (this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
2129  params.m_rnti = rnti;
2130  params.m_transmissionMode = txMode;
2132 }
2133 
2134 
2135 }
void DoSchedUlNoiseInterferenceReq(const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
Sched UL noise interference request.
void RefreshUlCqiMaps(void)
Refresh UL CQI maps function.
std::vector< struct UlInfoListElement_s > m_ulInfoList
UL info list.
See section 4.3.1 dlDciListElement.
Definition: ff-mac-common.h:93
void DoCschedLcReleaseReq(const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
CSched LC release request.
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
DL HARQ current process ID.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Definition: lte-ffr-sap.h:138
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void DoDispose(void)
Destructor implementation.
void DoSchedDlRlcBufferReq(const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Sched DL RLC buffer request.
#define HARQ_PERIOD
Definition: lte-common.h:30
AttributeValue implementation for Boolean.
Definition: boolean.h:36
Time flowStart
flow start time
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void DoCschedUeConfigReq(const struct FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
CSched UE config request.
virtual void ReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)=0
ReportUlCqiInfo.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint32_t m_creditLimit
flow credit limit (byte)
Parameters of the CSCHED_UE_CONFIG_CNF primitive.
Parameters of the CSCHED_UE_RELEASE_REQ primitive.
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
void DoSchedDlRachInfoReq(const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
Sched DL RACH info request.
virtual bool IsDlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in DL.
uint32_t burstCredit
the maximum number of tokens connection i can borrow from the bank each time
virtual bool IsUlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in UL.
FfMacSchedSapProvider * m_schedSapProvider
Sched SAP provider.
enum ns3::UlCqi_s::Type_e m_type
type
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:84
std::vector< UlDciListElement_s > UlHarqProcessesDciBuffer_t
UL HARQ process DCI buffer vector.
uint32_t maxTokenPoolSize
maximum size of token pool (byte)
std::vector< struct LogicalChannelConfigListElement_s > m_logicalChannelConfigList
logicalChannelConfigList
std::vector< uint16_t > m_sinr
SINR.
uint16_t m_rnti
RNTI.
Definition: ff-mac-common.h:95
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
Estimate UL SINR function.
std::vector< uint8_t > DlHarqProcessesTimer_t
DL HARQ process timer vector typedef.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
virtual ~TdTbfqFfMacScheduler()
Destructor.
Hold a signed integer type.
Definition: integer.h:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
unsigned int LcActivePerFlow(uint16_t rnti)
LC active flow size.
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
std::vector< uint8_t > m_mcs
mcs
See section 4.3.2 ulDciListElement.
Provides the CSCHED SAP.
std::vector< struct UlDciListElement_s > m_dciList
DCI list.
void DoCschedLcConfigReq(const struct FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
CSched LC config request.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:278
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
See section 4.3.10 buildRARListElement.
Parameters of the CSCHED_UE_CONFIG_UPDATE_IND primitive.
Parameters of the CSCHED_LC_RELEASE_REQ primitive.
int counter
the number of token borrow or given to token bank
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmission mde configuration update function.
virtual uint8_t GetTpc(uint16_t rnti)=0
GetTpc.
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
Vectors of UE&#39;s LC info.
std::vector< std::vector< struct RlcPduListElement_s > > m_rlcPduList
RLC PDU list.
Implements the SCHED SAP and CSCHED SAP for a Time Domain Token Bank Fair Queue scheduler.
std::vector< struct RachListElement_s > m_rachList
RACH list.
Parameters of the SCHED_DL_TRIGGER_REQ primitive.
uint8_t m_rbLen
length
FfMacCschedSapUser * m_cschedSapUser
CSched SAP user.
uint8_t m_harqProcess
HARQ process.
void DoSchedUlTriggerReq(const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
Sched UL trigger request.
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
DL HARQ process timer.
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: integer.h:45
void RefreshDlCqiMaps(void)
Refresh DL CQI maps function.
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
vector of the 8 HARQ processes per UE
Parameters of the SCHED_DL_MAC_BUFFER_REQ primitive.
Parameters of the SCHED_DL_PAGING_BUFFER_REQ primitive.
virtual void CschedUeConfigUpdateInd(const struct CschedUeConfigUpdateIndParameters &params)=0
CSCHED_UE_UPDATE_IND.
void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
Sched UL SR info request.
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
vendor specific list
uint8_t m_aggrLevel
aggr level
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
Map of previous allocated UE per RBG (used to retrieve info from UL-CQI)
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Definition: lte-ffr-sap.h:39
Parameters of the SCHED_UL_TRIGGER_REQ primitive.
int debtLimit
counter threshold that the flow cannot further borrow tokens from bank
uint32_t m_rbBitmap
rb bitmap
Definition: ff-mac-common.h:96
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual void SetLteFfrSapProvider(LteFfrSapProvider *s)
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
static uint8_t TxMode2LayerNum(uint8_t txMode)
Transmit mode 2 layer number.
Definition: lte-common.cc:212
std::map< uint16_t, uint32_t > m_a30CqiTimers
Map of UE&#39;s timers on DL CQI A30 received.
bool m_cqiRequest
CQI request.
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
Update DL RLC buffer info function.
std::vector< uint8_t > m_ndi
ndi
uint8_t m_cceIndex
CCE index.
Provides the SCHED SAP.
uint16_t m_nextRntiUl
RNTI of the next user to be served next scheduling in UL.
void DoSchedDlCqiInfoReq(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
Sched DL CQI info request.
void DoSchedDlMacBufferReq(const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
Sched DL MAC buffer request.
virtual void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters &params)=0
CSCHED_UE_CONFIG_CNF.
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
UL HARQ process DCI buffer.
std::vector< uint8_t > m_logicalChannelIdentity
logical channel identity
Parameters of the SCHED_UL_NOISE_INTERFERENCE_REQ primitive.
uint8_t m_logicalChannelIdentity
logical channel indentity
std::vector< struct CqiListElement_s > m_cqiList
CQI list.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
DL HARQ process RLC PDU list buffer.
std::vector< struct DlInfoListElement_s > m_dlInfoList
DL info list.
FfMacSchedSapUser * m_schedSapUser
A=Sched SAP user.
virtual void ReportDlCqiInfo(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)=0
ReportDlCqiInfo.
virtual LteFfrSapUser * GetLteFfrSapUser()
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
DL HARQ process status.
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
virtual void SchedDlConfigInd(const struct SchedDlConfigIndParameters &params)=0
SCHED_DL_CONFIG_IND.
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
set the user part of the FfMacSchedSap that this Scheduler will interact with.
int8_t m_pdcchPowerOffset
CCH power offset.
std::vector< uint16_t > m_tbsSize
tbs size
Definition: ff-mac-common.h:99
See section 4.3.9 rlcPDU_ListElement.
uint64_t tokenGenerationRate
token generation rate ( byte/s )
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< uint16_t, std::vector< double > > m_ueCqi
Map of UEs&#39; UL-CQI per RBG.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint8_t m_freqHopping
freq hopping
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
DL HARQ process DCI buffer vector typedef.
Parameters of the CSCHED_LC_CONFIG_REQ primitive.
std::vector< uint8_t > m_rv
rv
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
Map of UE&#39;s DL CQI A30 received.
std::map< uint16_t, uint8_t > m_p10CqiRxed
Map of UE&#39;s DL CQI P01 received.
MemberCschedSapProvider class.
virtual std::vector< bool > GetAvailableUlRbg()=0
Get vector of available RB in UL for this Cell.
virtual uint8_t GetMinContinuousUlBandwidth()=0
Get the minimum continuous Ul bandwidth.
virtual void SchedUlConfigInd(const struct SchedUlConfigIndParameters &params)=0
SCHED_UL_CONFIG_IND.
uint8_t m_ulIndex
UL index.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
HARQ retx buffered.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint32_t creditableThreshold
the flow cannot borrow token from bank until the number of token it has deposited to bank reaches thi...
UlCqiFilter_t m_ulCqiFilter
UL CQI filter.
uint32_t tokenPoolSize
current size of token pool (byte)
#define SRS_CQI_RNTI_VSP
This abstract base class identifies the interface by means of which the helper object can plug on the...
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
set the user part of the FfMacCschedSap that this Scheduler will interact with.
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
FfMacCschedSapUser class.
uint8_t m_nrOfPdcchOfdmSymbols
number of PDCCH OFDM symbols
void DoCschedUeReleaseReq(const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
CSched UE release request.
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
std::vector< struct MacCeListElement_s > m_macCeList
MAC CE list.
std::map< uint16_t, tdtbfqsFlowPerf_t > m_flowStatsDl
Map of UE statistics (per RNTI basis) in downlink.
std::vector< struct RachListElement_s > m_rachList
RACH list.
static double fpS11dot3toDouble(uint16_t val)
Convert from fixed point S11.3 notation to double.
Definition: lte-common.cc:155
bool m_harqOn
m_harqOn when false inhibit the HARQ mechanisms (by default active)
uint8_t m_n2Dmrs
n2 DMRS
static const int TdTbfqType0AllocationRbg[4]
TDTBFQ type 0 allocation RBG.
std::map< uint16_t, uint8_t > m_uesTxMode
txMode of the UEs
std::vector< uint8_t > UlHarqProcessesStatus_t
UL HARQ process status vector.
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
Update UL RLC buffer info function.
std::map< uint16_t, uint32_t > m_ueCqiTimers
Map of UEs&#39; timers on UL-CQI per RBG.
std::vector< uint8_t > DlHarqProcessesStatus_t
DL HARQ process status vector typedef.
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
uint64_t bankSize
the number of bytes in token bank
static uint32_t BsrId2BufferSize(uint8_t val)
Convert BSR ID to buffer size.
Definition: lte-common.cc:184
Template for the implementation of the LteFfrSapUser as a member of an owner class of type C to which...
Definition: lte-ffr-sap.h:255
LteFlowId structure.
Definition: lte-common.h:36
Parameters of the SCHED_UL_MAC_CTRL_INFO_REQ primitive.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
virtual std::vector< bool > GetAvailableDlRbg()=0
Get vector of available RBG in DL for this Cell.
uint32_t m_cqiTimersThreshold
of TTIs for which a CQI can be considered valid
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
CSched cell config.
Parameters of the SCHED_UL_SR_INFO_REQ primitive.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
void DoSchedUlCqiInfoReq(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
Sched UL CQI info request.
void DoCschedCellConfigReq(const struct FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
CSched cell config request.
FfMacCschedSapProvider * m_cschedSapProvider
CSched SAP provider.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
DL HARQ process DCI buffer.
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
Parameters of the SCHED_DL_RACH_INFO_REQ primitive.
uint32_t m_creditableThreshold
threshold of flow credit
Parameters of the SCHED_UL_CONFIG_IND primitive.
void DoSchedDlPagingBufferReq(const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
Sched DL paging buffer request.
MemberSchedSapProvider class.
Parameters of the CSCHED_UE_CONFIG_REQ primitive.
#define HARQ_DL_TIMEOUT
uint64_t packetArrivalRate
packet arrival rate( byte/s)
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
int m_debtLimit
flow debt limit (byte)
#define NO_SINR
void DoSchedUlMacCtrlInfoReq(const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
Sched UL MAC control info request.
std::vector< uint16_t > m_rachAllocationMap
RACH allocation map.
struct DlDciListElement_s m_dci
DCI.
std::vector< struct BuildRarListElement_s > m_buildRarList
build rar list
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
UL HARQ process status.
std::map< uint16_t, uint32_t > m_ceBsrRxed
Map of UE&#39;s buffer status reports received.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
uint8_t m_resAlloc
res allocate
Definition: ff-mac-common.h:98
void DoSchedDlTriggerReq(const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
Sched DL trigger request.
std::map< uint16_t, uint32_t > m_p10CqiTimers
Map of UE&#39;s timers on DL CQI P01 received.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
uint32_t m_tokenPoolSize
maximum size of token pool (byte)
int GetRbgSize(int dlbandwidth)
Get RBG size.
#define HARQ_PROC_NUM
FfMacSchedSapUser class.
uint8_t m_ulGrantMcs
MCS for UL grant (default 0)
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
UL HARQ current process ID.
std::vector< struct BuildDataListElement_s > m_buildDataList
build data list
std::map< uint16_t, tdtbfqsFlowPerf_t > m_flowStatsUl
Map of UE statistics (per RNTI basis)
uint8_t m_ueTxAntennaSelection
UE antenna selection.
static TypeId GetTypeId(void)
Get the type ID.
See section 4.3.8 builDataListElement.