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