A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tdtbfq-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("TdTbfqFfMacScheduler");
40
42static const int TdTbfqType0AllocationRbg[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(TdTbfqFfMacScheduler);
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::TdTbfqFfMacScheduler")
91 .SetGroupName("Lte")
92 .AddConstructor<TdTbfqFfMacScheduler>()
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 std::map<uint16_t, uint8_t>::iterator 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 std::map<uint16_t, tdtbfqsFlowPerf_t>::iterator it;
234 for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++)
235 {
236 it = m_flowStatsDl.find(params.m_rnti);
237
238 if (it == m_flowStatsDl.end())
239 {
240 uint64_t mbrDlInBytes =
241 params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl / 8; // byte/s
242 uint64_t mbrUlInBytes =
243 params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateUl / 8; // byte/s
244
245 tdtbfqsFlowPerf_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, tdtbfqsFlowPerf_t>(params.m_rnti, flowStatsDl));
257 tdtbfqsFlowPerf_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, tdtbfqsFlowPerf_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 m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
278 m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
279 }
280 }
281}
282
283void
286{
287 NS_LOG_FUNCTION(this);
288 for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++)
289 {
290 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
291 m_rlcBufferReq.begin();
292 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
293 while (it != m_rlcBufferReq.end())
294 {
295 if (((*it).first.m_rnti == params.m_rnti) &&
296 ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i)))
297 {
298 temp = it;
299 it++;
300 m_rlcBufferReq.erase(temp);
301 }
302 else
303 {
304 it++;
305 }
306 }
307 }
308}
309
310void
313{
314 NS_LOG_FUNCTION(this);
315
316 m_uesTxMode.erase(params.m_rnti);
317 m_dlHarqCurrentProcessId.erase(params.m_rnti);
318 m_dlHarqProcessesStatus.erase(params.m_rnti);
319 m_dlHarqProcessesTimer.erase(params.m_rnti);
320 m_dlHarqProcessesDciBuffer.erase(params.m_rnti);
321 m_dlHarqProcessesRlcPduListBuffer.erase(params.m_rnti);
322 m_ulHarqCurrentProcessId.erase(params.m_rnti);
323 m_ulHarqProcessesStatus.erase(params.m_rnti);
324 m_ulHarqProcessesDciBuffer.erase(params.m_rnti);
325 m_flowStatsDl.erase(params.m_rnti);
326 m_flowStatsUl.erase(params.m_rnti);
327 m_ceBsrRxed.erase(params.m_rnti);
328 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
329 m_rlcBufferReq.begin();
330 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
331 while (it != m_rlcBufferReq.end())
332 {
333 if ((*it).first.m_rnti == params.m_rnti)
334 {
335 temp = it;
336 it++;
337 m_rlcBufferReq.erase(temp);
338 }
339 else
340 {
341 it++;
342 }
343 }
344 if (m_nextRntiUl == params.m_rnti)
345 {
346 m_nextRntiUl = 0;
347 }
348}
349
350void
353{
354 NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity);
355 // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
356
357 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
358
359 LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity);
360
361 it = m_rlcBufferReq.find(flow);
362
363 if (it == m_rlcBufferReq.end())
364 {
365 m_rlcBufferReq.insert(
366 std::pair<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>(flow,
367 params));
368 }
369 else
370 {
371 (*it).second = params;
372 }
373}
374
375void
378{
379 NS_LOG_FUNCTION(this);
380 NS_FATAL_ERROR("method not implemented");
381}
382
383void
386{
387 NS_LOG_FUNCTION(this);
388 NS_FATAL_ERROR("method not implemented");
389}
390
391int
393{
394 for (int i = 0; i < 4; i++)
395 {
396 if (dlbandwidth < TdTbfqType0AllocationRbg[i])
397 {
398 return (i + 1);
399 }
400 }
401
402 return (-1);
403}
404
405unsigned int
407{
408 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
409 unsigned int lcActive = 0;
410 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
411 {
412 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) ||
413 ((*it).second.m_rlcRetransmissionQueueSize > 0) ||
414 ((*it).second.m_rlcStatusPduSize > 0)))
415 {
416 lcActive++;
417 }
418 if ((*it).first.m_rnti > rnti)
419 {
420 break;
421 }
422 }
423 return (lcActive);
424}
425
426bool
428{
429 NS_LOG_FUNCTION(this << rnti);
430
431 std::map<uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find(rnti);
432 if (it == m_dlHarqCurrentProcessId.end())
433 {
434 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
435 }
436 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
437 m_dlHarqProcessesStatus.find(rnti);
438 if (itStat == m_dlHarqProcessesStatus.end())
439 {
440 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
441 }
442 uint8_t i = (*it).second;
443 do
444 {
445 i = (i + 1) % HARQ_PROC_NUM;
446 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
447
448 return (*itStat).second.at(i) == 0;
449}
450
451uint8_t
453{
454 NS_LOG_FUNCTION(this << rnti);
455
456 if (!m_harqOn)
457 {
458 return (0);
459 }
460
461 std::map<uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find(rnti);
462 if (it == m_dlHarqCurrentProcessId.end())
463 {
464 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
465 }
466 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
467 m_dlHarqProcessesStatus.find(rnti);
468 if (itStat == m_dlHarqProcessesStatus.end())
469 {
470 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
471 }
472 uint8_t i = (*it).second;
473 do
474 {
475 i = (i + 1) % HARQ_PROC_NUM;
476 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
477 if ((*itStat).second.at(i) == 0)
478 {
479 (*it).second = i;
480 (*itStat).second.at(i) = 1;
481 }
482 else
483 {
484 NS_FATAL_ERROR("No HARQ process available for RNTI "
485 << rnti << " check before update with HarqProcessAvailability");
486 }
487
488 return ((*it).second);
489}
490
491void
493{
494 NS_LOG_FUNCTION(this);
495
496 std::map<uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
497 for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end();
498 itTimers++)
499 {
500 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
501 {
502 if ((*itTimers).second.at(i) == HARQ_DL_TIMEOUT)
503 {
504 // reset HARQ process
505
506 NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first);
507 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
508 m_dlHarqProcessesStatus.find((*itTimers).first);
509 if (itStat == m_dlHarqProcessesStatus.end())
510 {
511 NS_FATAL_ERROR("No Process Id Status found for this RNTI "
512 << (*itTimers).first);
513 }
514 (*itStat).second.at(i) = 0;
515 (*itTimers).second.at(i) = 0;
516 }
517 else
518 {
519 (*itTimers).second.at(i)++;
520 }
521 }
522 }
523}
524
525void
528{
529 NS_LOG_FUNCTION(this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
530 << (0xF & params.m_sfnSf));
531 // API generated by RLC for triggering the scheduling of a DL subframe
532
533 // evaluate the relative channel quality indicator for each UE per each RBG
534 // (since we are using allocation type 0 the small unit of allocation is RBG)
535 // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
536
538
540 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
541 std::map<uint16_t, std::vector<uint16_t>> allocationMap; // RBs map per RNTI
542 std::vector<bool> rbgMap; // global RBGs map
543 uint16_t rbgAllocatedNum = 0;
544 std::set<uint16_t> rntiAllocated;
545 rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false);
546
548 for (std::vector<bool>::iterator it = rbgMap.begin(); it != rbgMap.end(); it++)
549 {
550 if (*it)
551 {
552 rbgAllocatedNum++;
553 }
554 }
555
557
558 // update UL HARQ proc id
559 std::map<uint16_t, uint8_t>::iterator itProcId;
560 for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end();
561 itProcId++)
562 {
563 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
564 }
565
566 // RACH Allocation
567 std::vector<bool> ulRbMap;
568 ulRbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
570 uint8_t maxContinuousUlBandwidth = 0;
571 uint8_t tmpMinBandwidth = 0;
572 uint16_t ffrRbStartOffset = 0;
573 uint16_t tmpFfrRbStartOffset = 0;
574 uint16_t index = 0;
575
576 for (std::vector<bool>::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++)
577 {
578 if (*it)
579 {
580 if (tmpMinBandwidth > maxContinuousUlBandwidth)
581 {
582 maxContinuousUlBandwidth = tmpMinBandwidth;
583 ffrRbStartOffset = tmpFfrRbStartOffset;
584 }
585 tmpMinBandwidth = 0;
586 }
587 else
588 {
589 if (tmpMinBandwidth == 0)
590 {
591 tmpFfrRbStartOffset = index;
592 }
593 tmpMinBandwidth++;
594 }
595 index++;
596 }
597
598 if (tmpMinBandwidth > maxContinuousUlBandwidth)
599 {
600 maxContinuousUlBandwidth = tmpMinBandwidth;
601 ffrRbStartOffset = tmpFfrRbStartOffset;
602 }
603
605 uint16_t rbStart = 0;
606 rbStart = ffrRbStartOffset;
607 std::vector<RachListElement_s>::iterator itRach;
608 for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++)
609 {
611 (*itRach).m_estimatedSize,
612 " Default UL Grant MCS does not allow to send RACH messages");
614 newRar.m_rnti = (*itRach).m_rnti;
615 // DL-RACH Allocation
616 // Ideal: no needs of configuring m_dci
617 // UL-RACH Allocation
618 newRar.m_grant.m_rnti = newRar.m_rnti;
619 newRar.m_grant.m_mcs = m_ulGrantMcs;
620 uint16_t rbLen = 1;
621 uint16_t tbSizeBits = 0;
622 // find lowest TB size that fits UL grant estimated size
623 while ((tbSizeBits < (*itRach).m_estimatedSize) &&
624 (rbStart + rbLen < (ffrRbStartOffset + maxContinuousUlBandwidth)))
625 {
626 rbLen++;
627 tbSizeBits = m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, rbLen);
628 }
629 if (tbSizeBits < (*itRach).m_estimatedSize)
630 {
631 // no more allocation space: finish allocation
632 break;
633 }
634 newRar.m_grant.m_rbStart = rbStart;
635 newRar.m_grant.m_rbLen = rbLen;
636 newRar.m_grant.m_tbSize = tbSizeBits / 8;
637 newRar.m_grant.m_hopping = false;
638 newRar.m_grant.m_tpc = 0;
639 newRar.m_grant.m_cqiRequest = false;
640 newRar.m_grant.m_ulDelay = false;
641 NS_LOG_INFO(this << " UL grant allocated to RNTI " << (*itRach).m_rnti << " rbStart "
642 << rbStart << " rbLen " << rbLen << " MCS " << m_ulGrantMcs << " tbSize "
643 << newRar.m_grant.m_tbSize);
644 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
645 {
646 m_rachAllocationMap.at(i) = (*itRach).m_rnti;
647 }
648
649 if (m_harqOn)
650 {
651 // generate UL-DCI for HARQ retransmissions
652 UlDciListElement_s uldci;
653 uldci.m_rnti = newRar.m_rnti;
654 uldci.m_rbLen = rbLen;
655 uldci.m_rbStart = rbStart;
656 uldci.m_mcs = m_ulGrantMcs;
657 uldci.m_tbSize = tbSizeBits / 8;
658 uldci.m_ndi = 1;
659 uldci.m_cceIndex = 0;
660 uldci.m_aggrLevel = 1;
661 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
662 uldci.m_hopping = false;
663 uldci.m_n2Dmrs = 0;
664 uldci.m_tpc = 0; // no power control
665 uldci.m_cqiRequest = false; // only period CQI at this stage
666 uldci.m_ulIndex = 0; // TDD parameter
667 uldci.m_dai = 1; // TDD parameter
668 uldci.m_freqHopping = 0;
669 uldci.m_pdcchPowerOffset = 0; // not used
670
671 uint8_t harqId = 0;
672 std::map<uint16_t, uint8_t>::iterator itProcId;
673 itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
674 if (itProcId == m_ulHarqCurrentProcessId.end())
675 {
676 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
677 }
678 harqId = (*itProcId).second;
679 std::map<uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci =
681 if (itDci == m_ulHarqProcessesDciBuffer.end())
682 {
683 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
684 << uldci.m_rnti);
685 }
686 (*itDci).second.at(harqId) = uldci;
687 }
688
689 rbStart = rbStart + rbLen;
690 ret.m_buildRarList.push_back(newRar);
691 }
692 m_rachList.clear();
693
694 // Process DL HARQ feedback
696 // retrieve past HARQ retx buffered
697 if (!m_dlInfoListBuffered.empty())
698 {
699 if (!params.m_dlInfoList.empty())
700 {
701 NS_LOG_INFO(this << " Received DL-HARQ feedback");
703 params.m_dlInfoList.begin(),
704 params.m_dlInfoList.end());
705 }
706 }
707 else
708 {
709 if (!params.m_dlInfoList.empty())
710 {
711 m_dlInfoListBuffered = params.m_dlInfoList;
712 }
713 }
714 if (!m_harqOn)
715 {
716 // Ignore HARQ feedback
717 m_dlInfoListBuffered.clear();
718 }
719 std::vector<DlInfoListElement_s> dlInfoListUntxed;
720 for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++)
721 {
722 std::set<uint16_t>::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti);
723 if (itRnti != rntiAllocated.end())
724 {
725 // RNTI already allocated for retx
726 continue;
727 }
728 auto nLayers = m_dlInfoListBuffered.at(i).m_harqStatus.size();
729 std::vector<bool> retx;
730 NS_LOG_INFO(this << " Processing DLHARQ feedback");
731 if (nLayers == 1)
732 {
733 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
735 retx.push_back(false);
736 }
737 else
738 {
739 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
741 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(1) ==
743 }
744 if (retx.at(0) || retx.at(1))
745 {
746 // retrieve HARQ process information
747 uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti;
748 uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId;
749 NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
750 std::map<uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq =
752 if (itHarq == m_dlHarqProcessesDciBuffer.end())
753 {
754 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti);
755 }
756
757 DlDciListElement_s dci = (*itHarq).second.at(harqId);
758 int rv = 0;
759 if (dci.m_rv.size() == 1)
760 {
761 rv = dci.m_rv.at(0);
762 }
763 else
764 {
765 rv = (dci.m_rv.at(0) > dci.m_rv.at(1) ? dci.m_rv.at(0) : dci.m_rv.at(1));
766 }
767
768 if (rv == 3)
769 {
770 // maximum number of retx reached -> drop process
771 NS_LOG_INFO("Maximum number of retransmissions reached -> drop process");
772 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator it =
773 m_dlHarqProcessesStatus.find(rnti);
774 if (it == m_dlHarqProcessesStatus.end())
775 {
776 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
777 << m_dlInfoListBuffered.at(i).m_rnti);
778 }
779 (*it).second.at(harqId) = 0;
780 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
782 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
783 {
784 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
785 << m_dlInfoListBuffered.at(i).m_rnti);
786 }
787 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
788 {
789 (*itRlcPdu).second.at(k).at(harqId).clear();
790 }
791 continue;
792 }
793 // check the feasibility of retransmitting on the same RBGs
794 // translate the DCI to Spectrum framework
795 std::vector<int> dciRbg;
796 uint32_t mask = 0x1;
797 NS_LOG_INFO("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
798 for (int j = 0; j < 32; j++)
799 {
800 if (((dci.m_rbBitmap & mask) >> j) == 1)
801 {
802 dciRbg.push_back(j);
803 NS_LOG_INFO("\t" << j);
804 }
805 mask = (mask << 1);
806 }
807 bool free = true;
808 for (std::size_t j = 0; j < dciRbg.size(); j++)
809 {
810 if (rbgMap.at(dciRbg.at(j)))
811 {
812 free = false;
813 break;
814 }
815 }
816 if (free)
817 {
818 // use the same RBGs for the retx
819 // reserve RBGs
820 for (std::size_t j = 0; j < dciRbg.size(); j++)
821 {
822 rbgMap.at(dciRbg.at(j)) = true;
823 NS_LOG_INFO("RBG " << dciRbg.at(j) << " assigned");
824 rbgAllocatedNum++;
825 }
826
827 NS_LOG_INFO(this << " Send retx in the same RBGs");
828 }
829 else
830 {
831 // find RBGs for sending HARQ retx
832 uint8_t j = 0;
833 uint8_t rbgId = (dciRbg.at(dciRbg.size() - 1) + 1) % rbgNum;
834 uint8_t startRbg = dciRbg.at(dciRbg.size() - 1);
835 std::vector<bool> rbgMapCopy = rbgMap;
836 while ((j < dciRbg.size()) && (startRbg != rbgId))
837 {
838 if (!rbgMapCopy.at(rbgId))
839 {
840 rbgMapCopy.at(rbgId) = true;
841 dciRbg.at(j) = rbgId;
842 j++;
843 }
844 rbgId = (rbgId + 1) % rbgNum;
845 }
846 if (j == dciRbg.size())
847 {
848 // find new RBGs -> update DCI map
849 uint32_t rbgMask = 0;
850 for (std::size_t k = 0; k < dciRbg.size(); k++)
851 {
852 rbgMask = rbgMask + (0x1 << dciRbg.at(k));
853 rbgAllocatedNum++;
854 }
855 dci.m_rbBitmap = rbgMask;
856 rbgMap = rbgMapCopy;
857 NS_LOG_INFO(this << " Move retx in RBGs " << dciRbg.size());
858 }
859 else
860 {
861 // HARQ retx cannot be performed on this TTI -> store it
862 dlInfoListUntxed.push_back(m_dlInfoListBuffered.at(i));
863 NS_LOG_INFO(this << " No resource for this retx -> buffer it");
864 }
865 }
866 // retrieve RLC PDU list for retx TBsize and update DCI
868 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
870 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
871 {
872 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
873 }
874 for (std::size_t j = 0; j < nLayers; j++)
875 {
876 if (retx.at(j))
877 {
878 if (j >= dci.m_ndi.size())
879 {
880 // for avoiding errors in MIMO transient phases
881 dci.m_ndi.push_back(0);
882 dci.m_rv.push_back(0);
883 dci.m_mcs.push_back(0);
884 dci.m_tbsSize.push_back(0);
885 NS_LOG_INFO(this << " layer " << (uint16_t)j
886 << " no txed (MIMO transition)");
887 }
888 else
889 {
890 dci.m_ndi.at(j) = 0;
891 dci.m_rv.at(j)++;
892 (*itHarq).second.at(harqId).m_rv.at(j)++;
893 NS_LOG_INFO(this << " layer " << (uint16_t)j << " RV "
894 << (uint16_t)dci.m_rv.at(j));
895 }
896 }
897 else
898 {
899 // empty TB of layer j
900 dci.m_ndi.at(j) = 0;
901 dci.m_rv.at(j) = 0;
902 dci.m_mcs.at(j) = 0;
903 dci.m_tbsSize.at(j) = 0;
904 NS_LOG_INFO(this << " layer " << (uint16_t)j << " no retx");
905 }
906 }
907 for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++)
908 {
909 std::vector<RlcPduListElement_s> rlcPduListPerLc;
910 for (std::size_t j = 0; j < nLayers; j++)
911 {
912 if (retx.at(j))
913 {
914 if (j < dci.m_ndi.size())
915 {
916 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size "
917 << dci.m_tbsSize.at(j));
918 rlcPduListPerLc.push_back(
919 (*itRlcPdu).second.at(j).at(dci.m_harqProcess).at(k));
920 }
921 }
922 else
923 { // if no retx needed on layer j, push an RlcPduListElement_s object with
924 // m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
925 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at(j));
926 RlcPduListElement_s emptyElement;
927 emptyElement.m_logicalChannelIdentity = (*itRlcPdu)
928 .second.at(j)
929 .at(dci.m_harqProcess)
930 .at(k)
931 .m_logicalChannelIdentity;
932 emptyElement.m_size = 0;
933 rlcPduListPerLc.push_back(emptyElement);
934 }
935 }
936
937 if (!rlcPduListPerLc.empty())
938 {
939 newEl.m_rlcPduList.push_back(rlcPduListPerLc);
940 }
941 }
942 newEl.m_rnti = rnti;
943 newEl.m_dci = dci;
944 (*itHarq).second.at(harqId).m_rv = dci.m_rv;
945 // refresh timer
946 std::map<uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer =
947 m_dlHarqProcessesTimer.find(rnti);
948 if (itHarqTimer == m_dlHarqProcessesTimer.end())
949 {
950 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
951 }
952 (*itHarqTimer).second.at(harqId) = 0;
953 ret.m_buildDataList.push_back(newEl);
954 rntiAllocated.insert(rnti);
955 }
956 else
957 {
958 // update HARQ process status
959 NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti);
960 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator it =
962 if (it == m_dlHarqProcessesStatus.end())
963 {
964 NS_FATAL_ERROR("No info find in HARQ buffer for UE "
965 << m_dlInfoListBuffered.at(i).m_rnti);
966 }
967 (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0;
968 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
970 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
971 {
972 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
973 << m_dlInfoListBuffered.at(i).m_rnti);
974 }
975 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
976 {
977 (*itRlcPdu).second.at(k).at(m_dlInfoListBuffered.at(i).m_harqProcessId).clear();
978 }
979 }
980 }
981 m_dlInfoListBuffered.clear();
982 m_dlInfoListBuffered = dlInfoListUntxed;
983
984 if (rbgAllocatedNum == rbgNum)
985 {
986 // all the RBGs are already allocated -> exit
987 if (!ret.m_buildDataList.empty() || !ret.m_buildRarList.empty())
988 {
990 }
991 return;
992 }
993
994 // update token pool, counter and bank size
995 std::map<uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
996 for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++)
997 {
998 if ((*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize >
999 (*itStats).second.maxTokenPoolSize)
1000 {
1001 (*itStats).second.counter +=
1002 (*itStats).second.tokenGenerationRate / 1000 -
1003 ((*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize);
1004 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
1005 bankSize += (*itStats).second.tokenGenerationRate / 1000 -
1006 ((*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize);
1007 }
1008 else
1009 {
1010 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
1011 }
1012 }
1013
1014 // select UE with largest metric
1015 std::map<uint16_t, tdtbfqsFlowPerf_t>::iterator it;
1016 std::map<uint16_t, tdtbfqsFlowPerf_t>::iterator itMax = m_flowStatsDl.end();
1017 double metricMax = 0.0;
1018 bool firstRnti = true;
1019 for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++)
1020 {
1021 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).first);
1022 if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first)))
1023 {
1024 // UE already allocated for HARQ or without HARQ process available -> drop it
1025 if (itRnti != rntiAllocated.end())
1026 {
1027 NS_LOG_DEBUG(this << " RNTI discarded for HARQ tx" << (uint16_t)(*it).first);
1028 }
1029 if (!HarqProcessAvailability((*it).first))
1030 {
1031 NS_LOG_DEBUG(this << " RNTI discarded for HARQ id" << (uint16_t)(*it).first);
1032 }
1033 continue;
1034 }
1035
1036 // check first the channel conditions for this UE, if CQI!=0
1037 std::map<uint16_t, SbMeasResult_s>::iterator itCqi;
1038 itCqi = m_a30CqiRxed.find((*it).first);
1039 std::map<uint16_t, uint8_t>::iterator itTxMode;
1040 itTxMode = m_uesTxMode.find((*it).first);
1041 if (itTxMode == m_uesTxMode.end())
1042 {
1043 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first);
1044 }
1045 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
1046
1047 uint8_t cqiSum = 0;
1048 for (int k = 0; k < rbgNum; k++)
1049 {
1050 for (uint8_t j = 0; j < nLayer; j++)
1051 {
1052 if (itCqi == m_a30CqiRxed.end())
1053 {
1054 cqiSum += 1; // no info on this user -> lowest MCS
1055 }
1056 else
1057 {
1058 cqiSum += (*itCqi).second.m_higherLayerSelected.at(k).m_sbCqi.at(j);
1059 }
1060 }
1061 }
1062
1063 if (cqiSum == 0)
1064 {
1065 NS_LOG_INFO("Skip this flow, CQI==0, rnti:" << (*it).first);
1066 continue;
1067 }
1068
1069 /*
1070 if (LcActivePerFlow ((*it).first) == 0)
1071 {
1072 continue;
1073 }
1074 */
1075
1076 double metric =
1077 (((double)(*it).second.counter) / ((double)(*it).second.tokenGenerationRate));
1078
1079 if (firstRnti)
1080 {
1081 metricMax = metric;
1082 itMax = it;
1083 firstRnti = false;
1084 continue;
1085 }
1086 if (metric > metricMax)
1087 {
1088 metricMax = metric;
1089 itMax = it;
1090 }
1091 } // end for m_flowStatsDl
1092
1093 if (itMax == m_flowStatsDl.end())
1094 {
1095 // all UEs are allocated RBG or all UEs already allocated for HARQ or without HARQ process
1096 // available
1097 return;
1098 }
1099 else
1100 {
1101 // assign all RBGs to this UE
1102 std::vector<uint16_t> tempMap;
1103 for (int i = 0; i < rbgNum; i++)
1104 {
1105 if (rbgMap.at(i))
1106 { // this RBG is allocated in RACH procedure
1107 continue;
1108 }
1109
1110 if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*itMax).first))
1111 {
1112 continue;
1113 }
1114
1115 tempMap.push_back(i);
1116 rbgMap.at(i) = true;
1117 }
1118 if (!tempMap.empty())
1119 {
1120 allocationMap.insert(
1121 std::pair<uint16_t, std::vector<uint16_t>>((*itMax).first, tempMap));
1122 }
1123 }
1124
1125 // generate the transmission opportunities by grouping the RBGs of the same RNTI and
1126 // creating the correspondent DCIs
1127 std::map<uint16_t, std::vector<uint16_t>>::iterator itMap = allocationMap.begin();
1128 while (itMap != allocationMap.end())
1129 {
1130 // create new BuildDataListElement_s for this LC
1132 newEl.m_rnti = (*itMap).first;
1133 // create the DlDciListElement_s
1134 DlDciListElement_s newDci;
1135 newDci.m_rnti = (*itMap).first;
1136 newDci.m_harqProcess = UpdateHarqProcessId((*itMap).first);
1137
1138 uint16_t lcActives = LcActivePerFlow((*itMap).first);
1139 NS_LOG_INFO(this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
1140 if (lcActives == 0)
1141 {
1142 // Set to max value, to avoid divide by 0 below
1143 lcActives = (uint16_t)65535; // UINT16_MAX;
1144 }
1145 uint16_t RgbPerRnti = (*itMap).second.size();
1146 std::map<uint16_t, SbMeasResult_s>::iterator itCqi;
1147 itCqi = m_a30CqiRxed.find((*itMap).first);
1148 std::map<uint16_t, uint8_t>::iterator itTxMode;
1149 itTxMode = m_uesTxMode.find((*itMap).first);
1150 if (itTxMode == m_uesTxMode.end())
1151 {
1152 NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first);
1153 }
1154 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
1155 std::vector<uint8_t> worstCqi(2, 15);
1156 if (itCqi != m_a30CqiRxed.end())
1157 {
1158 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1159 {
1160 if ((*itCqi).second.m_higherLayerSelected.size() > (*itMap).second.at(k))
1161 {
1162 for (uint8_t j = 0; j < nLayer; j++)
1163 {
1164 if ((*itCqi)
1165 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1166 .m_sbCqi.size() > j)
1167 {
1168 if (((*itCqi)
1169 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1170 .m_sbCqi.at(j)) < worstCqi.at(j))
1171 {
1172 worstCqi.at(j) =
1173 ((*itCqi)
1174 .second.m_higherLayerSelected.at((*itMap).second.at(k))
1175 .m_sbCqi.at(j));
1176 }
1177 }
1178 else
1179 {
1180 // no CQI for this layer of this suband -> worst one
1181 worstCqi.at(j) = 1;
1182 }
1183 }
1184 }
1185 else
1186 {
1187 for (uint8_t j = 0; j < nLayer; j++)
1188 {
1189 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1190 }
1191 }
1192 }
1193 }
1194 else
1195 {
1196 for (uint8_t j = 0; j < nLayer; j++)
1197 {
1198 worstCqi.at(j) = 1; // try with lowest MCS in RBG with no info on channel
1199 }
1200 }
1201 uint32_t bytesTxed = 0;
1202 for (uint8_t j = 0; j < nLayer; j++)
1203 {
1204 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi(worstCqi.at(j)));
1205 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(j), RgbPerRnti * rbgSize) /
1206 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
1207 newDci.m_tbsSize.push_back(tbSize);
1208 bytesTxed += tbSize;
1209 }
1210
1211 newDci.m_resAlloc = 0; // only allocation type 0 at this stage
1212 newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
1213 uint32_t rbgMask = 0;
1214 for (std::size_t k = 0; k < (*itMap).second.size(); k++)
1215 {
1216 rbgMask = rbgMask + (0x1 << (*itMap).second.at(k));
1217 NS_LOG_INFO(this << " Allocated RBG " << (*itMap).second.at(k));
1218 }
1219 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1220
1221 // create the rlc PDUs -> equally divide resources among actives LCs
1222 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator
1223 itBufReq;
1224 for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++)
1225 {
1226 if (((*itBufReq).first.m_rnti == (*itMap).first) &&
1227 (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) ||
1228 ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0) ||
1229 ((*itBufReq).second.m_rlcStatusPduSize > 0)))
1230 {
1231 std::vector<RlcPduListElement_s> newRlcPduLe;
1232 for (uint8_t j = 0; j < nLayer; j++)
1233 {
1234 RlcPduListElement_s newRlcEl;
1235 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1236 newRlcEl.m_size = newDci.m_tbsSize.at(j) / lcActives;
1237 NS_LOG_INFO(this << " LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
1238 << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
1239 newRlcPduLe.push_back(newRlcEl);
1241 newRlcEl.m_logicalChannelIdentity,
1242 newRlcEl.m_size);
1243 if (m_harqOn)
1244 {
1245 // store RLC PDU list for HARQ
1246 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
1247 m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first);
1248 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1249 {
1250 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1251 << (*itMap).first);
1252 }
1253 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1254 }
1255 }
1256 newEl.m_rlcPduList.push_back(newRlcPduLe);
1257 }
1258 if ((*itBufReq).first.m_rnti > (*itMap).first)
1259 {
1260 break;
1261 }
1262 }
1263 for (uint8_t j = 0; j < nLayer; j++)
1264 {
1265 newDci.m_ndi.push_back(1);
1266 newDci.m_rv.push_back(0);
1267 }
1268
1269 newDci.m_tpc = m_ffrSapProvider->GetTpc((*itMap).first);
1270
1271 newEl.m_dci = newDci;
1272
1273 if (m_harqOn)
1274 {
1275 // store DCI for HARQ
1276 std::map<uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci =
1278 if (itDci == m_dlHarqProcessesDciBuffer.end())
1279 {
1280 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1281 << newEl.m_rnti);
1282 }
1283 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1284 // refresh timer
1285 std::map<uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer =
1286 m_dlHarqProcessesTimer.find(newEl.m_rnti);
1287 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1288 {
1289 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1290 }
1291 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1292 }
1293
1294 // update UE stats
1295 if (bytesTxed <= (*itMax).second.tokenPoolSize)
1296 {
1297 (*itMax).second.tokenPoolSize -= bytesTxed;
1298 }
1299 else
1300 {
1301 (*itMax).second.counter =
1302 (*itMax).second.counter - (bytesTxed - (*itMax).second.tokenPoolSize);
1303 (*itMax).second.tokenPoolSize = 0;
1304 if (bankSize <= (bytesTxed - (*itMax).second.tokenPoolSize))
1305 {
1306 bankSize = 0;
1307 }
1308 else
1309 {
1310 bankSize = bankSize - (bytesTxed - (*itMax).second.tokenPoolSize);
1311 }
1312 }
1313
1314 // ...more parameters -> ignored in this version
1315
1316 ret.m_buildDataList.push_back(newEl);
1317
1318 itMap++;
1319 } // end while allocation
1320 ret.m_nrOfPdcchOfdmSymbols = 1;
1321
1323}
1324
1325void
1328{
1329 NS_LOG_FUNCTION(this);
1330
1331 m_rachList = params.m_rachList;
1332}
1333
1334void
1337{
1338 NS_LOG_FUNCTION(this);
1340
1341 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1342 {
1343 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1344 {
1345 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1346 << " reported");
1347 std::map<uint16_t, uint8_t>::iterator it;
1348 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1349 it = m_p10CqiRxed.find(rnti);
1350 if (it == m_p10CqiRxed.end())
1351 {
1352 // create the new entry
1353 m_p10CqiRxed.insert(std::pair<uint16_t, uint8_t>(
1354 rnti,
1355 params.m_cqiList.at(i).m_wbCqi.at(0))); // only codeword 0 at this stage (SISO)
1356 // generate correspondent timer
1357 m_p10CqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
1358 }
1359 else
1360 {
1361 // update the CQI value and refresh correspondent timer
1362 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1363 // update correspondent timer
1364 std::map<uint16_t, uint32_t>::iterator itTimers;
1365 itTimers = m_p10CqiTimers.find(rnti);
1366 (*itTimers).second = m_cqiTimersThreshold;
1367 }
1368 }
1369 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1370 {
1371 // subband CQI reporting high layer configured
1372 std::map<uint16_t, SbMeasResult_s>::iterator it;
1373 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1374 it = m_a30CqiRxed.find(rnti);
1375 if (it == m_a30CqiRxed.end())
1376 {
1377 // create the new entry
1378 m_a30CqiRxed.insert(
1379 std::pair<uint16_t, SbMeasResult_s>(rnti,
1380 params.m_cqiList.at(i).m_sbMeasResult));
1381 m_a30CqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
1382 }
1383 else
1384 {
1385 // update the CQI value and refresh correspondent timer
1386 (*it).second = params.m_cqiList.at(i).m_sbMeasResult;
1387 std::map<uint16_t, uint32_t>::iterator itTimers;
1388 itTimers = m_a30CqiTimers.find(rnti);
1389 (*itTimers).second = m_cqiTimersThreshold;
1390 }
1391 }
1392 else
1393 {
1394 NS_LOG_ERROR(this << " CQI type unknown");
1395 }
1396 }
1397}
1398
1399double
1400TdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb)
1401{
1402 std::map<uint16_t, std::vector<double>>::iterator itCqi = m_ueCqi.find(rnti);
1403 if (itCqi == m_ueCqi.end())
1404 {
1405 // no cqi info about this UE
1406 return (NO_SINR);
1407 }
1408 else
1409 {
1410 // take the average SINR value among the available
1411 double sinrSum = 0;
1412 unsigned int sinrNum = 0;
1413 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1414 {
1415 double sinr = (*itCqi).second.at(i);
1416 if (sinr != NO_SINR)
1417 {
1418 sinrSum += sinr;
1419 sinrNum++;
1420 }
1421 }
1422 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1423 // store the value
1424 (*itCqi).second.at(rb) = estimatedSinr;
1425 return (estimatedSinr);
1426 }
1427}
1428
1429void
1432{
1433 NS_LOG_FUNCTION(this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
1434 << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size());
1435
1438
1439 // Generate RBs map
1441 std::vector<bool> rbMap;
1442 uint16_t rbAllocatedNum = 0;
1443 std::set<uint16_t> rntiAllocated;
1444 std::vector<uint16_t> rbgAllocationMap;
1445 // update with RACH allocation map
1446 rbgAllocationMap = m_rachAllocationMap;
1447 // rbgAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1448 m_rachAllocationMap.clear();
1450
1451 rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false);
1452
1454
1455 for (std::vector<bool>::iterator it = rbMap.begin(); it != rbMap.end(); it++)
1456 {
1457 if (*it)
1458 {
1459 rbAllocatedNum++;
1460 }
1461 }
1462
1463 uint8_t minContinuousUlBandwidth = m_ffrSapProvider->GetMinContinuousUlBandwidth();
1464 uint8_t ffrUlBandwidth = m_cschedCellConfig.m_ulBandwidth - rbAllocatedNum;
1465
1466 // remove RACH allocation
1467 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1468 {
1469 if (rbgAllocationMap.at(i) != 0)
1470 {
1471 rbMap.at(i) = true;
1472 NS_LOG_DEBUG(this << " Allocated for RACH " << i);
1473 }
1474 }
1475
1476 if (m_harqOn)
1477 {
1478 // Process UL HARQ feedback
1479 for (std::size_t i = 0; i < params.m_ulInfoList.size(); i++)
1480 {
1481 if (params.m_ulInfoList.at(i).m_receptionStatus == UlInfoListElement_s::NotOk)
1482 {
1483 // retx correspondent block: retrieve the UL-DCI
1484 uint16_t rnti = params.m_ulInfoList.at(i).m_rnti;
1485 std::map<uint16_t, uint8_t>::iterator itProcId =
1486 m_ulHarqCurrentProcessId.find(rnti);
1487 if (itProcId == m_ulHarqCurrentProcessId.end())
1488 {
1489 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1490 }
1491 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1492 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId
1493 << " i " << i << " size " << params.m_ulInfoList.size());
1494 std::map<uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq =
1495 m_ulHarqProcessesDciBuffer.find(rnti);
1496 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1497 {
1498 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1499 continue;
1500 }
1501 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1502 std::map<uint16_t, UlHarqProcessesStatus_t>::iterator itStat =
1503 m_ulHarqProcessesStatus.find(rnti);
1504 if (itStat == m_ulHarqProcessesStatus.end())
1505 {
1506 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1507 }
1508 if ((*itStat).second.at(harqId) >= 3)
1509 {
1510 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1511 continue;
1512 }
1513 bool free = true;
1514 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1515 {
1516 if (rbMap.at(j))
1517 {
1518 free = false;
1519 NS_LOG_INFO(this << " BUSY " << j);
1520 }
1521 }
1522 if (free)
1523 {
1524 // retx on the same RBs
1525 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1526 {
1527 rbMap.at(j) = true;
1528 rbgAllocationMap.at(j) = dci.m_rnti;
1529 NS_LOG_INFO("\tRB " << j);
1530 rbAllocatedNum++;
1531 }
1532 NS_LOG_INFO(this << " Send retx in the same RBs " << (uint16_t)dci.m_rbStart
1533 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1534 << (*itStat).second.at(harqId) + 1);
1535 }
1536 else
1537 {
1538 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1539 continue;
1540 }
1541 dci.m_ndi = 0;
1542 // Update HARQ buffers with new HarqId
1543 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1544 (*itStat).second.at(harqId) = 0;
1545 (*itHarq).second.at((*itProcId).second) = dci;
1546 ret.m_dciList.push_back(dci);
1547 rntiAllocated.insert(dci.m_rnti);
1548 }
1549 else
1550 {
1551 NS_LOG_INFO(this << " HARQ-ACK feedback from RNTI "
1552 << params.m_ulInfoList.at(i).m_rnti);
1553 }
1554 }
1555 }
1556
1557 std::map<uint16_t, uint32_t>::iterator it;
1558 int nflows = 0;
1559
1560 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1561 {
1562 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).first);
1563 // select UEs with queues not empty and not yet allocated for HARQ
1564 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1565 {
1566 nflows++;
1567 }
1568 }
1569
1570 if (nflows == 0)
1571 {
1572 if (!ret.m_dciList.empty())
1573 {
1574 m_allocationMaps.insert(
1575 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
1577 }
1578
1579 return; // no flows to be scheduled
1580 }
1581
1582 // Divide the remaining resources equally among the active users starting from the subsequent
1583 // one served last scheduling trigger
1584 uint16_t tempRbPerFlow = (ffrUlBandwidth) / (nflows + rntiAllocated.size());
1585 uint16_t rbPerFlow =
1586 (minContinuousUlBandwidth < tempRbPerFlow) ? minContinuousUlBandwidth : tempRbPerFlow;
1587
1588 if (rbPerFlow < 3)
1589 {
1590 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1591 // >= 7 bytes
1592 }
1593 int rbAllocated = 0;
1594
1595 std::map<uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1596 if (m_nextRntiUl != 0)
1597 {
1598 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1599 {
1600 if ((*it).first == m_nextRntiUl)
1601 {
1602 break;
1603 }
1604 }
1605 if (it == m_ceBsrRxed.end())
1606 {
1607 NS_LOG_ERROR(this << " no user found");
1608 }
1609 }
1610 else
1611 {
1612 it = m_ceBsrRxed.begin();
1613 m_nextRntiUl = (*it).first;
1614 }
1615 do
1616 {
1617 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).first);
1618 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1619 {
1620 // UE already allocated for UL-HARQ -> skip it
1621 NS_LOG_DEBUG(this << " UE already allocated in HARQ -> discarded, RNTI "
1622 << (*it).first);
1623 it++;
1624 if (it == m_ceBsrRxed.end())
1625 {
1626 // restart from the first
1627 it = m_ceBsrRxed.begin();
1628 }
1629 continue;
1630 }
1631 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1632 {
1633 // limit to physical resources last resource assignment
1634 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1635 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1636 if (rbPerFlow < 3)
1637 {
1638 // terminate allocation
1639 rbPerFlow = 0;
1640 }
1641 }
1642
1643 rbAllocated = 0;
1644 UlDciListElement_s uldci;
1645 uldci.m_rnti = (*it).first;
1646 uldci.m_rbLen = rbPerFlow;
1647 bool allocated = false;
1648 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1649 << " flows " << nflows);
1650 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1651 (rbPerFlow != 0))
1652 {
1653 // check availability
1654 bool free = true;
1655 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1656 {
1657 if (rbMap.at(j))
1658 {
1659 free = false;
1660 break;
1661 }
1662 if (!m_ffrSapProvider->IsUlRbgAvailableForUe(j, (*it).first))
1663 {
1664 free = false;
1665 break;
1666 }
1667 }
1668 if (free)
1669 {
1670 NS_LOG_INFO(this << "RNTI: " << (*it).first << " RB Allocated " << rbAllocated
1671 << " rbPerFlow " << rbPerFlow << " flows " << nflows);
1672 uldci.m_rbStart = rbAllocated;
1673
1674 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1675 {
1676 rbMap.at(j) = true;
1677 // store info on allocation for managing ul-cqi interpretation
1678 rbgAllocationMap.at(j) = (*it).first;
1679 }
1680 rbAllocated += rbPerFlow;
1681 allocated = true;
1682 break;
1683 }
1684 rbAllocated++;
1685 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1686 {
1687 // limit to physical resources last resource assignment
1688 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1689 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1690 if (rbPerFlow < 3)
1691 {
1692 // terminate allocation
1693 rbPerFlow = 0;
1694 }
1695 }
1696 }
1697 if (!allocated)
1698 {
1699 // unable to allocate new resource: finish scheduling
1700 // m_nextRntiUl = (*it).first;
1701 // if (ret.m_dciList.size () > 0)
1702 // {
1703 // m_schedSapUser->SchedUlConfigInd (ret);
1704 // }
1705 // m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> >
1706 // (params.m_sfnSf, rbgAllocationMap)); return;
1707 break;
1708 }
1709
1710 std::map<uint16_t, std::vector<double>>::iterator itCqi = m_ueCqi.find((*it).first);
1711 int cqi = 0;
1712 if (itCqi == m_ueCqi.end())
1713 {
1714 // no cqi info about this UE
1715 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1716 }
1717 else
1718 {
1719 // take the lowest CQI value (worst RB)
1720 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1721 "CQI of RNTI = " << (*it).first << " has expired");
1722 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1723 if (minSinr == NO_SINR)
1724 {
1725 minSinr = EstimateUlSinr((*it).first, uldci.m_rbStart);
1726 }
1727 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1728 {
1729 double sinr = (*itCqi).second.at(i);
1730 if (sinr == NO_SINR)
1731 {
1732 sinr = EstimateUlSinr((*it).first, i);
1733 }
1734 if (sinr < minSinr)
1735 {
1736 minSinr = sinr;
1737 }
1738 }
1739
1740 // translate SINR -> cqi: WILD ACK: same as DL
1741 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1742 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1743 if (cqi == 0)
1744 {
1745 it++;
1746 if (it == m_ceBsrRxed.end())
1747 {
1748 // restart from the first
1749 it = m_ceBsrRxed.begin();
1750 }
1751 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1752 // remove UE from allocation map
1753 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1754 {
1755 rbgAllocationMap.at(i) = 0;
1756 }
1757 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1758 }
1759 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1760 }
1761
1762 uldci.m_tbSize = (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8);
1764 uldci.m_ndi = 1;
1765 uldci.m_cceIndex = 0;
1766 uldci.m_aggrLevel = 1;
1767 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1768 uldci.m_hopping = false;
1769 uldci.m_n2Dmrs = 0;
1770 uldci.m_tpc = 0; // no power control
1771 uldci.m_cqiRequest = false; // only period CQI at this stage
1772 uldci.m_ulIndex = 0; // TDD parameter
1773 uldci.m_dai = 1; // TDD parameter
1774 uldci.m_freqHopping = 0;
1775 uldci.m_pdcchPowerOffset = 0; // not used
1776 ret.m_dciList.push_back(uldci);
1777 // store DCI for HARQ_PERIOD
1778 uint8_t harqId = 0;
1779 if (m_harqOn)
1780 {
1781 std::map<uint16_t, uint8_t>::iterator itProcId;
1782 itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1783 if (itProcId == m_ulHarqCurrentProcessId.end())
1784 {
1785 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
1786 }
1787 harqId = (*itProcId).second;
1788 std::map<uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci =
1790 if (itDci == m_ulHarqProcessesDciBuffer.end())
1791 {
1792 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
1793 << uldci.m_rnti);
1794 }
1795 (*itDci).second.at(harqId) = uldci;
1796 // Update HARQ process status (RV 0)
1797 std::map<uint16_t, UlHarqProcessesStatus_t>::iterator itStat =
1798 m_ulHarqProcessesStatus.find(uldci.m_rnti);
1799 if (itStat == m_ulHarqProcessesStatus.end())
1800 {
1801 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
1802 << uldci.m_rnti);
1803 }
1804 (*itStat).second.at(harqId) = 0;
1805 }
1806
1807 NS_LOG_INFO(this << " UE Allocation RNTI " << (*it).first << " startPRB "
1808 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
1809 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
1810 << uldci.m_tbSize << " RbAlloc " << rbAllocated << " harqId "
1811 << (uint16_t)harqId);
1812
1813 it++;
1814 if (it == m_ceBsrRxed.end())
1815 {
1816 // restart from the first
1817 it = m_ceBsrRxed.begin();
1818 }
1819 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1820 {
1821 // Stop allocation: no more PRBs
1822 m_nextRntiUl = (*it).first;
1823 break;
1824 }
1825 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
1826
1827 m_allocationMaps.insert(
1828 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
1830}
1831
1832void
1835{
1836 NS_LOG_FUNCTION(this);
1837}
1838
1839void
1842{
1843 NS_LOG_FUNCTION(this);
1844}
1845
1846void
1849{
1850 NS_LOG_FUNCTION(this);
1851
1852 std::map<uint16_t, uint32_t>::iterator it;
1853
1854 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
1855 {
1856 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
1857 {
1858 // buffer status report
1859 // note that this scheduler does not differentiate the
1860 // allocation according to which LCGs have more/less bytes
1861 // to send.
1862 // Hence the BSR of different LCGs are just summed up to get
1863 // a total queue size that is used for allocation purposes.
1864
1865 uint32_t buffer = 0;
1866 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1867 {
1868 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
1869 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
1870 }
1871
1872 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
1873 NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer);
1874 it = m_ceBsrRxed.find(rnti);
1875 if (it == m_ceBsrRxed.end())
1876 {
1877 // create the new entry
1878 m_ceBsrRxed.insert(std::pair<uint16_t, uint32_t>(rnti, buffer));
1879 }
1880 else
1881 {
1882 // update the buffer size value
1883 (*it).second = buffer;
1884 }
1885 }
1886 }
1887}
1888
1889void
1892{
1893 NS_LOG_FUNCTION(this);
1894 // retrieve the allocation for this subframe
1895 switch (m_ulCqiFilter)
1896 {
1898 // filter all the CQIs that are not SRS based
1899 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1900 {
1901 return;
1902 }
1903 }
1904 break;
1906 // filter all the CQIs that are not SRS based
1907 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1908 {
1909 return;
1910 }
1911 }
1912 break;
1913 default:
1914 NS_FATAL_ERROR("Unknown UL CQI type");
1915 }
1916
1917 switch (params.m_ulCqi.m_type)
1918 {
1919 case UlCqi_s::PUSCH: {
1920 std::map<uint16_t, std::vector<uint16_t>>::iterator itMap;
1921 std::map<uint16_t, std::vector<double>>::iterator itCqi;
1922 NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4)
1923 << " subframe no. " << (0xF & params.m_sfnSf));
1924 itMap = m_allocationMaps.find(params.m_sfnSf);
1925 if (itMap == m_allocationMaps.end())
1926 {
1927 return;
1928 }
1929 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
1930 {
1931 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1932 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
1933 itCqi = m_ueCqi.find((*itMap).second.at(i));
1934 if (itCqi == m_ueCqi.end())
1935 {
1936 // create a new entry
1937 std::vector<double> newCqi;
1938 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1939 {
1940 if (i == j)
1941 {
1942 newCqi.push_back(sinr);
1943 }
1944 else
1945 {
1946 // initialize with NO_SINR value.
1947 newCqi.push_back(NO_SINR);
1948 }
1949 }
1950 m_ueCqi.insert(
1951 std::pair<uint16_t, std::vector<double>>((*itMap).second.at(i), newCqi));
1952 // generate correspondent timer
1953 m_ueCqiTimers.insert(
1954 std::pair<uint16_t, uint32_t>((*itMap).second.at(i), m_cqiTimersThreshold));
1955 }
1956 else
1957 {
1958 // update the value
1959 (*itCqi).second.at(i) = sinr;
1960 NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR "
1961 << sinr);
1962 // update correspondent timer
1963 std::map<uint16_t, uint32_t>::iterator itTimers;
1964 itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
1965 (*itTimers).second = m_cqiTimersThreshold;
1966 }
1967 }
1968 // remove obsolete info on allocation
1969 m_allocationMaps.erase(itMap);
1970 }
1971 break;
1972 case UlCqi_s::SRS: {
1973 // get the RNTI from vendor specific parameters
1974 uint16_t rnti = 0;
1975 NS_ASSERT(!params.m_vendorSpecificList.empty());
1976 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
1977 {
1978 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
1979 {
1980 Ptr<SrsCqiRntiVsp> vsp =
1981 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
1982 rnti = vsp->GetRnti();
1983 }
1984 }
1985 std::map<uint16_t, std::vector<double>>::iterator itCqi;
1986 itCqi = m_ueCqi.find(rnti);
1987 if (itCqi == m_ueCqi.end())
1988 {
1989 // create a new entry
1990 std::vector<double> newCqi;
1991 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1992 {
1993 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1994 newCqi.push_back(sinr);
1995 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
1996 << sinr);
1997 }
1998 m_ueCqi.insert(std::pair<uint16_t, std::vector<double>>(rnti, newCqi));
1999 // generate correspondent timer
2000 m_ueCqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
2001 }
2002 else
2003 {
2004 // update the values
2005 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
2006 {
2007 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
2008 (*itCqi).second.at(j) = sinr;
2009 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
2010 << sinr);
2011 }
2012 // update correspondent timer
2013 std::map<uint16_t, uint32_t>::iterator itTimers;
2014 itTimers = m_ueCqiTimers.find(rnti);
2015 (*itTimers).second = m_cqiTimersThreshold;
2016 }
2017 }
2018 break;
2019 case UlCqi_s::PUCCH_1:
2020 case UlCqi_s::PUCCH_2:
2021 case UlCqi_s::PRACH: {
2022 NS_FATAL_ERROR("TdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2023 }
2024 break;
2025 default:
2026 NS_FATAL_ERROR("Unknown type of UL-CQI");
2027 }
2028}
2029
2030void
2032{
2033 // refresh DL CQI P01 Map
2034 std::map<uint16_t, uint32_t>::iterator itP10 = m_p10CqiTimers.begin();
2035 while (itP10 != m_p10CqiTimers.end())
2036 {
2037 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
2038 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2039 if ((*itP10).second == 0)
2040 {
2041 // delete correspondent entries
2042 std::map<uint16_t, uint8_t>::iterator itMap = m_p10CqiRxed.find((*itP10).first);
2043 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
2044 " Does not find CQI report for user " << (*itP10).first);
2045 NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first);
2046 m_p10CqiRxed.erase(itMap);
2047 std::map<uint16_t, uint32_t>::iterator temp = itP10;
2048 itP10++;
2049 m_p10CqiTimers.erase(temp);
2050 }
2051 else
2052 {
2053 (*itP10).second--;
2054 itP10++;
2055 }
2056 }
2057
2058 // refresh DL CQI A30 Map
2059 std::map<uint16_t, uint32_t>::iterator itA30 = m_a30CqiTimers.begin();
2060 while (itA30 != m_a30CqiTimers.end())
2061 {
2062 NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is "
2063 << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2064 if ((*itA30).second == 0)
2065 {
2066 // delete correspondent entries
2067 std::map<uint16_t, SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find((*itA30).first);
2068 NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(),
2069 " Does not find CQI report for user " << (*itA30).first);
2070 NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first);
2071 m_a30CqiRxed.erase(itMap);
2072 std::map<uint16_t, uint32_t>::iterator temp = itA30;
2073 itA30++;
2074 m_a30CqiTimers.erase(temp);
2075 }
2076 else
2077 {
2078 (*itA30).second--;
2079 itA30++;
2080 }
2081 }
2082}
2083
2084void
2086{
2087 // refresh UL CQI Map
2088 std::map<uint16_t, uint32_t>::iterator itUl = m_ueCqiTimers.begin();
2089 while (itUl != m_ueCqiTimers.end())
2090 {
2091 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
2092 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
2093 if ((*itUl).second == 0)
2094 {
2095 // delete correspondent entries
2096 std::map<uint16_t, std::vector<double>>::iterator itMap = m_ueCqi.find((*itUl).first);
2097 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
2098 " Does not find CQI report for user " << (*itUl).first);
2099 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
2100 (*itMap).second.clear();
2101 m_ueCqi.erase(itMap);
2102 std::map<uint16_t, uint32_t>::iterator temp = itUl;
2103 itUl++;
2104 m_ueCqiTimers.erase(temp);
2105 }
2106 else
2107 {
2108 (*itUl).second--;
2109 itUl++;
2110 }
2111 }
2112}
2113
2114void
2115TdTbfqFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
2116{
2117 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2118 LteFlowId_t flow(rnti, lcid);
2119 it = m_rlcBufferReq.find(flow);
2120 if (it != m_rlcBufferReq.end())
2121 {
2122 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
2123 << (*it).second.m_rlcTransmissionQueueSize << " retxqueue "
2124 << (*it).second.m_rlcRetransmissionQueueSize << " status "
2125 << (*it).second.m_rlcStatusPduSize << " decrease " << size);
2126 // Update queues: RLC tx order Status, ReTx, Tx
2127 // Update status queue
2128 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2129 {
2130 (*it).second.m_rlcStatusPduSize = 0;
2131 }
2132 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) &&
2133 (size >= (*it).second.m_rlcRetransmissionQueueSize))
2134 {
2135 (*it).second.m_rlcRetransmissionQueueSize = 0;
2136 }
2137 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2138 {
2139 uint32_t rlcOverhead;
2140 if (lcid == 1)
2141 {
2142 // for SRB1 (using RLC AM) it's better to
2143 // overestimate RLC overhead rather than
2144 // underestimate it and risk unneeded
2145 // segmentation which increases delay
2146 rlcOverhead = 4;
2147 }
2148 else
2149 {
2150 // minimum RLC overhead due to header
2151 rlcOverhead = 2;
2152 }
2153 // update transmission queue
2154 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2155 {
2156 (*it).second.m_rlcTransmissionQueueSize = 0;
2157 }
2158 else
2159 {
2160 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2161 }
2162 }
2163 }
2164 else
2165 {
2166 NS_LOG_ERROR(this << " Does not find DL RLC Buffer Report of UE " << rnti);
2167 }
2168}
2169
2170void
2172{
2173 size = size - 2; // remove the minimum RLC overhead
2174 std::map<uint16_t, uint32_t>::iterator it = m_ceBsrRxed.find(rnti);
2175 if (it != m_ceBsrRxed.end())
2176 {
2177 NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
2178 if ((*it).second >= size)
2179 {
2180 (*it).second -= size;
2181 }
2182 else
2183 {
2184 (*it).second = 0;
2185 }
2186 }
2187 else
2188 {
2189 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
2190 }
2191}
2192
2193void
2195{
2196 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
2198 params.m_rnti = rnti;
2199 params.m_transmissionMode = txMode;
2201}
2202
2203} // 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
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
Implements the SCHED SAP and CSCHED SAP for a Time Domain Token Bank Fair Queue scheduler.
uint16_t m_nextRntiUl
RNTI of the next user to be served next scheduling in UL.
bool HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
void SetLteFfrSapProvider(LteFfrSapProvider *s) override
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
static TypeId GetTypeId()
Get the type ID.
std::map< uint16_t, uint8_t > m_uesTxMode
txMode of the UEs
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
DL HARQ process timer.
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
Update DL RLC buffer info function.
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
Update UL RLC buffer info function.
~TdTbfqFfMacScheduler() override
Destructor.
FfMacSchedSapProvider * m_schedSapProvider
Sched SAP provider.
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
UL HARQ process DCI buffer.
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
CSched cell config.
FfMacSchedSapUser * m_schedSapUser
A=Sched SAP user.
unsigned int LcActivePerFlow(uint16_t rnti)
LC active flow size.
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
DL HARQ process DCI buffer.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
DL HARQ process RLC PDU list buffer.
uint32_t m_creditLimit
flow credit limit (byte)
void DoSchedUlMacCtrlInfoReq(const FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters &params)
Sched UL MAC control info request.
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
void DoSchedUlTriggerReq(const FfMacSchedSapProvider::SchedUlTriggerReqParameters &params)
Sched UL trigger request.
std::map< uint16_t, uint32_t > m_a30CqiTimers
Map of UE's timers on DL CQI A30 received.
std::vector< uint16_t > m_rachAllocationMap
RACH allocation map.
LteFfrSapUser * m_ffrSapUser
FFR SAP user.
std::map< uint16_t, uint32_t > m_ceBsrRxed
Map of UE's buffer status reports received.
int GetRbgSize(int dlbandwidth)
Get RBG size.
std::map< uint16_t, uint32_t > m_p10CqiTimers
Map of UE's timers on DL CQI P01 received.
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
UL HARQ current process ID.
void DoSchedDlPagingBufferReq(const FfMacSchedSapProvider::SchedDlPagingBufferReqParameters &params)
Sched DL paging buffer request.
void RefreshDlCqiMaps()
Refresh DL CQI maps function.
uint8_t m_ulGrantMcs
MCS for UL grant (default 0)
std::map< uint16_t, std::vector< double > > m_ueCqi
Map of UEs' UL-CQI per RBG.
FfMacSchedSapProvider * GetFfMacSchedSapProvider() override
uint32_t m_creditableThreshold
threshold of flow credit
void DoSchedDlTriggerReq(const FfMacSchedSapProvider::SchedDlTriggerReqParameters &params)
Sched DL trigger request.
std::map< uint16_t, tdtbfqsFlowPerf_t > m_flowStatsUl
Map of UE statistics (per RNTI basis)
LteFfrSapUser * GetLteFfrSapUser() override
FfMacCschedSapProvider * GetFfMacCschedSapProvider() override
void DoSchedDlMacBufferReq(const FfMacSchedSapProvider::SchedDlMacBufferReqParameters &params)
Sched DL MAC buffer request.
void DoCschedLcConfigReq(const FfMacCschedSapProvider::CschedLcConfigReqParameters &params)
CSched LC config request.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmission mde configuration update function.
friend class MemberCschedSapProvider< TdTbfqFfMacScheduler >
allow MemberCschedSapProvider<TdTbfqFfMacScheduler> class friend access
void DoSchedDlRachInfoReq(const FfMacSchedSapProvider::SchedDlRachInfoReqParameters &params)
Sched DL RACH info request.
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
Vectors of UE's LC info.
FfMacCschedSapProvider * m_cschedSapProvider
CSched SAP provider.
void RefreshUlCqiMaps()
Refresh UL CQI maps function.
void DoSchedUlCqiInfoReq(const FfMacSchedSapProvider::SchedUlCqiInfoReqParameters &params)
Sched UL CQI info request.
void SetFfMacSchedSapUser(FfMacSchedSapUser *s) override
set the user part of the FfMacSchedSap that this Scheduler will interact with.
int m_debtLimit
flow debt limit (byte)
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
Estimate UL SINR function.
std::vector< RachListElement_s > m_rachList
RACH list.
void DoCschedLcReleaseReq(const FfMacCschedSapProvider::CschedLcReleaseReqParameters &params)
CSched LC release request.
LteFfrSapProvider * m_ffrSapProvider
FFR SAP provider.
void DoSchedUlSrInfoReq(const FfMacSchedSapProvider::SchedUlSrInfoReqParameters &params)
Sched UL SR info request.
std::map< uint16_t, uint8_t > m_p10CqiRxed
Map of UE's DL CQI P01 received.
void DoCschedUeConfigReq(const FfMacCschedSapProvider::CschedUeConfigReqParameters &params)
CSched UE config request.
friend class MemberSchedSapProvider< TdTbfqFfMacScheduler >
allow MemberSchedSapProvider<TdTbfqFfMacScheduler> class friend access
uint32_t m_tokenPoolSize
maximum size of token pool (byte)
void DoCschedUeReleaseReq(const FfMacCschedSapProvider::CschedUeReleaseReqParameters &params)
CSched UE release request.
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
DL HARQ process status.
void DoSchedDlRlcBufferReq(const FfMacSchedSapProvider::SchedDlRlcBufferReqParameters &params)
Sched DL RLC buffer request.
FfMacCschedSapUser * m_cschedSapUser
CSched SAP user.
std::map< uint16_t, uint32_t > m_ueCqiTimers
Map of UEs' timers on UL-CQI per RBG.
void DoDispose() override
Destructor implementation.
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
DL HARQ current process ID.
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
Map of previous allocated UE per RBG (used to retrieve info from UL-CQI)
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
void SetFfMacCschedSapUser(FfMacCschedSapUser *s) override
set the user part of the FfMacCschedSap that this Scheduler will interact with.
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
HARQ retx buffered.
void DoSchedUlNoiseInterferenceReq(const FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters &params)
Sched UL noise interference request.
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
UL HARQ process status.
void DoCschedCellConfigReq(const FfMacCschedSapProvider::CschedCellConfigReqParameters &params)
CSched cell config request.
void DoSchedDlCqiInfoReq(const FfMacSchedSapProvider::SchedDlCqiInfoReqParameters &params)
Sched DL CQI info request.
std::map< uint16_t, tdtbfqsFlowPerf_t > m_flowStatsDl
Map of UE statistics (per RNTI basis) in downlink.
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
Map of UE's DL CQI A30 received.
uint64_t bankSize
the number of bytes in token bank
bool m_harqOn
m_harqOn when false inhibit the HARQ mechanisms (by default active)
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:936
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...
static const int TdTbfqType0AllocationRbg[4]
TDTBFQ type 0 allocation RBG.
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.
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.
uint32_t tokenPoolSize
current size of token pool (byte)
int debtLimit
counter threshold that the flow cannot further borrow tokens from bank
uint32_t maxTokenPoolSize
maximum size of token pool (byte)
int counter
the number of token borrow or given to token 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)
uint64_t tokenGenerationRate
token generation rate ( byte/s )
Time flowStart
flow start time
uint32_t burstCredit
the maximum number of tokens connection i can borrow from the bank each time