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-ue-rrc.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: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
#include <ns3/fatal-error.h>
22
#include <ns3/log.h>
23
#include "ns3/object-map.h"
24
#include "ns3/object-factory.h"
25
26
#include "
lte-ue-rrc.h
"
27
#include "
lte-rlc.h
"
28
#include "
lte-pdcp.h
"
29
#include "
lte-pdcp-sap.h
"
30
#include "
lte-radio-bearer-info.h
"
31
32
33
NS_LOG_COMPONENT_DEFINE
(
"LteUeRrc"
);
34
35
namespace
ns3 {
36
37
38
40
// CMAC SAP forwarder
42
43
class
UeMemberLteUeCmacSapUser
:
public
LteUeCmacSapUser
44
{
45
public
:
46
UeMemberLteUeCmacSapUser
(
LteUeRrc
* rrc);
47
48
virtual
void
LcConfigCompleted
();
49
50
private
:
51
LteUeRrc
*
m_rrc
;
52
};
53
54
UeMemberLteUeCmacSapUser::UeMemberLteUeCmacSapUser
(
LteUeRrc
* rrc)
55
: m_rrc (rrc)
56
{
57
}
58
59
void
60
UeMemberLteUeCmacSapUser::LcConfigCompleted
()
61
{
62
m_rrc
->
DoLcConfigCompleted
();
63
}
64
65
67
// PDCP SAP Forwarder
69
70
// class UeRrcMemberLtePdcpSapUser : public LtePdcpSapUser
71
// {
72
// public:
73
// MemberLtePdcpSapUser (LteUeRrc* rrc);
74
// virtual void ReceiveRrcPdu (Ptr<Packet> p);
75
// private:
76
// LteUeRrc* m_rrc;EnbRrc
77
// };
78
79
80
// UeRrcMemberLtePdcpSapUser::UeRrcMemberLtePdcpSapUser (LteUeRrc* rrc)
81
// : m_rrc (rrc)
82
// {
83
// }
84
85
// void UeRrcMemberLtePdcpSapUser::ReceiveRrcPdu (Ptr<Packet> p)
86
// {
87
// m_rrc->DoReceiveRrcPdu (p);
88
// }
89
90
91
92
94
// ue RRC methods
96
97
NS_OBJECT_ENSURE_REGISTERED
(
LteUeRrc
);
98
99
LteUeRrc::LteUeRrc
()
100
: m_cmacSapProvider (0),
101
m_macSapProvider (0),
102
m_cellId (0)
103
{
104
NS_LOG_FUNCTION
(
this
);
105
m_cmacSapUser
=
new
UeMemberLteUeCmacSapUser
(
this
);
106
m_pdcpSapUser
=
new
LtePdcpSpecificLtePdcpSapUser<LteUeRrc>
(
this
);
107
}
108
109
110
LteUeRrc::~LteUeRrc
()
111
{
112
NS_LOG_FUNCTION
(
this
);
113
}
114
115
void
116
LteUeRrc::DoDispose
()
117
{
118
NS_LOG_FUNCTION
(
this
);
119
delete
m_cmacSapUser
;
120
delete
m_pdcpSapUser
;
121
m_rbMap
.clear ();
122
}
123
124
TypeId
125
LteUeRrc::GetTypeId
(
void
)
126
{
127
static
TypeId
tid =
TypeId
(
"ns3::LteUeRrc"
)
128
.
SetParent
<
Object
> ()
129
.AddConstructor<LteUeRrc> ()
130
.AddAttribute (
"RadioBearerMap"
,
"List of UE RadioBearerInfo by LCID."
,
131
ObjectMapValue
(),
132
MakeObjectMapAccessor
(&
LteUeRrc::m_rbMap
),
133
MakeObjectMapChecker<LteRadioBearerInfo> ())
134
.AddAttribute (
"CellId"
,
135
"Serving cell identifier"
,
136
UintegerValue
(1),
137
MakeUintegerAccessor (&
LteUeRrc::m_cellId
),
138
MakeUintegerChecker<uint16_t> ())
139
.AddAttribute (
"C-RNTI"
,
140
"Cell Radio Network Temporary Identifier"
,
141
UintegerValue
(1),
142
MakeUintegerAccessor (&
LteUeRrc::m_rnti
),
143
MakeUintegerChecker<uint16_t> ())
144
;
145
return
tid;
146
}
147
148
void
149
LteUeRrc::SetLteUeCmacSapProvider
(
LteUeCmacSapProvider
* s)
150
{
151
NS_LOG_FUNCTION
(
this
<< s);
152
m_cmacSapProvider
= s;
153
}
154
155
LteUeCmacSapUser
*
156
LteUeRrc::GetLteUeCmacSapUser
()
157
{
158
NS_LOG_FUNCTION
(
this
);
159
return
m_cmacSapUser
;
160
}
161
162
void
163
LteUeRrc::SetLteMacSapProvider
(
LteMacSapProvider
* s)
164
{
165
NS_LOG_FUNCTION
(
this
<< s);
166
m_macSapProvider
= s;
167
}
168
169
170
171
void
172
LteUeRrc::ConfigureUe
(uint16_t rnti, uint16_t cellId)
173
{
174
NS_LOG_FUNCTION
(
this
<< (uint32_t) rnti);
175
m_rnti
= rnti;
176
m_cellId
= cellId;
177
m_cmacSapProvider
->
ConfigureUe
(rnti);
178
}
179
180
void
181
LteUeRrc::SetupRadioBearer
(uint16_t rnti,
EpsBearer
bearer,
TypeId
rlcTypeId, uint8_t lcid,
Ptr<EpcTft>
tft)
182
{
183
NS_LOG_FUNCTION
(
this
<< (uint32_t) rnti << (uint32_t) lcid);
184
185
ObjectFactory
rlcObjectFactory;
186
rlcObjectFactory.
SetTypeId
(rlcTypeId);
187
Ptr<LteRlc>
rlc = rlcObjectFactory.
Create
()->
GetObject
<
LteRlc
> ();
188
rlc->
SetLteMacSapProvider
(
m_macSapProvider
);
189
rlc->
SetRnti
(rnti);
190
rlc->
SetLcId
(lcid);
191
192
Ptr<LteRadioBearerInfo>
rbInfo = CreateObject<LteRadioBearerInfo> ();
193
rbInfo->
m_rlc
= rlc;
194
195
// we need PDCP only for real RLC, i.e., RLC/UM or RLC/AM
196
// if we are using RLC/SM we don't care of anything above RLC
197
if
(rlcTypeId !=
LteRlcSm::GetTypeId
())
198
{
199
Ptr<LtePdcp>
pdcp = CreateObject<LtePdcp> ();
200
pdcp->
SetRnti
(rnti);
201
pdcp->
SetLcId
(lcid);
202
pdcp->
SetLtePdcpSapUser
(
m_pdcpSapUser
);
203
pdcp->
SetLteRlcSapProvider
(rlc->
GetLteRlcSapProvider
());
204
rlc->
SetLteRlcSapUser
(pdcp->
GetLteRlcSapUser
());
205
rbInfo->
m_pdcp
= pdcp;
206
}
207
208
NS_ASSERT_MSG
(
m_rbMap
.find (lcid) ==
m_rbMap
.end (),
"bearer with same lcid already existing"
);
209
m_rbMap
.insert (std::pair<uint8_t,
Ptr<LteRadioBearerInfo>
> (lcid, rbInfo));
210
211
212
m_tftClassifier
.
Add
(tft, lcid);
213
214
m_cmacSapProvider
->
AddLc
(lcid, rlc->
GetLteMacSapUser
());
215
}
216
217
void
218
LteUeRrc::ReleaseRadioBearer
(uint16_t rnti, uint8_t lcid)
219
{
220
NS_LOG_FUNCTION
(
this
<< (uint32_t) rnti << (uint32_t) lcid);
221
std::map<uint8_t, Ptr<LteRadioBearerInfo> >::iterator it =
m_rbMap
.find (lcid);
222
NS_ASSERT_MSG
(it !=
m_rbMap
.end (),
"could not find bearer with given lcid"
);
223
m_rbMap
.erase (it);
224
NS_FATAL_ERROR
(
"need to remove entry from TFT classifier, but this is not implemented yet"
);
225
}
226
227
228
bool
229
LteUeRrc::Send
(
Ptr<Packet>
packet)
230
{
231
NS_LOG_FUNCTION
(
this
<< packet);
232
uint8_t lcid =
m_tftClassifier
.
Classify
(packet,
EpcTft::UPLINK
);
233
LtePdcpSapProvider::TransmitRrcPduParameters
params;
234
params.
rrcPdu
= packet;
235
params.
rnti
=
m_rnti
;
236
params.
lcid
= lcid;
237
std::map<uint8_t, Ptr<LteRadioBearerInfo> >::iterator it =
m_rbMap
.find (lcid);
238
if
(it ==
m_rbMap
.end ())
239
{
240
NS_LOG_WARN
(
"could not find bearer with lcid == "
<< lcid);
241
return
false
;
242
}
243
else
244
{
245
NS_LOG_LOGIC
(
this
<<
" RNTI="
<<
m_rnti
<<
" sending "
<< packet <<
"on LCID "
<< (uint32_t) lcid <<
" ("
<< packet->
GetSize
() <<
" bytes)"
);
246
it->second->m_pdcp->GetLtePdcpSapProvider ()->TransmitRrcPdu (params);
247
return
true
;
248
}
249
}
250
251
252
void
253
LteUeRrc::SetForwardUpCallback
(
Callback
<
void
,
Ptr<Packet>
> cb)
254
{
255
m_forwardUpCallback
= cb;
256
}
257
258
259
void
260
LteUeRrc::DoReceiveRrcPdu
(
LtePdcpSapUser::ReceiveRrcPduParameters
params)
261
{
262
NS_LOG_FUNCTION
(
this
);
263
m_forwardUpCallback
(params.
rrcPdu
);
264
}
265
266
267
268
269
void
270
LteUeRrc::DoLcConfigCompleted
()
271
{
272
NS_LOG_FUNCTION
(
this
);
273
NS_FATAL_ERROR
(
"not implemented"
);
274
}
275
276
uint16_t
277
LteUeRrc::GetRnti
()
278
{
279
NS_LOG_FUNCTION
(
this
);
280
return
m_rnti
;
281
}
282
283
uint16_t
284
LteUeRrc::GetCellId
()
285
{
286
NS_LOG_FUNCTION
(
this
);
287
return
m_cellId
;
288
}
289
290
std::vector<uint8_t>
291
LteUeRrc::GetLcIdVector
()
292
{
293
std::vector<uint8_t> v;
294
for
(std::map<uint8_t,
Ptr<LteRadioBearerInfo>
>::iterator it =
m_rbMap
.begin (); it !=
m_rbMap
.end (); ++it)
295
{
296
v.push_back (it->first);
297
}
298
return
v;
299
}
300
301
void
302
LteUeRrc::DoRrcConfigurationUpdateInd
(
LteUeConfig_t
params)
303
{
304
NS_LOG_FUNCTION
(
this
<<
" RNTI "
<< params.
m_rnti
<<
" txMode "
<< (uint16_t)params.
m_transmissionMode
);
305
306
// propagate the information to MAC layer
307
m_cmacSapProvider
->
RrcUpdateConfigurationReq
(params);
308
}
309
310
311
}
// namespace ns3
312
src
lte
model
lte-ue-rrc.cc
Generated on Tue Nov 13 2012 10:32:17 for ns-3 by
1.8.1.2