A Discrete-Event Network Simulator
API
lte-rlc.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 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: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 
22 #include "ns3/log.h"
23 #include "ns3/simulator.h"
24 
25 #include "ns3/lte-rlc.h"
26 #include "ns3/lte-rlc-tag.h"
27 // #include "lte-mac-sap.h"
28 #include "ns3/lte-rlc-sap.h"
29 // #include "ff-mac-sched-sap.h"
30 
31 namespace ns3 {
32 
33 NS_LOG_COMPONENT_DEFINE ("LteRlc");
34 
37 {
38 public:
45 
46  // Interface implemented from LteMacSapUser
48  virtual void NotifyHarqDeliveryFailure ();
49  virtual void ReceivePdu (LteMacSapUser::ReceivePduParameters params);
50 
51 private:
54 };
55 
57  : m_rlc (rlc)
58 {}
59 
61 {}
62 
63 void
65 {
66  m_rlc->DoNotifyTxOpportunity (params);
67 }
68 
69 void
71 {
73 }
74 
75 void
77 {
78  m_rlc->DoReceivePdu (params);
79 }
80 
81 
83 
85 
87  : m_rlcSapUser (0),
88  m_macSapProvider (0),
89  m_rnti (0),
90  m_lcid (0)
91 {
92  NS_LOG_FUNCTION (this);
95 }
96 
98 {
99  NS_LOG_FUNCTION (this);
100 }
101 
103 {
104  static TypeId tid = TypeId ("ns3::LteRlc")
105  .SetParent<Object> ()
106  .SetGroupName ("Lte")
107  .AddTraceSource ("TxPDU",
108  "PDU transmission notified to the MAC.",
110  "ns3::LteRlc::NotifyTxTracedCallback")
111  .AddTraceSource ("RxPDU",
112  "PDU received.",
114  "ns3::LteRlc::ReceiveTracedCallback")
115  ;
116  return tid;
117 }
118 
119 void
121 {
122  NS_LOG_FUNCTION (this);
123  delete (m_rlcSapProvider);
124  delete (m_macSapUser);
125 }
126 
127 void
128 LteRlc::SetRnti (uint16_t rnti)
129 {
130  NS_LOG_FUNCTION (this << (uint32_t) rnti);
131  m_rnti = rnti;
132 }
133 
134 void
135 LteRlc::SetLcId (uint8_t lcId)
136 {
137  NS_LOG_FUNCTION (this << (uint32_t) lcId);
138  m_lcid = lcId;
139 }
140 
141 void
143 {
144  NS_LOG_FUNCTION (this << s);
145  m_rlcSapUser = s;
146 }
147 
150 {
151  NS_LOG_FUNCTION (this);
152  return m_rlcSapProvider;
153 }
154 
155 void
157 {
158  NS_LOG_FUNCTION (this << s);
159  m_macSapProvider = s;
160 }
161 
164 {
165  NS_LOG_FUNCTION (this);
166  return m_macSapUser;
167 }
168 
169 
170 
172 
174 
176 {
177  NS_LOG_FUNCTION (this);
178 }
179 
181 {
182  NS_LOG_FUNCTION (this);
183 }
184 
185 TypeId
187 {
188  static TypeId tid = TypeId ("ns3::LteRlcSm")
189  .SetParent<LteRlc> ()
190  .SetGroupName ("Lte")
191  .AddConstructor<LteRlcSm> ()
192  ;
193  return tid;
194 }
195 
196 void
198 {
199  NS_LOG_FUNCTION (this);
201 }
202 
203 void
205 {
206  NS_LOG_FUNCTION (this);
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION (this << p);
214 }
215 
216 void
218 {
219  NS_LOG_FUNCTION (this << rxPduParams.p);
220  // RLC Performance evaluation
221  RlcTag rlcTag;
222  Time delay;
223  bool ret = rxPduParams.p->FindFirstMatchingByteTag (rlcTag);
224  NS_ASSERT_MSG (ret, "RlcTag is missing");
225  delay = Simulator::Now () - rlcTag.GetSenderTimestamp ();
226  NS_LOG_LOGIC (" RNTI=" << m_rnti
227  << " LCID=" << (uint32_t) m_lcid
228  << " size=" << rxPduParams.p->GetSize ()
229  << " delay=" << delay.As (Time::NS));
230  m_rxPdu (m_rnti, m_lcid, rxPduParams.p->GetSize (), delay.GetNanoSeconds () );
231 }
232 
233 void
235 {
236  NS_LOG_FUNCTION (this << txOpParams.bytes);
238  RlcTag tag (Simulator::Now ());
239 
240  params.pdu = Create<Packet> (txOpParams.bytes);
241  NS_ABORT_MSG_UNLESS (txOpParams.bytes > 0, "Bytes must be > 0");
246  params.pdu->AddByteTag (tag, 1, params.pdu->GetSize ());
247 
248  params.rnti = m_rnti;
249  params.lcid = m_lcid;
250  params.layer = txOpParams.layer;
251  params.harqProcessId = txOpParams.harqId;
252  params.componentCarrierId = txOpParams.componentCarrierId;
253 
254  // RLC Performance evaluation
255  NS_LOG_LOGIC (" RNTI=" << m_rnti
256  << " LCID=" << (uint32_t) m_lcid
257  << " size=" << txOpParams.bytes);
258  m_txPdu (m_rnti, m_lcid, txOpParams.bytes);
259 
260  m_macSapProvider->TransmitPdu (params);
262 }
263 
264 void
266 {
267  NS_LOG_FUNCTION (this);
268 }
269 
270 void
272 {
273  NS_LOG_FUNCTION (this);
275  p.rnti = m_rnti;
276  p.lcid = m_lcid;
277  p.txQueueSize = 80000;
278  p.txQueueHolDelay = 10;
279  p.retxQueueSize = 0;
280  p.retxQueueHolDelay = 0;
281  p.statusPduSize = 0;
283 }
284 
285 
286 
287 
289 
290 // LteRlcTm::~LteRlcTm ()
291 // {
292 // }
293 
295 
296 // LteRlcUm::~LteRlcUm ()
297 // {
298 // }
299 
301 
302 // LteRlcAm::~LteRlcAm ()
303 // {
304 // }
305 
306 
307 } // namespace ns3
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:939
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
LteMacSapUser * m_macSapUser
MAC SAP user.
Definition: lte-rlc.h:165
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
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
nanosecond
Definition: nstime.h:118
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Parameters for LteMacSapUser::NotifyTxOpportunity.
Definition: lte-mac-sap.h:103
virtual ~LteRlcSm()
Definition: lte-rlc.cc:180
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:35
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
virtual ~LteRlc()
Definition: lte-rlc.cc:97
LteRlcSpecificLteMacSapUser class.
Definition: lte-rlc.cc:36
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:186
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:204
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters params)=0
Notify transmit opportunity.
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.
Definition: lte-rlc-tag.h:36
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
Definition: lte-mac-sap.h:73
uint16_t m_rnti
RNTI.
Definition: lte-rlc.h:168
virtual void NotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters params)
Called by the MAC to notify the RLC that the scheduler granted a transmission opportunity to this RLC...
Definition: lte-rlc.cc:64
uint8_t m_lcid
LCID.
Definition: lte-rlc.h:169
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure.
Definition: lte-rlc.cc:265
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
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:128
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:69
LteRlcSpecificLteRlcSapProvider.
Definition: lte-rlc-sap.h:83
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:67
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
Definition: lte-mac-sap.h:72
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition: lte-rlc.h:144
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:48
uint8_t componentCarrierId
the component carrier id
Definition: lte-mac-sap.h:132
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:120
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
Transmit PDCP PDU.
Definition: lte-rlc.cc:211
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:163
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:166
void ReportBufferStatus()
Report buffer status.
Definition: lte-rlc.cc:271
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition: lte-rlc.h:145
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:392
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:142
virtual void ReceivePdu(LteMacSapUser::ReceivePduParameters params)
Called by the MAC to notify the RLC of the reception of a new PDU.
Definition: lte-rlc.cc:76
Time GetSenderTimestamp(void) const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
Definition: lte-rlc-tag.h:65
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-mac-sap.h:70
uint32_t txQueueSize
the current size of the RLC transmission queue
Definition: lte-mac-sap.h:71
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:135
#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:88
uint32_t bytes
the number of bytes to transmit
Definition: lte-mac-sap.h:129
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
Definition: lte-mac-sap.h:75
virtual void DoNotifyHarqDeliveryFailure()=0
Notify HARQ delivery failure.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
uint8_t layer
the layer of transmission (MIMO)
Definition: lte-mac-sap.h:130
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:95
virtual void NotifyHarqDeliveryFailure()
Called by the MAC to notify the RLC that an HARQ process related to this RLC instance has failed...
Definition: lte-rlc.cc:70
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
Definition: lte-mac-sap.h:74
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 ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams)
Notify transmit opportunity.
Definition: lte-rlc.cc:234
Parameters for LteMacSapUser::ReceivePdu.
Definition: lte-mac-sap.h:156
friend class LteRlcSpecificLteMacSapUser
allow LteRlcSpecificLteMacSapUser class friend access
Definition: lte-rlc.h:53
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:149
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
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters params)=0
Receive PDU function.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void DoInitialize()
Initialize() implementation.
Definition: lte-rlc.cc:197
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
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE...
Definition: lte-rlc.h:50
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:912
LTE_RLC Saturation Mode (SM): simulation-specific mode used for experiments that do not need to consi...
Definition: lte-rlc.h:192
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:156
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:102
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
Definition: lte-rlc.cc:217
Ptr< Packet > p
the RLC PDU to be received
Definition: lte-mac-sap.h:175
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45