|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
25 #include <ns3/pointer.h>
26 #include <ns3/packet.h>
27 #include <ns3/packet-burst.h>
28 #include <ns3/random-variable-stream.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>
66 virtual void SetRnti (uint16_t rnti);
68 virtual void RemoveLc (uint8_t lcId);
69 virtual void Reset ();
71 virtual void SetImsi (uint64_t imsi);
239 .AddTraceSource (
"RaResponseTimeout",
240 "trace fired upon RA response timeout",
242 "ns3::LteUeMac::RaResponseTimeoutTracedCallback")
252 m_freshUlBsr (false),
256 m_rachConfigured (false),
257 m_waitingForRaResponse (false)
349 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
356 (*it).second = params;
360 m_ulBsrReceived.insert (std::pair<uint8_t, LteMacSapProvider::ReportBufferStatusParameters> (params.
lcid, params));
387 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator it;
388 std::vector<uint32_t> queue (4, 0);
391 uint8_t lcid = it->first;
392 std::map <uint8_t, LcInfo>::iterator lcInfoMapIt;
395 NS_ASSERT_MSG ((lcid != 0) || (((*it).second.txQueueSize == 0)
396 && ((*it).second.retxQueueSize == 0)
397 && ((*it).second.statusPduSize == 0)),
398 "BSR should not be used for LCID 0");
399 uint8_t lcg = lcInfoMapIt->second.lcConfig.logicalChannelGroup;
400 queue.at (lcg) += ((*it).second.txQueueSize + (*it).second.retxQueueSize + (*it).second.statusPduSize);
424 bool contention =
true;
473 const uint8_t lc0Lcid = 0;
474 std::map <uint8_t, LcInfo>::iterator lc0InfoIt =
m_lcInfoMap.find (lc0Lcid);
476 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator lc0BsrIt
479 && (lc0BsrIt->second.txQueueSize > 0))
482 "segmentation of Message 3 is not allowed");
490 txOpParams.
layer = 0;
494 txOpParams.
lcid = lc0Lcid;
495 lc0InfoIt->second.macSapUser->NotifyTxOpportunity (txOpParams);
496 lc0BsrIt->second.txQueueSize = 0;
512 NS_LOG_INFO (
"RAR timeout, preambleTransMax reached => giving up");
567 NS_LOG_FUNCTION (
this << rnti << (uint16_t) preambleId << (uint16_t) prachMask);
568 NS_ASSERT_MSG (prachMask == 0,
"requested PRACH MASK = " << (uint32_t) prachMask <<
", but only PRACH MASK = 0 is supported");
572 bool contention =
false;
601 std::map <uint8_t, LcInfo>::iterator it =
m_lcInfoMap.begin ();
645 it->second.macSapUser->ReceivePdu (rxPduParams);
669 std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters>::iterator itBsr;
670 uint16_t activeLcs = 0;
671 uint32_t statusPduMinSize = 0;
674 if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
677 if (((*itBsr).second.statusPduSize != 0)&&((*itBsr).second.statusPduSize < statusPduMinSize))
679 statusPduMinSize = (*itBsr).second.statusPduSize;
681 if (((*itBsr).second.statusPduSize != 0)&&(statusPduMinSize == 0))
683 statusPduMinSize = (*itBsr).second.statusPduSize;
689 NS_LOG_ERROR (
this <<
" No active flows for this UL-DCI");
692 std::map <uint8_t, LcInfo>::iterator it;
693 uint32_t bytesPerActiveLc = dci.
m_tbSize / activeLcs;
694 bool statusPduPriority =
false;
695 if ((statusPduMinSize != 0)&&(bytesPerActiveLc < statusPduMinSize))
698 statusPduPriority =
true;
699 NS_LOG_DEBUG (
this <<
" Reduced resource -> send only Status, b ytes " << statusPduMinSize);
700 if (dci.
m_tbSize < statusPduMinSize)
702 NS_FATAL_ERROR (
"Insufficient Tx Opportunity for sending a status message");
705 NS_LOG_LOGIC (
this <<
" UE " <<
m_rnti <<
": UL-CQI notified TxOpportunity of " << dci.
m_tbSize <<
" => " << bytesPerActiveLc <<
" bytes per active LC" <<
" statusPduMinSize " << statusPduMinSize);
712 NS_LOG_DEBUG (
this <<
" Processing LC " << (uint32_t)(*it).first <<
" bytesPerActiveLc " << bytesPerActiveLc);
714 && ( ((*itBsr).second.statusPduSize > 0)
715 || ((*itBsr).second.retxQueueSize > 0)
716 || ((*itBsr).second.txQueueSize > 0)) )
718 if ((statusPduPriority) && ((*itBsr).second.statusPduSize == statusPduMinSize))
720 txOpParams.
bytes = (*itBsr).second.statusPduSize;
721 txOpParams.
layer = 0;
725 txOpParams.
lcid = (*it).first;
726 (*it).second.macSapUser->NotifyTxOpportunity (txOpParams);
727 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);
728 (*itBsr).second.statusPduSize = 0;
733 uint32_t bytesForThisLc = bytesPerActiveLc;
734 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);
735 if (((*itBsr).second.statusPduSize > 0) && (bytesForThisLc > (*itBsr).second.statusPduSize))
737 txOpParams.
bytes = (*itBsr).second.statusPduSize;
738 txOpParams.
layer = 0;
742 txOpParams.
lcid = (*it).first;
743 (*it).second.macSapUser->NotifyTxOpportunity (txOpParams);
744 bytesForThisLc -= (*itBsr).second.statusPduSize;
745 NS_LOG_DEBUG (
this <<
" serve STATUS " << (*itBsr).second.statusPduSize);
746 (*itBsr).second.statusPduSize = 0;
750 if ((*itBsr).second.statusPduSize > bytesForThisLc)
752 NS_FATAL_ERROR (
"Insufficient Tx Opportunity for sending a status message");
756 if ((bytesForThisLc > 7)
757 && (((*itBsr).second.retxQueueSize > 0)
758 || ((*itBsr).second.txQueueSize > 0)))
760 if ((*itBsr).second.retxQueueSize > 0)
762 NS_LOG_DEBUG (
this <<
" serve retx DATA, bytes " << bytesForThisLc);
763 txOpParams.
bytes = bytesForThisLc;
764 txOpParams.
layer = 0;
768 txOpParams.
lcid = (*it).first;
769 (*it).second.macSapUser->NotifyTxOpportunity (txOpParams);
770 if ((*itBsr).second.retxQueueSize >= bytesForThisLc)
772 (*itBsr).second.retxQueueSize -= bytesForThisLc;
776 (*itBsr).second.retxQueueSize = 0;
779 else if ((*itBsr).second.txQueueSize > 0)
781 uint16_t lcid = (*it).first;
782 uint32_t rlcOverhead;
796 NS_LOG_DEBUG (
this <<
" serve tx DATA, bytes " << bytesForThisLc <<
", RLC overhead " << rlcOverhead);
797 txOpParams.
bytes = bytesForThisLc;
798 txOpParams.
layer = 0;
802 txOpParams.
lcid = (*it).first;
803 (*it).second.macSapUser->NotifyTxOpportunity (txOpParams);
804 if ((*itBsr).second.txQueueSize >= bytesForThisLc - rlcOverhead)
806 (*itBsr).second.txQueueSize -= bytesForThisLc - rlcOverhead;
810 (*itBsr).second.txQueueSize = 0;
816 if ( ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0))
822 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);
847 uint16_t raRnti = rarMsg->GetRaRnti ();
848 NS_LOG_LOGIC (
this <<
"got RAR with RA-RNTI " << (uint32_t) raRnti <<
", expecting " << (uint32_t)
m_raRnti);
851 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin ();
852 it != rarMsg->RarListEnd ();
868 NS_LOG_WARN (
this <<
" LteControlMessage not recognized");
884 NS_LOG_INFO (
this <<
" HARQ Proc Id " << i <<
" packets buffer expired");
Parameters for LteMacSapProvider::TransmitPdu.
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Forwarded from LteUePhySapUser: trigger the start from a new frame.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
LteUePhySapUser * m_uePhySapUser
UE Phy SAP user.
Time m_bsrPeriodicity
BSR periodicity.
virtual void DoDispose(void)
Destructor implementation.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
virtual void SetRnti(uint16_t rnti)
void StartWaitingForRaResponse()
Start waiting for RA response function.
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
void RecvRaResponse(BuildRarListElement_s raResponse)
Receive the RA response function.
Ptr< Packet > p
the RLC PDU to be received
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
logical channel config
Tag used to define the RNTI and LC id for each MAC packet trasmitted.
struct MacCeValue_u m_macCeValue
MAC CE value.
virtual void SendRachPreamble(uint32_t prachId, uint32_t raRnti)=0
Send a preamble on the PRACH.
void RandomlySelectAndSendRaPreamble()
Randomly select and send RA preamble function.
void DoSetImsi(uint64_t imsi)
Set IMSI.
virtual void NotifyConnectionSuccessful()
Notify MAC about the successful RRC connection establishment.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
UeMemberLteMacSapProvider(LteUeMac *mac)
Constructor.
Parameters for LteMacSapUser::NotifyTxOpportunity.
UeMemberLteUeCmacSapProvider(LteUeMac *mac)
Constructor.
uint8_t raResponseWindowSize
RA response window size.
void DoReset()
Reset function.
bool m_waitingForRaResponse
waiting for RA response
void SetLteUePhySapProvider(LteUePhySapProvider *s)
Set the PHY SAP Provider.
void DoNotifyConnectionSuccessful()
Notify MAC about the successful RRC connection establishment.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetComponentCarrierId(uint8_t index)
Set the component carried ID.
LteUePhySapUser * GetLteUePhySapUser()
Get the PHY SAP user.
void DoStartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t rapId, uint8_t prachMask)
Start non contention based random access procedure function.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
See section 4.3.10 buildRARListElement.
uint16_t GetRnti(void) const
Get RNTI function.
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)=0
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
std::vector< uint8_t > m_miUlHarqProcessesPacketTimer
timer for packet life in the buffer
LteUeCmacSapProvider * m_cmacSapProvider
CMAC SAP provider.
virtual void StartContentionBasedRandomAccessProcedure()
tell the MAC to start a contention-based random access procedure, e.g., to perform RRC connection est...
uint16_t rnti
the C-RNTI identifying the UE
virtual void NotifyConnectionSuccessful()=0
Notify PHY about the successful RRC connection establishment.
uint8_t lcid
the logical channel id
static TypeId GetTypeId(void)
Get the type ID.
uint8_t preambleTransMax
preamble transmit maximum
virtual void SetImsi(uint64_t imsi)
A method call by UE RRC to communicate the IMSI to the UE MAC.
TracedCallback< uint64_t, bool, uint8_t, uint8_t > m_raResponseTimeoutTrace
The RaResponseTimeout trace source.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< Packet > pdu
the RLC PDU
virtual void TransmitPdu(TransmitPduParameters params)
send an RLC PDU to the MAC for transmission.
virtual void ConfigureRach(RachConfig rc)
Configure RACH function.
virtual void NotifyRandomAccessSuccessful()=0
Notify the RRC that the MAC Random Access procedure completed successfully.
UeMemberLteUeCmacSapProvider class.
void DoAddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Add LC function.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
friend class UeMemberLteMacSapProvider
allow UeMemberLteMacSapProvider class friend access
virtual void NotifyRandomAccessFailed()=0
Notify the RRC that the MAC Random Access procedure failed.
LteUeCmacSapProvider::RachConfig m_rachConfig
RACH configuration.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
static uint8_t BufferSize2BsrId(uint32_t val)
Convert Buffer size to BSR ID.
std::map< uint8_t, LteMacSapProvider::ReportBufferStatusParameters > m_ulBsrReceived
BSR received from RLC (the last one)
uint8_t lcid
the logical channel id
friend class UeMemberLteUeCmacSapProvider
allow UeMemberLteUeCmacSapProvider class friend access
std::vector< uint8_t > m_bufferStatus
buffer status
LteMacSapUser * macSapUser
MAC SAP user.
void SendRaPreamble(bool contention)
Send RA preamble function.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
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...
virtual void SendMacPdu(Ptr< Packet > p)=0
Send the MAC PDU to the channel.
LteUeMac * m_mac
the UE MAC
uint8_t m_raPreambleId
RA preamble ID.
uint8_t GetLcid(void) const
Get LCID function.
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Transmit PDU function.
Parameters for LteMacSapProvider::ReportBufferStatus.
See section 4.3.2 ulDciListElement.
UeMemberLteUePhySapUser(LteUeMac *mac)
Constructor.
A base class which provides memory management and object aggregation.
virtual void RemoveLc(uint8_t lcId)
remove an existing LC
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool m_rachConfigured
is RACH configured?
EventId m_noRaResponseReceivedEvent
no RA response received event ID
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void DoReceivePhyPdu(Ptr< Packet > p)
Receive Phy PDU function.
uint8_t numberOfRaPreambles
number of RA preambles
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
See section 4.3.14 macCEListElement.
LteUeCmacSapUser * m_cmacSapUser
CMAC SAP user.
void SendReportBufferStatus(void)
Send report buffer status.
void DoSetRnti(uint16_t rnti)
Set RNTI.
Parameters for LteMacSapUser::ReceivePdu.
std::map< uint8_t, LcInfo > m_lcInfoMap
logical channel info map
LteUePhySapProvider * m_uePhySapProvider
UE Phy SAP provider.
Simulation virtual time values and global simulation resolution.
LteMacSapProvider * GetLteMacSapProvider(void)
Get the LTE MAC SAP provider.
uint8_t m_componentCarrierId
component carrier Id --> used to address sap
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void SetTemporaryCellRnti(uint16_t rnti)=0
friend class UeMemberLteUePhySapUser
allow UeMemberLteUePhySapUser class friend access
uint8_t harqId
the HARQ ID
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint32_t m_subframeNo
subframe number
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
virtual void AddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
add a new Logical Channel (LC)
void AddPacketTag(const Tag &tag) const
Add a packet tag.
bool m_freshUlBsr
true when a BSR has been received in the last TTI
uint8_t m_preambleTransmissionCounter
preamble tranamission counter
std::vector< Ptr< PacketBurst > > m_miUlHarqProcessesPacket
Packets under transmission of the UL HARQ processes.
UeMemberLteMacSapProvider class.
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
void DoRemoveLc(uint8_t lcId)
Remove LC function.
LogicalChannelConfig structure.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
uint16_t m_backoffParameter
backoff parameter
virtual void ReceivePhyPdu(Ptr< Packet > p)
Receive Phy Pdu funtion.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint8_t m_harqProcessId
HARQ process ID.
uint8_t componentCarrierId
the component carrier id
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
void DoStartContentionBasedRandomAccessProcedure()
Start contention based random access procedure function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint32_t bytes
the number of bytes to transmit
uint16_t rnti
the C-RNTI identifying the UE
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
uint32_t m_frameNo
frame number
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Ptr< UniformRandomVariable > m_raPreambleUniformVariable
RA preamble random variable.
LteUeMac * m_mac
the UE MAC
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
void SetLteUeCmacSapUser(LteUeCmacSapUser *s)
Set the LTE UE CMAC SAP user.
virtual void ReportBufferStatus(ReportBufferStatusParameters params)
Report the RLC buffer status to the MAC.
LteUeMac * m_mac
the UE MAC
uint8_t layer
the layer of transmission (MIMO)
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Service Access Point (SAP) offered by the PHY to the MAC.
void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Report buffers status function.
virtual void DoDispose(void)
Destructor implementation.
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
LteUeCmacSapProvider * GetLteUeCmacSapProvider(void)
Get the LTE CMAC SAP provider.
void RaResponseTimeout(bool contention)
RA response timeout function.
void DoConfigureRach(LteUeCmacSapProvider::RachConfig rc)
Configure RACH function.
void DoReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive LTE control message function.
uint16_t rnti
the C-RNTI identifying the UE
virtual void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Trigger the start from a new frame (input from Phy layer)
void RefreshHarqProcessesPacketBuffer(void)
Refresh HARQ processes packet buffer function.
virtual void Reset()
reset the MAC