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 (see table 7.1.6.1-1 of 36.213)
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};
37
38NS_OBJECT_ENSURE_REGISTERED(RrFfMacScheduler);
39
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
136{
137 NS_LOG_FUNCTION(this);
138 // Read the subset of parameters used
139 m_cschedCellConfig = params;
140 m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0);
142 cnf.m_result = SUCCESS;
143 m_cschedSapUser->CschedUeConfigCnf(cnf);
144}
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
436 int rbgSize = GetRbgSize(m_cschedCellConfig.m_dlBandwidth);
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
455 m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0);
456 uint16_t rbStart = 0;
457 for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++)
458 {
459 NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) >
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 retx.reserve(2);
578 NS_LOG_INFO(this << " Processing DLHARQ feedback");
579 if (nLayers == 1)
580 {
581 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
583 retx.push_back(false);
584 }
585 else
586 {
587 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
589 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(1) ==
591 }
592 if (retx.at(0) || retx.at(1))
593 {
594 // retrieve HARQ process information
595 uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti;
596 uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId;
597 NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
598 auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti);
599 if (itHarq == m_dlHarqProcessesDciBuffer.end())
600 {
601 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti);
602 }
603
604 DlDciListElement_s dci = (*itHarq).second.at(harqId);
605 int rv = 0;
606 if (dci.m_rv.size() == 1)
607 {
608 rv = dci.m_rv.at(0);
609 }
610 else
611 {
612 rv = (dci.m_rv.at(0) > dci.m_rv.at(1) ? dci.m_rv.at(0) : dci.m_rv.at(1));
613 }
614
615 if (rv == 3)
616 {
617 // maximum number of retx reached -> drop process
618 NS_LOG_INFO("Max number of retransmissions reached -> drop process");
619 auto it = m_dlHarqProcessesStatus.find(rnti);
620 if (it == m_dlHarqProcessesStatus.end())
621 {
622 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
623 << m_dlInfoListBuffered.at(i).m_rnti);
624 }
625 (*it).second.at(harqId) = 0;
626 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
627 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
628 {
629 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
630 << m_dlInfoListBuffered.at(i).m_rnti);
631 }
632 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
633 {
634 (*itRlcPdu).second.at(k).at(harqId).clear();
635 }
636 continue;
637 }
638 // check the feasibility of retransmitting on the same RBGs
639 // translate the DCI to Spectrum framework
640 std::vector<int> dciRbg;
641 uint32_t mask = 0x1;
642 NS_LOG_INFO("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
643 for (int j = 0; j < 32; j++)
644 {
645 if (((dci.m_rbBitmap & mask) >> j) == 1)
646 {
647 dciRbg.push_back(j);
648 NS_LOG_INFO("\t" << j);
649 }
650 mask = (mask << 1);
651 }
652 bool free = true;
653 for (std::size_t j = 0; j < dciRbg.size(); j++)
654 {
655 if (rbgMap.at(dciRbg.at(j)))
656 {
657 free = false;
658 break;
659 }
660 }
661 if (free)
662 {
663 // use the same RBGs for the retx
664 // reserve RBGs
665 for (std::size_t j = 0; j < dciRbg.size(); j++)
666 {
667 rbgMap.at(dciRbg.at(j)) = true;
668 NS_LOG_INFO("RBG " << dciRbg.at(j) << " assigned");
669 rbgAllocatedNum++;
670 }
671
672 NS_LOG_INFO(this << " Send retx in the same RBGs");
673 }
674 else
675 {
676 // find RBGs for sending HARQ retx
677 uint8_t j = 0;
678 uint8_t rbgId = (dciRbg.at(dciRbg.size() - 1) + 1) % rbgNum;
679 uint8_t startRbg = dciRbg.at(dciRbg.size() - 1);
680 std::vector<bool> rbgMapCopy = rbgMap;
681 while ((j < dciRbg.size()) && (startRbg != rbgId))
682 {
683 if (!rbgMapCopy.at(rbgId))
684 {
685 rbgMapCopy.at(rbgId) = true;
686 dciRbg.at(j) = rbgId;
687 j++;
688 }
689 rbgId = (rbgId + 1) % rbgNum;
690 }
691 if (j == dciRbg.size())
692 {
693 // find new RBGs -> update DCI map
694 uint32_t rbgMask = 0;
695 for (std::size_t k = 0; k < dciRbg.size(); k++)
696 {
697 rbgMask = rbgMask + (0x1 << dciRbg.at(k));
698 NS_LOG_INFO(this << " New allocated RBG " << dciRbg.at(k));
699 rbgAllocatedNum++;
700 }
701 dci.m_rbBitmap = rbgMask;
702 rbgMap = rbgMapCopy;
703 }
704 else
705 {
706 // HARQ retx cannot be performed on this TTI -> store it
707 dlInfoListUntxed.push_back(m_dlInfoListBuffered.at(i));
708 NS_LOG_INFO(this << " No resource for this retx -> buffer it");
709 }
710 }
711 // retrieve RLC PDU list for retx TBsize and update DCI
713 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
714 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
715 {
716 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
717 }
718 for (std::size_t j = 0; j < nLayers; j++)
719 {
720 if (retx.at(j))
721 {
722 if (j >= dci.m_ndi.size())
723 {
724 // for avoiding errors in MIMO transient phases
725 dci.m_ndi.push_back(0);
726 dci.m_rv.push_back(0);
727 dci.m_mcs.push_back(0);
728 dci.m_tbsSize.push_back(0);
729 NS_LOG_INFO(this << " layer " << (uint16_t)j
730 << " no txed (MIMO transition)");
731 }
732 else
733 {
734 dci.m_ndi.at(j) = 0;
735 dci.m_rv.at(j)++;
736 (*itHarq).second.at(harqId).m_rv.at(j)++;
737 NS_LOG_INFO(this << " layer " << (uint16_t)j << " RV "
738 << (uint16_t)dci.m_rv.at(j));
739 }
740 }
741 else
742 {
743 // empty TB of layer j
744 dci.m_ndi.at(j) = 0;
745 dci.m_rv.at(j) = 0;
746 dci.m_mcs.at(j) = 0;
747 dci.m_tbsSize.at(j) = 0;
748 NS_LOG_INFO(this << " layer " << (uint16_t)j << " no retx");
749 }
750 }
751
752 for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++)
753 {
754 std::vector<RlcPduListElement_s> rlcPduListPerLc;
755 for (std::size_t j = 0; j < nLayers; j++)
756 {
757 if (retx.at(j))
758 {
759 if (j < dci.m_ndi.size())
760 {
761 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size "
762 << dci.m_tbsSize.at(j));
763 rlcPduListPerLc.push_back(
764 (*itRlcPdu).second.at(j).at(dci.m_harqProcess).at(k));
765 }
766 }
767 else
768 { // if no retx needed on layer j, push an RlcPduListElement_s object with
769 // m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
770 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at(j));
771 RlcPduListElement_s emptyElement;
772 emptyElement.m_logicalChannelIdentity = (*itRlcPdu)
773 .second.at(j)
774 .at(dci.m_harqProcess)
775 .at(k)
776 .m_logicalChannelIdentity;
777 emptyElement.m_size = 0;
778 rlcPduListPerLc.push_back(emptyElement);
779 }
780 }
781
782 if (!rlcPduListPerLc.empty())
783 {
784 newEl.m_rlcPduList.push_back(rlcPduListPerLc);
785 }
786 }
787 newEl.m_rnti = rnti;
788 newEl.m_dci = dci;
789 (*itHarq).second.at(harqId).m_rv = dci.m_rv;
790 // refresh timer
791 auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti);
792 if (itHarqTimer == m_dlHarqProcessesTimer.end())
793 {
794 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
795 }
796 (*itHarqTimer).second.at(harqId) = 0;
797 ret.m_buildDataList.push_back(newEl);
798 rntiAllocated.insert(rnti);
799 }
800 else
801 {
802 // update HARQ process status
803 NS_LOG_INFO(this << " HARQ ACK UE " << m_dlInfoListBuffered.at(i).m_rnti);
804 auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti);
805 if (it == m_dlHarqProcessesStatus.end())
806 {
807 NS_FATAL_ERROR("No info find in HARQ buffer for UE "
808 << m_dlInfoListBuffered.at(i).m_rnti);
809 }
810 (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0;
811 auto itRlcPdu =
813 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
814 {
815 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
816 << m_dlInfoListBuffered.at(i).m_rnti);
817 }
818 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
819 {
820 (*itRlcPdu).second.at(k).at(m_dlInfoListBuffered.at(i).m_harqProcessId).clear();
821 }
822 }
823 }
824 m_dlInfoListBuffered.clear();
825 m_dlInfoListBuffered = dlInfoListUntxed;
826
827 if (rbgAllocatedNum == rbgNum)
828 {
829 // all the RBGs are already allocated -> exit
830 if (!ret.m_buildDataList.empty() || !ret.m_buildRarList.empty())
831 {
832 m_schedSapUser->SchedDlConfigInd(ret);
833 }
834 return;
835 }
836
837 // Get the actual active flows (queue!=0)
838 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
840 int nflows = 0;
841 int nTbs = 0;
842 std::map<uint16_t, uint8_t> lcActivesPerRnti; // tracks how many active LCs per RNTI there are
843 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
844 {
845 // remove old entries of this UE-LC
846 auto itRnti = rntiAllocated.find((*it).m_rnti);
847 if ((((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) ||
848 ((*it).m_rlcStatusPduSize > 0)) &&
849 (itRnti == rntiAllocated.end()) // UE must not be allocated for HARQ retx
850 && (HarqProcessAvailability((*it).m_rnti))) // UE needs HARQ proc free
851
852 {
853 NS_LOG_LOGIC(this << " User " << (*it).m_rnti << " LC "
854 << (uint16_t)(*it).m_logicalChannelIdentity << " is active, status "
855 << (*it).m_rlcStatusPduSize << " retx "
856 << (*it).m_rlcRetransmissionQueueSize << " tx "
857 << (*it).m_rlcTransmissionQueueSize);
858 auto itCqi = m_p10CqiRxed.find((*it).m_rnti);
859 uint8_t cqi = 0;
860 if (itCqi != m_p10CqiRxed.end())
861 {
862 cqi = (*itCqi).second;
863 }
864 else
865 {
866 cqi = 1; // lowest value for trying a transmission
867 }
868 if (cqi != 0)
869 {
870 // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
871 nflows++;
872 auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti);
873 if (itLcRnti != lcActivesPerRnti.end())
874 {
875 (*itLcRnti).second++;
876 }
877 else
878 {
879 lcActivesPerRnti[(*it).m_rnti] = 1;
880 nTbs++;
881 }
882 }
883 }
884 }
885
886 if (nflows == 0)
887 {
888 if ((!ret.m_buildDataList.empty()) || (!ret.m_buildRarList.empty()))
889 {
890 m_schedSapUser->SchedDlConfigInd(ret);
891 }
892 return;
893 }
894 // Divide the resource equally among the active users according to
895 // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
896
897 int rbgPerTb = (nTbs > 0) ? ((rbgNum - rbgAllocatedNum) / nTbs) : INT_MAX;
898 NS_LOG_INFO(this << " Flows to be transmitted " << nflows << " rbgPerTb " << rbgPerTb);
899 if (rbgPerTb == 0)
900 {
901 rbgPerTb = 1; // at least 1 rbg per TB (till available resource)
902 }
903 int rbgAllocated = 0;
904
905 // round robin assignment to all UEs registered starting from the subsequent of the one
906 // served last scheduling trigger event
907 if (m_nextRntiDl != 0)
908 {
909 NS_LOG_DEBUG("Start from the successive of " << (uint16_t)m_nextRntiDl);
910 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
911 {
912 if ((*it).m_rnti == m_nextRntiDl)
913 {
914 // select the next RNTI to starting
915 it++;
916 if (it == m_rlcBufferReq.end())
917 {
918 it = m_rlcBufferReq.begin();
919 }
920 m_nextRntiDl = (*it).m_rnti;
921 break;
922 }
923 }
924
925 if (it == m_rlcBufferReq.end())
926 {
927 NS_LOG_ERROR(this << " no user found");
928 }
929 }
930 else
931 {
932 it = m_rlcBufferReq.begin();
933 m_nextRntiDl = (*it).m_rnti;
934 }
935 do
936 {
937 auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti);
938 auto itRnti = rntiAllocated.find((*it).m_rnti);
939 if ((itLcRnti == lcActivesPerRnti.end()) || (itRnti != rntiAllocated.end()))
940 {
941 // skip this RNTI (no active queue or yet allocated for HARQ)
942 uint16_t rntiDiscarded = (*it).m_rnti;
943 while (it != m_rlcBufferReq.end())
944 {
945 if ((*it).m_rnti != rntiDiscarded)
946 {
947 break;
948 }
949 it++;
950 }
951 if (it == m_rlcBufferReq.end())
952 {
953 // restart from the first
954 it = m_rlcBufferReq.begin();
955 }
956 continue;
957 }
958 auto itTxMode = m_uesTxMode.find((*it).m_rnti);
959 if (itTxMode == m_uesTxMode.end())
960 {
961 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).m_rnti);
962 }
963 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
964 int lcNum = (*itLcRnti).second;
965 // create new BuildDataListElement_s for this RNTI
967 newEl.m_rnti = (*it).m_rnti;
968 // create the DlDciListElement_s
969 DlDciListElement_s newDci;
970 newDci.m_rnti = (*it).m_rnti;
971 newDci.m_harqProcess = UpdateHarqProcessId((*it).m_rnti);
972 newDci.m_resAlloc = 0;
973 newDci.m_rbBitmap = 0;
974 auto itCqi = m_p10CqiRxed.find(newEl.m_rnti);
975 for (uint8_t i = 0; i < nLayer; i++)
976 {
977 if (itCqi == m_p10CqiRxed.end())
978 {
979 newDci.m_mcs.push_back(0); // no info on this user -> lowest MCS
980 }
981 else
982 {
983 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi((*itCqi).second));
984 }
985 }
986 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(0), rbgPerTb * rbgSize) / 8);
987 uint16_t rlcPduSize = tbSize / lcNum;
988 while ((*it).m_rnti == newEl.m_rnti)
989 {
990 if (((*it).m_rlcTransmissionQueueSize > 0) ||
991 ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0))
992 {
993 std::vector<RlcPduListElement_s> newRlcPduLe;
994 for (uint8_t j = 0; j < nLayer; j++)
995 {
996 RlcPduListElement_s newRlcEl;
997 newRlcEl.m_logicalChannelIdentity = (*it).m_logicalChannelIdentity;
998 NS_LOG_INFO(this << "LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
999 << " size " << rlcPduSize << " ID " << (*it).m_rnti
1000 << " layer " << (uint16_t)j);
1001 newRlcEl.m_size = rlcPduSize;
1002 UpdateDlRlcBufferInfo((*it).m_rnti,
1003 newRlcEl.m_logicalChannelIdentity,
1004 rlcPduSize);
1005 newRlcPduLe.push_back(newRlcEl);
1006
1007 if (m_harqOn)
1008 {
1009 // store RLC PDU list for HARQ
1010 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti);
1011 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1012 {
1013 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1014 << (*it).m_rnti);
1015 }
1016 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1017 }
1018 }
1019 newEl.m_rlcPduList.push_back(newRlcPduLe);
1020 lcNum--;
1021 }
1022 it++;
1023 if (it == m_rlcBufferReq.end())
1024 {
1025 // restart from the first
1026 it = m_rlcBufferReq.begin();
1027 break;
1028 }
1029 }
1030 uint32_t rbgMask = 0;
1031 uint16_t i = 0;
1032 NS_LOG_INFO(this << " DL - Allocate user " << newEl.m_rnti << " LCs "
1033 << (uint16_t)(*itLcRnti).second << " bytes " << tbSize << " mcs "
1034 << (uint16_t)newDci.m_mcs.at(0) << " harqId "
1035 << (uint16_t)newDci.m_harqProcess << " layers " << nLayer);
1036 NS_LOG_INFO("RBG:");
1037 while (i < rbgPerTb)
1038 {
1039 if (!rbgMap.at(rbgAllocated))
1040 {
1041 rbgMask = rbgMask + (0x1 << rbgAllocated);
1042 NS_LOG_INFO("\t " << rbgAllocated);
1043 i++;
1044 rbgMap.at(rbgAllocated) = true;
1045 rbgAllocatedNum++;
1046 }
1047 rbgAllocated++;
1048 }
1049 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1050
1051 for (std::size_t i = 0; i < nLayer; i++)
1052 {
1053 newDci.m_tbsSize.push_back(tbSize);
1054 newDci.m_ndi.push_back(1);
1055 newDci.m_rv.push_back(0);
1056 }
1057
1058 newDci.m_tpc = 1; // 1 is mapped to 0 in Accumulated Mode and to -1 in Absolute Mode
1059
1060 newEl.m_dci = newDci;
1061 if (m_harqOn)
1062 {
1063 // store DCI for HARQ
1064 auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti);
1065 if (itDci == m_dlHarqProcessesDciBuffer.end())
1066 {
1067 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1068 << newEl.m_rnti);
1069 }
1070 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1071 // refresh timer
1072 auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti);
1073 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1074 {
1075 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1076 }
1077 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1078 }
1079 // ...more parameters -> ignored in this version
1080
1081 ret.m_buildDataList.push_back(newEl);
1082 if (rbgAllocatedNum == rbgNum)
1083 {
1084 m_nextRntiDl = newEl.m_rnti; // store last RNTI served
1085 break; // no more RBG to be allocated
1086 }
1087 } while ((*it).m_rnti != m_nextRntiDl);
1088
1089 ret.m_nrOfPdcchOfdmSymbols = 1; /// \todo check correct value according the DCIs txed
1090
1091 m_schedSapUser->SchedDlConfigInd(ret);
1092}
1093
1094void
1097{
1098 NS_LOG_FUNCTION(this);
1099
1100 m_rachList = params.m_rachList;
1101}
1102
1103void
1106{
1107 NS_LOG_FUNCTION(this);
1108
1109 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1110 {
1111 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1112 {
1113 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1114 << " reported");
1115 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1116 auto it = m_p10CqiRxed.find(rnti);
1117 if (it == m_p10CqiRxed.end())
1118 {
1119 // create the new entry
1120 m_p10CqiRxed[rnti] =
1121 params.m_cqiList.at(i).m_wbCqi.at(0); // only codeword 0 at this stage (SISO)
1122 // generate correspondent timer
1124 }
1125 else
1126 {
1127 // update the CQI value
1128 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1129 // update correspondent timer
1130 auto itTimers = m_p10CqiTimers.find(rnti);
1131 (*itTimers).second = m_cqiTimersThreshold;
1132 }
1133 }
1134 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1135 {
1136 // subband CQI reporting high layer configured
1137 // Not used by RR Scheduler
1138 }
1139 else
1140 {
1141 NS_LOG_ERROR(this << " CQI type unknown");
1142 }
1143 }
1144}
1145
1146void
1149{
1150 NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
1151 << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size());
1152
1154
1155 // Generate RBs map
1157 std::vector<bool> rbMap;
1158 std::set<uint16_t> rntiAllocated;
1159 std::vector<uint16_t> rbgAllocationMap;
1160 // update with RACH allocation map
1161 rbgAllocationMap = m_rachAllocationMap;
1162 // rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1163 m_rachAllocationMap.clear();
1164 m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0);
1165
1166 rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
1167 // remove RACH allocation
1168 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1169 {
1170 if (rbgAllocationMap.at(i) != 0)
1171 {
1172 rbMap.at(i) = true;
1173 NS_LOG_DEBUG(this << " Allocated for RACH " << i);
1174 }
1175 }
1176
1177 if (m_harqOn)
1178 {
1179 // Process UL HARQ feedback
1180 for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++)
1181 {
1182 if (params.m_ulInfoList.at(i).m_receptionStatus == UlInfoListElement_s::NotOk)
1183 {
1184 // retx correspondent block: retrieve the UL-DCI
1185 uint16_t rnti = params.m_ulInfoList.at(i).m_rnti;
1186 auto itProcId = m_ulHarqCurrentProcessId.find(rnti);
1187 if (itProcId == m_ulHarqCurrentProcessId.end())
1188 {
1189 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1190 }
1191 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1192 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId "
1193 << (uint16_t)harqId);
1194 auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti);
1195 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1196 {
1197 NS_LOG_ERROR("No info find in UL-HARQ buffer for UE (might change eNB) "
1198 << rnti);
1199 }
1200 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1201 auto itStat = m_ulHarqProcessesStatus.find(rnti);
1202 if (itStat == m_ulHarqProcessesStatus.end())
1203 {
1204 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1205 }
1206 if ((*itStat).second.at(harqId) >= 3)
1207 {
1208 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1209 continue;
1210 }
1211 bool free = true;
1212 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1213 {
1214 if (rbMap.at(j))
1215 {
1216 free = false;
1217 NS_LOG_INFO(this << " BUSY " << j);
1218 }
1219 }
1220 if (free)
1221 {
1222 // retx on the same RBs
1223 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1224 {
1225 rbMap.at(j) = true;
1226 rbgAllocationMap.at(j) = dci.m_rnti;
1227 NS_LOG_INFO("\tRB " << j);
1228 }
1229 NS_LOG_INFO(this << " Send retx in the same RBGs " << (uint16_t)dci.m_rbStart
1230 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1231 << (*itStat).second.at(harqId) + 1);
1232 }
1233 else
1234 {
1235 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1236 continue;
1237 }
1238 dci.m_ndi = 0;
1239 // Update HARQ buffers with new HarqId
1240 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1241 (*itStat).second.at(harqId) = 0;
1242 (*itHarq).second.at((*itProcId).second) = dci;
1243 ret.m_dciList.push_back(dci);
1244 rntiAllocated.insert(dci.m_rnti);
1245 }
1246 }
1247 }
1248
1249 std::map<uint16_t, uint32_t>::iterator it;
1250 int nflows = 0;
1251
1252 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1253 {
1254 auto itRnti = rntiAllocated.find((*it).first);
1255 // select UEs with queues not empty and not yet allocated for HARQ
1256 NS_LOG_INFO(this << " UE " << (*it).first << " queue " << (*it).second);
1257 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1258 {
1259 nflows++;
1260 }
1261 }
1262
1263 if (nflows == 0)
1264 {
1265 if (!ret.m_dciList.empty())
1266 {
1267 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1268 m_schedSapUser->SchedUlConfigInd(ret);
1269 }
1270 return; // no flows to be scheduled
1271 }
1272
1273 // Divide the remaining resources equally among the active users starting from the subsequent
1274 // one served last scheduling trigger
1275 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size());
1276 if (rbPerFlow < 3)
1277 {
1278 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1279 // >= 7 bytes
1280 }
1281 uint16_t rbAllocated = 0;
1282
1283 if (m_nextRntiUl != 0)
1284 {
1285 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1286 {
1287 if ((*it).first == m_nextRntiUl)
1288 {
1289 break;
1290 }
1291 }
1292 if (it == m_ceBsrRxed.end())
1293 {
1294 NS_LOG_ERROR(this << " no user found");
1295 }
1296 }
1297 else
1298 {
1299 it = m_ceBsrRxed.begin();
1300 m_nextRntiUl = (*it).first;
1301 }
1302 NS_LOG_INFO(this << " NFlows " << nflows << " RB per Flow " << rbPerFlow);
1303 do
1304 {
1305 auto itRnti = rntiAllocated.find((*it).first);
1306 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1307 {
1308 // UE already allocated for UL-HARQ -> skip it
1309 it++;
1310 if (it == m_ceBsrRxed.end())
1311 {
1312 // restart from the first
1313 it = m_ceBsrRxed.begin();
1314 }
1315 continue;
1316 }
1317 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1318 {
1319 // limit to physical resources last resource assignment
1320 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1321 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1322 if (rbPerFlow < 3)
1323 {
1324 // terminate allocation
1325 rbPerFlow = 0;
1326 }
1327 }
1328 NS_LOG_INFO(this << " try to allocate " << (*it).first);
1329 UlDciListElement_s uldci;
1330 uldci.m_rnti = (*it).first;
1331 uldci.m_rbLen = rbPerFlow;
1332 bool allocated = false;
1333 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1334 << " flows " << nflows);
1335 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1336 (rbPerFlow != 0))
1337 {
1338 // check availability
1339 bool free = true;
1340 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1341 {
1342 if (rbMap.at(j))
1343 {
1344 free = false;
1345 break;
1346 }
1347 }
1348 if (free)
1349 {
1350 uldci.m_rbStart = rbAllocated;
1351
1352 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1353 {
1354 rbMap.at(j) = true;
1355 // store info on allocation for managing ul-cqi interpretation
1356 rbgAllocationMap.at(j) = (*it).first;
1357 NS_LOG_INFO("\t " << j);
1358 }
1359 rbAllocated += rbPerFlow;
1360 allocated = true;
1361 break;
1362 }
1363 rbAllocated++;
1364 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1365 {
1366 // limit to physical resources last resource assignment
1367 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1368 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1369 if (rbPerFlow < 3)
1370 {
1371 // terminate allocation
1372 rbPerFlow = 0;
1373 }
1374 }
1375 }
1376 if (!allocated)
1377 {
1378 // unable to allocate new resource: finish scheduling
1379 m_nextRntiUl = (*it).first;
1380 if (!ret.m_dciList.empty())
1381 {
1382 m_schedSapUser->SchedUlConfigInd(ret);
1383 }
1384 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1385 return;
1386 }
1387 auto itCqi = m_ueCqi.find((*it).first);
1388 int cqi = 0;
1389 if (itCqi == m_ueCqi.end())
1390 {
1391 // no cqi info about this UE
1392 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1393 NS_LOG_INFO(this << " UE does not have ULCQI " << (*it).first);
1394 }
1395 else
1396 {
1397 // take the lowest CQI value (worst RB)
1398 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1399 "CQI of RNTI = " << (*it).first << " has expired");
1400 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1401 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1402 {
1403 if ((*itCqi).second.at(i) < minSinr)
1404 {
1405 minSinr = (*itCqi).second.at(i);
1406 }
1407 }
1408 // translate SINR -> cqi: WILD ACK: same as DL
1409 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1410
1411 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1412 if (cqi == 0)
1413 {
1414 it++;
1415 if (it == m_ceBsrRxed.end())
1416 {
1417 // restart from the first
1418 it = m_ceBsrRxed.begin();
1419 }
1420 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1421 // remove UE from allocation map
1422 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1423 {
1424 rbgAllocationMap.at(i) = 0;
1425 }
1426 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1427 }
1428 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1429 }
1430 uldci.m_tbSize =
1431 (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8); // MCS 0 -> UL-AMC TBD
1432
1434 uldci.m_ndi = 1;
1435 uldci.m_cceIndex = 0;
1436 uldci.m_aggrLevel = 1;
1437 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1438 uldci.m_hopping = false;
1439 uldci.m_n2Dmrs = 0;
1440 uldci.m_tpc = 0; // no power control
1441 uldci.m_cqiRequest = false; // only period CQI at this stage
1442 uldci.m_ulIndex = 0; // TDD parameter
1443 uldci.m_dai = 1; // TDD parameter
1444 uldci.m_freqHopping = 0;
1445 uldci.m_pdcchPowerOffset = 0; // not used
1446 ret.m_dciList.push_back(uldci);
1447 // store DCI for HARQ_PERIOD
1448 uint8_t harqId = 0;
1449 if (m_harqOn)
1450 {
1451 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1452 if (itProcId == m_ulHarqCurrentProcessId.end())
1453 {
1454 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
1455 }
1456 harqId = (*itProcId).second;
1457 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
1458 if (itDci == m_ulHarqProcessesDciBuffer.end())
1459 {
1460 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
1461 << uldci.m_rnti);
1462 }
1463 (*itDci).second.at(harqId) = uldci;
1464 // Update HARQ process status (RV 0)
1465 auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti);
1466 if (itStat == m_ulHarqProcessesStatus.end())
1467 {
1468 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
1469 << uldci.m_rnti);
1470 }
1471 (*itStat).second.at(harqId) = 0;
1472 }
1473
1474 NS_LOG_INFO(this << " UL Allocation - UE " << (*it).first << " startPRB "
1475 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
1476 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
1477 << uldci.m_tbSize << " harqId " << (uint16_t)harqId);
1478
1479 it++;
1480 if (it == m_ceBsrRxed.end())
1481 {
1482 // restart from the first
1483 it = m_ceBsrRxed.begin();
1484 }
1485 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1486 {
1487 // Stop allocation: no more PRBs
1488 m_nextRntiUl = (*it).first;
1489 break;
1490 }
1491 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
1492
1493 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1494
1495 m_schedSapUser->SchedUlConfigInd(ret);
1496}
1497
1498void
1504
1505void
1511
1512void
1515{
1516 NS_LOG_FUNCTION(this);
1517
1518 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
1519 {
1520 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
1521 {
1522 // buffer status report
1523 // note that this scheduler does not differentiate the
1524 // allocation according to which LCGs have more/less bytes
1525 // to send.
1526 // Hence the BSR of different LCGs are just summed up to get
1527 // a total queue size that is used for allocation purposes.
1528
1529 uint32_t buffer = 0;
1530 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1531 {
1532 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
1533 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
1534 }
1535
1536 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
1537 auto it = m_ceBsrRxed.find(rnti);
1538 if (it == m_ceBsrRxed.end())
1539 {
1540 // create the new entry
1541 m_ceBsrRxed[rnti] = buffer;
1542 NS_LOG_INFO(this << " Insert RNTI " << rnti << " queue " << buffer);
1543 }
1544 else
1545 {
1546 // update the buffer size value
1547 (*it).second = buffer;
1548 NS_LOG_INFO(this << " Update RNTI " << rnti << " queue " << buffer);
1549 }
1550 }
1551 }
1552}
1553
1554void
1557{
1558 NS_LOG_FUNCTION(this);
1559
1560 switch (m_ulCqiFilter)
1561 {
1563 // filter all the CQIs that are not SRS based
1564 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1565 {
1566 return;
1567 }
1568 }
1569 break;
1571 // filter all the CQIs that are not SRS based
1572 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1573 {
1574 return;
1575 }
1576 }
1577 break;
1578 default:
1579 NS_FATAL_ERROR("Unknown UL CQI type");
1580 }
1581 switch (params.m_ulCqi.m_type)
1582 {
1583 case UlCqi_s::PUSCH: {
1584 auto itMap = m_allocationMaps.find(params.m_sfnSf);
1585 if (itMap == m_allocationMaps.end())
1586 {
1587 NS_LOG_INFO(this << " Does not find info on allocation, size : "
1588 << m_allocationMaps.size());
1589 return;
1590 }
1591 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
1592 {
1593 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1594 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
1595 auto itCqi = m_ueCqi.find((*itMap).second.at(i));
1596 if (itCqi == m_ueCqi.end())
1597 {
1598 // create a new entry
1599 std::vector<double> newCqi;
1600 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1601 {
1602 if (i == j)
1603 {
1604 newCqi.push_back(sinr);
1605 }
1606 else
1607 {
1608 // initialize with NO_SINR value.
1609 newCqi.push_back(30.0);
1610 }
1611 }
1612 m_ueCqi[(*itMap).second.at(i)] = newCqi;
1613 // generate correspondent timer
1614 m_ueCqiTimers[(*itMap).second.at(i)] = m_cqiTimersThreshold;
1615 }
1616 else
1617 {
1618 // update the value
1619 (*itCqi).second.at(i) = sinr;
1620 // update correspondent timer
1621 auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
1622 (*itTimers).second = m_cqiTimersThreshold;
1623 }
1624 }
1625 // remove obsolete info on allocation
1626 m_allocationMaps.erase(itMap);
1627 }
1628 break;
1629 case UlCqi_s::SRS: {
1630 // get the RNTI from vendor specific parameters
1631 uint16_t rnti = 0;
1632 NS_ASSERT(!params.m_vendorSpecificList.empty());
1633 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
1634 {
1635 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
1636 {
1637 Ptr<SrsCqiRntiVsp> vsp =
1638 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
1639 rnti = vsp->GetRnti();
1640 }
1641 }
1642 auto itCqi = m_ueCqi.find(rnti);
1643 if (itCqi == m_ueCqi.end())
1644 {
1645 // create a new entry
1646 std::vector<double> newCqi;
1647 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1648 {
1649 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1650 newCqi.push_back(sinr);
1651 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
1652 << sinr);
1653 }
1654 m_ueCqi[rnti] = newCqi;
1655 // generate correspondent timer
1657 }
1658 else
1659 {
1660 // update the values
1661 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1662 {
1663 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1664 (*itCqi).second.at(j) = sinr;
1665 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
1666 << sinr);
1667 }
1668 // update correspondent timer
1669 auto itTimers = m_ueCqiTimers.find(rnti);
1670 (*itTimers).second = m_cqiTimersThreshold;
1671 }
1672 }
1673 break;
1674 case UlCqi_s::PUCCH_1:
1675 case UlCqi_s::PUCCH_2:
1676 case UlCqi_s::PRACH: {
1677 NS_FATAL_ERROR("PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1678 }
1679 break;
1680 default:
1681 NS_FATAL_ERROR("Unknown type of UL-CQI");
1682 }
1683}
1684
1685void
1687{
1688 NS_LOG_FUNCTION(this << m_p10CqiTimers.size());
1689 // refresh DL CQI P01 Map
1690 auto itP10 = m_p10CqiTimers.begin();
1691 while (itP10 != m_p10CqiTimers.end())
1692 {
1693 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
1694 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1695 if ((*itP10).second == 0)
1696 {
1697 // delete correspondent entries
1698 auto itMap = m_p10CqiRxed.find((*itP10).first);
1699 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
1700 " Does not find CQI report for user " << (*itP10).first);
1701 NS_LOG_INFO(this << " P10-CQI exired for user " << (*itP10).first);
1702 m_p10CqiRxed.erase(itMap);
1703 auto temp = itP10;
1704 itP10++;
1705 m_p10CqiTimers.erase(temp);
1706 }
1707 else
1708 {
1709 (*itP10).second--;
1710 itP10++;
1711 }
1712 }
1713}
1714
1715void
1717{
1718 // refresh UL CQI Map
1719 auto itUl = m_ueCqiTimers.begin();
1720 while (itUl != m_ueCqiTimers.end())
1721 {
1722 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
1723 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1724 if ((*itUl).second == 0)
1725 {
1726 // delete correspondent entries
1727 auto itMap = m_ueCqi.find((*itUl).first);
1728 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
1729 " Does not find CQI report for user " << (*itUl).first);
1730 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
1731 (*itMap).second.clear();
1732 m_ueCqi.erase(itMap);
1733 auto temp = itUl;
1734 itUl++;
1735 m_ueCqiTimers.erase(temp);
1736 }
1737 else
1738 {
1739 (*itUl).second--;
1740 itUl++;
1741 }
1742 }
1743}
1744
1745void
1746RrFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
1747{
1748 NS_LOG_FUNCTION(this);
1749 for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
1750 {
1751 if (((*it).m_rnti == rnti) && ((*it).m_logicalChannelIdentity == lcid))
1752 {
1753 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
1754 << (*it).m_rlcTransmissionQueueSize << " retxqueue "
1755 << (*it).m_rlcRetransmissionQueueSize << " status "
1756 << (*it).m_rlcStatusPduSize << " decrease " << size);
1757 // Update queues: RLC tx order Status, ReTx, Tx
1758 // Update status queue
1759 if (((*it).m_rlcStatusPduSize > 0) && (size >= (*it).m_rlcStatusPduSize))
1760 {
1761 (*it).m_rlcStatusPduSize = 0;
1762 }
1763 else if (((*it).m_rlcRetransmissionQueueSize > 0) &&
1764 (size >= (*it).m_rlcRetransmissionQueueSize))
1765 {
1766 (*it).m_rlcRetransmissionQueueSize = 0;
1767 }
1768 else if ((*it).m_rlcTransmissionQueueSize > 0)
1769 {
1770 uint32_t rlcOverhead;
1771 if (lcid == 1)
1772 {
1773 // for SRB1 (using RLC AM) it's better to
1774 // overestimate RLC overhead rather than
1775 // underestimate it and risk unneeded
1776 // segmentation which increases delay
1777 rlcOverhead = 4;
1778 }
1779 else
1780 {
1781 // minimum RLC overhead due to header
1782 rlcOverhead = 2;
1783 }
1784 // update transmission queue
1785 if ((*it).m_rlcTransmissionQueueSize <= size - rlcOverhead)
1786 {
1787 (*it).m_rlcTransmissionQueueSize = 0;
1788 }
1789 else
1790 {
1791 (*it).m_rlcTransmissionQueueSize -= size - rlcOverhead;
1792 }
1793 }
1794 return;
1795 }
1796 }
1797}
1798
1799void
1800RrFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
1801{
1802 size = size - 2; // remove the minimum RLC overhead
1803 auto it = m_ceBsrRxed.find(rnti);
1804 if (it != m_ceBsrRxed.end())
1805 {
1806 NS_LOG_INFO(this << " Update RLC BSR UE " << rnti << " size " << size << " BSR "
1807 << (*it).second);
1808 if ((*it).second >= size)
1809 {
1810 (*it).second -= size;
1811 }
1812 else
1813 {
1814 (*it).second = 0;
1815 }
1816 }
1817 else
1818 {
1819 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
1820 }
1821}
1822
1823void
1825{
1826 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
1828 params.m_rnti = rnti;
1829 params.m_transmissionMode = txMode;
1830 m_cschedSapUser->CschedUeConfigUpdateInd(params);
1831}
1832
1833} // namespace ns3
static uint32_t BsrId2BufferSize(uint8_t val)
Convert BSR ID to buffer size.
Provides the CSCHED SAP.
FfMacCschedSapUser class.
Provides the SCHED SAP.
FfMacSchedSapUser class.
FfMacScheduler()
constructor
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.
Definition ptr.h:70
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:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:999
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:246
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:260
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:274
#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:267
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
#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:643
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 table 7.1.6.1-1 of 3GPP TS 36.213).
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.