A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-pdcp.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Manuel Requena <manuel.requena@cttc.es>
18 */
19
20#include "lte-pdcp.h"
21
22#include "lte-pdcp-header.h"
23#include "lte-pdcp-sap.h"
24#include "lte-pdcp-tag.h"
25
26#include "ns3/log.h"
27#include "ns3/simulator.h"
28
29namespace ns3
30{
31
33
34/// LtePdcpSpecificLteRlcSapUser class
36{
37 public:
38 /**
39 * Constructor
40 *
41 * \param pdcp PDCP
42 */
44
45 // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
46 void ReceivePdcpPdu(Ptr<Packet> p) override;
47
48 private:
50 LtePdcp* m_pdcp; ///< the PDCP
51};
52
54 : m_pdcp(pdcp)
55{
56}
57
59{
60}
61
62void
64{
66}
67
68///////////////////////////////////////
69
71
73 : m_pdcpSapUser(nullptr),
74 m_rlcSapProvider(nullptr),
75 m_rnti(0),
76 m_lcid(0),
77 m_txSequenceNumber(0),
78 m_rxSequenceNumber(0)
79{
80 NS_LOG_FUNCTION(this);
83}
84
86{
87 NS_LOG_FUNCTION(this);
88}
89
92{
93 static TypeId tid = TypeId("ns3::LtePdcp")
95 .SetGroupName("Lte")
96 .AddTraceSource("TxPDU",
97 "PDU transmission notified to the RLC.",
99 "ns3::LtePdcp::PduTxTracedCallback")
100 .AddTraceSource("RxPDU",
101 "PDU received.",
103 "ns3::LtePdcp::PduRxTracedCallback");
104 return tid;
105}
106
107void
109{
110 NS_LOG_FUNCTION(this);
111 delete (m_pdcpSapProvider);
112 delete (m_rlcSapUser);
113}
114
115void
116LtePdcp::SetRnti(uint16_t rnti)
117{
118 NS_LOG_FUNCTION(this << (uint32_t)rnti);
119 m_rnti = rnti;
120}
121
122void
123LtePdcp::SetLcId(uint8_t lcId)
124{
125 NS_LOG_FUNCTION(this << (uint32_t)lcId);
126 m_lcid = lcId;
127}
128
129void
131{
132 NS_LOG_FUNCTION(this << s);
133 m_pdcpSapUser = s;
134}
135
138{
139 NS_LOG_FUNCTION(this);
140 return m_pdcpSapProvider;
141}
142
143void
145{
146 NS_LOG_FUNCTION(this << s);
148}
149
152{
153 NS_LOG_FUNCTION(this);
154 return m_rlcSapUser;
155}
156
159{
160 Status s;
163 return s;
164}
165
166void
168{
171}
172
173////////////////////////////////////////
174
175void
177{
178 NS_LOG_FUNCTION(this << m_rnti << static_cast<uint16_t>(m_lcid) << params.pdcpSdu->GetSize());
179 Ptr<Packet> p = params.pdcpSdu;
180
181 // Sender timestamp
182 PdcpTag pdcpTag(Simulator::Now());
183
184 LtePdcpHeader pdcpHeader;
186
189 {
191 }
192
194 p->AddHeader(pdcpHeader);
195 p->AddByteTag(pdcpTag, 1, pdcpHeader.GetSerializedSize());
196
197 m_txPdu(m_rnti, m_lcid, p->GetSize());
198
200 txParams.rnti = m_rnti;
201 txParams.lcid = m_lcid;
202 txParams.pdcpPdu = p;
203
204 NS_LOG_INFO("Transmitting PDCP PDU with header: " << pdcpHeader);
206}
207
208void
210{
211 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << p->GetSize());
212
213 // Receiver timestamp
214 PdcpTag pdcpTag;
215 Time delay;
216 p->FindFirstMatchingByteTag(pdcpTag);
217 delay = Simulator::Now() - pdcpTag.GetSenderTimestamp();
218 m_rxPdu(m_rnti, m_lcid, p->GetSize(), delay.GetNanoSeconds());
219
220 LtePdcpHeader pdcpHeader;
221 p->RemoveHeader(pdcpHeader);
222 NS_LOG_LOGIC("PDCP header: " << pdcpHeader);
223
224 m_rxSequenceNumber = pdcpHeader.GetSequenceNumber() + 1;
226 {
228 }
229
231 params.pdcpSdu = p;
232 params.rnti = m_rnti;
233 params.lcid = m_lcid;
235}
236
237} // namespace ns3
The packet header for the Packet Data Convergence Protocol (PDCP) packets.
uint16_t GetSequenceNumber() const
Get sequence number.
void SetDcBit(uint8_t dcBit)
Set DC bit.
uint32_t GetSerializedSize() const override
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number.
LTE PDCP entity, see 3GPP TS 36.323.
Definition: lte-pdcp.h:37
uint16_t m_rxSequenceNumber
State variables.
Definition: lte-pdcp.h:187
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition: lte-pdcp.cc:130
LteRlcSapUser * GetLteRlcSapUser()
Definition: lte-pdcp.cc:151
LtePdcpSapUser * m_pdcpSapUser
PDCP SAP user.
Definition: lte-pdcp.h:152
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition: lte-pdcp.cc:137
virtual void DoReceivePdu(Ptr< Packet > p)
Interface provided to lower RLC entity.
Definition: lte-pdcp.cc:209
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition: lte-pdcp.h:162
uint8_t m_lcid
LCID.
Definition: lte-pdcp.h:166
~LtePdcp() override
Definition: lte-pdcp.cc:85
uint16_t m_txSequenceNumber
State variables.
Definition: lte-pdcp.h:183
void SetStatus(Status s)
Set the status of the PDCP.
Definition: lte-pdcp.cc:167
friend class LtePdcpSpecificLtePdcpSapProvider< LtePdcp >
allow LtePdcpSpecificLtePdcpSapProvider<LtePdcp> class friend access
Definition: lte-pdcp.h:41
virtual void DoTransmitPdcpSdu(LtePdcpSapProvider::TransmitPdcpSduParameters params)
Interface provided to upper RRC entity.
Definition: lte-pdcp.cc:176
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition: lte-pdcp.h:163
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the RLC SAP user.
Definition: lte-pdcp.h:177
static const uint16_t m_maxPdcpSn
Constants.
Definition: lte-pdcp.h:192
void SetRnti(uint16_t rnti)
Definition: lte-pdcp.cc:116
friend class LtePdcpSpecificLteRlcSapUser
allow LtePdcpSpecificLteRlcSapUser class friend access
Definition: lte-pdcp.h:39
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
Used to inform of a PDU delivery to the RLC SAP provider.
Definition: lte-pdcp.h:172
LtePdcpSapProvider * m_pdcpSapProvider
PDCP SAP provider.
Definition: lte-pdcp.h:153
Status GetStatus() const
Definition: lte-pdcp.cc:158
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Definition: lte-pdcp.cc:144
void DoDispose() override
Destructor implementation.
Definition: lte-pdcp.cc:108
void SetLcId(uint8_t lcId)
Definition: lte-pdcp.cc:123
uint16_t m_rnti
RNTI.
Definition: lte-pdcp.h:165
static TypeId GetTypeId()
Get the type ID.
Definition: lte-pdcp.cc:91
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36....
Definition: lte-pdcp-sap.h:36
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36....
Definition: lte-pdcp-sap.h:69
virtual void ReceivePdcpSdu(ReceivePdcpSduParameters params)=0
Called by the PDCP entity to notify the RRC entity of the reception of a new RRC PDU.
LtePdcpSpecificLteRlcSapUser class.
Definition: lte-pdcp.cc:36
void ReceivePdcpPdu(Ptr< Packet > p) override
Called by the RLC entity to notify the PDCP entity of the reception of a new PDCP PDU.
Definition: lte-pdcp.cc:63
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:36
virtual void TransmitPdcpPdu(TransmitPdcpPduParameters params)=0
Send a PDCP PDU to the RLC for transmission This method is to be called when upper PDCP entity has a ...
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
A base class which provides memory management and object aggregation.
Definition: object.h:89
Tag to calculate the per-PDU delay from eNb PDCP to UE PDCP.
Definition: lte-pdcp-tag.h:37
Time GetSenderTimestamp() const
Get the instant when the PDCP delivers the PDU to the MAC SAP provider.
Definition: lte-pdcp-tag.cc:86
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:418
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Status variables of the PDCP.
Definition: lte-pdcp.h:102
uint16_t rxSn
RX sequence number.
Definition: lte-pdcp.h:104
uint16_t txSn
TX sequence number.
Definition: lte-pdcp.h:103
Parameters for LtePdcpSapProvider::TransmitPdcpSdu.
Definition: lte-pdcp-sap.h:44
Parameters for LtePdcpSapUser::ReceivePdcpSdu.
Definition: lte-pdcp-sap.h:77
Parameters for LteRlcSapProvider::TransmitPdcpPdu.
Definition: lte-rlc-sap.h:44
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-rlc-sap.h:47
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-rlc-sap.h:46