A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lte-rlc.cc
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 NS_LOG_COMPONENT_DEFINE ("LteRlc");
32 
33 namespace ns3 {
34 
35 
36 
38 
40 {
41 public:
43 
44  // Interface implemented from LteMacSapUser
45  virtual void NotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId);
46  virtual void NotifyHarqDeliveryFailure ();
47  virtual void ReceivePdu (Ptr<Packet> p);
48 
49 private:
51  LteRlc* m_rlc;
52 };
53 
54 LteRlcSpecificLteMacSapUser::LteRlcSpecificLteMacSapUser (LteRlc* rlc)
55  : m_rlc (rlc)
56 {
57 }
58 
59 LteRlcSpecificLteMacSapUser::LteRlcSpecificLteMacSapUser ()
60 {
61 }
62 
63 void
64 LteRlcSpecificLteMacSapUser::NotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId)
65 {
66  m_rlc->DoNotifyTxOpportunity (bytes, layer, harqId);
67 }
68 
69 void
71 {
72  m_rlc->DoNotifyHarqDeliveryFailure ();
73 }
74 
75 void
77 {
78  m_rlc->DoReceivePdu (p);
79 }
80 
81 
83 
84 NS_OBJECT_ENSURE_REGISTERED (LteRlc);
85 
86 LteRlc::LteRlc ()
87  : m_rlcSapUser (0),
88  m_macSapProvider (0),
89  m_rnti (0),
90  m_lcid (0)
91 {
92  NS_LOG_FUNCTION (this);
93  m_rlcSapProvider = new LteRlcSpecificLteRlcSapProvider<LteRlc> (this);
94  m_macSapUser = new LteRlcSpecificLteMacSapUser (this);
95 }
96 
97 LteRlc::~LteRlc ()
98 {
99  NS_LOG_FUNCTION (this);
100 }
101 
102 TypeId LteRlc::GetTypeId (void)
103 {
104  static TypeId tid = TypeId ("ns3::LteRlc")
105  .SetParent<Object> ()
106  .AddTraceSource ("TxPDU",
107  "PDU transmission notified to the MAC.",
109  .AddTraceSource ("RxPDU",
110  "PDU received.",
112  ;
113  return tid;
114 }
115 
116 void
118 {
119  NS_LOG_FUNCTION (this);
120  delete (m_rlcSapProvider);
121  delete (m_macSapUser);
122 }
123 
124 void
125 LteRlc::SetRnti (uint16_t rnti)
126 {
127  NS_LOG_FUNCTION (this << (uint32_t) rnti);
128  m_rnti = rnti;
129 }
130 
131 void
132 LteRlc::SetLcId (uint8_t lcId)
133 {
134  NS_LOG_FUNCTION (this << (uint32_t) lcId);
135  m_lcid = lcId;
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION (this << s);
142  m_rlcSapUser = s;
143 }
144 
147 {
148  NS_LOG_FUNCTION (this);
149  return m_rlcSapProvider;
150 }
151 
152 void
154 {
155  NS_LOG_FUNCTION (this << s);
156  m_macSapProvider = s;
157 }
158 
161 {
162  NS_LOG_FUNCTION (this);
163  return m_macSapUser;
164 }
165 
166 
167 
169 
170 NS_OBJECT_ENSURE_REGISTERED (LteRlcSm);
171 
172 LteRlcSm::LteRlcSm ()
173 {
174  NS_LOG_FUNCTION (this);
175 }
176 
177 LteRlcSm::~LteRlcSm ()
178 {
179  NS_LOG_FUNCTION (this);
180 }
181 
182 TypeId
183 LteRlcSm::GetTypeId (void)
184 {
185  static TypeId tid = TypeId ("ns3::LteRlcSm")
186  .SetParent<LteRlc> ()
187  .AddConstructor<LteRlcSm> ()
188  ;
189  return tid;
190 }
191 
192 void
194 {
195  NS_LOG_FUNCTION (this);
196  ReportBufferStatus ();
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (this);
204 }
205 
206 void
207 LteRlcSm::DoTransmitPdcpPdu (Ptr<Packet> p)
208 {
209  NS_LOG_FUNCTION (this << p);
210 }
211 
212 void
213 LteRlcSm::DoReceivePdu (Ptr<Packet> p)
214 {
215  NS_LOG_FUNCTION (this << p);
216  // RLC Performance evaluation
217  RlcTag rlcTag;
218  Time delay;
219  if (p->FindFirstMatchingByteTag(rlcTag))
220  {
221  delay = Simulator::Now() - rlcTag.GetSenderTimestamp ();
222  }
223  NS_LOG_LOGIC (" RNTI=" << m_rnti
224  << " LCID=" << (uint32_t) m_lcid
225  << " size=" << p->GetSize ()
226  << " delay=" << delay.GetNanoSeconds ());
227  m_rxPdu(m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds () );
228 }
229 
230 void
231 LteRlcSm::DoNotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId)
232 {
233  NS_LOG_FUNCTION (this << bytes);
234  LteMacSapProvider::TransmitPduParameters params;
235  params.pdu = Create<Packet> (bytes);
236  params.rnti = m_rnti;
237  params.lcid = m_lcid;
238  params.layer = layer;
239  params.harqProcessId = harqId;
240 
241  // RLC Performance evaluation
242  RlcTag tag (Simulator::Now());
243  params.pdu->AddByteTag (tag);
244  NS_LOG_LOGIC (" RNTI=" << m_rnti
245  << " LCID=" << (uint32_t) m_lcid
246  << " size=" << bytes);
247  m_txPdu(m_rnti, m_lcid, bytes);
248 
249  m_macSapProvider->TransmitPdu (params);
250  ReportBufferStatus ();
251 }
252 
253 void
254 LteRlcSm::DoNotifyHarqDeliveryFailure ()
255 {
256  NS_LOG_FUNCTION (this);
257 }
258 
259 void
260 LteRlcSm::ReportBufferStatus ()
261 {
262  NS_LOG_FUNCTION (this);
263  LteMacSapProvider::ReportBufferStatusParameters p;
264  p.rnti = m_rnti;
265  p.lcid = m_lcid;
266  p.txQueueSize = 80000;
267  p.txQueueHolDelay = 10;
268  p.retxQueueSize = 0;
269  p.retxQueueHolDelay = 0;
270  p.statusPduSize = 0;
271  m_macSapProvider->ReportBufferStatus (p);
272 }
273 
274 
275 
276 
278 
279 // LteRlcTm::~LteRlcTm ()
280 // {
281 // }
282 
284 
285 // LteRlcUm::~LteRlcUm ()
286 // {
287 // }
288 
290 
291 // LteRlcAm::~LteRlcAm ()
292 // {
293 // }
294 
295 
296 } // namespace ns3
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
Definition: lte-rlc.h:128
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
virtual void DoDispose()
Definition: lte-rlc.cc:200
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
virtual void ReceivePdu(Ptr< Packet > p)
Definition: lte-rlc.cc:76
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:125
virtual void NotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId)
Definition: lte-rlc.cc:64
virtual void DoDispose()
Definition: lte-rlc.cc:117
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:160
#define NS_LOG_LOGIC(msg)
Definition: log.h:334
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:139
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static Time Now(void)
Definition: simulator.cc:179
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:132
virtual void NotifyHarqDeliveryFailure()
Definition: lte-rlc.cc:70
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:146
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Definition: lte-rlc.h:132
virtual void DoInitialize()
Definition: lte-rlc.cc:193
virtual void TransmitPdu(TransmitPduParameters params)=0
void SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:153