A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tta-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("TtaFfMacScheduler");
28
29/// TTA type 0 allocation RBG (see table 7.1.6.1-1 of 36.213)
30static const int TtaType0AllocationRbg[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(TtaFfMacScheduler);
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::TtaFfMacScheduler")
75 .SetGroupName("Lte")
76 .AddConstructor<TtaFfMacScheduler>()
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 < TtaType0AllocationRbg[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 itSbCqi = m_a30CqiRxed.find(*it);
868 auto itWbCqi = m_p10CqiRxed.find(*it);
869
870 auto itTxMode = m_uesTxMode.find(*it);
871 if (itTxMode == m_uesTxMode.end())
872 {
873 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it));
874 }
875 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
876
877 std::vector<uint8_t> sbCqi;
878 if (itSbCqi == m_a30CqiRxed.end())
879 {
880 sbCqi = std::vector<uint8_t>(nLayer, 1); // start with lowest value
881 }
882 else
883 {
884 sbCqi = (*itSbCqi).second.m_higherLayerSelected.at(i).m_sbCqi;
885 }
886
887 uint8_t wbCqi = 0;
888 if (itWbCqi != m_p10CqiRxed.end())
889 {
890 wbCqi = (*itWbCqi).second;
891 }
892 else
893 {
894 wbCqi = 1; // lowest value for trying a transmission
895 }
896
897 uint8_t cqi1 = sbCqi.at(0);
898 uint8_t cqi2 = 0;
899 if (sbCqi.size() > 1)
900 {
901 cqi2 = sbCqi.at(1);
902 }
903 if ((cqi1 > 0) ||
904 (cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
905 {
906 if (LcActivePerFlow(*it) > 0)
907 {
908 // this UE has data to transmit
909 double achievableSbRate = 0.0;
910 double achievableWbRate = 0.0;
911 uint8_t sbMcs = 0;
912 uint8_t wbMcs = 0;
913 for (uint8_t k = 0; k < nLayer; k++)
914 {
915 if (sbCqi.size() > k)
916 {
917 sbMcs = m_amc->GetMcsFromCqi(sbCqi.at(k));
918 }
919 else
920 {
921 // no info on this subband -> worst MCS
922 sbMcs = 0;
923 }
924 achievableSbRate += ((m_amc->GetDlTbSizeFromMcs(sbMcs, rbgSize) / 8) /
925 0.001); // = TB size / TTI
926 wbMcs = m_amc->GetMcsFromCqi(wbCqi);
927 achievableWbRate += ((m_amc->GetDlTbSizeFromMcs(wbMcs, rbgSize) / 8) /
928 0.001); // = TB size / TTI
929 }
930
931 double metric = achievableSbRate / achievableWbRate;
932
933 if (metric > rcqiMax)
934 {
935 rcqiMax = metric;
936 itMax = it;
937 }
938 }
939 }
940 }
941
942 if (itMax == m_flowStatsDl.end())
943 {
944 // no UE available for this RB
945 NS_LOG_INFO(this << " any UE found");
946 }
947 else
948 {
949 rbgMap.at(i) = true;
950 auto itMap = allocationMap.find(*itMax);
951 if (itMap == allocationMap.end())
952 {
953 // insert new element
954 std::vector<uint16_t> tempMap;
955 tempMap.push_back(i);
956 allocationMap[(*itMax)] = tempMap;
957 }
958 else
959 {
960 (*itMap).second.push_back(i);
961 }
962 NS_LOG_INFO(this << " UE assigned " << (*itMax));
963 }
964 }
965 }
966
967 // generate the transmission opportunities by grouping the RBGs of the same RNTI and
968 // creating the correspondent DCIs
969 auto itMap = allocationMap.begin();
970 while (itMap != allocationMap.end())
971 {
972 // create new BuildDataListElement_s for this LC
974 newEl.m_rnti = (*itMap).first;
975 // create the DlDciListElement_s
976 DlDciListElement_s newDci;
977 newDci.m_rnti = (*itMap).first;
978 newDci.m_harqProcess = UpdateHarqProcessId((*itMap).first);
979
980 uint16_t lcActives = LcActivePerFlow((*itMap).first);
981 NS_LOG_INFO(this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
982 if (lcActives == 0)
983 {
984 // Set to max value, to avoid divide by 0 below
985 lcActives = (uint16_t)65535; // UINT16_MAX;
986 }
987 uint16_t RbgPerRnti = (*itMap).second.size();
988 auto itCqi = m_a30CqiRxed.find((*itMap).first);
989 auto itTxMode = m_uesTxMode.find((*itMap).first);
990 if (itTxMode == m_uesTxMode.end())
991 {
992 NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first);
993 }
994 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
995 std::vector<uint8_t> worstCqi(2, 15);
996 if (itCqi != m_a30CqiRxed.end())
997 {
998 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
999 {
1000 if ((*itCqi).second.m_higherLayerSelected.size() > (*itMap).second.at(k))
1001 {
1002 NS_LOG_INFO(this << " RBG " << (*itMap).second.at(k) << " CQI "
1003 << (uint16_t)((*itCqi)
1004 .second.m_higherLayerSelected
1005 .at((*itMap).second.at(k))
1006 .m_sbCqi.at(0)));
1007 for (uint8_t j = 0; j < nLayer; j++)
1008 {
1009 if ((*itCqi)
1010 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1011 .m_sbCqi.size() > j)
1012 {
1013 if (((*itCqi)
1014 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1015 .m_sbCqi.at(j)) < worstCqi.at(j))
1016 {
1017 worstCqi.at(j) =
1018 ((*itCqi)
1019 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1020 .m_sbCqi.at(j));
1021 }
1022 }
1023 else
1024 {
1025 // no CQI for this layer of this suband -> worst one
1026 worstCqi.at(j) = 1;
1027 }
1028 }
1029 }
1030 else
1031 {
1032 for (uint8_t j = 0; j < nLayer; j++)
1033 {
1034 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1035 }
1036 }
1037 }
1038 }
1039 else
1040 {
1041 for (uint8_t j = 0; j < nLayer; j++)
1042 {
1043 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1044 }
1045 }
1046 for (uint8_t j = 0; j < nLayer; j++)
1047 {
1048 NS_LOG_INFO(this << " Layer " << (uint16_t)j << " CQI selected "
1049 << (uint16_t)worstCqi.at(j));
1050 }
1051 for (uint8_t j = 0; j < nLayer; j++)
1052 {
1053 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi(worstCqi.at(j)));
1054 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(j), RbgPerRnti * rbgSize) /
1055 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
1056 newDci.m_tbsSize.push_back(tbSize);
1057 NS_LOG_INFO(this << " Layer " << (uint16_t)j << " MCS selected"
1058 << m_amc->GetMcsFromCqi(worstCqi.at(j)));
1059 }
1060
1061 newDci.m_resAlloc = 0; // only allocation type 0 at this stage
1062 newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
1063 uint32_t rbgMask = 0;
1064 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1065 {
1066 rbgMask = rbgMask + (0x1 << (*itMap).second.at(k));
1067 NS_LOG_INFO(this << " Allocated RBG " << (*itMap).second.at(k));
1068 }
1069 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1070
1071 // create the rlc PDUs -> equally divide resources among actives LCs
1072 for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++)
1073 {
1074 if (((*itBufReq).first.m_rnti == (*itMap).first) &&
1075 (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) ||
1076 ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) ||
1077 ((*itBufReq).second.m_rlcStatusPduSize > 0)))
1078 {
1079 std::vector<RlcPduListElement_s> newRlcPduLe;
1080 for (uint8_t j = 0; j < nLayer; j++)
1081 {
1082 RlcPduListElement_s newRlcEl;
1083 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1084 newRlcEl.m_size = newDci.m_tbsSize.at(j) / lcActives;
1085 NS_LOG_INFO(this << " LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
1086 << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
1087 newRlcPduLe.push_back(newRlcEl);
1089 newRlcEl.m_logicalChannelIdentity,
1090 newRlcEl.m_size);
1091 if (m_harqOn)
1092 {
1093 // store RLC PDU list for HARQ
1094 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first);
1095 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1096 {
1097 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1098 << (*itMap).first);
1099 }
1100 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1101 }
1102 }
1103 newEl.m_rlcPduList.push_back(newRlcPduLe);
1104 }
1105 if ((*itBufReq).first.m_rnti > (*itMap).first)
1106 {
1107 break;
1108 }
1109 }
1110 for (uint8_t j = 0; j < nLayer; j++)
1111 {
1112 newDci.m_ndi.push_back(1);
1113 newDci.m_rv.push_back(0);
1114 }
1115
1116 newDci.m_tpc = 1; // 1 is mapped to 0 in Accumulated Mode and to -1 in Absolute Mode
1117
1118 newEl.m_dci = newDci;
1119
1120 if (m_harqOn)
1121 {
1122 // store DCI for HARQ
1123 auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti);
1124 if (itDci == m_dlHarqProcessesDciBuffer.end())
1125 {
1126 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1127 << newEl.m_rnti);
1128 }
1129 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1130 // refresh timer
1131 auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti);
1132 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1133 {
1134 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1135 }
1136 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1137 }
1138
1139 // ...more parameters -> ignored in this version
1140
1141 ret.m_buildDataList.push_back(newEl);
1142
1143 itMap++;
1144 }
1145 ret.m_nrOfPdcchOfdmSymbols = 1; /// \todo check correct value according the DCIs txed
1146
1148}
1149
1150void
1153{
1154 NS_LOG_FUNCTION(this);
1155
1156 m_rachList = params.m_rachList;
1157}
1158
1159void
1162{
1163 NS_LOG_FUNCTION(this);
1164
1165 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1166 {
1167 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1168 {
1169 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1170 << " reported");
1171 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1172 auto it = m_p10CqiRxed.find(rnti);
1173 if (it == m_p10CqiRxed.end())
1174 {
1175 // create the new entry
1176 m_p10CqiRxed[rnti] =
1177 params.m_cqiList.at(i).m_wbCqi.at(0); // only codeword 0 at this stage (SISO)
1178 // generate correspondent timer
1180 }
1181 else
1182 {
1183 // update the CQI value and refresh correspondent timer
1184 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1185 // update correspondent timer
1186 auto itTimers = m_p10CqiTimers.find(rnti);
1187 (*itTimers).second = m_cqiTimersThreshold;
1188 }
1189 }
1190 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1191 {
1192 // subband CQI reporting high layer configured
1193 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1194 auto it = m_a30CqiRxed.find(rnti);
1195 if (it == m_a30CqiRxed.end())
1196 {
1197 // create the new entry
1198 m_a30CqiRxed[rnti] = params.m_cqiList.at(i).m_sbMeasResult;
1200 }
1201 else
1202 {
1203 // update the CQI value and refresh correspondent timer
1204 (*it).second = params.m_cqiList.at(i).m_sbMeasResult;
1205 auto itTimers = m_a30CqiTimers.find(rnti);
1206 (*itTimers).second = m_cqiTimersThreshold;
1207 }
1208 }
1209 else
1210 {
1211 NS_LOG_ERROR(this << " CQI type unknown");
1212 }
1213 }
1214}
1215
1216double
1217TtaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb)
1218{
1219 auto itCqi = m_ueCqi.find(rnti);
1220 if (itCqi == m_ueCqi.end())
1221 {
1222 // no cqi info about this UE
1223 return NO_SINR;
1224 }
1225 else
1226 {
1227 // take the average SINR value among the available
1228 double sinrSum = 0;
1229 unsigned int sinrNum = 0;
1230 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1231 {
1232 double sinr = (*itCqi).second.at(i);
1233 if (sinr != NO_SINR)
1234 {
1235 sinrSum += sinr;
1236 sinrNum++;
1237 }
1238 }
1239 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1240 // store the value
1241 (*itCqi).second.at(rb) = estimatedSinr;
1242 return estimatedSinr;
1243 }
1244}
1245
1246void
1249{
1250 NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
1251 << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size());
1252
1254
1255 // Generate RBs map
1257 std::vector<bool> rbMap;
1258 std::set<uint16_t> rntiAllocated;
1259 std::vector<uint16_t> rbgAllocationMap;
1260 // update with RACH allocation map
1261 rbgAllocationMap = m_rachAllocationMap;
1262 // rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1263 m_rachAllocationMap.clear();
1265
1266 rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
1267 // remove RACH allocation
1268 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1269 {
1270 if (rbgAllocationMap.at(i) != 0)
1271 {
1272 rbMap.at(i) = true;
1273 NS_LOG_DEBUG(this << " Allocated for RACH " << i);
1274 }
1275 }
1276
1277 if (m_harqOn)
1278 {
1279 // Process UL HARQ feedback
1280 for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++)
1281 {
1282 if (params.m_ulInfoList.at(i).m_receptionStatus == UlInfoListElement_s::NotOk)
1283 {
1284 // retx correspondent block: retrieve the UL-DCI
1285 uint16_t rnti = params.m_ulInfoList.at(i).m_rnti;
1286 auto itProcId = m_ulHarqCurrentProcessId.find(rnti);
1287 if (itProcId == m_ulHarqCurrentProcessId.end())
1288 {
1289 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1290 }
1291 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1292 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId
1293 << " i " << i << " size " << params.m_ulInfoList.size());
1294 auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti);
1295 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1296 {
1297 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1298 continue;
1299 }
1300 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1301 auto itStat = m_ulHarqProcessesStatus.find(rnti);
1302 if (itStat == m_ulHarqProcessesStatus.end())
1303 {
1304 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1305 }
1306 if ((*itStat).second.at(harqId) >= 3)
1307 {
1308 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1309 continue;
1310 }
1311 bool free = true;
1312 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1313 {
1314 if (rbMap.at(j))
1315 {
1316 free = false;
1317 NS_LOG_INFO(this << " BUSY " << j);
1318 }
1319 }
1320 if (free)
1321 {
1322 // retx on the same RBs
1323 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1324 {
1325 rbMap.at(j) = true;
1326 rbgAllocationMap.at(j) = dci.m_rnti;
1327 NS_LOG_INFO("\tRB " << j);
1328 }
1329 NS_LOG_INFO(this << " Send retx in the same RBs " << (uint16_t)dci.m_rbStart
1330 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1331 << (*itStat).second.at(harqId) + 1);
1332 }
1333 else
1334 {
1335 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1336 continue;
1337 }
1338 dci.m_ndi = 0;
1339 // Update HARQ buffers with new HarqId
1340 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1341 (*itStat).second.at(harqId) = 0;
1342 (*itHarq).second.at((*itProcId).second) = dci;
1343 ret.m_dciList.push_back(dci);
1344 rntiAllocated.insert(dci.m_rnti);
1345 }
1346 else
1347 {
1348 NS_LOG_INFO(this << " HARQ-ACK feedback from RNTI "
1349 << params.m_ulInfoList.at(i).m_rnti);
1350 }
1351 }
1352 }
1353
1354 std::map<uint16_t, uint32_t>::iterator it;
1355 int nflows = 0;
1356
1357 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1358 {
1359 auto itRnti = rntiAllocated.find((*it).first);
1360 // select UEs with queues not empty and not yet allocated for HARQ
1361 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1362 {
1363 nflows++;
1364 }
1365 }
1366
1367 if (nflows == 0)
1368 {
1369 if (!ret.m_dciList.empty())
1370 {
1371 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1373 }
1374
1375 return; // no flows to be scheduled
1376 }
1377
1378 // Divide the remaining resources equally among the active users starting from the subsequent
1379 // one served last scheduling trigger
1380 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size());
1381 if (rbPerFlow < 3)
1382 {
1383 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1384 // >= 7 bytes
1385 }
1386 int rbAllocated = 0;
1387
1388 if (m_nextRntiUl != 0)
1389 {
1390 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1391 {
1392 if ((*it).first == m_nextRntiUl)
1393 {
1394 break;
1395 }
1396 }
1397 if (it == m_ceBsrRxed.end())
1398 {
1399 NS_LOG_ERROR(this << " no user found");
1400 }
1401 }
1402 else
1403 {
1404 it = m_ceBsrRxed.begin();
1405 m_nextRntiUl = (*it).first;
1406 }
1407 do
1408 {
1409 auto itRnti = rntiAllocated.find((*it).first);
1410 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1411 {
1412 // UE already allocated for UL-HARQ -> skip it
1413 NS_LOG_DEBUG(this << " UE already allocated in HARQ -> discarded, RNTI "
1414 << (*it).first);
1415 it++;
1416 if (it == m_ceBsrRxed.end())
1417 {
1418 // restart from the first
1419 it = m_ceBsrRxed.begin();
1420 }
1421 continue;
1422 }
1423 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1424 {
1425 // limit to physical resources last resource assignment
1426 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1427 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1428 if (rbPerFlow < 3)
1429 {
1430 // terminate allocation
1431 rbPerFlow = 0;
1432 }
1433 }
1434
1435 UlDciListElement_s uldci;
1436 uldci.m_rnti = (*it).first;
1437 uldci.m_rbLen = rbPerFlow;
1438 bool allocated = false;
1439 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1440 << " flows " << nflows);
1441 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1442 (rbPerFlow != 0))
1443 {
1444 // check availability
1445 bool free = true;
1446 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1447 {
1448 if (rbMap.at(j))
1449 {
1450 free = false;
1451 break;
1452 }
1453 }
1454 if (free)
1455 {
1456 uldci.m_rbStart = rbAllocated;
1457
1458 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1459 {
1460 rbMap.at(j) = true;
1461 // store info on allocation for managing ul-cqi interpretation
1462 rbgAllocationMap.at(j) = (*it).first;
1463 }
1464 rbAllocated += rbPerFlow;
1465 allocated = true;
1466 break;
1467 }
1468 rbAllocated++;
1469 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1470 {
1471 // limit to physical resources last resource assignment
1472 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1473 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1474 if (rbPerFlow < 3)
1475 {
1476 // terminate allocation
1477 rbPerFlow = 0;
1478 }
1479 }
1480 }
1481 if (!allocated)
1482 {
1483 // unable to allocate new resource: finish scheduling
1484 m_nextRntiUl = (*it).first;
1485 if (!ret.m_dciList.empty())
1486 {
1488 }
1489 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1490 return;
1491 }
1492
1493 auto itCqi = m_ueCqi.find((*it).first);
1494 int cqi = 0;
1495 if (itCqi == m_ueCqi.end())
1496 {
1497 // no cqi info about this UE
1498 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1499 }
1500 else
1501 {
1502 // take the lowest CQI value (worst RB)
1503 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1504 "CQI of RNTI = " << (*it).first << " has expired");
1505 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1506 if (minSinr == NO_SINR)
1507 {
1508 minSinr = EstimateUlSinr((*it).first, uldci.m_rbStart);
1509 }
1510 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1511 {
1512 double sinr = (*itCqi).second.at(i);
1513 if (sinr == NO_SINR)
1514 {
1515 sinr = EstimateUlSinr((*it).first, i);
1516 }
1517 if (sinr < minSinr)
1518 {
1519 minSinr = sinr;
1520 }
1521 }
1522
1523 // translate SINR -> cqi: WILD ACK: same as DL
1524 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1525 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1526 if (cqi == 0)
1527 {
1528 it++;
1529 if (it == m_ceBsrRxed.end())
1530 {
1531 // restart from the first
1532 it = m_ceBsrRxed.begin();
1533 }
1534 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1535 // remove UE from allocation map
1536 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1537 {
1538 rbgAllocationMap.at(i) = 0;
1539 }
1540 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1541 }
1542 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1543 }
1544
1545 uldci.m_tbSize = (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8);
1547 uldci.m_ndi = 1;
1548 uldci.m_cceIndex = 0;
1549 uldci.m_aggrLevel = 1;
1550 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1551 uldci.m_hopping = false;
1552 uldci.m_n2Dmrs = 0;
1553 uldci.m_tpc = 0; // no power control
1554 uldci.m_cqiRequest = false; // only period CQI at this stage
1555 uldci.m_ulIndex = 0; // TDD parameter
1556 uldci.m_dai = 1; // TDD parameter
1557 uldci.m_freqHopping = 0;
1558 uldci.m_pdcchPowerOffset = 0; // not used
1559 ret.m_dciList.push_back(uldci);
1560 // store DCI for HARQ_PERIOD
1561 uint8_t harqId = 0;
1562 if (m_harqOn)
1563 {
1564 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1565 if (itProcId == m_ulHarqCurrentProcessId.end())
1566 {
1567 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
1568 }
1569 harqId = (*itProcId).second;
1570 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
1571 if (itDci == m_ulHarqProcessesDciBuffer.end())
1572 {
1573 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
1574 << uldci.m_rnti);
1575 }
1576 (*itDci).second.at(harqId) = uldci;
1577 // Update HARQ process status (RV 0)
1578 auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti);
1579 if (itStat == m_ulHarqProcessesStatus.end())
1580 {
1581 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
1582 << uldci.m_rnti);
1583 }
1584 (*itStat).second.at(harqId) = 0;
1585 }
1586
1587 NS_LOG_INFO(this << " UE Allocation RNTI " << (*it).first << " startPRB "
1588 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
1589 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
1590 << uldci.m_tbSize << " RbAlloc " << rbAllocated << " harqId "
1591 << (uint16_t)harqId);
1592
1593 it++;
1594 if (it == m_ceBsrRxed.end())
1595 {
1596 // restart from the first
1597 it = m_ceBsrRxed.begin();
1598 }
1599 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1600 {
1601 // Stop allocation: no more PRBs
1602 m_nextRntiUl = (*it).first;
1603 break;
1604 }
1605 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
1606
1607 m_allocationMaps[params.m_sfnSf] = rbgAllocationMap;
1609}
1610
1611void
1617
1618void
1624
1625void
1628{
1629 NS_LOG_FUNCTION(this);
1630
1631 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
1632 {
1633 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
1634 {
1635 // buffer status report
1636 // note that this scheduler does not differentiate the
1637 // allocation according to which LCGs have more/less bytes
1638 // to send.
1639 // Hence the BSR of different LCGs are just summed up to get
1640 // a total queue size that is used for allocation purposes.
1641
1642 uint32_t buffer = 0;
1643 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1644 {
1645 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
1646 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
1647 }
1648
1649 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
1650 NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer);
1651 auto it = m_ceBsrRxed.find(rnti);
1652 if (it == m_ceBsrRxed.end())
1653 {
1654 // create the new entry
1655 m_ceBsrRxed[rnti] = buffer;
1656 }
1657 else
1658 {
1659 // update the buffer size value
1660 (*it).second = buffer;
1661 }
1662 }
1663 }
1664}
1665
1666void
1669{
1670 NS_LOG_FUNCTION(this);
1671 // retrieve the allocation for this subframe
1672 switch (m_ulCqiFilter)
1673 {
1675 // filter all the CQIs that are not SRS based
1676 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1677 {
1678 return;
1679 }
1680 }
1681 break;
1683 // filter all the CQIs that are not SRS based
1684 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1685 {
1686 return;
1687 }
1688 }
1689 break;
1690 default:
1691 NS_FATAL_ERROR("Unknown UL CQI type");
1692 }
1693
1694 switch (params.m_ulCqi.m_type)
1695 {
1696 case UlCqi_s::PUSCH: {
1697 NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4)
1698 << " subframe no. " << (0xF & params.m_sfnSf));
1699 auto itMap = m_allocationMaps.find(params.m_sfnSf);
1700 if (itMap == m_allocationMaps.end())
1701 {
1702 return;
1703 }
1704 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
1705 {
1706 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1707 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
1708 auto itCqi = m_ueCqi.find((*itMap).second.at(i));
1709 if (itCqi == m_ueCqi.end())
1710 {
1711 // create a new entry
1712 std::vector<double> newCqi;
1713 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1714 {
1715 if (i == j)
1716 {
1717 newCqi.push_back(sinr);
1718 }
1719 else
1720 {
1721 // initialize with NO_SINR value.
1722 newCqi.push_back(NO_SINR);
1723 }
1724 }
1725 m_ueCqi[(*itMap).second.at(i)] = newCqi;
1726 // generate correspondent timer
1727 m_ueCqiTimers[(*itMap).second.at(i)] = m_cqiTimersThreshold;
1728 }
1729 else
1730 {
1731 // update the value
1732 (*itCqi).second.at(i) = sinr;
1733 // NS_LOG_DEBUG (this << " RNTI " << (*itMap).second.at (i) << " RB " << i << " SINR
1734 // " << sinr);
1735 // update correspondent timer
1736 auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
1737 (*itTimers).second = m_cqiTimersThreshold;
1738 }
1739 }
1740 // remove obsolete info on allocation
1741 m_allocationMaps.erase(itMap);
1742 }
1743 break;
1744 case UlCqi_s::SRS: {
1745 // get the RNTI from vendor specific parameters
1746 uint16_t rnti = 0;
1747 NS_ASSERT(!params.m_vendorSpecificList.empty());
1748 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
1749 {
1750 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
1751 {
1752 Ptr<SrsCqiRntiVsp> vsp =
1753 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
1754 rnti = vsp->GetRnti();
1755 }
1756 }
1757 auto itCqi = m_ueCqi.find(rnti);
1758 if (itCqi == m_ueCqi.end())
1759 {
1760 // create a new entry
1761 std::vector<double> newCqi;
1762 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1763 {
1764 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1765 newCqi.push_back(sinr);
1766 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
1767 << sinr);
1768 }
1769 m_ueCqi[rnti] = newCqi;
1770 // generate correspondent timer
1772 }
1773 else
1774 {
1775 // update the values
1776 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1777 {
1778 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1779 (*itCqi).second.at(j) = sinr;
1780 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
1781 << sinr);
1782 }
1783 // update correspondent timer
1784 auto itTimers = m_ueCqiTimers.find(rnti);
1785 (*itTimers).second = m_cqiTimersThreshold;
1786 }
1787 }
1788 break;
1789 case UlCqi_s::PUCCH_1:
1790 case UlCqi_s::PUCCH_2:
1791 case UlCqi_s::PRACH: {
1792 NS_FATAL_ERROR("TtaFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1793 }
1794 break;
1795 default:
1796 NS_FATAL_ERROR("Unknown type of UL-CQI");
1797 }
1798}
1799
1800void
1802{
1803 // refresh DL CQI P01 Map
1804 auto itP10 = m_p10CqiTimers.begin();
1805 while (itP10 != m_p10CqiTimers.end())
1806 {
1807 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
1808 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1809 if ((*itP10).second == 0)
1810 {
1811 // delete correspondent entries
1812 auto itMap = m_p10CqiRxed.find((*itP10).first);
1813 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
1814 " Does not find CQI report for user " << (*itP10).first);
1815 NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first);
1816 m_p10CqiRxed.erase(itMap);
1817 auto temp = itP10;
1818 itP10++;
1819 m_p10CqiTimers.erase(temp);
1820 }
1821 else
1822 {
1823 (*itP10).second--;
1824 itP10++;
1825 }
1826 }
1827
1828 // refresh DL CQI A30 Map
1829 auto itA30 = m_a30CqiTimers.begin();
1830 while (itA30 != m_a30CqiTimers.end())
1831 {
1832 NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is "
1833 << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1834 if ((*itA30).second == 0)
1835 {
1836 // delete correspondent entries
1837 auto itMap = m_a30CqiRxed.find((*itA30).first);
1838 NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(),
1839 " Does not find CQI report for user " << (*itA30).first);
1840 NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first);
1841 m_a30CqiRxed.erase(itMap);
1842 auto temp = itA30;
1843 itA30++;
1844 m_a30CqiTimers.erase(temp);
1845 }
1846 else
1847 {
1848 (*itA30).second--;
1849 itA30++;
1850 }
1851 }
1852}
1853
1854void
1856{
1857 // refresh UL CQI Map
1858 auto itUl = m_ueCqiTimers.begin();
1859 while (itUl != m_ueCqiTimers.end())
1860 {
1861 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
1862 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1863 if ((*itUl).second == 0)
1864 {
1865 // delete correspondent entries
1866 auto itMap = m_ueCqi.find((*itUl).first);
1867 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
1868 " Does not find CQI report for user " << (*itUl).first);
1869 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
1870 (*itMap).second.clear();
1871 m_ueCqi.erase(itMap);
1872 auto temp = itUl;
1873 itUl++;
1874 m_ueCqiTimers.erase(temp);
1875 }
1876 else
1877 {
1878 (*itUl).second--;
1879 itUl++;
1880 }
1881 }
1882}
1883
1884void
1885TtaFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
1886{
1887 LteFlowId_t flow(rnti, lcid);
1888 auto it = m_rlcBufferReq.find(flow);
1889 if (it != m_rlcBufferReq.end())
1890 {
1891 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
1892 << (*it).second.m_rlcTransmissionQueueSize << " retxqueue "
1893 << (*it).second.m_rlcRetransmissionQueueSize << " status "
1894 << (*it).second.m_rlcStatusPduSize << " decrease " << size);
1895 // Update queues: RLC tx order Status, ReTx, Tx
1896 // Update status queue
1897 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
1898 {
1899 (*it).second.m_rlcStatusPduSize = 0;
1900 }
1901 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) &&
1902 (size >= (*it).second.m_rlcRetransmissionQueueSize))
1903 {
1904 (*it).second.m_rlcRetransmissionQueueSize = 0;
1905 }
1906 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
1907 {
1908 uint32_t rlcOverhead;
1909 if (lcid == 1)
1910 {
1911 // for SRB1 (using RLC AM) it's better to
1912 // overestimate RLC overhead rather than
1913 // underestimate it and risk unneeded
1914 // segmentation which increases delay
1915 rlcOverhead = 4;
1916 }
1917 else
1918 {
1919 // minimum RLC overhead due to header
1920 rlcOverhead = 2;
1921 }
1922 // update transmission queue
1923 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
1924 {
1925 (*it).second.m_rlcTransmissionQueueSize = 0;
1926 }
1927 else
1928 {
1929 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
1930 }
1931 }
1932 }
1933 else
1934 {
1935 NS_LOG_ERROR(this << " Does not find DL RLC Buffer Report of UE " << rnti);
1936 }
1937}
1938
1939void
1940TtaFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
1941{
1942 size = size - 2; // remove the minimum RLC overhead
1943 auto it = m_ceBsrRxed.find(rnti);
1944 if (it != m_ceBsrRxed.end())
1945 {
1946 NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
1947 if ((*it).second >= size)
1948 {
1949 (*it).second -= size;
1950 }
1951 else
1952 {
1953 (*it).second = 0;
1954 }
1955 }
1956 else
1957 {
1958 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
1959 }
1960}
1961
1962void
1964{
1965 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
1967 params.m_rnti = rnti;
1968 params.m_transmissionMode = txMode;
1970}
1971
1972} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
static uint32_t BsrId2BufferSize(uint8_t val)
Convert BSR ID to buffer size.
Provides the CSCHED SAP.
FfMacCschedSapUser class.
virtual void CschedUeConfigCnf(const CschedUeConfigCnfParameters &params)=0
CSCHED_UE_CONFIG_CNF.
virtual void CschedUeConfigUpdateInd(const CschedUeConfigUpdateIndParameters &params)=0
CSCHED_UE_UPDATE_IND.
Provides the SCHED SAP.
FfMacSchedSapUser class.
virtual void SchedUlConfigInd(const SchedUlConfigIndParameters &params)=0
SCHED_UL_CONFIG_IND.
virtual void SchedDlConfigInd(const SchedDlConfigIndParameters &params)=0
SCHED_DL_CONFIG_IND.
This abstract base class identifies the interface by means of which the helper object can plug on the...
UlCqiFilter_t m_ulCqiFilter
UL CQI filter.
static double fpS11dot3toDouble(uint16_t val)
Convert from fixed point S11.3 notation to double.
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Definition lte-ffr-sap.h:29
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Smart pointer class similar to boost::intrusive_ptr.
static uint8_t TxMode2LayerNum(uint8_t txMode)
Transmit mode 2 layer number.
Implements the SCHED SAP and CSCHED SAP for a Throughput to Average scheduler.
std::map< uint16_t, uint8_t > m_p10CqiRxed
Map of UE's DL CQI P01 received.
std::map< uint16_t, uint32_t > m_a30CqiTimers
Map of UE's timers on DL CQI A30 received.
FfMacSchedSapUser * m_schedSapUser
Sched SAP user.
void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
Sched DL CQI info request function.
bool m_harqOn
m_harqOn when false inhibit the HARQ mechanisms (by default active)
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
Sched UL CQI info request function.
void SetLteFfrSapProvider(LteFfrSapProvider *s) override
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
std::map< uint16_t, std::vector< double > > m_ueCqi
Map of UEs' UL-CQI per RBG.
std::set< uint16_t > m_flowStatsDl
Set of UE statistics (per RNTI basis) in downlink.
void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
Sched DL RACH info request function.
void DoDispose() override
Destructor implementation.
uint16_t m_nextRntiUl
RNTI of the next user to be served next scheduling in UL.
void DoSchedDlPagingBufferReq(const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
Sched DL paging buffer request function.
int GetRbgSize(int dlbandwidth)
Get RBG size function.
void SetFfMacCschedSapUser(FfMacCschedSapUser *s) override
set the user part of the FfMacCschedSap that this Scheduler will interact with.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
Update DL RLC buffer info function.
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
HARQ retx buffered.
void RefreshDlCqiMaps()
Refresh DL CQI maps.
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 SINR function.
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
FfMacSchedSapProvider * GetFfMacSchedSapProvider() override
friend class MemberSchedSapProvider< TtaFfMacScheduler >
allow MemberSchedSapProvider<TtaFfMacScheduler> class friend access
void RefreshUlCqiMaps()
Refresh UL CQI maps.
static TypeId GetTypeId()
Get the type ID.
~TtaFfMacScheduler() override
Destructor.
std::map< uint16_t, uint8_t > m_uesTxMode
txMode of the UEs
void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
CSched LC release request function.
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 SetFfMacSchedSapUser(FfMacSchedSapUser *s) override
set the user part of the FfMacSchedSap that this Scheduler will interact with.
FfMacCschedSapProvider * m_cschedSapProvider
CSched SAP provider.
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
UL HARQ current process ID.
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
DL HARQ current process ID.
void DoSchedUlMacCtrlInfoReq(const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
Sched UL MAC control info request function.
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
UL HARQ process status.
void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
Sched UL trigger request function.
std::vector< uint16_t > m_rachAllocationMap
RACH allocation map.
LteFfrSapUser * GetLteFfrSapUser() override
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
DL HARQ process status.
void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
Sched DL trigger request function.
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
Sched UL SR info request function.
void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
CSched LC config request function.
FfMacCschedSapUser * m_cschedSapUser
CSched SAP user.
FfMacCschedSapProvider * GetFfMacCschedSapProvider() override
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
UL HARQ process DCI buffer.
std::map< uint16_t, uint32_t > m_p10CqiTimers
Map of UE's timers on DL CQI P01 received.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmission mode configuration update.
void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
Sched DL MAC buffer request function.
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
Update DL RLC buffer info function.
void DoSchedUlNoiseInterferenceReq(const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
Sched UL noise interference request function.
void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
CSched cell config request function.
bool HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
unsigned int LcActivePerFlow(uint16_t rnti)
LC active per flow function.
std::map< uint16_t, uint32_t > m_ueCqiTimers
Map of UEs' timers on UL-CQI per RBG.
void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Sched DL RLC buffer request function.
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
DL HARQ process timer.
std::map< uint16_t, uint32_t > m_ceBsrRxed
Map of UE's buffer status reports received.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
DL HARQ process RLC PDU list buffer.
void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
CSched UE release request function.
friend class MemberCschedSapProvider< TtaFfMacScheduler >
allow MemberCschedSapProvider<TtaFfMacScheduler> class friend access
FfMacSchedSapProvider * m_schedSapProvider
Sched SAP provider.
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
Vectors of UE's LC info.
std::set< uint16_t > m_flowStatsUl
Set of UE statistics (per RNTI basis)
std::vector< RachListElement_s > m_rachList
RACH list.
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
CSched cell config.
void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
CSched UE config request function.
uint8_t m_ulGrantMcs
MCS for UL grant (default 0)
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
DL HARQ process DCI buffer.
a unique identifier for an interface.
Definition type-id.h:49
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
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition boolean.h:70
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#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.
std::vector< uint8_t > DlHarqProcessesTimer_t
DL HARQ process timer vector.
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...
std::vector< uint8_t > UlHarqProcessesStatus_t
UL HARQ process status vector.
std::vector< uint8_t > DlHarqProcessesStatus_t
DL HARQ process status vector.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
DL HARQ process DCI buffer vector.
@ SUCCESS
constexpr uint32_t HARQ_DL_TIMEOUT
HARQ DL timeout.
constexpr uint32_t HARQ_PROC_NUM
Number of HARQ processes.
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
Vector of the 8 HARQ processes per UE.
static const int TtaType0AllocationRbg[4]
TTA type 0 allocation RBG (see table 7.1.6.1-1 of 36.213)
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.