A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 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);
46  virtual void NotifyHarqDeliveryFailure ();
47  virtual void ReceivePdu (Ptr<Packet> p);
48 
49 private:
52 };
53 
55  : m_rlc (rlc)
56 {
57 }
58 
60 {
61 }
62 
63 void
64 LteRlcSpecificLteMacSapUser::NotifyTxOpportunity (uint32_t bytes, uint8_t layer)
65 {
66  m_rlc->DoNotifyTxOpportunity (bytes, layer);
67 }
68 
69 void
71 {
73 }
74 
75 void
77 {
78  m_rlc->DoReceivePdu (p);
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  static TypeId tid = TypeId ("ns3::LteRlc")
100  .SetParent<Object> ()
101  .AddTraceSource ("TxPDU",
102  "PDU transmission notified to the MAC.",
104  .AddTraceSource ("RxPDU",
105  "PDU received.",
107  ;
108  return tid;
109 }
110 
111 void
112 LteRlc::SetRnti (uint16_t rnti)
113 {
114  NS_LOG_FUNCTION (this << (uint32_t) rnti);
115  m_rnti = rnti;
116 }
117 
118 void
119 LteRlc::SetLcId (uint8_t lcId)
120 {
121  NS_LOG_FUNCTION (this << (uint32_t) lcId);
122  m_lcid = lcId;
123 }
124 
126 {
127  NS_LOG_FUNCTION (this);
128  delete (m_rlcSapProvider);
129  delete (m_macSapUser);
130 }
131 
132 void
134 {
135  NS_LOG_FUNCTION (this << s);
136  m_rlcSapUser = s;
137 }
138 
141 {
142  NS_LOG_FUNCTION (this);
143  return m_rlcSapProvider;
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION (this << s);
150  m_macSapProvider = s;
151 }
152 
155 {
156  NS_LOG_FUNCTION (this);
157  return m_macSapUser;
158 }
159 
160 
161 
163 
165 
167 {
168 
169  NS_LOG_FUNCTION (this);
171 }
172 
174 {
175 
176 }
177 
178 TypeId
180 {
181  static TypeId tid = TypeId ("ns3::LteRlcSm")
182  .SetParent<LteRlc> ()
183  .AddConstructor<LteRlcSm> ()
184  ;
185  return tid;
186 }
187 
188 void
190 {
191  NS_LOG_FUNCTION (this << p);
192 }
193 
194 void
196 {
197  NS_LOG_FUNCTION (this << p);
198  // RLC Performance evaluation
199  RlcTag rlcTag;
200  Time delay;
201  if (p->FindFirstMatchingByteTag(rlcTag))
202  {
203  delay = Simulator::Now() - rlcTag.GetSenderTimestamp ();
204  }
205  NS_LOG_LOGIC (" RNTI=" << m_rnti
206  << " LCID=" << (uint32_t) m_lcid
207  << " size=" << p->GetSize ()
208  << " delay=" << delay.GetNanoSeconds ());
209  m_rxPdu(m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds () );
210 }
211 
212 void
213 LteRlcSm::DoNotifyTxOpportunity (uint32_t bytes, uint8_t layer)
214 {
215  NS_LOG_FUNCTION (this << bytes);
217  params.pdu = Create<Packet> (bytes);
218  params.rnti = m_rnti;
219  params.lcid = m_lcid;
220  params.layer = layer;
221 
222  // RLC Performance evaluation
223  RlcTag tag (Simulator::Now());
224  params.pdu->AddByteTag (tag);
225  NS_LOG_LOGIC (" RNTI=" << m_rnti
226  << " LCID=" << (uint32_t) m_lcid
227  << " size=" << bytes);
228  m_txPdu(m_rnti, m_lcid, bytes);
229 
230  m_macSapProvider->TransmitPdu (params);
232 }
233 
234 void
236 {
237  NS_LOG_FUNCTION (this);
238 }
239 
240 void
242 {
243  NS_LOG_FUNCTION (this);
245 }
246 
247 void
249 {
250  NS_LOG_FUNCTION (this);
252  p.rnti = m_rnti;
253  p.lcid = m_lcid;
254  p.txQueueSize = 80000;
255  p.txQueueHolDelay = 10;
256  p.retxQueueSize = 0;
257  p.retxQueueHolDelay = 0;
258  p.statusPduSize = 0;
260 }
261 
262 
263 
264 
266 
267 // LteRlcTm::~LteRlcTm ()
268 // {
269 // }
270 
272 
273 // LteRlcUm::~LteRlcUm ()
274 // {
275 // }
276 
278 
279 // LteRlcAm::~LteRlcAm ()
280 // {
281 // }
282 
283 
284 } // namespace ns3