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 }
60 
62 {
63 }
64 
65 void
67 {
68  m_rlc->DoNotifyTxOpportunity (params);
69 }
70 
71 void
73 {
75 }
76 
77 void
79 {
80  m_rlc->DoReceivePdu (params);
81 }
82 
83 
85 
87 
89  : m_rlcSapUser (0),
90  m_macSapProvider (0),
91  m_rnti (0),
92  m_lcid (0)
93 {
94  NS_LOG_FUNCTION (this);
97 }
98 
100 {
101  NS_LOG_FUNCTION (this);
102 }
103 
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  ;
118  return tid;
119 }
120 
121 void
123 {
124  NS_LOG_FUNCTION (this);
125  delete (m_rlcSapProvider);
126  delete (m_macSapUser);
127 }
128 
129 void
130 LteRlc::SetRnti (uint16_t rnti)
131 {
132  NS_LOG_FUNCTION (this << (uint32_t) rnti);
133  m_rnti = rnti;
134 }
135 
136 void
137 LteRlc::SetLcId (uint8_t lcId)
138 {
139  NS_LOG_FUNCTION (this << (uint32_t) lcId);
140  m_lcid = lcId;
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION (this << s);
147  m_rlcSapUser = s;
148 }
149 
152 {
153  NS_LOG_FUNCTION (this);
154  return m_rlcSapProvider;
155 }
156 
157 void
159 {
160  NS_LOG_FUNCTION (this << s);
161  m_macSapProvider = s;
162 }
163 
166 {
167  NS_LOG_FUNCTION (this);
168  return m_macSapUser;
169 }
170 
171 
172 
174 
176 
178 {
179  NS_LOG_FUNCTION (this);
180 }
181 
183 {
184  NS_LOG_FUNCTION (this);
185 }
186 
187 TypeId
189 {
190  static TypeId tid = TypeId ("ns3::LteRlcSm")
191  .SetParent<LteRlc> ()
192  .SetGroupName("Lte")
193  .AddConstructor<LteRlcSm> ()
194  ;
195  return tid;
196 }
197 
198 void
200 {
201  NS_LOG_FUNCTION (this);
203 }
204 
205 void
207 {
208  NS_LOG_FUNCTION (this);
210 }
211 
212 void
214 {
215  NS_LOG_FUNCTION (this << p);
216 }
217 
218 void
220 {
221  NS_LOG_FUNCTION (this << rxPduParams.p);
222  // RLC Performance evaluation
223  RlcTag rlcTag;
224  Time delay;
225  bool ret = rxPduParams.p->FindFirstMatchingByteTag (rlcTag);
226  NS_ASSERT_MSG (ret, "RlcTag is missing");
227  delay = Simulator::Now() - rlcTag.GetSenderTimestamp ();
228  NS_LOG_LOGIC (" RNTI=" << m_rnti
229  << " LCID=" << (uint32_t) m_lcid
230  << " size=" << rxPduParams.p->GetSize ()
231  << " delay=" << delay.GetNanoSeconds ());
232  m_rxPdu(m_rnti, m_lcid, rxPduParams.p->GetSize (), delay.GetNanoSeconds () );
233 }
234 
235 void
237 {
238  NS_LOG_FUNCTION (this << txOpParams.bytes);
240  RlcTag tag (Simulator::Now ());
241 
242  params.pdu = Create<Packet> (txOpParams.bytes);
243  NS_ABORT_MSG_UNLESS (txOpParams.bytes > 0, "Bytes must be > 0");
248  params.pdu->AddByteTag (tag, 1, params.pdu->GetSize ());
249 
250  params.rnti = m_rnti;
251  params.lcid = m_lcid;
252  params.layer = txOpParams.layer;
253  params.harqProcessId = txOpParams.harqId;
254  params.componentCarrierId = txOpParams.componentCarrierId;
255 
256  // RLC Performance evaluation
257  NS_LOG_LOGIC (" RNTI=" << m_rnti
258  << " LCID=" << (uint32_t) m_lcid
259  << " size=" << txOpParams.bytes);
260  m_txPdu(m_rnti, m_lcid, txOpParams.bytes);
261 
262  m_macSapProvider->TransmitPdu (params);
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this);
270 }
271 
272 void
274 {
275  NS_LOG_FUNCTION (this);
277  p.rnti = m_rnti;
278  p.lcid = m_lcid;
279  p.txQueueSize = 80000;
280  p.txQueueHolDelay = 10;
281  p.retxQueueSize = 0;
282  p.retxQueueHolDelay = 0;
283  p.statusPduSize = 0;
285 }
286 
287 
288 
289 
291 
292 // LteRlcTm::~LteRlcTm ()
293 // {
294 // }
295 
297 
298 // LteRlcUm::~LteRlcUm ()
299 // {
300 // }
301 
303 
304 // LteRlcAm::~LteRlcAm ()
305 // {
306 // }
307 
308 
309 } // namespace ns3
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:846
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
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
#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:182
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
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
virtual ~LteRlc()
Definition: lte-rlc.cc:99
LteRlcSpecificLteMacSapUser class.
Definition: lte-rlc.cc:36
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:188
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:206
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:66
uint8_t m_lcid
LCID.
Definition: lte-rlc.h:169
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure.
Definition: lte-rlc.cc:267
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:130
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:122
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
Transmit PDCP PDU.
Definition: lte-rlc.cc:213
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:165
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:166
void ReportBufferStatus()
Report buffer status.
Definition: lte-rlc.cc:273
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:367
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:144
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:78
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:193
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:137
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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:72
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:236
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:151
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:199
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:922
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:819
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:158
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:104
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
Definition: lte-rlc.cc:219
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