A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-ue-mac.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: Nicola Baldo <nbaldo@cttc.es>
19  * Author: Marco Miozzo <mmiozzo@cttc.es>
20  */
21 
22 
23 
24 #include <ns3/log.h>
25 #include <ns3/pointer.h>
26 #include <ns3/packet.h>
27 #include <ns3/packet-burst.h>
28 #include <ns3/random-variable.h>
29 
30 #include "lte-ue-mac.h"
31 #include "lte-ue-net-device.h"
32 #include "lte-radio-bearer-tag.h"
33 #include <ns3/ff-mac-common.h>
34 #include <ns3/lte-control-messages.h>
35 #include <ns3/simulator.h>
36 #include <ns3/lte-common.h>
37 
38 
39 
40 NS_LOG_COMPONENT_DEFINE ("LteUeMac");
41 
42 namespace ns3 {
43 
45 
46 
48 // SAP forwarders
50 
51 
53 {
54 public:
56 
57  // inherited from LteUeCmacSapProvider
58  virtual void ConfigureRach (RachConfig rc);
60  virtual void StartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t preambleId, uint8_t prachMask);
61  virtual void AddLc (uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser* msu);
62  virtual void RemoveLc (uint8_t lcId);
63  virtual void Reset ();
64 
65 private:
67 };
68 
69 
71  : m_mac (mac)
72 {
73 }
74 
75 void
77 {
78  m_mac->DoConfigureRach (rc);
79 }
80 
81  void
83 {
85 }
86 
87  void
88 UeMemberLteUeCmacSapProvider::StartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t preambleId, uint8_t prachMask)
89 {
90  m_mac->DoStartNonContentionBasedRandomAccessProcedure (rnti, preambleId, prachMask);
91 }
92 
93 
94 void
96 {
97  m_mac->DoAddLc (lcId, lcConfig, msu);
98 }
99 
100 void
102 {
103  m_mac->DoRemoveLc (lcid);
104 }
105 
106 void
108 {
109  m_mac->DoReset ();
110 }
111 
113 {
114 public:
116 
117  // inherited from LteMacSapProvider
118  virtual void TransmitPdu (TransmitPduParameters params);
119  virtual void ReportBufferStatus (ReportBufferStatusParameters params);
120 
121 private:
123 };
124 
125 
127  : m_mac (mac)
128 {
129 }
130 
131 void
133 {
134  m_mac->DoTransmitPdu (params);
135 }
136 
137 
138 void
140 {
141  m_mac->DoReportBufferStatus (params);
142 }
143 
144 
145 
146 
148 {
149 public:
151 
152  // inherited from LtePhySapUser
153  virtual void ReceivePhyPdu (Ptr<Packet> p);
154  virtual void SubframeIndication (uint32_t frameNo, uint32_t subframeNo);
156 
157 private:
159 };
160 
162 {
163 
164 }
165 
166 void
168 {
169  m_mac->DoReceivePhyPdu (p);
170 }
171 
172 
173 void
174 UeMemberLteUePhySapUser::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
175 {
176  m_mac->DoSubframeIndication (frameNo, subframeNo);
177 }
178 
179 void
181 {
183 }
184 
185 
186 
187 
189 // LteUeMac methods
191 
192 
193 TypeId
195 {
196  static TypeId tid = TypeId ("ns3::LteUeMac")
197  .SetParent<Object> ()
198  .AddConstructor<LteUeMac> ();
199  return tid;
200 }
201 
202 
204  : m_bsrPeriodicity (MilliSeconds (1)), // ideal behavior
205  m_bsrLast (MilliSeconds (0)),
206  m_freshUlBsr (false),
207  m_harqProcessId (0),
208  m_rnti (0),
209  m_rachConfigured (false),
210  m_waitingForRaResponse (false)
211 
212 {
213  NS_LOG_FUNCTION (this);
215  for (uint8_t i = 0; i < m_miUlHarqProcessesPacket.size (); i++)
216  {
217  Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
218  m_miUlHarqProcessesPacket.at (i) = pb;
219  }
221 
225  m_raPreambleUniformVariable = CreateObject<UniformRandomVariable> ();
226 }
227 
228 
230 {
231  NS_LOG_FUNCTION (this);
232 }
233 
234 void
236 {
237  NS_LOG_FUNCTION (this);
238  m_miUlHarqProcessesPacket.clear ();
239  delete m_macSapProvider;
240  delete m_cmacSapProvider;
241  delete m_uePhySapUser;
243 }
244 
245 
248 {
249  return m_uePhySapUser;
250 }
251 
252 void
254 {
256 }
257 
258 
261 {
262  return m_macSapProvider;
263 }
264 
265 void
267 {
268  m_cmacSapUser = s;
269 }
270 
273 {
274  return m_cmacSapProvider;
275 }
276 
277 
278 void
280 {
281  NS_LOG_FUNCTION (this);
282  NS_ASSERT_MSG (m_rnti == params.rnti, "RNTI mismatch between RLC and MAC");
283  LteRadioBearerTag tag (params.rnti, params.lcid, 0 /* UE works in SISO mode*/);
284  params.pdu->AddPacketTag (tag);
285  // store pdu in HARQ buffer
286  m_miUlHarqProcessesPacket.at (m_harqProcessId)->AddPacket (params.pdu);
289 }
290 
291 void
293 {
294  NS_LOG_FUNCTION (this << (uint32_t) params.lcid);
295 
296  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
297 
298 
299  it = m_ulBsrReceived.find (params.lcid);
300  if (it!=m_ulBsrReceived.end ())
301  {
302  // update entry
303  (*it).second = params;
304  }
305  else
306  {
307  m_ulBsrReceived.insert (std::pair<uint8_t, LteMacSapProvider::ReportBufferStatusParameters> (params.lcid, params));
308  }
309  m_freshUlBsr = true;
310 }
311 
312 
313 void
315 {
316  NS_LOG_FUNCTION (this);
317 
318  if (m_rnti == 0)
319  {
320  NS_LOG_INFO ("MAC not initialized, BSR deferred");
321  return;
322  }
323 
324  if (m_ulBsrReceived.size () == 0)
325  {
326  NS_LOG_INFO ("No BSR report to transmit");
327  return;
328  }
329  MacCeListElement_s bsr;
330  bsr.m_rnti = m_rnti;
332 
333  // BSR is reported for each LCG
334  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
335  std::vector<uint32_t> queue (4, 0); // one value per each of the 4 LCGs, initialized to 0
336  for (it = m_ulBsrReceived.begin (); it != m_ulBsrReceived.end (); it++)
337  {
338  uint8_t lcid = it->first;
339  std::map <uint8_t, LcInfo>::iterator lcInfoMapIt;
340  lcInfoMapIt = m_lcInfoMap.find (lcid);
341  NS_ASSERT (lcInfoMapIt != m_lcInfoMap.end ());
342  NS_ASSERT_MSG ((lcid != 0) || (((*it).second.txQueueSize == 0)
343  && ((*it).second.retxQueueSize == 0)
344  && ((*it).second.statusPduSize == 0)),
345  "BSR should not be used for LCID 0");
346  uint8_t lcg = lcInfoMapIt->second.lcConfig.logicalChannelGroup;
347  queue.at (lcg) += ((*it).second.txQueueSize + (*it).second.retxQueueSize + (*it).second.statusPduSize);
348  }
349 
350  // FF API says that all 4 LCGs are always present
355 
356  // create the feedback to eNB
357  Ptr<BsrLteControlMessage> msg = Create<BsrLteControlMessage> ();
358  msg->SetBsr (bsr);
360 
361 }
362 
363 void
365 {
366  NS_LOG_FUNCTION (this);
367  // 3GPP 36.321 5.1.1
368  NS_ASSERT_MSG (m_rachConfigured, "RACH not configured");
369  // assume that there is no Random Access Preambles group B
371  bool contention = true;
372  SendRaPreamble (contention);
373 }
374 
375 void
376 LteUeMac::SendRaPreamble (bool contention)
377 {
378  NS_LOG_FUNCTION (this << (uint32_t) m_raPreambleId << contention);
379  // Since regular UL LteControlMessages need m_ulConfigured = true in
380  // order to be sent by the UE, the rach preamble needs to be sent
381  // with a dedicated primitive (not
382  // m_uePhySapProvider->SendLteControlMessage (msg)) so that it can
383  // bypass the m_ulConfigured flag. This is reasonable, since In fact
384  // the RACH preamble is sent on 6RB bandwidth so the uplink
385  // bandwidth does not need to be configured.
386  NS_ASSERT (m_subframeNo > 0); // sanity check for subframe starting at 1
387  m_raRnti = m_subframeNo - 1;
389  NS_LOG_INFO (this << " sent preamble id " << (uint32_t) m_raPreambleId << ", RA-RNTI " << (uint32_t) m_raRnti);
390  // 3GPP 36.321 5.1.4
391  Time raWindowBegin = MilliSeconds (3);
392  Time raWindowEnd = MilliSeconds (3 + m_rachConfig.raResponseWindowSize);
395 }
396 
397 void
399 {
400  NS_LOG_FUNCTION (this);
401  m_waitingForRaResponse = true;
402 }
403 
404 void
406 {
407  NS_LOG_FUNCTION (this);
408  m_waitingForRaResponse = false;
410  NS_LOG_INFO ("got RAR for RAPID " << (uint32_t) m_raPreambleId << ", setting T-C-RNTI = " << raResponse.m_rnti);
411  m_rnti = raResponse.m_rnti;
413  // in principle we should wait for contention resolution,
414  // but in the current LTE model when two or more identical
415  // preambles are sent no one is received, so there is no need
416  // for contention resolution
418  // trigger tx opportunity for Message 3 over LC 0
419  // this is needed since Message 3's UL GRANT is in the RAR, not in UL-DCIs
420  const uint8_t lc0Lcid = 0;
421  std::map <uint8_t, LcInfo>::iterator lc0InfoIt = m_lcInfoMap.find (lc0Lcid);
422  NS_ASSERT (lc0InfoIt != m_lcInfoMap.end ());
423  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator lc0BsrIt
424  = m_ulBsrReceived.find (lc0Lcid);
425  if ((lc0BsrIt != m_ulBsrReceived.end ())
426  && (lc0BsrIt->second.txQueueSize > 0))
427  {
428  NS_ASSERT_MSG (raResponse.m_grant.m_tbSize > lc0BsrIt->second.txQueueSize,
429  "segmentation of Message 3 is not allowed");
430  lc0InfoIt->second.macSapUser->NotifyTxOpportunity (raResponse.m_grant.m_tbSize, 0, 0);
431  lc0BsrIt->second.txQueueSize = 0;
432  }
433 }
434 
435 void
437 {
438  NS_LOG_FUNCTION (this << contention);
439  m_waitingForRaResponse = false;
440  // 3GPP 36.321 5.1.4
443  {
444  NS_LOG_INFO ("RAR timeout, preambleTransMax reached => giving up");
446  }
447  else
448  {
449  NS_LOG_INFO ("RAR timeout, re-send preamble");
450  if (contention)
451  {
453  }
454  else
455  {
456  SendRaPreamble (contention);
457  }
458  }
459 }
460 
461 void
463 {
464  NS_LOG_FUNCTION (this);
465  m_rachConfig = rc;
466  m_rachConfigured = true;
467 }
468 
469 void
471 {
472  NS_LOG_FUNCTION (this);
473 
474  // 3GPP 36.321 5.1.1
475  NS_ASSERT_MSG (m_rachConfigured, "RACH not configured");
477  m_backoffParameter = 0;
479 }
480 
481 void
482 LteUeMac::DoStartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t preambleId, uint8_t prachMask)
483 {
484  NS_LOG_FUNCTION (this << " rnti" << rnti);
485  NS_ASSERT_MSG (prachMask == 0, "requested PRACH MASK = " << (uint32_t) prachMask << ", but only PRACH MASK = 0 is supported");
486  m_rnti = rnti;
487  m_raPreambleId = preambleId;
488  bool contention = false;
489  SendRaPreamble (contention);
490 }
491 
492 void
494 {
495  NS_LOG_FUNCTION (this << " lcId" << (uint32_t) lcId);
496  NS_ASSERT_MSG (m_lcInfoMap.find (lcId) == m_lcInfoMap.end (), "cannot add channel because LCID " << lcId << " is already present");
497 
498  LcInfo lcInfo;
499  lcInfo.lcConfig = lcConfig;
500  lcInfo.macSapUser = msu;
501  m_lcInfoMap[lcId] = lcInfo;
502 }
503 
504 void
505 LteUeMac::DoRemoveLc (uint8_t lcId)
506 {
507  NS_LOG_FUNCTION (this << " lcId" << lcId);
508  NS_ASSERT_MSG (m_lcInfoMap.find (lcId) != m_lcInfoMap.end (), "could not find LCID " << lcId);
509  m_lcInfoMap.erase (lcId);
510 }
511 
512 void
514 {
515  NS_LOG_FUNCTION (this);
516  std::map <uint8_t, LcInfo>::iterator it = m_lcInfoMap.begin ();
517  while (it != m_lcInfoMap.end ())
518  {
519  // don't delete CCCH)
520  if (it->first == 0)
521  {
522  ++it;
523  }
524  else
525  {
526  // note: use of postfix operator preserves validity of iterator
527  m_lcInfoMap.erase (it++);
528  }
529  }
530  m_rachConfigured = false;
531  m_freshUlBsr = false;
532  m_ulBsrReceived.clear ();
533 }
534 
535 void
537 {
538  LteRadioBearerTag tag;
539  p->RemovePacketTag (tag);
540  if (tag.GetRnti () == m_rnti)
541  {
542  // packet is for the current user
543  std::map <uint8_t, LcInfo>::const_iterator it = m_lcInfoMap.find (tag.GetLcid ());
544  NS_ASSERT_MSG (it != m_lcInfoMap.end (), "received packet with unknown lcid");
545  it->second.macSapUser->ReceivePdu (p);
546  }
547 }
548 
549 
550 void
552 {
553  NS_LOG_FUNCTION (this);
554  if (msg->GetMessageType () == LteControlMessage::UL_DCI)
555  {
556  Ptr<UlDciLteControlMessage> msg2 = DynamicCast<UlDciLteControlMessage> (msg);
557  UlDciListElement_s dci = msg2->GetDci ();
558  if (dci.m_ndi==1)
559  {
560  // New transmission -> emtpy pkt buffer queue (for deleting eventual pkts not acked )
561  Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
563  // Retrieve data from RLC
564  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator itBsr;
565  uint16_t activeLcs = 0;
566  uint32_t statusPduMinSize = 0;
567  for (itBsr = m_ulBsrReceived.begin (); itBsr != m_ulBsrReceived.end (); itBsr++)
568  {
569  if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
570  {
571  activeLcs++;
572  if (((*itBsr).second.statusPduSize!=0)&&((*itBsr).second.statusPduSize < statusPduMinSize))
573  {
574  statusPduMinSize = (*itBsr).second.statusPduSize;
575  }
576  if (((*itBsr).second.statusPduSize!=0)&&(statusPduMinSize == 0))
577  {
578  statusPduMinSize = (*itBsr).second.statusPduSize;
579  }
580  }
581  }
582  if (activeLcs == 0)
583  {
584  NS_LOG_ERROR (this << " No active flows for this UL-DCI");
585  return;
586  }
587  std::map <uint8_t, LcInfo>::iterator it;
588  uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs;
589  bool statusPduPriority = false;
590  if ((statusPduMinSize != 0)&&(bytesPerActiveLc < statusPduMinSize))
591  {
592  // send only the status PDU which has highest priority
593  statusPduPriority = true;
594  NS_LOG_DEBUG (this << " Reduced resource -> send only Status, b ytes " << statusPduMinSize);
595  if (dci.m_tbSize < statusPduMinSize)
596  {
597  NS_FATAL_ERROR ("Insufficient Tx Opportunity for sending a status message");
598  }
599  }
600  NS_LOG_LOGIC (this << " UE " << m_rnti << ": UL-CQI notified TxOpportunity of " << dci.m_tbSize << " => " << bytesPerActiveLc << " bytes per active LC" << " statusPduMinSize " << statusPduMinSize);
601  for (it = m_lcInfoMap.begin (); it!=m_lcInfoMap.end (); it++)
602  {
603  itBsr = m_ulBsrReceived.find ((*it).first);
604  NS_LOG_DEBUG (this << " Processing LC " << (uint32_t)(*it).first << " bytesPerActiveLc " << bytesPerActiveLc);
605  if ( (itBsr!=m_ulBsrReceived.end ()) &&
606  ( ((*itBsr).second.statusPduSize > 0) ||
607  ((*itBsr).second.retxQueueSize > 0) ||
608  ((*itBsr).second.txQueueSize > 0)) )
609  {
610  if ((statusPduPriority) && ((*itBsr).second.statusPduSize == statusPduMinSize))
611  {
612  (*it).second.macSapUser->NotifyTxOpportunity ((*itBsr).second.statusPduSize, 0, 0);
613  NS_LOG_LOGIC (this << "\t" << bytesPerActiveLc << " send " << (*itBsr).second.statusPduSize << " status bytes to LC " << (uint32_t)(*it).first << " statusQueue " << (*itBsr).second.statusPduSize << " retxQueue" << (*itBsr).second.retxQueueSize << " txQueue" << (*itBsr).second.txQueueSize);
614  (*itBsr).second.statusPduSize = 0;
615  break;
616  }
617  else
618  {
619  uint32_t bytesForThisLc = bytesPerActiveLc;
620  NS_LOG_LOGIC (this << "\t" << bytesPerActiveLc << " bytes to LC " << (uint32_t)(*it).first << " statusQueue " << (*itBsr).second.statusPduSize << " retxQueue" << (*itBsr).second.retxQueueSize << " txQueue" << (*itBsr).second.txQueueSize);
621  if (((*itBsr).second.statusPduSize > 0) && (bytesForThisLc > (*itBsr).second.statusPduSize))
622  {
623  (*it).second.macSapUser->NotifyTxOpportunity ((*itBsr).second.statusPduSize, 0, 0);
624  bytesForThisLc -= (*itBsr).second.statusPduSize;
625  NS_LOG_DEBUG (this << " serve STATUS " << (*itBsr).second.statusPduSize);
626  (*itBsr).second.statusPduSize = 0;
627  }
628  else
629  {
630  if ((*itBsr).second.statusPduSize>bytesForThisLc)
631  {
632  NS_FATAL_ERROR ("Insufficient Tx Opportunity for sending a status message");
633  }
634  }
635 
636  if ((bytesForThisLc > 7) && // 7 is the min TxOpportunity useful for Rlc
637  (((*itBsr).second.retxQueueSize > 0) ||
638  ((*itBsr).second.txQueueSize > 0)))
639  {
640  if ((*itBsr).second.retxQueueSize > 0)
641  {
642  NS_LOG_DEBUG (this << " serve retx DATA, bytes " << bytesForThisLc);
643  (*it).second.macSapUser->NotifyTxOpportunity (bytesForThisLc, 0, 0);
644  if ((*itBsr).second.retxQueueSize >= bytesForThisLc)
645  {
646  (*itBsr).second.retxQueueSize -= bytesForThisLc;
647  }
648  else
649  {
650  (*itBsr).second.retxQueueSize = 0;
651  }
652  }
653  else if ((*itBsr).second.txQueueSize > 0)
654  {
655  uint16_t lcid = (*it).first;
656  uint32_t rlcOverhead;
657  if (lcid == 1)
658  {
659  // for SRB1 (using RLC AM) it's better to
660  // overestimate RLC overhead rather than
661  // underestimate it and risk unneeded
662  // segmentation which increases delay
663  rlcOverhead = 4;
664  }
665  else
666  {
667  // minimum RLC overhead due to header
668  rlcOverhead = 2;
669  }
670  NS_LOG_DEBUG (this << " serve tx DATA, bytes " << bytesForThisLc << ", RLC overhead " << rlcOverhead);
671  (*it).second.macSapUser->NotifyTxOpportunity (bytesForThisLc, 0, 0);
672  if ((*itBsr).second.txQueueSize >= bytesForThisLc - rlcOverhead)
673  {
674  (*itBsr).second.txQueueSize -= bytesForThisLc - rlcOverhead;
675  }
676  else
677  {
678  (*itBsr).second.txQueueSize = 0;
679  }
680  }
681  }
682  else
683  {
684  if ( ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
685  {
686  // resend BSR info for updating eNB peer MAC
687  m_freshUlBsr = true;
688  }
689  }
690  NS_LOG_LOGIC (this << "\t" << bytesPerActiveLc << "\t new queues " << (uint32_t)(*it).first << " statusQueue " << (*itBsr).second.statusPduSize << " retxQueue" << (*itBsr).second.retxQueueSize << " txQueue" << (*itBsr).second.txQueueSize);
691  }
692 
693  }
694  }
695  }
696  else
697  {
698  // HARQ retransmission -> retrieve data from HARQ buffer
699  NS_LOG_DEBUG (this << " UE MAC RETX HARQ " << (uint16_t)m_harqProcessId);
700  Ptr<PacketBurst> pb = m_miUlHarqProcessesPacket.at (m_harqProcessId);
701  for (std::list<Ptr<Packet> >::const_iterator j = pb->Begin (); j != pb->End (); ++j)
702  {
703  Ptr<Packet> pkt = (*j)->Copy ();
705  }
706  m_miUlHarqProcessesPacketTimer.at (m_harqProcessId) = HARQ_PERIOD;
707  }
708 
709  }
710  else if (msg->GetMessageType () == LteControlMessage::RAR)
711  {
713  {
714  Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage> (msg);
715  uint16_t raRnti = rarMsg->GetRaRnti ();
716  NS_LOG_LOGIC (this << "got RAR with RA-RNTI " << (uint32_t) raRnti << ", expecting " << (uint32_t) m_raRnti);
717  if (raRnti == m_raRnti) // RAR corresponds to TX subframe of preamble
718  {
719  for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin ();
720  it != rarMsg->RarListEnd ();
721  ++it)
722  {
723  if (it->rapId == m_raPreambleId) // RAR is for me
724  {
725  RecvRaResponse (it->rarPayload);
729  }
730  }
731  }
732  }
733  }
734  else
735  {
736  NS_LOG_WARN (this << " LteControlMessage not recognized");
737  }
738 }
739 
740 void
742 {
743  NS_LOG_FUNCTION (this);
744 
745  for (uint16_t i = 0; i < m_miUlHarqProcessesPacketTimer.size (); i++)
746  {
747  if (m_miUlHarqProcessesPacketTimer.at (i) == 0)
748  {
749  if (m_miUlHarqProcessesPacket.at (i)->GetSize () > 0)
750  {
751  // timer expired: drop packets in buffer for this process
752  NS_LOG_INFO (this << " HARQ Proc Id " << i << " packets buffer expired");
753  Ptr<PacketBurst> emptyPb = CreateObject <PacketBurst> ();
754  m_miUlHarqProcessesPacket.at (i) = emptyPb;
755  }
756  }
757  else
758  {
760  }
761  }
762 }
763 
764 
765 void
766 LteUeMac::DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo)
767 {
768  NS_LOG_FUNCTION (this);
769  m_frameNo = frameNo;
770  m_subframeNo = subframeNo;
772  if ((Simulator::Now () >= m_bsrLast + m_bsrPeriodicity) && (m_freshUlBsr==true))
773  {
776  m_freshUlBsr = false;
778  }
779 }
780 
781 int64_t
782 LteUeMac::AssignStreams (int64_t stream)
783 {
784  NS_LOG_FUNCTION (this << stream);
786  return 1;
787 }
788 
789 } // namespace ns3
virtual void AddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
add a new Logical Channel (LC)
Definition: lte-ue-mac.cc:95
void DoStartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t rapId, uint8_t prachMask)
Definition: lte-ue-mac.cc:482
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
Definition: lte-ue-mac.h:120
uint8_t GetLcid(void) const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
void DoReset()
Definition: lte-ue-mac.cc:513
uint8_t m_raPreambleId
Definition: lte-ue-mac.h:150
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
virtual void TransmitPdu(TransmitPduParameters params)
send an RLC PDU to the MAC for transmission.
Definition: lte-ue-mac.cc:132
#define HARQ_PERIOD
Definition: lte-common.h:30
void SendRaPreamble(bool contention)
Definition: lte-ue-mac.cc:376
void StartWaitingForRaResponse()
Definition: lte-ue-mac.cc:398
uint32_t GetInteger(uint32_t min, uint32_t max)
Returns a random unsigned integer from a uniform distribution over the interval [min,max] including both ends.
void DoReceivePhyPdu(Ptr< Packet > p)
Definition: lte-ue-mac.cc:536
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
Ptr< UniformRandomVariable > m_raPreambleUniformVariable
Definition: lte-ue-mac.h:154
uint16_t GetRnti(void) const
LteUePhySapUser * m_uePhySapUser
Definition: lte-ue-mac.h:132
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:841
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
void RaResponseTimeout(bool contention)
Definition: lte-ue-mac.cc:436
See section 4.3.2 ulDciListElement.
virtual void ReportBufferStatus(ReportBufferStatusParameters params)
Report the RLC buffer status to the MAC.
Definition: lte-ue-mac.cc:139
struct MacCeValue_u m_macCeValue
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
See section 4.3.10 buildRARListElement.
void DoAddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Definition: lte-ue-mac.cc:493
void SetLteUePhySapProvider(LteUePhySapProvider *s)
Set the PHY SAP Provider.
Definition: lte-ue-mac.cc:253
virtual void SendRachPreamble(uint32_t prachId, uint32_t raRnti)=0
send a preamble on the PRACH
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:825
Service Access Point (SAP) offered by the PHY to the MAC.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-mac-sap.h:49
void DoStartContentionBasedRandomAccessProcedure()
Definition: lte-ue-mac.cc:470
void SendReportBufferStatus(void)
Definition: lte-ue-mac.cc:314
virtual void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Trigger the start from a new frame (input from Phy layer)
Definition: lte-ue-mac.cc:174
virtual ~LteUeMac()
Definition: lte-ue-mac.cc:229
uint16_t m_tbSize
virtual void StartContentionBasedRandomAccessProcedure()
tell the MAC to start a contention-based random access procedure, e.g., to perform RRC connection est...
Definition: lte-ue-mac.cc:82
void DoRemoveLc(uint8_t lcId)
Definition: lte-ue-mac.cc:505
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:66
std::vector< uint8_t > m_miUlHarqProcessesPacketTimer
Definition: lte-ue-mac.h:144
friend class UeMemberLteUePhySapUser
Definition: lte-ue-mac.h:47
void SetLteUeCmacSapUser(LteUeCmacSapUser *s)
Definition: lte-ue-mac.cc:266
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Definition: lte-ue-mac.cc:279
virtual void ConfigureRach(RachConfig rc)
Definition: lte-ue-mac.cc:76
virtual void SetTemporaryCellRnti(uint16_t rnti)=0
friend class UeMemberLteMacSapProvider
Definition: lte-ue-mac.h:46
uint8_t m_harqProcessId
Definition: lte-ue-mac.h:142
static uint8_t BufferSize2BsrId(uint32_t val)
Definition: lte-common.cc:149
virtual void Reset()
reset the MAC
Definition: lte-ue-mac.cc:107
uint32_t m_frameNo
Definition: lte-ue-mac.h:156
bool m_waitingForRaResponse
Definition: lte-ue-mac.h:159
void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Definition: lte-ue-mac.cc:292
virtual void StartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t preambleId, uint8_t prachMask)
tell the MAC to start a non-contention-based random access procedure, e.g., as a consequence of hando...
Definition: lte-ue-mac.cc:88
virtual void SendMacPdu(Ptr< Packet > p)=0
Send the MAC PDU to the channel.
Ptr< SampleEmitter > s
uint16_t m_rnti
Definition: lte-ue-mac.h:146
LteUeCmacSapProvider * m_cmacSapProvider
Definition: lte-ue-mac.h:129
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:48
uint8_t m_raRnti
Definition: lte-ue-mac.h:158
std::vector< Ptr< PacketBurst > > m_miUlHarqProcessesPacket
Definition: lte-ue-mac.h:143
LteUeCmacSapProvider * GetLteUeCmacSapProvider(void)
Definition: lte-ue-mac.cc:272
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
void DoConfigureRach(LteUeCmacSapProvider::RachConfig rc)
Definition: lte-ue-mac.cc:462
#define list
virtual void NotifyRandomAccessSuccessful()=0
Notify the RRC that the MAC Random Access procedure completed successfully.
See section 4.3.14 macCEListElement.
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Forwarded from LteUePhySapUser: trigger the start from a new frame.
Definition: lte-ue-mac.cc:766
UeMemberLteUeCmacSapProvider(LteUeMac *mac)
Definition: lte-ue-mac.cc:70
void DoReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Definition: lte-ue-mac.cc:551
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
std::map< uint8_t, LcInfo > m_lcInfoMap
Definition: lte-ue-mac.h:124
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)=0
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
LteUePhySapUser * GetLteUePhySapUser()
Get the PHY SAP user.
Definition: lte-ue-mac.cc:247
LteMacSapProvider * GetLteMacSapProvider(void)
Definition: lte-ue-mac.cc:260
uint16_t m_backoffParameter
Definition: lte-ue-mac.h:152
static TypeId GetTypeId(void)
Definition: lte-ue-mac.cc:194
UeMemberLteUePhySapUser(LteUeMac *mac)
Definition: lte-ue-mac.cc:161
LteMacSapProvider * m_macSapProvider
Definition: lte-ue-mac.h:126
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-mac-sap.h:69
virtual void ReceivePhyPdu(Ptr< Packet > p)
Called by the Phy to notify the MAC of the reception of a new PHY-PDU.
Definition: lte-ue-mac.cc:167
LteUePhySapProvider * m_uePhySapProvider
Definition: lte-ue-mac.h:131
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
bool m_freshUlBsr
Definition: lte-ue-mac.h:140
virtual void RemoveLc(uint8_t lcId)
remove an existing LC
Definition: lte-ue-mac.cc:101
#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:84
std::vector< uint8_t > m_bufferStatus
virtual void NotifyRandomAccessFailed()=0
Notify the RRC that the MAC Random Access procedure failed.
void RandomlySelectAndSendRaPreamble()
Definition: lte-ue-mac.cc:364
void RecvRaResponse(BuildRarListElement_s raResponse)
Definition: lte-ue-mac.cc:405
uint8_t m_preambleTransmissionCounter
Definition: lte-ue-mac.h:151
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:94
EventId m_noRaResponseReceivedEvent
Definition: lte-ue-mac.h:153
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:203
bool m_rachConfigured
Definition: lte-ue-mac.h:148
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-ue-mac.cc:235
LteUeCmacSapProvider::RachConfig m_rachConfig
Definition: lte-ue-mac.h:149
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:848
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:36
Tag used to define the RNTI and LC id for each MAC packet trasmitted.
enum ns3::MacCeListElement_s::MacCeType_e m_macCeType
Time m_bsrPeriodicity
Definition: lte-ue-mac.h:137
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Definition: lte-ue-mac.cc:180
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:193
uint32_t m_subframeNo
Definition: lte-ue-mac.h:157
std::map< uint8_t, LteMacSapProvider::ReportBufferStatusParameters > m_ulBsrReceived
Definition: lte-ue-mac.h:134
a base class which provides memory management and object aggregation
Definition: object.h:64
friend class UeMemberLteUeCmacSapProvider
Definition: lte-ue-mac.h:45
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: lte-ue-mac.cc:782
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
void RefreshHarqProcessesPacketBuffer(void)
Definition: lte-ue-mac.cc:741
UeMemberLteMacSapProvider(LteUeMac *mac)
Definition: lte-ue-mac.cc:126
LteUeCmacSapUser * m_cmacSapUser
Definition: lte-ue-mac.h:128
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45