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