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)
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 
154  m_macSapProvider->TransmitPdu (params);
155 
156  if (! m_txBuffer.empty ())
157  {
158  m_rbsTimer.Cancel ();
160  }
161 }
162 
163 void
165 {
166  NS_LOG_FUNCTION (this);
167 }
168 
169 void
171 {
172  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
173 
174  // Receiver timestamp
175  RlcTag rlcTag;
176  Time delay;
177  NS_ASSERT_MSG (p->PeekPacketTag (rlcTag), "RlcTag is missing");
178  p->RemovePacketTag (rlcTag);
179  delay = Simulator::Now() - rlcTag.GetSenderTimestamp ();
180  m_rxPdu (m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds ());
181 
182  // 5.1.1.2 Receive operations
183  // 5.1.1.2.1 General
184  // When receiving a new TMD PDU from lower layer, the receiving TM RLC entity shall:
185  // - deliver the TMD PDU without any modification to upper layer.
186 
188 }
189 
190 
191 void
193 {
194  Time holDelay (0);
195  uint32_t queueSize = 0;
196 
197  if (! m_txBuffer.empty ())
198  {
199  RlcTag holTimeTag;
200  NS_ASSERT_MSG (m_txBuffer.front ()->PeekPacketTag (holTimeTag), "RlcTag is missing");
201  m_txBuffer.front ()->PeekPacketTag (holTimeTag);
202  holDelay = Simulator::Now () - holTimeTag.GetSenderTimestamp ();
203 
204  queueSize = m_txBufferSize; // just data in tx queue (no header overhead for RLC TM)
205  }
206 
208  r.rnti = m_rnti;
209  r.lcid = m_lcid;
210  r.txQueueSize = queueSize;
211  r.txQueueHolDelay = holDelay.GetMilliSeconds () ;
212  r.retxQueueSize = 0;
213  r.retxQueueHolDelay = 0;
214  r.statusPduSize = 0;
215 
216  NS_LOG_LOGIC ("Send ReportBufferStatus = " << r.txQueueSize << ", " << r.txQueueHolDelay );
218 }
219 
220 void
222 {
223  NS_LOG_LOGIC ("RBS Timer expires");
224 
225  if (! m_txBuffer.empty ())
226  {
229  }
230 }
231 
232 } // 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:150
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
Definition: lte-rlc-tm.h:61
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual void DoNotifyHarqDeliveryFailure()
Definition: lte-rlc-tm.cc:164
void ExpireRbsTimer(void)
Definition: lte-rlc-tm.cc:221
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:824
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:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
void DoReportBufferStatus()
Definition: lte-rlc-tm.cc:192
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:792
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
Definition: lte-mac-sap.h:72
uint16_t m_rnti
Definition: lte-rlc.h:144
uint8_t m_lcid
Definition: lte-rlc.h:145
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-mac-sap.h:68
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:66
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
Definition: lte-mac-sap.h:71
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:846
LteRlcSapUser * m_rlcSapUser
Definition: lte-rlc.h:133
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1238
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:838
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:119
LteMacSapProvider * m_macSapProvider
Definition: lte-rlc.h:142
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
LTE RLC Transparent Mode (TM), see 3GPP TS 36.322.
Definition: lte-rlc-tm.h:35
EventId m_rbsTimer
Definition: lte-rlc-tm.h:64
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
std::vector< Ptr< Packet > > m_txBuffer
Definition: lte-rlc-tm.h:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Definition: lte-rlc-tm.cc:47
Time GetSenderTimestamp(void) const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
Definition: lte-rlc-tag.h:60
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-mac-sap.h:69
uint32_t txQueueSize
the current size of the RLC transmission queue
Definition: lte-mac-sap.h:70
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:224
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:353
virtual void DoReceivePdu(Ptr< Packet > p)
Definition: lte-rlc-tm.cc:170
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
Definition: lte-mac-sap.h:74
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:831
uint32_t m_maxTxBufferSize
Definition: lte-rlc-tm.h:60
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
Definition: lte-mac-sap.h:73
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:154
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
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:345
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId)
MAC SAP.
Definition: lte-rlc-tm.cc:114
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45