25 #include <ns3/pointer.h>
26 #include <ns3/packet.h>
27 #include <ns3/packet-burst.h>
28 #include <ns3/random-variable.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>
62 virtual void RemoveLc (uint8_t lcId);
63 virtual void Reset ();
198 .AddConstructor<LteUeMac> ();
206 m_freshUlBsr (false),
209 m_rachConfigured (false),
210 m_waitingForRaResponse (false)
296 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
303 (*it).second = params;
307 m_ulBsrReceived.insert (std::pair<uint8_t, LteMacSapProvider::ReportBufferStatusParameters> (params.
lcid, params));
334 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
335 std::vector<uint32_t> queue (4, 0);
338 uint8_t lcid = it->first;
339 std::map <uint8_t, LcInfo>::iterator lcInfoMapIt;
342 uint8_t lcg = lcInfoMapIt->second.lcConfig.logicalChannelGroup;
343 queue.at (lcg) += ((*it).second.txQueueSize + (*it).second.retxQueueSize + (*it).second.statusPduSize);
367 bool contention =
true;
425 NS_LOG_INFO (
"RAR timeout, preambleTransMax reached => giving up");
466 NS_ASSERT_MSG (prachMask == 0,
"requested PRACH MASK = " << (uint32_t) prachMask <<
", but only PRACH MASK = 0 is supported");
469 bool contention =
false;
481 lcInfo.macSapUser = msu;
497 std::map <uint8_t, LcInfo>::iterator it =
m_lcInfoMap.begin ();
526 it->second.macSapUser->ReceivePdu (p);
545 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator itBsr;
546 uint16_t activeLcs = 0;
547 uint32_t statusPduMinSize = 0;
550 if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
553 if (((*itBsr).second.statusPduSize!=0)&&((*itBsr).second.statusPduSize < statusPduMinSize))
555 statusPduMinSize = (*itBsr).second.statusPduSize;
557 if (((*itBsr).second.statusPduSize!=0)&&(statusPduMinSize == 0))
559 statusPduMinSize = (*itBsr).second.statusPduSize;
565 NS_LOG_ERROR (
this <<
" No active flows for this UL-DCI");
568 std::map <uint8_t, LcInfo>::iterator it;
569 uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs;
570 bool statusPduPriority =
false;
571 if ((statusPduMinSize != 0)&&(bytesPerActiveLc < statusPduMinSize))
574 statusPduPriority =
true;
575 NS_LOG_DEBUG (
this <<
" Reduced resource -> send only Status, b ytes " << statusPduMinSize);
576 if (dci.m_tbSize < statusPduMinSize)
578 NS_FATAL_ERROR (
"Insufficient Tx Opportunity for sending a status message");
581 NS_LOG_LOGIC (
this <<
" UE " <<
m_rnti <<
": UL-CQI notified TxOpportunity of " << dci.m_tbSize <<
" => " << bytesPerActiveLc <<
" bytes per active LC" <<
" statusPduMinSize " << statusPduMinSize);
585 NS_LOG_DEBUG (
this <<
" Processing LC " << (uint32_t)(*it).first <<
" bytesPerActiveLc " << bytesPerActiveLc);
587 ( ((*itBsr).second.statusPduSize > 0) ||
588 ((*itBsr).second.retxQueueSize > 0) ||
589 ((*itBsr).second.txQueueSize > 0)) )
591 if ((statusPduPriority) && ((*itBsr).second.statusPduSize == statusPduMinSize))
593 (*it).second.macSapUser->NotifyTxOpportunity ((*itBsr).second.statusPduSize, 0, 0);
594 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);
595 (*itBsr).second.statusPduSize = 0;
600 uint32_t bytesForThisLc = bytesPerActiveLc;
601 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);
602 if (((*itBsr).second.statusPduSize > 0) && (bytesForThisLc > (*itBsr).second.statusPduSize))
604 (*it).second.macSapUser->NotifyTxOpportunity ((*itBsr).second.statusPduSize, 0, 0);
605 bytesForThisLc -= (*itBsr).second.statusPduSize;
606 NS_LOG_DEBUG (
this <<
" serve STATUS " << (*itBsr).second.statusPduSize);
607 (*itBsr).second.statusPduSize = 0;
611 if ((*itBsr).second.statusPduSize>bytesForThisLc)
613 NS_FATAL_ERROR (
"Insufficient Tx Opportunity for sending a status message");
617 if ((bytesForThisLc > 7) &&
618 (((*itBsr).second.retxQueueSize > 0) ||
619 ((*itBsr).second.txQueueSize > 0)))
621 if ((*itBsr).second.retxQueueSize > 0)
623 NS_LOG_DEBUG (
this <<
" serve retx DATA, bytes " << bytesForThisLc);
624 (*it).second.macSapUser->NotifyTxOpportunity (bytesForThisLc, 0, 0);
625 if ((*itBsr).second.retxQueueSize >= bytesForThisLc)
627 (*itBsr).second.retxQueueSize -= bytesForThisLc;
631 (*itBsr).second.retxQueueSize = 0;
634 else if ((*itBsr).second.txQueueSize > 0)
636 NS_LOG_DEBUG (
this <<
" serve tx DATA, bytes " << bytesForThisLc);
637 (*it).second.macSapUser->NotifyTxOpportunity (bytesForThisLc, 0, 0);
638 if ((*itBsr).second.txQueueSize >= bytesForThisLc - 2)
640 (*itBsr).second.txQueueSize -= bytesForThisLc - 2;
644 (*itBsr).second.txQueueSize = 0;
650 if ( ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
656 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);
681 uint16_t raRnti = rarMsg->GetRaRnti ();
682 NS_LOG_LOGIC (
this <<
"got RAR with RA-RNTI " << (uint32_t) raRnti <<
", expecting " << (uint32_t)
m_raRnti);
683 if (raRnti == m_raRnti)
685 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin ();
686 it != rarMsg->RarListEnd ();
702 NS_LOG_WARN (
this <<
" LteControlMessage not recognized");
718 NS_LOG_INFO (
this <<
" HARQ Proc Id " << i <<
" packets buffer expired");