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