A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fdtbfq-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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Marco Miozzo <marco.miozzo@cttc.es>
18 * Modification: Dizhi Zhou <dizhi.zhou@gmail.com> // modify codes related to downlink scheduler
19 */
20
22
23#include "lte-amc.h"
25
26#include <ns3/boolean.h>
27#include <ns3/integer.h>
28#include <ns3/log.h>
29#include <ns3/math.h>
30#include <ns3/pointer.h>
31#include <ns3/simulator.h>
32
33#include <cfloat>
34#include <set>
35
36namespace ns3
37{
38
39NS_LOG_COMPONENT_DEFINE("FdTbfqFfMacScheduler");
40
42static const int FdTbfqType0AllocationRbg[4] = {
43 10, // RGB size 1
44 26, // RGB size 2
45 63, // RGB size 3
46 110, // RGB size 4
47}; // see table 7.1.6.1-1 of 36.213
48
49NS_OBJECT_ENSURE_REGISTERED(FdTbfqFfMacScheduler);
50
52 : m_cschedSapUser(nullptr),
53 m_schedSapUser(nullptr),
54 m_nextRntiUl(0),
55 bankSize(0)
56{
57 m_amc = CreateObject<LteAmc>();
60 m_ffrSapProvider = nullptr;
62}
63
65{
66 NS_LOG_FUNCTION(this);
67}
68
69void
71{
72 NS_LOG_FUNCTION(this);
81 delete m_schedSapProvider;
82 delete m_ffrSapUser;
83}
84
87{
88 static TypeId tid =
89 TypeId("ns3::FdTbfqFfMacScheduler")
91 .SetGroupName("Lte")
92 .AddConstructor<FdTbfqFfMacScheduler>()
93 .AddAttribute("CqiTimerThreshold",
94 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
95 UintegerValue(1000),
97 MakeUintegerChecker<uint32_t>())
98 .AddAttribute("DebtLimit",
99 "Flow debt limit (default -625000 bytes)",
100 IntegerValue(-625000),
102 MakeIntegerChecker<int>())
103 .AddAttribute("CreditLimit",
104 "Flow credit limit (default 625000 bytes)",
105 UintegerValue(625000),
107 MakeUintegerChecker<uint32_t>())
108 .AddAttribute("TokenPoolSize",
109 "The maximum value of flow token pool (default 1 bytes)",
110 UintegerValue(1),
112 MakeUintegerChecker<uint32_t>())
113 .AddAttribute("CreditableThreshold",
114 "Threshold of flow credit (default 0 bytes)",
115 UintegerValue(0),
117 MakeUintegerChecker<uint32_t>())
118
119 .AddAttribute("HarqEnabled",
120 "Activate/Deactivate the HARQ [by default is active].",
121 BooleanValue(true),
124 .AddAttribute("UlGrantMcs",
125 "The MCS of the UL grant, must be [0..15] (default 0)",
126 UintegerValue(0),
128 MakeUintegerChecker<uint8_t>());
129 return tid;
130}
131
132void
134{
135 m_cschedSapUser = s;
136}
137
138void
140{
141 m_schedSapUser = s;
142}
143
146{
147 return m_cschedSapProvider;
148}
149
152{
153 return m_schedSapProvider;
154}
155
156void
158{
160}
161
164{
165 return m_ffrSapUser;
166}
167
168void
171{
172 NS_LOG_FUNCTION(this);
173 // Read the subset of parameters used
174 m_cschedCellConfig = params;
177 cnf.m_result = SUCCESS;
179}
180
181void
184{
185 NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode "
186 << (uint16_t)params.m_transmissionMode);
187 auto it = m_uesTxMode.find(params.m_rnti);
188 if (it == m_uesTxMode.end())
189 {
190 m_uesTxMode.insert(std::pair<uint16_t, double>(params.m_rnti, params.m_transmissionMode));
191 // generate HARQ buffers
192 m_dlHarqCurrentProcessId.insert(std::pair<uint16_t, uint8_t>(params.m_rnti, 0));
193 DlHarqProcessesStatus_t dlHarqPrcStatus;
194 dlHarqPrcStatus.resize(8, 0);
196 std::pair<uint16_t, DlHarqProcessesStatus_t>(params.m_rnti, dlHarqPrcStatus));
197 DlHarqProcessesTimer_t dlHarqProcessesTimer;
198 dlHarqProcessesTimer.resize(8, 0);
200 std::pair<uint16_t, DlHarqProcessesTimer_t>(params.m_rnti, dlHarqProcessesTimer));
202 dlHarqdci.resize(8);
204 std::pair<uint16_t, DlHarqProcessesDciBuffer_t>(params.m_rnti, dlHarqdci));
205 DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
206 dlHarqRlcPdu.resize(2);
207 dlHarqRlcPdu.at(0).resize(8);
208 dlHarqRlcPdu.at(1).resize(8);
210 std::pair<uint16_t, DlHarqRlcPduListBuffer_t>(params.m_rnti, dlHarqRlcPdu));
211 m_ulHarqCurrentProcessId.insert(std::pair<uint16_t, uint8_t>(params.m_rnti, 0));
212 UlHarqProcessesStatus_t ulHarqPrcStatus;
213 ulHarqPrcStatus.resize(8, 0);
215 std::pair<uint16_t, UlHarqProcessesStatus_t>(params.m_rnti, ulHarqPrcStatus));
217 ulHarqdci.resize(8);
219 std::pair<uint16_t, UlHarqProcessesDciBuffer_t>(params.m_rnti, ulHarqdci));
220 }
221 else
222 {
223 (*it).second = params.m_transmissionMode;
224 }
225}
226
227void
230{
231 NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti);
232
233 for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++)
234 {
235 auto it = m_flowStatsDl.find(params.m_rnti);
236
237 if (it == m_flowStatsDl.end())
238 {
239 uint64_t mbrDlInBytes =
240 params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl / 8; // byte/s
241 uint64_t mbrUlInBytes =
242 params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateUl / 8; // byte/s
243 NS_LOG_DEBUG("mbrDlInBytes: " << mbrDlInBytes << " mbrUlInBytes: " << mbrUlInBytes);
244
245 fdtbfqsFlowPerf_t flowStatsDl;
246 flowStatsDl.flowStart = Simulator::Now();
247 flowStatsDl.packetArrivalRate = 0;
248 flowStatsDl.tokenGenerationRate = mbrDlInBytes;
249 flowStatsDl.tokenPoolSize = 0;
250 flowStatsDl.maxTokenPoolSize = m_tokenPoolSize;
251 flowStatsDl.counter = 0;
252 flowStatsDl.burstCredit = m_creditLimit; // bytes
253 flowStatsDl.debtLimit = m_debtLimit; // bytes
255 m_flowStatsDl.insert(
256 std::pair<uint16_t, fdtbfqsFlowPerf_t>(params.m_rnti, flowStatsDl));
257 fdtbfqsFlowPerf_t flowStatsUl;
258 flowStatsUl.flowStart = Simulator::Now();
259 flowStatsUl.packetArrivalRate = 0;
260 flowStatsUl.tokenGenerationRate = mbrUlInBytes;
261 flowStatsUl.tokenPoolSize = 0;
262 flowStatsUl.maxTokenPoolSize = m_tokenPoolSize;
263 flowStatsUl.counter = 0;
264 flowStatsUl.burstCredit = m_creditLimit; // bytes
265 flowStatsUl.debtLimit = m_debtLimit; // bytes
267 m_flowStatsUl.insert(
268 std::pair<uint16_t, fdtbfqsFlowPerf_t>(params.m_rnti, flowStatsUl));
269 }
270 else
271 {
272 // update MBR and GBR from UeManager::SetupDataRadioBearer ()
273 uint64_t mbrDlInBytes =
274 params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl / 8; // byte/s
275 uint64_t mbrUlInBytes =
276 params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateUl / 8; // byte/s
277 NS_LOG_DEBUG("mbrDlInBytes: " << mbrDlInBytes << " mbrUlInBytes: " << mbrUlInBytes);
278 m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
279 m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
280 }
281 }
282}
283
284void
287{
288 NS_LOG_FUNCTION(this);
289 for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++)
290 {
291 auto it = m_rlcBufferReq.begin();
292 while (it != m_rlcBufferReq.end())
293 {
294 if (((*it).first.m_rnti == params.m_rnti) &&
295 ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i)))
296 {
297 auto temp = it;
298 it++;
299 m_rlcBufferReq.erase(temp);
300 }
301 else
302 {
303 it++;
304 }
305 }
306 }
307}
308
309void
312{
313 NS_LOG_FUNCTION(this);
314
315 m_uesTxMode.erase(params.m_rnti);
316 m_dlHarqCurrentProcessId.erase(params.m_rnti);
317 m_dlHarqProcessesStatus.erase(params.m_rnti);
318 m_dlHarqProcessesTimer.erase(params.m_rnti);
319 m_dlHarqProcessesDciBuffer.erase(params.m_rnti);
320 m_dlHarqProcessesRlcPduListBuffer.erase(params.m_rnti);
321 m_ulHarqCurrentProcessId.erase(params.m_rnti);
322 m_ulHarqProcessesStatus.erase(params.m_rnti);
323 m_ulHarqProcessesDciBuffer.erase(params.m_rnti);
324 m_flowStatsDl.erase(params.m_rnti);
325 m_flowStatsUl.erase(params.m_rnti);
326 m_ceBsrRxed.erase(params.m_rnti);
327 auto it = m_rlcBufferReq.begin();
328 while (it != m_rlcBufferReq.end())
329 {
330 if ((*it).first.m_rnti == params.m_rnti)
331 {
332 auto temp = it;
333 it++;
334 m_rlcBufferReq.erase(temp);
335 }
336 else
337 {
338 it++;
339 }
340 }
341 if (m_nextRntiUl == params.m_rnti)
342 {
343 m_nextRntiUl = 0;
344 }
345}
346
347void
350{
351 NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity);
352 // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
353
354 LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity);
355
356 auto it = m_rlcBufferReq.find(flow);
357
358 if (it == m_rlcBufferReq.end())
359 {
360 m_rlcBufferReq.insert(
361 std::pair<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>(flow,
362 params));
363 }
364 else
365 {
366 (*it).second = params;
367 }
368}
369
370void
373{
374 NS_LOG_FUNCTION(this);
375 NS_FATAL_ERROR("method not implemented");
376}
377
378void
381{
382 NS_LOG_FUNCTION(this);
383 NS_FATAL_ERROR("method not implemented");
384}
385
386int
388{
389 for (int i = 0; i < 4; i++)
390 {
391 if (dlbandwidth < FdTbfqType0AllocationRbg[i])
392 {
393 return (i + 1);
394 }
395 }
396
397 return (-1);
398}
399
400unsigned int
402{
403 unsigned int lcActive = 0;
404 for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
405 {
406 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) ||
407 ((*it).second.m_rlcRetransmissionQueueSize > 0) ||
408 ((*it).second.m_rlcStatusPduSize > 0)))
409 {
410 lcActive++;
411 }
412 if ((*it).first.m_rnti > rnti)
413 {
414 break;
415 }
416 }
417 return (lcActive);
418}
419
420bool
422{
423 NS_LOG_FUNCTION(this << rnti);
424
425 auto it = m_dlHarqCurrentProcessId.find(rnti);
426 if (it == m_dlHarqCurrentProcessId.end())
427 {
428 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
429 }
430 auto itStat = m_dlHarqProcessesStatus.find(rnti);
431 if (itStat == m_dlHarqProcessesStatus.end())
432 {
433 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
434 }
435 uint8_t i = (*it).second;
436 do
437 {
438 i = (i + 1) % HARQ_PROC_NUM;
439 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
440
441 return (*itStat).second.at(i) == 0;
442}
443
444uint8_t
446{
447 NS_LOG_FUNCTION(this << rnti);
448
449 if (!m_harqOn)
450 {
451 return (0);
452 }
453
454 auto it = m_dlHarqCurrentProcessId.find(rnti);
455 if (it == m_dlHarqCurrentProcessId.end())
456 {
457 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
458 }
459 auto itStat = m_dlHarqProcessesStatus.find(rnti);
460 if (itStat == m_dlHarqProcessesStatus.end())
461 {
462 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
463 }
464 uint8_t i = (*it).second;
465 do
466 {
467 i = (i + 1) % HARQ_PROC_NUM;
468 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
469 if ((*itStat).second.at(i) == 0)
470 {
471 (*it).second = i;
472 (*itStat).second.at(i) = 1;
473 }
474 else
475 {
476 NS_FATAL_ERROR("No HARQ process available for RNTI "
477 << rnti << " check before update with HarqProcessAvailability");
478 }
479
480 return ((*it).second);
481}
482
483void
485{
486 NS_LOG_FUNCTION(this);
487
488 for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end();
489 itTimers++)
490 {
491 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
492 {
493 if ((*itTimers).second.at(i) == HARQ_DL_TIMEOUT)
494 {
495 // reset HARQ process
496
497 NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first);
498 auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first);
499 if (itStat == m_dlHarqProcessesStatus.end())
500 {
501 NS_FATAL_ERROR("No Process Id Status found for this RNTI "
502 << (*itTimers).first);
503 }
504 (*itStat).second.at(i) = 0;
505 (*itTimers).second.at(i) = 0;
506 }
507 else
508 {
509 (*itTimers).second.at(i)++;
510 }
511 }
512 }
513}
514
515void
518{
519 NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
520 << (0xF & params.m_sfnSf));
521 // API generated by RLC for triggering the scheduling of a DL subframe
522
523 // evaluate the relative channel quality indicator for each UE per each RBG
524 // (since we are using allocation type 0 the small unit of allocation is RBG)
525 // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
526
528
530 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
531 std::map<uint16_t, std::vector<uint16_t>> allocationMap; // RBs map per RNTI
532 std::vector<bool> rbgMap; // global RBGs map
533 uint16_t rbgAllocatedNum = 0;
534 std::set<uint16_t> rntiAllocated;
535 rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false);
536
538 for (auto it = rbgMap.begin(); it != rbgMap.end(); it++)
539 {
540 if (*it)
541 {
542 rbgAllocatedNum++;
543 }
544 }
545
547
548 // update UL HARQ proc id
549 for (auto itProcId = m_ulHarqCurrentProcessId.begin();
550 itProcId != m_ulHarqCurrentProcessId.end();
551 itProcId++)
552 {
553 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
554 }
555
556 // RACH Allocation
557 std::vector<bool> ulRbMap;
558 ulRbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
560 uint8_t maxContinuousUlBandwidth = 0;
561 uint8_t tmpMinBandwidth = 0;
562 uint16_t ffrRbStartOffset = 0;
563 uint16_t tmpFfrRbStartOffset = 0;
564 uint16_t index = 0;
565
566 for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++)
567 {
568 if (*it)
569 {
570 if (tmpMinBandwidth > maxContinuousUlBandwidth)
571 {
572 maxContinuousUlBandwidth = tmpMinBandwidth;
573 ffrRbStartOffset = tmpFfrRbStartOffset;
574 }
575 tmpMinBandwidth = 0;
576 }
577 else
578 {
579 if (tmpMinBandwidth == 0)
580 {
581 tmpFfrRbStartOffset = index;
582 }
583 tmpMinBandwidth++;
584 }
585 index++;
586 }
587
588 if (tmpMinBandwidth > maxContinuousUlBandwidth)
589 {
590 maxContinuousUlBandwidth = tmpMinBandwidth;
591 ffrRbStartOffset = tmpFfrRbStartOffset;
592 }
593
595 uint16_t rbStart = 0;
596 rbStart = ffrRbStartOffset;
597 for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++)
598 {
600 (*itRach).m_estimatedSize,
601 " Default UL Grant MCS does not allow to send RACH messages");
603 newRar.m_rnti = (*itRach).m_rnti;
604 // DL-RACH Allocation
605 // Ideal: no needs of configuring m_dci
606 // UL-RACH Allocation
607 newRar.m_grant.m_rnti = newRar.m_rnti;
608 newRar.m_grant.m_mcs = m_ulGrantMcs;
609 uint16_t rbLen = 1;
610 uint16_t tbSizeBits = 0;
611 // find lowest TB size that fits UL grant estimated size
612 while ((tbSizeBits < (*itRach).m_estimatedSize) &&
613 (rbStart + rbLen < (ffrRbStartOffset + maxContinuousUlBandwidth)))
614 {
615 rbLen++;
616 tbSizeBits = m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, rbLen);
617 }
618 if (tbSizeBits < (*itRach).m_estimatedSize)
619 {
620 // no more allocation space: finish allocation
621 break;
622 }
623 newRar.m_grant.m_rbStart = rbStart;
624 newRar.m_grant.m_rbLen = rbLen;
625 newRar.m_grant.m_tbSize = tbSizeBits / 8;
626 newRar.m_grant.m_hopping = false;
627 newRar.m_grant.m_tpc = 0;
628 newRar.m_grant.m_cqiRequest = false;
629 newRar.m_grant.m_ulDelay = false;
630 NS_LOG_INFO(this << " UL grant allocated to RNTI " << (*itRach).m_rnti << " rbStart "
631 << rbStart << " rbLen " << rbLen << " MCS " << (uint16_t)m_ulGrantMcs
632 << " tbSize " << newRar.m_grant.m_tbSize);
633 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
634 {
635 m_rachAllocationMap.at(i) = (*itRach).m_rnti;
636 }
637
638 if (m_harqOn)
639 {
640 // generate UL-DCI for HARQ retransmissions
641 UlDciListElement_s uldci;
642 uldci.m_rnti = newRar.m_rnti;
643 uldci.m_rbLen = rbLen;
644 uldci.m_rbStart = rbStart;
645 uldci.m_mcs = m_ulGrantMcs;
646 uldci.m_tbSize = tbSizeBits / 8;
647 uldci.m_ndi = 1;
648 uldci.m_cceIndex = 0;
649 uldci.m_aggrLevel = 1;
650 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
651 uldci.m_hopping = false;
652 uldci.m_n2Dmrs = 0;
653 uldci.m_tpc = 0; // no power control
654 uldci.m_cqiRequest = false; // only period CQI at this stage
655 uldci.m_ulIndex = 0; // TDD parameter
656 uldci.m_dai = 1; // TDD parameter
657 uldci.m_freqHopping = 0;
658 uldci.m_pdcchPowerOffset = 0; // not used
659
660 uint8_t harqId = 0;
661 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
662 if (itProcId == m_ulHarqCurrentProcessId.end())
663 {
664 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
665 }
666 harqId = (*itProcId).second;
667 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
668 if (itDci == m_ulHarqProcessesDciBuffer.end())
669 {
670 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
671 << uldci.m_rnti);
672 }
673 (*itDci).second.at(harqId) = uldci;
674 }
675
676 rbStart = rbStart + rbLen;
677 ret.m_buildRarList.push_back(newRar);
678 }
679 m_rachList.clear();
680
681 // Process DL HARQ feedback
683 // retrieve past HARQ retx buffered
684 if (!m_dlInfoListBuffered.empty())
685 {
686 if (!params.m_dlInfoList.empty())
687 {
688 NS_LOG_INFO(this << " Received DL-HARQ feedback");
690 params.m_dlInfoList.begin(),
691 params.m_dlInfoList.end());
692 }
693 }
694 else
695 {
696 if (!params.m_dlInfoList.empty())
697 {
698 m_dlInfoListBuffered = params.m_dlInfoList;
699 }
700 }
701 if (!m_harqOn)
702 {
703 // Ignore HARQ feedback
704 m_dlInfoListBuffered.clear();
705 }
706 std::vector<DlInfoListElement_s> dlInfoListUntxed;
707 for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++)
708 {
709 auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti);
710 if (itRnti != rntiAllocated.end())
711 {
712 // RNTI already allocated for retx
713 continue;
714 }
715 auto nLayers = m_dlInfoListBuffered.at(i).m_harqStatus.size();
716 std::vector<bool> retx;
717 NS_LOG_INFO(this << " Processing DLHARQ feedback");
718 if (nLayers == 1)
719 {
720 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
722 retx.push_back(false);
723 }
724 else
725 {
726 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
728 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(1) ==
730 }
731 if (retx.at(0) || retx.at(1))
732 {
733 // retrieve HARQ process information
734 uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti;
735 uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId;
736 NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
737 auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti);
738 if (itHarq == m_dlHarqProcessesDciBuffer.end())
739 {
740 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti);
741 }
742
743 DlDciListElement_s dci = (*itHarq).second.at(harqId);
744 int rv = 0;
745 if (dci.m_rv.size() == 1)
746 {
747 rv = dci.m_rv.at(0);
748 }
749 else
750 {
751 rv = (dci.m_rv.at(0) > dci.m_rv.at(1) ? dci.m_rv.at(0) : dci.m_rv.at(1));
752 }
753
754 if (rv == 3)
755 {
756 // maximum number of retx reached -> drop process
757 NS_LOG_INFO("Maximum number of retransmissions reached -> drop process");
758 auto it = m_dlHarqProcessesStatus.find(rnti);
759 if (it == m_dlHarqProcessesStatus.end())
760 {
761 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
762 << m_dlInfoListBuffered.at(i).m_rnti);
763 }
764 (*it).second.at(harqId) = 0;
765 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
766 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
767 {
768 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
769 << m_dlInfoListBuffered.at(i).m_rnti);
770 }
771 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
772 {
773 (*itRlcPdu).second.at(k).at(harqId).clear();
774 }
775 continue;
776 }
777 // check the feasibility of retransmitting on the same RBGs
778 // translate the DCI to Spectrum framework
779 std::vector<int> dciRbg;
780 uint32_t mask = 0x1;
781 NS_LOG_INFO("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
782 for (int j = 0; j < 32; j++)
783 {
784 if (((dci.m_rbBitmap & mask) >> j) == 1)
785 {
786 dciRbg.push_back(j);
787 NS_LOG_INFO("\t" << j);
788 }
789 mask = (mask << 1);
790 }
791 bool free = true;
792 for (std::size_t j = 0; j < dciRbg.size(); j++)
793 {
794 if (rbgMap.at(dciRbg.at(j)))
795 {
796 free = false;
797 break;
798 }
799 }
800 if (free)
801 {
802 // use the same RBGs for the retx
803 // reserve RBGs
804 for (std::size_t j = 0; j < dciRbg.size(); j++)
805 {
806 rbgMap.at(dciRbg.at(j)) = true;
807 NS_LOG_INFO("RBG " << dciRbg.at(j) << " assigned");
808 rbgAllocatedNum++;
809 }
810
811 NS_LOG_INFO(this << " Send retx in the same RBGs");
812 }
813 else
814 {
815 // find RBGs for sending HARQ retx
816 uint8_t j = 0;
817 uint8_t rbgId = (dciRbg.at(dciRbg.size() - 1) + 1) % rbgNum;
818 uint8_t startRbg = dciRbg.at(dciRbg.size() - 1);
819 std::vector<bool> rbgMapCopy = rbgMap;
820 while ((j < dciRbg.size()) && (startRbg != rbgId))
821 {
822 if (!rbgMapCopy.at(rbgId))
823 {
824 rbgMapCopy.at(rbgId) = true;
825 dciRbg.at(j) = rbgId;
826 j++;
827 }
828 rbgId = (rbgId + 1) % rbgNum;
829 }
830 if (j == dciRbg.size())
831 {
832 // find new RBGs -> update DCI map
833 uint32_t rbgMask = 0;
834 for (std::size_t k = 0; k < dciRbg.size(); k++)
835 {
836 rbgMask = rbgMask + (0x1 << dciRbg.at(k));
837 rbgAllocatedNum++;
838 }
839 dci.m_rbBitmap = rbgMask;
840 rbgMap = rbgMapCopy;
841 NS_LOG_INFO(this << " Move retx in RBGs " << dciRbg.size());
842 }
843 else
844 {
845 // HARQ retx cannot be performed on this TTI -> store it
846 dlInfoListUntxed.push_back(m_dlInfoListBuffered.at(i));
847 NS_LOG_INFO(this << " No resource for this retx -> buffer it");
848 }
849 }
850 // retrieve RLC PDU list for retx TBsize and update DCI
852 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti);
853 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
854 {
855 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
856 }
857 for (std::size_t j = 0; j < nLayers; j++)
858 {
859 if (retx.at(j))
860 {
861 if (j >= dci.m_ndi.size())
862 {
863 // for avoiding errors in MIMO transient phases
864 dci.m_ndi.push_back(0);
865 dci.m_rv.push_back(0);
866 dci.m_mcs.push_back(0);
867 dci.m_tbsSize.push_back(0);
868 NS_LOG_INFO(this << " layer " << (uint16_t)j
869 << " no txed (MIMO transition)");
870 }
871 else
872 {
873 dci.m_ndi.at(j) = 0;
874 dci.m_rv.at(j)++;
875 (*itHarq).second.at(harqId).m_rv.at(j)++;
876 NS_LOG_INFO(this << " layer " << (uint16_t)j << " RV "
877 << (uint16_t)dci.m_rv.at(j));
878 }
879 }
880 else
881 {
882 // empty TB of layer j
883 dci.m_ndi.at(j) = 0;
884 dci.m_rv.at(j) = 0;
885 dci.m_mcs.at(j) = 0;
886 dci.m_tbsSize.at(j) = 0;
887 NS_LOG_INFO(this << " layer " << (uint16_t)j << " no retx");
888 }
889 }
890 for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++)
891 {
892 std::vector<RlcPduListElement_s> rlcPduListPerLc;
893 for (std::size_t j = 0; j < nLayers; j++)
894 {
895 if (retx.at(j))
896 {
897 if (j < dci.m_ndi.size())
898 {
899 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size "
900 << dci.m_tbsSize.at(j));
901 rlcPduListPerLc.push_back(
902 (*itRlcPdu).second.at(j).at(dci.m_harqProcess).at(k));
903 }
904 }
905 else
906 { // if no retx needed on layer j, push an RlcPduListElement_s object with
907 // m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
908 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at(j));
909 RlcPduListElement_s emptyElement;
910 emptyElement.m_logicalChannelIdentity = (*itRlcPdu)
911 .second.at(j)
912 .at(dci.m_harqProcess)
913 .at(k)
914 .m_logicalChannelIdentity;
915 emptyElement.m_size = 0;
916 rlcPduListPerLc.push_back(emptyElement);
917 }
918 }
919
920 if (!rlcPduListPerLc.empty())
921 {
922 newEl.m_rlcPduList.push_back(rlcPduListPerLc);
923 }
924 }
925 newEl.m_rnti = rnti;
926 newEl.m_dci = dci;
927 (*itHarq).second.at(harqId).m_rv = dci.m_rv;
928 // refresh timer
929 auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti);
930 if (itHarqTimer == m_dlHarqProcessesTimer.end())
931 {
932 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
933 }
934 (*itHarqTimer).second.at(harqId) = 0;
935 ret.m_buildDataList.push_back(newEl);
936 rntiAllocated.insert(rnti);
937 }
938 else
939 {
940 // update HARQ process status
941 NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti);
942 auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti);
943 if (it == m_dlHarqProcessesStatus.end())
944 {
945 NS_FATAL_ERROR("No info find in HARQ buffer for UE "
946 << m_dlInfoListBuffered.at(i).m_rnti);
947 }
948 (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0;
949 auto itRlcPdu =
951 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
952 {
953 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
954 << m_dlInfoListBuffered.at(i).m_rnti);
955 }
956 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
957 {
958 (*itRlcPdu).second.at(k).at(m_dlInfoListBuffered.at(i).m_harqProcessId).clear();
959 }
960 }
961 }
962 m_dlInfoListBuffered.clear();
963 m_dlInfoListBuffered = dlInfoListUntxed;
964
965 if (rbgAllocatedNum == rbgNum)
966 {
967 // all the RBGs are already allocated -> exit
968 if (!ret.m_buildDataList.empty() || !ret.m_buildRarList.empty())
969 {
971 }
972 return;
973 }
974
975 // update token pool, counter and bank size
976 for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++)
977 {
978 if ((*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize >
979 (*itStats).second.maxTokenPoolSize)
980 {
981 (*itStats).second.counter +=
982 (*itStats).second.tokenGenerationRate / 1000 -
983 ((*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize);
984 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
985 bankSize += (*itStats).second.tokenGenerationRate / 1000 -
986 ((*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize);
987 }
988 else
989 {
990 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
991 }
992 }
993
994 std::set<uint16_t> allocatedRnti; // store UEs which are already assigned RBGs
995 std::set<uint8_t> allocatedRbg; // store RBGs which are already allocated to UE
996
997 int totalRbg = 0;
998 while (totalRbg < rbgNum)
999 {
1000 // select UE with largest metric
1001 std::map<uint16_t, fdtbfqsFlowPerf_t>::iterator it;
1002 auto itMax = m_flowStatsDl.end();
1003 double metricMax = 0.0;
1004 bool firstRnti = true;
1005 for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++)
1006 {
1007 auto itRnti = rntiAllocated.find((*it).first);
1008 if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first)))
1009 {
1010 // UE already allocated for HARQ or without HARQ process available -> drop it
1011 if (itRnti != rntiAllocated.end())
1012 {
1013 NS_LOG_DEBUG(this << " RNTI discarded for HARQ tx" << (uint16_t)(*it).first);
1014 }
1015 if (!HarqProcessAvailability((*it).first))
1016 {
1017 NS_LOG_DEBUG(this << " RNTI discarded for HARQ id" << (uint16_t)(*it).first);
1018 }
1019 continue;
1020 }
1021 // check first the channel conditions for this UE, if CQI!=0
1022 auto itCqi = m_a30CqiRxed.find((*it).first);
1023 auto itTxMode = m_uesTxMode.find((*it).first);
1024 if (itTxMode == m_uesTxMode.end())
1025 {
1026 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first);
1027 }
1028 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
1029
1030 uint8_t cqiSum = 0;
1031 for (int k = 0; k < rbgNum; k++)
1032 {
1033 for (uint8_t j = 0; j < nLayer; j++)
1034 {
1035 if (itCqi == m_a30CqiRxed.end())
1036 {
1037 cqiSum += 1; // no info on this user -> lowest MCS
1038 }
1039 else
1040 {
1041 cqiSum += (*itCqi).second.m_higherLayerSelected.at(k).m_sbCqi.at(j);
1042 }
1043 }
1044 }
1045
1046 if (cqiSum == 0)
1047 {
1048 NS_LOG_INFO("Skip this flow, CQI==0, rnti:" << (*it).first);
1049 continue;
1050 }
1051
1052 if (LcActivePerFlow((*it).first) == 0)
1053 {
1054 continue;
1055 }
1056
1057 auto rnti = allocatedRnti.find((*it).first);
1058 if (rnti != allocatedRnti.end()) // already allocated RBGs to this UE
1059 {
1060 continue;
1061 }
1062
1063 double metric =
1064 (((double)(*it).second.counter) / ((double)(*it).second.tokenGenerationRate));
1065
1066 if (firstRnti)
1067 {
1068 metricMax = metric;
1069 itMax = it;
1070 firstRnti = false;
1071 continue;
1072 }
1073 if (metric > metricMax)
1074 {
1075 metricMax = metric;
1076 itMax = it;
1077 }
1078 } // end for m_flowStatsDl
1079
1080 if (itMax == m_flowStatsDl.end())
1081 {
1082 // all UEs are allocated RBG or all UEs already allocated for HARQ or without HARQ
1083 // process available
1084 break;
1085 }
1086
1087 // mark this UE as "allocated"
1088 allocatedRnti.insert((*itMax).first);
1089
1090 // calculate the maximum number of byte that the scheduler can assigned to this UE
1091 uint32_t budget = 0;
1092 if (bankSize > 0)
1093 {
1094 budget = (*itMax).second.counter - (*itMax).second.debtLimit;
1095 if (budget > (*itMax).second.burstCredit)
1096 {
1097 budget = (*itMax).second.burstCredit;
1098 }
1099 if (budget > bankSize)
1100 {
1101 budget = bankSize;
1102 }
1103 }
1104 budget = budget + (*itMax).second.tokenPoolSize;
1105
1106 // calculate how much bytes this UE actually need
1107 if (budget == 0)
1108 {
1109 // there are no tokens for this UE
1110 continue;
1111 }
1112 else
1113 {
1114 // calculate rlc buffer size
1115 uint32_t rlcBufSize = 0;
1116 uint8_t lcid = 0;
1117 for (auto itRlcBuf = m_rlcBufferReq.begin(); itRlcBuf != m_rlcBufferReq.end();
1118 itRlcBuf++)
1119 {
1120 if ((*itRlcBuf).first.m_rnti == (*itMax).first)
1121 {
1122 lcid = (*itRlcBuf).first.m_lcId;
1123 }
1124 }
1125 LteFlowId_t flow((*itMax).first, lcid);
1126 auto itRlcBuf = m_rlcBufferReq.find(flow);
1127 if (itRlcBuf != m_rlcBufferReq.end())
1128 {
1129 rlcBufSize = (*itRlcBuf).second.m_rlcTransmissionQueueSize +
1130 (*itRlcBuf).second.m_rlcRetransmissionQueueSize +
1131 (*itRlcBuf).second.m_rlcStatusPduSize;
1132 }
1133 if (budget > rlcBufSize)
1134 {
1135 budget = rlcBufSize;
1136 NS_LOG_DEBUG("budget > rlcBufSize. budget: " << budget
1137 << " RLC buffer size: " << rlcBufSize);
1138 }
1139 }
1140
1141 // assign RBGs to this UE
1142 uint32_t bytesTxed = 0;
1143 uint32_t bytesTxedTmp = 0;
1144 int rbgIndex = 0;
1145 while (bytesTxed <= budget)
1146 {
1147 totalRbg++;
1148
1149 auto itCqi = m_a30CqiRxed.find((*itMax).first);
1150 auto itTxMode = m_uesTxMode.find((*itMax).first);
1151 if (itTxMode == m_uesTxMode.end())
1152 {
1153 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first);
1154 }
1155 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
1156
1157 // find RBG with largest achievableRate
1158 double achievableRateMax = 0.0;
1159 rbgIndex = rbgNum;
1160 for (int k = 0; k < rbgNum; k++)
1161 {
1162 auto rbg = allocatedRbg.find(k);
1163 if (rbg != allocatedRbg.end()) // RBGs are already allocated to this UE
1164 {
1165 continue;
1166 }
1167
1168 if (rbgMap.at(k)) // this RBG is allocated in RACH procedure
1169 {
1170 continue;
1171 }
1172
1173 if (!m_ffrSapProvider->IsDlRbgAvailableForUe(k, (*itMax).first))
1174 {
1175 continue;
1176 }
1177
1178 std::vector<uint8_t> sbCqi;
1179 if (itCqi == m_a30CqiRxed.end())
1180 {
1181 sbCqi = std::vector<uint8_t>(nLayer, 1); // start with lowest value
1182 }
1183 else
1184 {
1185 sbCqi = (*itCqi).second.m_higherLayerSelected.at(k).m_sbCqi;
1186 }
1187 uint8_t cqi1 = sbCqi.at(0);
1188 uint8_t cqi2 = 0;
1189 if (sbCqi.size() > 1)
1190 {
1191 cqi2 = sbCqi.at(1);
1192 }
1193
1194 if ((cqi1 > 0) ||
1195 (cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1196 {
1197 if (LcActivePerFlow((*itMax).first) > 0)
1198 {
1199 // this UE has data to transmit
1200 double achievableRate = 0.0;
1201 for (uint8_t j = 0; j < nLayer; j++)
1202 {
1203 uint8_t mcs = 0;
1204 if (sbCqi.size() > j)
1205 {
1206 mcs = m_amc->GetMcsFromCqi(sbCqi.at(j));
1207 }
1208 else
1209 {
1210 // no info on this subband -> worst MCS
1211 mcs = 0;
1212 }
1213 achievableRate += ((m_amc->GetDlTbSizeFromMcs(mcs, rbgSize) / 8) /
1214 0.001); // = TB size / TTI
1215 }
1216
1217 if (achievableRate > achievableRateMax)
1218 {
1219 achievableRateMax = achievableRate;
1220 rbgIndex = k;
1221 }
1222 } // end of LcActivePerFlow
1223 } // end of cqi
1224 } // end of for rbgNum
1225
1226 if (rbgIndex == rbgNum) // impossible
1227 {
1228 // all RBGs are already assigned
1229 totalRbg = rbgNum;
1230 break;
1231 }
1232 else
1233 {
1234 // mark this UE as "allocated"
1235 allocatedRbg.insert(rbgIndex);
1236 }
1237
1238 // assign this RBG to UE
1239 auto itMap = allocationMap.find((*itMax).first);
1240 uint16_t RbgPerRnti;
1241 if (itMap == allocationMap.end())
1242 {
1243 // insert new element
1244 std::vector<uint16_t> tempMap;
1245 tempMap.push_back(rbgIndex);
1246 allocationMap.insert(
1247 std::pair<uint16_t, std::vector<uint16_t>>((*itMax).first, tempMap));
1248 itMap = allocationMap.find(
1249 (*itMax).first); // point itMap to the first RBGs assigned to this UE
1250 }
1251 else
1252 {
1253 (*itMap).second.push_back(rbgIndex);
1254 }
1255 rbgMap.at(rbgIndex) = true; // Mark this RBG as allocated
1256
1257 RbgPerRnti = (*itMap).second.size();
1258
1259 // calculate tb size
1260 std::vector<uint8_t> worstCqi(2, 15);
1261 if (itCqi != m_a30CqiRxed.end())
1262 {
1263 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1264 {
1265 if ((*itCqi).second.m_higherLayerSelected.size() > (*itMap).second.at(k))
1266 {
1267 for (uint8_t j = 0; j < nLayer; j++)
1268 {
1269 if ((*itCqi)
1270 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1271 .m_sbCqi.size() > j)
1272 {
1273 if (((*itCqi)
1274 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1275 .m_sbCqi.at(j)) < worstCqi.at(j))
1276 {
1277 worstCqi.at(j) =
1278 ((*itCqi)
1279 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1280 .m_sbCqi.at(j));
1281 }
1282 }
1283 else
1284 {
1285 // no CQI for this layer of this suband -> worst one
1286 worstCqi.at(j) = 1;
1287 }
1288 }
1289 }
1290 else
1291 {
1292 for (uint8_t j = 0; j < nLayer; j++)
1293 {
1294 worstCqi.at(j) =
1295 1; // try with lowest MCS in RBG with no info on channel
1296 }
1297 }
1298 }
1299 }
1300 else
1301 {
1302 for (uint8_t j = 0; j < nLayer; j++)
1303 {
1304 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1305 }
1306 }
1307
1308 bytesTxedTmp = bytesTxed;
1309 bytesTxed = 0;
1310 for (uint8_t j = 0; j < nLayer; j++)
1311 {
1312 int tbSize = (m_amc->GetDlTbSizeFromMcs(m_amc->GetMcsFromCqi(worstCqi.at(j)),
1313 RbgPerRnti * rbgSize) /
1314 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
1315 bytesTxed += tbSize;
1316 }
1317
1318 } // end of while()
1319
1320 // remove and unmark last RBG assigned to UE
1321 if (bytesTxed > budget)
1322 {
1323 NS_LOG_DEBUG("budget: " << budget << " bytesTxed: " << bytesTxed << " at "
1324 << Simulator::Now().As(Time::MS));
1325 auto itMap = allocationMap.find((*itMax).first);
1326 (*itMap).second.pop_back();
1327 allocatedRbg.erase(rbgIndex);
1328 bytesTxed = bytesTxedTmp; // recovery bytesTxed
1329 totalRbg--;
1330 rbgMap.at(rbgIndex) = false; // unmark this RBG
1331 // If all the RBGs are removed from the allocation
1332 // of this RNTI, we remove the UE from the allocation map
1333 if ((*itMap).second.empty())
1334 {
1335 itMap = allocationMap.erase(itMap);
1336 }
1337 }
1338
1339 // only update the UE stats if it exists in the allocation map
1340 if (allocationMap.find((*itMax).first) != allocationMap.end())
1341 {
1342 // update UE stats
1343 if (bytesTxed <= (*itMax).second.tokenPoolSize)
1344 {
1345 (*itMax).second.tokenPoolSize -= bytesTxed;
1346 }
1347 else
1348 {
1349 (*itMax).second.counter =
1350 (*itMax).second.counter - (bytesTxed - (*itMax).second.tokenPoolSize);
1351 (*itMax).second.tokenPoolSize = 0;
1352 if (bankSize <= (bytesTxed - (*itMax).second.tokenPoolSize))
1353 {
1354 bankSize = 0;
1355 }
1356 else
1357 {
1358 bankSize = bankSize - (bytesTxed - (*itMax).second.tokenPoolSize);
1359 }
1360 }
1361 }
1362 } // end of RBGs
1363
1364 // generate the transmission opportunities by grouping the RBGs of the same RNTI and
1365 // creating the correspondent DCIs
1366 auto itMap = allocationMap.begin();
1367 while (itMap != allocationMap.end())
1368 {
1369 NS_LOG_DEBUG("Preparing DCI for RNTI " << (*itMap).first);
1370 // create new BuildDataListElement_s for this LC
1372 newEl.m_rnti = (*itMap).first;
1373 // create the DlDciListElement_s
1374 DlDciListElement_s newDci;
1375 newDci.m_rnti = (*itMap).first;
1376 newDci.m_harqProcess = UpdateHarqProcessId((*itMap).first);
1377
1378 uint16_t lcActives = LcActivePerFlow((*itMap).first);
1379 NS_LOG_INFO(this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
1380 if (lcActives == 0)
1381 {
1382 // Set to max value, to avoid divide by 0 below
1383 lcActives = (uint16_t)65535; // UINT16_MAX;
1384 }
1385 uint16_t RgbPerRnti = (*itMap).second.size();
1386 auto itCqi = m_a30CqiRxed.find((*itMap).first);
1387 auto itTxMode = m_uesTxMode.find((*itMap).first);
1388 if (itTxMode == m_uesTxMode.end())
1389 {
1390 NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first);
1391 }
1392 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
1393 std::vector<uint8_t> worstCqi(2, 15);
1394 if (itCqi != m_a30CqiRxed.end())
1395 {
1396 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1397 {
1398 if ((*itCqi).second.m_higherLayerSelected.size() > (*itMap).second.at(k))
1399 {
1400 NS_LOG_INFO(this << " RBG " << (*itMap).second.at(k) << " CQI "
1401 << (uint16_t)((*itCqi)
1402 .second.m_higherLayerSelected
1403 .at((*itMap).second.at(k))
1404 .m_sbCqi.at(0)));
1405 for (uint8_t j = 0; j < nLayer; j++)
1406 {
1407 if ((*itCqi)
1408 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1409 .m_sbCqi.size() > j)
1410 {
1411 if (((*itCqi)
1412 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1413 .m_sbCqi.at(j)) < worstCqi.at(j))
1414 {
1415 worstCqi.at(j) =
1416 ((*itCqi)
1417 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1418 .m_sbCqi.at(j));
1419 }
1420 }
1421 else
1422 {
1423 // no CQI for this layer of this suband -> worst one
1424 worstCqi.at(j) = 1;
1425 }
1426 }
1427 }
1428 else
1429 {
1430 for (uint8_t j = 0; j < nLayer; j++)
1431 {
1432 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1433 }
1434 }
1435 }
1436 }
1437 else
1438 {
1439 for (uint8_t j = 0; j < nLayer; j++)
1440 {
1441 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1442 }
1443 }
1444 for (uint8_t j = 0; j < nLayer; j++)
1445 {
1446 NS_LOG_INFO(this << " Layer " << (uint16_t)j << " CQI selected "
1447 << (uint16_t)worstCqi.at(j));
1448 }
1449 for (uint8_t j = 0; j < nLayer; j++)
1450 {
1451 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi(worstCqi.at(j)));
1452 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(j), RgbPerRnti * rbgSize) /
1453 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
1454 newDci.m_tbsSize.push_back(tbSize);
1455 NS_LOG_INFO(this << " Layer " << (uint16_t)j << " MCS selected"
1456 << (uint16_t)m_amc->GetMcsFromCqi(worstCqi.at(j)));
1457 }
1458
1459 newDci.m_resAlloc = 0; // only allocation type 0 at this stage
1460 newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
1461 uint32_t rbgMask = 0;
1462 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1463 {
1464 rbgMask = rbgMask + (0x1 << (*itMap).second.at(k));
1465 NS_LOG_INFO(this << " Allocated RBG " << (*itMap).second.at(k));
1466 }
1467 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1468
1469 // create the rlc PDUs -> equally divide resources among actives LCs
1470 for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++)
1471 {
1472 if (((*itBufReq).first.m_rnti == (*itMap).first) &&
1473 (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) ||
1474 ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) ||
1475 ((*itBufReq).second.m_rlcStatusPduSize > 0)))
1476 {
1477 std::vector<RlcPduListElement_s> newRlcPduLe;
1478 for (uint8_t j = 0; j < nLayer; j++)
1479 {
1480 RlcPduListElement_s newRlcEl;
1481 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1482 newRlcEl.m_size = newDci.m_tbsSize.at(j) / lcActives;
1483 NS_LOG_INFO(this << " LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
1484 << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
1485 newRlcPduLe.push_back(newRlcEl);
1487 newRlcEl.m_logicalChannelIdentity,
1488 newRlcEl.m_size);
1489 if (m_harqOn)
1490 {
1491 // store RLC PDU list for HARQ
1492 auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first);
1493 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1494 {
1495 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1496 << (*itMap).first);
1497 }
1498 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1499 }
1500 }
1501 newEl.m_rlcPduList.push_back(newRlcPduLe);
1502 }
1503 if ((*itBufReq).first.m_rnti > (*itMap).first)
1504 {
1505 break;
1506 }
1507 }
1508 for (uint8_t j = 0; j < nLayer; j++)
1509 {
1510 newDci.m_ndi.push_back(1);
1511 newDci.m_rv.push_back(0);
1512 }
1513
1514 newDci.m_tpc = m_ffrSapProvider->GetTpc((*itMap).first);
1515
1516 newEl.m_dci = newDci;
1517
1518 if (m_harqOn)
1519 {
1520 // store DCI for HARQ
1521 auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti);
1522 if (itDci == m_dlHarqProcessesDciBuffer.end())
1523 {
1524 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1525 << newEl.m_rnti);
1526 }
1527 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1528 // refresh timer
1529 auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti);
1530 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1531 {
1532 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1533 }
1534 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1535 }
1536
1537 // ...more parameters -> ignored in this version
1538
1539 ret.m_buildDataList.push_back(newEl);
1540
1541 itMap++;
1542 } // end while allocation
1543 ret.m_nrOfPdcchOfdmSymbols = 1;
1544
1546}
1547
1548void
1551{
1552 NS_LOG_FUNCTION(this);
1553
1554 m_rachList = params.m_rachList;
1555}
1556
1557void
1560{
1561 NS_LOG_FUNCTION(this);
1563
1564 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1565 {
1566 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1567 {
1568 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1569 << " reported");
1570 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1571 auto it = m_p10CqiRxed.find(rnti);
1572 if (it == m_p10CqiRxed.end())
1573 {
1574 // create the new entry
1575 m_p10CqiRxed.insert(std::pair<uint16_t, uint8_t>(
1576 rnti,
1577 params.m_cqiList.at(i).m_wbCqi.at(0))); // only codeword 0 at this stage (SISO)
1578 // generate correspondent timer
1579 m_p10CqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
1580 }
1581 else
1582 {
1583 // update the CQI value and refresh correspondent timer
1584 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1585 // update correspondent timer
1586 auto itTimers = m_p10CqiTimers.find(rnti);
1587 (*itTimers).second = m_cqiTimersThreshold;
1588 }
1589 }
1590 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1591 {
1592 // subband CQI reporting high layer configured
1593 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1594 auto it = m_a30CqiRxed.find(rnti);
1595 if (it == m_a30CqiRxed.end())
1596 {
1597 // create the new entry
1598 m_a30CqiRxed.insert(
1599 std::pair<uint16_t, SbMeasResult_s>(rnti,
1600 params.m_cqiList.at(i).m_sbMeasResult));
1601 m_a30CqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
1602 }
1603 else
1604 {
1605 // update the CQI value and refresh correspondent timer
1606 (*it).second = params.m_cqiList.at(i).m_sbMeasResult;
1607 auto itTimers = m_a30CqiTimers.find(rnti);
1608 (*itTimers).second = m_cqiTimersThreshold;
1609 }
1610 }
1611 else
1612 {
1613 NS_LOG_ERROR(this << " CQI type unknown");
1614 }
1615 }
1616}
1617
1618double
1619FdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb)
1620{
1621 auto itCqi = m_ueCqi.find(rnti);
1622 if (itCqi == m_ueCqi.end())
1623 {
1624 // no cqi info about this UE
1625 return (NO_SINR);
1626 }
1627 else
1628 {
1629 // take the average SINR value among the available
1630 double sinrSum = 0;
1631 unsigned int sinrNum = 0;
1632 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1633 {
1634 double sinr = (*itCqi).second.at(i);
1635 if (sinr != NO_SINR)
1636 {
1637 sinrSum += sinr;
1638 sinrNum++;
1639 }
1640 }
1641 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1642 // store the value
1643 (*itCqi).second.at(rb) = estimatedSinr;
1644 return (estimatedSinr);
1645 }
1646}
1647
1648void
1651{
1652 NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
1653 << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size());
1654
1657
1658 // Generate RBs map
1660 std::vector<bool> rbMap;
1661 uint16_t rbAllocatedNum = 0;
1662 std::set<uint16_t> rntiAllocated;
1663 std::vector<uint16_t> rbgAllocationMap;
1664 // update with RACH allocation map
1665 rbgAllocationMap = m_rachAllocationMap;
1666 // rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1667 m_rachAllocationMap.clear();
1669
1670 rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
1671
1673
1674 for (auto it = rbMap.begin(); it != rbMap.end(); it++)
1675 {
1676 if (*it)
1677 {
1678 rbAllocatedNum++;
1679 }
1680 }
1681
1682 uint8_t minContinuousUlBandwidth = m_ffrSapProvider->GetMinContinuousUlBandwidth();
1683 uint8_t ffrUlBandwidth = m_cschedCellConfig.m_ulBandwidth - rbAllocatedNum;
1684
1685 // remove RACH allocation
1686 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1687 {
1688 if (rbgAllocationMap.at(i) != 0)
1689 {
1690 rbMap.at(i) = true;
1691 NS_LOG_DEBUG(this << " Allocated for RACH " << i);
1692 }
1693 }
1694
1695 if (m_harqOn)
1696 {
1697 // Process UL HARQ feedback
1698 for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++)
1699 {
1700 if (params.m_ulInfoList.at(i).m_receptionStatus == UlInfoListElement_s::NotOk)
1701 {
1702 // retx correspondent block: retrieve the UL-DCI
1703 uint16_t rnti = params.m_ulInfoList.at(i).m_rnti;
1704 auto itProcId = m_ulHarqCurrentProcessId.find(rnti);
1705 if (itProcId == m_ulHarqCurrentProcessId.end())
1706 {
1707 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1708 }
1709 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1710 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId
1711 << " i " << i << " size " << params.m_ulInfoList.size());
1712 auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti);
1713 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1714 {
1715 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1716 continue;
1717 }
1718 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1719 auto itStat = m_ulHarqProcessesStatus.find(rnti);
1720 if (itStat == m_ulHarqProcessesStatus.end())
1721 {
1722 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1723 }
1724 if ((*itStat).second.at(harqId) >= 3)
1725 {
1726 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1727 continue;
1728 }
1729 bool free = true;
1730 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1731 {
1732 if (rbMap.at(j))
1733 {
1734 free = false;
1735 NS_LOG_INFO(this << " BUSY " << j);
1736 }
1737 }
1738 if (free)
1739 {
1740 // retx on the same RBs
1741 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1742 {
1743 rbMap.at(j) = true;
1744 rbgAllocationMap.at(j) = dci.m_rnti;
1745 NS_LOG_INFO("\tRB " << j);
1746 rbAllocatedNum++;
1747 }
1748 NS_LOG_INFO(this << " Send retx in the same RBs " << (uint16_t)dci.m_rbStart
1749 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1750 << (*itStat).second.at(harqId) + 1);
1751 }
1752 else
1753 {
1754 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1755 continue;
1756 }
1757 dci.m_ndi = 0;
1758 // Update HARQ buffers with new HarqId
1759 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1760 (*itStat).second.at(harqId) = 0;
1761 (*itHarq).second.at((*itProcId).second) = dci;
1762 ret.m_dciList.push_back(dci);
1763 rntiAllocated.insert(dci.m_rnti);
1764 }
1765 else
1766 {
1767 NS_LOG_INFO(this << " HARQ-ACK feedback from RNTI "
1768 << params.m_ulInfoList.at(i).m_rnti);
1769 }
1770 }
1771 }
1772
1773 std::map<uint16_t, uint32_t>::iterator it;
1774 int nflows = 0;
1775
1776 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1777 {
1778 auto itRnti = rntiAllocated.find((*it).first);
1779 // select UEs with queues not empty and not yet allocated for HARQ
1780 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1781 {
1782 nflows++;
1783 }
1784 }
1785
1786 if (nflows == 0)
1787 {
1788 if (!ret.m_dciList.empty())
1789 {
1790 m_allocationMaps.insert(
1791 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
1793 }
1794
1795 return; // no flows to be scheduled
1796 }
1797
1798 // Divide the remaining resources equally among the active users starting from the subsequent
1799 // one served last scheduling trigger
1800 uint16_t tempRbPerFlow = (ffrUlBandwidth) / (nflows + rntiAllocated.size());
1801 uint16_t rbPerFlow =
1802 (minContinuousUlBandwidth < tempRbPerFlow) ? minContinuousUlBandwidth : tempRbPerFlow;
1803
1804 if (rbPerFlow < 3)
1805 {
1806 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1807 // >= 7 bytes
1808 }
1809 int rbAllocated = 0;
1810
1811 if (m_nextRntiUl != 0)
1812 {
1813 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1814 {
1815 if ((*it).first == m_nextRntiUl)
1816 {
1817 break;
1818 }
1819 }
1820 if (it == m_ceBsrRxed.end())
1821 {
1822 NS_LOG_ERROR(this << " no user found");
1823 }
1824 }
1825 else
1826 {
1827 it = m_ceBsrRxed.begin();
1828 m_nextRntiUl = (*it).first;
1829 }
1830 do
1831 {
1832 auto itRnti = rntiAllocated.find((*it).first);
1833 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1834 {
1835 // UE already allocated for UL-HARQ -> skip it
1836 NS_LOG_DEBUG(this << " UE already allocated in HARQ -> discarded, RNTI "
1837 << (*it).first);
1838 it++;
1839 if (it == m_ceBsrRxed.end())
1840 {
1841 // restart from the first
1842 it = m_ceBsrRxed.begin();
1843 }
1844 continue;
1845 }
1846 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1847 {
1848 // limit to physical resources last resource assignment
1849 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1850 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1851 if (rbPerFlow < 3)
1852 {
1853 // terminate allocation
1854 rbPerFlow = 0;
1855 }
1856 }
1857
1858 rbAllocated = 0;
1859 UlDciListElement_s uldci;
1860 uldci.m_rnti = (*it).first;
1861 uldci.m_rbLen = rbPerFlow;
1862 bool allocated = false;
1863 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1864 << " flows " << nflows);
1865 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1866 (rbPerFlow != 0))
1867 {
1868 // check availability
1869 bool free = true;
1870 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1871 {
1872 if (rbMap.at(j))
1873 {
1874 free = false;
1875 break;
1876 }
1877 if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first))
1878 {
1879 free = false;
1880 break;
1881 }
1882 }
1883 if (free)
1884 {
1885 NS_LOG_INFO(this << "RNTI: " << (*it).first << " RB Allocated " << rbAllocated
1886 << " rbPerFlow " << rbPerFlow << " flows " << nflows);
1887 uldci.m_rbStart = rbAllocated;
1888
1889 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1890 {
1891 rbMap.at(j) = true;
1892 // store info on allocation for managing ul-cqi interpretation
1893 rbgAllocationMap.at(j) = (*it).first;
1894 }
1895 rbAllocated += rbPerFlow;
1896 allocated = true;
1897 break;
1898 }
1899 rbAllocated++;
1900 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1901 {
1902 // limit to physical resources last resource assignment
1903 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1904 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1905 if (rbPerFlow < 3)
1906 {
1907 // terminate allocation
1908 rbPerFlow = 0;
1909 }
1910 }
1911 }
1912 if (!allocated)
1913 {
1914 // unable to allocate new resource: finish scheduling
1915 // m_nextRntiUl = (*it).first;
1916 // if (ret.m_dciList.size () > 0)
1917 // {
1918 // m_schedSapUser->SchedUlConfigInd (ret);
1919 // }
1920 // m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> >
1921 // (params.m_sfnSf, rbgAllocationMap)); return;
1922 break;
1923 }
1924
1925 auto itCqi = m_ueCqi.find((*it).first);
1926 int cqi = 0;
1927 if (itCqi == m_ueCqi.end())
1928 {
1929 // no cqi info about this UE
1930 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1931 }
1932 else
1933 {
1934 // take the lowest CQI value (worst RB)
1935 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1936 "CQI of RNTI = " << (*it).first << " has expired");
1937 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1938 if (minSinr == NO_SINR)
1939 {
1940 minSinr = EstimateUlSinr((*it).first, uldci.m_rbStart);
1941 }
1942 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1943 {
1944 double sinr = (*itCqi).second.at(i);
1945 if (sinr == NO_SINR)
1946 {
1947 sinr = EstimateUlSinr((*it).first, i);
1948 }
1949 if (sinr < minSinr)
1950 {
1951 minSinr = sinr;
1952 }
1953 }
1954
1955 // translate SINR -> cqi: WILD ACK: same as DL
1956 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1957 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1958 if (cqi == 0)
1959 {
1960 it++;
1961 if (it == m_ceBsrRxed.end())
1962 {
1963 // restart from the first
1964 it = m_ceBsrRxed.begin();
1965 }
1966 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1967 // remove UE from allocation map
1968 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1969 {
1970 rbgAllocationMap.at(i) = 0;
1971 }
1972 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1973 }
1974 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1975 }
1976
1977 uldci.m_tbSize = (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8);
1979 uldci.m_ndi = 1;
1980 uldci.m_cceIndex = 0;
1981 uldci.m_aggrLevel = 1;
1982 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1983 uldci.m_hopping = false;
1984 uldci.m_n2Dmrs = 0;
1985 uldci.m_tpc = 0; // no power control
1986 uldci.m_cqiRequest = false; // only period CQI at this stage
1987 uldci.m_ulIndex = 0; // TDD parameter
1988 uldci.m_dai = 1; // TDD parameter
1989 uldci.m_freqHopping = 0;
1990 uldci.m_pdcchPowerOffset = 0; // not used
1991 ret.m_dciList.push_back(uldci);
1992 // store DCI for HARQ_PERIOD
1993 uint8_t harqId = 0;
1994 if (m_harqOn)
1995 {
1996 auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1997 if (itProcId == m_ulHarqCurrentProcessId.end())
1998 {
1999 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
2000 }
2001 harqId = (*itProcId).second;
2002 auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti);
2003 if (itDci == m_ulHarqProcessesDciBuffer.end())
2004 {
2005 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
2006 << uldci.m_rnti);
2007 }
2008 (*itDci).second.at(harqId) = uldci;
2009 // Update HARQ process status (RV 0)
2010 auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti);
2011 if (itStat == m_ulHarqProcessesStatus.end())
2012 {
2013 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
2014 << uldci.m_rnti);
2015 }
2016 (*itStat).second.at(harqId) = 0;
2017 }
2018
2019 NS_LOG_INFO(this << " UE Allocation RNTI " << (*it).first << " startPRB "
2020 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
2021 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
2022 << uldci.m_tbSize << " RbAlloc " << rbAllocated << " harqId "
2023 << (uint16_t)harqId);
2024
2025 it++;
2026 if (it == m_ceBsrRxed.end())
2027 {
2028 // restart from the first
2029 it = m_ceBsrRxed.begin();
2030 }
2031 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
2032 {
2033 // Stop allocation: no more PRBs
2034 m_nextRntiUl = (*it).first;
2035 break;
2036 }
2037 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
2038
2039 m_allocationMaps.insert(
2040 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
2042}
2043
2044void
2047{
2048 NS_LOG_FUNCTION(this);
2049}
2050
2051void
2054{
2055 NS_LOG_FUNCTION(this);
2056}
2057
2058void
2061{
2062 NS_LOG_FUNCTION(this);
2063
2064 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
2065 {
2066 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
2067 {
2068 // buffer status report
2069 // note that this scheduler does not differentiate the
2070 // allocation according to which LCGs have more/less bytes
2071 // to send.
2072 // Hence the BSR of different LCGs are just summed up to get
2073 // a total queue size that is used for allocation purposes.
2074
2075 uint32_t buffer = 0;
2076 for (uint8_t lcg = 0; lcg < 4; ++lcg)
2077 {
2078 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
2079 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
2080 }
2081
2082 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
2083 NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer);
2084 auto it = m_ceBsrRxed.find(rnti);
2085 if (it == m_ceBsrRxed.end())
2086 {
2087 // create the new entry
2088 m_ceBsrRxed.insert(std::pair<uint16_t, uint32_t>(rnti, buffer));
2089 }
2090 else
2091 {
2092 // update the buffer size value
2093 (*it).second = buffer;
2094 }
2095 }
2096 }
2097}
2098
2099void
2102{
2103 NS_LOG_FUNCTION(this);
2104 // retrieve the allocation for this subframe
2105 switch (m_ulCqiFilter)
2106 {
2108 // filter all the CQIs that are not SRS based
2109 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
2110 {
2111 return;
2112 }
2113 }
2114 break;
2116 // filter all the CQIs that are not SRS based
2117 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
2118 {
2119 return;
2120 }
2121 }
2122 break;
2123 default:
2124 NS_FATAL_ERROR("Unknown UL CQI type");
2125 }
2126
2127 switch (params.m_ulCqi.m_type)
2128 {
2129 case UlCqi_s::PUSCH: {
2130 NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4)
2131 << " subframe no. " << (0xF & params.m_sfnSf));
2132 auto itMap = m_allocationMaps.find(params.m_sfnSf);
2133 if (itMap == m_allocationMaps.end())
2134 {
2135 return;
2136 }
2137 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
2138 {
2139 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
2140 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
2141 auto itCqi = m_ueCqi.find((*itMap).second.at(i));
2142 if (itCqi == m_ueCqi.end())
2143 {
2144 // create a new entry
2145 std::vector<double> newCqi;
2146 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2147 {
2148 if (i == j)
2149 {
2150 newCqi.push_back(sinr);
2151 }
2152 else
2153 {
2154 // initialize with NO_SINR value.
2155 newCqi.push_back(NO_SINR);
2156 }
2157 }
2158 m_ueCqi.insert(
2159 std::pair<uint16_t, std::vector<double>>((*itMap).second.at(i), newCqi));
2160 // generate correspondent timer
2161 m_ueCqiTimers.insert(
2162 std::pair<uint16_t, uint32_t>((*itMap).second.at(i), m_cqiTimersThreshold));
2163 }
2164 else
2165 {
2166 // update the value
2167 (*itCqi).second.at(i) = sinr;
2168 NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR "
2169 << sinr);
2170 // update correspondent timer
2171 auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
2172 (*itTimers).second = m_cqiTimersThreshold;
2173 }
2174 }
2175 // remove obsolete info on allocation
2176 m_allocationMaps.erase(itMap);
2177 }
2178 break;
2179 case UlCqi_s::SRS: {
2180 // get the RNTI from vendor specific parameters
2181 uint16_t rnti = 0;
2182 NS_ASSERT(!params.m_vendorSpecificList.empty());
2183 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
2184 {
2185 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
2186 {
2187 Ptr<SrsCqiRntiVsp> vsp =
2188 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
2189 rnti = vsp->GetRnti();
2190 }
2191 }
2192 auto itCqi = m_ueCqi.find(rnti);
2193 if (itCqi == m_ueCqi.end())
2194 {
2195 // create a new entry
2196 std::vector<double> newCqi;
2197 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2198 {
2199 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
2200 newCqi.push_back(sinr);
2201 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
2202 << sinr);
2203 }
2204 m_ueCqi.insert(std::pair<uint16_t, std::vector<double>>(rnti, newCqi));
2205 // generate correspondent timer
2206 m_ueCqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
2207 }
2208 else
2209 {
2210 // update the values
2211 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2212 {
2213 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
2214 (*itCqi).second.at(j) = sinr;
2215 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
2216 << sinr);
2217 }
2218 // update correspondent timer
2219 auto itTimers = m_ueCqiTimers.find(rnti);
2220 (*itTimers).second = m_cqiTimersThreshold;
2221 }
2222 }
2223 break;
2224 case UlCqi_s::PUCCH_1:
2225 case UlCqi_s::PUCCH_2:
2226 case UlCqi_s::PRACH: {
2227 NS_FATAL_ERROR("FdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2228 }
2229 break;
2230 default:
2231 NS_FATAL_ERROR("Unknown type of UL-CQI");
2232 }
2233}
2234
2235void
2237{
2238 // refresh DL CQI P01 Map
2239 auto itP10 = m_p10CqiTimers.begin();
2240 while (itP10 != m_p10CqiTimers.end())
2241 {
2242 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
2243 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2244 if ((*itP10).second == 0)
2245 {
2246 // delete correspondent entries
2247 auto itMap = m_p10CqiRxed.find((*itP10).first);
2248 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
2249 " Does not find CQI report for user " << (*itP10).first);
2250 NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first);
2251 m_p10CqiRxed.erase(itMap);
2252 auto temp = itP10;
2253 itP10++;
2254 m_p10CqiTimers.erase(temp);
2255 }
2256 else
2257 {
2258 (*itP10).second--;
2259 itP10++;
2260 }
2261 }
2262
2263 // refresh DL CQI A30 Map
2264 auto itA30 = m_a30CqiTimers.begin();
2265 while (itA30 != m_a30CqiTimers.end())
2266 {
2267 NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is "
2268 << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2269 if ((*itA30).second == 0)
2270 {
2271 // delete correspondent entries
2272 auto itMap = m_a30CqiRxed.find((*itA30).first);
2273 NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(),
2274 " Does not find CQI report for user " << (*itA30).first);
2275 NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first);
2276 m_a30CqiRxed.erase(itMap);
2277 auto temp = itA30;
2278 itA30++;
2279 m_a30CqiTimers.erase(temp);
2280 }
2281 else
2282 {
2283 (*itA30).second--;
2284 itA30++;
2285 }
2286 }
2287}
2288
2289void
2291{
2292 // refresh UL CQI Map
2293 auto itUl = m_ueCqiTimers.begin();
2294 while (itUl != m_ueCqiTimers.end())
2295 {
2296 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
2297 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2298 if ((*itUl).second == 0)
2299 {
2300 // delete correspondent entries
2301 auto itMap = m_ueCqi.find((*itUl).first);
2302 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
2303 " Does not find CQI report for user " << (*itUl).first);
2304 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
2305 (*itMap).second.clear();
2306 m_ueCqi.erase(itMap);
2307 auto temp = itUl;
2308 itUl++;
2309 m_ueCqiTimers.erase(temp);
2310 }
2311 else
2312 {
2313 (*itUl).second--;
2314 itUl++;
2315 }
2316 }
2317}
2318
2319void
2320FdTbfqFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
2321{
2322 LteFlowId_t flow(rnti, lcid);
2323 auto it = m_rlcBufferReq.find(flow);
2324 if (it != m_rlcBufferReq.end())
2325 {
2326 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
2327 << (*it).second.m_rlcTransmissionQueueSize << " retxqueue "
2328 << (*it).second.m_rlcRetransmissionQueueSize << " status "
2329 << (*it).second.m_rlcStatusPduSize << " decrease " << size);
2330 // Update queues: RLC tx order Status, ReTx, Tx
2331 // Update status queue
2332 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2333 {
2334 (*it).second.m_rlcStatusPduSize = 0;
2335 }
2336 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) &&
2337 (size >= (*it).second.m_rlcRetransmissionQueueSize))
2338 {
2339 (*it).second.m_rlcRetransmissionQueueSize = 0;
2340 }
2341 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2342 {
2343 uint32_t rlcOverhead;
2344 if (lcid == 1)
2345 {
2346 // for SRB1 (using RLC AM) it's better to
2347 // overestimate RLC overhead rather than
2348 // underestimate it and risk unneeded
2349 // segmentation which increases delay
2350 rlcOverhead = 4;
2351 }
2352 else
2353 {
2354 // minimum RLC overhead due to header
2355 rlcOverhead = 2;
2356 }
2357 // update transmission queue
2358 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2359 {
2360 (*it).second.m_rlcTransmissionQueueSize = 0;
2361 }
2362 else
2363 {
2364 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2365 }
2366 }
2367 }
2368 else
2369 {
2370 NS_LOG_ERROR(this << " Does not find DL RLC Buffer Report of UE " << rnti);
2371 }
2372}
2373
2374void
2376{
2377 size = size - 2; // remove the minimum RLC overhead
2378 auto it = m_ceBsrRxed.find(rnti);
2379 if (it != m_ceBsrRxed.end())
2380 {
2381 NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
2382 if ((*it).second >= size)
2383 {
2384 (*it).second -= size;
2385 }
2386 else
2387 {
2388 (*it).second = 0;
2389 }
2390 }
2391 else
2392 {
2393 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
2394 }
2395}
2396
2397void
2399{
2400 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
2402 params.m_rnti = rnti;
2403 params.m_transmissionMode = txMode;
2405}
2406
2407} // namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:37
static uint32_t BsrId2BufferSize(uint8_t val)
Convert BSR ID to buffer size.
Definition: lte-common.cc:176
Implements the SCHED SAP and CSCHED SAP for a Frequency Domain Token Bank Fair Queue scheduler.
std::vector< uint16_t > m_rachAllocationMap
RACH allocation map.
uint32_t m_tokenPoolSize
maximum size of token pool (byte)
std::map< uint16_t, fdtbfqsFlowPerf_t > m_flowStatsUl
Map of UE statistics (per RNTI basis)
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
std::map< uint16_t, uint32_t > m_ceBsrRxed
Map of UE's buffer status reports received.
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
Vectors of UE's LC info.
std::map< uint16_t, std::vector< double > > m_ueCqi
Map of UEs' UL-CQI per RBG.
void DoSchedDlPagingBufferReq(const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
Sched DL paging buffer request function.
static TypeId GetTypeId()
Get the type ID.
bool HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
uint64_t bankSize
the number of bytes in token bank
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
UL HARQ current process ID.
void SetFfMacCschedSapUser(FfMacCschedSapUser *s) override
Set FF MAC Csched SAP user function.
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
DL HARQ process DCI buffer.
friend class MemberSchedSapProvider< FdTbfqFfMacScheduler >
allow MemberSchedSapProvider<FdTbfqFfMacScheduler> claass friend access
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
LteFfrSapUser * GetLteFfrSapUser() override
Get FFR SAP user function.
~FdTbfqFfMacScheduler() override
Destructor.
void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
CSched LC config request function.
void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
Sched DL MAC buffer request function.
uint32_t m_creditableThreshold
threshold of flow credit
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
Update DL RLC buffer info function.
void SetFfMacSchedSapUser(FfMacSchedSapUser *s) override
Set FF MAC sched SAP user function.
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
DL HARQ current process ID.
std::map< uint16_t, uint8_t > m_p10CqiRxed
Map of UE's DL CQI P01 received.
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
HARQ retx buffered.
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
Csched cell config.
void RefreshDlCqiMaps()
Refresh DL CQI maps function.
void DoDispose() override
Destructor implementation.
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
Estimate UL SNR function.
std::vector< RachListElement_s > m_rachList
RACH list.
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
Map of UE's DL CQI A30 received.
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
UL HARQ process DCI buffer.
std::map< uint16_t, uint32_t > m_ueCqiTimers
Map of UEs' timers on UL-CQI per RBG.
std::map< uint16_t, uint32_t > m_p10CqiTimers
Map of UE's timers on DL CQI P01 received.
void SetLteFfrSapProvider(LteFfrSapProvider *s) override
Set FFR SAP provider function.
FfMacCschedSapProvider * GetFfMacCschedSapProvider() override
Get FF MAC CSched SAP provider function.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmisson mode config update function.
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
UL HARQ process status.
uint32_t m_creditLimit
flow credit limit (byte)
void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Sched DL RLC buffer request function.
int m_debtLimit
flow debt limit (byte)
std::map< uint16_t, uint32_t > m_a30CqiTimers
Map of UE's timers on DL CQI A30 received.
uint8_t m_ulGrantMcs
MCS for UL grant (default 0)
void DoSchedUlNoiseInterferenceReq(const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
Sched UL noise interference request function.
void RefreshUlCqiMaps()
Refresh UL CQI maps function.
FfMacCschedSapProvider * m_cschedSapProvider
CSched SAP provider.
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
DL HARQ process status.
void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
Sched DL RACH info request function.
FfMacSchedSapProvider * m_schedSapProvider
sched SAP provider
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
DL HARQ process RLC PDU list buffer.
void DoSchedUlMacCtrlInfoReq(const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
Sched UL MAC control info request function.
void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
Sched UL CQI info request function.
void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
CSched LC release request function.
std::map< uint16_t, uint8_t > m_uesTxMode
txMode of the UEs
void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
Sched DL CQI info request function.
std::map< uint16_t, fdtbfqsFlowPerf_t > m_flowStatsDl
Map of UE statistics (per RNTI basis) in downlink.
FfMacSchedSapProvider * GetFfMacSchedSapProvider() override
Get FF MAC sched SAP provider function.
void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
CSched UE config request function.
FfMacSchedSapUser * m_schedSapUser
sched SAP user
void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
Csched cell config request function.
uint16_t m_nextRntiUl
RNTI of the next user to be served next scheduling in UL.
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
Map of previous allocated UE per RBG (used to retrieve info from UL-CQI)
unsigned int LcActivePerFlow(uint16_t rnti)
LC Active per flow function.
void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
CSched UE release request function.
void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
Sched UL SR info request function.
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
DL HARQ process timer.
FfMacCschedSapUser * m_cschedSapUser
Csched SAP user.
friend class MemberCschedSapProvider< FdTbfqFfMacScheduler >
allow MemberCschedSapProvider<FdTbfqFfMacScheduler> class friend access
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
Update UL RLC buffer info function.
int GetRbgSize(int dlbandwidth)
Get RBG size function.
void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
Sched UL trigger request function.
void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
Sched DL trigger request function.
bool m_harqOn
m_harqOn when false inhibit the HARQ mechanisms (by default active)
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.
Hold a signed integer type.
Definition: integer.h:45
static double fpS11dot3toDouble(uint16_t val)
Convert from fixed point S11.3 notation to double.
Definition: lte-common.cc:151
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Definition: lte-ffr-sap.h:40
virtual uint8_t GetTpc(uint16_t rnti)=0
GetTpc.
virtual std::vector< bool > GetAvailableUlRbg()=0
Get vector of available RB in UL for this Cell.
virtual void ReportUlCqiInfo(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)=0
ReportUlCqiInfo.
virtual bool IsUlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in UL.
virtual void ReportDlCqiInfo(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)=0
ReportDlCqiInfo.
virtual std::vector< bool > GetAvailableDlRbg()=0
Get vector of available RBG in DL for this Cell.
virtual uint16_t GetMinContinuousUlBandwidth()=0
Get the minimum continuous Ul bandwidth.
virtual bool IsDlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in DL.
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
Definition: lte-ffr-sap.h:140
Template for the implementation of the LteFfrSapUser as a member of an owner class of type C to which...
Definition: lte-ffr-sap.h:259
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
@ MS
millisecond
Definition: nstime.h:117
static uint8_t TxMode2LayerNum(uint8_t txMode)
Transmit mode 2 layer number.
Definition: lte-common.cc:203
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:930
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#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:86
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition: integer.h:46
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
#define HARQ_PERIOD
Definition: lte-common.h:30
#define SRS_CQI_RNTI_VSP
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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< UlDciListElement_s > UlHarqProcessesDciBuffer_t
UL HARQ process DCI buffer vector.
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
Vector of the 8 HARQ processes per UE.
@ SUCCESS
Definition: ff-mac-common.h:62
constexpr uint32_t HARQ_DL_TIMEOUT
HARQ DL timeout.
constexpr uint32_t HARQ_PROC_NUM
Number of HARQ processes.
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
DL HARQ process DCI buffer vector.
std::vector< uint8_t > UlHarqProcessesStatus_t
UL HARQ process status vector.
std::vector< uint8_t > DlHarqProcessesTimer_t
DL HARQ process timer vector.
static const int FdTbfqType0AllocationRbg[4]
FdTbfqType0AllocationRbg value array.
std::vector< uint8_t > DlHarqProcessesStatus_t
DL HARQ process status vector.
Definition: second.py:1
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.
Definition: ff-mac-common.h:93
std::vector< uint8_t > m_ndi
New data indicator.
uint8_t m_harqProcess
HARQ process.
uint32_t m_rbBitmap
RB bitmap.
Definition: ff-mac-common.h:95
std::vector< uint8_t > m_mcs
MCS.
Definition: ff-mac-common.h:99
uint8_t m_resAlloc
The type of resource allocation.
Definition: ff-mac-common.h:97
std::vector< uint16_t > m_tbsSize
The TBs size.
Definition: ff-mac-common.h:98
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:43
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_n2Dmrs
n2 DMRS
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.
Time flowStart
flow start time
int counter
the number of token borrow or given to token bank
uint32_t burstCredit
the maximum number of tokens connection i can borrow from the bank each time
int debtLimit
counter threshold that the flow cannot further borrow tokens from bank
uint32_t creditableThreshold
the flow cannot borrow token from bank until the number of token it has deposited to bank reaches thi...
uint64_t packetArrivalRate
packet arrival rate( byte/s)
uint32_t tokenPoolSize
current size of token pool (byte)
uint32_t maxTokenPoolSize
maximum size of token pool (byte)
uint64_t tokenGenerationRate
token generation rate ( byte/s )