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 
35 
38 {
39 public:
46 
47  // Interface implemented from LteMacSapUser
48  virtual void NotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid);
49  virtual void NotifyHarqDeliveryFailure ();
50  virtual void ReceivePdu (Ptr<Packet> p, uint16_t rnti, uint8_t lcid);
51 
52 private:
55 };
56 
58  : m_rlc (rlc)
59 {
60 }
61 
63 {
64 }
65 
66 void
67 LteRlcSpecificLteMacSapUser::NotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
68 {
69  m_rlc->DoNotifyTxOpportunity (bytes, layer, harqId, componentCarrierId, rnti, lcid);
70 }
71 
72 void
74 {
76 }
77 
78 void
79 LteRlcSpecificLteMacSapUser::ReceivePdu (Ptr<Packet> p, uint16_t rnti, uint8_t lcid)
80 {
81  m_rlc->DoReceivePdu (p, rnti, lcid);
82 }
83 
84 
86 
88 
90  : m_rlcSapUser (0),
91  m_macSapProvider (0),
92  m_rnti (0),
93  m_lcid (0)
94 {
95  NS_LOG_FUNCTION (this);
98 }
99 
101 {
102  NS_LOG_FUNCTION (this);
103 }
104 
106 {
107  static TypeId tid = TypeId ("ns3::LteRlc")
108  .SetParent<Object> ()
109  .SetGroupName("Lte")
110  .AddTraceSource ("TxPDU",
111  "PDU transmission notified to the MAC.",
113  "ns3::LteRlc::NotifyTxTracedCallback")
114  .AddTraceSource ("RxPDU",
115  "PDU received.",
117  "ns3::LteRlc::ReceiveTracedCallback")
118  ;
119  return tid;
120 }
121 
122 void
124 {
125  NS_LOG_FUNCTION (this);
126  delete (m_rlcSapProvider);
127  delete (m_macSapUser);
128 }
129 
130 void
131 LteRlc::SetRnti (uint16_t rnti)
132 {
133  NS_LOG_FUNCTION (this << (uint32_t) rnti);
134  m_rnti = rnti;
135 }
136 
137 void
138 LteRlc::SetLcId (uint8_t lcId)
139 {
140  NS_LOG_FUNCTION (this << (uint32_t) lcId);
141  m_lcid = lcId;
142 }
143 
144 void
146 {
147  NS_LOG_FUNCTION (this << s);
148  m_rlcSapUser = s;
149 }
150 
153 {
154  NS_LOG_FUNCTION (this);
155  return m_rlcSapProvider;
156 }
157 
158 void
160 {
161  NS_LOG_FUNCTION (this << s);
162  m_macSapProvider = s;
163 }
164 
167 {
168  NS_LOG_FUNCTION (this);
169  return m_macSapUser;
170 }
171 
172 
173 
175 
177 
179 {
180  NS_LOG_FUNCTION (this);
181 }
182 
184 {
185  NS_LOG_FUNCTION (this);
186 }
187 
188 TypeId
190 {
191  static TypeId tid = TypeId ("ns3::LteRlcSm")
192  .SetParent<LteRlc> ()
193  .SetGroupName("Lte")
194  .AddConstructor<LteRlcSm> ()
195  ;
196  return tid;
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (this);
204 }
205 
206 void
208 {
209  NS_LOG_FUNCTION (this);
211 }
212 
213 void
215 {
216  NS_LOG_FUNCTION (this << p);
217 }
218 
219 void
220 LteRlcSm::DoReceivePdu (Ptr<Packet> p, uint16_t rnti, uint8_t lcid)
221 {
222  NS_LOG_FUNCTION (this << p);
223  // RLC Performance evaluation
224  RlcTag rlcTag;
225  Time delay;
226  NS_ASSERT_MSG (p->PeekPacketTag (rlcTag), "RlcTag is missing");
227  p->RemovePacketTag (rlcTag);
228  delay = Simulator::Now() - rlcTag.GetSenderTimestamp ();
229  NS_LOG_LOGIC (" RNTI=" << m_rnti
230  << " LCID=" << (uint32_t) m_lcid
231  << " size=" << p->GetSize ()
232  << " delay=" << delay.GetNanoSeconds ());
233  m_rxPdu(m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds () );
234 }
235 
236 void
237 LteRlcSm::DoNotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
238 {
239  NS_LOG_FUNCTION (this << bytes);
241  params.pdu = Create<Packet> (bytes);
242  params.rnti = m_rnti;
243  params.lcid = m_lcid;
244  params.layer = layer;
245  params.harqProcessId = harqId;
246  params.componentCarrierId = componentCarrierId;
247 
248  // RLC Performance evaluation
249  RlcTag tag (Simulator::Now());
250  params.pdu->AddPacketTag (tag);
251  NS_LOG_LOGIC (" RNTI=" << m_rnti
252  << " LCID=" << (uint32_t) m_lcid
253  << " size=" << bytes);
254  m_txPdu(m_rnti, m_lcid, bytes);
255 
256  m_macSapProvider->TransmitPdu (params);
258 }
259 
260 void
262 {
263  NS_LOG_FUNCTION (this);
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this);
271  p.rnti = m_rnti;
272  p.lcid = m_lcid;
273  p.txQueueSize = 80000;
274  p.txQueueHolDelay = 10;
275  p.retxQueueSize = 0;
276  p.retxQueueHolDelay = 0;
277  p.statusPduSize = 0;
279 }
280 
281 
282 
283 
285 
286 // LteRlcTm::~LteRlcTm ()
287 // {
288 // }
289 
291 
292 // LteRlcUm::~LteRlcUm ()
293 // {
294 // }
295 
297 
298 // LteRlcAm::~LteRlcAm ()
299 // {
300 // }
301 
302 
303 } // namespace ns3
virtual void DoReceivePdu(Ptr< Packet > p, uint16_t rnti, uint8_t lcid)
Receive PDU function.
Definition: lte-rlc.cc:220
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:172
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:181
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 "...
virtual ~LteRlcSm()
Definition: lte-rlc.cc:183
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:831
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
virtual ~LteRlc()
Definition: lte-rlc.cc:100
LteRlcSpecificLteMacSapUser class.
Definition: lte-rlc.cc:37
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:189
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:207
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:202
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:175
uint8_t m_lcid
LCID.
Definition: lte-rlc.h:176
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure.
Definition: lte-rlc.cc:261
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:131
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
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)=0
Notify transmit opportunity.
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
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:123
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
Transmit PDCP PDU.
Definition: lte-rlc.cc:214
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:166
virtual void DoReceivePdu(Ptr< Packet > p, uint16_t rnti, uint8_t lcid)=0
Receive PDU function.
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:173
void ReportBufferStatus()
Report buffer status.
Definition: lte-rlc.cc:267
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:145
virtual void NotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
Called by the MAC to notify the RLC that the scheduler granted a transmission opportunity to this RLC...
Definition: lte-rlc.cc:67
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:249
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:138
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:95
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:859
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:73
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.
friend class LteRlcSpecificLteMacSapUser
allow LteRlcSpecificLteMacSapUser class friend access
Definition: lte-rlc.h:53
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:152
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:185
A base class which provides memory management and object aggregation.
Definition: object.h:87
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:874
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
Notify transmit opportunity.
Definition: lte-rlc.cc:237
virtual void DoInitialize()
Initialize() implementation.
Definition: lte-rlc.cc:200
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 ReceivePdu(Ptr< Packet > p, uint16_t rnti, uint8_t lcid)
Called by the MAC to notify the RLC of the reception of a new PDU.
Definition: lte-rlc.cc:79
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:915
LTE_RLC Saturation Mode (SM): simulation-specific mode used for experiments that do not need to consi...
Definition: lte-rlc.h:199
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:159
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc.cc:105
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45