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