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