A Discrete-Event Network Simulator
API
lte-rlc-tm.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011,2012 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: Manuel Requena <manuel.requena@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 #include "ns3/simulator.h"
23 #include "ns3/log.h"
24 
25 #include "ns3/lte-rlc-tm.h"
26 #include "ns3/lte-rlc-tag.h"
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("LteRlcTm");
31 
33 
35  : m_maxTxBufferSize (0),
36  m_txBufferSize (0)
37 {
38  NS_LOG_FUNCTION (this);
39 }
40 
42 {
43  NS_LOG_FUNCTION (this);
44 }
45 
46 TypeId
48 {
49  static TypeId tid = TypeId ("ns3::LteRlcTm")
50  .SetParent<LteRlc> ()
51  .SetGroupName("Lte")
52  .AddConstructor<LteRlcTm> ()
53  .AddAttribute ("MaxTxBufferSize",
54  "Maximum Size of the Transmission Buffer (in Bytes)",
55  UintegerValue (2 * 1024 * 1024),
57  MakeUintegerChecker<uint32_t> ())
58  ;
59  return tid;
60 }
61 
62 void
64 {
65  NS_LOG_FUNCTION (this);
66  m_rbsTimer.Cancel ();
67  m_txBuffer.clear ();
68 
70 }
71 
72 
77 void
79 {
80  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
81 
83  {
85  RlcTag timeTag (Simulator::Now ());
86  p->AddPacketTag (timeTag);
87 
88  NS_LOG_LOGIC ("Tx Buffer: New packet added");
89  m_txBuffer.push_back (p);
90  m_txBufferSize += p->GetSize ();
91  NS_LOG_LOGIC ("NumOfBuffers = " << m_txBuffer.size() );
92  NS_LOG_LOGIC ("txBufferSize = " << m_txBufferSize);
93  }
94  else
95  {
96  // Discard full RLC SDU
97  NS_LOG_LOGIC ("TxBuffer is full. RLC SDU discarded");
98  NS_LOG_LOGIC ("MaxTxBufferSize = " << m_maxTxBufferSize);
99  NS_LOG_LOGIC ("txBufferSize = " << m_txBufferSize);
100  NS_LOG_LOGIC ("packet size = " << p->GetSize ());
101  }
102 
105  m_rbsTimer.Cancel ();
106 }
107 
108 
113 void
114 LteRlcTm::DoNotifyTxOpportunity (uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
115 {
116  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << bytes << (uint32_t) layer << (uint32_t) harqId);
117 
118  // 5.1.1.1 Transmit operations
119  // 5.1.1.1.1 General
120  // When submitting a new TMD PDU to lower layer, the transmitting TM RLC entity shall:
121  // - submit a RLC SDU without any modification to lower layer.
122 
123 
124  if ( m_txBuffer.size () == 0 )
125  {
126  NS_LOG_LOGIC ("No data pending");
127  return;
128  }
129 
130  Ptr<Packet> packet = (*(m_txBuffer.begin ()))->Copy ();
131 
132  if (bytes < packet->GetSize ())
133  {
134  NS_LOG_WARN ("TX opportunity too small = " << bytes << " (PDU size: " << packet->GetSize () << ")");
135  return;
136  }
137 
138  m_txBufferSize -= (*(m_txBuffer.begin()))->GetSize ();
139  m_txBuffer.erase (m_txBuffer.begin ());
140 
141  // Sender timestamp
142  RlcTag rlcTag (Simulator::Now ());
143  packet->ReplacePacketTag (rlcTag);
144  m_txPdu (m_rnti, m_lcid, packet->GetSize ());
145 
146  // Send RLC PDU to MAC layer
148  params.pdu = packet;
149  params.rnti = m_rnti;
150  params.lcid = m_lcid;
151  params.layer = layer;
152  params.harqProcessId = harqId;
153  params.componentCarrierId = componentCarrierId;
154 
155  m_macSapProvider->TransmitPdu (params);
156 
157  if (! m_txBuffer.empty ())
158  {
159  m_rbsTimer.Cancel ();
161  }
162 }
163 
164 void
166 {
167  NS_LOG_FUNCTION (this);
168 }
169 
170 void
171 LteRlcTm::DoReceivePdu (Ptr<Packet> p, uint16_t rnti, uint8_t lcid)
172 {
173  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
174 
175  // Receiver timestamp
176  RlcTag rlcTag;
177  Time delay;
178  NS_ASSERT_MSG (p->PeekPacketTag (rlcTag), "RlcTag is missing");
179  p->RemovePacketTag (rlcTag);
180  delay = Simulator::Now() - rlcTag.GetSenderTimestamp ();
181  m_rxPdu (m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds ());
182 
183  // 5.1.1.2 Receive operations
184  // 5.1.1.2.1 General
185  // When receiving a new TMD PDU from lower layer, the receiving TM RLC entity shall:
186  // - deliver the TMD PDU without any modification to upper layer.
187 
189 }
190 
191 
192 void
194 {
195  Time holDelay (0);
196  uint32_t queueSize = 0;
197 
198  if (! m_txBuffer.empty ())
199  {
200  RlcTag holTimeTag;
201  NS_ASSERT_MSG (m_txBuffer.front ()->PeekPacketTag (holTimeTag), "RlcTag is missing");
202  m_txBuffer.front ()->PeekPacketTag (holTimeTag);
203  holDelay = Simulator::Now () - holTimeTag.GetSenderTimestamp ();
204 
205  queueSize = m_txBufferSize; // just data in tx queue (no header overhead for RLC TM)
206  }
207 
209  r.rnti = m_rnti;
210  r.lcid = m_lcid;
211  r.txQueueSize = queueSize;
212  r.txQueueHolDelay = holDelay.GetMilliSeconds () ;
213  r.retxQueueSize = 0;
214  r.retxQueueHolDelay = 0;
215  r.statusPduSize = 0;
216 
217  NS_LOG_LOGIC ("Send ReportBufferStatus = " << r.txQueueSize << ", " << r.txQueueHolDelay );
219 }
220 
221 void
223 {
224  NS_LOG_LOGIC ("RBS Timer expires");
225 
226  if (! m_txBuffer.empty ())
227  {
230  }
231 }
232 
233 } // namespace ns3
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 "...
uint32_t m_txBufferSize
transmit buffer size
Definition: lte-rlc-tm.h:79
#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 void DoNotifyHarqDeliveryFailure()
Notify HARQ deliver failure.
Definition: lte-rlc-tm.cc:165
void ExpireRbsTimer(void)
Expire RBS timer function.
Definition: lte-rlc-tm.cc:222
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added...
Definition: wifi-utils.cc:146
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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
void DoReportBufferStatus()
Report buffer status.
Definition: lte-rlc-tm.cc:193
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
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:69
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId, uint8_t componentCarrierId, uint16_t rnti, uint8_t lcid)
MAC SAP.
Definition: lte-rlc-tm.cc:114
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
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
RLC SAP.
Definition: lte-rlc-tm.cc:78
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:866
virtual void ReceivePdcpPdu(Ptr< Packet > p)=0
Called by the RLC entity to notify the PDCP entity of the reception of a new PDCP PDU...
virtual ~LteRlcTm()
Definition: lte-rlc-tm.cc:41
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc.cc:123
virtual void DoReceivePdu(Ptr< Packet > p, uint16_t rnti, uint8_t lcid)
Receive PDU function.
Definition: lte-rlc-tm.cc:171
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-rlc.h:173
LTE RLC Transparent Mode (TM), see 3GPP TS 36.322.
Definition: lte-rlc-tm.h:35
EventId m_rbsTimer
RBS timer.
Definition: lte-rlc-tm.h:82
std::vector< Ptr< Packet > > m_txBuffer
Transmission buffer.
Definition: lte-rlc-tm.h:80
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-rlc-tm.cc:47
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
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
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
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:359
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:859
uint32_t m_maxTxBufferSize
maximum transmit buffer size
Definition: lte-rlc-tm.h:78
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
Definition: lte-mac-sap.h:74
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
virtual void DoDispose()
Destructor implementation.
Definition: lte-rlc-tm.cc:63
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
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:874
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
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
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45