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 std::map<uint16_t, uint8_t>::iterator 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 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
219 m_rlcBufferReq.begin();
220 while (it != m_rlcBufferReq.end())
221 {
222 if (((*it).m_rnti == params.m_rnti) &&
223 ((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity.at(i)))
224 {
225 it = m_rlcBufferReq.erase(it);
226 }
227 else
228 {
229 it++;
230 }
231 }
232 }
233}
234
235void
238{
239 NS_LOG_FUNCTION(this << " Release RNTI " << params.m_rnti);
240
241 m_uesTxMode.erase(params.m_rnti);
242 m_dlHarqCurrentProcessId.erase(params.m_rnti);
243 m_dlHarqProcessesStatus.erase(params.m_rnti);
244 m_dlHarqProcessesTimer.erase(params.m_rnti);
245 m_dlHarqProcessesDciBuffer.erase(params.m_rnti);
246 m_dlHarqProcessesRlcPduListBuffer.erase(params.m_rnti);
247 m_ulHarqCurrentProcessId.erase(params.m_rnti);
248 m_ulHarqProcessesStatus.erase(params.m_rnti);
249 m_ulHarqProcessesDciBuffer.erase(params.m_rnti);
250 m_ceBsrRxed.erase(params.m_rnti);
251 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
252 m_rlcBufferReq.begin();
253 while (it != m_rlcBufferReq.end())
254 {
255 if ((*it).m_rnti == params.m_rnti)
256 {
257 NS_LOG_INFO(this << " Erase RNTI " << (*it).m_rnti << " LC "
258 << (uint16_t)(*it).m_logicalChannelIdentity);
259 it = m_rlcBufferReq.erase(it);
260 }
261 else
262 {
263 it++;
264 }
265 }
266 if (m_nextRntiUl == params.m_rnti)
267 {
268 m_nextRntiUl = 0;
269 }
270
271 if (m_nextRntiDl == params.m_rnti)
272 {
273 m_nextRntiDl = 0;
274 }
275}
276
277void
280{
281 NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity);
282 // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
283 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
284 m_rlcBufferReq.begin();
285 bool newLc = true;
286 while (it != m_rlcBufferReq.end())
287 {
288 // remove old entries of this UE-LC
289 if (((*it).m_rnti == params.m_rnti) &&
290 ((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity))
291 {
292 it = m_rlcBufferReq.erase(it);
293 newLc = false;
294 }
295 else
296 {
297 ++it;
298 }
299 }
300 // add the new parameters
301 m_rlcBufferReq.insert(it, params);
302 NS_LOG_INFO(this << " RNTI " << params.m_rnti << " LC "
303 << (uint16_t)params.m_logicalChannelIdentity << " RLC tx size "
304 << params.m_rlcTransmissionQueueSize << " RLC retx size "
305 << params.m_rlcRetransmissionQueueSize << " RLC stat size "
306 << params.m_rlcStatusPduSize);
307 // initialize statistics of the flow in case of new flows
308 if (newLc)
309 {
310 m_p10CqiRxed.insert(
311 std::pair<uint16_t, uint8_t>(params.m_rnti, 1)); // only codeword 0 at this stage (SISO)
312 // initialized to 1 (i.e., the lowest value for transmitting a signal)
313 m_p10CqiTimers.insert(std::pair<uint16_t, uint32_t>(params.m_rnti, m_cqiTimersThreshold));
314 }
315}
316
317void
320{
321 NS_LOG_FUNCTION(this);
322 NS_FATAL_ERROR("method not implemented");
323}
324
325void
328{
329 NS_LOG_FUNCTION(this);
330 NS_FATAL_ERROR("method not implemented");
331}
332
333int
335{
336 for (int i = 0; i < 4; i++)
337 {
338 if (dlbandwidth < Type0AllocationRbg[i])
339 {
340 return (i + 1);
341 }
342 }
343
344 return (-1);
345}
346
347bool
350{
351 return (i.m_rnti < j.m_rnti);
352}
353
354bool
356{
357 NS_LOG_FUNCTION(this << rnti);
358
359 std::map<uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find(rnti);
360 if (it == m_dlHarqCurrentProcessId.end())
361 {
362 NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti);
363 }
364 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
365 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 std::map<uint16_t, uint8_t>::iterator 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 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
395 m_dlHarqProcessesStatus.find(rnti);
396 if (itStat == m_dlHarqProcessesStatus.end())
397 {
398 NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti);
399 }
400 uint8_t i = (*it).second;
401 do
402 {
403 i = (i + 1) % HARQ_PROC_NUM;
404 } while (((*itStat).second.at(i) != 0) && (i != (*it).second));
405 if ((*itStat).second.at(i) == 0)
406 {
407 (*it).second = i;
408 (*itStat).second.at(i) = 1;
409 }
410 else
411 {
412 return (9); // return a not valid harq proc id
413 }
414
415 return ((*it).second);
416}
417
418void
420{
421 NS_LOG_FUNCTION(this);
422
423 std::map<uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
424 for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end();
425 itTimers++)
426 {
427 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
428 {
429 if ((*itTimers).second.at(i) == HARQ_DL_TIMEOUT)
430 {
431 // reset HARQ process
432
433 NS_LOG_INFO(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first);
434 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
435 m_dlHarqProcessesStatus.find((*itTimers).first);
436 if (itStat == m_dlHarqProcessesStatus.end())
437 {
438 NS_FATAL_ERROR("No Process Id Status found for this RNTI "
439 << (*itTimers).first);
440 }
441 (*itStat).second.at(i) = 0;
442 (*itTimers).second.at(i) = 0;
443 }
444 else
445 {
446 (*itTimers).second.at(i)++;
447 }
448 }
449 }
450}
451
452void
455{
456 NS_LOG_FUNCTION(this << " DL Frame no. " << (params.m_sfnSf >> 4) << " subframe no. "
457 << (0xF & params.m_sfnSf));
458 // API generated by RLC for triggering the scheduling of a DL subframe
459
462 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
464
465 // Generate RBGs map
466 std::vector<bool> rbgMap;
467 uint16_t rbgAllocatedNum = 0;
468 std::set<uint16_t> rntiAllocated;
469 rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false);
470
471 // update UL HARQ proc id
472 std::map<uint16_t, uint8_t>::iterator itProcId;
473 for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end();
474 itProcId++)
475 {
476 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
477 }
478
479 // RACH Allocation
481 uint16_t rbStart = 0;
482 std::vector<RachListElement_s>::iterator itRach;
483 for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++)
484 {
486 (*itRach).m_estimatedSize,
487 " Default UL Grant MCS does not allow to send RACH messages");
489 newRar.m_rnti = (*itRach).m_rnti;
490 // DL-RACH Allocation
491 // Ideal: no needs of configuring m_dci
492 // UL-RACH Allocation
493 newRar.m_grant.m_rnti = newRar.m_rnti;
494 newRar.m_grant.m_mcs = m_ulGrantMcs;
495 uint16_t rbLen = 1;
496 uint16_t tbSizeBits = 0;
497 // find lowest TB size that fits UL grant estimated size
498 while ((tbSizeBits < (*itRach).m_estimatedSize) &&
499 (rbStart + rbLen < m_cschedCellConfig.m_ulBandwidth))
500 {
501 rbLen++;
502 tbSizeBits = m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, rbLen);
503 }
504 if (tbSizeBits < (*itRach).m_estimatedSize)
505 {
506 // no more allocation space: finish allocation
507 break;
508 }
509 newRar.m_grant.m_rbStart = rbStart;
510 newRar.m_grant.m_rbLen = rbLen;
511 newRar.m_grant.m_tbSize = tbSizeBits / 8;
512 newRar.m_grant.m_hopping = false;
513 newRar.m_grant.m_tpc = 0;
514 newRar.m_grant.m_cqiRequest = false;
515 newRar.m_grant.m_ulDelay = false;
516 NS_LOG_INFO(this << " UL grant allocated to RNTI " << (*itRach).m_rnti << " rbStart "
517 << rbStart << " rbLen " << rbLen << " MCS " << (uint16_t)m_ulGrantMcs
518 << " tbSize " << newRar.m_grant.m_tbSize);
519 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
520 {
521 m_rachAllocationMap.at(i) = (*itRach).m_rnti;
522 }
523
524 if (m_harqOn)
525 {
526 // generate UL-DCI for HARQ retransmissions
527 UlDciListElement_s uldci;
528 uldci.m_rnti = newRar.m_rnti;
529 uldci.m_rbLen = rbLen;
530 uldci.m_rbStart = rbStart;
531 uldci.m_mcs = m_ulGrantMcs;
532 uldci.m_tbSize = tbSizeBits / 8;
533 uldci.m_ndi = 1;
534 uldci.m_cceIndex = 0;
535 uldci.m_aggrLevel = 1;
536 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
537 uldci.m_hopping = false;
538 uldci.m_n2Dmrs = 0;
539 uldci.m_tpc = 0; // no power control
540 uldci.m_cqiRequest = false; // only period CQI at this stage
541 uldci.m_ulIndex = 0; // TDD parameter
542 uldci.m_dai = 1; // TDD parameter
543 uldci.m_freqHopping = 0;
544 uldci.m_pdcchPowerOffset = 0; // not used
545
546 uint8_t harqId = 0;
547 std::map<uint16_t, uint8_t>::iterator itProcId;
548 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 std::map<uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci =
556 if (itDci == m_ulHarqProcessesDciBuffer.end())
557 {
558 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
559 << uldci.m_rnti);
560 }
561 (*itDci).second.at(harqId) = uldci;
562 }
563
564 rbStart = rbStart + rbLen;
565 ret.m_buildRarList.push_back(newRar);
566 }
567 m_rachList.clear();
568
569 // Process DL HARQ feedback
571 // retrieve past HARQ retx buffered
572 if (!m_dlInfoListBuffered.empty())
573 {
574 if (!params.m_dlInfoList.empty())
575 {
576 NS_LOG_INFO(this << " Received DL-HARQ feedback");
578 params.m_dlInfoList.begin(),
579 params.m_dlInfoList.end());
580 }
581 }
582 else
583 {
584 if (!params.m_dlInfoList.empty())
585 {
586 m_dlInfoListBuffered = params.m_dlInfoList;
587 }
588 }
589 if (!m_harqOn)
590 {
591 // Ignore HARQ feedback
592 m_dlInfoListBuffered.clear();
593 }
594 std::vector<DlInfoListElement_s> dlInfoListUntxed;
595 for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++)
596 {
597 std::set<uint16_t>::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti);
598 if (itRnti != rntiAllocated.end())
599 {
600 // RNTI already allocated for retx
601 continue;
602 }
603 auto nLayers = m_dlInfoListBuffered.at(i).m_harqStatus.size();
604 std::vector<bool> retx;
605 NS_LOG_INFO(this << " Processing DLHARQ feedback");
606 if (nLayers == 1)
607 {
608 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
610 retx.push_back(false);
611 }
612 else
613 {
614 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(0) ==
616 retx.push_back(m_dlInfoListBuffered.at(i).m_harqStatus.at(1) ==
618 }
619 if (retx.at(0) || retx.at(1))
620 {
621 // retrieve HARQ process information
622 uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti;
623 uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId;
624 NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
625 std::map<uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq =
627 if (itHarq == m_dlHarqProcessesDciBuffer.end())
628 {
629 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti);
630 }
631
632 DlDciListElement_s dci = (*itHarq).second.at(harqId);
633 int rv = 0;
634 if (dci.m_rv.size() == 1)
635 {
636 rv = dci.m_rv.at(0);
637 }
638 else
639 {
640 rv = (dci.m_rv.at(0) > dci.m_rv.at(1) ? dci.m_rv.at(0) : dci.m_rv.at(1));
641 }
642
643 if (rv == 3)
644 {
645 // maximum number of retx reached -> drop process
646 NS_LOG_INFO("Max number of retransmissions reached -> drop process");
647 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator it =
648 m_dlHarqProcessesStatus.find(rnti);
649 if (it == m_dlHarqProcessesStatus.end())
650 {
651 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
652 << m_dlInfoListBuffered.at(i).m_rnti);
653 }
654 (*it).second.at(harqId) = 0;
655 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
657 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
658 {
659 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
660 << m_dlInfoListBuffered.at(i).m_rnti);
661 }
662 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
663 {
664 (*itRlcPdu).second.at(k).at(harqId).clear();
665 }
666 continue;
667 }
668 // check the feasibility of retransmitting on the same RBGs
669 // translate the DCI to Spectrum framework
670 std::vector<int> dciRbg;
671 uint32_t mask = 0x1;
672 NS_LOG_INFO("Original RBGs " << dci.m_rbBitmap << " rnti " << dci.m_rnti);
673 for (int j = 0; j < 32; j++)
674 {
675 if (((dci.m_rbBitmap & mask) >> j) == 1)
676 {
677 dciRbg.push_back(j);
678 NS_LOG_INFO("\t" << j);
679 }
680 mask = (mask << 1);
681 }
682 bool free = true;
683 for (std::size_t j = 0; j < dciRbg.size(); j++)
684 {
685 if (rbgMap.at(dciRbg.at(j)))
686 {
687 free = false;
688 break;
689 }
690 }
691 if (free)
692 {
693 // use the same RBGs for the retx
694 // reserve RBGs
695 for (std::size_t j = 0; j < dciRbg.size(); j++)
696 {
697 rbgMap.at(dciRbg.at(j)) = true;
698 NS_LOG_INFO("RBG " << dciRbg.at(j) << " assigned");
699 rbgAllocatedNum++;
700 }
701
702 NS_LOG_INFO(this << " Send retx in the same RBGs");
703 }
704 else
705 {
706 // find RBGs for sending HARQ retx
707 uint8_t j = 0;
708 uint8_t rbgId = (dciRbg.at(dciRbg.size() - 1) + 1) % rbgNum;
709 uint8_t startRbg = dciRbg.at(dciRbg.size() - 1);
710 std::vector<bool> rbgMapCopy = rbgMap;
711 while ((j < dciRbg.size()) && (startRbg != rbgId))
712 {
713 if (!rbgMapCopy.at(rbgId))
714 {
715 rbgMapCopy.at(rbgId) = true;
716 dciRbg.at(j) = rbgId;
717 j++;
718 }
719 rbgId = (rbgId + 1) % rbgNum;
720 }
721 if (j == dciRbg.size())
722 {
723 // find new RBGs -> update DCI map
724 uint32_t rbgMask = 0;
725 for (std::size_t k = 0; k < dciRbg.size(); k++)
726 {
727 rbgMask = rbgMask + (0x1 << dciRbg.at(k));
728 NS_LOG_INFO(this << " New allocated RBG " << dciRbg.at(k));
729 rbgAllocatedNum++;
730 }
731 dci.m_rbBitmap = rbgMask;
732 rbgMap = rbgMapCopy;
733 }
734 else
735 {
736 // HARQ retx cannot be performed on this TTI -> store it
737 dlInfoListUntxed.push_back(m_dlInfoListBuffered.at(i));
738 NS_LOG_INFO(this << " No resource for this retx -> buffer it");
739 }
740 }
741 // retrieve RLC PDU list for retx TBsize and update DCI
743 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
745 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
746 {
747 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
748 }
749 for (std::size_t j = 0; j < nLayers; j++)
750 {
751 if (retx.at(j))
752 {
753 if (j >= dci.m_ndi.size())
754 {
755 // for avoiding errors in MIMO transient phases
756 dci.m_ndi.push_back(0);
757 dci.m_rv.push_back(0);
758 dci.m_mcs.push_back(0);
759 dci.m_tbsSize.push_back(0);
760 NS_LOG_INFO(this << " layer " << (uint16_t)j
761 << " no txed (MIMO transition)");
762 }
763 else
764 {
765 dci.m_ndi.at(j) = 0;
766 dci.m_rv.at(j)++;
767 (*itHarq).second.at(harqId).m_rv.at(j)++;
768 NS_LOG_INFO(this << " layer " << (uint16_t)j << " RV "
769 << (uint16_t)dci.m_rv.at(j));
770 }
771 }
772 else
773 {
774 // empty TB of layer j
775 dci.m_ndi.at(j) = 0;
776 dci.m_rv.at(j) = 0;
777 dci.m_mcs.at(j) = 0;
778 dci.m_tbsSize.at(j) = 0;
779 NS_LOG_INFO(this << " layer " << (uint16_t)j << " no retx");
780 }
781 }
782
783 for (std::size_t k = 0; k < (*itRlcPdu).second.at(0).at(dci.m_harqProcess).size(); k++)
784 {
785 std::vector<RlcPduListElement_s> rlcPduListPerLc;
786 for (std::size_t j = 0; j < nLayers; j++)
787 {
788 if (retx.at(j))
789 {
790 if (j < dci.m_ndi.size())
791 {
792 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size "
793 << dci.m_tbsSize.at(j));
794 rlcPduListPerLc.push_back(
795 (*itRlcPdu).second.at(j).at(dci.m_harqProcess).at(k));
796 }
797 }
798 else
799 { // if no retx needed on layer j, push an RlcPduListElement_s object with
800 // m_size=0 to keep the size of rlcPduListPerLc vector = 2 in case of MIMO
801 NS_LOG_INFO(" layer " << (uint16_t)j << " tb size " << dci.m_tbsSize.at(j));
802 RlcPduListElement_s emptyElement;
803 emptyElement.m_logicalChannelIdentity = (*itRlcPdu)
804 .second.at(j)
805 .at(dci.m_harqProcess)
806 .at(k)
807 .m_logicalChannelIdentity;
808 emptyElement.m_size = 0;
809 rlcPduListPerLc.push_back(emptyElement);
810 }
811 }
812
813 if (!rlcPduListPerLc.empty())
814 {
815 newEl.m_rlcPduList.push_back(rlcPduListPerLc);
816 }
817 }
818 newEl.m_rnti = rnti;
819 newEl.m_dci = dci;
820 (*itHarq).second.at(harqId).m_rv = dci.m_rv;
821 // refresh timer
822 std::map<uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer =
823 m_dlHarqProcessesTimer.find(rnti);
824 if (itHarqTimer == m_dlHarqProcessesTimer.end())
825 {
826 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
827 }
828 (*itHarqTimer).second.at(harqId) = 0;
829 ret.m_buildDataList.push_back(newEl);
830 rntiAllocated.insert(rnti);
831 }
832 else
833 {
834 // update HARQ process status
835 NS_LOG_INFO(this << " HARQ ACK UE " << m_dlInfoListBuffered.at(i).m_rnti);
836 std::map<uint16_t, DlHarqProcessesStatus_t>::iterator it =
838 if (it == m_dlHarqProcessesStatus.end())
839 {
840 NS_FATAL_ERROR("No info find in HARQ buffer for UE "
841 << m_dlInfoListBuffered.at(i).m_rnti);
842 }
843 (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0;
844 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
846 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
847 {
848 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
849 << m_dlInfoListBuffered.at(i).m_rnti);
850 }
851 for (std::size_t k = 0; k < (*itRlcPdu).second.size(); k++)
852 {
853 (*itRlcPdu).second.at(k).at(m_dlInfoListBuffered.at(i).m_harqProcessId).clear();
854 }
855 }
856 }
857 m_dlInfoListBuffered.clear();
858 m_dlInfoListBuffered = dlInfoListUntxed;
859
860 if (rbgAllocatedNum == rbgNum)
861 {
862 // all the RBGs are already allocated -> exit
863 if (!ret.m_buildDataList.empty() || !ret.m_buildRarList.empty())
864 {
866 }
867 return;
868 }
869
870 // Get the actual active flows (queue!=0)
871 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
873 int nflows = 0;
874 int nTbs = 0;
875 std::map<uint16_t, uint8_t> lcActivesPerRnti; // tracks how many active LCs per RNTI there are
876 std::map<uint16_t, uint8_t>::iterator itLcRnti;
877 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
878 {
879 // remove old entries of this UE-LC
880 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).m_rnti);
881 if ((((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) ||
882 ((*it).m_rlcStatusPduSize > 0)) &&
883 (itRnti == rntiAllocated.end()) // UE must not be allocated for HARQ retx
884 && (HarqProcessAvailability((*it).m_rnti))) // UE needs HARQ proc free
885
886 {
887 NS_LOG_LOGIC(this << " User " << (*it).m_rnti << " LC "
888 << (uint16_t)(*it).m_logicalChannelIdentity << " is active, status "
889 << (*it).m_rlcStatusPduSize << " retx "
890 << (*it).m_rlcRetransmissionQueueSize << " tx "
891 << (*it).m_rlcTransmissionQueueSize);
892 std::map<uint16_t, uint8_t>::iterator itCqi = m_p10CqiRxed.find((*it).m_rnti);
893 uint8_t cqi = 0;
894 if (itCqi != m_p10CqiRxed.end())
895 {
896 cqi = (*itCqi).second;
897 }
898 else
899 {
900 cqi = 1; // lowest value for trying a transmission
901 }
902 if (cqi != 0)
903 {
904 // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
905 nflows++;
906 itLcRnti = lcActivesPerRnti.find((*it).m_rnti);
907 if (itLcRnti != lcActivesPerRnti.end())
908 {
909 (*itLcRnti).second++;
910 }
911 else
912 {
913 lcActivesPerRnti.insert(std::pair<uint16_t, uint8_t>((*it).m_rnti, 1));
914 nTbs++;
915 }
916 }
917 }
918 }
919
920 if (nflows == 0)
921 {
922 if ((!ret.m_buildDataList.empty()) || (!ret.m_buildRarList.empty()))
923 {
925 }
926 return;
927 }
928 // Divide the resource equally among the active users according to
929 // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
930
931 int rbgPerTb = (nTbs > 0) ? ((rbgNum - rbgAllocatedNum) / nTbs) : INT_MAX;
932 NS_LOG_INFO(this << " Flows to be transmitted " << nflows << " rbgPerTb " << rbgPerTb);
933 if (rbgPerTb == 0)
934 {
935 rbgPerTb = 1; // at least 1 rbg per TB (till available resource)
936 }
937 int rbgAllocated = 0;
938
939 // round robin assignment to all UEs registered starting from the subsequent of the one
940 // served last scheduling trigger event
941 if (m_nextRntiDl != 0)
942 {
943 NS_LOG_DEBUG("Start from the successive of " << (uint16_t)m_nextRntiDl);
944 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
945 {
946 if ((*it).m_rnti == m_nextRntiDl)
947 {
948 // select the next RNTI to starting
949 it++;
950 if (it == m_rlcBufferReq.end())
951 {
952 it = m_rlcBufferReq.begin();
953 }
954 m_nextRntiDl = (*it).m_rnti;
955 break;
956 }
957 }
958
959 if (it == m_rlcBufferReq.end())
960 {
961 NS_LOG_ERROR(this << " no user found");
962 }
963 }
964 else
965 {
966 it = m_rlcBufferReq.begin();
967 m_nextRntiDl = (*it).m_rnti;
968 }
969 std::map<uint16_t, uint8_t>::iterator itTxMode;
970 do
971 {
972 itLcRnti = lcActivesPerRnti.find((*it).m_rnti);
973 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).m_rnti);
974 if ((itLcRnti == lcActivesPerRnti.end()) || (itRnti != rntiAllocated.end()))
975 {
976 // skip this RNTI (no active queue or yet allocated for HARQ)
977 uint16_t rntiDiscarded = (*it).m_rnti;
978 while (it != m_rlcBufferReq.end())
979 {
980 if ((*it).m_rnti != rntiDiscarded)
981 {
982 break;
983 }
984 it++;
985 }
986 if (it == m_rlcBufferReq.end())
987 {
988 // restart from the first
989 it = m_rlcBufferReq.begin();
990 }
991 continue;
992 }
993 itTxMode = m_uesTxMode.find((*it).m_rnti);
994 if (itTxMode == m_uesTxMode.end())
995 {
996 NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).m_rnti);
997 }
998 auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second);
999 int lcNum = (*itLcRnti).second;
1000 // create new BuildDataListElement_s for this RNTI
1002 newEl.m_rnti = (*it).m_rnti;
1003 // create the DlDciListElement_s
1004 DlDciListElement_s newDci;
1005 newDci.m_rnti = (*it).m_rnti;
1006 newDci.m_harqProcess = UpdateHarqProcessId((*it).m_rnti);
1007 newDci.m_resAlloc = 0;
1008 newDci.m_rbBitmap = 0;
1009 std::map<uint16_t, uint8_t>::iterator itCqi = m_p10CqiRxed.find(newEl.m_rnti);
1010 for (uint8_t i = 0; i < nLayer; i++)
1011 {
1012 if (itCqi == m_p10CqiRxed.end())
1013 {
1014 newDci.m_mcs.push_back(0); // no info on this user -> lowest MCS
1015 }
1016 else
1017 {
1018 newDci.m_mcs.push_back(m_amc->GetMcsFromCqi((*itCqi).second));
1019 }
1020 }
1021 int tbSize = (m_amc->GetDlTbSizeFromMcs(newDci.m_mcs.at(0), rbgPerTb * rbgSize) / 8);
1022 uint16_t rlcPduSize = tbSize / lcNum;
1023 while ((*it).m_rnti == newEl.m_rnti)
1024 {
1025 if (((*it).m_rlcTransmissionQueueSize > 0) ||
1026 ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0))
1027 {
1028 std::vector<RlcPduListElement_s> newRlcPduLe;
1029 for (uint8_t j = 0; j < nLayer; j++)
1030 {
1031 RlcPduListElement_s newRlcEl;
1032 newRlcEl.m_logicalChannelIdentity = (*it).m_logicalChannelIdentity;
1033 NS_LOG_INFO(this << "LCID " << (uint32_t)newRlcEl.m_logicalChannelIdentity
1034 << " size " << rlcPduSize << " ID " << (*it).m_rnti
1035 << " layer " << (uint16_t)j);
1036 newRlcEl.m_size = rlcPduSize;
1037 UpdateDlRlcBufferInfo((*it).m_rnti,
1038 newRlcEl.m_logicalChannelIdentity,
1039 rlcPduSize);
1040 newRlcPduLe.push_back(newRlcEl);
1041
1042 if (m_harqOn)
1043 {
1044 // store RLC PDU list for HARQ
1045 std::map<uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu =
1046 m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti);
1047 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end())
1048 {
1049 NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI "
1050 << (*it).m_rnti);
1051 }
1052 (*itRlcPdu).second.at(j).at(newDci.m_harqProcess).push_back(newRlcEl);
1053 }
1054 }
1055 newEl.m_rlcPduList.push_back(newRlcPduLe);
1056 lcNum--;
1057 }
1058 it++;
1059 if (it == m_rlcBufferReq.end())
1060 {
1061 // restart from the first
1062 it = m_rlcBufferReq.begin();
1063 break;
1064 }
1065 }
1066 uint32_t rbgMask = 0;
1067 uint16_t i = 0;
1068 NS_LOG_INFO(this << " DL - Allocate user " << newEl.m_rnti << " LCs "
1069 << (uint16_t)(*itLcRnti).second << " bytes " << tbSize << " mcs "
1070 << (uint16_t)newDci.m_mcs.at(0) << " harqId "
1071 << (uint16_t)newDci.m_harqProcess << " layers " << nLayer);
1072 NS_LOG_INFO("RBG:");
1073 while (i < rbgPerTb)
1074 {
1075 if (!rbgMap.at(rbgAllocated))
1076 {
1077 rbgMask = rbgMask + (0x1 << rbgAllocated);
1078 NS_LOG_INFO("\t " << rbgAllocated);
1079 i++;
1080 rbgMap.at(rbgAllocated) = true;
1081 rbgAllocatedNum++;
1082 }
1083 rbgAllocated++;
1084 }
1085 newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
1086
1087 for (std::size_t i = 0; i < nLayer; i++)
1088 {
1089 newDci.m_tbsSize.push_back(tbSize);
1090 newDci.m_ndi.push_back(1);
1091 newDci.m_rv.push_back(0);
1092 }
1093
1094 newDci.m_tpc = 1; // 1 is mapped to 0 in Accumulated Mode and to -1 in Absolute Mode
1095
1096 newEl.m_dci = newDci;
1097 if (m_harqOn)
1098 {
1099 // store DCI for HARQ
1100 std::map<uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci =
1102 if (itDci == m_dlHarqProcessesDciBuffer.end())
1103 {
1104 NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI "
1105 << newEl.m_rnti);
1106 }
1107 (*itDci).second.at(newDci.m_harqProcess) = newDci;
1108 // refresh timer
1109 std::map<uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer =
1110 m_dlHarqProcessesTimer.find(newEl.m_rnti);
1111 if (itHarqTimer == m_dlHarqProcessesTimer.end())
1112 {
1113 NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1114 }
1115 (*itHarqTimer).second.at(newDci.m_harqProcess) = 0;
1116 }
1117 // ...more parameters -> ignored in this version
1118
1119 ret.m_buildDataList.push_back(newEl);
1120 if (rbgAllocatedNum == rbgNum)
1121 {
1122 m_nextRntiDl = newEl.m_rnti; // store last RNTI served
1123 break; // no more RGB to be allocated
1124 }
1125 } while ((*it).m_rnti != m_nextRntiDl);
1126
1127 ret.m_nrOfPdcchOfdmSymbols = 1;
1128
1130}
1131
1132void
1135{
1136 NS_LOG_FUNCTION(this);
1137
1138 m_rachList = params.m_rachList;
1139}
1140
1141void
1144{
1145 NS_LOG_FUNCTION(this);
1146
1147 std::map<uint16_t, uint8_t>::iterator it;
1148 for (unsigned int i = 0; i < params.m_cqiList.size(); i++)
1149 {
1150 if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10)
1151 {
1152 NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0)
1153 << " reported");
1154 std::map<uint16_t, uint8_t>::iterator it;
1155 uint16_t rnti = params.m_cqiList.at(i).m_rnti;
1156 it = m_p10CqiRxed.find(rnti);
1157 if (it == m_p10CqiRxed.end())
1158 {
1159 // create the new entry
1160 m_p10CqiRxed.insert(std::pair<uint16_t, uint8_t>(
1161 rnti,
1162 params.m_cqiList.at(i).m_wbCqi.at(0))); // only codeword 0 at this stage (SISO)
1163 // generate correspondent timer
1164 m_p10CqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
1165 }
1166 else
1167 {
1168 // update the CQI value
1169 (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0);
1170 // update correspondent timer
1171 std::map<uint16_t, uint32_t>::iterator itTimers;
1172 itTimers = m_p10CqiTimers.find(rnti);
1173 (*itTimers).second = m_cqiTimersThreshold;
1174 }
1175 }
1176 else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30)
1177 {
1178 // subband CQI reporting high layer configured
1179 // Not used by RR Scheduler
1180 }
1181 else
1182 {
1183 NS_LOG_ERROR(this << " CQI type unknown");
1184 }
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 std::map<uint16_t, uint8_t>::iterator itProcId =
1229 m_ulHarqCurrentProcessId.find(rnti);
1230 if (itProcId == m_ulHarqCurrentProcessId.end())
1231 {
1232 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1233 }
1234 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1235 NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId "
1236 << (uint16_t)harqId);
1237 std::map<uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq =
1238 m_ulHarqProcessesDciBuffer.find(rnti);
1239 if (itHarq == m_ulHarqProcessesDciBuffer.end())
1240 {
1241 NS_LOG_ERROR("No info find in UL-HARQ buffer for UE (might change eNB) "
1242 << rnti);
1243 }
1244 UlDciListElement_s dci = (*itHarq).second.at(harqId);
1245 std::map<uint16_t, UlHarqProcessesStatus_t>::iterator itStat =
1246 m_ulHarqProcessesStatus.find(rnti);
1247 if (itStat == m_ulHarqProcessesStatus.end())
1248 {
1249 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti);
1250 }
1251 if ((*itStat).second.at(harqId) >= 3)
1252 {
1253 NS_LOG_INFO("Max number of retransmissions reached (UL)-> drop process");
1254 continue;
1255 }
1256 bool free = true;
1257 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1258 {
1259 if (rbMap.at(j))
1260 {
1261 free = false;
1262 NS_LOG_INFO(this << " BUSY " << j);
1263 }
1264 }
1265 if (free)
1266 {
1267 // retx on the same RBs
1268 for (int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1269 {
1270 rbMap.at(j) = true;
1271 rbgAllocationMap.at(j) = dci.m_rnti;
1272 NS_LOG_INFO("\tRB " << j);
1273 }
1274 NS_LOG_INFO(this << " Send retx in the same RBGs " << (uint16_t)dci.m_rbStart
1275 << " to " << dci.m_rbStart + dci.m_rbLen << " RV "
1276 << (*itStat).second.at(harqId) + 1);
1277 }
1278 else
1279 {
1280 NS_LOG_INFO("Cannot allocate retx due to RACH allocations for UE " << rnti);
1281 continue;
1282 }
1283 dci.m_ndi = 0;
1284 // Update HARQ buffers with new HarqId
1285 (*itStat).second.at((*itProcId).second) = (*itStat).second.at(harqId) + 1;
1286 (*itStat).second.at(harqId) = 0;
1287 (*itHarq).second.at((*itProcId).second) = dci;
1288 ret.m_dciList.push_back(dci);
1289 rntiAllocated.insert(dci.m_rnti);
1290 }
1291 }
1292 }
1293
1294 std::map<uint16_t, uint32_t>::iterator it;
1295 int nflows = 0;
1296
1297 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1298 {
1299 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).first);
1300 // select UEs with queues not empty and not yet allocated for HARQ
1301 NS_LOG_INFO(this << " UE " << (*it).first << " queue " << (*it).second);
1302 if (((*it).second > 0) && (itRnti == rntiAllocated.end()))
1303 {
1304 nflows++;
1305 }
1306 }
1307
1308 if (nflows == 0)
1309 {
1310 if (!ret.m_dciList.empty())
1311 {
1312 m_allocationMaps.insert(
1313 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
1315 }
1316 return; // no flows to be scheduled
1317 }
1318
1319 // Divide the remaining resources equally among the active users starting from the subsequent
1320 // one served last scheduling trigger
1321 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size());
1322 if (rbPerFlow < 3)
1323 {
1324 rbPerFlow = 3; // at least 3 rbg per flow (till available resource) to ensure TxOpportunity
1325 // >= 7 bytes
1326 }
1327 uint16_t rbAllocated = 0;
1328
1329 if (m_nextRntiUl != 0)
1330 {
1331 for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++)
1332 {
1333 if ((*it).first == m_nextRntiUl)
1334 {
1335 break;
1336 }
1337 }
1338 if (it == m_ceBsrRxed.end())
1339 {
1340 NS_LOG_ERROR(this << " no user found");
1341 }
1342 }
1343 else
1344 {
1345 it = m_ceBsrRxed.begin();
1346 m_nextRntiUl = (*it).first;
1347 }
1348 NS_LOG_INFO(this << " NFlows " << nflows << " RB per Flow " << rbPerFlow);
1349 do
1350 {
1351 std::set<uint16_t>::iterator itRnti = rntiAllocated.find((*it).first);
1352 if ((itRnti != rntiAllocated.end()) || ((*it).second == 0))
1353 {
1354 // UE already allocated for UL-HARQ -> skip it
1355 it++;
1356 if (it == m_ceBsrRxed.end())
1357 {
1358 // restart from the first
1359 it = m_ceBsrRxed.begin();
1360 }
1361 continue;
1362 }
1363 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1364 {
1365 // limit to physical resources last resource assignment
1366 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1367 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1368 if (rbPerFlow < 3)
1369 {
1370 // terminate allocation
1371 rbPerFlow = 0;
1372 }
1373 }
1374 NS_LOG_INFO(this << " try to allocate " << (*it).first);
1375 UlDciListElement_s uldci;
1376 uldci.m_rnti = (*it).first;
1377 uldci.m_rbLen = rbPerFlow;
1378 bool allocated = false;
1379 NS_LOG_INFO(this << " RB Allocated " << rbAllocated << " rbPerFlow " << rbPerFlow
1380 << " flows " << nflows);
1381 while ((!allocated) && ((rbAllocated + rbPerFlow - m_cschedCellConfig.m_ulBandwidth) < 1) &&
1382 (rbPerFlow != 0))
1383 {
1384 // check availability
1385 bool free = true;
1386 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1387 {
1388 if (rbMap.at(j))
1389 {
1390 free = false;
1391 break;
1392 }
1393 }
1394 if (free)
1395 {
1396 uldci.m_rbStart = rbAllocated;
1397
1398 for (int j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1399 {
1400 rbMap.at(j) = true;
1401 // store info on allocation for managing ul-cqi interpretation
1402 rbgAllocationMap.at(j) = (*it).first;
1403 NS_LOG_INFO("\t " << j);
1404 }
1405 rbAllocated += rbPerFlow;
1406 allocated = true;
1407 break;
1408 }
1409 rbAllocated++;
1410 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1411 {
1412 // limit to physical resources last resource assignment
1413 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1414 // at least 3 rbg per flow to ensure TxOpportunity >= 7 bytes
1415 if (rbPerFlow < 3)
1416 {
1417 // terminate allocation
1418 rbPerFlow = 0;
1419 }
1420 }
1421 }
1422 if (!allocated)
1423 {
1424 // unable to allocate new resource: finish scheduling
1425 m_nextRntiUl = (*it).first;
1426 if (!ret.m_dciList.empty())
1427 {
1429 }
1430 m_allocationMaps.insert(
1431 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
1432 return;
1433 }
1434 std::map<uint16_t, std::vector<double>>::iterator itCqi = m_ueCqi.find((*it).first);
1435 int cqi = 0;
1436 if (itCqi == m_ueCqi.end())
1437 {
1438 // no cqi info about this UE
1439 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
1440 NS_LOG_INFO(this << " UE does not have ULCQI " << (*it).first);
1441 }
1442 else
1443 {
1444 // take the lowest CQI value (worst RB)
1445 NS_ABORT_MSG_IF((*itCqi).second.empty(),
1446 "CQI of RNTI = " << (*it).first << " has expired");
1447 double minSinr = (*itCqi).second.at(uldci.m_rbStart);
1448 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1449 {
1450 if ((*itCqi).second.at(i) < minSinr)
1451 {
1452 minSinr = (*itCqi).second.at(i);
1453 }
1454 }
1455 // translate SINR -> cqi: WILD ACK: same as DL
1456 double s = log2(1 + (std::pow(10, minSinr / 10) / ((-std::log(5.0 * 0.00005)) / 1.5)));
1457
1458 cqi = m_amc->GetCqiFromSpectralEfficiency(s);
1459 if (cqi == 0)
1460 {
1461 it++;
1462 if (it == m_ceBsrRxed.end())
1463 {
1464 // restart from the first
1465 it = m_ceBsrRxed.begin();
1466 }
1467 NS_LOG_DEBUG(this << " UE discarded for CQI = 0, RNTI " << uldci.m_rnti);
1468 // remove UE from allocation map
1469 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1470 {
1471 rbgAllocationMap.at(i) = 0;
1472 }
1473 continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
1474 }
1475 uldci.m_mcs = m_amc->GetMcsFromCqi(cqi);
1476 }
1477 uldci.m_tbSize =
1478 (m_amc->GetUlTbSizeFromMcs(uldci.m_mcs, rbPerFlow) / 8); // MCS 0 -> UL-AMC TBD
1479
1481 uldci.m_ndi = 1;
1482 uldci.m_cceIndex = 0;
1483 uldci.m_aggrLevel = 1;
1484 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
1485 uldci.m_hopping = false;
1486 uldci.m_n2Dmrs = 0;
1487 uldci.m_tpc = 0; // no power control
1488 uldci.m_cqiRequest = false; // only period CQI at this stage
1489 uldci.m_ulIndex = 0; // TDD parameter
1490 uldci.m_dai = 1; // TDD parameter
1491 uldci.m_freqHopping = 0;
1492 uldci.m_pdcchPowerOffset = 0; // not used
1493 ret.m_dciList.push_back(uldci);
1494 // store DCI for HARQ_PERIOD
1495 uint8_t harqId = 0;
1496 if (m_harqOn)
1497 {
1498 std::map<uint16_t, uint8_t>::iterator itProcId;
1499 itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti);
1500 if (itProcId == m_ulHarqCurrentProcessId.end())
1501 {
1502 NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti);
1503 }
1504 harqId = (*itProcId).second;
1505 std::map<uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci =
1507 if (itDci == m_ulHarqProcessesDciBuffer.end())
1508 {
1509 NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI "
1510 << uldci.m_rnti);
1511 }
1512 (*itDci).second.at(harqId) = uldci;
1513 // Update HARQ process status (RV 0)
1514 std::map<uint16_t, UlHarqProcessesStatus_t>::iterator itStat =
1515 m_ulHarqProcessesStatus.find(uldci.m_rnti);
1516 if (itStat == m_ulHarqProcessesStatus.end())
1517 {
1518 NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) "
1519 << uldci.m_rnti);
1520 }
1521 (*itStat).second.at(harqId) = 0;
1522 }
1523
1524 NS_LOG_INFO(this << " UL Allocation - UE " << (*it).first << " startPRB "
1525 << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen
1526 << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize "
1527 << uldci.m_tbSize << " harqId " << (uint16_t)harqId);
1528
1529 it++;
1530 if (it == m_ceBsrRxed.end())
1531 {
1532 // restart from the first
1533 it = m_ceBsrRxed.begin();
1534 }
1535 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1536 {
1537 // Stop allocation: no more PRBs
1538 m_nextRntiUl = (*it).first;
1539 break;
1540 }
1541 } while (((*it).first != m_nextRntiUl) && (rbPerFlow != 0));
1542
1543 m_allocationMaps.insert(
1544 std::pair<uint16_t, std::vector<uint16_t>>(params.m_sfnSf, rbgAllocationMap));
1545
1547}
1548
1549void
1552{
1553 NS_LOG_FUNCTION(this);
1554}
1555
1556void
1559{
1560 NS_LOG_FUNCTION(this);
1561}
1562
1563void
1566{
1567 NS_LOG_FUNCTION(this);
1568
1569 std::map<uint16_t, uint32_t>::iterator it;
1570
1571 for (unsigned int i = 0; i < params.m_macCeList.size(); i++)
1572 {
1573 if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR)
1574 {
1575 // buffer status report
1576 // note that this scheduler does not differentiate the
1577 // allocation according to which LCGs have more/less bytes
1578 // to send.
1579 // Hence the BSR of different LCGs are just summed up to get
1580 // a total queue size that is used for allocation purposes.
1581
1582 uint32_t buffer = 0;
1583 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1584 {
1585 uint8_t bsrId = params.m_macCeList.at(i).m_macCeValue.m_bufferStatus.at(lcg);
1586 buffer += BufferSizeLevelBsr::BsrId2BufferSize(bsrId);
1587 }
1588
1589 uint16_t rnti = params.m_macCeList.at(i).m_rnti;
1590 it = m_ceBsrRxed.find(rnti);
1591 if (it == m_ceBsrRxed.end())
1592 {
1593 // create the new entry
1594 m_ceBsrRxed.insert(std::pair<uint16_t, uint32_t>(rnti, buffer));
1595 NS_LOG_INFO(this << " Insert RNTI " << rnti << " queue " << buffer);
1596 }
1597 else
1598 {
1599 // update the buffer size value
1600 (*it).second = buffer;
1601 NS_LOG_INFO(this << " Update RNTI " << rnti << " queue " << buffer);
1602 }
1603 }
1604 }
1605}
1606
1607void
1610{
1611 NS_LOG_FUNCTION(this);
1612
1613 switch (m_ulCqiFilter)
1614 {
1616 // filter all the CQIs that are not SRS based
1617 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1618 {
1619 return;
1620 }
1621 }
1622 break;
1624 // filter all the CQIs that are not SRS based
1625 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1626 {
1627 return;
1628 }
1629 }
1630 break;
1631 default:
1632 NS_FATAL_ERROR("Unknown UL CQI type");
1633 }
1634 switch (params.m_ulCqi.m_type)
1635 {
1636 case UlCqi_s::PUSCH: {
1637 std::map<uint16_t, std::vector<uint16_t>>::iterator itMap;
1638 std::map<uint16_t, std::vector<double>>::iterator itCqi;
1639 itMap = m_allocationMaps.find(params.m_sfnSf);
1640 if (itMap == m_allocationMaps.end())
1641 {
1642 NS_LOG_INFO(this << " Does not find info on allocation, size : "
1643 << m_allocationMaps.size());
1644 return;
1645 }
1646 for (uint32_t i = 0; i < (*itMap).second.size(); i++)
1647 {
1648 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
1649 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i));
1650 itCqi = m_ueCqi.find((*itMap).second.at(i));
1651 if (itCqi == m_ueCqi.end())
1652 {
1653 // create a new entry
1654 std::vector<double> newCqi;
1655 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1656 {
1657 if (i == j)
1658 {
1659 newCqi.push_back(sinr);
1660 }
1661 else
1662 {
1663 // initialize with NO_SINR value.
1664 newCqi.push_back(30.0);
1665 }
1666 }
1667 m_ueCqi.insert(
1668 std::pair<uint16_t, std::vector<double>>((*itMap).second.at(i), newCqi));
1669 // generate correspondent timer
1670 m_ueCqiTimers.insert(
1671 std::pair<uint16_t, uint32_t>((*itMap).second.at(i), m_cqiTimersThreshold));
1672 }
1673 else
1674 {
1675 // update the value
1676 (*itCqi).second.at(i) = sinr;
1677 // update correspondent timer
1678 std::map<uint16_t, uint32_t>::iterator itTimers;
1679 itTimers = m_ueCqiTimers.find((*itMap).second.at(i));
1680 (*itTimers).second = m_cqiTimersThreshold;
1681 }
1682 }
1683 // remove obsolete info on allocation
1684 m_allocationMaps.erase(itMap);
1685 }
1686 break;
1687 case UlCqi_s::SRS: {
1688 // get the RNTI from vendor specific parameters
1689 uint16_t rnti = 0;
1690 NS_ASSERT(!params.m_vendorSpecificList.empty());
1691 for (std::size_t i = 0; i < params.m_vendorSpecificList.size(); i++)
1692 {
1693 if (params.m_vendorSpecificList.at(i).m_type == SRS_CQI_RNTI_VSP)
1694 {
1695 Ptr<SrsCqiRntiVsp> vsp =
1696 DynamicCast<SrsCqiRntiVsp>(params.m_vendorSpecificList.at(i).m_value);
1697 rnti = vsp->GetRnti();
1698 }
1699 }
1700 std::map<uint16_t, std::vector<double>>::iterator itCqi;
1701 itCqi = m_ueCqi.find(rnti);
1702 if (itCqi == m_ueCqi.end())
1703 {
1704 // create a new entry
1705 std::vector<double> newCqi;
1706 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1707 {
1708 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1709 newCqi.push_back(sinr);
1710 NS_LOG_INFO(this << " RNTI " << rnti << " new SRS-CQI for RB " << j << " value "
1711 << sinr);
1712 }
1713 m_ueCqi.insert(std::pair<uint16_t, std::vector<double>>(rnti, newCqi));
1714 // generate correspondent timer
1715 m_ueCqiTimers.insert(std::pair<uint16_t, uint32_t>(rnti, m_cqiTimersThreshold));
1716 }
1717 else
1718 {
1719 // update the values
1720 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1721 {
1722 double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(j));
1723 (*itCqi).second.at(j) = sinr;
1724 NS_LOG_INFO(this << " RNTI " << rnti << " update SRS-CQI for RB " << j << " value "
1725 << sinr);
1726 }
1727 // update correspondent timer
1728 std::map<uint16_t, uint32_t>::iterator itTimers;
1729 itTimers = m_ueCqiTimers.find(rnti);
1730 (*itTimers).second = m_cqiTimersThreshold;
1731 }
1732 }
1733 break;
1734 case UlCqi_s::PUCCH_1:
1735 case UlCqi_s::PUCCH_2:
1736 case UlCqi_s::PRACH: {
1737 NS_FATAL_ERROR("PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1738 }
1739 break;
1740 default:
1741 NS_FATAL_ERROR("Unknown type of UL-CQI");
1742 }
1743}
1744
1745void
1747{
1748 NS_LOG_FUNCTION(this << m_p10CqiTimers.size());
1749 // refresh DL CQI P01 Map
1750 std::map<uint16_t, uint32_t>::iterator itP10 = m_p10CqiTimers.begin();
1751 while (itP10 != m_p10CqiTimers.end())
1752 {
1753 NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is "
1754 << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1755 if ((*itP10).second == 0)
1756 {
1757 // delete correspondent entries
1758 std::map<uint16_t, uint8_t>::iterator itMap = m_p10CqiRxed.find((*itP10).first);
1759 NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(),
1760 " Does not find CQI report for user " << (*itP10).first);
1761 NS_LOG_INFO(this << " P10-CQI exired for user " << (*itP10).first);
1762 m_p10CqiRxed.erase(itMap);
1763 std::map<uint16_t, uint32_t>::iterator temp = itP10;
1764 itP10++;
1765 m_p10CqiTimers.erase(temp);
1766 }
1767 else
1768 {
1769 (*itP10).second--;
1770 itP10++;
1771 }
1772 }
1773}
1774
1775void
1777{
1778 // refresh UL CQI Map
1779 std::map<uint16_t, uint32_t>::iterator itUl = m_ueCqiTimers.begin();
1780 while (itUl != m_ueCqiTimers.end())
1781 {
1782 NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is "
1783 << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
1784 if ((*itUl).second == 0)
1785 {
1786 // delete correspondent entries
1787 std::map<uint16_t, std::vector<double>>::iterator itMap = m_ueCqi.find((*itUl).first);
1788 NS_ASSERT_MSG(itMap != m_ueCqi.end(),
1789 " Does not find CQI report for user " << (*itUl).first);
1790 NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first);
1791 (*itMap).second.clear();
1792 m_ueCqi.erase(itMap);
1793 std::map<uint16_t, uint32_t>::iterator temp = itUl;
1794 itUl++;
1795 m_ueCqiTimers.erase(temp);
1796 }
1797 else
1798 {
1799 (*itUl).second--;
1800 itUl++;
1801 }
1802 }
1803}
1804
1805void
1806RrFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
1807{
1808 NS_LOG_FUNCTION(this);
1809 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
1810 for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++)
1811 {
1812 if (((*it).m_rnti == rnti) && ((*it).m_logicalChannelIdentity == lcid))
1813 {
1814 NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue "
1815 << (*it).m_rlcTransmissionQueueSize << " retxqueue "
1816 << (*it).m_rlcRetransmissionQueueSize << " status "
1817 << (*it).m_rlcStatusPduSize << " decrease " << size);
1818 // Update queues: RLC tx order Status, ReTx, Tx
1819 // Update status queue
1820 if (((*it).m_rlcStatusPduSize > 0) && (size >= (*it).m_rlcStatusPduSize))
1821 {
1822 (*it).m_rlcStatusPduSize = 0;
1823 }
1824 else if (((*it).m_rlcRetransmissionQueueSize > 0) &&
1825 (size >= (*it).m_rlcRetransmissionQueueSize))
1826 {
1827 (*it).m_rlcRetransmissionQueueSize = 0;
1828 }
1829 else if ((*it).m_rlcTransmissionQueueSize > 0)
1830 {
1831 uint32_t rlcOverhead;
1832 if (lcid == 1)
1833 {
1834 // for SRB1 (using RLC AM) it's better to
1835 // overestimate RLC overhead rather than
1836 // underestimate it and risk unneeded
1837 // segmentation which increases delay
1838 rlcOverhead = 4;
1839 }
1840 else
1841 {
1842 // minimum RLC overhead due to header
1843 rlcOverhead = 2;
1844 }
1845 // update transmission queue
1846 if ((*it).m_rlcTransmissionQueueSize <= size - rlcOverhead)
1847 {
1848 (*it).m_rlcTransmissionQueueSize = 0;
1849 }
1850 else
1851 {
1852 (*it).m_rlcTransmissionQueueSize -= size - rlcOverhead;
1853 }
1854 }
1855 return;
1856 }
1857 }
1858}
1859
1860void
1861RrFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
1862{
1863 size = size - 2; // remove the minimum RLC overhead
1864 std::map<uint16_t, uint32_t>::iterator it = m_ceBsrRxed.find(rnti);
1865 if (it != m_ceBsrRxed.end())
1866 {
1867 NS_LOG_INFO(this << " Update RLC BSR UE " << rnti << " size " << size << " BSR "
1868 << (*it).second);
1869 if ((*it).second >= size)
1870 {
1871 (*it).second -= size;
1872 }
1873 else
1874 {
1875 (*it).second = 0;
1876 }
1877 }
1878 else
1879 {
1880 NS_LOG_ERROR(this << " Does not find BSR report info of UE " << rnti);
1881 }
1882}
1883
1884void
1886{
1887 NS_LOG_FUNCTION(this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
1889 params.m_rnti = rnti;
1890 params.m_transmissionMode = txMode;
1892}
1893
1894} // 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:936
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > 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.