10#include "nr-rlc-tag.h"
15#include "ns3/simulator.h"
20NS_LOG_COMPONENT_DEFINE(
"NrRlc");
23class NrRlcSpecificNrMacSapUser :
public NrMacSapUser
31 NrRlcSpecificNrMacSapUser(NrRlc* rlc);
34 void NotifyTxOpportunity(NrMacSapUser::TxOpportunityParameters params)
override;
35 void NotifyHarqDeliveryFailure()
override;
36 void ReceivePdu(NrMacSapUser::ReceivePduParameters params)
override;
39 NrRlcSpecificNrMacSapUser();
43NrRlcSpecificNrMacSapUser::NrRlcSpecificNrMacSapUser(NrRlc* rlc)
48NrRlcSpecificNrMacSapUser::NrRlcSpecificNrMacSapUser()
53NrRlcSpecificNrMacSapUser::NotifyTxOpportunity(TxOpportunityParameters params)
55 m_rlc->DoNotifyTxOpportunity(params);
59NrRlcSpecificNrMacSapUser::NotifyHarqDeliveryFailure()
61 m_rlc->DoNotifyHarqDeliveryFailure();
65NrRlcSpecificNrMacSapUser::ReceivePdu(NrMacSapUser::ReceivePduParameters params)
67 m_rlc->DoReceivePdu(params);
72NS_OBJECT_ENSURE_REGISTERED(NrRlc);
75 : m_rlcSapUser(nullptr),
76 m_macSapProvider(nullptr),
80 NS_LOG_FUNCTION(
this);
81 m_rlcSapProvider =
new NrRlcSpecificNrRlcSapProvider<NrRlc>(
this);
82 m_macSapUser =
new NrRlcSpecificNrMacSapUser(
this);
87 NS_LOG_FUNCTION(
this);
93 static TypeId tid = TypeId(
"ns3::NrRlc")
96 .AddTraceSource(
"TxPDU",
97 "PDU transmission notified to the MAC.",
98 MakeTraceSourceAccessor(&NrRlc::m_txPdu),
99 "ns3::NrRlc::NotifyTxTracedCallback")
100 .AddTraceSource(
"RxPDU",
102 MakeTraceSourceAccessor(&NrRlc::m_rxPdu),
103 "ns3::NrRlc::ReceiveTracedCallback")
104 .AddTraceSource(
"TxDrop",
105 "Trace source indicating a packet "
106 "has been dropped before transmission",
107 MakeTraceSourceAccessor(&NrRlc::m_txDropTrace),
108 "ns3::Packet::TracedCallback");
115 NS_LOG_FUNCTION(
this);
116 delete (m_rlcSapProvider);
117 delete (m_macSapUser);
121NrRlc::SetRnti(uint16_t rnti)
123 NS_LOG_FUNCTION(
this << (uint32_t)rnti);
128NrRlc::SetLcId(uint8_t lcId)
130 NS_LOG_FUNCTION(
this << (uint32_t)lcId);
135NrRlc::SetPacketDelayBudgetMs(uint16_t packetDelayBudget)
137 NS_LOG_FUNCTION(
this << +packetDelayBudget);
138 m_packetDelayBudgetMs = packetDelayBudget;
144 NS_LOG_FUNCTION(
this << s);
149NrRlc::GetNrRlcSapProvider()
151 NS_LOG_FUNCTION(
this);
152 return m_rlcSapProvider;
158 NS_LOG_FUNCTION(
this << s);
159 m_macSapProvider = s;
163NrRlc::GetNrMacSapUser()
165 NS_LOG_FUNCTION(
this);
171NS_OBJECT_ENSURE_REGISTERED(
NrRlcSm);
175 NS_LOG_FUNCTION(
this);
180 NS_LOG_FUNCTION(
this);
187 TypeId(
"ns3::NrRlcSm").SetParent<
NrRlc>().SetGroupName(
"Nr").AddConstructor<
NrRlcSm>();
192NrRlcSm::DoInitialize()
194 NS_LOG_FUNCTION(
this);
195 BufferStatusReport();
201 NS_LOG_FUNCTION(
this);
206NrRlcSm::DoTransmitPdcpPdu(Ptr<Packet> p)
208 NS_LOG_FUNCTION(
this << p);
214 NS_LOG_FUNCTION(
this << rxPduParams.
p);
218 bool ret = rxPduParams.
p->FindFirstMatchingByteTag(rlcTag);
219 NS_ASSERT_MSG(ret,
"NrRlcTag is missing");
221 NS_LOG_LOGIC(
" RNTI=" << m_rnti <<
" LCID=" << (uint32_t)m_lcid <<
" size="
222 << rxPduParams.
p->GetSize() <<
" delay=" << delay.As(Time::NS));
223 m_rxPdu(m_rnti, m_lcid, rxPduParams.
p->GetSize(), delay.GetNanoSeconds());
229 NS_LOG_FUNCTION(
this << txOpParams.
bytes);
233 params.
pdu = Create<Packet>(txOpParams.
bytes);
234 NS_ABORT_MSG_UNLESS(txOpParams.
bytes > 0,
"Bytes must be > 0");
239 params.
pdu->AddByteTag(tag, 1, params.
pdu->GetSize());
241 params.
rnti = m_rnti;
242 params.
lcid = m_lcid;
248 NS_LOG_LOGIC(
" RNTI=" << m_rnti <<
" LCID=" << (uint32_t)m_lcid
249 <<
" size=" << txOpParams.
bytes);
250 m_txPdu(m_rnti, m_lcid, txOpParams.
bytes);
252 m_macSapProvider->TransmitPdu(params);
253 BufferStatusReport();
257NrRlcSm::DoNotifyHarqDeliveryFailure()
259 NS_LOG_FUNCTION(
this);
263NrRlcSm::BufferStatusReport()
265 NS_LOG_FUNCTION(
this);
274 p.expBsrTimer =
false;
275 m_macSapProvider->BufferStatusReport(p);
Time GetSenderTimestamp() const
uint16_t retxQueueHolDelay
uint8_t componentCarrierId
uint8_t componentCarrierId