A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
rr-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 */
8
10
11#include "lte-amc.h"
12#include "lte-common.h"
14
15#include <ns3/boolean.h>
16#include <ns3/log.h>
17#include <ns3/math.h>
18#include <ns3/pointer.h>
19#include <ns3/simulator.h>
20
21#include <cfloat>
22#include <climits>
23#include <set>
24
25namespace ns3
26{
27
28NS_LOG_COMPONENT_DEFINE("RrFfMacScheduler");
29
30/// Type 0 allocation RBG
31static const int Type0AllocationRbg[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(RrFfMacScheduler);
39
41 : m_cschedSapUser(nullptr),
42 m_schedSapUser(nullptr),
43 m_nextRntiDl(0),
44 m_nextRntiUl(0)
45{
49}
50
55
56void
70
73{
74 static TypeId tid =
75 TypeId("ns3::RrFfMacScheduler")
77 .SetGroupName("Lte")
78 .AddConstructor<RrFfMacScheduler>()
79 .AddAttribute("CqiTimerThreshold",
80 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
81 UintegerValue(1000),
84 .AddAttribute("HarqEnabled",
85 "Activate/Deactivate the HARQ [by default is active].",
86 BooleanValue(true),
89 .AddAttribute("UlGrantMcs",
90 "The MCS of the UL grant, must be [0..15] (default 0)",
94 return tid;
95}
96
97void
102
103void
108
114
120
121void
126
132
133void
145
146void
149{
150 NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode "
151 << (uint16_t)params.m_transmissionMode);
152 auto it = m_uesTxMode.find(params.m_rnti);
153 if (it == m_uesTxMode.end())
154 {
155 m_uesTxMode[params.m_rnti] = params.m_transmissionMode;
156 // generate HARQ buffers
157 m_dlHarqCurrentProcessId[params.m_rnti] = 0;
158 DlHarqProcessesStatus_t dlHarqPrcStatus;
159 dlHarqPrcStatus.resize(8, 0);
160 m_dlHarqProcessesStatus[params.m_rnti] = dlHarqPrcStatus;
161 DlHarqProcessesTimer_t dlHarqProcessesTimer;
162 dlHarqProcessesTimer.resize(8, 0);
163 m_dlHarqProcessesTimer[params.m_rnti] = dlHarqProcessesTimer;
165 dlHarqdci.resize(8);
166 m_dlHarqProcessesDciBuffer[params.m_rnti] = dlHarqdci;
167 DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
168 dlHarqRlcPdu.resize(2);
169 dlHarqRlcPdu.at(0).resize(8);
170 dlHarqRlcPdu.at(1).resize(8);
171 m_dlHarqProcessesRlcPduListBuffer[params.m_rnti] = dlHarqRlcPdu;
172 m_ulHarqCurrentProcessId[params.m_rnti] = 0;
173 UlHarqProcessesStatus_t ulHarqPrcStatus;
174 ulHarqPrcStatus.resize(8, 0);
175 m_ulHarqProcessesStatus[params.m_rnti] = ulHarqPrcStatus;
177 ulHarqdci.resize(8);
178 m_ulHarqProcessesDciBuffer[params.m_rnti] = ulHarqdci;
179 }
180 else
181 {
182 (*it).second = params.m_transmissionMode;
183 }
184}
185
186void
189{
190 NS_LOG_FUNCTION(this);
191 // Not used at this stage (LCs updated by DoSchedDlRlcBufferReq)
192}
193
194void
197{
198 NS_LOG_FUNCTION(this);
199 for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++)
200 {
201 auto it = m_rlcBufferReq.begin();
202 while (it != m_rlcBufferReq.end())
203 {
204 if (((*it).m_rnti == params.m_rnti) &&
205 ((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity.at(i)))
206 {
207 it = m_rlcBufferReq.erase(it);
208 }
209 else
210 {
211 it++;
212 }
213 }
214 }
215}
216
217void
220{
221 NS_LOG_FUNCTION(this << " Release RNTI " << params.m_rnti);
222
223 m_uesTxMode.erase(params.m_rnti);
224 m_dlHarqCurrentProcessId.erase(params.m_rnti);
225 m_dlHarqProcessesStatus.erase(params.m_rnti);
226 m_dlHarqProcessesTimer.erase(params.m_rnti);
227 m_dlHarqProcessesDciBuffer.erase(params.m_rnti);
228 m_dlHarqProcessesRlcPduListBuffer.erase(params.m_rnti);
229 m_ulHarqCurrentProcessId.erase(params.m_rnti);
230 m_ulHarqProcessesStatus.erase(params.m_rnti);
231 m_ulHarqProcessesDciBuffer.erase(params.m_rnti);
232 m_ceBsrRxed.erase(params.m_rnti);
233 auto it = m_rlcBufferReq.begin();
234 while (it != m_rlcBufferReq.end())
235 {
236 if ((*it).m_rnti == params.m_rnti)
237 {
238 NS_LOG_INFO(this << " Erase RNTI " << (*it).m_rnti << " LC "
239 << (uint16_t)(*it).m_logicalChannelIdentity);
240 it = m_rlcBufferReq.erase(it);
241 }
242 else
243 {
244 it++;
245 }
246 }
247 if (m_nextRntiUl == params.m_rnti)
248 {
249 m_nextRntiUl = 0;
250 }
251
252 if (m_nextRntiDl == params.m_rnti)
253 {
254 m_nextRntiDl = 0;
255 }
256}
257
258void
261{
262 NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity);
263 // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
264 auto it = m_rlcBufferReq.begin();
265 bool newLc = true;
266 while (it != m_rlcBufferReq.end())
267 {
268 // remove old entries of this UE-LC
269 if (((*it).m_rnti == params.m_rnti) &&
270 ((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity))
271 {
272 it = m_rlcBufferReq.erase(it);
273 newLc = false;
274 }
275 else
276 {
277 ++it;
278 }
279 }
280 // add the new parameters
281 m_rlcBufferReq.insert(it, params);
282 NS_LOG_INFO(this << " RNTI " << params.m_rnti << " LC "
283 << (uint16_t)params.m_logicalChannelIdentity << " RLC tx size "
284 << params.m_rlcTransmissionQueueSize << " RLC retx size "
285 << params.m_rlcRetransmissionQueueSize << " RLC stat size "
286 << params.m_rlcStatusPduSize);
287 // initialize statistics of the flow in case of new flows
288 if (newLc)
289 {
290 m_p10CqiRxed.emplace(params.m_rnti, 1); // only codeword 0 at this stage (SISO)
291 // initialized to 1 (i.e., the lowest value for transmitting a signal)
292 m_p10CqiTimers[params.m_rnti] = m_cqiTimersThreshold;
293 }
294}
295
296void
303
304void
311
312int
314{
315 for (int i = 0; i < 4; i++)
316 {
317 if (dlbandwidth < Type0AllocationRbg[i])
318 {
319 return i + 1;
320 }
321 }
322
323 return -1;
324}
325
326bool
332
333bool
335{
336 NS_LOG_FUNCTION(this << rnti);
337
338 auto it = m_dlHarqCurrentProcessId.find(rnti);
339 if (it == m_dlHarqCurrentProcessId.end())
340 {
341 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
342 }
343 auto itStat = m_dlHarqProcessesStatus.find(rnti);
344 if (itStat == m_dlHarqProcessesStatus.end())
345 {
346 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
347 }
348 uint8_t i = (*it).second;
349 do
350 {
351 i = (i + 1) % HARQ_PROC_NUM;
352 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
353
354 return (*itStat).second.at(i) == 0;
355}
356
357uint8_t
359{
360 NS_LOG_FUNCTION(this << rnti);
361
362 if (!m_harqOn)
363 {
364 return 0;
365 }
366
367 auto it = m_dlHarqCurrentProcessId.find(rnti);
368 if (it == m_dlHarqCurrentProcessId.end())
369 {
370 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
371 }
372 auto itStat = m_dlHarqProcessesStatus.find(rnti);
373 if (itStat == m_dlHarqProcessesStatus.end())
374 {
375 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
376 }
377 uint8_t i = (*it).second;
378 do
379 {
380 i = (i + 1) % HARQ_PROC_NUM;
381 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
382 if ((*itStat).second.at(i) == 0)
383 {
384 (*it).second = i;
385 (*itStat).second.at(i) = 1;
386 }
387 else
388 {
389 return 9; // return a not valid harq proc id
390 }
391
392 return (*it).second;
393}
394
395void
397{
398 NS_LOG_FUNCTION(this);
399
400 for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end();
401 itTimers++)
402 {
403 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
404 {
405 if ((*itTimers).second.at(i) == HARQ_DL_TIMEOUT)
406 {
407 // reset HARQ process
408
409 NS_LOG_INFO(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first);
410 auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first);
411 if (itStat == m_dlHarqProcessesStatus.end())
412 {
413 NS_FATAL_ERROR("No Process Id Status found for this RNTI "
414 << (*itTimers).first);
415 }
416 (*itStat).second.at(i) = 0;
417 (*itTimers).second.at(i) = 0;
418 }
419 else
420 {
421 (*itTimers).second.at(i)++;
422 }
423 }
424 }
425}
426
427void
430{
431 NS_LOG_FUNCTION(this << " DL Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
432 << (0xF & params.m_sfnSf));
433 // API generated by RLC for triggering the scheduling of a DL subframe
434
437 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
439
440 // Generate RBGs map
441 std::vector<bool> rbgMap;
442 uint16_t rbgAllocatedNum = 0;
443 std::set<uint16_t> rntiAllocated;
444 rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false);
445
446 // update UL HARQ proc id
447 for (auto itProcId = m_ulHarqCurrentProcessId.begin();
448 itProcId != m_ulHarqCurrentProcessId.end();
449 itProcId++)
450 {
451 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
452 }
453
454 // RACH Allocation
456 uint16_t rbStart = 0;
457 for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++)
458 {
460 (*itRach).m_estimatedSize,
461 " Default UL Grant MCS does not allow to send RACH messages");
463 newRar.m_rnti = (*itRach).m_rnti;
464 // DL-RACH Allocation
465 // Ideal: no needs of configuring m_dci
466 // UL-RACH Allocation
467 newRar.m_grant.m_rnti = newRar.m_rnti;
468 newRar.m_grant.m_mcs = m_ulGrantMcs;
469 uint16_t rbLen = 1;
470 uint16_t tbSizeBits = 0;
471 // find lowest TB size that fits UL grant estimated size
472 while ((tbSizeBits < (*itRach).m_estimatedSize) &&
473 (rbStart + rbLen < m_cschedCellConfig.m_ulBandwidth))
474 {
475 rbLen++;
476 tbSizeBits = m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, rbLen);
477 }
478 if (tbSizeBits < (*itRach).m_estimatedSize)
479 {
480 // no more allocation space: finish allocation
481 break;
482 }
483 newRar.m_grant.m_rbStart = rbStart;
484 newRar.m_grant.m_rbLen = rbLen;
485 newRar.m_grant.m_tbSize = tbSizeBits / 8;
486 newRar.m_grant.m_hopping = false;
487 newRar.m_grant.m_tpc = 0;
488 newRar.m_grant.m_cqiRequest = false;
489 newRar.m_grant.m_ulDelay = false;
490 NS_LOG_INFO(this << " UL grant allocated to RNTI " << (*itRach).m_rnti << " rbStart "
491 << rbStart << " rbLen " << rbLen << " MCS " << (uint16_t)m_ulGrantMcs
492 << " tbSize " << newRar.m_grant.m_tbSize);
493 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
494 {
495 m_rachAllocationMap.at(i) = (*itRach).m_rnti;
496 }
497
498 if (m_harqOn)
499 {
500 // generate UL-DCI for HARQ retransmissions
501 UlDciListElement_s uldci;
502 uldci.m_rnti = newRar.m_rnti;
503 uldci.m_rbLen = rbLen;
504 uldci.m_rbStart = rbStart;
505 uldci.m_mcs = m_ulGrantMcs;
506 uldci.m_tbSize = tbSizeBits / 8;
507 uldci.m_ndi = 1;
508 uldci.m_cceIndex = 0;
509 uldci.m_aggrLevel = 1;
510 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
511 uldci.m_hopping = false;
512 uldci.m_n2Dmrs = 0;
513 uldci.m_tpc = 0; // no power control
514 uldci.m_cqiRequest = false; // only period CQI at this stage
515 uldci.m_ulIndex = 0; // TDD parameter
516 uldci.m_dai = 1; // TDD parameter
517 uldci.m_freqHopping = 0;
518 uldci.m_pdcchPowerOffset = 0; // not used
519
520 uint8_t harqId = 0;
521 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
522 if (itProcId == m_ulHarqCurrentProcessId.end())
523 {
524 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
525 }
526 harqId = (*itProcId).second;
527 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
528 if (itDci == m_ulHarqProcessesDciBuffer.end())
529 {
530 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
531 << uldci.m_rnti);
532 }
533 (*itDci).second.at(harqId) = uldci;
534 }
535
536 rbStart = rbStart + rbLen;
537 ret.m_buildRarList.push_back(newRar);
538 }
539 m_rachList.clear();
540
541 // Process DL HARQ feedback
543 // retrieve past HARQ retx buffered
544 if (!m_dlInfoListBuffered.empty())
545 {
546 if (!params.m_dlInfoList.empty())
547 {
548 NS_LOG_INFO(this << " Received DL-HARQ feedback");
550 params.m_dlInfoList.begin(),
551 params.m_dlInfoList.end());
552 }
553 }
554 else
555 {
556 if (!params.m_dlInfoList.empty())
557 {
558 m_dlInfoListBuffered = params.m_dlInfoList;
559 }
560 }
561 if (!m_harqOn)
562 {
563 // Ignore HARQ feedback
564 m_dlInfoListBuffered.clear();
565 }
566 std::vector<DlInfoListElement_s> dlInfoListUntxed;
567 for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++)
568 {
569 auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti);
570 if (itRnti != rntiAllocated.end())
571 {
572 // RNTI already allocated for retx
573 continue;
574 }
575 auto nLayers = m_dlInfoListBuffered.at(i).m_harqStatus.size();
576 std::vector<bool> retx;
577 NS_LOG_INFO(this << " Processing DLHARQ feedback");
578 if (nLayers == 1)
579 {
580 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
582 retx.push_back(false);
583 }
584 else
585 {
586 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
588 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(1) ==
590 }
591 if (retx.at(0) || retx.at(1))
592 {
593 // retrieve HARQ process information
594 uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti;
595 uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId;
596 NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
597 auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti);
598 if (itHarq == m_dlHarqProcessesDciBuffer.end())
599 {
600 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti);
601 }
602
603 DlDciListElement_s dci = (*itHarq).second.at(harqId);
604 int rv = 0;
605 if (dci.m_rv.size() == 1)
606 {
607 rv = dci.m_rv.at(0);
608 }
609 else
610 {
611 rv = (dci.m_rv.at(0) > dci.m_rv.at(1) ? dci.m_rv.at(0) : dci.m_rv.at(1));
612 }
613
614 if (rv == 3)
615 {
616 // maximum number of retx reached -> drop process
617 NS_LOG_INFO("Max number of retransmissions reached -> drop process");
618 auto it = m_dlHarqProcessesStatus.find(rnti);
619 if (it == m_dlHarqProcessesStatus.end())
620 {
621 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
622 << m_dlInfoListBuffered.at(i).m_rnti);
623 }
624 (*it).second.at(harqId) = 0;
625 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
626 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
627 {
628 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
629 << m_dlInfoListBuffered.at(i).m_rnti);
630 }
631 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
632 {
633 (*itRlcPdu).second.at(k).at(harqId).clear();
634 }
635 continue;
636 }
637 // check the feasibility of retransmitting on the same RBGs
638 // translate the DCI to Spectrum framework
639 std::vector<int> dciRbg;
640 uint32_t mask = 0x1;
641 NS_LOG_INFO("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
642 for (int j = 0; j < 32; j++)
643 {
644 if (((dci.m_rbBitmap & mask) >> j) == 1)
645 {
646 dciRbg.push_back(j);
647 NS_LOG_INFO("\t" << j);
648 }
649 mask = (mask << 1);
650 }
651 bool free = true;
652 for (std::size_t j = 0; j < dciRbg.size(); j++)
653 {
654 if (rbgMap.at(dciRbg.at(j)))
655 {
656 free = false;
657 break;
658 }
659 }
660 if (free)
661 {
662 // use the same RBGs for the retx
663 // reserve RBGs
664 for (std::size_t j = 0; j < dciRbg.size(); j++)
665 {
666 rbgMap.at(dciRbg.at(j)) = true;
667 NS_LOG_INFO("RBG " << dciRbg.at(j) << " assigned");
668 rbgAllocatedNum++;
669 }
670
671 NS_LOG_INFO(this << " Send retx in the same RBGs");
672 }
673 else
674 {
675 // find RBGs for sending HARQ retx
676 uint8_t j = 0;
677 uint8_t rbgId = (dciRbg.at(dciRbg.size() - 1) + 1) % rbgNum;
678 uint8_t startRbg = dciRbg.at(dciRbg.size() - 1);
679 std::vector<bool> rbgMapCopy = rbgMap;
680 while ((j < dciRbg.size()) && (startRbg != rbgId))
681 {
682 if (!rbgMapCopy.at(rbgId))
683 {
684 rbgMapCopy.at(rbgId) = true;
685 dciRbg.at(j) = rbgId;
686 j++;
687 }
688 rbgId = (rbgId + 1) % rbgNum;
689 }
690 if (j == dciRbg.size())
691 {
692 // find new RBGs -> update DCI map
693 uint32_t rbgMask = 0;
694 for (std::size_t k = 0; k < dciRbg.size(); k++)
695 {
696 rbgMask = rbgMask + (0x1 << dciRbg.at(k));
697 NS_LOG_INFO(this << " New allocated RBG " << dciRbg.at(k));
698 rbgAllocatedNum++;
699 }
700 dci.m_rbBitmap = rbgMask;
701 rbgMap = rbgMapCopy;
702 }
703 else
704 {
705 // HARQ retx cannot be performed on this TTI -> store it
706 dlInfoListUntxed.push_back(m_dlInfoListBuffered.at(i));
707 NS_LOG_INFO(this << " No resource for this retx -> buffer it");
708 }
709 }
710 // retrieve RLC PDU list for retx TBsize and update DCI
712 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
713 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
714 {
715 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
716 }
717 for (std::size_t j = 0; j < nLayers; j++)
718 {
719 if (retx.at(j))
720 {
721 if (j >= dci.m_ndi.size())
722 {
723 // for avoiding errors in MIMO transient phases
724 dci.m_ndi.push_back(0);
725 dci.m_rv.push_back(0);
726 dci.m_mcs.push_back(0);
727 dci.m_tbsSize.push_back(0);
728 NS_LOG_INFO(this << " layer " << (uint16_t)j
729 << " no txed (MIMO transition)");
730 }
731 else
732 {
733 dci.m_ndi.at(j) = 0;
734 dci.m_rv.at(j)++;
735 (*itHarq).second.at(harqId).m_rv.at(j)++;
736 NS_LOG_INFO(this << " layer " << (uint16_t)j << " RV "
737 << (uint16_t)dci.m_rv.at(j));
738 }
739 }
740 else
741 {
742 // empty TB of layer j
743 dci.m_ndi.at(j) = 0;
744 dci.m_rv.at(j) = 0;
745 dci.m_mcs.at(j) = 0;
746 dci.m_tbsSize.at(j) = 0;
747 NS_LOG_INFO(this << " layer " << (uint16_t)j << " no retx");
748 }
749 }
750
751 for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++)
752 {
753 std::vector<RlcPduListElement_s> rlcPduListPerLc;
754 for (std::size_t j = 0; j < nLayers; j++)
755 {
756 if (retx.at(j))
757 {
758 if (j < dci.m_ndi.size())
759 {
760 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size "
761 << dci.m_tbsSize.at(j));
762 rlcPduListPerLc.push_back(
763 (*itRlcPdu).second.at(j).at(dci.m_harqProcess).at(k));
764 }
765 }
766 else
767 { // if no retx needed on layer j, push an RlcPduListElement_s object with
768 // m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
769 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at(j));
770 RlcPduListElement_s emptyElement;
771 emptyElement.m_logicalChannelIdentity = (*itRlcPdu)
772 .second.at(j)
773 .at(dci.m_harqProcess)
774 .at(k)
775 .m_logicalChannelIdentity;
776 emptyElement.m_size = 0;
777 rlcPduListPerLc.push_back(emptyElement);
778 }
779 }
780
781 if (!rlcPduListPerLc.empty())
782 {
783 newEl.m_rlcPduList.push_back(rlcPduListPerLc);
784 }
785 }
786 newEl.m_rnti = rnti;
787 newEl.m_dci = dci;
788 (*itHarq).second.at(harqId).m_rv = dci.m_rv;
789 // refresh timer
790 auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti);
791 if (itHarqTimer == m_dlHarqProcessesTimer.end())
792 {
793 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
794 }
795 (*itHarqTimer).second.at(harqId) = 0;
796 ret.m_buildDataList.push_back(newEl);
797 rntiAllocated.insert(rnti);
798 }
799 else
800 {
801 // update HARQ process status
802 NS_LOG_INFO(this << " HARQ ACK UE " << m_dlInfoListBuffered.at(i).m_rnti);
803 auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti);
804 if (it == m_dlHarqProcessesStatus.end())
805 {
806 NS_FATAL_ERROR("No info find in HARQ buffer for UE "
807 << m_dlInfoListBuffered.at(i).m_rnti);
808 }
809 (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0;
810 auto itRlcPdu =
812 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
813 {
814 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
815 << m_dlInfoListBuffered.at(i).m_rnti);
816 }
817 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
818 {
819 (*itRlcPdu).second.at(k).at(m_dlInfoListBuffered.at(i).m_harqProcessId).clear();
820 }
821 }
822 }
823 m_dlInfoListBuffered.clear();
824 m_dlInfoListBuffered = dlInfoListUntxed;
825
826 if (rbgAllocatedNum == rbgNum)
827 {
828 // all the RBGs are already allocated -> exit
829 if (!ret.m_buildDataList.empty() || !ret.m_buildRarList.empty())
830 {
832 }
833 return;
834 }
835
836 // Get the actual active flows (queue!=0)
837 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
839 int nflows = 0;
840 int nTbs = 0;
841 std::map<uint16_t, uint8_t> lcActivesPerRnti; // tracks how many active LCs per RNTI there are
842 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
843 {
844 // remove old entries of this UE-LC
845 auto itRnti = rntiAllocated.find((*it).m_rnti);
846 if ((((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) ||
847 ((*it).m_rlcStatusPduSize > 0)) &&
848 (itRnti == rntiAllocated.end()) // UE must not be allocated for HARQ retx
849 && (HarqProcessAvailability((*it).m_rnti))) // UE needs HARQ proc free
850
851 {
852 NS_LOG_LOGIC(this << " User " << (*it).m_rnti << " LC "
853 << (uint16_t)(*it).m_logicalChannelIdentity << " is active, status "
854 << (*it).m_rlcStatusPduSize << " retx "
855 << (*it).m_rlcRetransmissionQueueSize << " tx "
856 << (*it).m_rlcTransmissionQueueSize);
857 auto itCqi = m_p10CqiRxed.find((*it).m_rnti);
858 uint8_t cqi = 0;
859 if (itCqi != m_p10CqiRxed.end())
860 {
861 cqi = (*itCqi).second;
862 }
863 else
864 {
865 cqi = 1; // lowest value for trying a transmission
866 }
867 if (cqi != 0)
868 {
869 // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
870 nflows++;
871 auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti);
872 if (itLcRnti != lcActivesPerRnti.end())
873 {
874 (*itLcRnti).second++;
875 }
876 else
877 {
878 lcActivesPerRnti[(*it).m_rnti] = 1;
879 nTbs++;
880 }
881 }
882 }
883 }
884
885 if (nflows == 0)
886 {
887 if ((!ret.m_buildDataList.empty()) || (!ret.m_buildRarList.empty()))
888 {
890 }
891 return;
892 }
893 // Divide the resource equally among the active users according to
894 // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
895
896 int rbgPerTb = (nTbs > 0) ? ((rbgNum - rbgAllocatedNum) / nTbs) : INT_MAX;
897 NS_LOG_INFO(this << " Flows to be transmitted " << nflows << " rbgPerTb " << rbgPerTb);
898 if (rbgPerTb == 0)
899 {
900 rbgPerTb = 1; // at least 1 rbg per TB (till available resource)
901 }
902 int rbgAllocated = 0;
903
904 // round robin assignment to all UEs registered starting from the subsequent of the one
905 // served last scheduling trigger event
906 if (m_nextRntiDl != 0)
907 {
908 NS_LOG_DEBUG("Start from the successive of " << (uint16_t)m_nextRntiDl);
909 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
910 {
911 if ((*it).m_rnti == m_nextRntiDl)
912 {
913 // select the next RNTI to starting
914 it++;
915 if (it == m_rlcBufferReq.end())
916 {
917 it = m_rlcBufferReq.begin();
918 }
919 m_nextRntiDl = (*it).m_rnti;
920 break;
921 }
922 }
923
924 if (it == m_rlcBufferReq.end())
925 {
926 NS_LOG_ERROR(this << " no user found");
927 }
928 }
929 else
930 {
931 it = m_rlcBufferReq.begin();
932 m_nextRntiDl = (*it).m_rnti;
933 }
934 do
935 {
936 auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti);
937 auto itRnti = rntiAllocated.find((*it).m_rnti);
938 if ((itLcRnti == lcActivesPerRnti.end()) || (itRnti != rntiAllocated.end()))
939 {
940 // skip this RNTI (no active queue or yet allocated for HARQ)
941 uint16_t rntiDiscarded = (*it).m_rnti;
942 while (it != m_rlcBufferReq.end())
943 {
944 if ((*it).m_rnti != rntiDiscarded)
945 {
946 break;
947 }
948 it++;
949 }
950 if (it == m_rlcBufferReq.end())
951 {
952 // restart from the first
953 it = m_rlcBufferReq.begin();
954 }
955 continue;
956 }
957 auto itTxMode = m_uesTxMode.find((*it).m_rnti);
958 if (itTxMode == m_uesTxMode.end())
959 {
960 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).m_rnti);
961 }
962 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
963 int lcNum = (*itLcRnti).second;
964 // create new BuildDataListElement_s for this RNTI
966 newEl.m_rnti = (*it).m_rnti;
967 // create the DlDciListElement_s
968 DlDciListElement_s newDci;
969 newDci.m_rnti = (*it).m_rnti;
970 newDci.m_harqProcess = UpdateHarqProcessId((*it).m_rnti);
971 newDci.m_resAlloc = 0;
972 newDci.m_rbBitmap = 0;
973 auto itCqi = m_p10CqiRxed.find(newEl.m_rnti);
974 for (uint8_t i = 0; i < nLayer; i++)
975 {
976 if (itCqi == m_p10CqiRxed.end())
977 {
978 newDci.m_mcs.push_back(0); // no info on this user -> lowest MCS
979 }
980 else
981 {
982 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi((*itCqi).second));
983 }
984 }
985 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(0), rbgPerTb * rbgSize) / 8);
986 uint16_t rlcPduSize = tbSize / lcNum;
987 while ((*it).m_rnti == newEl.m_rnti)
988 {
989 if (((*it).m_rlcTransmissionQueueSize > 0) ||
990 ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0))
991 {
992 std::vector<RlcPduListElement_s> newRlcPduLe;
993 for (uint8_t j = 0; j < nLayer; j++)
994 {
995 RlcPduListElement_s newRlcEl;
996 newRlcEl.m_logicalChannelIdentity = (*it).m_logicalChannelIdentity;
997 NS_LOG_INFO(this << "LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
998 << " size " << rlcPduSize << " ID " << (*it).m_rnti
999 << " layer " << (uint16_t)j);
1000 newRlcEl.m_size = rlcPduSize;
1001 UpdateDlRlcBufferInfo((*it).m_rnti,
1002 newRlcEl.m_logicalChannelIdentity,
1003 rlcPduSize);
1004 newRlcPduLe.push_back(newRlcEl);
1005
1006 if (m_harqOn)
1007 {
1008 // store RLC PDU list for HARQ
1009 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti);
1010 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1011 {
1012 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1013 << (*it).m_rnti);
1014 }
1015 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1016 }
1017 }
1018 newEl.m_rlcPduList.push_back(newRlcPduLe);
1019 lcNum--;
1020 }
1021 it++;
1022 if (it == m_rlcBufferReq.end())
1023 {
1024 // restart from the first
1025 it = m_rlcBufferReq.begin();
1026 break;
1027 }
1028 }
1029 uint32_t rbgMask = 0;
1030 uint16_t i = 0;
1031 NS_LOG_INFO(this << " DL - Allocate user " << newEl.m_rnti << " LCs "
1032 << (uint16_t)(*itLcRnti).second << " bytes " << tbSize << " mcs "
1033 << (uint16_t)newDci.m_mcs.at(0) << " harqId "
1034 << (uint16_t)newDci.m_harqProcess << " layers " << nLayer);
1035 NS_LOG_INFO("RBG:");
1036 while (i < rbgPerTb)
1037 {
1038 if (!rbgMap.at(rbgAllocated))
1039 {
1040 rbgMask = rbgMask + (0x1 << rbgAllocated);
1041 NS_LOG_INFO("\t " << rbgAllocated);
1042 i++;
1043 rbgMap.at(rbgAllocated) = true;
1044 rbgAllocatedNum++;
1045 }
1046 rbgAllocated++;
1047 }
1048 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1049
1050 for (std::size_t i = 0; i < nLayer; i++)
1051 {
1052 newDci.m_tbsSize.push_back(tbSize);
1053 newDci.m_ndi.push_back(1);
1054 newDci.m_rv.push_back(0);
1055 }
1056
1057 newDci.m_tpc = 1; // 1 is mapped to 0 in Accumulated Mode and to -1 in Absolute Mode
1058
1059 newEl.m_dci = newDci;
1060 if (m_harqOn)
1061 {
1062 // store DCI for HARQ
1063 auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti);
1064 if (itDci == m_dlHarqProcessesDciBuffer.end())
1065 {
1066 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1067 << newEl.m_rnti);
1068 }
1069 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1070 // refresh timer
1071 auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti);
1072 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1073 {
1074 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1075 }
1076 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1077 }
1078 // ...more parameters -> ignored in this version
1079
1080 ret.m_buildDataList.push_back(newEl);
1081 if (rbgAllocatedNum == rbgNum)
1082 {
1083 m_nextRntiDl = newEl.m_rnti; // store last RNTI served
1084 break; // no more RBG to be allocated
1085 }
1086 } while ((*it).m_rnti != m_nextRntiDl);
1087
1088 ret.m_nrOfPdcchOfdmSymbols = 1; /// \todo check correct value according the DCIs txed
1089
1091}
1092
1093void
1096{
1097 NS_LOG_FUNCTION(this);
1098
1099 m_rachList = params.m_rachList;
1100}
1101
1102void
1105{
1106 NS_LOG_FUNCTION(this);
1107
1108 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1109 {
1110 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1111 {
1112 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1113 << " reported");
1114 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1115 auto it = m_p10CqiRxed.find(rnti);
1116 if (it == m_p10CqiRxed.end())
1117 {
1118 // create the new entry
1119 m_p10CqiRxed[rnti] =
1120 params.m_cqiList.at(i).m_wbCqi.at(0); // only codeword 0 at this stage (SISO)
1121 // generate correspondent timer
1123 }
1124 else
1125 {
1126 // update the CQI value
1127 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1128 // update correspondent timer
1129 auto itTimers = m_p10CqiTimers.find(rnti);
1130 (*itTimers).second = m_cqiTimersThreshold;
1131 }
1132 }
1133 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1134 {
1135 // subband CQI reporting high layer configured
1136 // Not used by RR Scheduler
1137 }
1138 else
1139 {
1140 NS_LOG_ERROR(this << " CQI type unknown");
1141 }
1142 }
1143}
1144
1145void
1148{
1149 NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
1150 << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size());
1151
1153
1154 // Generate RBs map
1156 std::vector<bool> rbMap;
1157 std::set<uint16_t> rntiAllocated;
1158 std::vector<uint16_t> rbgAllocationMap;
1159 // update with RACH allocation map
1160 rbgAllocationMap = m_rachAllocationMap;
1161 // rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1162 m_rachAllocationMap.clear();
1164
1165 rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
1166 // remove RACH allocation
1167 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1168 {
1169 if (rbgAllocationMap.at(i) != 0)
1170 {
1171 rbMap.at(i) = true;
1172 NS_LOG_DEBUG(this << " Allocated for RACH " << i);
1173 }
1174 }
1175
1176 if (m_harqOn)
1177 {
1178 // Process UL HARQ feedback
1179 for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++)
1180 {
1181 if (params.m_ulInfoList.at(i).m_receptionStatus == UlInfoListElement_s::NotOk)
1182 {
1183 // retx correspondent block: retrieve the UL-DCI
1184 uint16_t rnti = params.m_ulInfoList.at(i).m_rnti;
1185 auto itProcId = m_ulHarqCurrentProcessId.find(rnti);
1186 if (itProcId == m_ulHarqCurrentProcessId.end())
1187 {
1188 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1189 }
1190 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1191 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId "
1192 << (uint16_t)harqId);
1193 auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti);
1194 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1195 {
1196 NS_LOG_ERROR("No info find in UL-HARQ buffer for UE (might change eNB) "
1197 << rnti);
1198 }
1199 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1200 auto itStat = m_ulHarqProcessesStatus.find(rnti);
1201 if (itStat == m_ulHarqProcessesStatus.end())
1202 {
1203 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1204 }
1205 if ((*itStat).second.at(harqId) >= 3)
1206 {
1207 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1208 continue;
1209 }
1210 bool free = true;
1211 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1212 {
1213 if (rbMap.at(j))
1214 {
1215 free = false;
1216 NS_LOG_INFO(this << " BUSY " << j);
1217 }
1218 }
1219 if (free)
1220 {
1221 // retx on the same RBs
1222 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1223 {
1224 rbMap.at(j) = true;
1225 rbgAllocationMap.at(j) = dci.m_rnti;
1226 NS_LOG_INFO("\tRB " << j);
1227 }
1228 NS_LOG_INFO(this << " Send retx in the same RBGs " << (uint16_t)dci.m_rbStart
1229 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1230 << (*itStat).second.at(harqId) + 1);
1231 }
1232 else
1233 {
1234 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1235 continue;
1236 }
1237 dci.m_ndi = 0;
1238 // Update HARQ buffers with new HarqId
1239 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1240 (*itStat).second.at(harqId) = 0;
1241 (*itHarq).second.at((*itProcId).second) = dci;
1242 ret.m_dciList.push_back(dci);
1243 rntiAllocated.insert(dci.m_rnti);
1244 }
1245 }
1246 }
1247
1248 std::map<uint16_t, uint32_t>::iterator it;
1249 int nflows = 0;
1250
1251 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1252 {
1253 auto itRnti = rntiAllocated.find((*it).first);
1254 // select UEs with queues not empty and not yet allocated for HARQ
1255 NS_LOG_INFO(this << " UE " << (*it).first << " queue " << (*it).second);
1256 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1257 {
1258 nflows++;
1259 }
1260 }
1261
1262 if (nflows == 0)
1263 {
1264 if (!ret.m_dciList.empty())
1265 {
1266 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1268 }
1269 return; // no flows to be scheduled
1270 }
1271
1272 // Divide the remaining resources equally among the active users starting from the subsequent
1273 // one served last scheduling trigger
1274 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size());
1275 if (rbPerFlow < 3)
1276 {
1277 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1278 // >= 7 bytes
1279 }
1280 uint16_t rbAllocated = 0;
1281
1282 if (m_nextRntiUl != 0)
1283 {
1284 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1285 {
1286 if ((*it).first == m_nextRntiUl)
1287 {
1288 break;
1289 }
1290 }
1291 if (it == m_ceBsrRxed.end())
1292 {
1293 NS_LOG_ERROR(this << " no user found");
1294 }
1295 }
1296 else
1297 {
1298 it = m_ceBsrRxed.begin();
1299 m_nextRntiUl = (*it).first;
1300 }
1301 NS_LOG_INFO(this << " NFlows " << nflows << " RB per Flow " << rbPerFlow);
1302 do
1303 {
1304 auto itRnti = rntiAllocated.find((*it).first);
1305 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1306 {
1307 // UE already allocated for UL-HARQ -> skip it
1308 it++;
1309 if (it == m_ceBsrRxed.end())
1310 {
1311 // restart from the first
1312 it = m_ceBsrRxed.begin();
1313 }
1314 continue;
1315 }
1316 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1317 {
1318 // limit to physical resources last resource assignment
1319 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1320 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1321 if (rbPerFlow < 3)
1322 {
1323 // terminate allocation
1324 rbPerFlow = 0;
1325 }
1326 }
1327 NS_LOG_INFO(this << " try to allocate " << (*it).first);
1328 UlDciListElement_s uldci;
1329 uldci.m_rnti = (*it).first;
1330 uldci.m_rbLen = rbPerFlow;
1331 bool allocated = false;
1332 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1333 << " flows " << nflows);
1334 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1335 (rbPerFlow != 0))
1336 {
1337 // check availability
1338 bool free = true;
1339 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1340 {
1341 if (rbMap.at(j))
1342 {
1343 free = false;
1344 break;
1345 }
1346 }
1347 if (free)
1348 {
1349 uldci.m_rbStart = rbAllocated;
1350
1351 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1352 {
1353 rbMap.at(j) = true;
1354 // store info on allocation for managing ul-cqi interpretation
1355 rbgAllocationMap.at(j) = (*it).first;
1356 NS_LOG_INFO("\t " << j);
1357 }
1358 rbAllocated += rbPerFlow;
1359 allocated = true;
1360 break;
1361 }
1362 rbAllocated++;
1363 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1364 {
1365 // limit to physical resources last resource assignment
1366 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1367 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1368 if (rbPerFlow < 3)
1369 {
1370 // terminate allocation
1371 rbPerFlow = 0;
1372 }
1373 }
1374 }
1375 if (!allocated)
1376 {
1377 // unable to allocate new resource: finish scheduling
1378 m_nextRntiUl = (*it).first;
1379 if (!ret.m_dciList.empty())
1380 {
1382 }
1383 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1384 return;
1385 }
1386 auto itCqi = m_ueCqi.find((*it).first);
1387 int cqi = 0;
1388 if (itCqi == m_ueCqi.end())
1389 {
1390 // no cqi info about this UE
1391 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1392 NS_LOG_INFO(this << " UE does not have ULCQI " << (*it).first);
1393 }
1394 else
1395 {
1396 // take the lowest CQI value (worst RB)
1397 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1398 "CQI of RNTI = " << (*it).first << " has expired");
1399 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1400 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1401 {
1402 if ((*itCqi).second.at(i) < minSinr)
1403 {
1404 minSinr = (*itCqi).second.at(i);
1405 }
1406 }
1407 // translate SINR -> cqi: WILD ACK: same as DL
1408 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1409
1410 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1411 if (cqi == 0)
1412 {
1413 it++;
1414 if (it == m_ceBsrRxed.end())
1415 {
1416 // restart from the first
1417 it = m_ceBsrRxed.begin();
1418 }
1419 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1420 // remove UE from allocation map
1421 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1422 {
1423 rbgAllocationMap.at(i) = 0;
1424 }
1425 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1426 }
1427 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1428 }
1429 uldci.m_tbSize =
1430 (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8); // MCS 0 -> UL-AMC TBD
1431
1433 uldci.m_ndi = 1;
1434 uldci.m_cceIndex = 0;
1435 uldci.m_aggrLevel = 1;
1436 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1437 uldci.m_hopping = false;
1438 uldci.m_n2Dmrs = 0;
1439 uldci.m_tpc = 0; // no power control
1440 uldci.m_cqiRequest = false; // only period CQI at this stage
1441 uldci.m_ulIndex = 0; // TDD parameter
1442 uldci.m_dai = 1; // TDD parameter
1443 uldci.m_freqHopping = 0;
1444 uldci.m_pdcchPowerOffset = 0; // not used
1445 ret.m_dciList.push_back(uldci);
1446 // store DCI for HARQ_PERIOD
1447 uint8_t harqId = 0;
1448 if (m_harqOn)
1449 {
1450 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1451 if (itProcId == m_ulHarqCurrentProcessId.end())
1452 {
1453 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
1454 }
1455 harqId = (*itProcId).second;
1456 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
1457 if (itDci == m_ulHarqProcessesDciBuffer.end())
1458 {
1459 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
1460 << uldci.m_rnti);
1461 }
1462 (*itDci).second.at(harqId) = uldci;
1463 // Update HARQ process status (RV 0)
1464 auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti);
1465 if (itStat == m_ulHarqProcessesStatus.end())
1466 {
1467 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
1468 << uldci.m_rnti);
1469 }
1470 (*itStat).second.at(harqId) = 0;
1471 }
1472
1473 NS_LOG_INFO(this << " UL Allocation - UE " << (*it).first << " startPRB "
1474 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
1475 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
1476 << uldci.m_tbSize << " harqId " << (uint16_t)harqId);
1477
1478 it++;
1479 if (it == m_ceBsrRxed.end())
1480 {
1481 // restart from the first
1482 it = m_ceBsrRxed.begin();
1483 }
1484 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1485 {
1486 // Stop allocation: no more PRBs
1487 m_nextRntiUl = (*it).first;
1488 break;
1489 }
1490 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
1491
1492 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1493
1495}
1496
1497void
1503
1504void
1510
1511void
1514{
1515 NS_LOG_FUNCTION(this);
1516
1517 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
1518 {
1519 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
1520 {
1521 // buffer status report
1522 // note that this scheduler does not differentiate the
1523 // allocation according to which LCGs have more/less bytes
1524 // to send.
1525 // Hence the BSR of different LCGs are just summed up to get
1526 // a total queue size that is used for allocation purposes.
1527
1528 uint32_t buffer = 0;
1529 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1530 {
1531 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
1532 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
1533 }
1534
1535 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
1536 auto it = m_ceBsrRxed.find(rnti);
1537 if (it == m_ceBsrRxed.end())
1538 {
1539 // create the new entry
1540 m_ceBsrRxed[rnti] = buffer;
1541 NS_LOG_INFO(this << " Insert RNTI " << rnti << " queue " << buffer);
1542 }
1543 else
1544 {
1545 // update the buffer size value
1546 (*it).second = buffer;
1547 NS_LOG_INFO(this << " Update RNTI " << rnti << " queue " << buffer);
1548 }
1549 }
1550 }
1551}
1552
1553void
1556{
1557 NS_LOG_FUNCTION(this);
1558
1559 switch (m_ulCqiFilter)
1560 {
1562 // filter all the CQIs that are not SRS based
1563 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1564 {
1565 return;
1566 }
1567 }
1568 break;
1570 // filter all the CQIs that are not SRS based
1571 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1572 {
1573 return;
1574 }
1575 }
1576 break;
1577 default:
1578 NS_FATAL_ERROR("Unknown UL CQI type");
1579 }
1580 switch (params.m_ulCqi.m_type)
1581 {
1582 case UlCqi_s::PUSCH: {
1583 auto itMap = m_allocationMaps.find(params.m_sfnSf);
1584 if (itMap == m_allocationMaps.end())
1585 {
1586 NS_LOG_INFO(this << " Does not find info on allocation, size : "
1587 << m_allocationMaps.size());
1588 return;
1589 }
1590 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
1591 {
1592 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1593 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
1594 auto itCqi = m_ueCqi.find((*itMap).second.at(i));
1595 if (itCqi == m_ueCqi.end())
1596 {
1597 // create a new entry
1598 std::vector<double> newCqi;
1599 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1600 {
1601 if (i == j)
1602 {
1603 newCqi.push_back(sinr);
1604 }
1605 else
1606 {
1607 // initialize with NO_SINR value.
1608 newCqi.push_back(30.0);
1609 }
1610 }
1611 m_ueCqi[(*itMap).second.at(i)] = newCqi;
1612 // generate correspondent timer
1613 m_ueCqiTimers[(*itMap).second.at(i)] = m_cqiTimersThreshold;
1614 }
1615 else
1616 {
1617 // update the value
1618 (*itCqi).second.at(i) = sinr;
1619 // update correspondent timer
1620 auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
1621 (*itTimers).second = m_cqiTimersThreshold;
1622 }
1623 }
1624 // remove obsolete info on allocation
1625 m_allocationMaps.erase(itMap);
1626 }
1627 break;
1628 case UlCqi_s::SRS: {
1629 // get the RNTI from vendor specific parameters
1630 uint16_t rnti = 0;
1631 NS_ASSERT(!params.m_vendorSpecificList.empty());
1632 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
1633 {
1634 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
1635 {
1636 Ptr<SrsCqiRntiVsp> vsp =
1637 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
1638 rnti = vsp->GetRnti();
1639 }
1640 }
1641 auto itCqi = m_ueCqi.find(rnti);
1642 if (itCqi == m_ueCqi.end())
1643 {
1644 // create a new entry
1645 std::vector<double> newCqi;
1646 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1647 {
1648 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1649 newCqi.push_back(sinr);
1650 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
1651 << sinr);
1652 }
1653 m_ueCqi[rnti] = newCqi;
1654 // generate correspondent timer
1656 }
1657 else
1658 {
1659 // update the values
1660 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1661 {
1662 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1663 (*itCqi).second.at(j) = sinr;
1664 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
1665 << sinr);
1666 }
1667 // update correspondent timer
1668 auto itTimers = m_ueCqiTimers.find(rnti);
1669 (*itTimers).second = m_cqiTimersThreshold;
1670 }
1671 }
1672 break;
1673 case UlCqi_s::PUCCH_1:
1674 case UlCqi_s::PUCCH_2:
1675 case UlCqi_s::PRACH: {
1676 NS_FATAL_ERROR("PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1677 }
1678 break;
1679 default:
1680 NS_FATAL_ERROR("Unknown type of UL-CQI");
1681 }
1682}
1683
1684void
1686{
1687 NS_LOG_FUNCTION(this << m_p10CqiTimers.size());
1688 // refresh DL CQI P01 Map
1689 auto itP10 = m_p10CqiTimers.begin();
1690 while (itP10 != m_p10CqiTimers.end())
1691 {
1692 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
1693 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1694 if ((*itP10).second == 0)
1695 {
1696 // delete correspondent entries
1697 auto itMap = m_p10CqiRxed.find((*itP10).first);
1698 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
1699 " Does not find CQI report for user " << (*itP10).first);
1700 NS_LOG_INFO(this << " P10-CQI exired for user " << (*itP10).first);
1701 m_p10CqiRxed.erase(itMap);
1702 auto temp = itP10;
1703 itP10++;
1704 m_p10CqiTimers.erase(temp);
1705 }
1706 else
1707 {
1708 (*itP10).second--;
1709 itP10++;
1710 }
1711 }
1712}
1713
1714void
1716{
1717 // refresh UL CQI Map
1718 auto itUl = m_ueCqiTimers.begin();
1719 while (itUl != m_ueCqiTimers.end())
1720 {
1721 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
1722 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1723 if ((*itUl).second == 0)
1724 {
1725 // delete correspondent entries
1726 auto itMap = m_ueCqi.find((*itUl).first);
1727 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
1728 " Does not find CQI report for user " << (*itUl).first);
1729 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
1730 (*itMap).second.clear();
1731 m_ueCqi.erase(itMap);
1732 auto temp = itUl;
1733 itUl++;
1734 m_ueCqiTimers.erase(temp);
1735 }
1736 else
1737 {
1738 (*itUl).second--;
1739 itUl++;
1740 }
1741 }
1742}
1743
1744void
1745RrFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
1746{
1747 NS_LOG_FUNCTION(this);
1748 for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
1749 {
1750 if (((*it).m_rnti == rnti) && ((*it).m_logicalChannelIdentity == lcid))
1751 {
1752 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
1753 << (*it).m_rlcTransmissionQueueSize << " retxqueue "
1754 << (*it).m_rlcRetransmissionQueueSize << " status "
1755 << (*it).m_rlcStatusPduSize << " decrease " << size);
1756 // Update queues: RLC tx order Status, ReTx, Tx
1757 // Update status queue
1758 if (((*it).m_rlcStatusPduSize > 0) && (size >= (*it).m_rlcStatusPduSize))
1759 {
1760 (*it).m_rlcStatusPduSize = 0;
1761 }
1762 else if (((*it).m_rlcRetransmissionQueueSize > 0) &&
1763 (size >= (*it).m_rlcRetransmissionQueueSize))
1764 {
1765 (*it).m_rlcRetransmissionQueueSize = 0;
1766 }
1767 else if ((*it).m_rlcTransmissionQueueSize > 0)
1768 {
1769 uint32_t rlcOverhead;
1770 if (lcid == 1)
1771 {
1772 // for SRB1 (using RLC AM) it's better to
1773 // overestimate RLC overhead rather than
1774 // underestimate it and risk unneeded
1775 // segmentation which increases delay
1776 rlcOverhead = 4;
1777 }
1778 else
1779 {
1780 // minimum RLC overhead due to header
1781 rlcOverhead = 2;
1782 }
1783 // update transmission queue
1784 if ((*it).m_rlcTransmissionQueueSize <= size - rlcOverhead)
1785 {
1786 (*it).m_rlcTransmissionQueueSize = 0;
1787 }
1788 else
1789 {
1790 (*it).m_rlcTransmissionQueueSize -= size - rlcOverhead;
1791 }
1792 }
1793 return;
1794 }
1795 }
1796}
1797
1798void
1799RrFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
1800{
1801 size = size - 2; // remove the minimum RLC overhead
1802 auto it = m_ceBsrRxed.find(rnti);
1803 if (it != m_ceBsrRxed.end())
1804 {
1805 NS_LOG_INFO(this << " Update RLC BSR UE " << rnti << " size " << size << " BSR "
1806 << (*it).second);
1807 if ((*it).second >= size)
1808 {
1809 (*it).second -= size;
1810 }
1811 else
1812 {
1813 (*it).second = 0;
1814 }
1815 }
1816 else
1817 {
1818 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
1819 }
1820}
1821
1822void
1824{
1825 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
1827 params.m_rnti = rnti;
1828 params.m_transmissionMode = txMode;
1830}
1831
1832} // namespace ns3
static uint32_t BsrId2BufferSize(uint8_t val)
Convert BSR ID to buffer size.
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.
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
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Smart pointer class similar to boost::intrusive_ptr.
Implements the SCHED SAP and CSCHED SAP for a Round Robin scheduler.
friend class MemberCschedSapProvider< RrFfMacScheduler >
allow MemberCschedSapProvider<RrFfMacScheduler> class friend access
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 DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Sched DL RLC buffer request.
void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
Sched UL CQI info request.
std::map< uint16_t, uint8_t > m_uesTxMode
txMode of the UEs
bool HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
Sched DL trigger request.
friend class MemberSchedSapProvider< RrFfMacScheduler >
allow MemberSchedSapProvider<RrFfMacScheduler> class friend access
void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
CSched LC release request.
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
DL HARQ process status.
void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
CSched LC config request.
void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
Sched UL SRS info request.
~RrFfMacScheduler() override
Destructor.
std::map< uint16_t, uint8_t > m_p10CqiRxed
Map of UE's DL CQI P01 received.
FfMacSchedSapUser * m_schedSapUser
Sched SAP user.
FfMacSchedSapProvider * m_schedSapProvider
Sched SAP provider.
void SetFfMacCschedSapUser(FfMacCschedSapUser *s) override
set the user part of the FfMacCschedSap that this Scheduler will interact with.
void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
CSched UE config request.
std::map< uint16_t, uint32_t > m_ceBsrRxed
Map of UE's buffer status reports received.
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
LteFfrSapUser * GetLteFfrSapUser() override
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
DL HARQ process timer.
void DoSchedUlMacCtrlInfoReq(const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
Sched UL MAC control info request.
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
Update DL RLC buffer info function.
void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
Sched UL trigger request.
void DoSchedUlNoiseInterferenceReq(const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
Sched UL noise interference request.
std::vector< uint16_t > m_rachAllocationMap
RACH allocation map.
std::map< uint16_t, uint32_t > m_p10CqiTimers
Map of UE's timers on DL CQI P01 received.
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
FfMacCschedSapProvider * m_cschedSapProvider
CSched SAP provider.
int GetRbgSize(int dlbandwidth)
Get RBG size function.
void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
Sched DL MAC buffer request.
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
DL HARQ process DCI buffer.
FfMacCschedSapUser * m_cschedSapUser
CSched SAP user.
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
DL HARQ current process ID.
std::map< uint16_t, std::vector< double > > m_ueCqi
Map of UEs' UL-CQI per RBG.
void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
CSched UE release request.
std::list< FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
Vectors of UE's RLC info.
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
UL HARQ process status.
uint16_t m_nextRntiDl
RNTI of the next user to be served next scheduling in DL.
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
CSched cell config.
std::vector< RachListElement_s > m_rachList
RACH list.
static bool SortRlcBufferReq(FfMacSchedSapProvider::SchedDlRlcBufferReqParameters i, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters j)
Sort RLC buffer request function.
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
void RefreshDlCqiMaps()
Refresh DL CQI maps function.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
DL HARQ process RLC PDU list buffer.
FfMacCschedSapProvider * GetFfMacCschedSapProvider() override
void SetLteFfrSapProvider(LteFfrSapProvider *s) override
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
bool m_harqOn
m_harqOn when false inhibit the HARQ mechanisms (by default active)
void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
Sched DL CQI info request.
void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
CSched cell config request.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmission mode configuration update function.
uint8_t m_ulGrantMcs
MCS for UL grant (default 0)
static TypeId GetTypeId()
Get the type ID.
std::map< uint16_t, uint32_t > m_ueCqiTimers
Map of UEs' timers on UL-CQI per RBG.
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
UL HARQ current process ID.
void DoSchedDlPagingBufferReq(const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
Sched DL paging buffer request.
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
HARQ retx buffered.
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
UL HARQ process DCI buffer.
void SetFfMacSchedSapUser(FfMacSchedSapUser *s) override
set the user part of the FfMacSchedSap that this Scheduler will interact with.
FfMacSchedSapProvider * GetFfMacSchedSapProvider() override
void RefreshUlCqiMaps()
Refresh UL CQI maps function.
void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
Sched DL RACH info request.
void DoDispose() override
Destructor implementation.
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
Update UL RLC buffer info function.
uint16_t m_nextRntiUl
RNTI of the next user to be served next scheduling in UL.
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 > MakeUintegerChecker()
Definition uinteger.h:85
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 Type0AllocationRbg[4]
Type 0 RBG allocation.
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.
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.