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