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  .AddTraceSource ("TxDrop",
116  "Trace source indicating a packet "
117  "has been dropped before transmission",
119  "ns3::Packet::TracedCallback")
120  ;
121  return tid;
122 }
123 
124 void
126 {
127  NS_LOG_FUNCTION (this);
128  delete (m_rlcSapProvider);
129  delete (m_macSapUser);
130 }
131 
132 void
133 LteRlc::SetRnti (uint16_t rnti)
134 {
135  NS_LOG_FUNCTION (this << (uint32_t) rnti);
136  m_rnti = rnti;
137 }
138 
139 void
140 LteRlc::SetLcId (uint8_t lcId)
141 {
142  NS_LOG_FUNCTION (this << (uint32_t) lcId);
143  m_lcid = lcId;
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION (this << s);
150  m_rlcSapUser = s;
151 }
152 
155 {
156  NS_LOG_FUNCTION (this);
157  return m_rlcSapProvider;
158 }
159 
160 void
162 {
163  NS_LOG_FUNCTION (this << s);
164  m_macSapProvider = s;
165 }
166 
169 {
170  NS_LOG_FUNCTION (this);
171  return m_macSapUser;
172 }
173 
174 
175 
177 
179 
181 {
182  NS_LOG_FUNCTION (this);
183 }
184 
186 {
187  NS_LOG_FUNCTION (this);
188 }
189 
190 TypeId
192 {
193  static TypeId tid = TypeId ("ns3::LteRlcSm")
194  .SetParent<LteRlc> ()
195  .SetGroupName ("Lte")
196  .AddConstructor<LteRlcSm> ()
197  ;
198  return tid;
199 }
200 
201 void
203 {
204  NS_LOG_FUNCTION (this);
206 }
207 
208 void
210 {
211  NS_LOG_FUNCTION (this);
213 }
214 
215 void
217 {
218  NS_LOG_FUNCTION (this << p);
219 }
220 
221 void
223 {
224  NS_LOG_FUNCTION (this << rxPduParams.p);
225  // RLC Performance evaluation
226  RlcTag rlcTag;
227  Time delay;
228  bool ret = rxPduParams.p->FindFirstMatchingByteTag (rlcTag);
229  NS_ASSERT_MSG (ret, "RlcTag is missing");
230  delay = Simulator::Now () - rlcTag.GetSenderTimestamp ();
231  NS_LOG_LOGIC (" RNTI=" << m_rnti
232  << " LCID=" << (uint32_t) m_lcid
233  << " size=" << rxPduParams.p->GetSize ()
234  << " delay=" << delay.As (Time::NS));
235  m_rxPdu (m_rnti, m_lcid, rxPduParams.p->GetSize (), delay.GetNanoSeconds () );
236 }
237 
238 void
240 {
241  NS_LOG_FUNCTION (this << txOpParams.bytes);
243  RlcTag tag (Simulator::Now ());
244 
245  params.pdu = Create<Packet> (txOpParams.bytes);
246  NS_ABORT_MSG_UNLESS (txOpParams.bytes > 0, "Bytes must be > 0");
251  params.pdu->AddByteTag (tag, 1, params.pdu->GetSize ());
252 
253  params.rnti = m_rnti;
254  params.lcid = m_lcid;
255  params.layer = txOpParams.layer;
256  params.harqProcessId = txOpParams.harqId;
257  params.componentCarrierId = txOpParams.componentCarrierId;
258 
259  // RLC Performance evaluation
260  NS_LOG_LOGIC (" RNTI=" << m_rnti
261  << " LCID=" << (uint32_t) m_lcid
262  << " size=" << txOpParams.bytes);
263  m_txPdu (m_rnti, m_lcid, txOpParams.bytes);
264 
265  m_macSapProvider->TransmitPdu (params);
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 
290 
291 
292 
294 
295 // LteRlcTm::~LteRlcTm ()
296 // {
297 // }
298 
300 
301 // LteRlcUm::~LteRlcUm ()
302 // {
303 // }
304 
306 
307 // LteRlcAm::~LteRlcAm ()
308 // {
309 // }
310 
311 
312 } // 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:37
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:51
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition: lte-rlc.h:144
uint8_t m_lcid
LCID.
Definition: lte-rlc.h:169
friend class LteRlcSpecificLteMacSapUser
allow LteRlcSpecificLteMacSapUser class friend access
Definition: lte-rlc.h:53
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters params)=0
Notify transmit opportunity.
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:102
TracedCallback< Ptr< const Packet > > m_txDropTrace
The trace source fired when the RLC drops a packet before transmission.
Definition: lte-rlc.h:183
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
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition: lte-rlc.h:145
LteMacSapUser * m_macSapUser
MAC SAP user.
Definition: lte-rlc.h:165
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:166
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:125
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:147
friend class LteRlcSpecificLteRlcSapProvider< LteRlc >
allow LteRlcSpecificLteRlcSapProvider<LteRlc> class friend access
Definition: lte-rlc.h:55
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
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:133
virtual void DoNotifyHarqDeliveryFailure()=0
Notify HARQ delivery failure.
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:161
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters params)=0
Receive PDU function.
virtual ~LteRlc()
Definition: lte-rlc.cc:97
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:168
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:140
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:154
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:68
LTE_RLC Saturation Mode (SM): simulation-specific mode used for experiments that do not need to consi...
Definition: lte-rlc.h:198
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:209
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams)
Notify transmit opportunity.
Definition: lte-rlc.cc:239
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:191
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
Transmit PDCP PDU.
Definition: lte-rlc.cc:216
virtual void DoInitialize()
Initialize() implementation.
Definition: lte-rlc.cc:202
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure.
Definition: lte-rlc.cc:270
virtual ~LteRlcSm()
Definition: lte-rlc.cc:185
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
Definition: lte-rlc.cc:222
void ReportBufferStatus()
Report buffer status.
Definition: lte-rlc.cc:276
LteRlcSpecificLteMacSapUser class.
Definition: lte-rlc.cc:37
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
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
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
A base class which provides memory management and object aggregation.
Definition: object.h:88
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:939
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:912
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.
Definition: lte-rlc-tag.h:37
Time GetSenderTimestamp(void) const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
Definition: lte-rlc-tag.h:65
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
@ NS
nanosecond
Definition: nstime.h:117
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:418
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:391
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#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
#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: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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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.
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