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