A Discrete-Event Network Simulator
API
lte-enb-mac.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  * Nicola Baldo <nbaldo@cttc.es>
19  * Modified by:
20  * Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
21  * Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
22  */
23 
24 #include "lte-amc.h"
25 #include "lte-control-messages.h"
26 #include "lte-enb-net-device.h"
27 #include "lte-ue-net-device.h"
28 
29 #include "ns3/lte-enb-cmac-sap.h"
30 #include "ns3/lte-mac-sap.h"
31 #include <ns3/log.h>
32 #include <ns3/lte-common.h>
33 #include <ns3/lte-enb-mac.h>
34 #include <ns3/lte-radio-bearer-tag.h>
35 #include <ns3/lte-ue-phy.h>
36 #include <ns3/packet.h>
37 #include <ns3/pointer.h>
38 #include <ns3/simulator.h>
39 
40 namespace ns3
41 {
42 
43 NS_LOG_COMPONENT_DEFINE("LteEnbMac");
44 
46 
47 // //////////////////////////////////////
48 // member SAP forwarders
49 // //////////////////////////////////////
50 
53 {
54  public:
61 
62  // inherited from LteEnbCmacSapProvider
63  void ConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth) override;
64  void AddUe(uint16_t rnti) override;
65  void RemoveUe(uint16_t rnti) override;
66  void AddLc(LcInfo lcinfo, LteMacSapUser* msu) override;
67  void ReconfigureLc(LcInfo lcinfo) override;
68  void ReleaseLc(uint16_t rnti, uint8_t lcid) override;
70  RachConfig GetRachConfig() override;
72 
73  private:
75 };
76 
78  : m_mac(mac)
79 {
80 }
81 
82 void
83 EnbMacMemberLteEnbCmacSapProvider::ConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth)
84 {
85  m_mac->DoConfigureMac(ulBandwidth, dlBandwidth);
86 }
87 
88 void
90 {
91  m_mac->DoAddUe(rnti);
92 }
93 
94 void
96 {
97  m_mac->DoRemoveUe(rnti);
98 }
99 
100 void
102 {
103  m_mac->DoAddLc(lcinfo, msu);
104 }
105 
106 void
108 {
109  m_mac->DoReconfigureLc(lcinfo);
110 }
111 
112 void
114 {
115  m_mac->DoReleaseLc(rnti, lcid);
116 }
117 
118 void
120 {
122 }
123 
126 {
127  return m_mac->DoGetRachConfig();
128 }
129 
132 {
133  return m_mac->DoAllocateNcRaPreamble(rnti);
134 }
135 
138 {
139  public:
146 
147  void SchedDlConfigInd(const struct SchedDlConfigIndParameters& params) override;
148  void SchedUlConfigInd(const struct SchedUlConfigIndParameters& params) override;
149 
150  private:
152 };
153 
155  : m_mac(mac)
156 {
157 }
158 
159 void
161 {
163 }
164 
165 void
167 {
169 }
170 
173 {
174  public:
181 
182  void CschedCellConfigCnf(const struct CschedCellConfigCnfParameters& params) override;
183  void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters& params) override;
184  void CschedLcConfigCnf(const struct CschedLcConfigCnfParameters& params) override;
185  void CschedLcReleaseCnf(const struct CschedLcReleaseCnfParameters& params) override;
186  void CschedUeReleaseCnf(const struct CschedUeReleaseCnfParameters& params) override;
189  const struct CschedCellConfigUpdateIndParameters& params) override;
190 
191  private:
193 };
194 
196  : m_mac(mac)
197 {
198 }
199 
200 void
203 {
205 }
206 
207 void
209 {
211 }
212 
213 void
215 {
217 }
218 
219 void
221  const struct CschedLcReleaseCnfParameters& params)
222 {
224 }
225 
226 void
228  const struct CschedUeReleaseCnfParameters& params)
229 {
231 }
232 
233 void
236 {
238 }
239 
240 void
243 {
245 }
246 
249 {
250  public:
257 
258  // inherited from LteEnbPhySapUser
259  void ReceivePhyPdu(Ptr<Packet> p) override;
260  void SubframeIndication(uint32_t frameNo, uint32_t subframeNo) override;
262  void ReceiveRachPreamble(uint32_t prachId) override;
266 
267  private:
269 };
270 
272  : m_mac(mac)
273 {
274 }
275 
276 void
278 {
280 }
281 
282 void
283 EnbMacMemberLteEnbPhySapUser::SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
284 {
285  m_mac->DoSubframeIndication(frameNo, subframeNo);
286 }
287 
288 void
290 {
292 }
293 
294 void
296 {
297  m_mac->DoReceiveRachPreamble(prachId);
298 }
299 
300 void
302 {
303  m_mac->DoUlCqiReport(ulcqi);
304 }
305 
306 void
308 {
310 }
311 
312 void
314 {
316 }
317 
318 // //////////////////////////////////////
319 // generic LteEnbMac methods
320 // //////////////////////////////////////
321 
322 TypeId
324 {
325  static TypeId tid =
326  TypeId("ns3::LteEnbMac")
327  .SetParent<Object>()
328  .SetGroupName("Lte")
329  .AddConstructor<LteEnbMac>()
330  .AddAttribute("NumberOfRaPreambles",
331  "how many random access preambles are available for the contention based "
332  "RACH process",
333  UintegerValue(52),
335  MakeUintegerChecker<uint8_t>(4, 64))
336  .AddAttribute("PreambleTransMax",
337  "Maximum number of random access preamble transmissions",
338  UintegerValue(50),
340  MakeUintegerChecker<uint8_t>(3, 200))
341  .AddAttribute("RaResponseWindowSize",
342  "length of the window (in TTIs) for the reception of the random access "
343  "response (RAR); the resulting RAR timeout is this value + 3 ms",
344  UintegerValue(3),
346  MakeUintegerChecker<uint8_t>(2, 10))
347  .AddAttribute("ConnEstFailCount",
348  "how many time T300 timer can expire on the same cell",
349  UintegerValue(1),
351  MakeUintegerChecker<uint8_t>(1, 4))
352  .AddTraceSource("DlScheduling",
353  "Information regarding DL scheduling.",
355  "ns3::LteEnbMac::DlSchedulingTracedCallback")
356  .AddTraceSource("UlScheduling",
357  "Information regarding UL scheduling.",
359  "ns3::LteEnbMac::UlSchedulingTracedCallback")
360  .AddAttribute("ComponentCarrierId",
361  "ComponentCarrier Id, needed to reply on the appropriate sap.",
362  UintegerValue(0),
364  MakeUintegerChecker<uint8_t>(0, 4));
365 
366  return tid;
367 }
368 
370  : m_ccmMacSapUser(nullptr)
371 {
372  NS_LOG_FUNCTION(this);
379 }
380 
382 {
383  NS_LOG_FUNCTION(this);
384 }
385 
386 void
388 {
389  NS_LOG_FUNCTION(this);
390  m_dlCqiReceived.clear();
391  m_ulCqiReceived.clear();
392  m_ulCeReceived.clear();
393  m_dlInfoListReceived.clear();
394  m_ulInfoListReceived.clear();
396  delete m_macSapProvider;
397  delete m_cmacSapProvider;
398  delete m_schedSapUser;
399  delete m_cschedSapUser;
400  delete m_enbPhySapUser;
401  delete m_ccmMacSapProvider;
402 }
403 
404 void
406 {
407  m_componentCarrierId = index;
408 }
409 
410 void
412 {
413  m_schedSapProvider = s;
414 }
415 
418 {
419  return m_schedSapUser;
420 }
421 
422 void
424 {
426 }
427 
430 {
431  return m_cschedSapUser;
432 }
433 
434 void
436 {
437  m_macSapUser = s;
438 }
439 
442 {
443  return m_macSapProvider;
444 }
445 
446 void
448 {
449  m_cmacSapUser = s;
450 }
451 
454 {
455  return m_cmacSapProvider;
456 }
457 
458 void
460 {
462 }
463 
466 {
467  return m_enbPhySapUser;
468 }
469 
470 void
472 {
473  m_ccmMacSapUser = s;
474 }
475 
478 {
479  return m_ccmMacSapProvider;
480 }
481 
482 void
483 LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
484 {
485  NS_LOG_FUNCTION(this << " EnbMac - frame " << frameNo << " subframe " << subframeNo);
486 
487  // Store current frame / subframe number
488  m_frameNo = frameNo;
489  m_subframeNo = subframeNo;
490 
491  // --- DOWNLINK ---
492  // Send Dl-CQI info to the scheduler
493  if (!m_dlCqiReceived.empty())
494  {
496  dlcqiInfoReq.m_sfnSf = ((0x3FF & frameNo) << 4) | (0xF & subframeNo);
497  dlcqiInfoReq.m_cqiList.insert(dlcqiInfoReq.m_cqiList.begin(),
498  m_dlCqiReceived.begin(),
499  m_dlCqiReceived.end());
500  m_dlCqiReceived.erase(m_dlCqiReceived.begin(), m_dlCqiReceived.end());
501  m_schedSapProvider->SchedDlCqiInfoReq(dlcqiInfoReq);
502  }
503 
504  if (!m_receivedRachPreambleCount.empty())
505  {
506  // process received RACH preambles and notify the scheduler
508  NS_ASSERT(subframeNo > 0 && subframeNo <= 10); // subframe in 1..10
509  for (std::map<uint8_t, uint32_t>::const_iterator it = m_receivedRachPreambleCount.begin();
510  it != m_receivedRachPreambleCount.end();
511  ++it)
512  {
513  NS_LOG_INFO(this << " preambleId " << (uint32_t)it->first << ": " << it->second
514  << " received");
515  NS_ASSERT(it->second != 0);
516  if (it->second > 1)
517  {
518  NS_LOG_INFO("preambleId " << (uint32_t)it->first << ": collision");
519  // in case of collision we assume that no preamble is
520  // successfully received, hence no RAR is sent
521  }
522  else
523  {
524  uint16_t rnti;
525  std::map<uint8_t, NcRaPreambleInfo>::iterator jt =
526  m_allocatedNcRaPreambleMap.find(it->first);
527  if (jt != m_allocatedNcRaPreambleMap.end())
528  {
529  rnti = jt->second.rnti;
530  NS_LOG_INFO("preambleId previously allocated for NC based RA, RNTI ="
531  << (uint32_t)rnti << ", sending RAR");
532  }
533  else
534  {
536  NS_LOG_INFO("preambleId " << (uint32_t)it->first << ": allocated T-C-RNTI "
537  << (uint32_t)rnti << ", sending RAR");
538  }
539 
540  RachListElement_s rachLe;
541  rachLe.m_rnti = rnti;
542  rachLe.m_estimatedSize = 144; // to be confirmed
543  rachInfoReqParams.m_rachList.push_back(rachLe);
544  m_rapIdRntiMap.insert(std::pair<uint16_t, uint32_t>(rnti, it->first));
545  }
546  }
547  m_schedSapProvider->SchedDlRachInfoReq(rachInfoReqParams);
549  }
550  // Get downlink transmission opportunities
551  uint32_t dlSchedFrameNo = m_frameNo;
552  uint32_t dlSchedSubframeNo = m_subframeNo;
553  // NS_LOG_DEBUG (this << " sfn " << frameNo << " sbfn " << subframeNo);
554  if (dlSchedSubframeNo + m_macChTtiDelay > 10)
555  {
556  dlSchedFrameNo++;
557  dlSchedSubframeNo = (dlSchedSubframeNo + m_macChTtiDelay) % 10;
558  }
559  else
560  {
561  dlSchedSubframeNo = dlSchedSubframeNo + m_macChTtiDelay;
562  }
564  dlparams.m_sfnSf = ((0x3FF & dlSchedFrameNo) << 4) | (0xF & dlSchedSubframeNo);
565 
566  // Forward DL HARQ feebacks collected during last TTI
567  if (!m_dlInfoListReceived.empty())
568  {
570  // empty local buffer
571  m_dlInfoListReceived.clear();
572  }
573 
575 
576  // --- UPLINK ---
577  // Send UL-CQI info to the scheduler
578  for (std::size_t i = 0; i < m_ulCqiReceived.size(); i++)
579  {
580  if (subframeNo > 1)
581  {
582  m_ulCqiReceived.at(i).m_sfnSf = ((0x3FF & frameNo) << 4) | (0xF & (subframeNo - 1));
583  }
584  else
585  {
586  m_ulCqiReceived.at(i).m_sfnSf = ((0x3FF & (frameNo - 1)) << 4) | (0xF & 10);
587  }
589  }
590  m_ulCqiReceived.clear();
591 
592  // Send BSR reports to the scheduler
593  if (!m_ulCeReceived.empty())
594  {
596  ulMacReq.m_sfnSf = ((0x3FF & frameNo) << 4) | (0xF & subframeNo);
597  ulMacReq.m_macCeList.insert(ulMacReq.m_macCeList.begin(),
598  m_ulCeReceived.begin(),
599  m_ulCeReceived.end());
600  m_ulCeReceived.erase(m_ulCeReceived.begin(), m_ulCeReceived.end());
602  }
603 
604  // Get uplink transmission opportunities
605  uint32_t ulSchedFrameNo = m_frameNo;
606  uint32_t ulSchedSubframeNo = m_subframeNo;
607  // NS_LOG_DEBUG (this << " sfn " << frameNo << " sbfn " << subframeNo);
608  if (ulSchedSubframeNo + (m_macChTtiDelay + UL_PUSCH_TTIS_DELAY) > 10)
609  {
610  ulSchedFrameNo++;
611  ulSchedSubframeNo = (ulSchedSubframeNo + (m_macChTtiDelay + UL_PUSCH_TTIS_DELAY)) % 10;
612  }
613  else
614  {
615  ulSchedSubframeNo = ulSchedSubframeNo + (m_macChTtiDelay + UL_PUSCH_TTIS_DELAY);
616  }
618  ulparams.m_sfnSf = ((0x3FF & ulSchedFrameNo) << 4) | (0xF & ulSchedSubframeNo);
619 
620  // Forward DL HARQ feebacks collected during last TTI
621  if (!m_ulInfoListReceived.empty())
622  {
624  // empty local buffer
625  m_ulInfoListReceived.clear();
626  }
627 
629 }
630 
631 void
633 {
634  NS_LOG_FUNCTION(this << msg);
635  if (msg->GetMessageType() == LteControlMessage::DL_CQI)
636  {
637  Ptr<DlCqiLteControlMessage> dlcqi = DynamicCast<DlCqiLteControlMessage>(msg);
639  }
640  else if (msg->GetMessageType() == LteControlMessage::BSR)
641  {
642  Ptr<BsrLteControlMessage> bsr = DynamicCast<BsrLteControlMessage>(msg);
643  ReceiveBsrMessage(bsr->GetBsr());
644  }
645  else if (msg->GetMessageType() == LteControlMessage::DL_HARQ)
646  {
648  DynamicCast<DlHarqFeedbackLteControlMessage>(msg);
649  DoDlInfoListElementHarqFeeback(dlharq->GetDlHarqFeedback());
650  }
651  else
652  {
653  NS_LOG_LOGIC(this << " LteControlMessage type " << msg->GetMessageType()
654  << " not recognized");
655  }
656 }
657 
658 void
660 {
661  NS_LOG_FUNCTION(this << (uint32_t)rapId);
662  // just record that the preamble has been received; it will be processed later
663  ++m_receivedRachPreambleCount[rapId]; // will create entry if not exists
664 }
665 
666 void
668 {
669  if (ulcqi.m_ulCqi.m_type == UlCqi_s::PUSCH)
670  {
671  NS_LOG_DEBUG(this << " eNB rxed an PUSCH UL-CQI");
672  }
673  else if (ulcqi.m_ulCqi.m_type == UlCqi_s::SRS)
674  {
675  NS_LOG_DEBUG(this << " eNB rxed an SRS UL-CQI");
676  }
677  m_ulCqiReceived.push_back(ulcqi);
678 }
679 
680 void
682 {
683  NS_LOG_FUNCTION(this << msg);
684 
685  CqiListElement_s dlcqi = msg->GetDlCqi();
686  NS_LOG_LOGIC(this << "Enb Received DL-CQI rnti" << dlcqi.m_rnti);
687  NS_ASSERT(dlcqi.m_rnti != 0);
688  m_dlCqiReceived.push_back(dlcqi);
689 }
690 
691 void
693 {
694  NS_LOG_FUNCTION(this);
696 }
697 
698 void
700 {
701  NS_LOG_FUNCTION(this);
702  NS_LOG_DEBUG(this << " bsr Size " << (uint16_t)m_ulCeReceived.size());
703  // send to LteCcmMacSapUser
704  m_ulCeReceived.push_back(
705  bsr); // this to called when LteUlCcmSapProvider::ReportMacCeToScheduler is called
706  NS_LOG_DEBUG(this << " bsr Size after push_back " << (uint16_t)m_ulCeReceived.size());
707 }
708 
709 void
711 {
712  NS_LOG_FUNCTION(this);
713  LteRadioBearerTag tag;
714  p->RemovePacketTag(tag);
715 
716  // store info of the packet received
717 
718  // std::map <uint16_t,UlInfoListElement_s>::iterator it;
719  // u_int rnti = tag.GetRnti ();
720  // u_int lcid = tag.GetLcid ();
721  // it = m_ulInfoListElements.find (tag.GetRnti ());
722  // if (it == m_ulInfoListElements.end ())
723  // {
724  // // new RNTI
725  // UlInfoListElement_s ulinfonew;
726  // ulinfonew.m_rnti = tag.GetRnti ();
727  // // always allocate full size of ulReception vector, initializing all elements to 0
728  // ulinfonew.m_ulReception.assign (MAX_LC_LIST+1, 0);
729  // // set the element for the current LCID
730  // ulinfonew.m_ulReception.at (tag.GetLcid ()) = p->GetSize ();
731  // ulinfonew.m_receptionStatus = UlInfoListElement_s::Ok;
732  // ulinfonew.m_tpc = 0; // Tx power control not implemented at this stage
733  // m_ulInfoListElements.insert (std::pair<uint16_t, UlInfoListElement_s > (tag.GetRnti (),
734  // ulinfonew));
735  //
736  // }
737  // else
738  // {
739  // // existing RNTI: we just set the value for the current
740  // // LCID. Note that the corresponding element had already been
741  // // allocated previously.
742  // NS_ASSERT_MSG ((*it).second.m_ulReception.at (tag.GetLcid ()) == 0, "would overwrite
743  // previously written ulReception element");
744  // (*it).second.m_ulReception.at (tag.GetLcid ()) = p->GetSize ();
745  // (*it).second.m_receptionStatus = UlInfoListElement_s::Ok;
746  // }
747 
748  // forward the packet to the correspondent RLC
749  uint16_t rnti = tag.GetRnti();
750  uint8_t lcid = tag.GetLcid();
751  std::map<uint16_t, std::map<uint8_t, LteMacSapUser*>>::iterator rntiIt =
752  m_rlcAttached.find(rnti);
753  NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "could not find RNTI" << rnti);
754  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = rntiIt->second.find(lcid);
755  // NS_ASSERT_MSG (lcidIt != rntiIt->second.end (), "could not find LCID" << lcid);
756 
758  rxPduParams.p = p;
759  rxPduParams.rnti = rnti;
760  rxPduParams.lcid = lcid;
761 
762  // Receive PDU only if LCID is found
763  if (lcidIt != rntiIt->second.end())
764  {
765  (*lcidIt).second->ReceivePdu(rxPduParams);
766  }
767 }
768 
769 // ////////////////////////////////////////////
770 // CMAC SAP
771 // ////////////////////////////////////////////
772 
773 void
774 LteEnbMac::DoConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth)
775 {
776  NS_LOG_FUNCTION(this << " ulBandwidth=" << ulBandwidth << " dlBandwidth=" << dlBandwidth);
778  // Configure the subset of parameters used by FfMacScheduler
779  params.m_ulBandwidth = ulBandwidth;
780  params.m_dlBandwidth = dlBandwidth;
782  // ...more parameters can be configured
784 }
785 
786 void
787 LteEnbMac::DoAddUe(uint16_t rnti)
788 {
789  NS_LOG_FUNCTION(this << " rnti=" << rnti);
790  std::map<uint8_t, LteMacSapUser*> empty;
791  std::pair<std::map<uint16_t, std::map<uint8_t, LteMacSapUser*>>::iterator, bool> ret =
792  m_rlcAttached.insert(std::pair<uint16_t, std::map<uint8_t, LteMacSapUser*>>(rnti, empty));
793  NS_ASSERT_MSG(ret.second, "element already present, RNTI already existed");
794 
796  params.m_rnti = rnti;
797  params.m_transmissionMode =
798  0; // set to default value (SISO) for avoiding random initialization (valgrind error)
799 
801 
802  // Create DL transmission HARQ buffers
803  std::vector<Ptr<PacketBurst>> dlHarqLayer0pkt;
804  dlHarqLayer0pkt.resize(8);
805  for (uint8_t i = 0; i < 8; i++)
806  {
807  Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
808  dlHarqLayer0pkt.at(i) = pb;
809  }
810  std::vector<Ptr<PacketBurst>> dlHarqLayer1pkt;
811  dlHarqLayer1pkt.resize(8);
812  for (uint8_t i = 0; i < 8; i++)
813  {
814  Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
815  dlHarqLayer1pkt.at(i) = pb;
816  }
818  buf.push_back(dlHarqLayer0pkt);
819  buf.push_back(dlHarqLayer1pkt);
820  m_miDlHarqProcessesPackets.insert(std::pair<uint16_t, DlHarqProcessesBuffer_t>(rnti, buf));
821 }
822 
823 void
824 LteEnbMac::DoRemoveUe(uint16_t rnti)
825 {
826  NS_LOG_FUNCTION(this << " rnti=" << rnti);
828  params.m_rnti = rnti;
830  m_rlcAttached.erase(rnti);
831  m_miDlHarqProcessesPackets.erase(rnti);
832 
833  NS_LOG_DEBUG("start checking for unprocessed preamble for rnti: " << rnti);
834  // remove unprocessed preamble received for RACH during handover
835  std::map<uint8_t, NcRaPreambleInfo>::iterator jt = m_allocatedNcRaPreambleMap.begin();
836  while (jt != m_allocatedNcRaPreambleMap.end())
837  {
838  if (jt->second.rnti == rnti)
839  {
840  std::map<uint8_t, uint32_t>::const_iterator it =
841  m_receivedRachPreambleCount.find(jt->first);
842  if (it != m_receivedRachPreambleCount.end())
843  {
844  m_receivedRachPreambleCount.erase(it->first);
845  }
846  jt = m_allocatedNcRaPreambleMap.erase(jt);
847  }
848  else
849  {
850  ++jt;
851  }
852  }
853 
854  std::vector<MacCeListElement_s>::iterator itCeRxd = m_ulCeReceived.begin();
855  while (itCeRxd != m_ulCeReceived.end())
856  {
857  if (itCeRxd->m_rnti == rnti)
858  {
859  itCeRxd = m_ulCeReceived.erase(itCeRxd);
860  }
861  else
862  {
863  itCeRxd++;
864  }
865  }
866 }
867 
868 void
870 {
871  NS_LOG_FUNCTION(this << lcinfo.rnti << (uint16_t)lcinfo.lcId);
872 
873  std::map<LteFlowId_t, LteMacSapUser*>::iterator it;
874 
875  LteFlowId_t flow(lcinfo.rnti, lcinfo.lcId);
876 
877  std::map<uint16_t, std::map<uint8_t, LteMacSapUser*>>::iterator rntiIt =
878  m_rlcAttached.find(lcinfo.rnti);
879  NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "RNTI not found");
880  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = rntiIt->second.find(lcinfo.lcId);
881  if (lcidIt == rntiIt->second.end())
882  {
883  rntiIt->second.insert(std::pair<uint8_t, LteMacSapUser*>(lcinfo.lcId, msu));
884  }
885  else
886  {
887  NS_LOG_ERROR("LC already exists");
888  }
889 
890  // CCCH (LCID 0) is pre-configured
891  // see FF LTE MAC Scheduler
892  // Interface Specification v1.11,
893  // 4.3.4 logicalChannelConfigListElement
894  if (lcinfo.lcId != 0)
895  {
897  params.m_rnti = lcinfo.rnti;
898  params.m_reconfigureFlag = false;
899 
901  lccle.m_logicalChannelIdentity = lcinfo.lcId;
902  lccle.m_logicalChannelGroup = lcinfo.lcGroup;
904  lccle.m_qosBearerType = lcinfo.isGbr ? LogicalChannelConfigListElement_s::QBT_GBR
906  lccle.m_qci = lcinfo.qci;
907  lccle.m_eRabMaximulBitrateUl = lcinfo.mbrUl;
908  lccle.m_eRabMaximulBitrateDl = lcinfo.mbrDl;
909  lccle.m_eRabGuaranteedBitrateUl = lcinfo.gbrUl;
910  lccle.m_eRabGuaranteedBitrateDl = lcinfo.gbrDl;
911  params.m_logicalChannelConfigList.push_back(lccle);
912 
914  }
915 }
916 
917 void
919 {
920  NS_FATAL_ERROR("not implemented");
921 }
922 
923 void
924 LteEnbMac::DoReleaseLc(uint16_t rnti, uint8_t lcid)
925 {
926  NS_LOG_FUNCTION(this);
927 
928  // Find user based on rnti and then erase lcid stored against the same
929  std::map<uint16_t, std::map<uint8_t, LteMacSapUser*>>::iterator rntiIt =
930  m_rlcAttached.find(rnti);
931  rntiIt->second.erase(lcid);
932 
934  params.m_rnti = rnti;
935  params.m_logicalChannelIdentity.push_back(lcid);
937 }
938 
939 void
941 {
942  NS_LOG_FUNCTION(this);
943 
944  // propagates to scheduler
946  req.m_rnti = params.m_rnti;
947  req.m_transmissionMode = params.m_transmissionMode;
948  req.m_reconfigureFlag = true;
950 }
951 
954 {
956  rc.numberOfRaPreambles = m_numberOfRaPreambles;
957  rc.preambleTransMax = m_preambleTransMax;
958  rc.raResponseWindowSize = m_raResponseWindowSize;
959  rc.connEstFailCount = m_connEstFailCount;
960  return rc;
961 }
962 
965 {
966  bool found = false;
967  uint8_t preambleId;
968  for (preambleId = m_numberOfRaPreambles; preambleId < 64; ++preambleId)
969  {
970  std::map<uint8_t, NcRaPreambleInfo>::iterator it =
971  m_allocatedNcRaPreambleMap.find(preambleId);
983  if ((it != m_allocatedNcRaPreambleMap.end()) && (it->second.expiryTime < Simulator::Now()))
984  {
985  if (!m_cmacSapUser->IsRandomAccessCompleted(it->second.rnti))
986  {
987  // random access of the UE is not completed,
988  // check other preambles
989  continue;
990  }
991  }
992  if ((it == m_allocatedNcRaPreambleMap.end()) || (it->second.expiryTime < Simulator::Now()))
993  {
994  found = true;
995  NcRaPreambleInfo preambleInfo;
996  uint32_t expiryIntervalMs =
997  (uint32_t)m_preambleTransMax * ((uint32_t)m_raResponseWindowSize + 5);
998 
999  preambleInfo.expiryTime = Simulator::Now() + MilliSeconds(expiryIntervalMs);
1000  preambleInfo.rnti = rnti;
1001  NS_LOG_INFO("allocated preamble for NC based RA: preamble "
1002  << preambleId << ", RNTI " << preambleInfo.rnti << ", exiryTime "
1003  << preambleInfo.expiryTime);
1004  m_allocatedNcRaPreambleMap[preambleId] =
1005  preambleInfo; // create if not exist, update otherwise
1006  break;
1007  }
1008  }
1010  if (found)
1011  {
1012  ret.valid = true;
1013  ret.raPreambleId = preambleId;
1014  ret.raPrachMaskIndex = 0;
1015  }
1016  else
1017  {
1018  ret.valid = false;
1019  ret.raPreambleId = 0;
1020  ret.raPrachMaskIndex = 0;
1021  }
1022  return ret;
1023 }
1024 
1025 // ////////////////////////////////////////////
1026 // MAC SAP
1027 // ////////////////////////////////////////////
1028 
1029 void
1031 {
1032  NS_LOG_FUNCTION(this);
1033  LteRadioBearerTag tag(params.rnti, params.lcid, params.layer);
1034  params.pdu->AddPacketTag(tag);
1035  params.componentCarrierId = m_componentCarrierId;
1036  // Store pkt in HARQ buffer
1037  std::map<uint16_t, DlHarqProcessesBuffer_t>::iterator it =
1040  NS_LOG_DEBUG(this << " LAYER " << (uint16_t)tag.GetLayer() << " HARQ ID "
1041  << (uint16_t)params.harqProcessId);
1042 
1043  //(*it).second.at (params.layer).at (params.harqProcessId) = params.pdu;//->Copy ();
1044  (*it).second.at(params.layer).at(params.harqProcessId)->AddPacket(params.pdu);
1046 }
1047 
1048 void
1050 {
1051  NS_LOG_FUNCTION(this);
1053  req.m_rnti = params.rnti;
1054  req.m_logicalChannelIdentity = params.lcid;
1055  req.m_rlcTransmissionQueueSize = params.txQueueSize;
1056  req.m_rlcTransmissionQueueHolDelay = params.txQueueHolDelay;
1057  req.m_rlcRetransmissionQueueSize = params.retxQueueSize;
1058  req.m_rlcRetransmissionHolDelay = params.retxQueueHolDelay;
1059  req.m_rlcStatusPduSize = params.statusPduSize;
1061 }
1062 
1063 // ////////////////////////////////////////////
1064 // SCHED SAP
1065 // ////////////////////////////////////////////
1066 
1067 void
1069 {
1070  NS_LOG_FUNCTION(this);
1071  // Create DL PHY PDU
1072  Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
1073  std::map<LteFlowId_t, LteMacSapUser*>::iterator it;
1075 
1076  for (std::size_t i = 0; i < ind.m_buildDataList.size(); i++)
1077  {
1078  for (std::size_t layer = 0; layer < ind.m_buildDataList.at(i).m_dci.m_ndi.size(); layer++)
1079  {
1080  if (ind.m_buildDataList.at(i).m_dci.m_ndi.at(layer) == 1)
1081  {
1082  // new data -> force emptying correspondent harq pkt buffer
1083  std::map<uint16_t, DlHarqProcessesBuffer_t>::iterator it =
1084  m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti);
1086  for (std::size_t lcId = 0; lcId < (*it).second.size(); lcId++)
1087  {
1088  Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
1089  (*it).second.at(lcId).at(ind.m_buildDataList.at(i).m_dci.m_harqProcess) = pb;
1090  }
1091  }
1092  }
1093  for (std::size_t j = 0; j < ind.m_buildDataList.at(i).m_rlcPduList.size(); j++)
1094  {
1095  for (std::size_t k = 0; k < ind.m_buildDataList.at(i).m_rlcPduList.at(j).size(); k++)
1096  {
1097  if (ind.m_buildDataList.at(i).m_dci.m_ndi.at(k) == 1)
1098  {
1099  // New Data -> retrieve it from RLC
1100  uint16_t rnti = ind.m_buildDataList.at(i).m_rnti;
1101  uint8_t lcid =
1102  ind.m_buildDataList.at(i).m_rlcPduList.at(j).at(k).m_logicalChannelIdentity;
1103  std::map<uint16_t, std::map<uint8_t, LteMacSapUser*>>::iterator rntiIt =
1104  m_rlcAttached.find(rnti);
1105  NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "could not find RNTI" << rnti);
1106  std::map<uint8_t, LteMacSapUser*>::iterator lcidIt = rntiIt->second.find(lcid);
1107  NS_ASSERT_MSG(lcidIt != rntiIt->second.end(),
1108  "could not find LCID" << (uint32_t)lcid << " carrier id:"
1109  << (uint16_t)m_componentCarrierId);
1110  NS_LOG_DEBUG(this << " rnti= " << rnti << " lcid= " << (uint32_t)lcid
1111  << " layer= " << k);
1112  txOpParams.bytes = ind.m_buildDataList.at(i).m_rlcPduList.at(j).at(k).m_size;
1113  txOpParams.layer = k;
1114  txOpParams.harqId = ind.m_buildDataList.at(i).m_dci.m_harqProcess;
1116  txOpParams.rnti = rnti;
1117  txOpParams.lcid = lcid;
1118  (*lcidIt).second->NotifyTxOpportunity(txOpParams);
1119  }
1120  else
1121  {
1122  if (ind.m_buildDataList.at(i).m_dci.m_tbsSize.at(k) > 0)
1123  {
1124  // HARQ retransmission -> retrieve TB from HARQ buffer
1125  std::map<uint16_t, DlHarqProcessesBuffer_t>::iterator it =
1126  m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti);
1128  Ptr<PacketBurst> pb =
1129  (*it).second.at(k).at(ind.m_buildDataList.at(i).m_dci.m_harqProcess);
1130  for (std::list<Ptr<Packet>>::const_iterator j = pb->Begin(); j != pb->End();
1131  ++j)
1132  {
1133  Ptr<Packet> pkt = (*j)->Copy();
1135  }
1136  }
1137  }
1138  }
1139  }
1140  // send the relative DCI
1141  Ptr<DlDciLteControlMessage> msg = Create<DlDciLteControlMessage>();
1142  msg->SetDci(ind.m_buildDataList.at(i).m_dci);
1144  }
1145 
1146  // Fire the trace with the DL information
1147  for (uint32_t i = 0; i < ind.m_buildDataList.size(); i++)
1148  {
1149  // Only one TB used
1150  if (ind.m_buildDataList.at(i).m_dci.m_tbsSize.size() == 1)
1151  {
1152  DlSchedulingCallbackInfo dlSchedulingCallbackInfo;
1153  dlSchedulingCallbackInfo.frameNo = m_frameNo;
1154  dlSchedulingCallbackInfo.subframeNo = m_subframeNo;
1155  dlSchedulingCallbackInfo.rnti = ind.m_buildDataList.at(i).m_dci.m_rnti;
1156  dlSchedulingCallbackInfo.mcsTb1 = ind.m_buildDataList.at(i).m_dci.m_mcs.at(0);
1157  dlSchedulingCallbackInfo.sizeTb1 = ind.m_buildDataList.at(i).m_dci.m_tbsSize.at(0);
1158  dlSchedulingCallbackInfo.mcsTb2 = 0;
1159  dlSchedulingCallbackInfo.sizeTb2 = 0;
1160  dlSchedulingCallbackInfo.componentCarrierId = m_componentCarrierId;
1161  m_dlScheduling(dlSchedulingCallbackInfo);
1162  }
1163  // Two TBs used
1164  else if (ind.m_buildDataList.at(i).m_dci.m_tbsSize.size() == 2)
1165  {
1166  DlSchedulingCallbackInfo dlSchedulingCallbackInfo;
1167  dlSchedulingCallbackInfo.frameNo = m_frameNo;
1168  dlSchedulingCallbackInfo.subframeNo = m_subframeNo;
1169  dlSchedulingCallbackInfo.rnti = ind.m_buildDataList.at(i).m_dci.m_rnti;
1170  dlSchedulingCallbackInfo.mcsTb1 = ind.m_buildDataList.at(i).m_dci.m_mcs.at(0);
1171  dlSchedulingCallbackInfo.sizeTb1 = ind.m_buildDataList.at(i).m_dci.m_tbsSize.at(0);
1172  dlSchedulingCallbackInfo.mcsTb2 = ind.m_buildDataList.at(i).m_dci.m_mcs.at(1);
1173  dlSchedulingCallbackInfo.sizeTb2 = ind.m_buildDataList.at(i).m_dci.m_tbsSize.at(1);
1174  dlSchedulingCallbackInfo.componentCarrierId = m_componentCarrierId;
1175  m_dlScheduling(dlSchedulingCallbackInfo);
1176  }
1177  else
1178  {
1179  NS_FATAL_ERROR("Found element with more than two transport blocks");
1180  }
1181  }
1182 
1183  // Random Access procedure: send RARs
1184  Ptr<RarLteControlMessage> rarMsg = Create<RarLteControlMessage>();
1185  // see TS 36.321 5.1.4; preambles were sent two frames ago
1186  // (plus 3GPP counts subframes from 0, not 1)
1187  uint16_t raRnti;
1188  if (m_subframeNo < 3)
1189  {
1190  raRnti = m_subframeNo + 7; // equivalent to +10-3
1191  }
1192  else
1193  {
1194  raRnti = m_subframeNo - 3;
1195  }
1196  rarMsg->SetRaRnti(raRnti);
1197  for (unsigned int i = 0; i < ind.m_buildRarList.size(); i++)
1198  {
1199  std::map<uint16_t, uint32_t>::iterator itRapId =
1200  m_rapIdRntiMap.find(ind.m_buildRarList.at(i).m_rnti);
1201  if (itRapId == m_rapIdRntiMap.end())
1202  {
1203  NS_FATAL_ERROR("Unable to find rapId of RNTI " << ind.m_buildRarList.at(i).m_rnti);
1204  }
1206  rar.rapId = itRapId->second;
1207  rar.rarPayload = ind.m_buildRarList.at(i);
1208  rarMsg->AddRar(rar);
1209  NS_LOG_INFO(this << " Send RAR message to RNTI " << ind.m_buildRarList.at(i).m_rnti
1210  << " rapId " << itRapId->second);
1211  }
1212  if (!ind.m_buildRarList.empty())
1213  {
1215  }
1216  m_rapIdRntiMap.clear();
1217 }
1218 
1219 void
1221 {
1222  NS_LOG_FUNCTION(this);
1223 
1224  for (unsigned int i = 0; i < ind.m_dciList.size(); i++)
1225  {
1226  // send the correspondent ul dci
1227  Ptr<UlDciLteControlMessage> msg = Create<UlDciLteControlMessage>();
1228  msg->SetDci(ind.m_dciList.at(i));
1230  }
1231 
1232  // Fire the trace with the UL information
1233  for (uint32_t i = 0; i < ind.m_dciList.size(); i++)
1234  {
1236  m_subframeNo,
1237  ind.m_dciList.at(i).m_rnti,
1238  ind.m_dciList.at(i).m_mcs,
1239  ind.m_dciList.at(i).m_tbSize,
1241  }
1242 }
1243 
1244 // ////////////////////////////////////////////
1245 // CSCHED SAP
1246 // ////////////////////////////////////////////
1247 
1248 void
1250 {
1251  NS_LOG_FUNCTION(this);
1252 }
1253 
1254 void
1256 {
1257  NS_LOG_FUNCTION(this);
1258 }
1259 
1260 void
1262 {
1263  NS_LOG_FUNCTION(this);
1264  // Call the CSCHED primitive
1265  // m_cschedSap->LcConfigCompleted();
1266 }
1267 
1268 void
1270 {
1271  NS_LOG_FUNCTION(this);
1272 }
1273 
1274 void
1276 {
1277  NS_LOG_FUNCTION(this);
1278 }
1279 
1280 void
1282 {
1283  NS_LOG_FUNCTION(this);
1284  // propagates to RRC
1285  LteEnbCmacSapUser::UeConfig ueConfigUpdate;
1286  ueConfigUpdate.m_rnti = params.m_rnti;
1287  ueConfigUpdate.m_transmissionMode = params.m_transmissionMode;
1288  m_cmacSapUser->RrcConfigurationUpdateInd(ueConfigUpdate);
1289 }
1290 
1291 void
1294 {
1295  NS_LOG_FUNCTION(this);
1296 }
1297 
1298 void
1300 {
1301  NS_LOG_FUNCTION(this);
1302  m_ulInfoListReceived.push_back(params);
1303 }
1304 
1305 void
1307 {
1308  NS_LOG_FUNCTION(this);
1309  // Update HARQ buffer
1310  std::map<uint16_t, DlHarqProcessesBuffer_t>::iterator it =
1311  m_miDlHarqProcessesPackets.find(params.m_rnti);
1313  for (std::size_t layer = 0; layer < params.m_harqStatus.size(); layer++)
1314  {
1315  if (params.m_harqStatus.at(layer) == DlInfoListElement_s::ACK)
1316  {
1317  // discard buffer
1318  Ptr<PacketBurst> emptyBuf = CreateObject<PacketBurst>();
1319  (*it).second.at(layer).at(params.m_harqProcessId) = emptyBuf;
1320  NS_LOG_DEBUG(this << " HARQ-ACK UE " << params.m_rnti << " harqId "
1321  << (uint16_t)params.m_harqProcessId << " layer " << (uint16_t)layer);
1322  }
1323  else if (params.m_harqStatus.at(layer) == DlInfoListElement_s::NACK)
1324  {
1325  NS_LOG_DEBUG(this << " HARQ-NACK UE " << params.m_rnti << " harqId "
1326  << (uint16_t)params.m_harqProcessId << " layer " << (uint16_t)layer);
1327  }
1328  else
1329  {
1330  NS_FATAL_ERROR(" HARQ functionality not implemented");
1331  }
1332  }
1333  m_dlInfoListReceived.push_back(params);
1334 }
1335 
1336 } // namespace ns3
EnbMacMemberFfMacCschedSapUser class.
Definition: lte-enb-mac.cc:173
void CschedUeReleaseCnf(const struct CschedUeReleaseCnfParameters &params) override
CSCHED_UE_RELEASE_CNF.
Definition: lte-enb-mac.cc:227
void CschedLcReleaseCnf(const struct CschedLcReleaseCnfParameters &params) override
CSCHED_LC_RELEASE_CNF.
Definition: lte-enb-mac.cc:220
EnbMacMemberFfMacCschedSapUser(LteEnbMac *mac)
Constructor.
Definition: lte-enb-mac.cc:195
void CschedLcConfigCnf(const struct CschedLcConfigCnfParameters &params) override
CSCHED_LC_CONFIG_CNF.
Definition: lte-enb-mac.cc:214
void CschedUeConfigUpdateInd(const struct CschedUeConfigUpdateIndParameters &params) override
CSCHED_UE_UPDATE_IND.
Definition: lte-enb-mac.cc:234
void CschedCellConfigUpdateInd(const struct CschedCellConfigUpdateIndParameters &params) override
CSCHED_UE_CONFIG_IND.
Definition: lte-enb-mac.cc:241
void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters &params) override
CSCHED_UE_CONFIG_CNF.
Definition: lte-enb-mac.cc:208
void CschedCellConfigCnf(const struct CschedCellConfigCnfParameters &params) override
CSCHED_CELL_CONFIG_CNF.
Definition: lte-enb-mac.cc:201
EnbMacMemberFfMacSchedSapUser class.
Definition: lte-enb-mac.cc:138
void SchedDlConfigInd(const struct SchedDlConfigIndParameters &params) override
SCHED_DL_CONFIG_IND.
Definition: lte-enb-mac.cc:160
EnbMacMemberFfMacSchedSapUser(LteEnbMac *mac)
Constructor.
Definition: lte-enb-mac.cc:154
void SchedUlConfigInd(const struct SchedUlConfigIndParameters &params) override
SCHED_UL_CONFIG_IND.
Definition: lte-enb-mac.cc:166
EnbMacMemberLteEnbCmacSapProvider class.
Definition: lte-enb-mac.cc:53
void AddLc(LcInfo lcinfo, LteMacSapUser *msu) override
Add a new logical channel.
Definition: lte-enb-mac.cc:101
void UeUpdateConfigurationReq(UeConfig params) override
update the configuration of the UE
Definition: lte-enb-mac.cc:119
void RemoveUe(uint16_t rnti) override
remove the UE, e.g., after handover or termination of the RRC connection
Definition: lte-enb-mac.cc:95
void AddUe(uint16_t rnti) override
Add UE function.
Definition: lte-enb-mac.cc:89
void ReconfigureLc(LcInfo lcinfo) override
Reconfigure an existing logical channel.
Definition: lte-enb-mac.cc:107
AllocateNcRaPreambleReturnValue AllocateNcRaPreamble(uint16_t rnti) override
Allocate a random access preamble for non-contention based random access (e.g., for handover).
Definition: lte-enb-mac.cc:131
void ConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth) override
Definition: lte-enb-mac.cc:83
EnbMacMemberLteEnbCmacSapProvider(LteEnbMac *mac)
Constructor.
Definition: lte-enb-mac.cc:77
void ReleaseLc(uint16_t rnti, uint8_t lcid) override
release an existing logical channel
Definition: lte-enb-mac.cc:113
-------— PHY-SAP
Definition: lte-enb-mac.cc:249
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo) override
Trigger the start from a new frame (input from Phy layer)
Definition: lte-enb-mac.cc:283
void UlInfoListElementHarqFeeback(UlInfoListElement_s params) override
Notify the HARQ on the UL transmission status.
Definition: lte-enb-mac.cc:307
void ReceivePhyPdu(Ptr< Packet > p) override
Called by the Phy to notify the MAC of the reception of a new PHY-PDU.
Definition: lte-enb-mac.cc:277
void DlInfoListElementHarqFeeback(DlInfoListElement_s params) override
Notify the HARQ on the DL transmission status.
Definition: lte-enb-mac.cc:313
void ReceiveLteControlMessage(Ptr< LteControlMessage > msg) override
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Definition: lte-enb-mac.cc:289
void ReceiveRachPreamble(uint32_t prachId) override
notify the reception of a RACH preamble on the PRACH
Definition: lte-enb-mac.cc:295
EnbMacMemberLteEnbPhySapUser(LteEnbMac *mac)
Constructor.
Definition: lte-enb-mac.cc:271
void UlCqiReport(FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi) override
Returns to MAC level the UL-CQI evaluated.
Definition: lte-enb-mac.cc:301
Provides the CSCHED SAP.
virtual void CschedUeConfigReq(const struct CschedUeConfigReqParameters &params)=0
CSCHED_UE_CONFIG_REQ.
virtual void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters &params)=0
CSCHED_UE_RELEASE_REQ.
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters &params)=0
CSCHED_CELL_CONFIG_REQ.
virtual void CschedLcConfigReq(const struct CschedLcConfigReqParameters &params)=0
CSCHED_LC_CONFIG_REQ.
virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters &params)=0
CSCHED_LC_RELEASE_REQ.
FfMacCschedSapUser class.
Provides the SCHED SAP.
virtual void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters &params)=0
SCHED_UL_MAC_CTRL_INFO_REQ.
virtual void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters &params)=0
SCHED_DL_RLC_BUFFER_REQ.
virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters &params)=0
SCHED_UL_TRIGGER_REQ.
virtual void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters &params)=0
SCHED_UL_CQI_INFO_REQ.
virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters &params)=0
SCHED_DL_TRIGGER_REQ.
virtual void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters &params)=0
SCHED_DL_RACH_INFO_REQ.
virtual void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters &params)=0
SCHED_DL_CQI_INFO_REQ.
FfMacSchedSapUser class.
Service Access Point (SAP) offered by the component carrier manager (CCM) by MAC to CCM.
Service Access Point (SAP) offered by MAC to the component carrier manager (CCM).
virtual void UlReceiveMacCe(MacCeListElement_s bsr, uint8_t componentCarrierId)=0
When the Primary Component carrier receive a buffer status report it is sent to the CCM.
Service Access Point (SAP) offered by the eNB MAC to the eNB RRC See Femto Forum MAC Scheduler Interf...
Service Access Point (SAP) offered by the MAC to the RRC See Femto Forum MAC Scheduler Interface Spec...
virtual bool IsRandomAccessCompleted(uint16_t rnti)=0
Is random access completed function.
virtual void RrcConfigurationUpdateInd(UeConfig params)=0
Notify the RRC of a UE config updated requested by the MAC (normally, by the scheduler)
virtual uint16_t AllocateTemporaryCellRnti()=0
request the allocation of a Temporary C-RNTI
This class implements the MAC layer of the eNodeB device.
Definition: lte-enb-mac.h:56
void SetFfMacCschedSapProvider(FfMacCschedSapProvider *s)
Set the control scheduler SAP provider.
Definition: lte-enb-mac.cc:423
~LteEnbMac() override
Definition: lte-enb-mac.cc:381
void DoReceivePhyPdu(Ptr< Packet > p)
legacy public for use the Phy callback
Definition: lte-enb-mac.cc:710
void DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind)
Sched DL Config Indication function.
FfMacSchedSapUser * m_schedSapUser
the Sched SAP user
Definition: lte-enb-mac.h:399
void DoCschedCellConfigCnf(FfMacCschedSapUser::CschedCellConfigCnfParameters params)
CSched Cell Config configure function.
FfMacCschedSapProvider * m_cschedSapProvider
the Csched SAP provider
Definition: lte-enb-mac.h:398
void SetLteEnbPhySapProvider(LteEnbPhySapProvider *s)
Set the PHY SAP Provider.
Definition: lte-enb-mac.cc:459
uint32_t m_frameNo
frame number of current subframe indication
Definition: lte-enb-mac.h:412
void DoDispose() override
Destructor implementation.
Definition: lte-enb-mac.cc:387
LteEnbPhySapProvider * m_enbPhySapProvider
the ENB Phy SAP provider
Definition: lte-enb-mac.h:403
void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Report Buffer Status function.
FfMacCschedSapUser * GetFfMacCschedSapUser()
Get the control scheduler SAP user.
Definition: lte-enb-mac.cc:429
FfMacCschedSapUser * m_cschedSapUser
the CSched SAP user
Definition: lte-enb-mac.h:400
static TypeId GetTypeId()
Get the type ID.
Definition: lte-enb-mac.cc:323
friend class EnbMacMemberFfMacCschedSapUser
allow EnbMacMemberFfMacCschedSapUser class friend access
Definition: lte-enb-mac.h:64
LteCcmMacSapUser * m_ccmMacSapUser
CCM MAC SAP user.
Definition: lte-enb-mac.h:408
void DoCschedUeReleaseCnf(FfMacCschedSapUser::CschedUeReleaseCnfParameters params)
CSched UE Release configure function.
void SetLteEnbCmacSapUser(LteEnbCmacSapUser *s)
Set the control MAC SAP user.
Definition: lte-enb-mac.cc:447
LteEnbPhySapUser * GetLteEnbPhySapUser()
Get the eNB-PHY SAP User.
Definition: lte-enb-mac.cc:465
std::vector< CqiListElement_s > m_dlCqiReceived
DL-CQI received.
Definition: lte-enb-mac.h:378
std::map< uint8_t, uint32_t > m_receivedRachPreambleCount
received RACH preamble count
Definition: lte-enb-mac.h:458
LteCcmMacSapProvider * m_ccmMacSapProvider
CCM MAC SAP provider.
Definition: lte-enb-mac.h:407
FfMacSchedSapProvider * m_schedSapProvider
the Sched SAP provider
Definition: lte-enb-mac.h:397
void DoReceiveRachPreamble(uint8_t prachId)
Receive RACH Preamble function.
Definition: lte-enb-mac.cc:659
void DoCschedLcConfigCnf(FfMacCschedSapUser::CschedLcConfigCnfParameters params)
CSched LC Config configure function.
uint8_t m_componentCarrierId
component carrier Id used to address sap
Definition: lte-enb-mac.h:463
void DoCschedUeConfigCnf(FfMacCschedSapUser::CschedUeConfigCnfParameters params)
CSched UE Config configure function.
void DoUlInfoListElementHarqFeeback(UlInfoListElement_s params)
UL Info List ELements HARQ Feedback function.
TracedCallback< uint32_t, uint32_t, uint16_t, uint8_t, uint16_t, uint8_t > m_ulScheduling
Trace information regarding UL scheduling Frame number, Subframe number, RNTI, MCS of TB,...
Definition: lte-enb-mac.h:428
void DoReleaseLc(uint16_t rnti, uint8_t lcid)
Release LC function.
Definition: lte-enb-mac.cc:924
void DoReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive a DL CQI ideal control message.
Definition: lte-enb-mac.cc:632
friend class EnbMacMemberLteEnbCmacSapProvider
allow EnbMacMemberLteEnbCmacSapProvider class friend access
Definition: lte-enb-mac.h:58
void SetLteCcmMacSapUser(LteCcmMacSapUser *s)
Set the ComponentCarrierManager SAP user.
Definition: lte-enb-mac.cc:471
std::map< uint16_t, std::map< uint8_t, LteMacSapUser * > > m_rlcAttached
RNTI, LC ID, SAP of the RLC instance.
Definition: lte-enb-mac.h:376
LteMacSapUser * m_macSapUser
the MAC SAP user
Definition: lte-enb-mac.h:394
std::vector< MacCeListElement_s > m_ulCeReceived
CE received (BSR up to now)
Definition: lte-enb-mac.h:381
LteEnbPhySapUser * m_enbPhySapUser
the ENB Phy SAP user
Definition: lte-enb-mac.h:404
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Transmit PDU function.
std::vector< FfMacSchedSapProvider::SchedUlCqiInfoReqParameters > m_ulCqiReceived
UL-CQI received.
Definition: lte-enb-mac.h:380
LteEnbCmacSapProvider * m_cmacSapProvider
the CMAC SAP provider
Definition: lte-enb-mac.h:393
friend class EnbMacMemberFfMacSchedSapUser
allow EnbMacMemberFfMacSchedSapUser class friend access
Definition: lte-enb-mac.h:62
TracedCallback< DlSchedulingCallbackInfo > m_dlScheduling
Trace information regarding DL scheduling Frame number, Subframe number, RNTI, MCS of TB1,...
Definition: lte-enb-mac.h:422
void SetFfMacSchedSapProvider(FfMacSchedSapProvider *s)
Set the scheduler SAP provider.
Definition: lte-enb-mac.cc:411
void ReceiveBsrMessage(MacCeListElement_s bsr)
Receive a CE element containing the buffer status report.
Definition: lte-enb-mac.cc:692
uint8_t m_connEstFailCount
the counter value for T300 timer expiration
Definition: lte-enb-mac.h:438
LteMacSapProvider * m_macSapProvider
the MAC SAP provider
Definition: lte-enb-mac.h:392
uint8_t m_raResponseWindowSize
RA response window size.
Definition: lte-enb-mac.h:437
void DoUeUpdateConfigurationReq(LteEnbCmacSapProvider::UeConfig params)
UE Update configuration request function.
Definition: lte-enb-mac.cc:940
void DoReconfigureLc(LteEnbCmacSapProvider::LcInfo lcinfo)
Reconfigure LC function.
Definition: lte-enb-mac.cc:918
uint8_t m_macChTtiDelay
delay of MAC, PHY and channel in terms of TTIs
Definition: lte-enb-mac.h:430
FfMacSchedSapUser * GetFfMacSchedSapUser()
Get the scheduler SAP user.
Definition: lte-enb-mac.cc:417
void DoDlInfoListElementHarqFeeback(DlInfoListElement_s params)
DL Info List ELements HARQ Feedback function.
LteCcmMacSapProvider * GetLteCcmMacSapProvider()
Get the eNB-ComponentCarrierManager SAP User.
Definition: lte-enb-mac.cc:477
uint8_t m_preambleTransMax
preamble transmit maximum
Definition: lte-enb-mac.h:436
void DoConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth)
Configure MAC function.
Definition: lte-enb-mac.cc:774
std::map< uint8_t, NcRaPreambleInfo > m_allocatedNcRaPreambleMap
map storing as key the random access preamble IDs allocated for non-contention based access,...
Definition: lte-enb-mac.h:456
uint8_t m_numberOfRaPreambles
number of RA preambles
Definition: lte-enb-mac.h:435
LteEnbCmacSapProvider * GetLteEnbCmacSapProvider()
Get the control MAC SAP provider.
Definition: lte-enb-mac.cc:453
std::map< uint16_t, DlHarqProcessesBuffer_t > m_miDlHarqProcessesPackets
Packet under transmission of the DL HARQ process.
Definition: lte-enb-mac.h:433
void DoCschedCellConfigUpdateInd(FfMacCschedSapUser::CschedCellConfigUpdateIndParameters params)
CSched Cell Config Update Indication function.
void DoAddLc(LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser *msu)
Add LC function.
Definition: lte-enb-mac.cc:869
void DoCschedUeConfigUpdateInd(FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params)
CSched UE Config Update Indication function.
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Subrame Indication function.
Definition: lte-enb-mac.cc:483
void SetLteMacSapUser(LteMacSapUser *s)
Set the MAC SAP user.
Definition: lte-enb-mac.cc:435
void ReceiveDlCqiLteControlMessage(Ptr< DlCqiLteControlMessage > msg)
Receive a DL CQI ideal control message.
Definition: lte-enb-mac.cc:681
LteEnbCmacSapProvider::AllocateNcRaPreambleReturnValue DoAllocateNcRaPreamble(uint16_t rnti)
Allocate NC RA preamble function.
Definition: lte-enb-mac.cc:964
void DoRemoveUe(uint16_t rnti)
Remove UE function.
Definition: lte-enb-mac.cc:824
friend class EnbMacMemberLteMacSapProvider< LteEnbMac >
allow EnbMacMemberLteMacSapProvider<LteEnbMac> class friend access
Definition: lte-enb-mac.h:60
LteEnbCmacSapProvider::RachConfig DoGetRachConfig() const
Get RACH configuration function.
Definition: lte-enb-mac.cc:953
std::vector< DlInfoListElement_s > m_dlInfoListReceived
DL HARQ feedback received.
Definition: lte-enb-mac.h:383
void DoSchedUlConfigInd(FfMacSchedSapUser::SchedUlConfigIndParameters params)
Sched UL Config Indication function.
LteMacSapProvider * GetLteMacSapProvider()
Get the MAC SAP provider.
Definition: lte-enb-mac.cc:441
LteEnbCmacSapUser * m_cmacSapUser
the CMAC SAP user
Definition: lte-enb-mac.h:395
uint32_t m_subframeNo
subframe number of current subframe indication
Definition: lte-enb-mac.h:416
friend class MemberLteCcmMacSapProvider< LteEnbMac >
allow MemberLteCcmMacSapProvider<LteEnbMac> class friend access
Definition: lte-enb-mac.h:68
void DoCschedLcReleaseCnf(FfMacCschedSapUser::CschedLcReleaseCnfParameters params)
CSched LC Release configure function.
void DoAddUe(uint16_t rnti)
Add UE function.
Definition: lte-enb-mac.cc:787
friend class EnbMacMemberLteEnbPhySapUser
allow EnbMacMemberLteEnbPhySapUser class friend access
Definition: lte-enb-mac.h:66
void DoReportMacCeToScheduler(MacCeListElement_s bsr)
Report MAC CE to scheduler.
Definition: lte-enb-mac.cc:699
void SetComponentCarrierId(uint8_t index)
Set the component carrier ID.
Definition: lte-enb-mac.cc:405
void DoUlCqiReport(FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi)
UL CQI report.
Definition: lte-enb-mac.cc:667
std::vector< UlInfoListElement_s > m_ulInfoListReceived
UL HARQ feedback received.
Definition: lte-enb-mac.h:385
std::map< uint16_t, uint32_t > m_rapIdRntiMap
RAPID RNTI map.
Definition: lte-enb-mac.h:460
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)=0
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
virtual uint8_t GetMacChTtiDelay()=0
Get the delay from MAC to Channel expressed in TTIs.
virtual void SendMacPdu(Ptr< Packet > p)=0
Send the MAC PDU to the channel.
Service Access Point (SAP) offered by the eNB-PHY to the eNB-MAC.
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:36
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:96
Tag used to define the RNTI and LC id for each MAC packet trasmitted.
uint16_t GetRnti() const
Get RNTI function.
uint8_t GetLcid() const
Get LCID function.
uint8_t GetLayer() const
Get layer function.
A base class which provides memory management and object aggregation.
Definition: object.h:89
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:986
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
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 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 > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
#define UL_PUSCH_TTIS_DELAY
Definition: lte-common.h:28
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< std::vector< Ptr< PacketBurst > > > DlHarqProcessesBuffer_t
DlHarqProcessesBuffer_t typedef.
Definition: lte-enb-mac.h:47
mac
Definition: third.py:85
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
#define list
See section 4.3.24 cqiListElement.
uint16_t m_rnti
RNTI.
See section 4.3.23 dlInfoListElement.
DlSchedulingCallbackInfo structure.
Definition: lte-common.h:231
uint32_t subframeNo
subframe number
Definition: lte-common.h:233
uint16_t sizeTb2
size TB2
Definition: lte-common.h:238
uint16_t sizeTb1
size TB1
Definition: lte-common.h:236
uint8_t componentCarrierId
component carrier ID
Definition: lte-common.h:239
uint32_t frameNo
frame number
Definition: lte-common.h:232
Parameters of the CSCHED_LC_CONFIG_REQ primitive.
Parameters of the CSCHED_LC_RELEASE_REQ primitive.
Parameters of the CSCHED_UE_CONFIG_REQ primitive.
Parameters of the CSCHED_UE_RELEASE_REQ primitive.
Parameters of the CSCHED_CELL_CONFIG_UPDATE_IND primitive.
Parameters of the CSCHED_LC_CONFIG_CNF primitive.
Parameters of the CSCHED_LC_RELEASE_CNF primitive.
Parameters of the CSCHED_UE_CONFIG_CNF primitive.
Parameters of the CSCHED_UE_CONFIG_UPDATE_IND primitive.
Parameters of the CSCHED_UE_RELEASE_CNF primitive.
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
std::vector< struct CqiListElement_s > m_cqiList
CQI list.
Parameters of the SCHED_DL_RACH_INFO_REQ primitive.
std::vector< struct RachListElement_s > m_rachList
RACH list.
uint16_t m_rlcRetransmissionHolDelay
RLC retransmission HOL delay.
uint32_t m_rlcRetransmissionQueueSize
RLC retransmission queue size.
uint16_t m_rlcTransmissionQueueHolDelay
RLC transmission queue HOL delay.
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.
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_TRIGGER_REQ primitive.
std::vector< struct UlInfoListElement_s > m_ulInfoList
UL info list.
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.4 logicalChannelConfigListElement.
uint64_t m_eRabMaximulBitrateUl
ERAB maximum bit rate UL.
uint64_t m_eRabGuaranteedBitrateDl
ERAB guaranteed bit rate DL.
uint8_t m_logicalChannelGroup
logical channel group
uint64_t m_eRabGuaranteedBitrateUl
ERAB guaranteed bit rate UL.
uint8_t m_logicalChannelIdentity
logical channel identity
uint64_t m_eRabMaximulBitrateDl
ERAB maximum bit rate DL.
AllocateNcRaPreambleReturnValue structure.
bool valid
true if a valid RA config was allocated, false otherwise
Logical Channel information to be passed to CmacSapProvider::ConfigureLc.
uint64_t gbrUl
guaranteed bitrate in uplink
uint8_t qci
QoS Class Identifier.
uint64_t mbrDl
maximum bitrate in downlink
uint64_t mbrUl
maximum bitrate in uplink
uint8_t lcGroup
logical channel group
uint64_t gbrDl
guaranteed bitrate in downlink
uint8_t lcId
logical channel identifier
bool isGbr
true if the bearer is GBR, false if the bearer is NON-GBR
uint16_t rnti
C-RNTI identifying the UE.
struct defining the RACH configuration of the MAC
Parameters for [re]configuring the UE.
Parameters for [re]configuring the UE.
uint16_t m_rnti
UE id within this cell.
uint8_t m_transmissionMode
Transmission mode 1..7
info associated with a preamble allocated for non-contention based RA
Definition: lte-enb-mac.h:445
Time expiryTime
value the expiration time of this allocation (so that stale preambles can be reused)
Definition: lte-enb-mac.h:447
uint16_t rnti
rnti previously allocated for this non-contention based RA procedure
Definition: lte-enb-mac.h:446
LteFlowId structure.
Definition: lte-common.h:37
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:69
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45
Parameters for LteMacSapUser::ReceivePdu.
Definition: lte-mac-sap.h:166
Ptr< Packet > p
the RLC PDU to be received
Definition: lte-mac-sap.h:187
uint8_t lcid
the logical channel id
Definition: lte-mac-sap.h:189
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:188
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition: lte-mac-sap.h:105
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:141
uint32_t bytes
the number of bytes to transmit
Definition: lte-mac-sap.h:137
uint8_t componentCarrierId
the component carrier id
Definition: lte-mac-sap.h:140
uint8_t layer
the layer of transmission (MIMO)
Definition: lte-mac-sap.h:138
uint8_t lcid
the logical channel id
Definition: lte-mac-sap.h:142
See section 4.3.14 macCEListElement.
See section 4.3.6 rachListElement.
uint16_t m_estimatedSize
estimated size
a MAC RAR and the corresponding RAPID subheader
BuildRarListElement_s rarPayload
RAR payload.
See section 4.3.12 ulInfoListElement.