A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pss-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/pss-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
31 #include <cfloat>
32 #include <set>
33 #include <ns3/string.h>
34 #include <algorithm>
35 
36 
37 NS_LOG_COMPONENT_DEFINE ("PssFfMacScheduler");
38 
39 namespace ns3 {
40 
42  10, // RGB size 1
43  26, // RGB size 2
44  63, // RGB size 3
45  110 // RGB size 4
46 }; // see table 7.1.6.1-1 of 36.213
47 
48 
49 NS_OBJECT_ENSURE_REGISTERED (PssFfMacScheduler);
50 
51 
52 
54 {
55 public:
57 
58  // inherited from FfMacCschedSapProvider
59  virtual void CschedCellConfigReq (const struct CschedCellConfigReqParameters& params);
60  virtual void CschedUeConfigReq (const struct CschedUeConfigReqParameters& params);
61  virtual void CschedLcConfigReq (const struct CschedLcConfigReqParameters& params);
62  virtual void CschedLcReleaseReq (const struct CschedLcReleaseReqParameters& params);
63  virtual void CschedUeReleaseReq (const struct CschedUeReleaseReqParameters& params);
64 
65 private:
68 };
69 
71 {
72 }
73 
75 {
76 }
77 
78 
79 void
81 {
83 }
84 
85 void
87 {
89 }
90 
91 
92 void
94 {
96 }
97 
98 void
100 {
102 }
103 
104 void
106 {
108 }
109 
110 
111 
112 
114 {
115 public:
117 
118  // inherited from FfMacSchedSapProvider
119  virtual void SchedDlRlcBufferReq (const struct SchedDlRlcBufferReqParameters& params);
120  virtual void SchedDlPagingBufferReq (const struct SchedDlPagingBufferReqParameters& params);
121  virtual void SchedDlMacBufferReq (const struct SchedDlMacBufferReqParameters& params);
122  virtual void SchedDlTriggerReq (const struct SchedDlTriggerReqParameters& params);
123  virtual void SchedDlRachInfoReq (const struct SchedDlRachInfoReqParameters& params);
124  virtual void SchedDlCqiInfoReq (const struct SchedDlCqiInfoReqParameters& params);
125  virtual void SchedUlTriggerReq (const struct SchedUlTriggerReqParameters& params);
126  virtual void SchedUlNoiseInterferenceReq (const struct SchedUlNoiseInterferenceReqParameters& params);
127  virtual void SchedUlSrInfoReq (const struct SchedUlSrInfoReqParameters& params);
128  virtual void SchedUlMacCtrlInfoReq (const struct SchedUlMacCtrlInfoReqParameters& params);
129  virtual void SchedUlCqiInfoReq (const struct SchedUlCqiInfoReqParameters& params);
130 
131 
132 private:
135 };
136 
137 
138 
140 {
141 }
142 
143 
145  : m_scheduler (scheduler)
146 {
147 }
148 
149 void
151 {
153 }
154 
155 void
157 {
159 }
160 
161 void
163 {
165 }
166 
167 void
169 {
171 }
172 
173 void
175 {
177 }
178 
179 void
181 {
183 }
184 
185 void
187 {
189 }
190 
191 void
193 {
195 }
196 
197 void
199 {
201 }
202 
203 void
205 {
207 }
208 
209 void
211 {
213 }
214 
215 
216 
217 
218 
220  : m_cschedSapUser (0),
221  m_schedSapUser (0),
222  m_timeWindow (99.0),
223  m_nextRntiUl (0)
224 {
225  m_amc = CreateObject <LteAmc> ();
228 }
229 
231 {
232  NS_LOG_FUNCTION (this);
233 }
234 
235 void
237 {
238  NS_LOG_FUNCTION (this);
240  m_dlHarqProcessesTimer.clear ();
242  m_dlInfoListBuffered.clear ();
243  m_ulHarqCurrentProcessId.clear ();
244  m_ulHarqProcessesStatus.clear ();
246  delete m_cschedSapProvider;
247  delete m_schedSapProvider;
248 }
249 
250 TypeId
252 {
253  static TypeId tid = TypeId ("ns3::PssFfMacScheduler")
255  .AddConstructor<PssFfMacScheduler> ()
256  .AddAttribute ("CqiTimerThreshold",
257  "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
258  UintegerValue (1000),
259  MakeUintegerAccessor (&PssFfMacScheduler::m_cqiTimersThreshold),
260  MakeUintegerChecker<uint32_t> ())
261  .AddAttribute ("PssFdSchedulerType",
262  "FD scheduler in PSS (default value is PFsch)",
263  StringValue ("PFsch"),
264  MakeStringAccessor (&PssFfMacScheduler::m_fdSchedulerType),
265  MakeStringChecker ())
266  .AddAttribute ("nMux",
267  "The number of UE selected by TD scheduler (default value is 0)",
268  UintegerValue (0),
269  MakeUintegerAccessor (&PssFfMacScheduler::m_nMux),
270  MakeUintegerChecker<uint32_t> ())
271  .AddAttribute ("HarqEnabled",
272  "Activate/Deactivate the HARQ [by default is active].",
273  BooleanValue (true),
274  MakeBooleanAccessor (&PssFfMacScheduler::m_harqOn),
275  MakeBooleanChecker ())
276  .AddAttribute ("UlGrantMcs",
277  "The MCS of the UL grant, must be [0..15] (default 0)",
278  UintegerValue (0),
279  MakeUintegerAccessor (&PssFfMacScheduler::m_ulGrantMcs),
280  MakeUintegerChecker<uint8_t> ())
281  ;
282  return tid;
283 }
284 
285 
286 
287 void
289 {
290  m_cschedSapUser = s;
291 }
292 
293 void
295 {
296  m_schedSapUser = s;
297 }
298 
301 {
302  return m_cschedSapProvider;
303 }
304 
307 {
308  return m_schedSapProvider;
309 }
310 
311 void
313 {
314  NS_LOG_FUNCTION (this);
315  // Read the subset of parameters used
316  m_cschedCellConfig = params;
319  cnf.m_result = SUCCESS;
321  return;
322 }
323 
324 void
326 {
327  NS_LOG_FUNCTION (this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode);
328  std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
329  if (it == m_uesTxMode.end ())
330  {
331  m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
332  // generate HARQ buffers
333  m_dlHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
334  DlHarqProcessesStatus_t dlHarqPrcStatus;
335  dlHarqPrcStatus.resize (8,0);
336  m_dlHarqProcessesStatus.insert (std::pair <uint16_t, DlHarqProcessesStatus_t> (params.m_rnti, dlHarqPrcStatus));
337  DlHarqProcessesTimer_t dlHarqProcessesTimer;
338  dlHarqProcessesTimer.resize (8,0);
339  m_dlHarqProcessesTimer.insert (std::pair <uint16_t, DlHarqProcessesTimer_t> (params.m_rnti, dlHarqProcessesTimer));
340  DlHarqProcessesDciBuffer_t dlHarqdci;
341  dlHarqdci.resize (8);
342  m_dlHarqProcessesDciBuffer.insert (std::pair <uint16_t, DlHarqProcessesDciBuffer_t> (params.m_rnti, dlHarqdci));
343  DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
344  dlHarqRlcPdu.resize (2);
345  dlHarqRlcPdu.at (0).resize (8);
346  dlHarqRlcPdu.at (1).resize (8);
347  m_dlHarqProcessesRlcPduListBuffer.insert (std::pair <uint16_t, DlHarqRlcPduListBuffer_t> (params.m_rnti, dlHarqRlcPdu));
348  m_ulHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
349  UlHarqProcessesStatus_t ulHarqPrcStatus;
350  ulHarqPrcStatus.resize (8,0);
351  m_ulHarqProcessesStatus.insert (std::pair <uint16_t, UlHarqProcessesStatus_t> (params.m_rnti, ulHarqPrcStatus));
352  UlHarqProcessesDciBuffer_t ulHarqdci;
353  ulHarqdci.resize (8);
354  m_ulHarqProcessesDciBuffer.insert (std::pair <uint16_t, UlHarqProcessesDciBuffer_t> (params.m_rnti, ulHarqdci));
355  }
356  else
357  {
358  (*it).second = params.m_transmissionMode;
359  }
360  return;
361 }
362 
363 void
365 {
366  NS_LOG_FUNCTION (this << " New LC, rnti: " << params.m_rnti);
367 
368  std::map <uint16_t, pssFlowPerf_t>::iterator it;
369  for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++)
370  {
371  it = m_flowStatsDl.find (params.m_rnti);
372 
373  if (it == m_flowStatsDl.end ())
374  {
375  double tbrDlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabGuaranteedBitrateDl / 8; // byte/s
376  double tbrUlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabGuaranteedBitrateUl / 8; // byte/s
377 
378  pssFlowPerf_t flowStatsDl;
379  flowStatsDl.flowStart = Simulator::Now ();
380  flowStatsDl.totalBytesTransmitted = 0;
381  flowStatsDl.lastTtiBytesTransmitted = 0;
382  flowStatsDl.lastAveragedThroughput = 1;
383  flowStatsDl.secondLastAveragedThroughput = 1;
384  flowStatsDl.targetThroughput = tbrDlInBytes;
385  m_flowStatsDl.insert (std::pair<uint16_t, pssFlowPerf_t> (params.m_rnti, flowStatsDl));
386  pssFlowPerf_t flowStatsUl;
387  flowStatsUl.flowStart = Simulator::Now ();
388  flowStatsUl.totalBytesTransmitted = 0;
389  flowStatsUl.lastTtiBytesTransmitted = 0;
390  flowStatsUl.lastAveragedThroughput = 1;
391  flowStatsUl.secondLastAveragedThroughput = 1;
392  flowStatsUl.targetThroughput = tbrUlInBytes;
393  m_flowStatsUl.insert (std::pair<uint16_t, pssFlowPerf_t> (params.m_rnti, flowStatsUl));
394  }
395  else
396  {
397  // update GBR from UeManager::SetupDataRadioBearer ()
398  double tbrDlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabGuaranteedBitrateDl / 8; // byte/s
399  double tbrUlInBytes = params.m_logicalChannelConfigList.at (i).m_eRabGuaranteedBitrateUl / 8; // byte/s
400  m_flowStatsDl[(*it).first].targetThroughput = tbrDlInBytes;
401  m_flowStatsUl[(*it).first].targetThroughput = tbrUlInBytes;
402  }
403  }
404 
405  return;
406 }
407 
408 void
410 {
411  NS_LOG_FUNCTION (this);
412  for (uint16_t i = 0; i < params.m_logicalChannelIdentity.size (); i++)
413  {
414  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
415  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
416  while (it!=m_rlcBufferReq.end ())
417  {
418  if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at (i)))
419  {
420  temp = it;
421  it++;
422  m_rlcBufferReq.erase (temp);
423  }
424  else
425  {
426  it++;
427  }
428  }
429  }
430  return;
431 }
432 
433 void
435 {
436  NS_LOG_FUNCTION (this);
437 
438  m_uesTxMode.erase (params.m_rnti);
439  m_dlHarqCurrentProcessId.erase (params.m_rnti);
440  m_dlHarqProcessesStatus.erase (params.m_rnti);
441  m_dlHarqProcessesTimer.erase (params.m_rnti);
442  m_dlHarqProcessesDciBuffer.erase (params.m_rnti);
444  m_ulHarqCurrentProcessId.erase (params.m_rnti);
445  m_ulHarqProcessesStatus.erase (params.m_rnti);
446  m_ulHarqProcessesDciBuffer.erase (params.m_rnti);
447  m_flowStatsDl.erase (params.m_rnti);
448  m_flowStatsUl.erase (params.m_rnti);
449  m_ceBsrRxed.erase (params.m_rnti);
450  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
451  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
452  while (it!=m_rlcBufferReq.end ())
453  {
454  if ((*it).first.m_rnti == params.m_rnti)
455  {
456  temp = it;
457  it++;
458  m_rlcBufferReq.erase (temp);
459  }
460  else
461  {
462  it++;
463  }
464  }
465  if (m_nextRntiUl == params.m_rnti)
466  {
467  m_nextRntiUl = 0;
468  }
469 
470  return;
471 }
472 
473 
474 void
476 {
477  NS_LOG_FUNCTION (this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
478  // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
479 
480  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
481 
482  LteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity);
483 
484  it = m_rlcBufferReq.find (flow);
485 
486  if (it == m_rlcBufferReq.end ())
487  {
488  m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
489  }
490  else
491  {
492  (*it).second = params;
493  }
494 
495  return;
496 }
497 
498 void
500 {
501  NS_LOG_FUNCTION (this);
502  NS_FATAL_ERROR ("method not implemented");
503  return;
504 }
505 
506 void
508 {
509  NS_LOG_FUNCTION (this);
510  NS_FATAL_ERROR ("method not implemented");
511  return;
512 }
513 
514 int
516 {
517  for (int i = 0; i < 4; i++)
518  {
519  if (dlbandwidth < PssType0AllocationRbg[i])
520  {
521  return (i + 1);
522  }
523  }
524 
525  return (-1);
526 }
527 
528 
529 int
531 {
532  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
533  int lcActive = 0;
534  for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
535  {
536  if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
537  || ((*it).second.m_rlcRetransmissionQueueSize > 0)
538  || ((*it).second.m_rlcStatusPduSize > 0) ))
539  {
540  lcActive++;
541  }
542  if ((*it).first.m_rnti > rnti)
543  {
544  break;
545  }
546  }
547  return (lcActive);
548 
549 }
550 
551 
552 uint8_t
554 {
555  NS_LOG_FUNCTION (this << rnti);
556 
557  std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
558  if (it == m_dlHarqCurrentProcessId.end ())
559  {
560  NS_FATAL_ERROR ("No Process Id found for this RNTI " << rnti);
561  }
562  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
563  if (itStat == m_dlHarqProcessesStatus.end ())
564  {
565  NS_FATAL_ERROR ("No Process Id Statusfound for this RNTI " << rnti);
566  }
567  uint8_t i = (*it).second;
568  do
569  {
570  i = (i + 1) % HARQ_PROC_NUM;
571  }
572  while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
573  if ((*itStat).second.at (i) == 0)
574  {
575  return (true);
576  }
577  else
578  {
579  return (false); // return a not valid harq proc id
580  }
581 }
582 
583 
584 
585 uint8_t
587 {
588  NS_LOG_FUNCTION (this << rnti);
589 
590  if (m_harqOn == false)
591  {
592  return (0);
593  }
594 
595 
596  std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
597  if (it == m_dlHarqCurrentProcessId.end ())
598  {
599  NS_FATAL_ERROR ("No Process Id found for this RNTI " << rnti);
600  }
601  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
602  if (itStat == m_dlHarqProcessesStatus.end ())
603  {
604  NS_FATAL_ERROR ("No Process Id Statusfound for this RNTI " << rnti);
605  }
606  uint8_t i = (*it).second;
607  do
608  {
609  i = (i + 1) % HARQ_PROC_NUM;
610  }
611  while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
612  if ((*itStat).second.at (i) == 0)
613  {
614  (*it).second = i;
615  (*itStat).second.at (i) = 1;
616  }
617  else
618  {
619  NS_FATAL_ERROR ("No HARQ process available for RNTI " << rnti << " check before update with HarqProcessAvailability");
620  }
621 
622  return ((*it).second);
623 }
624 
625 
626 void
628 {
629  NS_LOG_FUNCTION (this);
630 
631  std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
632  for (itTimers = m_dlHarqProcessesTimer.begin (); itTimers != m_dlHarqProcessesTimer.end (); itTimers ++)
633  {
634  for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
635  {
636  if ((*itTimers).second.at (i) == HARQ_DL_TIMEOUT)
637  {
638  // reset HARQ process
639 
640  NS_LOG_DEBUG (this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first);
641  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find ((*itTimers).first);
642  if (itStat == m_dlHarqProcessesStatus.end ())
643  {
644  NS_FATAL_ERROR ("No Process Id Status found for this RNTI " << (*itTimers).first);
645  }
646  (*itStat).second.at (i) = 0;
647  (*itTimers).second.at (i) = 0;
648  }
649  else
650  {
651  (*itTimers).second.at (i)++;
652  }
653  }
654  }
655 
656 }
657 
658 
659 void
661 {
662  NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
663  // API generated by RLC for triggering the scheduling of a DL subframe
664 
665 
666  // evaluate the relative channel quality indicator for each UE per each RBG
667  // (since we are using allocation type 0 the small unit of allocation is RBG)
668  // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
669 
670  RefreshDlCqiMaps ();
671 
673  int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
674  std::map <uint16_t, std::vector <uint16_t> > allocationMap; // RBs map per RNTI
675  std::vector <bool> rbgMap; // global RBGs map
676  uint16_t rbgAllocatedNum = 0;
677  std::set <uint16_t> rntiAllocated;
678  rbgMap.resize (m_cschedCellConfig.m_dlBandwidth / rbgSize, false);
680 
681  // RACH Allocation
683  uint16_t rbStart = 0;
684  std::vector <struct RachListElement_s>::iterator itRach;
685  for (itRach = m_rachList.begin (); itRach != m_rachList.end (); itRach++)
686  {
687  NS_ASSERT_MSG (m_amc->GetTbSizeFromMcs (m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, " Default UL Grant MCS does not allow to send RACH messages");
688  BuildRarListElement_s newRar;
689  newRar.m_rnti = (*itRach).m_rnti;
690  // DL-RACH Allocation
691  // Ideal: no needs of configuring m_dci
692  // UL-RACH Allocation
693  newRar.m_grant.m_rnti = newRar.m_rnti;
694  newRar.m_grant.m_mcs = m_ulGrantMcs;
695  uint16_t rbLen = 1;
696  uint16_t tbSizeBits = 0;
697  // find lowest TB size that fits UL grant estimated size
698  while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < m_cschedCellConfig.m_ulBandwidth))
699  {
700  rbLen++;
701  tbSizeBits = m_amc->GetTbSizeFromMcs (m_ulGrantMcs, rbLen);
702  }
703  if (tbSizeBits < (*itRach).m_estimatedSize)
704  {
705  // no more allocation space: finish allocation
706  break;
707  }
708  newRar.m_grant.m_rbStart = rbStart;
709  newRar.m_grant.m_rbLen = rbLen;
710  newRar.m_grant.m_tbSize = tbSizeBits / 8;
711  newRar.m_grant.m_hopping = false;
712  newRar.m_grant.m_tpc = 0;
713  newRar.m_grant.m_cqiRequest = false;
714  newRar.m_grant.m_ulDelay = false;
715  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);
716  for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
717  {
718  m_rachAllocationMap.at (i) = (*itRach).m_rnti;
719  }
720  rbStart = rbStart + rbLen;
721 
722  ret.m_buildRarList.push_back (newRar);
723  }
724  m_rachList.clear ();
725 
726 
727  // Process DL HARQ feedback
729  // retrieve past HARQ retx buffered
730  if (m_dlInfoListBuffered.size () > 0)
731  {
732  if (params.m_dlInfoList.size () > 0)
733  {
734  NS_LOG_INFO (this << " Received DL-HARQ feedback");
735  m_dlInfoListBuffered.insert (m_dlInfoListBuffered.end (), params.m_dlInfoList.begin (), params.m_dlInfoList.end ());
736  }
737  }
738  else
739  {
740  if (params.m_dlInfoList.size () > 0)
741  {
743  }
744  }
745  if (m_harqOn == false)
746  {
747  // Ignore HARQ feedback
748  m_dlInfoListBuffered.clear ();
749  }
750  std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
751  for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
752  {
753  std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
754  if (itRnti != rntiAllocated.end ())
755  {
756  // RNTI already allocated for retx
757  continue;
758  }
759  uint8_t nLayers = m_dlInfoListBuffered.at (i).m_harqStatus.size ();
760  std::vector <bool> retx;
761  NS_LOG_INFO (this << " Processing DLHARQ feedback");
762  if (nLayers == 1)
763  {
764  retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
765  retx.push_back (false);
766  }
767  else
768  {
769  retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
770  retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (1) == DlInfoListElement_s::NACK);
771  }
772  if (retx.at (0) || retx.at (1))
773  {
774  // retrieve HARQ process information
775  uint16_t rnti = m_dlInfoListBuffered.at (i).m_rnti;
776  uint8_t harqId = m_dlInfoListBuffered.at (i).m_harqProcessId;
777  NS_LOG_INFO (this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
778  std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq = m_dlHarqProcessesDciBuffer.find (rnti);
779  if (itHarq == m_dlHarqProcessesDciBuffer.end ())
780  {
781  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << rnti);
782  }
783 
784  DlDciListElement_s dci = (*itHarq).second.at (harqId);
785  int rv = 0;
786  if (dci.m_rv.size () == 1)
787  {
788  rv = dci.m_rv.at (0);
789  }
790  else
791  {
792  rv = (dci.m_rv.at (0) > dci.m_rv.at (1) ? dci.m_rv.at (0) : dci.m_rv.at (1));
793  }
794 
795  if (rv == 3)
796  {
797  // maximum number of retx reached -> drop process
798  NS_LOG_INFO ("Maximum number of retransmissions reached -> drop process");
799  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (rnti);
800  if (it == m_dlHarqProcessesStatus.end ())
801  {
802  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at (i).m_rnti);
803  }
804  (*it).second.at (harqId) = 0;
805  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
806  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
807  {
808  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
809  }
810  for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
811  {
812  (*itRlcPdu).second.at (k).at (harqId).clear ();
813  }
814  continue;
815  }
816  // check the feasibility of retransmitting on the same RBGs
817  // translate the DCI to Spectrum framework
818  std::vector <int> dciRbg;
819  uint32_t mask = 0x1;
820  NS_LOG_INFO ("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
821  for (int j = 0; j < 32; j++)
822  {
823  if (((dci.m_rbBitmap & mask) >> j) == 1)
824  {
825  dciRbg.push_back (j);
826  NS_LOG_INFO ("\t" << j);
827  }
828  mask = (mask << 1);
829  }
830  bool free = true;
831  for (uint8_t j = 0; j < dciRbg.size (); j++)
832  {
833  if (rbgMap.at (dciRbg.at (j)) == true)
834  {
835  free = false;
836  break;
837  }
838  }
839  if (free)
840  {
841  // use the same RBGs for the retx
842  // reserve RBGs
843  for (uint8_t j = 0; j < dciRbg.size (); j++)
844  {
845  rbgMap.at (dciRbg.at (j)) = true;
846  NS_LOG_INFO ("RBG " << dciRbg.at (j) << " assigned");
847  rbgAllocatedNum++;
848  }
849 
850  NS_LOG_INFO (this << " Send retx in the same RBGs");
851  }
852  else
853  {
854  // find RBGs for sending HARQ retx
855  uint8_t j = 0;
856  uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
857  uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
858  std::vector <bool> rbgMapCopy = rbgMap;
859  while ((j < dciRbg.size ())&&(startRbg != rbgId))
860  {
861  if (rbgMapCopy.at (rbgId) == false)
862  {
863  rbgMapCopy.at (rbgId) = true;
864  dciRbg.at (j) = rbgId;
865  j++;
866  }
867  rbgId++;
868  }
869  if (j == dciRbg.size ())
870  {
871  // find new RBGs -> update DCI map
872  uint32_t rbgMask = 0;
873  for (uint16_t k = 0; k < dciRbg.size (); k++)
874  {
875  rbgMask = rbgMask + (0x1 << dciRbg.at (k));
876  rbgAllocatedNum++;
877  }
878  dci.m_rbBitmap = rbgMask;
879  rbgMap = rbgMapCopy;
880  NS_LOG_INFO (this << " Move retx in RBGs " << dciRbg.size ());
881  }
882  else
883  {
884  // HARQ retx cannot be performed on this TTI -> store it
885  dlInfoListUntxed.push_back (params.m_dlInfoList.at (i));
886  NS_LOG_INFO (this << " No resource for this retx -> buffer it");
887  }
888  }
889  // retrieve RLC PDU list for retx TBsize and update DCI
891  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
892  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
893  {
894  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
895  }
896  for (uint8_t j = 0; j < nLayers; j++)
897  {
898  if (retx.at (j))
899  {
900  if (j >= dci.m_ndi.size ())
901  {
902  // for avoiding errors in MIMO transient phases
903  dci.m_ndi.push_back (0);
904  dci.m_rv.push_back (0);
905  dci.m_mcs.push_back (0);
906  dci.m_tbsSize.push_back (0);
907  NS_LOG_INFO (this << " layer " << (uint16_t)j << " no txed (MIMO transition)");
908  }
909  else
910  {
911  dci.m_ndi.at (j) = 0;
912  dci.m_rv.at (j)++;
913  (*itHarq).second.at (harqId).m_rv.at (j)++;
914  NS_LOG_INFO (this << " layer " << (uint16_t)j << " RV " << (uint16_t)dci.m_rv.at (j));
915  }
916  }
917  else
918  {
919  // empty TB of layer j
920  dci.m_ndi.at (j) = 0;
921  dci.m_rv.at (j) = 0;
922  dci.m_mcs.at (j) = 0;
923  dci.m_tbsSize.at (j) = 0;
924  NS_LOG_INFO (this << " layer " << (uint16_t)j << " no retx");
925  }
926  }
927  for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.m_harqProcess).size (); k++)
928  {
929  std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
930  for (uint8_t j = 0; j < nLayers; j++)
931  {
932  if (retx.at (j))
933  {
934  if (j < dci.m_ndi.size ())
935  {
936  rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.m_harqProcess).at (k));
937  }
938  }
939  }
940 
941  if (rlcPduListPerLc.size () > 0)
942  {
943  newEl.m_rlcPduList.push_back (rlcPduListPerLc);
944  }
945  }
946  newEl.m_rnti = rnti;
947  newEl.m_dci = dci;
948  (*itHarq).second.at (harqId).m_rv = dci.m_rv;
949  // refresh timer
950  std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (rnti);
951  if (itHarqTimer== m_dlHarqProcessesTimer.end ())
952  {
953  NS_FATAL_ERROR ("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
954  }
955  (*itHarqTimer).second.at (harqId) = 0;
956  ret.m_buildDataList.push_back (newEl);
957  rntiAllocated.insert (rnti);
958  }
959  else
960  {
961  // update HARQ process status
962  NS_LOG_INFO (this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at (i).m_rnti);
963  std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (m_dlInfoListBuffered.at (i).m_rnti);
964  if (it == m_dlHarqProcessesStatus.end ())
965  {
966  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at (i).m_rnti);
967  }
968  (*it).second.at (m_dlInfoListBuffered.at (i).m_harqProcessId) = 0;
969  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (m_dlInfoListBuffered.at (i).m_rnti);
970  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
971  {
972  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
973  }
974  for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
975  {
976  (*itRlcPdu).second.at (k).at (m_dlInfoListBuffered.at (i).m_harqProcessId).clear ();
977  }
978  }
979  }
980  m_dlInfoListBuffered.clear ();
981  m_dlInfoListBuffered = dlInfoListUntxed;
982 
983 
984  std::map <uint16_t, pssFlowPerf_t>::iterator it;
985  std::map <uint16_t, pssFlowPerf_t> tdUeSet; // the result of TD scheduler
986 
987  // schedulability check
988  std::map <uint16_t, pssFlowPerf_t> ueSet;
989  for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++)
990  {
991  if( LcActivePerFlow ((*it).first) > 0 )
992  {
993  ueSet.insert(std::pair <uint16_t, pssFlowPerf_t> ((*it).first, (*it).second));
994  }
995  }
996 
997  if (ueSet.size() != 0)
998  { // has data in RLC buffer
999 
1000  // Time Domain scheduler
1001  std::vector <std::pair<double, uint16_t> > ueSet1;
1002  std::vector <std::pair<double,uint16_t> > ueSet2;
1003  for (it = ueSet.begin (); it != ueSet.end (); it++)
1004  {
1005  std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1006  if ((itRnti != rntiAllocated.end ())||(!HarqProcessAvailability ((*it).first)))
1007  {
1008  // UE already allocated for HARQ or without HARQ process available -> drop it
1009  if (itRnti != rntiAllocated.end ())
1010  {
1011  NS_LOG_DEBUG (this << " RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1012  }
1013  if (!HarqProcessAvailability ((*it).first))
1014  {
1015  NS_LOG_DEBUG (this << " RNTI discared for HARQ id" << (uint16_t)(*it).first);
1016  }
1017  continue;
1018  }
1019 
1020  double metric = 0.0;
1021  if ((*it).second.lastAveragedThroughput < (*it).second.targetThroughput )
1022  {
1023  // calculate TD BET metric
1024  metric = 1 / (*it).second.lastAveragedThroughput;
1025  ueSet1.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1026  }
1027  else
1028  {
1029  // calculate TD PF metric
1030  std::map <uint16_t,uint8_t>::iterator itCqi;
1031  itCqi = m_p10CqiRxed.find ((*it).first);
1032  std::map <uint16_t,uint8_t>::iterator itTxMode;
1033  itTxMode = m_uesTxMode.find ((*it).first);
1034  if (itTxMode == m_uesTxMode.end())
1035  {
1036  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).first);
1037  }
1038  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1039  uint8_t wbCqi = 0;
1040  if (itCqi == m_p10CqiRxed.end())
1041  {
1042  wbCqi = 1; // start with lowest value
1043  }
1044  else
1045  {
1046  wbCqi = (*itCqi).second;
1047  }
1048 
1049  if (wbCqi > 0)
1050  {
1051  if (LcActivePerFlow ((*it).first) > 0)
1052  {
1053  // this UE has data to transmit
1054  double achievableRate = 0.0;
1055  for (uint8_t k = 0; k < nLayer; k++)
1056  {
1057  uint8_t mcs = 0;
1058  mcs = m_amc->GetMcsFromCqi (wbCqi);
1059  achievableRate += ((m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001); // = TB size / TTI
1060  }
1061 
1062  metric = achievableRate / (*it).second.lastAveragedThroughput;
1063  }
1064  } // end of wbCqi
1065 
1066  ueSet2.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1067  }
1068  }// end of ueSet
1069 
1070 
1071  if (ueSet1.size () != 0 || ueSet2.size () != 0)
1072  {
1073  // sorting UE in ueSet1 and ueSet1 in descending order based on their metric value
1074  std::sort (ueSet1.rbegin (), ueSet1.rend ());
1075  std::sort (ueSet2.rbegin (), ueSet2.rend ());
1076 
1077  // select UE set for frequency domain scheduler
1078  uint32_t nMux;
1079  if ( m_nMux > 0)
1080  nMux = m_nMux;
1081  else
1082  {
1083  // select half number of UE
1084  if (ueSet1.size() + ueSet2.size() <=2 )
1085  nMux = 1;
1086  else
1087  nMux = (int)((ueSet1.size() + ueSet2.size()) / 2) ; // TD scheduler only transfers half selected UE per RTT to TD scheduler
1088  }
1089  for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it--)
1090  {
1091  std::vector <std::pair<double, uint16_t> >::iterator itSet;
1092  for (itSet = ueSet1.begin (); itSet != ueSet1.end () && nMux != 0; itSet++)
1093  {
1094  std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1095  itUe = m_flowStatsDl.find((*itSet).second);
1096  tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1097  nMux--;
1098  }
1099 
1100  if (nMux == 0)
1101  break;
1102 
1103  for (itSet = ueSet2.begin (); itSet != ueSet2.end () && nMux != 0; itSet++)
1104  {
1105  std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1106  itUe = m_flowStatsDl.find((*itSet).second);
1107  tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1108  nMux--;
1109  }
1110 
1111  if (nMux == 0)
1112  break;
1113 
1114  } // end of m_flowStatsDl
1115 
1116 
1117  if ( m_fdSchedulerType.compare("CoItA") == 0)
1118  {
1119  // FD scheduler: Carrier over Interference to Average (CoItA)
1120  std::map < uint16_t, uint8_t > sbCqiSum;
1121  for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1122  {
1123  uint8_t sum = 0;
1124  for (int i = 0; i < rbgNum; i++)
1125  {
1126  std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1127  itCqi = m_a30CqiRxed.find ((*it).first);
1128  std::map <uint16_t,uint8_t>::iterator itTxMode;
1129  itTxMode = m_uesTxMode.find ((*it).first);
1130  if (itTxMode == m_uesTxMode.end ())
1131  {
1132  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).first);
1133  }
1134  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1135  std::vector <uint8_t> sbCqis;
1136  if (itCqi == m_a30CqiRxed.end ())
1137  {
1138  for (uint8_t k = 0; k < nLayer; k++)
1139  {
1140  sbCqis.push_back (1); // start with lowest value
1141  }
1142  }
1143  else
1144  {
1145  sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1146  }
1147 
1148  uint8_t cqi1 = sbCqis.at (0);
1149  uint8_t cqi2 = 1;
1150  if (sbCqis.size () > 1)
1151  {
1152  cqi2 = sbCqis.at (1);
1153  }
1154 
1155  uint8_t sbCqi;
1156  if ((cqi1 > 0)||(cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1157  {
1158  for (uint8_t k = 0; k < nLayer; k++)
1159  {
1160  if (sbCqis.size () > k)
1161  {
1162  sbCqi = sbCqis.at(k);
1163  }
1164  else
1165  {
1166  // no info on this subband
1167  sbCqi = 0;
1168  }
1169  sum += sbCqi;
1170  }
1171  } // end if cqi
1172  }// end of rbgNum
1173 
1174  sbCqiSum.insert (std::pair<uint16_t, uint8_t> ((*it).first, sum));
1175  }// end tdUeSet
1176 
1177  for (int i = 0; i < rbgNum; i++)
1178  {
1179  if (rbgMap.at (i) == true)
1180  continue;
1181 
1182  std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1183  double metricMax = 0.0;
1184  for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1185  {
1186  // calculate PF weigth
1187  double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1188  if (weight < 1.0)
1189  weight = 1.0;
1190 
1191  std::map < uint16_t, uint8_t>::iterator itSbCqiSum;
1192  itSbCqiSum = sbCqiSum.find((*it).first);
1193 
1194  std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1195  itCqi = m_a30CqiRxed.find ((*it).first);
1196  std::map <uint16_t,uint8_t>::iterator itTxMode;
1197  itTxMode = m_uesTxMode.find ((*it).first);
1198  if (itTxMode == m_uesTxMode.end())
1199  {
1200  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).first);
1201  }
1202  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1203  std::vector <uint8_t> sbCqis;
1204  if (itCqi == m_a30CqiRxed.end ())
1205  {
1206  for (uint8_t k = 0; k < nLayer; k++)
1207  {
1208  sbCqis.push_back (1); // start with lowest value
1209  }
1210  }
1211  else
1212  {
1213  sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1214  }
1215 
1216  uint8_t cqi1 = sbCqis.at( 0);
1217  uint8_t cqi2 = 1;
1218  if (sbCqis.size () > 1)
1219  {
1220  cqi2 = sbCqis.at(1);
1221  }
1222 
1223  uint8_t sbCqi;
1224  double colMetric = 0.0;
1225  if ((cqi1 > 0)||(cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1226  {
1227  for (uint8_t k = 0; k < nLayer; k++)
1228  {
1229  if (sbCqis.size () > k)
1230  {
1231  sbCqi = sbCqis.at(k);
1232  }
1233  else
1234  {
1235  // no info on this subband
1236  sbCqi = 0;
1237  }
1238  colMetric += (double)sbCqi / (double)(*itSbCqiSum).second;
1239  }
1240  } // end if cqi
1241 
1242  double metric = 0.0;
1243  if (colMetric != 0)
1244  metric= weight * colMetric;
1245  else
1246  metric = 1;
1247 
1248  if (metric > metricMax )
1249  {
1250  metricMax = metric;
1251  itMax = it;
1252  }
1253  } // end of tdUeSet
1254 
1255  if (itMax == m_flowStatsDl.end ())
1256  {
1257  // no UE available for downlink
1258  return;
1259  }
1260  else
1261  {
1262  allocationMap[(*itMax).first].push_back (i);
1263  rbgMap.at (i) = true;
1264  }
1265  }// end of rbgNum
1266 
1267  }// end of CoIta
1268 
1269 
1270  if ( m_fdSchedulerType.compare("PFsch") == 0)
1271  {
1272  // FD scheduler: Proportional Fair scheduled (PFsch)
1273  for (int i = 0; i < rbgNum; i++)
1274  {
1275  if (rbgMap.at (i) == true)
1276  continue;
1277 
1278  std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1279  double metricMax = 0.0;
1280  for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1281  {
1282  // calculate PF weigth
1283  double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1284  if (weight < 1.0)
1285  weight = 1.0;
1286 
1287  std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1288  itCqi = m_a30CqiRxed.find ((*it).first);
1289  std::map <uint16_t,uint8_t>::iterator itTxMode;
1290  itTxMode = m_uesTxMode.find ((*it).first);
1291  if (itTxMode == m_uesTxMode.end())
1292  {
1293  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).first);
1294  }
1295  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1296  std::vector <uint8_t> sbCqis;
1297  if (itCqi == m_a30CqiRxed.end ())
1298  {
1299  for (uint8_t k = 0; k < nLayer; k++)
1300  {
1301  sbCqis.push_back (1); // start with lowest value
1302  }
1303  }
1304  else
1305  {
1306  sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1307  }
1308 
1309  uint8_t cqi1 = sbCqis.at(0);
1310  uint8_t cqi2 = 1;
1311  if (sbCqis.size () > 1)
1312  {
1313  cqi2 = sbCqis.at(1);
1314  }
1315 
1316  double schMetric = 0.0;
1317  if ((cqi1 > 0)||(cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1318  {
1319  double achievableRate = 0.0;
1320  for (uint8_t k = 0; k < nLayer; k++)
1321  {
1322  uint8_t mcs = 0;
1323  if (sbCqis.size () > k)
1324  {
1325  mcs = m_amc->GetMcsFromCqi (sbCqis.at (k));
1326  }
1327  else
1328  {
1329  // no info on this subband -> worst MCS
1330  mcs = 0;
1331  }
1332  achievableRate += ((m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001); // = TB size / TTI
1333  }
1334  schMetric = achievableRate / (*it).second.secondLastAveragedThroughput;
1335  } // end if cqi
1336 
1337  double metric = 0.0;
1338  metric= weight * schMetric;
1339 
1340  if (metric > metricMax )
1341  {
1342  metricMax = metric;
1343  itMax = it;
1344  }
1345  } // end of tdUeSet
1346 
1347  if (itMax == m_flowStatsDl.end ())
1348  {
1349  // no UE available for downlink
1350  return;
1351  }
1352  else
1353  {
1354  allocationMap[(*itMax).first].push_back (i);
1355  rbgMap.at (i) = true;
1356  }
1357 
1358  }// end of rbgNum
1359 
1360  } // end of PFsch
1361 
1362  } // end if ueSet1 || ueSet2
1363 
1364  } // end if ueSet
1365 
1366 
1367 
1368  // reset TTI stats of users
1369  std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1370  for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
1371  {
1372  (*itStats).second.lastTtiBytesTransmitted = 0;
1373  }
1374 
1375  // generate the transmission opportunities by grouping the RBGs of the same RNTI and
1376  // creating the correspondent DCIs
1377  std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1378  while (itMap != allocationMap.end ())
1379  {
1380  // create new BuildDataListElement_s for this LC
1381  BuildDataListElement_s newEl;
1382  newEl.m_rnti = (*itMap).first;
1383  // create the DlDciListElement_s
1384  DlDciListElement_s newDci;
1385  newDci.m_rnti = (*itMap).first;
1386  newDci.m_harqProcess = UpdateHarqProcessId ((*itMap).first);
1387 
1388  uint16_t lcActives = LcActivePerFlow ((*itMap).first);
1389  NS_LOG_INFO (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
1390  if (lcActives == 0)
1391  {
1392  // Set to max value, to avoid divide by 0 below
1393  lcActives = (uint16_t)65535; // UINT16_MAX;
1394  }
1395  uint16_t RgbPerRnti = (*itMap).second.size ();
1396  std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1397  itCqi = m_a30CqiRxed.find ((*itMap).first);
1398  std::map <uint16_t,uint8_t>::iterator itTxMode;
1399  itTxMode = m_uesTxMode.find ((*itMap).first);
1400  if (itTxMode == m_uesTxMode.end ())
1401  {
1402  NS_FATAL_ERROR ("No Transmission Mode info on user " << (*itMap).first);
1403  }
1404  int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1405  std::vector <uint8_t> worstCqi (2, 15);
1406  if (itCqi != m_a30CqiRxed.end ())
1407  {
1408  for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1409  {
1410  if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1411  {
1412  NS_LOG_INFO (this << " RBG " << (*itMap).second.at (k) << " CQI " << (uint16_t)((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (0)) );
1413  for (uint8_t j = 0; j < nLayer; j++)
1414  {
1415  if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1416  {
1417  if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1418  {
1419  worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1420  }
1421  }
1422  else
1423  {
1424  // no CQI for this layer of this suband -> worst one
1425  worstCqi.at (j) = 1;
1426  }
1427  }
1428  }
1429  else
1430  {
1431  for (uint8_t j = 0; j < nLayer; j++)
1432  {
1433  worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
1434  }
1435  }
1436  }
1437  }
1438  else
1439  {
1440  for (uint8_t j = 0; j < nLayer; j++)
1441  {
1442  worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
1443  }
1444  }
1445  for (uint8_t j = 0; j < nLayer; j++)
1446  {
1447  NS_LOG_INFO (this << " Layer " << (uint16_t)j << " CQI selected " << (uint16_t)worstCqi.at (j));
1448  }
1449  uint32_t bytesTxed = 0;
1450  for (uint8_t j = 0; j < nLayer; j++)
1451  {
1452  newDci.m_mcs.push_back (m_amc->GetMcsFromCqi (worstCqi.at (j)));
1453  int tbSize = (m_amc->GetTbSizeFromMcs (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)
1454  newDci.m_tbsSize.push_back (tbSize);
1455  NS_LOG_INFO (this << " Layer " << (uint16_t)j << " MCS selected" << m_amc->GetMcsFromCqi (worstCqi.at (j)));
1456  bytesTxed += tbSize;
1457  }
1458 
1459  newDci.m_resAlloc = 0; // only allocation type 0 at this stage
1460  newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
1461  uint32_t rbgMask = 0;
1462  for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1463  {
1464  rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1465  NS_LOG_INFO (this << " Allocated RBG " << (*itMap).second.at (k));
1466  }
1467  newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1468 
1469  // create the rlc PDUs -> equally divide resources among actives LCs
1470  std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1471  for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
1472  {
1473  if (((*itBufReq).first.m_rnti == (*itMap).first)
1474  && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1475  || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1476  || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1477  {
1478  std::vector <struct RlcPduListElement_s> newRlcPduLe;
1479  for (uint8_t j = 0; j < nLayer; j++)
1480  {
1481  RlcPduListElement_s newRlcEl;
1482  newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1483  newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
1484  NS_LOG_INFO (this << " LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
1485  newRlcPduLe.push_back (newRlcEl);
1486  UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
1487  if (m_harqOn == true)
1488  {
1489  // store RLC PDU list for HARQ
1490  std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find ((*itMap).first);
1491  if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
1492  {
1493  NS_FATAL_ERROR ("Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1494  }
1495  (*itRlcPdu).second.at (j).at (newDci.m_harqProcess).push_back (newRlcEl);
1496  }
1497  }
1498  newEl.m_rlcPduList.push_back (newRlcPduLe);
1499  }
1500  if ((*itBufReq).first.m_rnti > (*itMap).first)
1501  {
1502  break;
1503  }
1504  }
1505  for (uint8_t j = 0; j < nLayer; j++)
1506  {
1507  newDci.m_ndi.push_back (1);
1508  newDci.m_rv.push_back (0);
1509  }
1510 
1511  newEl.m_dci = newDci;
1512 
1513  if (m_harqOn == true)
1514  {
1515  // store DCI for HARQ
1516  std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci = m_dlHarqProcessesDciBuffer.find (newEl.m_rnti);
1517  if (itDci == m_dlHarqProcessesDciBuffer.end ())
1518  {
1519  NS_FATAL_ERROR ("Unable to find RNTI entry in DCI HARQ buffer for RNTI " << newEl.m_rnti);
1520  }
1521  (*itDci).second.at (newDci.m_harqProcess) = newDci;
1522  // refresh timer
1523  std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (newEl.m_rnti);
1524  if (itHarqTimer== m_dlHarqProcessesTimer.end ())
1525  {
1526  NS_FATAL_ERROR ("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1527  }
1528  (*itHarqTimer).second.at (newDci.m_harqProcess) = 0;
1529  }
1530 
1531  // ...more parameters -> ingored in this version
1532 
1533  ret.m_buildDataList.push_back (newEl);
1534  // update UE stats
1535  std::map <uint16_t, pssFlowPerf_t>::iterator it;
1536  it = m_flowStatsDl.find ((*itMap).first);
1537  if (it != m_flowStatsDl.end ())
1538  {
1539  (*it).second.lastTtiBytesTransmitted = bytesTxed;
1540  NS_LOG_INFO (this << " UE total bytes txed " << (*it).second.lastTtiBytesTransmitted);
1541 
1542 
1543  }
1544  else
1545  {
1546  NS_FATAL_ERROR (this << " No Stats for this allocated UE");
1547  }
1548 
1549  itMap++;
1550  } // end while allocation
1551  ret.m_nrOfPdcchOfdmSymbols = 1;
1552 
1553 
1554  // update UEs stats
1555  NS_LOG_INFO (this << " Update UEs statistics");
1556  for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
1557  {
1558  std::map <uint16_t, pssFlowPerf_t>::iterator itUeScheduleted = tdUeSet.end();
1559  itUeScheduleted = tdUeSet.find((*itStats).first);
1560  if (itUeScheduleted != tdUeSet.end())
1561  {
1562  (*itStats).second.secondLastAveragedThroughput = ((1.0 - (1 / m_timeWindow)) * (*itStats).second.secondLastAveragedThroughput) + ((1 / m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1563  }
1564 
1565  (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTransmitted;
1566  // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term Evolution, Ed Wiley)
1567  (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 / m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 / m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1568  (*itStats).second.lastTtiBytesTransmitted = 0;
1569  }
1570 
1571 
1573 
1574 
1575  return;
1576 }
1577 
1578 void
1580 {
1581  NS_LOG_FUNCTION (this);
1582 
1583  m_rachList = params.m_rachList;
1584 
1585  return;
1586 }
1587 
1588 void
1590 {
1591  NS_LOG_FUNCTION (this);
1592 
1593  for (unsigned int i = 0; i < params.m_cqiList.size (); i++)
1594  {
1595  if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
1596  {
1597  // wideband CQI reporting
1598  std::map <uint16_t,uint8_t>::iterator it;
1599  uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1600  it = m_p10CqiRxed.find (rnti);
1601  if (it == m_p10CqiRxed.end ())
1602  {
1603  // create the new entry
1604  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)
1605  // generate correspondent timer
1606  m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1607  }
1608  else
1609  {
1610  // update the CQI value and refresh correspondent timer
1611  (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
1612  // update correspondent timer
1613  std::map <uint16_t,uint32_t>::iterator itTimers;
1614  itTimers = m_p10CqiTimers.find (rnti);
1615  (*itTimers).second = m_cqiTimersThreshold;
1616  }
1617  }
1618  else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
1619  {
1620  // subband CQI reporting high layer configured
1621  std::map <uint16_t,SbMeasResult_s>::iterator it;
1622  uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1623  it = m_a30CqiRxed.find (rnti);
1624  if (it == m_a30CqiRxed.end ())
1625  {
1626  // create the new entry
1627  m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
1628  m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1629  }
1630  else
1631  {
1632  // update the CQI value and refresh correspondent timer
1633  (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
1634  std::map <uint16_t,uint32_t>::iterator itTimers;
1635  itTimers = m_a30CqiTimers.find (rnti);
1636  (*itTimers).second = m_cqiTimersThreshold;
1637  }
1638  }
1639  else
1640  {
1641  NS_LOG_ERROR (this << " CQI type unknown");
1642  }
1643  }
1644 
1645  return;
1646 }
1647 
1648 
1649 double
1650 PssFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
1651 {
1652  std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
1653  if (itCqi == m_ueCqi.end ())
1654  {
1655  // no cqi info about this UE
1656  return (NO_SINR);
1657 
1658  }
1659  else
1660  {
1661  // take the average SINR value among the available
1662  double sinrSum = 0;
1663  int sinrNum = 0;
1664  for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1665  {
1666  double sinr = (*itCqi).second.at (i);
1667  if (sinr != NO_SINR)
1668  {
1669  sinrSum += sinr;
1670  sinrNum++;
1671  }
1672  }
1673  double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1674  // store the value
1675  (*itCqi).second.at (rb) = estimatedSinr;
1676  return (estimatedSinr);
1677  }
1678 }
1679 
1680 void
1682 {
1683  NS_LOG_FUNCTION (this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size ());
1684 
1685  RefreshUlCqiMaps ();
1686 
1687  // Generate RBs map
1689  std::vector <bool> rbMap;
1690  uint16_t rbAllocatedNum = 0;
1691  std::set <uint16_t> rntiAllocated;
1692  std::vector <uint16_t> rbgAllocationMap;
1693  // update with RACH allocation map
1694  rbgAllocationMap = m_rachAllocationMap;
1695  //rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1696  m_rachAllocationMap.clear ();
1698 
1699  rbMap.resize (m_cschedCellConfig.m_ulBandwidth, false);
1700  // remove RACH allocation
1701  for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1702  {
1703  if (rbgAllocationMap.at (i) != 0)
1704  {
1705  rbMap.at (i) = true;
1706  NS_LOG_DEBUG (this << " Allocated for RACH " << i);
1707  }
1708  }
1709 
1710 
1711  if (m_harqOn == true)
1712  {
1713  // Process UL HARQ feedback
1714  // update UL HARQ proc id
1715  std::map <uint16_t, uint8_t>::iterator itProcId;
1716  for (itProcId = m_ulHarqCurrentProcessId.begin (); itProcId != m_ulHarqCurrentProcessId.end (); itProcId++)
1717  {
1718  (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
1719  }
1720 
1721  for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
1722  {
1723  if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
1724  {
1725  // retx correspondent block: retrieve the UL-DCI
1726  uint16_t rnti = params.m_ulInfoList.at (i).m_rnti;
1727  itProcId = m_ulHarqCurrentProcessId.find (rnti);
1728  if (itProcId == m_ulHarqCurrentProcessId.end ())
1729  {
1730  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1731  }
1732  uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1733  NS_LOG_INFO (this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size ());
1734  std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
1735  if (itHarq == m_ulHarqProcessesDciBuffer.end ())
1736  {
1737  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1738  continue;
1739  }
1740  UlDciListElement_s dci = (*itHarq).second.at (harqId);
1741  std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (rnti);
1742  if (itStat == m_ulHarqProcessesStatus.end ())
1743  {
1744  NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1745  }
1746  if ((*itStat).second.at (harqId) >= 3)
1747  {
1748  NS_LOG_INFO ("Max number of retransmissions reached (UL)-> drop process");
1749  continue;
1750  }
1751  bool free = true;
1752  for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1753  {
1754  if (rbMap.at (j) == true)
1755  {
1756  free = false;
1757  NS_LOG_INFO (this << " BUSY " << j);
1758  }
1759  }
1760  if (free)
1761  {
1762  // retx on the same RBs
1763  for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1764  {
1765  rbMap.at (j) = true;
1766  rbgAllocationMap.at (j) = dci.m_rnti;
1767  NS_LOG_INFO ("\tRB " << j);
1768  rbAllocatedNum++;
1769  }
1770  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);
1771  }
1772  else
1773  {
1774  NS_LOG_INFO ("Cannot allocate retx due to RACH allocations for UE " << rnti);
1775  continue;
1776  }
1777  dci.m_ndi = 0;
1778  // Update HARQ buffers with new HarqId
1779  (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1780  (*itStat).second.at (harqId) = 0;
1781  (*itHarq).second.at ((*itProcId).second) = dci;
1782  ret.m_dciList.push_back (dci);
1783  rntiAllocated.insert (dci.m_rnti);
1784  }
1785  else
1786  {
1787  NS_LOG_INFO (this << " HARQ-ACK feedback from RNTI " << params.m_ulInfoList.at (i).m_rnti);
1788  }
1789  }
1790  }
1791 
1792  std::map <uint16_t,uint32_t>::iterator it;
1793  int nflows = 0;
1794 
1795  for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1796  {
1797  std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1798  // select UEs with queues not empty and not yet allocated for HARQ
1799  if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1800  {
1801  nflows++;
1802  }
1803  }
1804 
1805  if (nflows == 0)
1806  {
1807  if (ret.m_dciList.size () > 0)
1808  {
1810  }
1811 
1812  return; // no flows to be scheduled
1813  }
1814 
1815 
1816  // Divide the remaining resources equally among the active users starting from the subsequent one served last scheduling trigger
1817  uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size ());
1818  if (rbPerFlow < 3)
1819  {
1820  rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity >= 7 bytes
1821  }
1822  int rbAllocated = 0;
1823 
1824  std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1825  if (m_nextRntiUl != 0)
1826  {
1827  for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1828  {
1829  if ((*it).first == m_nextRntiUl)
1830  {
1831  break;
1832  }
1833  }
1834  if (it == m_ceBsrRxed.end ())
1835  {
1836  NS_LOG_ERROR (this << " no user found");
1837  }
1838  }
1839  else
1840  {
1841  it = m_ceBsrRxed.begin ();
1842  m_nextRntiUl = (*it).first;
1843  }
1844  do
1845  {
1846  std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1847  if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1848  {
1849  // UE already allocated for UL-HARQ -> skip it
1850  NS_LOG_DEBUG (this << " UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1851  it++;
1852  if (it == m_ceBsrRxed.end ())
1853  {
1854  // restart from the first
1855  it = m_ceBsrRxed.begin ();
1856  }
1857  continue;
1858  }
1859  if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1860  {
1861  // limit to physical resources last resource assignment
1862  rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1863  // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1864  if (rbPerFlow < 3)
1865  {
1866  // terminate allocation
1867  rbPerFlow = 0;
1868  }
1869  }
1870 
1871  UlDciListElement_s uldci;
1872  uldci.m_rnti = (*it).first;
1873  uldci.m_rbLen = rbPerFlow;
1874  bool allocated = false;
1875  NS_LOG_INFO (this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow << " flows " << nflows);
1876  while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0))
1877  {
1878  // check availability
1879  bool free = true;
1880  for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1881  {
1882  if (rbMap.at (j) == true)
1883  {
1884  free = false;
1885  break;
1886  }
1887  }
1888  if (free)
1889  {
1890  uldci.m_rbStart = rbAllocated;
1891 
1892  for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1893  {
1894  rbMap.at (j) = true;
1895  // store info on allocation for managing ul-cqi interpretation
1896  rbgAllocationMap.at (j) = (*it).first;
1897  }
1898  rbAllocated += rbPerFlow;
1899  allocated = true;
1900  break;
1901  }
1902  rbAllocated++;
1903  if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1904  {
1905  // limit to physical resources last resource assignment
1906  rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1907  // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1908  if (rbPerFlow < 3)
1909  {
1910  // terminate allocation
1911  rbPerFlow = 0;
1912  }
1913  }
1914  }
1915  if (!allocated)
1916  {
1917  // unable to allocate new resource: finish scheduling
1918  m_nextRntiUl = (*it).first;
1919  if (ret.m_dciList.size () > 0)
1920  {
1922  }
1923  m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1924  return;
1925  }
1926 
1927 
1928 
1929  std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
1930  int cqi = 0;
1931  if (itCqi == m_ueCqi.end ())
1932  {
1933  // no cqi info about this UE
1934  uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1935  }
1936  else
1937  {
1938  // take the lowest CQI value (worst RB)
1939  double minSinr = (*itCqi).second.at (uldci.m_rbStart);
1940  if (minSinr == NO_SINR)
1941  {
1942  minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
1943  }
1944  for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1945  {
1946  double sinr = (*itCqi).second.at (i);
1947  if (sinr == NO_SINR)
1948  {
1949  sinr = EstimateUlSinr ((*it).first, i);
1950  }
1951  if ((*itCqi).second.at (i) < minSinr)
1952  {
1953  minSinr = (*itCqi).second.at (i);
1954  }
1955  }
1956 
1957  // translate SINR -> cqi: WILD ACK: same as DL
1958  double s = log2 ( 1 + (
1959  std::pow (10, minSinr / 10 ) /
1960  ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1961  cqi = m_amc->GetCqiFromSpectralEfficiency (s);
1962  if (cqi == 0)
1963  {
1964  it++;
1965  if (it == m_ceBsrRxed.end ())
1966  {
1967  // restart from the first
1968  it = m_ceBsrRxed.begin ();
1969  }
1970  NS_LOG_DEBUG (this << " UE discared for CQI=0, RNTI " << uldci.m_rnti);
1971  // remove UE from allocation map
1972  for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1973  {
1974  rbgAllocationMap.at (i) = 0;
1975  }
1976  continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1977  }
1978  uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
1979  }
1980 
1981  uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
1982  UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
1983  uldci.m_ndi = 1;
1984  uldci.m_cceIndex = 0;
1985  uldci.m_aggrLevel = 1;
1986  uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1987  uldci.m_hopping = false;
1988  uldci.m_n2Dmrs = 0;
1989  uldci.m_tpc = 0; // no power control
1990  uldci.m_cqiRequest = false; // only period CQI at this stage
1991  uldci.m_ulIndex = 0; // TDD parameter
1992  uldci.m_dai = 1; // TDD parameter
1993  uldci.m_freqHopping = 0;
1994  uldci.m_pdcchPowerOffset = 0; // not used
1995  ret.m_dciList.push_back (uldci);
1996  // store DCI for HARQ_PERIOD
1997  uint8_t harqId = 0;
1998  if (m_harqOn == true)
1999  {
2000  std::map <uint16_t, uint8_t>::iterator itProcId;
2001  itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
2002  if (itProcId == m_ulHarqCurrentProcessId.end ())
2003  {
2004  NS_FATAL_ERROR ("No info find in HARQ buffer for UE " << uldci.m_rnti);
2005  }
2006  harqId = (*itProcId).second;
2007  std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
2008  if (itDci == m_ulHarqProcessesDciBuffer.end ())
2009  {
2010  NS_FATAL_ERROR ("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
2011  }
2012  (*itDci).second.at (harqId) = uldci;
2013  }
2014 
2015  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);
2016 
2017  it++;
2018  if (it == m_ceBsrRxed.end ())
2019  {
2020  // restart from the first
2021  it = m_ceBsrRxed.begin ();
2022  }
2023  if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
2024  {
2025  // Stop allocation: no more PRBs
2026  m_nextRntiUl = (*it).first;
2027  break;
2028  }
2029  }
2030  while (((*it).first != m_nextRntiUl)&&(rbPerFlow!=0));
2031 
2032  m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
2034 
2035  return;
2036 }
2037 
2038 void
2040 {
2041  NS_LOG_FUNCTION (this);
2042  return;
2043 }
2044 
2045 void
2047 {
2048  NS_LOG_FUNCTION (this);
2049  return;
2050 }
2051 
2052 void
2054 {
2055  NS_LOG_FUNCTION (this);
2056 
2057  std::map <uint16_t,uint32_t>::iterator it;
2058 
2059  for (unsigned int i = 0; i < params.m_macCeList.size (); i++)
2060  {
2061  if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
2062  {
2063  // buffer status report
2064  // note that this scheduler does not differentiate the
2065  // allocation according to which LCGs have more/less bytes
2066  // to send.
2067  // Hence the BSR of different LCGs are just summed up to get
2068  // a total queue size that is used for allocation purposes.
2069 
2070  uint32_t buffer = 0;
2071  for (uint8_t lcg = 0; lcg < 4; ++lcg)
2072  {
2073  uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
2074  buffer += BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
2075  }
2076 
2077  uint16_t rnti = params.m_macCeList.at (i).m_rnti;
2078  NS_LOG_LOGIC (this << "RNTI=" << rnti << " buffer=" << buffer);
2079  it = m_ceBsrRxed.find (rnti);
2080  if (it == m_ceBsrRxed.end ())
2081  {
2082  // create the new entry
2083  m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
2084  }
2085  else
2086  {
2087  // update the buffer size value
2088  (*it).second = buffer;
2089  }
2090  }
2091  }
2092 
2093  return;
2094 }
2095 
2096 void
2098 {
2099  NS_LOG_FUNCTION (this);
2100 // retrieve the allocation for this subframe
2101  switch (m_ulCqiFilter)
2102  {
2104  {
2105  // filter all the CQIs that are not SRS based
2106  if (params.m_ulCqi.m_type != UlCqi_s::SRS)
2107  {
2108  return;
2109  }
2110  }
2111  break;
2113  {
2114  // filter all the CQIs that are not SRS based
2115  if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
2116  {
2117  return;
2118  }
2119  }
2121  break;
2122 
2123  default:
2124  NS_FATAL_ERROR ("Unknown UL CQI type");
2125  }
2126 
2127  switch (params.m_ulCqi.m_type)
2128  {
2129  case UlCqi_s::PUSCH:
2130  {
2131  std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2132  std::map <uint16_t, std::vector <double> >::iterator itCqi;
2133  NS_LOG_DEBUG (this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
2134  itMap = m_allocationMaps.find (params.m_sfnSf);
2135  if (itMap == m_allocationMaps.end ())
2136  {
2137  return;
2138  }
2139  for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2140  {
2141  // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
2142  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
2143  itCqi = m_ueCqi.find ((*itMap).second.at (i));
2144  if (itCqi == m_ueCqi.end ())
2145  {
2146  // create a new entry
2147  std::vector <double> newCqi;
2148  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2149  {
2150  if (i == j)
2151  {
2152  newCqi.push_back (sinr);
2153  }
2154  else
2155  {
2156  // initialize with NO_SINR value.
2157  newCqi.push_back (NO_SINR);
2158  }
2159 
2160  }
2161  m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2162  // generate correspondent timer
2163  m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
2164  }
2165  else
2166  {
2167  // update the value
2168  (*itCqi).second.at (i) = sinr;
2169  NS_LOG_DEBUG (this << " RNTI " << (*itMap).second.at (i) << " RB " << i << " SINR " << sinr);
2170  // update correspondent timer
2171  std::map <uint16_t, uint32_t>::iterator itTimers;
2172  itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
2173  (*itTimers).second = m_cqiTimersThreshold;
2174 
2175  }
2176 
2177  }
2178  // remove obsolete info on allocation
2179  m_allocationMaps.erase (itMap);
2180  }
2181  break;
2182  case UlCqi_s::SRS:
2183  {
2184  // get the RNTI from vendor specific parameters
2185  uint16_t rnti = 0;
2186  NS_ASSERT (params.m_vendorSpecificList.size () > 0);
2187  for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
2188  {
2189  if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
2190  {
2191  Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
2192  rnti = vsp->GetRnti ();
2193  }
2194  }
2195  std::map <uint16_t, std::vector <double> >::iterator itCqi;
2196  itCqi = m_ueCqi.find (rnti);
2197  if (itCqi == m_ueCqi.end ())
2198  {
2199  // create a new entry
2200  std::vector <double> newCqi;
2201  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2202  {
2203  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
2204  newCqi.push_back (sinr);
2205  NS_LOG_INFO (this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value " << sinr);
2206 
2207  }
2208  m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2209  // generate correspondent timer
2210  m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
2211  }
2212  else
2213  {
2214  // update the values
2215  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2216  {
2217  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
2218  (*itCqi).second.at (j) = sinr;
2219  NS_LOG_INFO (this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value " << sinr);
2220  }
2221  // update correspondent timer
2222  std::map <uint16_t, uint32_t>::iterator itTimers;
2223  itTimers = m_ueCqiTimers.find (rnti);
2224  (*itTimers).second = m_cqiTimersThreshold;
2225 
2226  }
2227 
2228 
2229  }
2230  break;
2231  case UlCqi_s::PUCCH_1:
2232  case UlCqi_s::PUCCH_2:
2233  case UlCqi_s::PRACH:
2234  {
2235  NS_FATAL_ERROR ("PssFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2236  }
2237  break;
2238  default:
2239  NS_FATAL_ERROR ("Unknown type of UL-CQI");
2240  }
2241  return;
2242 }
2243 
2244 void
2246 {
2247  // refresh DL CQI P01 Map
2248  std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
2249  while (itP10 != m_p10CqiTimers.end ())
2250  {
2251  NS_LOG_INFO (this << " P10-CQI for user " << (*itP10).first << " is " << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2252  if ((*itP10).second == 0)
2253  {
2254  // delete correspondent entries
2255  std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
2256  NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (), " Does not find CQI report for user " << (*itP10).first);
2257  NS_LOG_INFO (this << " P10-CQI expired for user " << (*itP10).first);
2258  m_p10CqiRxed.erase (itMap);
2259  std::map <uint16_t,uint32_t>::iterator temp = itP10;
2260  itP10++;
2261  m_p10CqiTimers.erase (temp);
2262  }
2263  else
2264  {
2265  (*itP10).second--;
2266  itP10++;
2267  }
2268  }
2269 
2270  // refresh DL CQI A30 Map
2271  std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
2272  while (itA30 != m_a30CqiTimers.end ())
2273  {
2274  NS_LOG_INFO (this << " A30-CQI for user " << (*itA30).first << " is " << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2275  if ((*itA30).second == 0)
2276  {
2277  // delete correspondent entries
2278  std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
2279  NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (), " Does not find CQI report for user " << (*itA30).first);
2280  NS_LOG_INFO (this << " A30-CQI expired for user " << (*itA30).first);
2281  m_a30CqiRxed.erase (itMap);
2282  std::map <uint16_t,uint32_t>::iterator temp = itA30;
2283  itA30++;
2284  m_a30CqiTimers.erase (temp);
2285  }
2286  else
2287  {
2288  (*itA30).second--;
2289  itA30++;
2290  }
2291  }
2292 
2293  return;
2294 }
2295 
2296 
2297 void
2299 {
2300  // refresh UL CQI Map
2301  std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
2302  while (itUl != m_ueCqiTimers.end ())
2303  {
2304  NS_LOG_INFO (this << " UL-CQI for user " << (*itUl).first << " is " << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2305  if ((*itUl).second == 0)
2306  {
2307  // delete correspondent entries
2308  std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
2309  NS_ASSERT_MSG (itMap != m_ueCqi.end (), " Does not find CQI report for user " << (*itUl).first);
2310  NS_LOG_INFO (this << " UL-CQI exired for user " << (*itUl).first);
2311  (*itMap).second.clear ();
2312  m_ueCqi.erase (itMap);
2313  std::map <uint16_t,uint32_t>::iterator temp = itUl;
2314  itUl++;
2315  m_ueCqiTimers.erase (temp);
2316  }
2317  else
2318  {
2319  (*itUl).second--;
2320  itUl++;
2321  }
2322  }
2323 
2324  return;
2325 }
2326 
2327 void
2328 PssFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
2329 {
2330  std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2331  LteFlowId_t flow (rnti, lcid);
2332  it = m_rlcBufferReq.find (flow);
2333  if (it != m_rlcBufferReq.end ())
2334  {
2335  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);
2336  // Update queues: RLC tx order Status, ReTx, Tx
2337  // Update status queue
2338  if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2339  {
2340  (*it).second.m_rlcStatusPduSize = 0;
2341  }
2342  else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2343  {
2344  (*it).second.m_rlcRetransmissionQueueSize = 0;
2345  }
2346  else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2347  {
2348  uint32_t rlcOverhead;
2349  if (lcid == 1)
2350  {
2351  // for SRB1 (using RLC AM) it's better to
2352  // overestimate RLC overhead rather than
2353  // underestimate it and risk unneeded
2354  // segmentation which increases delay
2355  rlcOverhead = 4;
2356  }
2357  else
2358  {
2359  // minimum RLC overhead due to header
2360  rlcOverhead = 2;
2361  }
2362  // update transmission queue
2363  if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2364  {
2365  (*it).second.m_rlcTransmissionQueueSize = 0;
2366  }
2367  else
2368  {
2369  (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2370  }
2371  }
2372  }
2373  else
2374  {
2375  NS_LOG_ERROR (this << " Does not find DL RLC Buffer Report of UE " << rnti);
2376  }
2377 }
2378 
2379 void
2380 PssFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
2381 {
2382 
2383  size = size - 2; // remove the minimum RLC overhead
2384  std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
2385  if (it != m_ceBsrRxed.end ())
2386  {
2387  NS_LOG_INFO (this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
2388  if ((*it).second >= size)
2389  {
2390  (*it).second -= size;
2391  }
2392  else
2393  {
2394  (*it).second = 0;
2395  }
2396  }
2397  else
2398  {
2399  NS_LOG_ERROR (this << " Does not find BSR report info of UE " << rnti);
2400  }
2401 
2402 }
2403 
2404 void
2406 {
2407  NS_LOG_FUNCTION (this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
2409  params.m_rnti = rnti;
2410  params.m_transmissionMode = txMode;
2412 }
2413 
2414 
2415 }
virtual void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters &params)
std::vector< struct UlInfoListElement_s > m_ulInfoList
See section 4.3.1 dlDciListElement.
Definition: ff-mac-common.h:88
std::map< uint16_t, uint32_t > m_p10CqiTimers
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
void DoCschedLcConfigReq(const struct FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
#define HARQ_PERIOD
Definition: lte-common.h:30
Hold a bool native type.
Definition: boolean.h:38
std::map< uint16_t, uint8_t > m_uesTxMode
void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
hold variables of type string
Definition: string.h:19
int LcActivePerFlow(uint16_t rnti)
void DoCschedLcReleaseReq(const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
std::map< uint16_t, uint8_t > m_p10CqiRxed
enum ns3::UlCqi_s::Type_e m_type
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
std::vector< UlDciListElement_s > UlHarqProcessesDciBuffer_t
std::vector< struct LogicalChannelConfigListElement_s > m_logicalChannelConfigList
std::vector< uint16_t > m_sinr
std::map< uint16_t, pssFlowPerf_t > m_flowStatsUl
std::vector< uint8_t > DlHarqProcessesTimer_t
#define NO_SINR
#define NS_ASSERT(condition)
Definition: assert.h:64
virtual void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters &params)
std::vector< uint8_t > m_mcs
Definition: ff-mac-common.h:95
See section 4.3.2 ulDciListElement.
Provides the CSCHED SAP.
int PssType0AllocationRbg[4]
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
virtual void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters &params)
std::vector< struct UlDciListElement_s > m_dciList
#define NS_LOG_INFO(msg)
Definition: log.h:264
See section 4.3.10 buildRARListElement.
virtual void CschedUeConfigReq(const struct CschedUeConfigReqParameters &params)
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
std::vector< std::vector< struct RlcPduListElement_s > > m_rlcPduList
static TypeId GetTypeId(void)
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
FfMacCschedSapUser * m_cschedSapUser
void DoSchedUlMacCtrlInfoReq(const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
void DoSchedDlTriggerReq(const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
int GetRbgSize(int dlbandwidth)
virtual void CschedUeConfigUpdateInd(const struct CschedUeConfigUpdateIndParameters &params)=0
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
void DoSchedDlCqiInfoReq(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
double secondLastAveragedThroughput
Past average throughput.
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
Hold an unsigned integer type.
Definition: uinteger.h:46
static uint8_t TxMode2LayerNum(uint8_t txMode)
Definition: lte-common.cc:170
Ptr< SampleEmitter > s
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
std::vector< uint8_t > m_ndi
Definition: ff-mac-common.h:96
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
void DoSchedDlRlcBufferReq(const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Provides the SCHED SAP.
virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters &params)
virtual void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters &params)=0
unsigned int lastTtiBytesTransmitted
Total bytes send by eNb for this UE.
#define NS_LOG_LOGIC(msg)
Definition: log.h:334
friend class PssSchedulerMemberSchedSapProvider
std::vector< struct CqiListElement_s > m_cqiList
std::vector< struct DlInfoListElement_s > m_dlInfoList
virtual void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters &params)
void DoCschedUeConfigReq(const struct FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
double lastAveragedThroughput
Total bytes send by eNB in last tti for this UE.
virtual void SchedDlConfigInd(const struct SchedDlConfigIndParameters &params)=0
virtual void CschedLcConfigReq(const struct CschedLcConfigReqParameters &params)
std::vector< uint16_t > m_tbsSize
Definition: ff-mac-common.h:94
See section 4.3.9 rlcPDU_ListElement.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
void DoSchedUlNoiseInterferenceReq(const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
void DoSchedDlPagingBufferReq(const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
unsigned long totalBytesTransmitted
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
std::vector< uint8_t > m_rv
Definition: ff-mac-common.h:97
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
std::map< uint16_t, pssFlowPerf_t > m_flowStatsDl
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
virtual void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters &params)
virtual void SchedUlConfigInd(const struct SchedUlConfigIndParameters &params)=0
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
static Time Now(void)
Definition: simulator.cc:180
NS_LOG_COMPONENT_DEFINE("PssFfMacScheduler")
UlCqiFilter_t m_ulCqiFilter
void DoSchedUlTriggerReq(const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
#define SRS_CQI_RNTI_VSP
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
std::vector< struct RachListElement_s > m_rachList
void DoSchedDlMacBufferReq(const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
std::vector< struct MacCeListElement_s > m_macCeList
std::vector< struct RachListElement_s > m_rachList
void DoCschedCellConfigReq(const struct FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
static double fpS11dot3toDouble(uint16_t val)
Definition: lte-common.cc:114
#define HARQ_PROC_NUM
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
void DoSchedUlCqiInfoReq(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
std::map< uint16_t, uint32_t > m_ceBsrRxed
std::vector< uint8_t > UlHarqProcessesStatus_t
virtual void DoDispose(void)
std::vector< uint8_t > DlHarqProcessesStatus_t
virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters &params)
void DoSchedDlRachInfoReq(const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
static uint32_t BsrId2BufferSize(uint8_t val)
Definition: lte-common.cc:142
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters &params)
std::vector< uint16_t > m_rachAllocationMap
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
virtual void SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters &params)
FfMacCschedSapProvider * m_cschedSapProvider
std::map< uint16_t, uint32_t > m_a30CqiTimers
virtual void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters &params)
virtual void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters &params)
std::map< uint16_t, std::vector< double > > m_ueCqi
std::map< uint16_t, uint32_t > m_ueCqiTimers
#define NS_LOG_ERROR(msg)
Definition: log.h:237
void DoCschedUeReleaseReq(const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
struct DlDciListElement_s m_dci
#define HARQ_DL_TIMEOUT
std::vector< struct BuildRarListElement_s > m_buildRarList
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
FfMacSchedSapUser * m_schedSapUser
a unique identifier for an interface.
Definition: type-id.h:49
FfMacSchedSapProvider * m_schedSapProvider
virtual void SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters &params)
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters &params)
CSCHED_CELL_CONFIG_REQ.
std::vector< struct BuildDataListElement_s > m_buildDataList
virtual void SchedUlNoiseInterferenceReq(const struct SchedUlNoiseInterferenceReqParameters &params)
friend class PssSchedulerMemberCschedSapProvider
See section 4.3.8 builDataListElement.
Implements the SCHED SAP and CSCHED SAP for a Priority Set scheduler.