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