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(),
231 m_freshUlBsr(false),
232 m_harqProcessId(0),
233 m_miUlHarqProcessesPacketTimer(HARQ_PERIOD, 0),
234 m_rnti(0),
235 m_imsi(0),
236 m_rachConfigured(false),
237 m_waitingForRaResponse(false)
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 }
246
252}
253
258
259void
261{
262 NS_LOG_FUNCTION(this);
264 delete m_macSapProvider;
265 delete m_cmacSapProvider;
266 delete m_uePhySapUser;
268}
269
275
276void
281
287
288void
293
299
300void
302{
303 m_componentCarrierId = index;
304}
305
306void
308{
309 NS_LOG_FUNCTION(this);
310 NS_ASSERT_MSG(m_rnti == params.rnti, "RNTI mismatch between RLC and MAC");
311 LteRadioBearerTag tag(params.rnti, params.lcid, 0 /* UE works in SISO mode*/);
312 params.pdu->AddPacketTag(tag);
313 // store pdu in HARQ buffer
314 m_miUlHarqProcessesPacket.at(m_harqProcessId)->AddPacket(params.pdu);
316 m_uePhySapProvider->SendMacPdu(params.pdu);
317}
318
319void
321{
322 NS_LOG_FUNCTION(this << (uint32_t)params.lcid);
323
324 auto it = m_ulBsrReceived.find(params.lcid);
325 if (it != m_ulBsrReceived.end())
326 {
327 // update entry
328 (*it).second = params;
329 }
330 else
331 {
332 m_ulBsrReceived.insert(
333 std::pair<uint8_t, LteMacSapProvider::ReportBufferStatusParameters>(params.lcid,
334 params));
335 }
336 m_freshUlBsr = true;
337}
338
339void
341{
342 NS_LOG_FUNCTION(this);
343
344 if (m_rnti == 0)
345 {
346 NS_LOG_INFO("MAC not initialized, BSR deferred");
347 return;
348 }
349
350 if (m_ulBsrReceived.empty())
351 {
352 NS_LOG_INFO("No BSR report to transmit");
353 return;
354 }
356 bsr.m_rnti = m_rnti;
357 bsr.m_macCeType = MacCeListElement_s::BSR;
358
359 // BSR is reported for each LCG
360 std::vector<uint32_t> queue(4, 0); // one value per each of the 4 LCGs, initialized to 0
361 for (auto it = m_ulBsrReceived.begin(); it != m_ulBsrReceived.end(); it++)
362 {
363 uint8_t lcid = it->first;
364 auto lcInfoMapIt = m_lcInfoMap.find(lcid);
365 NS_ASSERT(lcInfoMapIt != m_lcInfoMap.end());
366 NS_ASSERT_MSG((lcid != 0) ||
367 (((*it).second.txQueueSize == 0) && ((*it).second.retxQueueSize == 0) &&
368 ((*it).second.statusPduSize == 0)),
369 "BSR should not be used for LCID 0");
370 uint8_t lcg = lcInfoMapIt->second.lcConfig.logicalChannelGroup;
371 queue.at(lcg) +=
372 ((*it).second.txQueueSize + (*it).second.retxQueueSize + (*it).second.statusPduSize);
373 }
374
375 // FF API says that all 4 LCGs are always present
380
381 // create the feedback to eNB
383 msg->SetBsr(bsr);
385}
386
387void
389{
390 NS_LOG_FUNCTION(this);
391 // 3GPP 36.321 5.1.1
392 NS_ASSERT_MSG(m_rachConfigured, "RACH not configured");
393 // assume that there is no Random Access Preambles group B
396 bool contention = true;
397 SendRaPreamble(contention);
398}
399
400void
402{
403 NS_LOG_FUNCTION(this << (uint32_t)m_raPreambleId << contention);
404 // Since regular UL LteControlMessages need m_ulConfigured = true in
405 // order to be sent by the UE, the rach preamble needs to be sent
406 // with a dedicated primitive (not
407 // m_uePhySapProvider->SendLteControlMessage (msg)) so that it can
408 // bypass the m_ulConfigured flag. This is reasonable, since In fact
409 // the RACH preamble is sent on 6RB bandwidth so the uplink
410 // bandwidth does not need to be configured.
411 NS_ASSERT(m_subframeNo > 0); // sanity check for subframe starting at 1
414 NS_LOG_INFO(this << " sent preamble id " << (uint32_t)m_raPreambleId << ", RA-RNTI "
415 << (uint32_t)m_raRnti);
416 // 3GPP 36.321 5.1.4
417 Time raWindowBegin = MilliSeconds(3);
421 Simulator::Schedule(raWindowEnd, &LteUeMac::RaResponseTimeout, this, contention);
422}
423
424void
430
431void
433{
434 NS_LOG_FUNCTION(this);
437 NS_LOG_INFO("got RAR for RAPID " << (uint32_t)m_raPreambleId
438 << ", setting T-C-RNTI = " << raResponse.m_rnti);
439 m_rnti = raResponse.m_rnti;
441 // in principle we should wait for contention resolution,
442 // but in the current LTE model when two or more identical
443 // preambles are sent no one is received, so there is no need
444 // for contention resolution
446 // trigger tx opportunity for Message 3 over LC 0
447 // this is needed since Message 3's UL GRANT is in the RAR, not in UL-DCIs
448 const uint8_t lc0Lcid = 0;
449 auto lc0InfoIt = m_lcInfoMap.find(lc0Lcid);
450 NS_ASSERT(lc0InfoIt != m_lcInfoMap.end());
451 auto lc0BsrIt = m_ulBsrReceived.find(lc0Lcid);
452 if ((lc0BsrIt != m_ulBsrReceived.end()) && (lc0BsrIt->second.txQueueSize > 0))
453 {
454 NS_ASSERT_MSG(raResponse.m_grant.m_tbSize > lc0BsrIt->second.txQueueSize,
455 "segmentation of Message 3 is not allowed");
456 // this function can be called only from primary carrier
457 if (m_componentCarrierId > 0)
458 {
459 NS_FATAL_ERROR("Function called on wrong componentCarrier");
460 }
462 txOpParams.bytes = raResponse.m_grant.m_tbSize;
463 txOpParams.layer = 0;
464 txOpParams.harqId = 0;
466 txOpParams.rnti = m_rnti;
467 txOpParams.lcid = lc0Lcid;
468 lc0InfoIt->second.macSapUser->NotifyTxOpportunity(txOpParams);
469 lc0BsrIt->second.txQueueSize = 0;
470 }
471}
472
473void
475{
476 NS_LOG_FUNCTION(this << contention);
478 // 3GPP 36.321 5.1.4
480 // fire RA response timeout trace
482 contention,
486 {
487 NS_LOG_INFO("RAR timeout, preambleTransMax reached => giving up");
489 }
490 else
491 {
492 NS_LOG_INFO("RAR timeout, re-send preamble");
493 if (contention)
494 {
496 }
497 else
498 {
499 SendRaPreamble(contention);
500 }
501 }
502}
503
504void
511
512void
523
524void
526{
527 NS_LOG_FUNCTION(this);
528 m_rnti = rnti;
529}
530
531void
533{
534 NS_LOG_FUNCTION(this);
535 m_imsi = imsi;
536}
537
538void
540 uint8_t preambleId,
541 uint8_t prachMask)
542{
543 NS_LOG_FUNCTION(this << rnti << (uint16_t)preambleId << (uint16_t)prachMask);
544 NS_ASSERT_MSG(prachMask == 0,
545 "requested PRACH MASK = " << (uint32_t)prachMask
546 << ", but only PRACH MASK = 0 is supported");
547 m_rnti = rnti;
548 m_raPreambleId = preambleId;
550 bool contention = false;
551 SendRaPreamble(contention);
552}
553
554void
555LteUeMac::DoAddLc(uint8_t lcId,
557 LteMacSapUser* msu)
558{
559 NS_LOG_FUNCTION(this << " lcId" << (uint32_t)lcId);
560 NS_ASSERT_MSG(m_lcInfoMap.find(lcId) == m_lcInfoMap.end(),
561 "cannot add channel because LCID " << (uint16_t)lcId << " is already present");
562
563 LcInfo lcInfo;
564 lcInfo.lcConfig = lcConfig;
565 lcInfo.macSapUser = msu;
566 m_lcInfoMap[lcId] = lcInfo;
567}
568
569void
571{
572 NS_LOG_FUNCTION(this << " lcId" << lcId);
573 NS_ASSERT_MSG(m_lcInfoMap.find(lcId) != m_lcInfoMap.end(), "could not find LCID " << lcId);
574 m_lcInfoMap.erase(lcId);
575 m_ulBsrReceived.erase(lcId); // empty BSR buffer for this lcId
576}
577
578void
580{
581 NS_LOG_FUNCTION(this);
582 auto it = m_lcInfoMap.begin();
583 while (it != m_lcInfoMap.end())
584 {
585 // don't delete CCCH)
586 if (it->first == 0)
587 {
588 ++it;
589 }
590 else
591 {
592 // note: use of postfix operator preserves validity of iterator
593 m_lcInfoMap.erase(it++);
594 }
595 }
596 // note: rnti will be assigned by the eNB using RA response message
597 m_rnti = 0;
599 m_rachConfigured = false;
600 m_freshUlBsr = false;
601 m_ulBsrReceived.clear();
602}
603
604void
610
611void
613{
615 p->RemovePacketTag(tag);
616 if (tag.GetRnti() == m_rnti)
617 {
618 // packet is for the current user
619 auto it = m_lcInfoMap.find(tag.GetLcid());
620 if (it != m_lcInfoMap.end())
621 {
623 rxPduParams.p = p;
624 rxPduParams.rnti = m_rnti;
625 rxPduParams.lcid = tag.GetLcid();
626 it->second.macSapUser->ReceivePdu(rxPduParams);
627 }
628 else
629 {
630 NS_LOG_WARN("received packet with unknown lcid " << (uint32_t)tag.GetLcid());
631 }
632 }
633}
634
635void
637{
638 NS_LOG_FUNCTION(this);
639 if (msg->GetMessageType() == LteControlMessage::UL_DCI)
640 {
642 UlDciListElement_s dci = msg2->GetDci();
643 if (dci.m_ndi == 1)
644 {
645 // New transmission -> empty pkt buffer queue (for deleting eventual pkts not acked )
648 // Retrieve data from RLC
649 uint16_t activeLcs = 0;
650 uint32_t statusPduMinSize = 0;
651 for (auto itBsr = m_ulBsrReceived.begin(); itBsr != m_ulBsrReceived.end(); itBsr++)
652 {
653 if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) ||
654 ((*itBsr).second.txQueueSize > 0))
655 {
656 activeLcs++;
657 if (((*itBsr).second.statusPduSize != 0) &&
658 ((*itBsr).second.statusPduSize < statusPduMinSize))
659 {
660 statusPduMinSize = (*itBsr).second.statusPduSize;
661 }
662 if (((*itBsr).second.statusPduSize != 0) && (statusPduMinSize == 0))
663 {
664 statusPduMinSize = (*itBsr).second.statusPduSize;
665 }
666 }
667 }
668 if (activeLcs == 0)
669 {
670 NS_LOG_ERROR(this << " No active flows for this UL-DCI");
671 return;
672 }
673 uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs;
674 bool statusPduPriority = false;
675 if ((statusPduMinSize != 0) && (bytesPerActiveLc < statusPduMinSize))
676 {
677 // send only the status PDU which has highest priority
678 statusPduPriority = true;
679 NS_LOG_DEBUG(this << " Reduced resource -> send only Status, b ytes "
680 << statusPduMinSize);
681 if (dci.m_tbSize < statusPduMinSize)
682 {
683 NS_FATAL_ERROR("Insufficient Tx Opportunity for sending a status message");
684 }
685 }
686 NS_LOG_LOGIC(this << " UE " << m_rnti << ": UL-CQI notified TxOpportunity of "
687 << dci.m_tbSize << " => " << bytesPerActiveLc
688 << " bytes per active LC"
689 << " statusPduMinSize " << statusPduMinSize);
690
692
693 for (auto it = m_lcInfoMap.begin(); it != m_lcInfoMap.end(); it++)
694 {
695 auto itBsr = m_ulBsrReceived.find((*it).first);
696 NS_LOG_DEBUG(this << " Processing LC " << (uint32_t)(*it).first
697 << " bytesPerActiveLc " << bytesPerActiveLc);
698 if ((itBsr != m_ulBsrReceived.end()) &&
699 (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) ||
700 ((*itBsr).second.txQueueSize > 0)))
701 {
702 if ((statusPduPriority) && ((*itBsr).second.statusPduSize == statusPduMinSize))
703 {
704 txOpParams.bytes = (*itBsr).second.statusPduSize;
705 txOpParams.layer = 0;
706 txOpParams.harqId = 0;
708 txOpParams.rnti = m_rnti;
709 txOpParams.lcid = (*it).first;
710 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
711 NS_LOG_LOGIC(this << "\t" << bytesPerActiveLc << " send "
712 << (*itBsr).second.statusPduSize << " status bytes to LC "
713 << (uint32_t)(*it).first << " statusQueue "
714 << (*itBsr).second.statusPduSize << " retxQueue"
715 << (*itBsr).second.retxQueueSize << " txQueue"
716 << (*itBsr).second.txQueueSize);
717 (*itBsr).second.statusPduSize = 0;
718 break;
719 }
720 else
721 {
722 uint32_t bytesForThisLc = bytesPerActiveLc;
723 NS_LOG_LOGIC(this << "\t" << bytesPerActiveLc << " bytes to LC "
724 << (uint32_t)(*it).first << " statusQueue "
725 << (*itBsr).second.statusPduSize << " retxQueue"
726 << (*itBsr).second.retxQueueSize << " txQueue"
727 << (*itBsr).second.txQueueSize);
728 if (((*itBsr).second.statusPduSize > 0) &&
729 (bytesForThisLc > (*itBsr).second.statusPduSize))
730 {
731 txOpParams.bytes = (*itBsr).second.statusPduSize;
732 txOpParams.layer = 0;
733 txOpParams.harqId = 0;
735 txOpParams.rnti = m_rnti;
736 txOpParams.lcid = (*it).first;
737 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
738 bytesForThisLc -= (*itBsr).second.statusPduSize;
739 NS_LOG_DEBUG(this << " serve STATUS " << (*itBsr).second.statusPduSize);
740 (*itBsr).second.statusPduSize = 0;
741 }
742 else
743 {
744 if ((*itBsr).second.statusPduSize > bytesForThisLc)
745 {
747 "Insufficient Tx Opportunity for sending a status message");
748 }
749 }
750
751 if ((bytesForThisLc > 7) // 7 is the min TxOpportunity useful for Rlc
752 && (((*itBsr).second.retxQueueSize > 0) ||
753 ((*itBsr).second.txQueueSize > 0)))
754 {
755 if ((*itBsr).second.retxQueueSize > 0)
756 {
757 NS_LOG_DEBUG(this << " serve retx DATA, bytes " << bytesForThisLc);
758 txOpParams.bytes = bytesForThisLc;
759 txOpParams.layer = 0;
760 txOpParams.harqId = 0;
762 txOpParams.rnti = m_rnti;
763 txOpParams.lcid = (*it).first;
764 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
765 if ((*itBsr).second.retxQueueSize >= bytesForThisLc)
766 {
767 (*itBsr).second.retxQueueSize -= bytesForThisLc;
768 }
769 else
770 {
771 (*itBsr).second.retxQueueSize = 0;
772 }
773 }
774 else if ((*itBsr).second.txQueueSize > 0)
775 {
776 uint16_t lcid = (*it).first;
777 uint32_t rlcOverhead;
778 if (lcid == 1)
779 {
780 // for SRB1 (using RLC AM) it's better to
781 // overestimate RLC overhead rather than
782 // underestimate it and risk unneeded
783 // segmentation which increases delay
784 rlcOverhead = 4;
785 }
786 else
787 {
788 // minimum RLC overhead due to header
789 rlcOverhead = 2;
790 }
791 NS_LOG_DEBUG(this << " serve tx DATA, bytes " << bytesForThisLc
792 << ", RLC overhead " << rlcOverhead);
793 txOpParams.bytes = bytesForThisLc;
794 txOpParams.layer = 0;
795 txOpParams.harqId = 0;
797 txOpParams.rnti = m_rnti;
798 txOpParams.lcid = (*it).first;
799 (*it).second.macSapUser->NotifyTxOpportunity(txOpParams);
800 if ((*itBsr).second.txQueueSize >= bytesForThisLc - rlcOverhead)
801 {
802 (*itBsr).second.txQueueSize -= bytesForThisLc - rlcOverhead;
803 }
804 else
805 {
806 (*itBsr).second.txQueueSize = 0;
807 }
808 }
809 }
810 else
811 {
812 if (((*itBsr).second.retxQueueSize > 0) ||
813 ((*itBsr).second.txQueueSize > 0))
814 {
815 // resend BSR info for updating eNB peer MAC
816 m_freshUlBsr = true;
817 }
818 }
819 NS_LOG_LOGIC(this << "\t" << bytesPerActiveLc << "\t new queues "
820 << (uint32_t)(*it).first << " statusQueue "
821 << (*itBsr).second.statusPduSize << " retxQueue"
822 << (*itBsr).second.retxQueueSize << " txQueue"
823 << (*itBsr).second.txQueueSize);
824 }
825 }
826 }
827 }
828 else
829 {
830 // HARQ retransmission -> retrieve data from HARQ buffer
831 NS_LOG_DEBUG(this << " UE MAC RETX HARQ " << (uint16_t)m_harqProcessId);
833 for (auto j = pb->Begin(); j != pb->End(); ++j)
834 {
835 Ptr<Packet> pkt = (*j)->Copy();
837 }
839 }
840 }
841 else if (msg->GetMessageType() == LteControlMessage::RAR)
842 {
844 {
846 uint16_t raRnti = rarMsg->GetRaRnti();
847 NS_LOG_LOGIC(this << "got RAR with RA-RNTI " << (uint32_t)raRnti << ", expecting "
848 << (uint32_t)m_raRnti);
849 if (raRnti == m_raRnti) // RAR corresponds to TX subframe of preamble
850 {
851 for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it)
852 {
853 if (it->rapId == m_raPreambleId) // RAR is for me
854 {
855 RecvRaResponse(it->rarPayload);
856 /// @todo RRC generates the RecvRaResponse messaged
857 /// for avoiding holes in transmission at PHY layer
858 /// (which produce erroneous UL CQI evaluation)
859 }
860 }
861 }
862 }
863 }
864 else
865 {
866 NS_LOG_WARN(this << " LteControlMessage not recognized");
867 }
868}
869
870void
872{
873 NS_LOG_FUNCTION(this);
874
875 for (std::size_t i = 0; i < m_miUlHarqProcessesPacketTimer.size(); i++)
876 {
877 if (m_miUlHarqProcessesPacketTimer.at(i) == 0)
878 {
879 if (m_miUlHarqProcessesPacket.at(i)->GetSize() > 0)
880 {
881 // timer expired: drop packets in buffer for this process
882 NS_LOG_INFO(this << " HARQ Proc Id " << i << " packets buffer expired");
884 m_miUlHarqProcessesPacket.at(i) = emptyPb;
885 }
886 }
887 else
888 {
890 }
891 }
892}
893
894void
896{
897 NS_LOG_FUNCTION(this);
898 m_frameNo = frameNo;
899 m_subframeNo = subframeNo;
902 {
903 if (m_componentCarrierId == 0)
904 {
905 // Send BSR through primary carrier
907 }
909 m_freshUlBsr = false;
910 }
912}
913
914int64_t
916{
917 NS_LOG_FUNCTION(this << stream);
918 m_raPreambleUniformVariable->SetStream(stream);
919 return 1;
920}
921
922} // 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:561
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:49
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:1357
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