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