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