11#include "ns3/simulator.h"
16NS_LOG_COMPONENT_DEFINE(
"NrRlcTm");
18NS_OBJECT_ENSURE_REGISTERED(NrRlcTm);
21 : m_maxTxBufferSize(0),
24 NS_LOG_FUNCTION(
this);
29 NS_LOG_FUNCTION(
this);
35 static TypeId tid = TypeId(
"ns3::NrRlcTm")
39 .AddAttribute(
"MaxTxBufferSize",
40 "Maximum Size of the Transmission Buffer (in Bytes)",
41 UintegerValue(2 * 1024 * 1024),
42 MakeUintegerAccessor(&NrRlcTm::m_maxTxBufferSize),
43 MakeUintegerChecker<uint32_t>());
50 NS_LOG_FUNCTION(
this);
62NrRlcTm::DoTransmitPdcpPdu(Ptr<Packet> p)
64 NS_LOG_FUNCTION(
this << m_rnti << (uint32_t)m_lcid << p->GetSize());
66 if (m_txBufferSize + p->GetSize() <= m_maxTxBufferSize)
68 NS_LOG_LOGIC(
"Tx Buffer: New packet added");
69 m_txBuffer.emplace_back(p, Simulator::Now());
70 m_txBufferSize += p->GetSize();
71 NS_LOG_LOGIC(
"NumOfBuffers = " << m_txBuffer.size());
72 NS_LOG_LOGIC(
"txBufferSize = " << m_txBufferSize);
77 NS_LOG_LOGIC(
"TxBuffer is full. RLC SDU discarded");
78 NS_LOG_LOGIC(
"MaxTxBufferSize = " << m_maxTxBufferSize);
79 NS_LOG_LOGIC(
"txBufferSize = " << m_txBufferSize);
80 NS_LOG_LOGIC(
"packet size = " << p->GetSize());
84 DoTransmitBufferStatusReport();
95 NS_LOG_FUNCTION(
this << m_rnti << (uint32_t)m_lcid << txOpParams.
bytes
96 << (uint32_t)txOpParams.
layer << (uint32_t)txOpParams.
harqId);
103 if (m_txBuffer.empty())
105 NS_LOG_LOGIC(
"No data pending");
109 Ptr<Packet> packet = m_txBuffer.begin()->m_pdu->Copy();
111 if (txOpParams.
bytes < packet->GetSize())
113 NS_LOG_WARN(
"TX opportunity too small = " << txOpParams.
bytes
114 <<
" (PDU size: " << packet->GetSize() <<
")");
118 m_txBufferSize -= packet->GetSize();
119 m_txBuffer.erase(m_txBuffer.begin());
121 m_txPdu(m_rnti, m_lcid, packet->GetSize());
126 params.
rnti = m_rnti;
127 params.
lcid = m_lcid;
132 m_macSapProvider->TransmitPdu(params);
134 if (!m_txBuffer.empty())
137 m_bsrTimer = Simulator::Schedule(MilliSeconds(10), &NrRlcTm::ExpireBsrTimer,
this);
142NrRlcTm::DoNotifyHarqDeliveryFailure()
144 NS_LOG_FUNCTION(
this);
150 NS_LOG_FUNCTION(
this << m_rnti << (uint32_t)m_lcid << rxPduParams.
p->GetSize());
152 m_rxPdu(m_rnti, m_lcid, rxPduParams.
p->GetSize(), 0);
159 m_rlcSapUser->ReceivePdcpPdu(rxPduParams.
p);
163NrRlcTm::DoTransmitBufferStatusReport()
166 uint32_t queueSize = 0;
168 if (!m_txBuffer.empty())
170 holDelay = Simulator::Now() - m_txBuffer.front().m_waitingSince;
172 queueSize = m_txBufferSize;
175 NrMacSapProvider::BufferStatusReportParameters r;
178 r.txQueueSize = queueSize;
179 r.txQueueHolDelay = holDelay.GetMilliSeconds();
181 r.retxQueueHolDelay = 0;
184 NS_LOG_LOGIC(
"Send BufferStatusReport = " << r.txQueueSize <<
", " << r.txQueueHolDelay);
185 m_macSapProvider->BufferStatusReport(r);
189NrRlcTm::ExpireBsrTimer()
191 NS_LOG_LOGIC(
"BSR Timer expires");
193 if (!m_txBuffer.empty())
195 DoTransmitBufferStatusReport();
196 m_bsrTimer = Simulator::Schedule(MilliSeconds(10), &NrRlcTm::ExpireBsrTimer,
this);
uint8_t componentCarrierId
uint8_t componentCarrierId