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 "ns3/lte-pdcp.h"
21
22#include "ns3/log.h"
23#include "ns3/lte-pdcp-header.h"
24#include "ns3/lte-pdcp-sap.h"
25#include "ns3/lte-pdcp-tag.h"
26#include "ns3/simulator.h"
27
28namespace ns3
29{
30
32
35{
36 public:
43
44 // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
45 void ReceivePdcpPdu(Ptr<Packet> p) override;
46
47 private:
50};
51
53 : m_pdcp(pdcp)
54{
55}
56
58{
59}
60
61void
63{
65}
66
68
70
72 : m_pdcpSapUser(nullptr),
73 m_rlcSapProvider(nullptr),
74 m_rnti(0),
75 m_lcid(0),
76 m_txSequenceNumber(0),
77 m_rxSequenceNumber(0)
78{
79 NS_LOG_FUNCTION(this);
82}
83
85{
86 NS_LOG_FUNCTION(this);
87}
88
91{
92 static TypeId tid = TypeId("ns3::LtePdcp")
94 .SetGroupName("Lte")
95 .AddTraceSource("TxPDU",
96 "PDU transmission notified to the RLC.",
98 "ns3::LtePdcp::PduTxTracedCallback")
99 .AddTraceSource("RxPDU",
100 "PDU received.",
102 "ns3::LtePdcp::PduRxTracedCallback");
103 return tid;
104}
105
106void
108{
109 NS_LOG_FUNCTION(this);
110 delete (m_pdcpSapProvider);
111 delete (m_rlcSapUser);
112}
113
114void
115LtePdcp::SetRnti(uint16_t rnti)
116{
117 NS_LOG_FUNCTION(this << (uint32_t)rnti);
118 m_rnti = rnti;
119}
120
121void
122LtePdcp::SetLcId(uint8_t lcId)
123{
124 NS_LOG_FUNCTION(this << (uint32_t)lcId);
125 m_lcid = lcId;
126}
127
128void
130{
131 NS_LOG_FUNCTION(this << s);
132 m_pdcpSapUser = s;
133}
134
137{
138 NS_LOG_FUNCTION(this);
139 return m_pdcpSapProvider;
140}
141
142void
144{
145 NS_LOG_FUNCTION(this << s);
147}
148
151{
152 NS_LOG_FUNCTION(this);
153 return m_rlcSapUser;
154}
155
158{
159 Status s;
162 return s;
163}
164
165void
167{
170}
171
173
174void
176{
177 NS_LOG_FUNCTION(this << m_rnti << static_cast<uint16_t>(m_lcid) << params.pdcpSdu->GetSize());
178 Ptr<Packet> p = params.pdcpSdu;
179
180 // Sender timestamp
181 PdcpTag pdcpTag(Simulator::Now());
182
183 LtePdcpHeader pdcpHeader;
185
188 {
190 }
191
193
194 NS_LOG_LOGIC("PDCP header: " << pdcpHeader);
195 p->AddHeader(pdcpHeader);
196 p->AddByteTag(pdcpTag, 1, pdcpHeader.GetSerializedSize());
197
198 m_txPdu(m_rnti, m_lcid, p->GetSize());
199
201 txParams.rnti = m_rnti;
202 txParams.lcid = m_lcid;
203 txParams.pdcpPdu = p;
204
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:36
uint16_t m_rxSequenceNumber
State variables.
Definition: lte-pdcp.h:186
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition: lte-pdcp.cc:129
LteRlcSapUser * GetLteRlcSapUser()
Definition: lte-pdcp.cc:150
LtePdcpSapUser * m_pdcpSapUser
PDCP SAP user.
Definition: lte-pdcp.h:151
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition: lte-pdcp.cc:136
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:161
uint8_t m_lcid
LCID.
Definition: lte-pdcp.h:165
~LtePdcp() override
Definition: lte-pdcp.cc:84
uint16_t m_txSequenceNumber
State variables.
Definition: lte-pdcp.h:182
void SetStatus(Status s)
Set the status of the PDCP.
Definition: lte-pdcp.cc:166
friend class LtePdcpSpecificLtePdcpSapProvider< LtePdcp >
allow LtePdcpSpecificLtePdcpSapProvider<LtePdcp> class friend access
Definition: lte-pdcp.h:40
virtual void DoTransmitPdcpSdu(LtePdcpSapProvider::TransmitPdcpSduParameters params)
Interface provided to upper RRC entity.
Definition: lte-pdcp.cc:175
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition: lte-pdcp.h:162
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:176
static const uint16_t m_maxPdcpSn
Constants.
Definition: lte-pdcp.h:191
void SetRnti(uint16_t rnti)
Definition: lte-pdcp.cc:115
friend class LtePdcpSpecificLteRlcSapUser
allow LtePdcpSpecificLteRlcSapUser class friend access
Definition: lte-pdcp.h:38
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:171
LtePdcpSapProvider * m_pdcpSapProvider
PDCP SAP provider.
Definition: lte-pdcp.h:152
Status GetStatus() const
Definition: lte-pdcp.cc:157
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Definition: lte-pdcp.cc:143
void DoDispose() override
Destructor implementation.
Definition: lte-pdcp.cc:107
void SetLcId(uint8_t lcId)
Definition: lte-pdcp.cc:122
uint16_t m_rnti
RNTI.
Definition: lte-pdcp.h:164
static TypeId GetTypeId()
Get the type ID.
Definition: lte-pdcp.cc:90
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:35
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:62
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:78
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
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:417
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#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_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:101
uint16_t rxSn
RX sequence number.
Definition: lte-pdcp.h:103
uint16_t txSn
TX sequence number.
Definition: lte-pdcp.h:102
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