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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Manuel Requena <manuel.requena@cttc.es>
18 * Nicola Baldo <nbaldo@cttc.es>
19 */
20
21#include "lte-rlc-tm.h"
22
23#include "ns3/log.h"
24#include "ns3/simulator.h"
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("LteRlcTm");
30
32
34 : m_maxTxBufferSize(0),
35 m_txBufferSize(0)
36{
37 NS_LOG_FUNCTION(this);
38}
39
41{
42 NS_LOG_FUNCTION(this);
43}
44
47{
48 static TypeId tid = TypeId("ns3::LteRlcTm")
50 .SetGroupName("Lte")
51 .AddConstructor<LteRlcTm>()
52 .AddAttribute("MaxTxBufferSize",
53 "Maximum Size of the Transmission Buffer (in Bytes)",
54 UintegerValue(2 * 1024 * 1024),
56 MakeUintegerChecker<uint32_t>());
57 return tid;
58}
59
60void
62{
63 NS_LOG_FUNCTION(this);
65 m_txBuffer.clear();
66
68}
69
70/**
71 * RLC SAP
72 */
73
74void
76{
77 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << p->GetSize());
78
79 if (m_txBufferSize + p->GetSize() <= m_maxTxBufferSize)
80 {
81 NS_LOG_LOGIC("Tx Buffer: New packet added");
82 m_txBuffer.emplace_back(p, Simulator::Now());
83 m_txBufferSize += p->GetSize();
84 NS_LOG_LOGIC("NumOfBuffers = " << m_txBuffer.size());
85 NS_LOG_LOGIC("txBufferSize = " << m_txBufferSize);
86 }
87 else
88 {
89 // Discard full RLC SDU
90 NS_LOG_LOGIC("TxBuffer is full. RLC SDU discarded");
91 NS_LOG_LOGIC("MaxTxBufferSize = " << m_maxTxBufferSize);
92 NS_LOG_LOGIC("txBufferSize = " << m_txBufferSize);
93 NS_LOG_LOGIC("packet size = " << p->GetSize());
94 }
95
96 /** Report Buffer Status */
99}
100
101/**
102 * MAC SAP
103 */
104
105void
107{
108 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << txOpParams.bytes
109 << (uint32_t)txOpParams.layer << (uint32_t)txOpParams.harqId);
110
111 // 5.1.1.1 Transmit operations
112 // 5.1.1.1.1 General
113 // When submitting a new TMD PDU to lower layer, the transmitting TM RLC entity shall:
114 // - submit a RLC SDU without any modification to lower layer.
115
116 if (m_txBuffer.empty())
117 {
118 NS_LOG_LOGIC("No data pending");
119 return;
120 }
121
122 Ptr<Packet> packet = m_txBuffer.begin()->m_pdu->Copy();
123
124 if (txOpParams.bytes < packet->GetSize())
125 {
126 NS_LOG_WARN("TX opportunity too small = " << txOpParams.bytes
127 << " (PDU size: " << packet->GetSize() << ")");
128 return;
129 }
130
131 m_txBufferSize -= packet->GetSize();
132 m_txBuffer.erase(m_txBuffer.begin());
133
134 m_txPdu(m_rnti, m_lcid, packet->GetSize());
135
136 // Send RLC PDU to MAC layer
138 params.pdu = packet;
139 params.rnti = m_rnti;
140 params.lcid = m_lcid;
141 params.layer = txOpParams.layer;
142 params.harqProcessId = txOpParams.harqId;
143 params.componentCarrierId = txOpParams.componentCarrierId;
144
146
147 if (!m_txBuffer.empty())
148 {
151 }
152}
153
154void
156{
157 NS_LOG_FUNCTION(this);
158}
159
160void
162{
163 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << rxPduParams.p->GetSize());
164
165 m_rxPdu(m_rnti, m_lcid, rxPduParams.p->GetSize(), 0);
166
167 // 5.1.1.2 Receive operations
168 // 5.1.1.2.1 General
169 // When receiving a new TMD PDU from lower layer, the receiving TM RLC entity shall:
170 // - deliver the TMD PDU without any modification to upper layer.
171
172 m_rlcSapUser->ReceivePdcpPdu(rxPduParams.p);
173}
174
175void
177{
178 Time holDelay(0);
180
181 if (!m_txBuffer.empty())
182 {
183 holDelay = Simulator::Now() - m_txBuffer.front().m_waitingSince;
184
185 queueSize = m_txBufferSize; // just data in tx queue (no header overhead for RLC TM)
186 }
187
189 r.rnti = m_rnti;
190 r.lcid = m_lcid;
192 r.txQueueHolDelay = holDelay.GetMilliSeconds();
193 r.retxQueueSize = 0;
194 r.retxQueueHolDelay = 0;
195 r.statusPduSize = 0;
196
197 NS_LOG_LOGIC("Send ReportBufferStatus = " << r.txQueueSize << ", " << r.txQueueHolDelay);
199}
200
201void
203{
204 NS_LOG_LOGIC("RBS Timer expires");
205
206 if (!m_txBuffer.empty())
207 {
210 }
211}
212
213} // namespace ns3
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
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:49
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition: lte-rlc.h:148
uint8_t m_lcid
LCID.
Definition: lte-rlc.h:173
uint16_t m_rnti
RNTI.
Definition: lte-rlc.h:172
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:184
void DoDispose() override
Destructor implementation.
Definition: lte-rlc.cc:126
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:170
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:180
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:41
void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override
Receive PDU function.
Definition: lte-rlc-tm.cc:161
void DoReportBufferStatus()
Report buffer status.
Definition: lte-rlc-tm.cc:176
void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams) override
MAC SAP.
Definition: lte-rlc-tm.cc:106
static TypeId GetTypeId()
Get the type ID.
Definition: lte-rlc-tm.cc:46
~LteRlcTm() override
Definition: lte-rlc-tm.cc:40
std::vector< TxPdu > m_txBuffer
Transmission buffer.
Definition: lte-rlc-tm.h:100
void ExpireRbsTimer()
Expire RBS timer function.
Definition: lte-rlc-tm.cc:202
uint32_t m_txBufferSize
transmit buffer size
Definition: lte-rlc-tm.h:103
EventId m_rbsTimer
RBS timer.
Definition: lte-rlc-tm.h:105
void DoNotifyHarqDeliveryFailure() override
Notify HARQ deliver failure.
Definition: lte-rlc-tm.cc:155
void DoTransmitPdcpPdu(Ptr< Packet > p) override
RLC SAP.
Definition: lte-rlc-tm.cc:75
uint32_t m_maxTxBufferSize
maximum transmit buffer size
Definition: lte-rlc-tm.h:102
void DoDispose() override
Destructor implementation.
Definition: lte-rlc-tm.cc:61
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:408
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Hold an unsigned integer type.
Definition: uinteger.h:45
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1331
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:69
uint32_t txQueueSize
the current size of the RLC transmission queue
Definition: lte-mac-sap.h:72
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
Definition: lte-mac-sap.h:75
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
Definition: lte-mac-sap.h:73
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
Definition: lte-mac-sap.h:74
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-mac-sap.h:71
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:70
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
Definition: lte-mac-sap.h:77
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45
Parameters for LteMacSapUser::ReceivePdu.
Definition: lte-mac-sap.h:166
Ptr< Packet > p
the RLC PDU to be received
Definition: lte-mac-sap.h:187
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition: lte-mac-sap.h:105
uint32_t bytes
the number of bytes to transmit
Definition: lte-mac-sap.h:137
uint8_t componentCarrierId
the component carrier id
Definition: lte-mac-sap.h:140
uint8_t layer
the layer of transmission (MIMO)
Definition: lte-mac-sap.h:138
std::ofstream queueSize