A Discrete-Event Network Simulator
API
lte-pdcp.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  */
20 
21 #include "ns3/log.h"
22 #include "ns3/simulator.h"
23 
24 #include "ns3/lte-pdcp.h"
25 #include "ns3/lte-pdcp-header.h"
26 #include "ns3/lte-pdcp-sap.h"
27 #include "ns3/lte-pdcp-tag.h"
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("LtePdcp");
32 
35 {
36 public:
43 
44  // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
45  virtual void ReceivePdcpPdu (Ptr<Packet> p);
46 
47 private:
50 };
51 
53  : m_pdcp (pdcp)
54 {
55 }
56 
58 {
59 }
60 
61 void
63 {
64  m_pdcp->DoReceivePdu (p);
65 }
66 
68 
70 
72  : m_pdcpSapUser (0),
73  m_rlcSapProvider (0),
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 
89 TypeId
91 {
92  static TypeId tid = TypeId ("ns3::LtePdcp")
93  .SetParent<Object> ()
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  ;
104  return tid;
105 }
106 
107 void
109 {
110  NS_LOG_FUNCTION (this);
111  delete (m_pdcpSapProvider);
112  delete (m_rlcSapUser);
113 }
114 
115 
116 void
117 LtePdcp::SetRnti (uint16_t rnti)
118 {
119  NS_LOG_FUNCTION (this << (uint32_t) rnti);
120  m_rnti = rnti;
121 }
122 
123 void
124 LtePdcp::SetLcId (uint8_t lcId)
125 {
126  NS_LOG_FUNCTION (this << (uint32_t) lcId);
127  m_lcid = lcId;
128 }
129 
130 void
132 {
133  NS_LOG_FUNCTION (this << s);
134  m_pdcpSapUser = s;
135 }
136 
139 {
140  NS_LOG_FUNCTION (this);
141  return m_pdcpSapProvider;
142 }
143 
144 void
146 {
147  NS_LOG_FUNCTION (this << s);
148  m_rlcSapProvider = s;
149 }
150 
153 {
154  NS_LOG_FUNCTION (this);
155  return m_rlcSapUser;
156 }
157 
160 {
161  Status s;
164  return s;
165 }
166 
167 void
169 {
172 }
173 
175 
176 void
178 {
179  NS_LOG_FUNCTION (this << m_rnti << static_cast <uint16_t> (m_lcid) << params.pdcpSdu->GetSize ());
180  Ptr<Packet> p = params.pdcpSdu;
181 
182  // Sender timestamp
183  PdcpTag pdcpTag (Simulator::Now ());
184 
185  LtePdcpHeader pdcpHeader;
187 
190  {
191  m_txSequenceNumber = 0;
192  }
193 
194  pdcpHeader.SetDcBit (LtePdcpHeader::DATA_PDU);
195 
196  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
197  p->AddHeader (pdcpHeader);
198  p->AddByteTag (pdcpTag, 1, pdcpHeader.GetSerializedSize ());
199 
200  m_txPdu (m_rnti, m_lcid, p->GetSize ());
201 
203  txParams.rnti = m_rnti;
204  txParams.lcid = m_lcid;
205  txParams.pdcpPdu = p;
206 
207  m_rlcSapProvider->TransmitPdcpPdu (txParams);
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
214 
215  // Receiver timestamp
216  PdcpTag pdcpTag;
217  Time delay;
218  p->FindFirstMatchingByteTag (pdcpTag);
219  delay = Simulator::Now() - pdcpTag.GetSenderTimestamp ();
220  m_rxPdu(m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds ());
221 
222  LtePdcpHeader pdcpHeader;
223  p->RemoveHeader (pdcpHeader);
224  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
225 
226  m_rxSequenceNumber = pdcpHeader.GetSequenceNumber () + 1;
228  {
229  m_rxSequenceNumber = 0;
230  }
231 
233  params.pdcpSdu = p;
234  params.rnti = m_rnti;
235  params.lcid = m_lcid;
236  m_pdcpSapUser->ReceivePdcpSdu (params);
237 }
238 
239 
240 } // 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.
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number.
virtual uint32_t GetSerializedSize(void) const
LTE PDCP entity, see 3GPP TS 36.323.
Definition: lte-pdcp.h:38
uint16_t m_rxSequenceNumber
State variables.
Definition: lte-pdcp.h:187
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition: lte-pdcp.cc:131
LteRlcSapUser * GetLteRlcSapUser()
Definition: lte-pdcp.cc:152
virtual void DoDispose()
Destructor implementation.
Definition: lte-pdcp.cc:108
LtePdcpSapUser * m_pdcpSapUser
PDCP SAP user.
Definition: lte-pdcp.h:152
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition: lte-pdcp.cc:138
virtual void DoReceivePdu(Ptr< Packet > p)
Interface provided to lower RLC entity.
Definition: lte-pdcp.cc:211
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition: lte-pdcp.h:162
uint8_t m_lcid
LCID.
Definition: lte-pdcp.h:166
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:168
friend class LtePdcpSpecificLtePdcpSapProvider< LtePdcp >
allow LtePdcpSpecificLtePdcpSapProvider<LtePdcp> class friend access
Definition: lte-pdcp.h:42
virtual void DoTransmitPdcpSdu(LtePdcpSapProvider::TransmitPdcpSduParameters params)
Interface provided to upper RRC entity.
Definition: lte-pdcp.cc:177
virtual ~LtePdcp()
Definition: lte-pdcp.cc:84
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:117
friend class LtePdcpSpecificLteRlcSapUser
allow LtePdcpSpecificLteRlcSapUser class friend access
Definition: lte-pdcp.h:40
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
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Definition: lte-pdcp.cc:145
Status GetStatus()
Definition: lte-pdcp.cc:159
void SetLcId(uint8_t lcId)
Definition: lte-pdcp.cc:124
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-pdcp.cc:90
uint16_t m_rnti
RNTI.
Definition: lte-pdcp.h:165
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:70
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
virtual void ReceivePdcpPdu(Ptr< Packet > p)
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:68
A base class which provides memory management and object aggregation.
Definition: object.h:88
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:939
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:912
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Tag to calculate the per-PDU delay from eNb PDCP to UE PDCP.
Definition: lte-pdcp-tag.h:38
Time GetSenderTimestamp(void) const
Get the instant when the PDCP delivers the PDU to the MAC SAP provider.
Definition: lte-pdcp-tag.cc:89
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:391
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#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:45
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:78
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-pdcp-sap.h:81
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-pdcp-sap.h:80
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