A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LtePdcp");
30 
31 namespace ns3 {
32 
33 
35 {
36 public:
38 
39  // Interface provided to lower RLC entity (implemented from LteRlcSapUser)
40  virtual void ReceivePdcpPdu (Ptr<Packet> p);
41 
42 private:
45 };
46 
48  : m_pdcp (pdcp)
49 {
50 }
51 
53 {
54 }
55 
56 void
58 {
59  m_pdcp->DoReceivePdu (p);
60 }
61 
63 
65  ;
66 
68  : m_pdcpSapUser (0),
69  m_rlcSapProvider (0),
70  m_rnti (0),
71  m_lcid (0),
72  m_txSequenceNumber (0),
73  m_rxSequenceNumber (0)
74 {
75  NS_LOG_FUNCTION (this);
78 }
79 
81 {
82  NS_LOG_FUNCTION (this);
83 }
84 
85 TypeId
87 {
88  static TypeId tid = TypeId ("ns3::LtePdcp")
89  .SetParent<Object> ()
90  .AddTraceSource ("TxPDU",
91  "PDU transmission notified to the RLC.",
93  .AddTraceSource ("RxPDU",
94  "PDU received.",
96  ;
97  return tid;
98 }
99 
100 void
102 {
103  NS_LOG_FUNCTION (this);
104  delete (m_pdcpSapProvider);
105  delete (m_rlcSapUser);
106 }
107 
108 
109 void
110 LtePdcp::SetRnti (uint16_t rnti)
111 {
112  NS_LOG_FUNCTION (this << (uint32_t) rnti);
113  m_rnti = rnti;
114 }
115 
116 void
117 LtePdcp::SetLcId (uint8_t lcId)
118 {
119  NS_LOG_FUNCTION (this << (uint32_t) lcId);
120  m_lcid = lcId;
121 }
122 
123 void
125 {
126  NS_LOG_FUNCTION (this << s);
127  m_pdcpSapUser = s;
128 }
129 
132 {
133  NS_LOG_FUNCTION (this);
134  return m_pdcpSapProvider;
135 }
136 
137 void
139 {
140  NS_LOG_FUNCTION (this << s);
142 }
143 
146 {
147  NS_LOG_FUNCTION (this);
148  return m_rlcSapUser;
149 }
150 
153 {
154  Status s;
157  return s;
158 }
159 
160 void
162 {
165 }
166 
168 
169 void
171 {
172  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
173 
174  LtePdcpHeader pdcpHeader;
176 
179  {
180  m_txSequenceNumber = 0;
181  }
182 
183  pdcpHeader.SetDcBit (LtePdcpHeader::DATA_PDU);
184 
185  NS_LOG_LOGIC ("PDCP header: " << pdcpHeader);
186  p->AddHeader (pdcpHeader);
187 
188  // Sender timestamp
189  PdcpTag pdcpTag (Simulator::Now ());
190  p->AddByteTag (pdcpTag);
191  m_txPdu (m_rnti, m_lcid, p->GetSize ());
192 
194  params.rnti = m_rnti;
195  params.lcid = m_lcid;
196  params.pdcpPdu = p;
197 
199 }
200 
201 void
203 {
204  NS_LOG_FUNCTION (this << m_rnti << (uint32_t) m_lcid << p->GetSize ());
205 
206  // Receiver timestamp
207  PdcpTag pdcpTag;
208  Time delay;
209  if (p->FindFirstMatchingByteTag (pdcpTag))
210  {
211  delay = Simulator::Now() - pdcpTag.GetSenderTimestamp ();
212  }
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:125
bool FindFirstMatchingByteTag(Tag &tag) const
Definition: packet.cc:824
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
uint16_t m_rnti
Definition: lte-pdcp.h:127
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
virtual void DoReceivePdu(Ptr< Packet > p)
Definition: lte-pdcp.cc:202
LteRlcSapUser * GetLteRlcSapUser()
Definition: lte-pdcp.cc:145
void SetLtePdcpSapUser(LtePdcpSapUser *s)
Definition: lte-pdcp.cc:124
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:86
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:119
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint32_t GetSize(void) const
Definition: packet.h:650
uint16_t m_txSequenceNumber
State variables.
Definition: lte-pdcp.h:145
uint16_t m_rxSequenceNumber
Definition: lte-pdcp.h:146
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 ...
void SetStatus(Status s)
Set the status of the PDCP.
Definition: lte-pdcp.cc:161
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:134
Ptr< SampleEmitter > s
virtual ~LtePdcp()
Definition: lte-pdcp.cc:80
LtePdcpSapProvider * GetLtePdcpSapProvider()
Definition: lte-pdcp.cc:131
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:138
uint16_t rxSn
RX sequence number.
Definition: lte-pdcp.h:98
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
virtual void DoTransmitPdcpSdu(Ptr< Packet > p)
Definition: lte-pdcp.cc:170
void SetLcId(uint8_t lcId)
Definition: lte-pdcp.cc:117
void SetRnti(uint16_t rnti)
Definition: lte-pdcp.cc:110
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-pdcp.cc:101
LteRlcSapUser * m_rlcSapUser
Definition: lte-pdcp.h:124
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 time".
Definition: simulator.cc:180
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
int64_t GetNanoSeconds(void) const
Definition: nstime.h:299
uint8_t m_lcid
Definition: lte-pdcp.h:128
Status GetStatus()
Definition: lte-pdcp.cc:152
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
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:57
NS_LOG_COMPONENT_DEFINE("LtePdcp")
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:139
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-rlc-sap.h:46
LtePdcpSapUser * m_pdcpSapUser
Definition: lte-pdcp.h:118
static const uint16_t m_maxPdcpSn
Constants.
Definition: lte-pdcp.h:151
The packet header for the Packet Data Convergence Protocol (PDCP) packets.
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:808
void SetSequenceNumber(uint16_t sequenceNumber)