A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fdmt-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("FdMtFfMacScheduler");
28
29/// FdMtType0AllocationRbg size array
30static const int FdMtType0AllocationRbg[4] = {
31 10, // RBG size 1
32 26, // RBG size 2
33 63, // RBG size 3
34 110, // RBG size 4
35}; // see table 7.1.6.1-1 of 36.213
36
37NS_OBJECT_ENSURE_REGISTERED(FdMtFfMacScheduler);
38
40 : m_cschedSapUser(nullptr),
41 m_schedSapUser(nullptr),
42 m_nextRntiUl(0)
43{
47}
48
53
54void
68
71{
72 static TypeId tid =
73 TypeId("ns3::FdMtFfMacScheduler")
75 .SetGroupName("Lte")
76 .AddConstructor<FdMtFfMacScheduler>()
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
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 < FdMtType0AllocationRbg[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
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
464 uint16_t rbStart = 0;
465 for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++)
466 {
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 NS_LOG_INFO(this << " Processing DLHARQ feedback");
586 if (nLayers == 1)
587 {
588 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
590 retx.push_back(false);
591 }
592 else
593 {
594 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
596 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(1) ==
598 }
599 if (retx.at(0) || retx.at(1))
600 {
601 // retrieve HARQ process information
602 uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti;
603 uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId;
604 NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
605 auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti);
606 if (itHarq == m_dlHarqProcessesDciBuffer.end())
607 {
608 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti);
609 }
610
611 DlDciListElement_s dci = (*itHarq).second.at(harqId);
612 int rv = 0;
613 if (dci.m_rv.size() == 1)
614 {
615 rv = dci.m_rv.at(0);
616 }
617 else
618 {
619 rv = (dci.m_rv.at(0) > dci.m_rv.at(1) ? dci.m_rv.at(0) : dci.m_rv.at(1));
620 }
621
622 if (rv == 3)
623 {
624 // maximum number of retx reached -> drop process
625 NS_LOG_INFO("Maximum number of retransmissions reached -> drop process");
626 auto it = m_dlHarqProcessesStatus.find(rnti);
627 if (it == m_dlHarqProcessesStatus.end())
628 {
629 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
630 << m_dlInfoListBuffered.at(i).m_rnti);
631 }
632 (*it).second.at(harqId) = 0;
633 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
634 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
635 {
636 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
637 << m_dlInfoListBuffered.at(i).m_rnti);
638 }
639 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
640 {
641 (*itRlcPdu).second.at(k).at(harqId).clear();
642 }
643 continue;
644 }
645 // check the feasibility of retransmitting on the same RBGs
646 // translate the DCI to Spectrum framework
647 std::vector<int> dciRbg;
648 uint32_t mask = 0x1;
649 NS_LOG_INFO("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
650 for (int j = 0; j < 32; j++)
651 {
652 if (((dci.m_rbBitmap & mask) >> j) == 1)
653 {
654 dciRbg.push_back(j);
655 NS_LOG_INFO("\t" << j);
656 }
657 mask = (mask << 1);
658 }
659 bool free = true;
660 for (std::size_t j = 0; j < dciRbg.size(); j++)
661 {
662 if (rbgMap.at(dciRbg.at(j)))
663 {
664 free = false;
665 break;
666 }
667 }
668 if (free)
669 {
670 // use the same RBGs for the retx
671 // reserve RBGs
672 for (std::size_t j = 0; j < dciRbg.size(); j++)
673 {
674 rbgMap.at(dciRbg.at(j)) = true;
675 NS_LOG_INFO("RBG " << dciRbg.at(j) << " assigned");
676 rbgAllocatedNum++;
677 }
678
679 NS_LOG_INFO(this << " Send retx in the same RBGs");
680 }
681 else
682 {
683 // find RBGs for sending HARQ retx
684 uint8_t j = 0;
685 uint8_t rbgId = (dciRbg.at(dciRbg.size() - 1) + 1) % rbgNum;
686 uint8_t startRbg = dciRbg.at(dciRbg.size() - 1);
687 std::vector<bool> rbgMapCopy = rbgMap;
688 while ((j < dciRbg.size()) && (startRbg != rbgId))
689 {
690 if (!rbgMapCopy.at(rbgId))
691 {
692 rbgMapCopy.at(rbgId) = true;
693 dciRbg.at(j) = rbgId;
694 j++;
695 }
696 rbgId = (rbgId + 1) % rbgNum;
697 }
698 if (j == dciRbg.size())
699 {
700 // find new RBGs -> update DCI map
701 uint32_t rbgMask = 0;
702 for (std::size_t k = 0; k < dciRbg.size(); k++)
703 {
704 rbgMask = rbgMask + (0x1 << dciRbg.at(k));
705 rbgAllocatedNum++;
706 }
707 dci.m_rbBitmap = rbgMask;
708 rbgMap = rbgMapCopy;
709 NS_LOG_INFO(this << " Move retx in RBGs " << dciRbg.size());
710 }
711 else
712 {
713 // HARQ retx cannot be performed on this TTI -> store it
714 dlInfoListUntxed.push_back(m_dlInfoListBuffered.at(i));
715 NS_LOG_INFO(this << " No resource for this retx -> buffer it");
716 }
717 }
718 // retrieve RLC PDU list for retx TBsize and update DCI
720 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
721 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
722 {
723 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
724 }
725 for (std::size_t j = 0; j < nLayers; j++)
726 {
727 if (retx.at(j))
728 {
729 if (j >= dci.m_ndi.size())
730 {
731 // for avoiding errors in MIMO transient phases
732 dci.m_ndi.push_back(0);
733 dci.m_rv.push_back(0);
734 dci.m_mcs.push_back(0);
735 dci.m_tbsSize.push_back(0);
736 NS_LOG_INFO(this << " layer " << (uint16_t)j
737 << " no txed (MIMO transition)");
738 }
739 else
740 {
741 dci.m_ndi.at(j) = 0;
742 dci.m_rv.at(j)++;
743 (*itHarq).second.at(harqId).m_rv.at(j)++;
744 NS_LOG_INFO(this << " layer " << (uint16_t)j << " RV "
745 << (uint16_t)dci.m_rv.at(j));
746 }
747 }
748 else
749 {
750 // empty TB of layer j
751 dci.m_ndi.at(j) = 0;
752 dci.m_rv.at(j) = 0;
753 dci.m_mcs.at(j) = 0;
754 dci.m_tbsSize.at(j) = 0;
755 NS_LOG_INFO(this << " layer " << (uint16_t)j << " no retx");
756 }
757 }
758 for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++)
759 {
760 std::vector<RlcPduListElement_s> rlcPduListPerLc;
761 for (std::size_t j = 0; j < nLayers; j++)
762 {
763 if (retx.at(j))
764 {
765 if (j < dci.m_ndi.size())
766 {
767 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size "
768 << dci.m_tbsSize.at(j));
769 rlcPduListPerLc.push_back(
770 (*itRlcPdu).second.at(j).at(dci.m_harqProcess).at(k));
771 }
772 }
773 else
774 { // if no retx needed on layer j, push an RlcPduListElement_s object with
775 // m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
776 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at(j));
777 RlcPduListElement_s emptyElement;
778 emptyElement.m_logicalChannelIdentity = (*itRlcPdu)
779 .second.at(j)
780 .at(dci.m_harqProcess)
781 .at(k)
782 .m_logicalChannelIdentity;
783 emptyElement.m_size = 0;
784 rlcPduListPerLc.push_back(emptyElement);
785 }
786 }
787
788 if (!rlcPduListPerLc.empty())
789 {
790 newEl.m_rlcPduList.push_back(rlcPduListPerLc);
791 }
792 }
793 newEl.m_rnti = rnti;
794 newEl.m_dci = dci;
795 (*itHarq).second.at(harqId).m_rv = dci.m_rv;
796 // refresh timer
797 auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti);
798 if (itHarqTimer == m_dlHarqProcessesTimer.end())
799 {
800 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
801 }
802 (*itHarqTimer).second.at(harqId) = 0;
803 ret.m_buildDataList.push_back(newEl);
804 rntiAllocated.insert(rnti);
805 }
806 else
807 {
808 // update HARQ process status
809 NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti);
810 auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti);
811 if (it == m_dlHarqProcessesStatus.end())
812 {
813 NS_FATAL_ERROR("No info find in HARQ buffer for UE "
814 << m_dlInfoListBuffered.at(i).m_rnti);
815 }
816 (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0;
817 auto itRlcPdu =
819 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
820 {
821 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
822 << m_dlInfoListBuffered.at(i).m_rnti);
823 }
824 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
825 {
826 (*itRlcPdu).second.at(k).at(m_dlInfoListBuffered.at(i).m_harqProcessId).clear();
827 }
828 }
829 }
830 m_dlInfoListBuffered.clear();
831 m_dlInfoListBuffered = dlInfoListUntxed;
832
833 if (rbgAllocatedNum == rbgNum)
834 {
835 // all the RBGs are already allocated -> exit
836 if (!ret.m_buildDataList.empty() || !ret.m_buildRarList.empty())
837 {
839 }
840 return;
841 }
842
843 for (int i = 0; i < rbgNum; i++)
844 {
845 NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum);
846 if (!rbgMap.at(i))
847 {
848 auto itMax = m_flowStatsDl.end();
849 double rcqiMax = 0.0;
850 for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++)
851 {
852 auto itRnti = rntiAllocated.find(*it);
853 if (itRnti != rntiAllocated.end() || !HarqProcessAvailability(*it))
854 {
855 // UE already allocated for HARQ or without HARQ process available -> drop it
856 if (itRnti != rntiAllocated.end())
857 {
858 NS_LOG_DEBUG(this << " RNTI discarded for HARQ tx" << (uint16_t)(*it));
859 }
860 if (!HarqProcessAvailability(*it))
861 {
862 NS_LOG_DEBUG(this << " RNTI discarded for HARQ id" << (uint16_t)(*it));
863 }
864 continue;
865 }
866
867 auto itCqi = m_a30CqiRxed.find(*it);
868 auto itTxMode = m_uesTxMode.find(*it);
869 if (itTxMode == m_uesTxMode.end())
870 {
871 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it));
872 }
873 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
874 std::vector<uint8_t> sbCqi;
875 if (itCqi == m_a30CqiRxed.end())
876 {
877 sbCqi = std::vector<uint8_t>(nLayer, 1); // start with lowest value
878 }
879 else
880 {
881 sbCqi = (*itCqi).second.m_higherLayerSelected.at(i).m_sbCqi;
882 }
883 uint8_t cqi1 = sbCqi.at(0);
884 uint8_t cqi2 = 0;
885 if (sbCqi.size() > 1)
886 {
887 cqi2 = sbCqi.at(1);
888 }
889 if ((cqi1 > 0) ||
890 (cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
891 {
892 if (LcActivePerFlow(*it) > 0)
893 {
894 // this UE has data to transmit
895 double achievableRate = 0.0;
896 uint8_t mcs = 0;
897 for (uint8_t k = 0; k < nLayer; k++)
898 {
899 if (sbCqi.size() > k)
900 {
901 mcs = m_amc->GetMcsFromCqi(sbCqi.at(k));
902 }
903 else
904 {
905 // no info on this subband -> worst MCS
906 mcs = 0;
907 }
908 achievableRate += ((m_amc->GetDlTbSizeFromMcs(mcs, rbgSize) / 8) /
909 0.001); // = TB size / TTI
910 }
911
912 double rcqi = achievableRate;
913 NS_LOG_INFO(this << " RNTI " << (*it) << " MCS " << (uint32_t)mcs
914 << " achievableRate " << achievableRate << " RCQI "
915 << rcqi);
916
917 if (rcqi > rcqiMax)
918 {
919 rcqiMax = rcqi;
920 itMax = it;
921 }
922 }
923 } // end if cqi
924
925 } // end for m_rlcBufferReq
926
927 if (itMax == m_flowStatsDl.end())
928 {
929 // no UE available for this RB
930 NS_LOG_INFO(this << " any UE found");
931 }
932 else
933 {
934 rbgMap.at(i) = true;
935 auto itMap = allocationMap.find(*itMax);
936 if (itMap == allocationMap.end())
937 {
938 // insert new element
939 std::vector<uint16_t> tempMap;
940 tempMap.push_back(i);
941 allocationMap[*itMax] = tempMap;
942 }
943 else
944 {
945 (*itMap).second.push_back(i);
946 }
947 NS_LOG_INFO(this << " UE assigned " << (*itMax));
948 }
949 } // end for RBG free
950 } // end for RBGs
951
952 // generate the transmission opportunities by grouping the RBGs of the same RNTI and
953 // creating the correspondent DCIs
954 auto itMap = allocationMap.begin();
955 while (itMap != allocationMap.end())
956 {
957 // create new BuildDataListElement_s for this LC
959 newEl.m_rnti = (*itMap).first;
960 // create the DlDciListElement_s
961 DlDciListElement_s newDci;
962 newDci.m_rnti = (*itMap).first;
963 newDci.m_harqProcess = UpdateHarqProcessId((*itMap).first);
964
965 uint16_t lcActives = LcActivePerFlow((*itMap).first);
966 NS_LOG_INFO(this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
967 if (lcActives == 0)
968 {
969 // Set to max value, to avoid divide by 0 below
970 lcActives = (uint16_t)65535; // UINT16_MAX;
971 }
972 uint16_t RbgPerRnti = (*itMap).second.size();
973 auto itCqi = m_a30CqiRxed.find((*itMap).first);
974 auto itTxMode = m_uesTxMode.find((*itMap).first);
975 if (itTxMode == m_uesTxMode.end())
976 {
977 NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first);
978 }
979 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
980 std::vector<uint8_t> worstCqi(2, 15);
981 if (itCqi != m_a30CqiRxed.end())
982 {
983 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
984 {
985 if ((*itCqi).second.m_higherLayerSelected.size() > (*itMap).second.at(k))
986 {
987 NS_LOG_INFO(this << " RBG " << (*itMap).second.at(k) << " CQI "
988 << (uint16_t)((*itCqi)
989 .second.m_higherLayerSelected
990 .at((*itMap).second.at(k))
991 .m_sbCqi.at(0)));
992 for (uint8_t j = 0; j < nLayer; j++)
993 {
994 if ((*itCqi)
995 .second.m_higherLayerSelected.at((*itMap).second.at(k))
996 .m_sbCqi.size() > j)
997 {
998 if (((*itCqi)
999 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1000 .m_sbCqi.at(j)) < worstCqi.at(j))
1001 {
1002 worstCqi.at(j) =
1003 ((*itCqi)
1004 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1005 .m_sbCqi.at(j));
1006 }
1007 }
1008 else
1009 {
1010 // no CQI for this layer of this suband -> worst one
1011 worstCqi.at(j) = 1;
1012 }
1013 }
1014 }
1015 else
1016 {
1017 for (uint8_t j = 0; j < nLayer; j++)
1018 {
1019 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1020 }
1021 }
1022 }
1023 }
1024 else
1025 {
1026 for (uint8_t j = 0; j < nLayer; j++)
1027 {
1028 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1029 }
1030 }
1031 for (uint8_t j = 0; j < nLayer; j++)
1032 {
1033 NS_LOG_INFO(this << " Layer " << (uint16_t)j << " CQI selected "
1034 << (uint16_t)worstCqi.at(j));
1035 }
1036 for (uint8_t j = 0; j < nLayer; j++)
1037 {
1038 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi(worstCqi.at(j)));
1039 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(j), RbgPerRnti * rbgSize) /
1040 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
1041 newDci.m_tbsSize.push_back(tbSize);
1042 NS_LOG_INFO(this << " Layer " << (uint16_t)j << " MCS selected"
1043 << m_amc->GetMcsFromCqi(worstCqi.at(j)));
1044 }
1045
1046 newDci.m_resAlloc = 0; // only allocation type 0 at this stage
1047 newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
1048 uint32_t rbgMask = 0;
1049 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1050 {
1051 rbgMask = rbgMask + (0x1 << (*itMap).second.at(k));
1052 NS_LOG_INFO(this << " Allocated RBG " << (*itMap).second.at(k));
1053 }
1054 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1055
1056 // create the rlc PDUs -> equally divide resources among actives LCs
1057 for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++)
1058 {
1059 if (((*itBufReq).first.m_rnti == (*itMap).first) &&
1060 (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) ||
1061 ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) ||
1062 ((*itBufReq).second.m_rlcStatusPduSize > 0)))
1063 {
1064 std::vector<RlcPduListElement_s> newRlcPduLe;
1065 for (uint8_t j = 0; j < nLayer; j++)
1066 {
1067 RlcPduListElement_s newRlcEl;
1068 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1069 newRlcEl.m_size = newDci.m_tbsSize.at(j) / lcActives;
1070 NS_LOG_INFO(this << " LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
1071 << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
1072 newRlcPduLe.push_back(newRlcEl);
1074 newRlcEl.m_logicalChannelIdentity,
1075 newRlcEl.m_size);
1076 if (m_harqOn)
1077 {
1078 // store RLC PDU list for HARQ
1079 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first);
1080 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1081 {
1082 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1083 << (*itMap).first);
1084 }
1085 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1086 }
1087 }
1088 newEl.m_rlcPduList.push_back(newRlcPduLe);
1089 }
1090 if ((*itBufReq).first.m_rnti > (*itMap).first)
1091 {
1092 break;
1093 }
1094 }
1095 for (uint8_t j = 0; j < nLayer; j++)
1096 {
1097 newDci.m_ndi.push_back(1);
1098 newDci.m_rv.push_back(0);
1099 }
1100
1101 newDci.m_tpc = 1; // 1 is mapped to 0 in Accumulated Mode and to -1 in Absolute Mode
1102
1103 newEl.m_dci = newDci;
1104
1105 if (m_harqOn)
1106 {
1107 // store DCI for HARQ
1108 auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti);
1109 if (itDci == m_dlHarqProcessesDciBuffer.end())
1110 {
1111 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1112 << newEl.m_rnti);
1113 }
1114 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1115 // refresh timer
1116 auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti);
1117 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1118 {
1119 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1120 }
1121 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1122 }
1123
1124 // ...more parameters -> ignored in this version
1125
1126 ret.m_buildDataList.push_back(newEl);
1127
1128 itMap++;
1129 } // end while allocation
1130 ret.m_nrOfPdcchOfdmSymbols = 1; /// \todo check correct value according the DCIs txed
1131
1133}
1134
1135void
1143
1144void
1147{
1148 NS_LOG_FUNCTION(this);
1149
1150 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1151 {
1152 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1153 {
1154 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1155 << " reported");
1156 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1157 auto it = m_p10CqiRxed.find(rnti);
1158 if (it == m_p10CqiRxed.end())
1159 {
1160 // create the new entry
1161 m_p10CqiRxed[rnti] =
1162 params.m_cqiList.at(i).m_wbCqi.at(0); // only codeword 0 at this stage (SISO)
1163 // generate correspondent timer
1165 }
1166 else
1167 {
1168 // update the CQI value and refresh correspondent timer
1169 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1170 // update correspondent timer
1171 auto itTimers = m_p10CqiTimers.find(rnti);
1172 (*itTimers).second = m_cqiTimersThreshold;
1173 }
1174 }
1175 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1176 {
1177 // subband CQI reporting high layer configured
1178 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1179 auto it = m_a30CqiRxed.find(rnti);
1180 if (it == m_a30CqiRxed.end())
1181 {
1182 // create the new entry
1183 m_a30CqiRxed[rnti] = params.m_cqiList.at(i).m_sbMeasResult;
1185 }
1186 else
1187 {
1188 // update the CQI value and refresh correspondent timer
1189 (*it).second = params.m_cqiList.at(i).m_sbMeasResult;
1190 auto itTimers = m_a30CqiTimers.find(rnti);
1191 (*itTimers).second = m_cqiTimersThreshold;
1192 }
1193 }
1194 else
1195 {
1196 NS_LOG_ERROR(this << " CQI type unknown");
1197 }
1198 }
1199}
1200
1201double
1202FdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb)
1203{
1204 auto itCqi = m_ueCqi.find(rnti);
1205 if (itCqi == m_ueCqi.end())
1206 {
1207 // no cqi info about this UE
1208 return NO_SINR;
1209 }
1210 else
1211 {
1212 // take the average SINR value among the available
1213 double sinrSum = 0;
1214 unsigned int sinrNum = 0;
1215 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1216 {
1217 double sinr = (*itCqi).second.at(i);
1218 if (sinr != NO_SINR)
1219 {
1220 sinrSum += sinr;
1221 sinrNum++;
1222 }
1223 }
1224 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1225 // store the value
1226 (*itCqi).second.at(rb) = estimatedSinr;
1227 return estimatedSinr;
1228 }
1229}
1230
1231void
1234{
1235 NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
1236 << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size());
1237
1239
1240 // Generate RBs map
1242 std::vector<bool> rbMap;
1243 std::set<uint16_t> rntiAllocated;
1244 std::vector<uint16_t> rbgAllocationMap;
1245 // update with RACH allocation map
1246 rbgAllocationMap = m_rachAllocationMap;
1247 // rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1248 m_rachAllocationMap.clear();
1250
1251 rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
1252 // remove RACH allocation
1253 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1254 {
1255 if (rbgAllocationMap.at(i) != 0)
1256 {
1257 rbMap.at(i) = true;
1258 NS_LOG_DEBUG(this << " Allocated for RACH " << i);
1259 }
1260 }
1261
1262 if (m_harqOn)
1263 {
1264 // Process UL HARQ feedback
1265 for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++)
1266 {
1267 if (params.m_ulInfoList.at(i).m_receptionStatus == UlInfoListElement_s::NotOk)
1268 {
1269 // retx correspondent block: retrieve the UL-DCI
1270 uint16_t rnti = params.m_ulInfoList.at(i).m_rnti;
1271 auto itProcId = m_ulHarqCurrentProcessId.find(rnti);
1272 if (itProcId == m_ulHarqCurrentProcessId.end())
1273 {
1274 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1275 }
1276 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1277 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId
1278 << " i " << i << " size " << params.m_ulInfoList.size());
1279 auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti);
1280 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1281 {
1282 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1283 continue;
1284 }
1285 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1286 auto itStat = m_ulHarqProcessesStatus.find(rnti);
1287 if (itStat == m_ulHarqProcessesStatus.end())
1288 {
1289 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1290 }
1291 if ((*itStat).second.at(harqId) >= 3)
1292 {
1293 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1294 continue;
1295 }
1296 bool free = true;
1297 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1298 {
1299 if (rbMap.at(j))
1300 {
1301 free = false;
1302 NS_LOG_INFO(this << " BUSY " << j);
1303 }
1304 }
1305 if (free)
1306 {
1307 // retx on the same RBs
1308 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1309 {
1310 rbMap.at(j) = true;
1311 rbgAllocationMap.at(j) = dci.m_rnti;
1312 NS_LOG_INFO("\tRB " << j);
1313 }
1314 NS_LOG_INFO(this << " Send retx in the same RBs " << (uint16_t)dci.m_rbStart
1315 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1316 << (*itStat).second.at(harqId) + 1);
1317 }
1318 else
1319 {
1320 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1321 continue;
1322 }
1323 dci.m_ndi = 0;
1324 // Update HARQ buffers with new HarqId
1325 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1326 (*itStat).second.at(harqId) = 0;
1327 (*itHarq).second.at((*itProcId).second) = dci;
1328 ret.m_dciList.push_back(dci);
1329 rntiAllocated.insert(dci.m_rnti);
1330 }
1331 else
1332 {
1333 NS_LOG_INFO(this << " HARQ-ACK feedback from RNTI "
1334 << params.m_ulInfoList.at(i).m_rnti);
1335 }
1336 }
1337 }
1338
1339 std::map<uint16_t, uint32_t>::iterator it;
1340 int nflows = 0;
1341
1342 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1343 {
1344 auto itRnti = rntiAllocated.find((*it).first);
1345 // select UEs with queues not empty and not yet allocated for HARQ
1346 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1347 {
1348 nflows++;
1349 }
1350 }
1351
1352 if (nflows == 0)
1353 {
1354 if (!ret.m_dciList.empty())
1355 {
1356 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1358 }
1359
1360 return; // no flows to be scheduled
1361 }
1362
1363 // Divide the remaining resources equally among the active users starting from the subsequent
1364 // one served last scheduling trigger
1365 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size());
1366 if (rbPerFlow < 3)
1367 {
1368 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1369 // >= 7 bytes
1370 }
1371 int rbAllocated = 0;
1372
1373 if (m_nextRntiUl != 0)
1374 {
1375 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1376 {
1377 if ((*it).first == m_nextRntiUl)
1378 {
1379 break;
1380 }
1381 }
1382 if (it == m_ceBsrRxed.end())
1383 {
1384 NS_LOG_ERROR(this << " no user found");
1385 }
1386 }
1387 else
1388 {
1389 it = m_ceBsrRxed.begin();
1390 m_nextRntiUl = (*it).first;
1391 }
1392 do
1393 {
1394 auto itRnti = rntiAllocated.find((*it).first);
1395 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1396 {
1397 // UE already allocated for UL-HARQ -> skip it
1398 NS_LOG_DEBUG(this << " UE already allocated in HARQ -> discarded, RNTI "
1399 << (*it).first);
1400 it++;
1401 if (it == m_ceBsrRxed.end())
1402 {
1403 // restart from the first
1404 it = m_ceBsrRxed.begin();
1405 }
1406 continue;
1407 }
1408 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1409 {
1410 // limit to physical resources last resource assignment
1411 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1412 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1413 if (rbPerFlow < 3)
1414 {
1415 // terminate allocation
1416 rbPerFlow = 0;
1417 }
1418 }
1419
1420 UlDciListElement_s uldci;
1421 uldci.m_rnti = (*it).first;
1422 uldci.m_rbLen = rbPerFlow;
1423 bool allocated = false;
1424 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1425 << " flows " << nflows);
1426 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1427 (rbPerFlow != 0))
1428 {
1429 // check availability
1430 bool free = true;
1431 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1432 {
1433 if (rbMap.at(j))
1434 {
1435 free = false;
1436 break;
1437 }
1438 }
1439 if (free)
1440 {
1441 uldci.m_rbStart = rbAllocated;
1442
1443 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1444 {
1445 rbMap.at(j) = true;
1446 // store info on allocation for managing ul-cqi interpretation
1447 rbgAllocationMap.at(j) = (*it).first;
1448 }
1449 rbAllocated += rbPerFlow;
1450 allocated = true;
1451 break;
1452 }
1453 rbAllocated++;
1454 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1455 {
1456 // limit to physical resources last resource assignment
1457 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1458 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1459 if (rbPerFlow < 3)
1460 {
1461 // terminate allocation
1462 rbPerFlow = 0;
1463 }
1464 }
1465 }
1466 if (!allocated)
1467 {
1468 // unable to allocate new resource: finish scheduling
1469 m_nextRntiUl = (*it).first;
1470 if (!ret.m_dciList.empty())
1471 {
1473 }
1474 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1475 return;
1476 }
1477
1478 auto itCqi = m_ueCqi.find((*it).first);
1479 int cqi = 0;
1480 if (itCqi == m_ueCqi.end())
1481 {
1482 // no cqi info about this UE
1483 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1484 }
1485 else
1486 {
1487 // take the lowest CQI value (worst RB)
1488 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1489 "CQI of RNTI = " << (*it).first << " has expired");
1490 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1491 if (minSinr == NO_SINR)
1492 {
1493 minSinr = EstimateUlSinr((*it).first, uldci.m_rbStart);
1494 }
1495 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1496 {
1497 double sinr = (*itCqi).second.at(i);
1498 if (sinr == NO_SINR)
1499 {
1500 sinr = EstimateUlSinr((*it).first, i);
1501 }
1502 if (sinr < minSinr)
1503 {
1504 minSinr = sinr;
1505 }
1506 }
1507
1508 // translate SINR -> cqi: WILD ACK: same as DL
1509 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1510 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1511 if (cqi == 0)
1512 {
1513 it++;
1514 if (it == m_ceBsrRxed.end())
1515 {
1516 // restart from the first
1517 it = m_ceBsrRxed.begin();
1518 }
1519 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1520 // remove UE from allocation map
1521 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1522 {
1523 rbgAllocationMap.at(i) = 0;
1524 }
1525 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1526 }
1527 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1528 }
1529
1530 uldci.m_tbSize = (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8);
1532 uldci.m_ndi = 1;
1533 uldci.m_cceIndex = 0;
1534 uldci.m_aggrLevel = 1;
1535 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1536 uldci.m_hopping = false;
1537 uldci.m_n2Dmrs = 0;
1538 uldci.m_tpc = 0; // no power control
1539 uldci.m_cqiRequest = false; // only period CQI at this stage
1540 uldci.m_ulIndex = 0; // TDD parameter
1541 uldci.m_dai = 1; // TDD parameter
1542 uldci.m_freqHopping = 0;
1543 uldci.m_pdcchPowerOffset = 0; // not used
1544 ret.m_dciList.push_back(uldci);
1545 // store DCI for HARQ_PERIOD
1546 uint8_t harqId = 0;
1547 if (m_harqOn)
1548 {
1549 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1550 if (itProcId == m_ulHarqCurrentProcessId.end())
1551 {
1552 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
1553 }
1554 harqId = (*itProcId).second;
1555 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
1556 if (itDci == m_ulHarqProcessesDciBuffer.end())
1557 {
1558 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
1559 << uldci.m_rnti);
1560 }
1561 (*itDci).second.at(harqId) = uldci;
1562 // Update HARQ process status (RV 0)
1563 auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti);
1564 if (itStat == m_ulHarqProcessesStatus.end())
1565 {
1566 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
1567 << uldci.m_rnti);
1568 }
1569 (*itStat).second.at(harqId) = 0;
1570 }
1571
1572 NS_LOG_INFO(this << " UE Allocation RNTI " << (*it).first << " startPRB "
1573 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
1574 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
1575 << uldci.m_tbSize << " RbAlloc " << rbAllocated << " harqId "
1576 << (uint16_t)harqId);
1577
1578 it++;
1579 if (it == m_ceBsrRxed.end())
1580 {
1581 // restart from the first
1582 it = m_ceBsrRxed.begin();
1583 }
1584 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1585 {
1586 // Stop allocation: no more PRBs
1587 m_nextRntiUl = (*it).first;
1588 break;
1589 }
1590 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
1591
1592 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1594}
1595
1596void
1602
1603void
1609
1610void
1613{
1614 NS_LOG_FUNCTION(this);
1615
1616 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
1617 {
1618 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
1619 {
1620 // buffer status report
1621 // note that this scheduler does not differentiate the
1622 // allocation according to which LCGs have more/less bytes
1623 // to send.
1624 // Hence the BSR of different LCGs are just summed up to get
1625 // a total queue size that is used for allocation purposes.
1626
1627 uint32_t buffer = 0;
1628 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1629 {
1630 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
1631 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
1632 }
1633
1634 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
1635 NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer);
1636 auto it = m_ceBsrRxed.find(rnti);
1637 if (it == m_ceBsrRxed.end())
1638 {
1639 // create the new entry
1640 m_ceBsrRxed[rnti] = buffer;
1641 }
1642 else
1643 {
1644 // update the buffer size value
1645 (*it).second = buffer;
1646 }
1647 }
1648 }
1649}
1650
1651void
1654{
1655 NS_LOG_FUNCTION(this);
1656 // retrieve the allocation for this subframe
1657 switch (m_ulCqiFilter)
1658 {
1660 // filter all the CQIs that are not SRS based
1661 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1662 {
1663 return;
1664 }
1665 }
1666 break;
1668 // filter all the CQIs that are not SRS based
1669 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1670 {
1671 return;
1672 }
1673 }
1674 break;
1675 default:
1676 NS_FATAL_ERROR("Unknown UL CQI type");
1677 }
1678
1679 switch (params.m_ulCqi.m_type)
1680 {
1681 case UlCqi_s::PUSCH: {
1682 NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4)
1683 << " subframe no. " << (0xF & params.m_sfnSf));
1684 auto itMap = m_allocationMaps.find(params.m_sfnSf);
1685 if (itMap == m_allocationMaps.end())
1686 {
1687 return;
1688 }
1689 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
1690 {
1691 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1692 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
1693 auto itCqi = m_ueCqi.find((*itMap).second.at(i));
1694 if (itCqi == m_ueCqi.end())
1695 {
1696 // create a new entry
1697 std::vector<double> newCqi;
1698 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1699 {
1700 if (i == j)
1701 {
1702 newCqi.push_back(sinr);
1703 }
1704 else
1705 {
1706 // initialize with NO_SINR value.
1707 newCqi.push_back(NO_SINR);
1708 }
1709 }
1710 m_ueCqi[(*itMap).second.at(i)] = newCqi;
1711 // generate correspondent timer
1712 m_ueCqiTimers[(*itMap).second.at(i)] = m_cqiTimersThreshold;
1713 }
1714 else
1715 {
1716 // update the value
1717 (*itCqi).second.at(i) = sinr;
1718 NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR "
1719 << sinr);
1720 // update correspondent timer
1721 auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
1722 (*itTimers).second = m_cqiTimersThreshold;
1723 }
1724 }
1725 // remove obsolete info on allocation
1726 m_allocationMaps.erase(itMap);
1727 }
1728 break;
1729 case UlCqi_s::SRS: {
1730 // get the RNTI from vendor specific parameters
1731 uint16_t rnti = 0;
1732 NS_ASSERT(!params.m_vendorSpecificList.empty());
1733 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
1734 {
1735 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
1736 {
1737 Ptr<SrsCqiRntiVsp> vsp =
1738 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
1739 rnti = vsp->GetRnti();
1740 }
1741 }
1742 auto itCqi = m_ueCqi.find(rnti);
1743 if (itCqi == m_ueCqi.end())
1744 {
1745 // create a new entry
1746 std::vector<double> newCqi;
1747 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1748 {
1749 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1750 newCqi.push_back(sinr);
1751 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
1752 << sinr);
1753 }
1754 m_ueCqi[rnti] = newCqi;
1755 // generate correspondent timer
1757 }
1758 else
1759 {
1760 // update the values
1761 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1762 {
1763 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1764 (*itCqi).second.at(j) = sinr;
1765 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
1766 << sinr);
1767 }
1768 // update correspondent timer
1769 auto itTimers = m_ueCqiTimers.find(rnti);
1770 (*itTimers).second = m_cqiTimersThreshold;
1771 }
1772 }
1773 break;
1774 case UlCqi_s::PUCCH_1:
1775 case UlCqi_s::PUCCH_2:
1776 case UlCqi_s::PRACH: {
1777 NS_FATAL_ERROR("FdMtFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1778 }
1779 break;
1780 default:
1781 NS_FATAL_ERROR("Unknown type of UL-CQI");
1782 }
1783}
1784
1785void
1787{
1788 // refresh DL CQI P01 Map
1789 auto itP10 = m_p10CqiTimers.begin();
1790 while (itP10 != m_p10CqiTimers.end())
1791 {
1792 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
1793 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1794 if ((*itP10).second == 0)
1795 {
1796 // delete correspondent entries
1797 auto itMap = m_p10CqiRxed.find((*itP10).first);
1798 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
1799 " Does not find CQI report for user " << (*itP10).first);
1800 NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first);
1801 m_p10CqiRxed.erase(itMap);
1802 auto temp = itP10;
1803 itP10++;
1804 m_p10CqiTimers.erase(temp);
1805 }
1806 else
1807 {
1808 (*itP10).second--;
1809 itP10++;
1810 }
1811 }
1812
1813 // refresh DL CQI A30 Map
1814 auto itA30 = m_a30CqiTimers.begin();
1815 while (itA30 != m_a30CqiTimers.end())
1816 {
1817 NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is "
1818 << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1819 if ((*itA30).second == 0)
1820 {
1821 // delete correspondent entries
1822 auto itMap = m_a30CqiRxed.find((*itA30).first);
1823 NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(),
1824 " Does not find CQI report for user " << (*itA30).first);
1825 NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first);
1826 m_a30CqiRxed.erase(itMap);
1827 auto temp = itA30;
1828 itA30++;
1829 m_a30CqiTimers.erase(temp);
1830 }
1831 else
1832 {
1833 (*itA30).second--;
1834 itA30++;
1835 }
1836 }
1837}
1838
1839void
1841{
1842 // refresh UL CQI Map
1843 auto itUl = m_ueCqiTimers.begin();
1844 while (itUl != m_ueCqiTimers.end())
1845 {
1846 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
1847 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1848 if ((*itUl).second == 0)
1849 {
1850 // delete correspondent entries
1851 auto itMap = m_ueCqi.find((*itUl).first);
1852 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
1853 " Does not find CQI report for user " << (*itUl).first);
1854 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
1855 (*itMap).second.clear();
1856 m_ueCqi.erase(itMap);
1857 auto temp = itUl;
1858 itUl++;
1859 m_ueCqiTimers.erase(temp);
1860 }
1861 else
1862 {
1863 (*itUl).second--;
1864 itUl++;
1865 }
1866 }
1867}
1868
1869void
1870FdMtFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
1871{
1872 LteFlowId_t flow(rnti, lcid);
1873 auto it = m_rlcBufferReq.find(flow);
1874 if (it != m_rlcBufferReq.end())
1875 {
1876 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
1877 << (*it).second.m_rlcTransmissionQueueSize << " retxqueue "
1878 << (*it).second.m_rlcRetransmissionQueueSize << " status "
1879 << (*it).second.m_rlcStatusPduSize << " decrease " << size);
1880 // Update queues: RLC tx order Status, ReTx, Tx
1881 // Update status queue
1882 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
1883 {
1884 (*it).second.m_rlcStatusPduSize = 0;
1885 }
1886 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) &&
1887 (size >= (*it).second.m_rlcRetransmissionQueueSize))
1888 {
1889 (*it).second.m_rlcRetransmissionQueueSize = 0;
1890 }
1891 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
1892 {
1893 uint32_t rlcOverhead;
1894 if (lcid == 1)
1895 {
1896 // for SRB1 (using RLC AM) it's better to
1897 // overestimate RLC overhead rather than
1898 // underestimate it and risk unneeded
1899 // segmentation which increases delay
1900 rlcOverhead = 4;
1901 }
1902 else
1903 {
1904 // minimum RLC overhead due to header
1905 rlcOverhead = 2;
1906 }
1907 // update transmission queue
1908 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
1909 {
1910 (*it).second.m_rlcTransmissionQueueSize = 0;
1911 }
1912 else
1913 {
1914 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
1915 }
1916 }
1917 }
1918 else
1919 {
1920 NS_LOG_ERROR(this << " Does not find DL RLC Buffer Report of UE " << rnti);
1921 }
1922}
1923
1924void
1926{
1927 size = size - 2; // remove the minimum RLC overhead
1928 auto it = m_ceBsrRxed.find(rnti);
1929 if (it != m_ceBsrRxed.end())
1930 {
1931 NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
1932 if ((*it).second >= size)
1933 {
1934 (*it).second -= size;
1935 }
1936 else
1937 {
1938 (*it).second = 0;
1939 }
1940 }
1941 else
1942 {
1943 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
1944 }
1945}
1946
1947void
1949{
1950 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
1952 params.m_rnti = rnti;
1953 params.m_transmissionMode = txMode;
1955}
1956
1957} // namespace ns3
static uint32_t BsrId2BufferSize(uint8_t val)
Convert BSR ID to buffer size.
Implements the SCHED SAP and CSCHED SAP for a Frequency Domain Maximize Throughput scheduler.
FfMacCschedSapProvider * GetFfMacCschedSapProvider() override
void DoSchedUlMacCtrlInfoReq(const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
Sched UL MAC control info request function.
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
Map of UE's DL CQI A30 received.
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
Estimate UL SNR function.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
DL HARQ process RLC PDU list buffer.
void SetFfMacSchedSapUser(FfMacSchedSapUser *s) override
set the user part of the FfMacSchedSap that this Scheduler will interact with.
static TypeId GetTypeId()
Get the type ID.
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
Update DL RLC buffer info function.
std::vector< RachListElement_s > m_rachList
RACH list.
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
UL HARQ process status.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
void RefreshUlCqiMaps()
Refresh UL CGI maps function.
~FdMtFfMacScheduler() override
Destructor.
void DoSchedUlNoiseInterferenceReq(const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
Sched UL noise interference request function.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmission mode configuration update.
std::map< uint16_t, uint32_t > m_a30CqiTimers
Map of UE's timers on DL CQI A30 received.
void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
Csched cell config request function.
unsigned int LcActivePerFlow(uint16_t rnti)
LC Active per flow function.
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
DL HARQ current process ID.
std::map< uint16_t, uint8_t > m_uesTxMode
txMode of the UEs
int GetRbgSize(int dlbandwidth)
Get RBG size function.
void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
CSched LC config request function.
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
UL HARQ process DCI buffer.
std::map< uint16_t, uint32_t > m_ceBsrRxed
Map of UE's buffer status reports received.
std::set< uint16_t > m_flowStatsUl
Set of UE statistics (per RNTI basis)
FfMacCschedSapProvider * m_cschedSapProvider
csched SAP provider
void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Sched DL RLC buffer request function.
void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
Sched DL trigger request function.
std::map< uint16_t, uint32_t > m_ueCqiTimers
Map of UEs' timers on UL-CQI per RBG.
void SetFfMacCschedSapUser(FfMacCschedSapUser *s) override
set the user part of the FfMacCschedSap that this Scheduler will interact with.
std::map< uint16_t, std::vector< double > > m_ueCqi
Map of UEs' UL-CQI per RBG.
void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
Sched UL CQI info request function.
FfMacSchedSapProvider * GetFfMacSchedSapProvider() override
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
DL HARQ process DCI buffer.
FfMacSchedSapProvider * m_schedSapProvider
sched SAP provider
std::map< uint16_t, uint8_t > m_p10CqiRxed
Map of UE's DL CQI P01 received.
void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
Sched UL SR info request function.
void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
Sched DL CQI info request function.
std::set< uint16_t > m_flowStatsDl
Set of UE statistics (per RNTI basis) in downlink.
std::map< uint16_t, uint32_t > m_p10CqiTimers
Map of UE's timers on DL CQI P01 received.
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
DL HARQ process status.
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
sched cell config
void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
CSched UE release request function.
std::vector< uint16_t > m_rachAllocationMap
RACH allocation map.
void DoDispose() override
Destructor implementation.
uint8_t m_ulGrantMcs
MCS for UL grant (default 0)
bool m_harqOn
m_harqOn when false inhibit tte HARQ mechanisms (by default active)
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
UL HARQ current process ID.
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
Map of previous allocated UE per RBG (used to retrieve info from UL-CQI)
friend class MemberSchedSapProvider< FdMtFfMacScheduler >
allow MemberSchedSapProvider<FdMtFfMacScheduler> clss friend access
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
HARQ retx buffered.
FfMacSchedSapUser * m_schedSapUser
sched SAP user
FfMacCschedSapUser * m_cschedSapUser
csched SAP user
void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
CSched UE config request function.
void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
Sched DL RACH info request function.
bool HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
void SetLteFfrSapProvider(LteFfrSapProvider *s) override
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
Sched DL MAC buffer request function.
void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
Sched UL trigger request function.
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
DL HARDQ process timer.
uint16_t m_nextRntiUl
RNTI of the next user to be served next scheduling in UL.
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
Vectors of UE's LC info.
LteFfrSapUser * GetLteFfrSapUser() override
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
Update UL RLC buffer info function.
void DoSchedDlPagingBufferReq(const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
Sched DL paging buffer request function.
void RefreshDlCqiMaps()
Refresh DL CGI maps function.
void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
CSched LC release request function.
friend class MemberCschedSapProvider< FdMtFfMacScheduler >
allow MemberCschedSapProvider<FdMtFfMacScheduler> class friend access
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
Provides the CSCHED SAP.
FfMacCschedSapUser class.
virtual void CschedUeConfigCnf(const CschedUeConfigCnfParameters &params)=0
CSCHED_UE_CONFIG_CNF.
virtual void CschedUeConfigUpdateInd(const CschedUeConfigUpdateIndParameters &params)=0
CSCHED_UE_UPDATE_IND.
Provides the SCHED SAP.
FfMacSchedSapUser class.
virtual void SchedUlConfigInd(const SchedUlConfigIndParameters &params)=0
SCHED_UL_CONFIG_IND.
virtual void SchedDlConfigInd(const SchedDlConfigIndParameters &params)=0
SCHED_DL_CONFIG_IND.
This abstract base class identifies the interface by means of which the helper object can plug on the...
UlCqiFilter_t m_ulCqiFilter
UL CQI filter.
static double fpS11dot3toDouble(uint16_t val)
Convert from fixed point S11.3 notation to double.
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Definition lte-ffr-sap.h:29
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Smart pointer class similar to boost::intrusive_ptr.
static uint8_t TxMode2LayerNum(uint8_t txMode)
Transmit mode 2 layer number.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
#define HARQ_PERIOD
Definition lte-common.h:19
#define SRS_CQI_RNTI_VSP
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
std::vector< uint8_t > DlHarqProcessesTimer_t
DL HARQ process timer vector.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
constexpr double NO_SINR
Value for SINR outside the range defined by FF-API, used to indicate that there is no CQI for this el...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
std::vector< uint8_t > UlHarqProcessesStatus_t
UL HARQ process status vector.
std::vector< uint8_t > DlHarqProcessesStatus_t
DL HARQ process status vector.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
DL HARQ process DCI buffer vector.
@ SUCCESS
constexpr uint32_t HARQ_DL_TIMEOUT
HARQ DL timeout.
static const int FdMtType0AllocationRbg[4]
FdMtType0AllocationRbg size array.
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.
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.