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 << (uint32_t) m_lcid << p->GetSize ());
180 
181  LtePdcpHeader pdcpHeader;
183 
186  {
187  m_txSequenceNumber = 0;
188  }
189 
190  pdcpHeader.SetDcBit (LtePdcpHeader::DATA_PDU);
191 
192  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
193  p->AddHeader (pdcpHeader);
194 
195  // Sender timestamp
196  PdcpTag pdcpTag (Simulator::Now ());
197  p->AddPacketTag (pdcpTag);
198  m_txPdu (m_rnti, m_lcid, p->GetSize ());
199 
201  params.rnti = m_rnti;
202  params.lcid = m_lcid;
203  params.pdcpPdu = p;
204 
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  NS_ASSERT_MSG (p->PeekPacketTag (pdcpTag), "PdcpTag is missing");
217  p->RemovePacketTag (pdcpTag);
218  delay = Simulator::Now() - pdcpTag.GetSenderTimestamp ();
219  m_rxPdu(m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds ());
220 
221  LtePdcpHeader pdcpHeader;
222  p->RemoveHeader (pdcpHeader);
223  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
224 
225  m_rxSequenceNumber = pdcpHeader.GetSequenceNumber () + 1;
227  {
228  m_rxSequenceNumber = 0;
229  }
230 
232  params.pdcpSdu = p;
233  params.rnti = m_rnti;
234  params.lcid = m_lcid;
235  m_pdcpSapUser->ReceivePdcpSdu (params);
236 }
237 
238 
239 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
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
LteRlcSapProvider * m_rlcSapProvider
RLC SAP provider.
Definition: lte-pdcp.h:163
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint16_t m_rnti
RNTI.
Definition: lte-pdcp.h:165
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void DoReceivePdu(Ptr< Packet > p)
Interface provided to lower RLC entity.
Definition: lte-pdcp.cc:209
LteRlcSapUser * GetLteRlcSapUser()
Definition: lte-pdcp.cc:152
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition: lte-pdcp.cc:131
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:35
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-pdcp.cc:90
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint16_t txSn
TX sequence number.
Definition: lte-pdcp.h:103
Status variables of the PDCP.
Definition: lte-pdcp.h:101
LtePdcpSapProvider * m_pdcpSapProvider
PDCP SAP provider.
Definition: lte-pdcp.h:153
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
uint16_t m_txSequenceNumber
State variables.
Definition: lte-pdcp.h:183
uint16_t m_rxSequenceNumber
State variables.
Definition: lte-pdcp.h:187
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 ...
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void SetStatus(Status s)
Set the status of the PDCP.
Definition: lte-pdcp.cc:168
Parameters for LtePdcpSapUser::ReceivePdcpSdu.
Definition: lte-pdcp-sap.h:76
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-pdcp-sap.h:79
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
virtual ~LtePdcp()
Definition: lte-pdcp.cc:84
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition: lte-pdcp.cc:138
Tag to calculate the per-PDU delay from eNb PDCP to UE PDCP.
Definition: lte-pdcp-tag.h:37
void SetLteRlcSapProvider(LteRlcSapProvider *s)
Definition: lte-pdcp.cc:145
uint16_t rxSn
RX sequence number.
Definition: lte-pdcp.h:104
virtual void DoTransmitPdcpSdu(Ptr< Packet > p)
Interface provided to upper RRC entity.
Definition: lte-pdcp.cc:177
void SetLcId(uint8_t lcId)
Definition: lte-pdcp.cc:124
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
void SetRnti(uint16_t rnti)
Definition: lte-pdcp.cc:117
virtual void DoDispose()
Destructor implementation.
Definition: lte-pdcp.cc:108
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
Definition: lte-pdcp.h:162
friend class LtePdcpSpecificLteRlcSapUser
allow LtePdcpSpecificLteRlcSapUser class friend access
Definition: lte-pdcp.h:40
LTE PDCP entity, see 3GPP TS 36.323.
Definition: lte-pdcp.h:37
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual void ReceivePdcpSdu(ReceivePdcpSduParameters params)=0
Called by the PDCP entity to notify the RRC entity of the reception of a new RRC PDU.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Parameters for LteRlcSapProvider::TransmitPdcpPdu.
Definition: lte-rlc-sap.h:43
LtePdcp * m_pdcp
the PDCP
Definition: lte-pdcp.cc:49
uint8_t m_lcid
LCID.
Definition: lte-pdcp.h:166
Status GetStatus()
Definition: lte-pdcp.cc:159
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36.323 Packet Data Convergence Protocol (PDCP) specification.
Definition: lte-pdcp-sap.h:35
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36.323 Packet Data Convergence Protocol (PDCP) specification.
Definition: lte-pdcp-sap.h:68
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:859
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
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-pdcp-sap.h:80
LtePdcpSpecificLteRlcSapUser class.
Definition: lte-pdcp.cc:34
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
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-rlc-sap.h:46
LtePdcpSapUser * m_pdcpSapUser
PDCP SAP user.
Definition: lte-pdcp.h:152
static const uint16_t m_maxPdcpSn
Constants.
Definition: lte-pdcp.h:192
The packet header for the Packet Data Convergence Protocol (PDCP) packets.
A base class which provides memory management and object aggregation.
Definition: object.h:87
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:874
a unique identifier for an interface.
Definition: type-id.h:58
LtePdcpSpecificLtePdcpSapProvider class.
Definition: lte-pdcp-sap.h:94
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number.