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