A Discrete-Event Network Simulator
API
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 
29 namespace ns3
30 {
31 
32 NS_LOG_COMPONENT_DEFINE("LtePdcp");
33 
36 {
37  public:
44 
45  // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
46  void ReceivePdcpPdu(Ptr<Packet> p) override;
47 
48  private:
51 };
52 
54  : m_pdcp(pdcp)
55 {
56 }
57 
59 {
60 }
61 
62 void
64 {
65  m_pdcp->DoReceivePdu(p);
66 }
67 
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 
90 TypeId
92 {
93  static TypeId tid = TypeId("ns3::LtePdcp")
94  .SetParent<Object>()
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 
107 void
109 {
110  NS_LOG_FUNCTION(this);
111  delete (m_pdcpSapProvider);
112  delete (m_rlcSapUser);
113 }
114 
115 void
116 LtePdcp::SetRnti(uint16_t rnti)
117 {
118  NS_LOG_FUNCTION(this << (uint32_t)rnti);
119  m_rnti = rnti;
120 }
121 
122 void
123 LtePdcp::SetLcId(uint8_t lcId)
124 {
125  NS_LOG_FUNCTION(this << (uint32_t)lcId);
126  m_lcid = lcId;
127 }
128 
129 void
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 
143 void
145 {
146  NS_LOG_FUNCTION(this << s);
147  m_rlcSapProvider = s;
148 }
149 
152 {
153  NS_LOG_FUNCTION(this);
154  return m_rlcSapUser;
155 }
156 
159 {
160  Status s;
163  return s;
164 }
165 
166 void
168 {
171 }
172 
174 
175 void
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  {
190  m_txSequenceNumber = 0;
191  }
192 
193  pdcpHeader.SetDcBit(LtePdcpHeader::DATA_PDU);
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 
208 void
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  {
227  m_rxSequenceNumber = 0;
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
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:943
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:915
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
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:931
#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.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
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