A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-ue-mac.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 * Author: Marco Miozzo <mmiozzo@cttc.es>
8 */
9
10#include "lte-ue-mac.h"
11
12#include "ff-mac-common.h"
13#include "lte-common.h"
16
17#include <ns3/log.h>
18#include <ns3/packet-burst.h>
19#include <ns3/packet.h>
20#include <ns3/pointer.h>
21#include <ns3/random-variable-stream.h>
22#include <ns3/simulator.h>
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("LteUeMac");
28
30
31///////////////////////////////////////////////////////////
32// SAP forwarders
33///////////////////////////////////////////////////////////
34
35/// UeMemberLteUeCmacSapProvider class
37{
38 public:
39 /**
40 * Constructor
41 *
42 * \param mac the UE MAC
43 */
45
46 // inherited from LteUeCmacSapProvider
47 void ConfigureRach(RachConfig rc) override;
50 uint8_t preambleId,
51 uint8_t prachMask) override;
52 void SetRnti(uint16_t rnti) override;
53 void AddLc(uint8_t lcId,
55 LteMacSapUser* msu) override;
56 void RemoveLc(uint8_t lcId) override;
57 void Reset() override;
58 void NotifyConnectionSuccessful() override;
59 void SetImsi(uint64_t imsi) override;
60
61 private:
62 LteUeMac* m_mac; ///< the UE MAC
63};
64
69
70void
75
76void
81
82void
84 uint8_t preambleId,
85 uint8_t prachMask)
86{
87 m_mac->DoStartNonContentionBasedRandomAccessProcedure(rnti, preambleId, prachMask);
88}
89
90void
92{
93 m_mac->DoSetRnti(rnti);
94}
95
96void
98{
99 m_mac->DoAddLc(lcId, lcConfig, msu);
100}
101
102void
104{
105 m_mac->DoRemoveLc(lcid);
106}
107
108void
113
114void
119
120void
122{
123 m_mac->DoSetImsi(imsi);
124}
125
126/// UeMemberLteMacSapProvider class
128{
129 public:
130 /**
131 * Constructor
132 *
133 * \param mac the UE MAC
134 */
136
137 // inherited from LteMacSapProvider
138 void TransmitPdu(TransmitPduParameters params) override;
140
141 private:
142 LteUeMac* m_mac; ///< the UE MAC
143};
144
149
150void
155
156void
161
162/**
163 * UeMemberLteUePhySapUser
164 */
166{
167 public:
168 /**
169 * Constructor
170 *
171 * \param mac the UE MAC
172 */
174
175 // inherited from LtePhySapUser
176 void ReceivePhyPdu(Ptr<Packet> p) override;
177 void SubframeIndication(uint32_t frameNo, uint32_t subframeNo) override;
179
180 private:
181 LteUeMac* m_mac; ///< the UE MAC
182};
183
188
189void
194
195void
197{
198 m_mac->DoSubframeIndication(frameNo, subframeNo);
199}
200
201void
206
207//////////////////////////////////////////////////////////
208// LteUeMac methods
209///////////////////////////////////////////////////////////
210
211TypeId
213{
214 static TypeId tid =
215 TypeId("ns3::LteUeMac")
216 .SetParent<Object>()
217 .SetGroupName("Lte")
218 .AddConstructor<LteUeMac>()
219 .AddTraceSource("RaResponseTimeout",
220 "trace fired upon RA response timeout",
222 "ns3::LteUeMac::RaResponseTimeoutTracedCallback")
223
224 ;
225 return tid;
226}
227
229 : m_bsrPeriodicity(MilliSeconds(1)), // ideal behavior
230 m_bsrLast(MilliSeconds(0)),
231 m_freshUlBsr(false),
232 m_harqProcessId(0),
233 m_rnti(0),
234 m_imsi(0),
235 m_rachConfigured(false),
236 m_waitingForRaResponse(false)
237
238{
239 NS_LOG_FUNCTION(this);
241 for (std::size_t i = 0; i < m_miUlHarqProcessesPacket.size(); i++)
242 {
244 m_miUlHarqProcessesPacket.at(i) = pb;
245 }
247
253}
254
259
260void
262{
263 NS_LOG_FUNCTION(this);
265 delete m_macSapProvider;
266 delete m_cmacSapProvider;
267 delete m_uePhySapUser;
269}
270
276
277void
282
288
289void
294
300
301void
303{
304 m_componentCarrierId = index;
305}
306
307void
309{
310 NS_LOG_FUNCTION(this);
311 NS_ASSERT_MSG(m_rnti == params.rnti, "RNTI mismatch between RLC and MAC");
312 LteRadioBearerTag tag(params.rnti, params.lcid, 0 /* UE works in SISO mode*/);
313 params.pdu->AddPacketTag(tag);
314 // store pdu in HARQ buffer
315 m_miUlHarqProcessesPacket.at(m_harqProcessId)->AddPacket(params.pdu);
317 m_uePhySapProvider->SendMacPdu(params.pdu);
318}
319
320void
322{
323 NS_LOG_FUNCTION(this << (uint32_t)params.lcid);
324
325 auto it = m_ulBsrReceived.find(params.lcid);
326 if (it != m_ulBsrReceived.end())
327 {
328 // update entry
329 (*it).second = params;
330 }
331 else
332 {
333 m_ulBsrReceived.insert(
334 std::pair<uint8_t, LteMacSapProvider::ReportBufferStatusParameters>(params.lcid,
335 params));
336 }
337 m_freshUlBsr = true;
338}
339
340void
342{
343 NS_LOG_FUNCTION(this);
344
345 if (m_rnti == 0)
346 {
347 NS_LOG_INFO("MAC not initialized, BSR deferred");
348 return;
349 }
350
351 if (m_ulBsrReceived.empty())
352 {
353 NS_LOG_INFO("No BSR report to transmit");
354 return;
355 }
357 bsr.m_rnti = m_rnti;
358 bsr.m_macCeType = MacCeListElement_s::BSR;
359
360 // BSR is reported for each LCG
361 std::vector<uint32_t> queue(4, 0); // one value per each of the 4 LCGs, initialized to 0
362 for (auto it = m_ulBsrReceived.begin(); it != m_ulBsrReceived.end(); it++)
363 {
364 uint8_t lcid = it->first;
365 auto lcInfoMapIt = m_lcInfoMap.find(lcid);
366 NS_ASSERT(lcInfoMapIt != m_lcInfoMap.end());
367 NS_ASSERT_MSG((lcid != 0) ||
368 (((*it).second.txQueueSize == 0) && ((*it).second.retxQueueSize == 0) &&
369 ((*it).second.statusPduSize == 0)),
370 "BSR should not be used for LCID 0");
371 uint8_t lcg = lcInfoMapIt->second.lcConfig.logicalChannelGroup;
372 queue.at(lcg) +=
373 ((*it).second.txQueueSize + (*it).second.retxQueueSize + (*it).second.statusPduSize);
374 }
375
376 // FF API says that all 4 LCGs are always present
381
382 // create the feedback to eNB
384 msg->SetBsr(bsr);
386}
387
388void
390{
391 NS_LOG_FUNCTION(this);
392 // 3GPP 36.321 5.1.1
393 NS_ASSERT_MSG(m_rachConfigured, "RACH not configured");
394 // assume that there is no Random Access Preambles group B
397 bool contention = true;
398 SendRaPreamble(contention);
399}
400
401void
403{
404 NS_LOG_FUNCTION(this << (uint32_t)m_raPreambleId << contention);
405 // Since regular UL LteControlMessages need m_ulConfigured = true in
406 // order to be sent by the UE, the rach preamble needs to be sent
407 // with a dedicated primitive (not
408 // m_uePhySapProvider->SendLteControlMessage (msg)) so that it can
409 // bypass the m_ulConfigured flag. This is reasonable, since In fact
410 // the RACH preamble is sent on 6RB bandwidth so the uplink
411 // bandwidth does not need to be configured.
412 NS_ASSERT(m_subframeNo > 0); // sanity check for subframe starting at 1
415 NS_LOG_INFO(this << " sent preamble id " << (uint32_t)m_raPreambleId << ", RA-RNTI "
416 << (uint32_t)m_raRnti);
417 // 3GPP 36.321 5.1.4
418 Time raWindowBegin = MilliSeconds(3);
422 Simulator::Schedule(raWindowEnd, &LteUeMac::RaResponseTimeout, this, contention);
423}
424
425void
431
432void
434{
435 NS_LOG_FUNCTION(this);
438 NS_LOG_INFO("got RAR for RAPID " << (uint32_t)m_raPreambleId
439 << ", setting T-C-RNTI = " << raResponse.m_rnti);
440 m_rnti = raResponse.m_rnti;
442 // in principle we should wait for contention resolution,
443 // but in the current LTE model when two or more identical
444 // preambles are sent no one is received, so there is no need
445 // for contention resolution
447 // trigger tx opportunity for Message 3 over LC 0
448 // this is needed since Message 3's UL GRANT is in the RAR, not in UL-DCIs
449 const uint8_t lc0Lcid = 0;
450 auto lc0InfoIt = m_lcInfoMap.find(lc0Lcid);
451 NS_ASSERT(lc0InfoIt != m_lcInfoMap.end());
452 auto lc0BsrIt = m_ulBsrReceived.find(lc0Lcid);
453 if ((lc0BsrIt != m_ulBsrReceived.end()) && (lc0BsrIt->second.txQueueSize > 0))
454 {
455 NS_ASSERT_MSG(raResponse.m_grant.m_tbSize > lc0BsrIt->second.txQueueSize,
456 "segmentation of Message 3 is not allowed");
457 // this function can be called only from primary carrier
458 if (m_componentCarrierId > 0)
459 {
460 NS_FATAL_ERROR("Function called on wrong componentCarrier");
461 }
463 txOpParams.bytes = raResponse.m_grant.m_tbSize;
464 txOpParams.layer = 0;
465 txOpParams.harqId = 0;
467 txOpParams.rnti = m_rnti;
468 txOpParams.lcid = lc0Lcid;
469 lc0InfoIt->second.macSapUser->NotifyTxOpportunity(txOpParams);
470 lc0BsrIt->second.txQueueSize = 0;
471 }
472}
473
474void
476{
477 NS_LOG_FUNCTION(this << contention);
479 // 3GPP 36.321 5.1.4
481 // fire RA response timeout trace
483 contention,
487 {
488 NS_LOG_INFO("RAR timeout, preambleTransMax reached => giving up");
490 }
491 else
492 {
493 NS_LOG_INFO("RAR timeout, re-send preamble");
494 if (contention)
495 {
497 }
498 else
499 {
500 SendRaPreamble(contention);
501 }
502 }
503}
504
505void
512
513void
524
525void
527{
528 NS_LOG_FUNCTION(this);
529 m_rnti = rnti;
530}
531
532void
534{
535 NS_LOG_FUNCTION(this);
536 m_imsi = imsi;
537}
538
539void
541 uint8_t preambleId,
542 uint8_t prachMask)
543{
544 NS_LOG_FUNCTION(this << rnti << (uint16_t)preambleId << (uint16_t)prachMask);
545 NS_ASSERT_MSG(prachMask == 0,
546 "requested PRACH MASK = " << (uint32_t)prachMask
547 << ", but only PRACH MASK = 0 is supported");
548 m_rnti = rnti;
549 m_raPreambleId = preambleId;
551 bool contention = false;
552 SendRaPreamble(contention);
553}
554
555void
556LteUeMac::DoAddLc(uint8_t lcId,
558 LteMacSapUser* msu)
559{
560 NS_LOG_FUNCTION(this << " lcId" << (uint32_t)lcId);
561 NS_ASSERT_MSG(m_lcInfoMap.find(lcId) == m_lcInfoMap.end(),
562 "cannot add channel because LCID " << (uint16_t)lcId << " is already present");
563
564 LcInfo lcInfo;
565 lcInfo.lcConfig = lcConfig;
566 lcInfo.macSapUser = msu;
567 m_lcInfoMap[lcId] = lcInfo;
568}
569
570void
572{
573 NS_LOG_FUNCTION(this << " lcId" << lcId);
574 NS_ASSERT_MSG(m_lcInfoMap.find(lcId) != m_lcInfoMap.end(), "could not find LCID " << lcId);
575 m_lcInfoMap.erase(lcId);
576 m_ulBsrReceived.erase(lcId); // empty BSR buffer for this lcId
577}
578
579void
581{
582 NS_LOG_FUNCTION(this);
583 auto it = m_lcInfoMap.begin();
584 while (it != m_lcInfoMap.end())
585 {
586 // don't delete CCCH)
587 if (it->first == 0)
588 {
589 ++it;
590 }
591 else
592 {
593 // note: use of postfix operator preserves validity of iterator
594 m_lcInfoMap.erase(it++);
595 }
596 }
597 // note: rnti will be assigned by the eNB using RA response message
598 m_rnti = 0;
600 m_rachConfigured = false;
601 m_freshUlBsr = false;
602 m_ulBsrReceived.clear();
603}
604
605void
611
612void
614{
616 p->RemovePacketTag(tag);
617 if (tag.GetRnti() == m_rnti)
618 {
619 // packet is for the current user
620 auto it = m_lcInfoMap.find(tag.GetLcid());
621 if (it != m_lcInfoMap.end())
622 {
624 rxPduParams.p = p;
625 rxPduParams.rnti = m_rnti;
626 rxPduParams.lcid = tag.GetLcid();
627 it->second.macSapUser->ReceivePdu(rxPduParams);
628 }
629 else
630 {
631 NS_LOG_WARN("received packet with unknown lcid " << (uint32_t)tag.GetLcid());
632 }
633 }
634}
635
636void
638{
639 NS_LOG_FUNCTION(this);
640 if (msg->GetMessageType() == LteControlMessage::UL_DCI)
641 {
643 UlDciListElement_s dci = msg2->GetDci();
644 if (dci.m_ndi == 1)
645 {
646 // New transmission -> empty pkt buffer queue (for deleting eventual pkts not acked )
649 // Retrieve data from RLC
650 uint16_t activeLcs = 0;
651 uint32_t statusPduMinSize = 0;
652 for (auto itBsr = m_ulBsrReceived.begin(); itBsr != m_ulBsrReceived.end(); itBsr++)
653 {
654 if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) ||
655 ((*itBsr).second.txQueueSize > 0))
656 {
657 activeLcs++;
658 if (((*itBsr).second.statusPduSize != 0) &&
659 ((*itBsr).second.statusPduSize < statusPduMinSize))
660 {
661 statusPduMinSize = (*itBsr).second.statusPduSize;
662 }
663 if (((*itBsr).second.statusPduSize != 0) && (statusPduMinSize == 0))
664 {
665 statusPduMinSize = (*itBsr).second.statusPduSize;
666 }
667 }
668 }
669 if (activeLcs == 0)
670 {
671 NS_LOG_ERROR(this << " No active flows for this UL-DCI");
672 return;
673 }
674 uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs;
675 bool statusPduPriority = false;
676 if ((statusPduMinSize != 0) && (bytesPerActiveLc < statusPduMinSize))
677 {
678 // send only the status PDU which has highest priority
679 statusPduPriority = true;
680 NS_LOG_DEBUG(this << " Reduced resource -> send only Status, b ytes "
681 << statusPduMinSize);
682 if (dci.m_tbSize < statusPduMinSize)
683 {
684 NS_FATAL_ERROR("Insufficient Tx Opportunity for sending a status message");
685 }
686 }
687 NS_LOG_LOGIC(this << " UE " << m_rnti << ": UL-CQI notified TxOpportunity of "
688 << dci.m_tbSize << " => " << bytesPerActiveLc
689 << " bytes per active LC"
690 << " statusPduMinSize " << statusPduMinSize);
691
693
694 for (auto it = m_lcInfoMap.begin(); it != m_lcInfoMap.end(); it++)
695 {
696 auto itBsr = m_ulBsrReceived.find((*it).first);
697 NS_LOG_DEBUG(this << " Processing LC " << (uint32_t)(*it).first
698 << " bytesPerActiveLc " << bytesPerActiveLc);
699 if ((itBsr != m_ulBsrReceived.end()) &&
700 (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) ||
701 ((*itBsr).second.txQueueSize > 0)))
702 {
703 if ((statusPduPriority) && ((*itBsr).second.statusPduSize == statusPduMinSize))
704 {
705 txOpParams.bytes = (*itBsr).second.statusPduSize;
706 txOpParams.layer = 0;
707 txOpParams.harqId = 0;
709 txOpParams.rnti = m_rnti;
710 txOpParams.lcid = (*it).first;
711 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
712 NS_LOG_LOGIC(this << "\t" << bytesPerActiveLc << " send "
713 << (*itBsr).second.statusPduSize << " status bytes to LC "
714 << (uint32_t)(*it).first << " statusQueue "
715 << (*itBsr).second.statusPduSize << " retxQueue"
716 << (*itBsr).second.retxQueueSize << " txQueue"
717 << (*itBsr).second.txQueueSize);
718 (*itBsr).second.statusPduSize = 0;
719 break;
720 }
721 else
722 {
723 uint32_t bytesForThisLc = bytesPerActiveLc;
724 NS_LOG_LOGIC(this << "\t" << bytesPerActiveLc << " bytes to LC "
725 << (uint32_t)(*it).first << " statusQueue "
726 << (*itBsr).second.statusPduSize << " retxQueue"
727 << (*itBsr).second.retxQueueSize << " txQueue"
728 << (*itBsr).second.txQueueSize);
729 if (((*itBsr).second.statusPduSize > 0) &&
730 (bytesForThisLc > (*itBsr).second.statusPduSize))
731 {
732 txOpParams.bytes = (*itBsr).second.statusPduSize;
733 txOpParams.layer = 0;
734 txOpParams.harqId = 0;
736 txOpParams.rnti = m_rnti;
737 txOpParams.lcid = (*it).first;
738 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
739 bytesForThisLc -= (*itBsr).second.statusPduSize;
740 NS_LOG_DEBUG(this << " serve STATUS " << (*itBsr).second.statusPduSize);
741 (*itBsr).second.statusPduSize = 0;
742 }
743 else
744 {
745 if ((*itBsr).second.statusPduSize > bytesForThisLc)
746 {
748 "Insufficient Tx Opportunity for sending a status message");
749 }
750 }
751
752 if ((bytesForThisLc > 7) // 7 is the min TxOpportunity useful for Rlc
753 && (((*itBsr).second.retxQueueSize > 0) ||
754 ((*itBsr).second.txQueueSize > 0)))
755 {
756 if ((*itBsr).second.retxQueueSize > 0)
757 {
758 NS_LOG_DEBUG(this << " serve retx DATA, bytes " << bytesForThisLc);
759 txOpParams.bytes = bytesForThisLc;
760 txOpParams.layer = 0;
761 txOpParams.harqId = 0;
763 txOpParams.rnti = m_rnti;
764 txOpParams.lcid = (*it).first;
765 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
766 if ((*itBsr).second.retxQueueSize >= bytesForThisLc)
767 {
768 (*itBsr).second.retxQueueSize -= bytesForThisLc;
769 }
770 else
771 {
772 (*itBsr).second.retxQueueSize = 0;
773 }
774 }
775 else if ((*itBsr).second.txQueueSize > 0)
776 {
777 uint16_t lcid = (*it).first;
778 uint32_t rlcOverhead;
779 if (lcid == 1)
780 {
781 // for SRB1 (using RLC AM) it's better to
782 // overestimate RLC overhead rather than
783 // underestimate it and risk unneeded
784 // segmentation which increases delay
785 rlcOverhead = 4;
786 }
787 else
788 {
789 // minimum RLC overhead due to header
790 rlcOverhead = 2;
791 }
792 NS_LOG_DEBUG(this << " serve tx DATA, bytes " << bytesForThisLc
793 << ", RLC overhead " << rlcOverhead);
794 txOpParams.bytes = bytesForThisLc;
795 txOpParams.layer = 0;
796 txOpParams.harqId = 0;
798 txOpParams.rnti = m_rnti;
799 txOpParams.lcid = (*it).first;
800 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
801 if ((*itBsr).second.txQueueSize >= bytesForThisLc - rlcOverhead)
802 {
803 (*itBsr).second.txQueueSize -= bytesForThisLc - rlcOverhead;
804 }
805 else
806 {
807 (*itBsr).second.txQueueSize = 0;
808 }
809 }
810 }
811 else
812 {
813 if (((*itBsr).second.retxQueueSize > 0) ||
814 ((*itBsr).second.txQueueSize > 0))
815 {
816 // resend BSR info for updating eNB peer MAC
817 m_freshUlBsr = true;
818 }
819 }
820 NS_LOG_LOGIC(this << "\t" << bytesPerActiveLc << "\t new queues "
821 << (uint32_t)(*it).first << " statusQueue "
822 << (*itBsr).second.statusPduSize << " retxQueue"
823 << (*itBsr).second.retxQueueSize << " txQueue"
824 << (*itBsr).second.txQueueSize);
825 }
826 }
827 }
828 }
829 else
830 {
831 // HARQ retransmission -> retrieve data from HARQ buffer
832 NS_LOG_DEBUG(this << " UE MAC RETX HARQ " << (uint16_t)m_harqProcessId);
834 for (auto j = pb->Begin(); j != pb->End(); ++j)
835 {
836 Ptr<Packet> pkt = (*j)->Copy();
838 }
840 }
841 }
842 else if (msg->GetMessageType() == LteControlMessage::RAR)
843 {
845 {
847 uint16_t raRnti = rarMsg->GetRaRnti();
848 NS_LOG_LOGIC(this << "got RAR with RA-RNTI " << (uint32_t)raRnti << ", expecting "
849 << (uint32_t)m_raRnti);
850 if (raRnti == m_raRnti) // RAR corresponds to TX subframe of preamble
851 {
852 for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it)
853 {
854 if (it->rapId == m_raPreambleId) // RAR is for me
855 {
856 RecvRaResponse(it->rarPayload);
857 /// \todo RRC generates the RecvRaResponse messaged
858 /// for avoiding holes in transmission at PHY layer
859 /// (which produce erroneous UL CQI evaluation)
860 }
861 }
862 }
863 }
864 }
865 else
866 {
867 NS_LOG_WARN(this << " LteControlMessage not recognized");
868 }
869}
870
871void
873{
874 NS_LOG_FUNCTION(this);
875
876 for (std::size_t i = 0; i < m_miUlHarqProcessesPacketTimer.size(); i++)
877 {
878 if (m_miUlHarqProcessesPacketTimer.at(i) == 0)
879 {
880 if (m_miUlHarqProcessesPacket.at(i)->GetSize() > 0)
881 {
882 // timer expired: drop packets in buffer for this process
883 NS_LOG_INFO(this << " HARQ Proc Id " << i << " packets buffer expired");
885 m_miUlHarqProcessesPacket.at(i) = emptyPb;
886 }
887 }
888 else
889 {
891 }
892 }
893}
894
895void
897{
898 NS_LOG_FUNCTION(this);
899 m_frameNo = frameNo;
900 m_subframeNo = subframeNo;
903 {
904 if (m_componentCarrierId == 0)
905 {
906 // Send BSR through primary carrier
908 }
910 m_freshUlBsr = false;
911 }
913}
914
915int64_t
917{
918 NS_LOG_FUNCTION(this << stream);
919 m_raPreambleUniformVariable->SetStream(stream);
920 return 1;
921}
922
923} // namespace ns3
static uint8_t BufferSize2BsrId(uint32_t val)
Convert Buffer size to BSR ID.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition event-id.cc:44
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition lte-mac-sap.h:25
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition lte-mac-sap.h:85
Tag used to define the RNTI and LC id for each MAC packet transmitted.
uint16_t GetRnti() const
Get RNTI function.
uint8_t GetLcid() const
Get LCID function.
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
virtual void NotifyRandomAccessFailed()=0
Notify the RRC that the MAC Random Access procedure failed.
virtual void NotifyRandomAccessSuccessful()=0
Notify the RRC that the MAC Random Access procedure completed successfully.
virtual void SetTemporaryCellRnti(uint16_t rnti)=0
uint8_t m_raRnti
RA RNTI.
Definition lte-ue-mac.h:282
std::vector< Ptr< PacketBurst > > m_miUlHarqProcessesPacket
Packets under transmission of the UL HARQ processes.
Definition lte-ue-mac.h:266
LteUePhySapUser * m_uePhySapUser
UE Phy SAP user.
Definition lte-ue-mac.h:254
uint8_t m_componentCarrierId
component carrier Id --> used to address sap
Definition lte-ue-mac.h:236
void RaResponseTimeout(bool contention)
RA response timeout function.
LteUeCmacSapProvider::RachConfig m_rachConfig
RACH configuration.
Definition lte-ue-mac.h:273
uint32_t m_frameNo
frame number
Definition lte-ue-mac.h:280
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Forwarded from LteUePhySapUser: trigger the start from a new frame.
void SendReportBufferStatus()
Send report buffer status.
void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Report buffers status function.
TracedCallback< uint64_t, bool, uint8_t, uint8_t > m_raResponseTimeoutTrace
The RaResponseTimeout trace source.
Definition lte-ue-mac.h:290
LteUePhySapProvider * m_uePhySapProvider
UE Phy SAP provider.
Definition lte-ue-mac.h:253
void SetLteUePhySapProvider(LteUePhySapProvider *s)
Set the PHY SAP Provider.
Time m_bsrPeriodicity
BSR periodicity.
Definition lte-ue-mac.h:259
void RefreshHarqProcessesPacketBuffer()
Refresh HARQ processes packet buffer function.
uint16_t m_imsi
IMSI.
Definition lte-ue-mac.h:270
EventId m_noRaResponseReceivedEvent
no RA response received event ID
Definition lte-ue-mac.h:277
LteUeCmacSapProvider * m_cmacSapProvider
CMAC SAP provider.
Definition lte-ue-mac.h:251
uint8_t m_preambleTransmissionCounter
preamble tranamission counter
Definition lte-ue-mac.h:275
Ptr< UniformRandomVariable > m_raPreambleUniformVariable
RA preamble random variable.
Definition lte-ue-mac.h:278
void SetComponentCarrierId(uint8_t index)
Set the component carried ID.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void DoConfigureRach(LteUeCmacSapProvider::RachConfig rc)
Configure RACH function.
LteUePhySapUser * GetLteUePhySapUser()
Get the PHY SAP user.
friend class UeMemberLteUePhySapUser
allow UeMemberLteUePhySapUser class friend access
Definition lte-ue-mac.h:39
bool m_rachConfigured
is RACH configured?
Definition lte-ue-mac.h:272
void DoRemoveLc(uint8_t lcId)
Remove LC function.
void RecvRaResponse(BuildRarListElement_s raResponse)
Receive the RA response function.
void DoReceivePhyPdu(Ptr< Packet > p)
Receive Phy PDU function.
uint8_t m_raPreambleId
RA preamble ID.
Definition lte-ue-mac.h:274
void DoNotifyConnectionSuccessful()
Notify MAC about the successful RRC connection establishment.
Time m_bsrLast
BSR last.
Definition lte-ue-mac.h:260
friend class UeMemberLteUeCmacSapProvider
allow UeMemberLteUeCmacSapProvider class friend access
Definition lte-ue-mac.h:35
std::vector< uint8_t > m_miUlHarqProcessesPacketTimer
timer for packet life in the buffer
Definition lte-ue-mac.h:267
void DoReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive LTE control message function.
uint16_t m_rnti
RNTI.
Definition lte-ue-mac.h:269
static TypeId GetTypeId()
Get the type ID.
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Transmit PDU function.
uint32_t m_subframeNo
subframe number
Definition lte-ue-mac.h:281
std::map< uint8_t, LteMacSapProvider::ReportBufferStatusParameters > m_ulBsrReceived
BSR received from RLC (the last one)
Definition lte-ue-mac.h:257
void DoDispose() override
Destructor implementation.
void DoReset()
Reset function.
~LteUeMac() override
LteUeCmacSapUser * m_cmacSapUser
CMAC SAP user.
Definition lte-ue-mac.h:250
bool m_freshUlBsr
true when a BSR has been received in the last TTI
Definition lte-ue-mac.h:262
LteMacSapProvider * GetLteMacSapProvider()
Get the LTE MAC SAP provider.
void DoStartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t rapId, uint8_t prachMask)
Start non contention based random access procedure function.
LteUeCmacSapProvider * GetLteUeCmacSapProvider()
Get the LTE CMAC SAP provider.
bool m_waitingForRaResponse
waiting for RA response
Definition lte-ue-mac.h:283
void DoAddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Add LC function.
uint8_t m_harqProcessId
HARQ process ID.
Definition lte-ue-mac.h:264
friend class UeMemberLteMacSapProvider
allow UeMemberLteMacSapProvider class friend access
Definition lte-ue-mac.h:37
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition lte-ue-mac.h:248
void RandomlySelectAndSendRaPreamble()
Randomly select and send RA preamble function.
void DoStartContentionBasedRandomAccessProcedure()
Start contention based random access procedure function.
uint16_t m_backoffParameter
backoff parameter
Definition lte-ue-mac.h:276
void StartWaitingForRaResponse()
Start waiting for RA response function.
void DoSetRnti(uint16_t rnti)
Set RNTI.
void DoSetImsi(uint64_t imsi)
Set IMSI.
void SendRaPreamble(bool contention)
Send RA preamble function.
void SetLteUeCmacSapUser(LteUeCmacSapUser *s)
Set the LTE UE CMAC SAP user.
std::map< uint8_t, LcInfo > m_lcInfoMap
logical channel info map
Definition lte-ue-mac.h:246
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)=0
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
virtual void SendRachPreamble(uint32_t prachId, uint32_t raRnti)=0
Send a preamble on the PRACH.
virtual void NotifyConnectionSuccessful()=0
Notify PHY about the successful RRC connection establishment.
virtual void SendMacPdu(Ptr< Packet > p)=0
Send the MAC PDU to the channel.
Service Access Point (SAP) offered by the PHY to the MAC.
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
UeMemberLteMacSapProvider class.
LteUeMac * m_mac
the UE MAC
void TransmitPdu(TransmitPduParameters params) override
send an RLC PDU to the MAC for transmission.
void ReportBufferStatus(ReportBufferStatusParameters params) override
Report the RLC buffer status to the MAC.
UeMemberLteMacSapProvider(LteUeMac *mac)
Constructor.
UeMemberLteUeCmacSapProvider class.
Definition lte-ue-mac.cc:37
void StartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t preambleId, uint8_t prachMask) override
tell the MAC to start a non-contention-based random access procedure, e.g., as a consequence of hando...
Definition lte-ue-mac.cc:83
void SetImsi(uint64_t imsi) override
A method call by UE RRC to communicate the IMSI to the UE MAC.
void Reset() override
reset the MAC
void StartContentionBasedRandomAccessProcedure() override
tell the MAC to start a contention-based random access procedure, e.g., to perform RRC connection est...
Definition lte-ue-mac.cc:77
void AddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu) override
add a new Logical Channel (LC)
Definition lte-ue-mac.cc:97
void RemoveLc(uint8_t lcId) override
remove an existing LC
void SetRnti(uint16_t rnti) override
Definition lte-ue-mac.cc:91
void ConfigureRach(RachConfig rc) override
Configure RACH function.
Definition lte-ue-mac.cc:71
void NotifyConnectionSuccessful() override
Notify MAC about the successful RRC connection establishment.
UeMemberLteUeCmacSapProvider(LteUeMac *mac)
Constructor.
Definition lte-ue-mac.cc:65
UeMemberLteUePhySapUser.
UeMemberLteUePhySapUser(LteUeMac *mac)
Constructor.
LteUeMac * m_mac
the UE MAC
void ReceiveLteControlMessage(Ptr< LteControlMessage > msg) override
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
void ReceivePhyPdu(Ptr< Packet > p) override
Receive Phy Pdu function.
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo) override
Trigger the start from a new frame (input from Phy layer)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#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:75
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
#define HARQ_PERIOD
Definition lte-common.h:19
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
See section 4.3.10 buildRARListElement.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition lte-mac-sap.h:58
Parameters for LteMacSapProvider::TransmitPdu.
Definition lte-mac-sap.h:34
Parameters for LteMacSapUser::ReceivePdu.
Ptr< Packet > p
the RLC PDU to be received
uint8_t lcid
the logical channel id
uint16_t rnti
the C-RNTI identifying the UE
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition lte-mac-sap.h:94
uint16_t rnti
the C-RNTI identifying the UE
uint32_t bytes
the number of bytes to transmit
uint8_t componentCarrierId
the component carrier id
uint8_t layer
the layer of transmission (MIMO)
uint8_t lcid
the logical channel id
uint8_t raResponseWindowSize
RA response window size.
uint8_t preambleTransMax
preamble transmit maximum
uint8_t numberOfRaPreambles
number of RA preambles
LcInfo structure.
Definition lte-ue-mac.h:241
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
logical channel config
Definition lte-ue-mac.h:242
LteMacSapUser * macSapUser
MAC SAP user.
Definition lte-ue-mac.h:243
See section 4.3.14 macCEListElement.
struct MacCeValue_u m_macCeValue
MAC CE value.
std::vector< uint8_t > m_bufferStatus
buffer status
See section 4.3.2 ulDciListElement.
uint16_t m_tbSize
size