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