A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-rlc-tm.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
10#include "lte-rlc-tm.h"
11
12#include "ns3/log.h"
13#include "ns3/simulator.h"
14
15namespace ns3
16{
17
18NS_LOG_COMPONENT_DEFINE("LteRlcTm");
19
21
23 : m_maxTxBufferSize(0),
24 m_txBufferSize(0)
25{
26 NS_LOG_FUNCTION(this);
27}
28
33
36{
37 static TypeId tid = TypeId("ns3::LteRlcTm")
39 .SetGroupName("Lte")
40 .AddConstructor<LteRlcTm>()
41 .AddAttribute("MaxTxBufferSize",
42 "Maximum Size of the Transmission Buffer (in Bytes)",
43 UintegerValue(2 * 1024 * 1024),
46 return tid;
47}
48
49void
58
59/**
60 * RLC SAP
61 */
62
63void
65{
66 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << p->GetSize());
67
68 if (m_txBufferSize + p->GetSize() <= m_maxTxBufferSize)
69 {
70 NS_LOG_LOGIC("Tx Buffer: New packet added");
71 m_txBuffer.emplace_back(p, Simulator::Now());
72 m_txBufferSize += p->GetSize();
73 NS_LOG_LOGIC("NumOfBuffers = " << m_txBuffer.size());
74 NS_LOG_LOGIC("txBufferSize = " << m_txBufferSize);
75 }
76 else
77 {
78 // Discard full RLC SDU
79 NS_LOG_LOGIC("TxBuffer is full. RLC SDU discarded");
80 NS_LOG_LOGIC("MaxTxBufferSize = " << m_maxTxBufferSize);
81 NS_LOG_LOGIC("txBufferSize = " << m_txBufferSize);
82 NS_LOG_LOGIC("packet size = " << p->GetSize());
83 }
84
85 /** Report Buffer Status */
88}
89
90/**
91 * MAC SAP
92 */
93
94void
96{
97 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << txOpParams.bytes
98 << (uint32_t)txOpParams.layer << (uint32_t)txOpParams.harqId);
99
100 // 5.1.1.1 Transmit operations
101 // 5.1.1.1.1 General
102 // When submitting a new TMD PDU to lower layer, the transmitting TM RLC entity shall:
103 // - submit a RLC SDU without any modification to lower layer.
104
105 if (m_txBuffer.empty())
106 {
107 NS_LOG_LOGIC("No data pending");
108 return;
109 }
110
111 Ptr<Packet> packet = m_txBuffer.begin()->m_pdu->Copy();
112
113 if (txOpParams.bytes < packet->GetSize())
114 {
115 NS_LOG_WARN("TX opportunity too small = " << txOpParams.bytes
116 << " (PDU size: " << packet->GetSize() << ")");
117 return;
118 }
119
120 m_txBufferSize -= packet->GetSize();
121 m_txBuffer.erase(m_txBuffer.begin());
122
123 m_txPdu(m_rnti, m_lcid, packet->GetSize());
124
125 // Send RLC PDU to MAC layer
127 params.pdu = packet;
128 params.rnti = m_rnti;
129 params.lcid = m_lcid;
130 params.layer = txOpParams.layer;
131 params.harqProcessId = txOpParams.harqId;
132 params.componentCarrierId = txOpParams.componentCarrierId;
133
135
136 if (!m_txBuffer.empty())
137 {
140 }
141}
142
143void
148
149void
151{
152 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << rxPduParams.p->GetSize());
153
154 m_rxPdu(m_rnti, m_lcid, rxPduParams.p->GetSize(), 0);
155
156 // 5.1.1.2 Receive operations
157 // 5.1.1.2.1 General
158 // When receiving a new TMD PDU from lower layer, the receiving TM RLC entity shall:
159 // - deliver the TMD PDU without any modification to upper layer.
160
161 m_rlcSapUser->ReceivePdcpPdu(rxPduParams.p);
162}
163
164void
166{
167 Time holDelay(0);
169
170 if (!m_txBuffer.empty())
171 {
172 holDelay = Simulator::Now() - m_txBuffer.front().m_waitingSince;
173
174 queueSize = m_txBufferSize; // just data in tx queue (no header overhead for RLC TM)
175 }
176
178 r.rnti = m_rnti;
179 r.lcid = m_lcid;
181 r.txQueueHolDelay = holDelay.GetMilliSeconds();
182 r.retxQueueSize = 0;
183 r.retxQueueHolDelay = 0;
184 r.statusPduSize = 0;
185
186 NS_LOG_LOGIC("Send ReportBufferStatus = " << r.txQueueSize << ", " << r.txQueueHolDelay);
188}
189
190void
192{
193 NS_LOG_LOGIC("RBS Timer expires");
194
195 if (!m_txBuffer.empty())
196 {
199 }
200}
201
202} // namespace ns3
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition event-id.cc:44
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE,...
Definition lte-rlc.h:38
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition lte-rlc.h:137
uint8_t m_lcid
LCID.
Definition lte-rlc.h:162
uint16_t m_rnti
RNTI.
Definition lte-rlc.h:161
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the MAC SAP user.
Definition lte-rlc.h:173
void DoDispose() override
Destructor implementation.
Definition lte-rlc.cc:115
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition lte-rlc.h:159
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
Used to inform of a PDU delivery to the MAC SAP provider.
Definition lte-rlc.h:169
virtual void ReceivePdcpPdu(Ptr< Packet > p)=0
Called by the RLC entity to notify the PDCP entity of the reception of a new PDCP PDU.
LTE RLC Transparent Mode (TM), see 3GPP TS 36.322.
Definition lte-rlc-tm.h:30
void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override
Receive PDU function.
void DoReportBufferStatus()
Report buffer status.
void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams) override
MAC SAP.
Definition lte-rlc-tm.cc:95
static TypeId GetTypeId()
Get the type ID.
Definition lte-rlc-tm.cc:35
~LteRlcTm() override
Definition lte-rlc-tm.cc:29
std::vector< TxPdu > m_txBuffer
Transmission buffer.
Definition lte-rlc-tm.h:89
void ExpireRbsTimer()
Expire RBS timer function.
uint32_t m_txBufferSize
transmit buffer size
Definition lte-rlc-tm.h:92
EventId m_rbsTimer
RBS timer.
Definition lte-rlc-tm.h:94
void DoNotifyHarqDeliveryFailure() override
Notify HARQ deliver failure.
void DoTransmitPdcpPdu(Ptr< Packet > p) override
RLC SAP.
Definition lte-rlc-tm.cc:64
uint32_t m_maxTxBufferSize
maximum transmit buffer size
Definition lte-rlc-tm.h:91
void DoDispose() override
Destructor implementation.
Definition lte-rlc-tm.cc:50
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition packet.h:850
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:560
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
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:397
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition lte-mac-sap.h:58
uint32_t txQueueSize
the current size of the RLC transmission queue
Definition lte-mac-sap.h:61
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
Definition lte-mac-sap.h:64
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
Definition lte-mac-sap.h:62
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
Definition lte-mac-sap.h:63
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition lte-mac-sap.h:60
uint16_t rnti
the C-RNTI identifying the UE
Definition lte-mac-sap.h:59
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
Definition lte-mac-sap.h:66
Parameters for LteMacSapProvider::TransmitPdu.
Definition lte-mac-sap.h:34
Parameters for LteMacSapUser::ReceivePdu.
Ptr< Packet > p
the RLC PDU to be received
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition lte-mac-sap.h:94
uint32_t bytes
the number of bytes to transmit
uint8_t componentCarrierId
the component carrier id
uint8_t layer
the layer of transmission (MIMO)
std::ofstream queueSize