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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 */
8
9#include "lte-pdcp.h"
10
11#include "lte-pdcp-header.h"
12#include "lte-pdcp-sap.h"
13#include "lte-pdcp-tag.h"
14
15#include "ns3/log.h"
16#include "ns3/simulator.h"
17
18namespace ns3
19{
20
22
23/// LtePdcpSpecificLteRlcSapUser class
25{
26 public:
27 /**
28 * Constructor
29 *
30 * \param pdcp PDCP
31 */
33
34 // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
35 void ReceivePdcpPdu(Ptr<Packet> p) override;
36
37 private:
39 LtePdcp* m_pdcp; ///< the PDCP
40};
41
46
50
51void
56
57///////////////////////////////////////
58
60
62 : m_pdcpSapUser(nullptr),
63 m_rlcSapProvider(nullptr),
64 m_rnti(0),
65 m_lcid(0),
66 m_txSequenceNumber(0),
67 m_rxSequenceNumber(0)
68{
69 NS_LOG_FUNCTION(this);
72}
73
78
81{
82 static TypeId tid = TypeId("ns3::LtePdcp")
84 .SetGroupName("Lte")
85 .AddTraceSource("TxPDU",
86 "PDU transmission notified to the RLC.",
88 "ns3::LtePdcp::PduTxTracedCallback")
89 .AddTraceSource("RxPDU",
90 "PDU received.",
92 "ns3::LtePdcp::PduRxTracedCallback");
93 return tid;
94}
95
96void
98{
99 NS_LOG_FUNCTION(this);
100 delete (m_pdcpSapProvider);
101 delete (m_rlcSapUser);
102}
103
104void
105LtePdcp::SetRnti(uint16_t rnti)
106{
107 NS_LOG_FUNCTION(this << (uint32_t)rnti);
108 m_rnti = rnti;
109}
110
111void
112LtePdcp::SetLcId(uint8_t lcId)
113{
114 NS_LOG_FUNCTION(this << (uint32_t)lcId);
115 m_lcid = lcId;
116}
117
118void
124
131
132void
138
141{
142 NS_LOG_FUNCTION(this);
143 return m_rlcSapUser;
144}
145
148{
149 Status s;
152 return s;
153}
154
155void
161
162////////////////////////////////////////
163
164void
166{
167 NS_LOG_FUNCTION(this << m_rnti << static_cast<uint16_t>(m_lcid) << params.pdcpSdu->GetSize());
168 Ptr<Packet> p = params.pdcpSdu;
169
170 // Sender timestamp
171 PdcpTag pdcpTag(Simulator::Now());
172
173 LtePdcpHeader pdcpHeader;
175
178 {
180 }
181
183 p->AddHeader(pdcpHeader);
184 p->AddByteTag(pdcpTag, 1, pdcpHeader.GetSerializedSize());
185
186 m_txPdu(m_rnti, m_lcid, p->GetSize());
187
189 txParams.rnti = m_rnti;
190 txParams.lcid = m_lcid;
191 txParams.pdcpPdu = p;
192
193 NS_LOG_INFO("Transmitting PDCP PDU with header: " << pdcpHeader);
195}
196
197void
199{
200 NS_LOG_FUNCTION(this << m_rnti << (uint32_t)m_lcid << p->GetSize());
201
202 // Receiver timestamp
203 PdcpTag pdcpTag;
204 Time delay;
205 p->FindFirstMatchingByteTag(pdcpTag);
206 delay = Simulator::Now() - pdcpTag.GetSenderTimestamp();
207 m_rxPdu(m_rnti, m_lcid, p->GetSize(), delay.GetNanoSeconds());
208
209 LtePdcpHeader pdcpHeader;
210 p->RemoveHeader(pdcpHeader);
211 NS_LOG_LOGIC("PDCP header: " << pdcpHeader);
212
213 m_rxSequenceNumber = pdcpHeader.GetSequenceNumber() + 1;
215 {
217 }
218
220 params.pdcpSdu = p;
221 params.rnti = m_rnti;
222 params.lcid = m_lcid;
224}
225
226} // 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:26
uint16_t m_rxSequenceNumber
State variables.
Definition lte-pdcp.h:176
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition lte-pdcp.cc:119
LteRlcSapUser * GetLteRlcSapUser()
Definition lte-pdcp.cc:140
LtePdcpSapUser * m_pdcpSapUser
PDCP SAP user.
Definition lte-pdcp.h:141
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition lte-pdcp.cc:126
virtual void DoReceivePdu(Ptr< Packet > p)
Interface provided to lower RLC entity.
Definition lte-pdcp.cc:198
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition lte-pdcp.h:151
uint8_t m_lcid
LCID.
Definition lte-pdcp.h:155
~LtePdcp() override
Definition lte-pdcp.cc:74
uint16_t m_txSequenceNumber
State variables.
Definition lte-pdcp.h:172
void SetStatus(Status s)
Set the status of the PDCP.
Definition lte-pdcp.cc:156
friend class LtePdcpSpecificLtePdcpSapProvider< LtePdcp >
allow LtePdcpSpecificLtePdcpSapProvider<LtePdcp> class friend access
Definition lte-pdcp.h:30
virtual void DoTransmitPdcpSdu(LtePdcpSapProvider::TransmitPdcpSduParameters params)
Interface provided to upper RRC entity.
Definition lte-pdcp.cc:165
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition lte-pdcp.h:152
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:166
static const uint16_t m_maxPdcpSn
Constants.
Definition lte-pdcp.h:181
void SetRnti(uint16_t rnti)
Definition lte-pdcp.cc:105
friend class LtePdcpSpecificLteRlcSapUser
allow LtePdcpSpecificLteRlcSapUser class friend access
Definition lte-pdcp.h:28
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:161
LtePdcpSapProvider * m_pdcpSapProvider
PDCP SAP provider.
Definition lte-pdcp.h:142
Status GetStatus() const
Definition lte-pdcp.cc:147
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Definition lte-pdcp.cc:133
void DoDispose() override
Destructor implementation.
Definition lte-pdcp.cc:97
void SetLcId(uint8_t lcId)
Definition lte-pdcp.cc:112
uint16_t m_rnti
RNTI.
Definition lte-pdcp.h:154
static TypeId GetTypeId()
Get the type ID.
Definition lte-pdcp.cc:80
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36....
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36....
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:25
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:52
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:25
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:56
A base class which provides memory management and object aggregation.
Definition object.h:78
Tag to calculate the per-PDU delay from eNb PDCP to UE PDCP.
Time GetSenderTimestamp() const
Get the instant when the PDCP delivers the PDU to the MAC SAP provider.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:407
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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:264
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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:91
uint16_t rxSn
RX sequence number.
Definition lte-pdcp.h:93
uint16_t txSn
TX sequence number.
Definition lte-pdcp.h:92
Parameters for LtePdcpSapProvider::TransmitPdcpSdu.
Parameters for LtePdcpSapUser::ReceivePdcpSdu.
Parameters for LteRlcSapProvider::TransmitPdcpPdu.
Definition lte-rlc-sap.h:33
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition lte-rlc-sap.h:36
uint16_t rnti
the C-RNTI identifying the UE
Definition lte-rlc-sap.h:35