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 
34 {
35 public:
37 
38  // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
39  virtual void ReceivePdcpPdu (Ptr<Packet> p);
40 
41 private:
44 };
45 
47  : m_pdcp (pdcp)
48 {
49 }
50 
52 {
53 }
54 
55 void
57 {
58  m_pdcp->DoReceivePdu (p);
59 }
60 
62 
64 
66  : m_pdcpSapUser (0),
67  m_rlcSapProvider (0),
68  m_rnti (0),
69  m_lcid (0),
70  m_txSequenceNumber (0),
71  m_rxSequenceNumber (0)
72 {
73  NS_LOG_FUNCTION (this);
76 }
77 
79 {
80  NS_LOG_FUNCTION (this);
81 }
82 
83 TypeId
85 {
86  static TypeId tid = TypeId ("ns3::LtePdcp")
87  .SetParent<Object> ()
88  .SetGroupName("Lte")
89  .AddTraceSource ("TxPDU",
90  "PDU transmission notified to the RLC.",
92  "ns3::LtePdcp::PduTxTracedCallback")
93  .AddTraceSource ("RxPDU",
94  "PDU received.",
96  "ns3::LtePdcp::PduRxTracedCallback")
97  ;
98  return tid;
99 }
100 
101 void
103 {
104  NS_LOG_FUNCTION (this);
105  delete (m_pdcpSapProvider);
106  delete (m_rlcSapUser);
107 }
108 
109 
110 void
111 LtePdcp::SetRnti (uint16_t rnti)
112 {
113  NS_LOG_FUNCTION (this << (uint32_t) rnti);
114  m_rnti = rnti;
115 }
116 
117 void
118 LtePdcp::SetLcId (uint8_t lcId)
119 {
120  NS_LOG_FUNCTION (this << (uint32_t) lcId);
121  m_lcid = lcId;
122 }
123 
124 void
126 {
127  NS_LOG_FUNCTION (this << s);
128  m_pdcpSapUser = s;
129 }
130 
133 {
134  NS_LOG_FUNCTION (this);
135  return m_pdcpSapProvider;
136 }
137 
138 void
140 {
141  NS_LOG_FUNCTION (this << s);
142  m_rlcSapProvider = s;
143 }
144 
147 {
148  NS_LOG_FUNCTION (this);
149  return m_rlcSapUser;
150 }
151 
154 {
155  Status s;
158  return s;
159 }
160 
161 void
163 {
166 }
167 
169 
170 void
172 {
173  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
174 
175  LtePdcpHeader pdcpHeader;
177 
180  {
181  m_txSequenceNumber = 0;
182  }
183 
184  pdcpHeader.SetDcBit (LtePdcpHeader::DATA_PDU);
185 
186  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
187  p->AddHeader (pdcpHeader);
188 
189  // Sender timestamp
190  PdcpTag pdcpTag (Simulator::Now ());
191  p->AddPacketTag (pdcpTag);
192  m_txPdu (m_rnti, m_lcid, p->GetSize ());
193 
195  params.rnti = m_rnti;
196  params.lcid = m_lcid;
197  params.pdcpPdu = p;
198 
200 }
201 
202 void
204 {
205  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
206 
207  // Receiver timestamp
208  PdcpTag pdcpTag;
209  Time delay;
210  NS_ASSERT_MSG (p->PeekPacketTag (pdcpTag), "PdcpTag is missing");
211  p->RemovePacketTag (pdcpTag);
212  delay = Simulator::Now() - pdcpTag.GetSenderTimestamp ();
213  m_rxPdu(m_rnti, m_lcid, p->GetSize (), delay.GetNanoSeconds ());
214 
215  LtePdcpHeader pdcpHeader;
216  p->RemoveHeader (pdcpHeader);
217  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
218 
219  m_rxSequenceNumber = pdcpHeader.GetSequenceNumber () + 1;
221  {
222  m_rxSequenceNumber = 0;
223  }
224 
226  params.pdcpSdu = p;
227  params.rnti = m_rnti;
228  params.lcid = m_lcid;
229  m_pdcpSapUser->ReceivePdcpSdu (params);
230 }
231 
232 
233 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
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:66
LteRlcSapProvider * m_rlcSapProvider
Definition: lte-pdcp.h:149
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint16_t m_rnti
Definition: lte-pdcp.h:151
#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)
Definition: lte-pdcp.cc:203
LteRlcSapUser * GetLteRlcSapUser()
Definition: lte-pdcp.cc:146
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition: lte-pdcp.cc:125
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)
Definition: lte-pdcp.cc:84
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
uint16_t txSn
TX sequence number.
Definition: lte-pdcp.h:97
Status variables of the PDCP.
Definition: lte-pdcp.h:95
LtePdcpSapProvider * m_pdcpSapProvider
Definition: lte-pdcp.h:143
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:824
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:792
uint16_t m_txSequenceNumber
State variables.
Definition: lte-pdcp.h:169
uint16_t m_rxSequenceNumber
Definition: lte-pdcp.h:170
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:162
Parameters for LtePdcpSapUser::ReceivePdcpSdu.
Definition: lte-pdcp-sap.h:76
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:846
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:158
virtual ~LtePdcp()
Definition: lte-pdcp.cc:78
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition: lte-pdcp.cc:132
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:139
uint16_t rxSn
RX sequence number.
Definition: lte-pdcp.h:98
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
virtual void DoTransmitPdcpSdu(Ptr< Packet > p)
Definition: lte-pdcp.cc:171
void SetLcId(uint8_t lcId)
Definition: lte-pdcp.cc:118
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetRnti(uint16_t rnti)
Definition: lte-pdcp.cc:111
virtual void DoDispose()
Destructor implementation.
Definition: lte-pdcp.cc:102
LteRlcSapUser * m_rlcSapUser
Definition: lte-pdcp.h:148
friend class LtePdcpSpecificLteRlcSapUser
Definition: lte-pdcp.h:39
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:224
virtual void ReceivePdcpSdu(ReceivePdcpSduParameters params)=0
Called by the PDCP entity to notify the RRC entity of the reception of a new RRC PDU.
Parameters for LteRlcSapProvider::TransmitPdcpPdu.
Definition: lte-rlc-sap.h:43
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:353
uint8_t m_lcid
Definition: lte-pdcp.h:152
Status GetStatus()
Definition: lte-pdcp.cc:153
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
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:831
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:56
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-pdcp-sap.h:80
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:163
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-rlc-sap.h:46
LtePdcpSapUser * m_pdcpSapUser
Definition: lte-pdcp.h:142
static const uint16_t m_maxPdcpSn
Constants.
Definition: lte-pdcp.h:175
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
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:257
void SetSequenceNumber(uint16_t sequenceNumber)