A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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 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
34
class
LtePdcpSpecificLteRlcSapUser
:
public
LteRlcSapUser
35
{
36
public
:
37
LtePdcpSpecificLteRlcSapUser
(
LtePdcp
* pdcp);
38
39
// Interface provided to lower RLC entity (implemented from LteRlcSapUser)
40
virtual
void
ReceivePdcpPdu
(
Ptr<Packet>
p);
41
42
private
:
43
LtePdcpSpecificLteRlcSapUser
();
44
LtePdcp
*
m_pdcp
;
45
};
46
47
LtePdcpSpecificLteRlcSapUser::LtePdcpSpecificLteRlcSapUser
(
LtePdcp
* pdcp)
48
: m_pdcp (pdcp)
49
{
50
}
51
52
LtePdcpSpecificLteRlcSapUser::LtePdcpSpecificLteRlcSapUser
()
53
{
54
}
55
56
void
57
LtePdcpSpecificLteRlcSapUser::ReceivePdcpPdu
(
Ptr<Packet>
p)
58
{
59
m_pdcp
->
DoReceivePdu
(p);
60
}
61
63
64
NS_OBJECT_ENSURE_REGISTERED
(
LtePdcp
);
65
66
LtePdcp::LtePdcp
()
67
: m_pdcpSapUser (0),
68
m_rlcSapProvider (0),
69
m_rnti (0),
70
m_lcid (0),
71
m_txSequenceNumber (0),
72
m_rxSequenceNumber (0)
73
{
74
NS_LOG_FUNCTION
(
this
);
75
m_pdcpSapProvider
=
new
LtePdcpSpecificLtePdcpSapProvider<LtePdcp>
(
this
);
76
m_rlcSapUser
=
new
LtePdcpSpecificLteRlcSapUser
(
this
);
77
78
Simulator::ScheduleNow
(&
LtePdcp::Start
,
this
);
79
}
80
81
TypeId
82
LtePdcp::GetTypeId
(
void
)
83
{
84
static
TypeId
tid =
TypeId
(
"ns3::LtePdcp"
)
85
.
SetParent
<
Object
> ()
86
.AddTraceSource (
"TxPDU"
,
87
"PDU transmission notified to the RLC."
,
88
MakeTraceSourceAccessor
(&
LtePdcp::m_txPdu
))
89
.AddTraceSource (
"RxPDU"
,
90
"PDU received."
,
91
MakeTraceSourceAccessor
(&
LtePdcp::m_rxPdu
))
92
;
93
return
tid;
94
}
95
96
void
97
LtePdcp::SetRnti
(uint16_t rnti)
98
{
99
NS_LOG_FUNCTION
(
this
<< (uint32_t) rnti);
100
m_rnti
= rnti;
101
}
102
103
void
104
LtePdcp::SetLcId
(uint8_t lcId)
105
{
106
NS_LOG_FUNCTION
(
this
<< (uint32_t) lcId);
107
m_lcid
= lcId;
108
}
109
110
LtePdcp::~LtePdcp
()
111
{
112
NS_LOG_FUNCTION
(
this
);
113
delete
(
m_pdcpSapProvider
);
114
delete
(
m_rlcSapUser
);
115
}
116
117
void
118
LtePdcp::SetLtePdcpSapUser
(
LtePdcpSapUser
* s)
119
{
120
NS_LOG_FUNCTION
(
this
<< s);
121
m_pdcpSapUser
= s;
122
}
123
124
LtePdcpSapProvider
*
125
LtePdcp::GetLtePdcpSapProvider
()
126
{
127
NS_LOG_FUNCTION
(
this
);
128
return
m_pdcpSapProvider
;
129
}
130
131
void
132
LtePdcp::SetLteRlcSapProvider
(
LteRlcSapProvider
* s)
133
{
134
NS_LOG_FUNCTION
(
this
<< s);
135
m_rlcSapProvider
= s;
136
}
137
138
LteRlcSapUser
*
139
LtePdcp::GetLteRlcSapUser
()
140
{
141
NS_LOG_FUNCTION
(
this
);
142
return
m_rlcSapUser
;
143
}
144
146
147
void
148
LtePdcp::DoTransmitRrcPdu
(
Ptr<Packet>
p)
149
{
150
NS_LOG_FUNCTION
(
this
<<
m_rnti
<< (uint32_t)
m_lcid
<< p->
GetSize
());
151
152
LtePdcpHeader
pdcpHeader;
153
pdcpHeader.
SetSequenceNumber
(
m_txSequenceNumber
);
154
155
m_txSequenceNumber
++;
156
if
(
m_txSequenceNumber
>
m_maxPdcpSn
)
157
{
158
m_txSequenceNumber
= 0;
159
}
160
161
pdcpHeader.SetDcBit (
LtePdcpHeader::DATA_PDU
);
162
163
NS_LOG_LOGIC
(
"PDCP header: "
<< pdcpHeader);
164
p->
AddHeader
(pdcpHeader);
165
166
// Sender timestamp
167
PdcpTag
pdcpTag (
Simulator::Now
());
168
p->
AddByteTag
(pdcpTag);
169
m_txPdu
(
m_rnti
,
m_lcid
, p->
GetSize
());
170
171
LteRlcSapProvider::TransmitPdcpPduParameters
params;
172
params.
rnti
=
m_rnti
;
173
params.lcid =
m_lcid
;
174
params.pdcpPdu = p;
175
176
m_rlcSapProvider
->
TransmitPdcpPdu
(params);
177
}
178
179
void
180
LtePdcp::DoReceivePdu
(
Ptr<Packet>
p)
181
{
182
NS_LOG_FUNCTION
(
this
<<
m_rnti
<< (uint32_t)
m_lcid
<< p->
GetSize
());
183
184
// Receiver timestamp
185
PdcpTag
pdcpTag;
186
Time
delay;
187
if
(p->
FindFirstMatchingByteTag
(pdcpTag))
188
{
189
delay =
Simulator::Now
() - pdcpTag.GetSenderTimestamp ();
190
}
191
m_rxPdu
(
m_rnti
,
m_lcid
, p->
GetSize
(), delay.
GetNanoSeconds
());
192
193
LtePdcpHeader
pdcpHeader;
194
p->
RemoveHeader
(pdcpHeader);
195
NS_LOG_LOGIC
(
"PDCP header: "
<< pdcpHeader);
196
197
m_rxSequenceNumber
= pdcpHeader.GetSequenceNumber () + 1;
198
if
(
m_rxSequenceNumber
>
m_maxPdcpSn
)
199
{
200
m_rxSequenceNumber
= 0;
201
}
202
203
LtePdcpSapUser::ReceiveRrcPduParameters
params;
204
params.
rrcPdu
= p;
205
params.
rnti
=
m_rnti
;
206
params.
lcid
=
m_lcid
;
207
m_pdcpSapUser
->
ReceiveRrcPdu
(params);
208
}
209
210
void
211
LtePdcp::Start
()
212
{
213
NS_LOG_FUNCTION
(
this
);
214
}
215
216
217
}
// namespace ns3
src
lte
model
lte-pdcp.cc
Generated on Tue Nov 13 2012 10:32:17 for ns-3 by
1.8.1.2