A Discrete-Event Network Simulator
API
lte-rlc.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 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: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
20 #include "lte-rlc.h"
21 
22 #include "lte-rlc-sap.h"
23 #include "lte-rlc-tag.h"
24 // #include "lte-mac-sap.h"
25 // #include "ff-mac-sched-sap.h"
26 
27 #include "ns3/log.h"
28 #include "ns3/simulator.h"
29 
30 namespace ns3
31 {
32 
33 NS_LOG_COMPONENT_DEFINE("LteRlc");
34 
37 {
38  public:
45 
46  // Interface implemented from LteMacSapUser
48  void NotifyHarqDeliveryFailure() override;
50 
51  private:
54 };
55 
57  : m_rlc(rlc)
58 {
59 }
60 
62 {
63 }
64 
65 void
67 {
69 }
70 
71 void
73 {
75 }
76 
77 void
79 {
81 }
82 
84 
86 
88  : m_rlcSapUser(nullptr),
89  m_macSapProvider(nullptr),
90  m_rnti(0),
91  m_lcid(0)
92 {
93  NS_LOG_FUNCTION(this);
96 }
97 
99 {
100  NS_LOG_FUNCTION(this);
101 }
102 
103 TypeId
105 {
106  static TypeId tid = TypeId("ns3::LteRlc")
107  .SetParent<Object>()
108  .SetGroupName("Lte")
109  .AddTraceSource("TxPDU",
110  "PDU transmission notified to the MAC.",
112  "ns3::LteRlc::NotifyTxTracedCallback")
113  .AddTraceSource("RxPDU",
114  "PDU received.",
116  "ns3::LteRlc::ReceiveTracedCallback")
117  .AddTraceSource("TxDrop",
118  "Trace source indicating a packet "
119  "has been dropped before transmission",
121  "ns3::Packet::TracedCallback");
122  return tid;
123 }
124 
125 void
127 {
128  NS_LOG_FUNCTION(this);
129  delete (m_rlcSapProvider);
130  delete (m_macSapUser);
131 }
132 
133 void
134 LteRlc::SetRnti(uint16_t rnti)
135 {
136  NS_LOG_FUNCTION(this << (uint32_t)rnti);
137  m_rnti = rnti;
138 }
139 
140 void
141 LteRlc::SetLcId(uint8_t lcId)
142 {
143  NS_LOG_FUNCTION(this << (uint32_t)lcId);
144  m_lcid = lcId;
145 }
146 
147 void
148 LteRlc::SetPacketDelayBudgetMs(uint16_t packetDelayBudget)
149 {
150  NS_LOG_FUNCTION(this << +packetDelayBudget);
151  m_packetDelayBudgetMs = packetDelayBudget;
152 }
153 
154 void
156 {
157  NS_LOG_FUNCTION(this << s);
158  m_rlcSapUser = s;
159 }
160 
163 {
164  NS_LOG_FUNCTION(this);
165  return m_rlcSapProvider;
166 }
167 
168 void
170 {
171  NS_LOG_FUNCTION(this << s);
172  m_macSapProvider = s;
173 }
174 
177 {
178  NS_LOG_FUNCTION(this);
179  return m_macSapUser;
180 }
181 
183 
185 
187 {
188  NS_LOG_FUNCTION(this);
189 }
190 
192 {
193  NS_LOG_FUNCTION(this);
194 }
195 
196 TypeId
198 {
199  static TypeId tid =
200  TypeId("ns3::LteRlcSm").SetParent<LteRlc>().SetGroupName("Lte").AddConstructor<LteRlcSm>();
201  return tid;
202 }
203 
204 void
206 {
207  NS_LOG_FUNCTION(this);
209 }
210 
211 void
213 {
214  NS_LOG_FUNCTION(this);
216 }
217 
218 void
220 {
221  NS_LOG_FUNCTION(this << p);
222 }
223 
224 void
226 {
227  NS_LOG_FUNCTION(this << rxPduParams.p);
228  // RLC Performance evaluation
229  RlcTag rlcTag;
230  Time delay;
231  bool ret = rxPduParams.p->FindFirstMatchingByteTag(rlcTag);
232  NS_ASSERT_MSG(ret, "RlcTag is missing");
233  delay = Simulator::Now() - rlcTag.GetSenderTimestamp();
234  NS_LOG_LOGIC(" RNTI=" << m_rnti << " LCID=" << (uint32_t)m_lcid << " size="
235  << rxPduParams.p->GetSize() << " delay=" << delay.As(Time::NS));
236  m_rxPdu(m_rnti, m_lcid, rxPduParams.p->GetSize(), delay.GetNanoSeconds());
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION(this << txOpParams.bytes);
244  RlcTag tag(Simulator::Now());
245 
246  params.pdu = Create<Packet>(txOpParams.bytes);
247  NS_ABORT_MSG_UNLESS(txOpParams.bytes > 0, "Bytes must be > 0");
252  params.pdu->AddByteTag(tag, 1, params.pdu->GetSize());
253 
254  params.rnti = m_rnti;
255  params.lcid = m_lcid;
256  params.layer = txOpParams.layer;
257  params.harqProcessId = txOpParams.harqId;
258  params.componentCarrierId = txOpParams.componentCarrierId;
259 
260  // RLC Performance evaluation
261  NS_LOG_LOGIC(" RNTI=" << m_rnti << " LCID=" << (uint32_t)m_lcid
262  << " size=" << txOpParams.bytes);
263  m_txPdu(m_rnti, m_lcid, txOpParams.bytes);
264 
267 }
268 
269 void
271 {
272  NS_LOG_FUNCTION(this);
273 }
274 
275 void
277 {
278  NS_LOG_FUNCTION(this);
280  p.rnti = m_rnti;
281  p.lcid = m_lcid;
282  p.txQueueSize = 80000;
283  p.txQueueHolDelay = 10;
284  p.retxQueueSize = 0;
285  p.retxQueueHolDelay = 0;
286  p.statusPduSize = 0;
288 }
289 
291 
292 // LteRlcTm::~LteRlcTm ()
293 // {
294 // }
295 
297 
298 // LteRlcUm::~LteRlcUm ()
299 // {
300 // }
301 
303 
304 // LteRlcAm::~LteRlcAm ()
305 // {
306 // }
307 
308 } // namespace ns3
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:36
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.
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:96
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
void SetPacketDelayBudgetMs(uint16_t packetDelayBudget)
Definition: lte-rlc.cc:148
friend class LteRlcSpecificLteMacSapUser
allow LteRlcSpecificLteMacSapUser class friend access
Definition: lte-rlc.h:51
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters params)=0
Notify transmit opportunity.
TracedCallback< Ptr< const Packet > > m_txDropTrace
The trace source fired when the RLC drops a packet before transmission.
Definition: lte-rlc.h:189
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
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition: lte-rlc.h:149
LteMacSapUser * m_macSapUser
MAC SAP user.
Definition: lte-rlc.h:169
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:170
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:155
uint16_t m_packetDelayBudgetMs
the packet delay budget in ms of the corresponding logical channel
Definition: lte-rlc.h:174
friend class LteRlcSpecificLteRlcSapProvider< LteRlc >
allow LteRlcSpecificLteRlcSapProvider<LteRlc> class friend access
Definition: lte-rlc.h:53
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
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:134
virtual void DoNotifyHarqDeliveryFailure()=0
Notify HARQ delivery failure.
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:169
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters params)=0
Receive PDU function.
~LteRlc() override
Definition: lte-rlc.cc:98
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:176
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:141
static TypeId GetTypeId()
Get the type ID.
Definition: lte-rlc.cc:104
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:162
Service Access Point (SAP) offered by the UM-RLC and AM-RLC entities to the PDCP entity See 3GPP 36....
Definition: lte-rlc-sap.h:36
Service Access Point (SAP) offered by the UM-RLC and AM-RLC entities to the PDCP entity See 3GPP 36....
Definition: lte-rlc-sap.h:67
LTE_RLC Saturation Mode (SM): simulation-specific mode used for experiments that do not need to consi...
Definition: lte-rlc.h:201
void DoDispose() override
Destructor implementation.
Definition: lte-rlc.cc:212
void DoInitialize() override
Initialize() implementation.
Definition: lte-rlc.cc:205
static TypeId GetTypeId()
Get the type ID.
Definition: lte-rlc.cc:197
~LteRlcSm() override
Definition: lte-rlc.cc:191
void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override
Receive PDU function.
Definition: lte-rlc.cc:225
void DoTransmitPdcpPdu(Ptr< Packet > p) override
Transmit PDCP PDU.
Definition: lte-rlc.cc:219
void DoNotifyHarqDeliveryFailure() override
Notify HARQ delivery failure.
Definition: lte-rlc.cc:270
void ReportBufferStatus()
Report buffer status.
Definition: lte-rlc.cc:276
void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams) override
Notify transmit opportunity.
Definition: lte-rlc.cc:240
LteRlcSpecificLteMacSapUser class.
Definition: lte-rlc.cc:37
void NotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters params) override
Called by the MAC to notify the RLC that the scheduler granted a transmission opportunity to this RLC...
Definition: lte-rlc.cc:66
void ReceivePdu(LteMacSapUser::ReceivePduParameters params) override
Called by the MAC to notify the RLC of the reception of a new PDU.
Definition: lte-rlc.cc:78
void NotifyHarqDeliveryFailure() override
Called by the MAC to notify the RLC that an HARQ process related to this RLC instance has failed.
Definition: lte-rlc.cc:72
A base class which provides memory management and object aggregation.
Definition: object.h:89
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:943
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.
Definition: lte-rlc-tag.h:36
Time GetSenderTimestamp() const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
Definition: lte-rlc-tag.h:64
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 GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:418
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
@ NS
nanosecond
Definition: nstime.h:119
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
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