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-rrc-protocol-ideal.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 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: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
#include <ns3/fatal-error.h>
22
#include <ns3/log.h>
23
#include <ns3/nstime.h>
24
#include <ns3/node-list.h>
25
#include <ns3/node.h>
26
#include <ns3/simulator.h>
27
28
#include "
lte-rrc-protocol-ideal.h
"
29
#include "
lte-ue-rrc.h
"
30
#include "
lte-enb-rrc.h
"
31
#include "
lte-enb-net-device.h
"
32
#include "
lte-ue-net-device.h
"
33
34
NS_LOG_COMPONENT_DEFINE
(
"LteRrcProtocolIdeal"
);
35
36
37
namespace
ns3 {
38
39
40
const
Time
RRC_IDEAL_MSG_DELAY
=
MilliSeconds
(0);
41
42
NS_OBJECT_ENSURE_REGISTERED
(
LteUeRrcProtocolIdeal
);
43
44
LteUeRrcProtocolIdeal::LteUeRrcProtocolIdeal
()
45
: m_ueRrcSapProvider (0),
46
m_enbRrcSapProvider (0)
47
{
48
m_ueRrcSapUser
=
new
MemberLteUeRrcSapUser<LteUeRrcProtocolIdeal>
(
this
);
49
}
50
51
LteUeRrcProtocolIdeal::~LteUeRrcProtocolIdeal
()
52
{
53
}
54
55
void
56
LteUeRrcProtocolIdeal::DoDispose
()
57
{
58
NS_LOG_FUNCTION
(
this
);
59
delete
m_ueRrcSapUser
;
60
m_rrc
= 0;
61
}
62
63
TypeId
64
LteUeRrcProtocolIdeal::GetTypeId
(
void
)
65
{
66
static
TypeId
tid =
TypeId
(
"ns3::LteUeRrcProtocolIdeal"
)
67
.
SetParent
<
Object
> ()
68
.AddConstructor<LteUeRrcProtocolIdeal> ()
69
;
70
return
tid;
71
}
72
73
void
74
LteUeRrcProtocolIdeal::SetLteUeRrcSapProvider
(
LteUeRrcSapProvider
* p)
75
{
76
m_ueRrcSapProvider
= p;
77
}
78
79
LteUeRrcSapUser
*
80
LteUeRrcProtocolIdeal::GetLteUeRrcSapUser
()
81
{
82
return
m_ueRrcSapUser
;
83
}
84
85
void
86
LteUeRrcProtocolIdeal::SetUeRrc
(
Ptr<LteUeRrc>
rrc)
87
{
88
m_rrc
= rrc;
89
}
90
91
void
92
LteUeRrcProtocolIdeal::DoSetup
(
LteUeRrcSapUser::SetupParameters
params)
93
{
94
NS_LOG_FUNCTION
(
this
);
95
// We don't care about SRB0/SRB1 since we use ideal RRC messages.
96
}
97
98
void
99
LteUeRrcProtocolIdeal::DoSendRrcConnectionRequest
(
LteRrcSap::RrcConnectionRequest
msg)
100
{
101
// initialize the RNTI and get the EnbLteRrcSapProvider for the
102
// eNB we are currently attached to
103
m_rnti
=
m_rrc
->
GetRnti
();
104
SetEnbRrcSapProvider
();
105
106
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
107
&
LteEnbRrcSapProvider::RecvRrcConnectionRequest
,
108
m_enbRrcSapProvider
,
109
m_rnti
,
110
msg);
111
}
112
113
void
114
LteUeRrcProtocolIdeal::DoSendRrcConnectionSetupCompleted
(
LteRrcSap::RrcConnectionSetupCompleted
msg)
115
{
116
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
117
&
LteEnbRrcSapProvider::RecvRrcConnectionSetupCompleted
,
118
m_enbRrcSapProvider
,
119
m_rnti
,
120
msg);
121
}
122
123
void
124
LteUeRrcProtocolIdeal::DoSendRrcConnectionReconfigurationCompleted
(
LteRrcSap::RrcConnectionReconfigurationCompleted
msg)
125
{
126
// re-initialize the RNTI and get the EnbLteRrcSapProvider for the
127
// eNB we are currently attached to
128
m_rnti
=
m_rrc
->
GetRnti
();
129
SetEnbRrcSapProvider
();
130
131
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
132
&
LteEnbRrcSapProvider::RecvRrcConnectionReconfigurationCompleted
,
133
m_enbRrcSapProvider
,
134
m_rnti
,
135
msg);
136
}
137
138
void
139
LteUeRrcProtocolIdeal::DoSendRrcConnectionReestablishmentRequest
(
LteRrcSap::RrcConnectionReestablishmentRequest
msg)
140
{
141
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
142
&
LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentRequest
,
143
m_enbRrcSapProvider
,
144
m_rnti
,
145
msg);
146
}
147
148
void
149
LteUeRrcProtocolIdeal::DoSendRrcConnectionReestablishmentComplete
(
LteRrcSap::RrcConnectionReestablishmentComplete
msg)
150
{
151
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
152
&
LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentComplete
,
153
m_enbRrcSapProvider
,
154
m_rnti
,
155
msg);
156
}
157
158
void
159
LteUeRrcProtocolIdeal::DoSendMeasurementReport
(
LteRrcSap::MeasurementReport
msg)
160
{
161
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
162
&
LteEnbRrcSapProvider::RecvMeasurementReport
,
163
m_enbRrcSapProvider
,
164
m_rnti
,
165
msg);
166
}
167
168
void
169
LteUeRrcProtocolIdeal::SetEnbRrcSapProvider
()
170
{
171
uint16_t cellId =
m_rrc
->
GetCellId
();
172
173
// walk list of all nodes to get the peer eNB
174
Ptr<LteEnbNetDevice>
enbDev;
175
NodeList::Iterator
listEnd =
NodeList::End
();
176
bool
found =
false
;
177
for
(
NodeList::Iterator
i =
NodeList::Begin
();
178
(i != listEnd) && (!found);
179
++i)
180
{
181
Ptr<Node>
node = *i;
182
int
nDevs = node->
GetNDevices
();
183
for
(
int
j = 0;
184
(j < nDevs) && (!found);
185
j++)
186
{
187
enbDev = node->
GetDevice
(j)->
GetObject
<
LteEnbNetDevice
> ();
188
if
(enbDev == 0)
189
{
190
continue
;
191
}
192
else
193
{
194
if
(enbDev->
GetCellId
() == cellId)
195
{
196
found =
true
;
197
break
;
198
}
199
}
200
}
201
}
202
NS_ASSERT_MSG
(found,
" Unable to find eNB with CellId ="
<< cellId);
203
m_enbRrcSapProvider
= enbDev->
GetRrc
()->
GetLteEnbRrcSapProvider
();
204
Ptr<LteEnbRrcProtocolIdeal>
enbRrcProtocolIdeal = enbDev->
GetRrc
()->
GetObject
<
LteEnbRrcProtocolIdeal
> ();
205
enbRrcProtocolIdeal->SetUeRrcSapProvider (
m_rnti
,
m_ueRrcSapProvider
);
206
}
207
208
209
NS_OBJECT_ENSURE_REGISTERED
(
LteEnbRrcProtocolIdeal
);
210
211
LteEnbRrcProtocolIdeal::LteEnbRrcProtocolIdeal
()
212
: m_enbRrcSapProvider (0)
213
{
214
NS_LOG_FUNCTION
(
this
);
215
m_enbRrcSapUser
=
new
MemberLteEnbRrcSapUser<LteEnbRrcProtocolIdeal>
(
this
);
216
}
217
218
LteEnbRrcProtocolIdeal::~LteEnbRrcProtocolIdeal
()
219
{
220
NS_LOG_FUNCTION
(
this
);
221
}
222
223
void
224
LteEnbRrcProtocolIdeal::DoDispose
()
225
{
226
NS_LOG_FUNCTION
(
this
);
227
delete
m_enbRrcSapUser
;
228
}
229
230
TypeId
231
LteEnbRrcProtocolIdeal::GetTypeId
(
void
)
232
{
233
static
TypeId
tid =
TypeId
(
"ns3::LteEnbRrcProtocolIdeal"
)
234
.
SetParent
<
Object
> ()
235
.AddConstructor<LteEnbRrcProtocolIdeal> ()
236
;
237
return
tid;
238
}
239
240
void
241
LteEnbRrcProtocolIdeal::SetLteEnbRrcSapProvider
(
LteEnbRrcSapProvider
* p)
242
{
243
m_enbRrcSapProvider
= p;
244
}
245
246
LteEnbRrcSapUser
*
247
LteEnbRrcProtocolIdeal::GetLteEnbRrcSapUser
()
248
{
249
return
m_enbRrcSapUser
;
250
}
251
252
void
253
LteEnbRrcProtocolIdeal::SetCellId
(uint16_t cellId)
254
{
255
m_cellId
= cellId;
256
}
257
258
LteUeRrcSapProvider
*
259
LteEnbRrcProtocolIdeal::GetUeRrcSapProvider
(uint16_t rnti)
260
{
261
std::map<uint16_t, LteUeRrcSapProvider*>::const_iterator it;
262
it =
m_enbRrcSapProviderMap
.find (rnti);
263
NS_ASSERT_MSG
(it !=
m_enbRrcSapProviderMap
.end (),
"could not find RNTI = "
<< rnti);
264
return
it->second;
265
}
266
267
void
268
LteEnbRrcProtocolIdeal::SetUeRrcSapProvider
(uint16_t rnti,
LteUeRrcSapProvider
* p)
269
{
270
std::map<uint16_t, LteUeRrcSapProvider*>::iterator it;
271
it =
m_enbRrcSapProviderMap
.find (rnti);
272
NS_ASSERT_MSG
(it !=
m_enbRrcSapProviderMap
.end (),
"could not find RNTI = "
<< rnti);
273
it->second = p;
274
}
275
276
void
277
LteEnbRrcProtocolIdeal::DoSetupUe
(uint16_t rnti,
LteEnbRrcSapUser::SetupUeParameters
params)
278
{
279
NS_LOG_FUNCTION
(
this
<< rnti);
280
281
// // walk list of all nodes to get the peer UE RRC SAP Provider
282
// Ptr<LteUeRrc> ueRrc;
283
// NodeList::Iterator listEnd = NodeList::End ();
284
// bool found = false;
285
// for (NodeList::Iterator i = NodeList::Begin (); (i != listEnd) && (found == false); i++)
286
// {
287
// Ptr<Node> node = *i;
288
// int nDevs = node->GetNDevices ();
289
// for (int j = 0; j < nDevs; j++)
290
// {
291
// Ptr<LteUeNetDevice> ueDev = node->GetDevice (j)->GetObject <LteUeNetDevice> ();
292
// if (!ueDev)
293
// {
294
// continue;
295
// }
296
// else
297
// {
298
// ueRrc = ueDev->GetRrc ();
299
// if ((ueRrc->GetRnti () == rnti) && (ueRrc->GetCellId () == m_cellId))
300
// {
301
// found = true;
302
// break;
303
// }
304
// }
305
// }
306
// }
307
// NS_ASSERT_MSG (found , " Unable to find UE with RNTI=" << rnti << " cellId=" << m_cellId);
308
// m_enbRrcSapProviderMap[rnti] = ueRrc->GetLteUeRrcSapProvider ();
309
310
311
// just create empty entry, the UeRrcSapProvider will be set by the
312
// ue upon connection request or connection reconfiguration
313
// completed
314
m_enbRrcSapProviderMap
[rnti] = 0;
315
316
}
317
318
void
319
LteEnbRrcProtocolIdeal::DoRemoveUe
(uint16_t rnti)
320
{
321
NS_LOG_FUNCTION
(
this
<< rnti);
322
m_enbRrcSapProviderMap
.erase (rnti);
323
}
324
325
void
326
LteEnbRrcProtocolIdeal::DoSendMasterInformationBlock
(
LteRrcSap::MasterInformationBlock
msg)
327
{
328
NS_LOG_FUNCTION
(
this
);
329
for
(std::map<uint16_t, LteUeRrcSapProvider*>::const_iterator it =
m_enbRrcSapProviderMap
.begin ();
330
it !=
m_enbRrcSapProviderMap
.end ();
331
++it)
332
{
333
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
334
&
LteUeRrcSapProvider::RecvMasterInformationBlock
,
335
it->second,
336
msg);
337
}
338
}
339
340
void
341
LteEnbRrcProtocolIdeal::DoSendSystemInformationBlockType1
(
LteRrcSap::SystemInformationBlockType1
msg)
342
{
343
NS_LOG_FUNCTION
(
this
<<
m_cellId
);
344
// walk list of all nodes to get UEs with this cellId
345
Ptr<LteUeRrc>
ueRrc;
346
for
(
NodeList::Iterator
i =
NodeList::Begin
(); i !=
NodeList::End
(); ++i)
347
{
348
Ptr<Node>
node = *i;
349
int
nDevs = node->
GetNDevices
();
350
for
(
int
j = 0; j < nDevs; ++j)
351
{
352
Ptr<LteUeNetDevice>
ueDev = node->
GetDevice
(j)->
GetObject
<
LteUeNetDevice
> ();
353
if
(ueDev != 0)
354
{
355
NS_LOG_LOGIC
(
"considering UE "
<< ueDev->GetImsi ());
356
Ptr<LteUeRrc>
ueRrc = ueDev->GetRrc ();
357
if
(ueRrc->GetCellId () ==
m_cellId
)
358
{
359
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
360
&
LteUeRrcSapProvider::RecvSystemInformationBlockType1
,
361
ueRrc->GetLteUeRrcSapProvider (),
362
msg);
363
}
364
}
365
}
366
}
367
}
368
369
void
370
LteEnbRrcProtocolIdeal::DoSendSystemInformation
(
LteRrcSap::SystemInformation
msg)
371
{
372
NS_LOG_FUNCTION
(
this
<<
m_cellId
);
373
// walk list of all nodes to get UEs with this cellId
374
Ptr<LteUeRrc>
ueRrc;
375
for
(
NodeList::Iterator
i =
NodeList::Begin
(); i !=
NodeList::End
(); ++i)
376
{
377
Ptr<Node>
node = *i;
378
int
nDevs = node->
GetNDevices
();
379
for
(
int
j = 0; j < nDevs; ++j)
380
{
381
Ptr<LteUeNetDevice>
ueDev = node->
GetDevice
(j)->
GetObject
<
LteUeNetDevice
> ();
382
if
(ueDev != 0)
383
{
384
Ptr<LteUeRrc>
ueRrc = ueDev->GetRrc ();
385
NS_LOG_LOGIC
(
"considering UE IMSI "
<< ueDev->GetImsi () <<
" that has cellId "
<< ueRrc->
GetCellId
());
386
if
(ueRrc->
GetCellId
() ==
m_cellId
)
387
{
388
NS_LOG_LOGIC
(
"sending SI to IMSI "
<< ueDev->GetImsi ());
389
ueRrc->
GetLteUeRrcSapProvider
()->
RecvSystemInformation
(msg);
390
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
391
&
LteUeRrcSapProvider::RecvSystemInformation
,
392
ueRrc->
GetLteUeRrcSapProvider
(),
393
msg);
394
}
395
}
396
}
397
}
398
}
399
400
void
401
LteEnbRrcProtocolIdeal::DoSendRrcConnectionSetup
(uint16_t rnti,
LteRrcSap::RrcConnectionSetup
msg)
402
{
403
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
404
&
LteUeRrcSapProvider::RecvRrcConnectionSetup
,
405
GetUeRrcSapProvider
(rnti),
406
msg);
407
}
408
409
void
410
LteEnbRrcProtocolIdeal::DoSendRrcConnectionReconfiguration
(uint16_t rnti,
LteRrcSap::RrcConnectionReconfiguration
msg)
411
{
412
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
413
&
LteUeRrcSapProvider::RecvRrcConnectionReconfiguration
,
414
GetUeRrcSapProvider
(rnti),
415
msg);
416
}
417
418
void
419
LteEnbRrcProtocolIdeal::DoSendRrcConnectionReestablishment
(uint16_t rnti,
LteRrcSap::RrcConnectionReestablishment
msg)
420
{
421
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
422
&
LteUeRrcSapProvider::RecvRrcConnectionReestablishment
,
423
GetUeRrcSapProvider
(rnti),
424
msg);
425
}
426
427
void
428
LteEnbRrcProtocolIdeal::DoSendRrcConnectionReestablishmentReject
(uint16_t rnti,
LteRrcSap::RrcConnectionReestablishmentReject
msg)
429
{
430
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
431
&
LteUeRrcSapProvider::RecvRrcConnectionReestablishmentReject
,
432
GetUeRrcSapProvider
(rnti),
433
msg);
434
}
435
436
void
437
LteEnbRrcProtocolIdeal::DoSendRrcConnectionRelease
(uint16_t rnti,
LteRrcSap::RrcConnectionRelease
msg)
438
{
439
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
440
&
LteUeRrcSapProvider::RecvRrcConnectionRelease
,
441
GetUeRrcSapProvider
(rnti),
442
msg);
443
}
444
445
void
446
LteEnbRrcProtocolIdeal::DoSendRrcConnectionReject
(uint16_t rnti,
LteRrcSap::RrcConnectionReject
msg)
447
{
448
Simulator::Schedule
(
RRC_IDEAL_MSG_DELAY
,
449
&
LteUeRrcSapProvider::RecvRrcConnectionReject
,
450
GetUeRrcSapProvider
(rnti),
451
msg);
452
}
453
454
/*
455
* The purpose of LteEnbRrcProtocolIdeal is to avoid encoding
456
* messages. In order to do so, we need to have some form of encoding for
457
* inter-node RRC messages like HandoverPreparationInfo and HandoverCommand. Doing so
458
* directly is not practical (these messages includes a lot of
459
* information elements, so encoding all of them would defeat the
460
* purpose of LteEnbRrcProtocolIdeal. The workaround is to store the
461
* actual message in a global map, so that then we can just encode the
462
* key in a header and send that between eNBs over X2.
463
*
464
*/
465
466
std::map<uint32_t, LteRrcSap::HandoverPreparationInfo>
g_handoverPreparationInfoMsgMap
;
467
uint32_t
g_handoverPreparationInfoMsgIdCounter
= 0;
468
469
/*
470
* This header encodes the map key discussed above. We keep this
471
* private since it should not be used outside this file.
472
*
473
*/
474
class
IdealHandoverPreparationInfoHeader
:
public
Header
475
{
476
public
:
477
uint32_t
GetMsgId
();
478
void
SetMsgId
(uint32_t
id
);
479
static
TypeId
GetTypeId
(
void
);
480
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
481
virtual
void
Print
(std::ostream &os)
const
;
482
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
483
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
484
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
485
486
private
:
487
uint32_t
m_msgId
;
488
};
489
490
uint32_t
491
IdealHandoverPreparationInfoHeader::GetMsgId
()
492
{
493
return
m_msgId
;
494
}
495
496
void
497
IdealHandoverPreparationInfoHeader::SetMsgId
(uint32_t
id
)
498
{
499
m_msgId
= id;
500
}
501
502
503
TypeId
504
IdealHandoverPreparationInfoHeader::GetTypeId
(
void
)
505
{
506
static
TypeId
tid =
TypeId
(
"ns3::IdealHandoverPreparationInfoHeader"
)
507
.
SetParent
<
Header
> ()
508
.AddConstructor<IdealHandoverPreparationInfoHeader> ()
509
;
510
return
tid;
511
}
512
513
TypeId
514
IdealHandoverPreparationInfoHeader::GetInstanceTypeId
(
void
)
const
515
{
516
return
GetTypeId
();
517
}
518
519
void
IdealHandoverPreparationInfoHeader::Print
(std::ostream &os)
const
520
{
521
os <<
" msgId="
<<
m_msgId
;
522
}
523
524
uint32_t
IdealHandoverPreparationInfoHeader::GetSerializedSize
(
void
)
const
525
{
526
return
4;
527
}
528
529
void
IdealHandoverPreparationInfoHeader::Serialize
(
Buffer::Iterator
start
)
const
530
{
531
start.
WriteU32
(
m_msgId
);
532
}
533
534
uint32_t
IdealHandoverPreparationInfoHeader::Deserialize
(
Buffer::Iterator
start
)
535
{
536
m_msgId
= start.
ReadU32
();
537
return
GetSerializedSize
();
538
}
539
540
541
542
Ptr<Packet>
543
LteEnbRrcProtocolIdeal::DoEncodeHandoverPreparationInformation
(
LteRrcSap::HandoverPreparationInfo
msg)
544
{
545
uint32_t msgId = ++
g_handoverPreparationInfoMsgIdCounter
;
546
NS_ASSERT_MSG
(
g_handoverPreparationInfoMsgMap
.find (msgId) ==
g_handoverPreparationInfoMsgMap
.end (),
"msgId "
<< msgId <<
" already in use"
);
547
NS_LOG_INFO
(
" encoding msgId = "
<< msgId);
548
g_handoverPreparationInfoMsgMap
.insert (std::pair<uint32_t, LteRrcSap::HandoverPreparationInfo> (msgId, msg));
549
IdealHandoverPreparationInfoHeader
h;
550
h.
SetMsgId
(msgId);
551
Ptr<Packet>
p = Create<Packet> ();
552
p->
AddHeader
(h);
553
return
p;
554
}
555
556
LteRrcSap::HandoverPreparationInfo
557
LteEnbRrcProtocolIdeal::DoDecodeHandoverPreparationInformation
(
Ptr<Packet>
p)
558
{
559
IdealHandoverPreparationInfoHeader
h;
560
p->
RemoveHeader
(h);
561
uint32_t msgId = h.
GetMsgId
();
562
NS_LOG_INFO
(
" decoding msgId = "
<< msgId);
563
std::map<uint32_t, LteRrcSap::HandoverPreparationInfo>::iterator it =
g_handoverPreparationInfoMsgMap
.find (msgId);
564
NS_ASSERT_MSG
(it !=
g_handoverPreparationInfoMsgMap
.end (),
"msgId "
<< msgId <<
" not found"
);
565
LteRrcSap::HandoverPreparationInfo
msg = it->second;
566
g_handoverPreparationInfoMsgMap
.erase (it);
567
return
msg;
568
}
569
570
571
572
std::map<uint32_t, LteRrcSap::RrcConnectionReconfiguration>
g_handoverCommandMsgMap
;
573
uint32_t
g_handoverCommandMsgIdCounter
= 0;
574
575
/*
576
* This header encodes the map key discussed above. We keep this
577
* private since it should not be used outside this file.
578
*
579
*/
580
class
IdealHandoverCommandHeader
:
public
Header
581
{
582
public
:
583
uint32_t
GetMsgId
();
584
void
SetMsgId
(uint32_t
id
);
585
static
TypeId
GetTypeId
(
void
);
586
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
587
virtual
void
Print
(std::ostream &os)
const
;
588
virtual
uint32_t
GetSerializedSize
(
void
)
const
;
589
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
590
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
591
592
private
:
593
uint32_t
m_msgId
;
594
};
595
596
uint32_t
597
IdealHandoverCommandHeader::GetMsgId
()
598
{
599
return
m_msgId
;
600
}
601
602
void
603
IdealHandoverCommandHeader::SetMsgId
(uint32_t
id
)
604
{
605
m_msgId
= id;
606
}
607
608
609
TypeId
610
IdealHandoverCommandHeader::GetTypeId
(
void
)
611
{
612
static
TypeId
tid =
TypeId
(
"ns3::IdealHandoverCommandHeader"
)
613
.
SetParent
<
Header
> ()
614
.AddConstructor<IdealHandoverCommandHeader> ()
615
;
616
return
tid;
617
}
618
619
TypeId
620
IdealHandoverCommandHeader::GetInstanceTypeId
(
void
)
const
621
{
622
return
GetTypeId
();
623
}
624
625
void
IdealHandoverCommandHeader::Print
(std::ostream &os)
const
626
{
627
os <<
" msgId="
<<
m_msgId
;
628
}
629
630
uint32_t
IdealHandoverCommandHeader::GetSerializedSize
(
void
)
const
631
{
632
return
4;
633
}
634
635
void
IdealHandoverCommandHeader::Serialize
(
Buffer::Iterator
start
)
const
636
{
637
start.
WriteU32
(
m_msgId
);
638
}
639
640
uint32_t
IdealHandoverCommandHeader::Deserialize
(
Buffer::Iterator
start
)
641
{
642
m_msgId
= start.
ReadU32
();
643
return
GetSerializedSize
();
644
}
645
646
647
648
Ptr<Packet>
649
LteEnbRrcProtocolIdeal::DoEncodeHandoverCommand
(
LteRrcSap::RrcConnectionReconfiguration
msg)
650
{
651
uint32_t msgId = ++
g_handoverCommandMsgIdCounter
;
652
NS_ASSERT_MSG
(
g_handoverCommandMsgMap
.find (msgId) ==
g_handoverCommandMsgMap
.end (),
"msgId "
<< msgId <<
" already in use"
);
653
NS_LOG_INFO
(
" encoding msgId = "
<< msgId);
654
g_handoverCommandMsgMap
.insert (std::pair<uint32_t, LteRrcSap::RrcConnectionReconfiguration> (msgId, msg));
655
IdealHandoverCommandHeader
h;
656
h.
SetMsgId
(msgId);
657
Ptr<Packet>
p = Create<Packet> ();
658
p->
AddHeader
(h);
659
return
p;
660
}
661
662
LteRrcSap::RrcConnectionReconfiguration
663
LteEnbRrcProtocolIdeal::DoDecodeHandoverCommand
(
Ptr<Packet>
p)
664
{
665
IdealHandoverCommandHeader
h;
666
p->
RemoveHeader
(h);
667
uint32_t msgId = h.
GetMsgId
();
668
NS_LOG_INFO
(
" decoding msgId = "
<< msgId);
669
std::map<uint32_t, LteRrcSap::RrcConnectionReconfiguration>::iterator it =
g_handoverCommandMsgMap
.find (msgId);
670
NS_ASSERT_MSG
(it !=
g_handoverCommandMsgMap
.end (),
"msgId "
<< msgId <<
" not found"
);
671
LteRrcSap::RrcConnectionReconfiguration
msg = it->second;
672
g_handoverCommandMsgMap
.erase (it);
673
return
msg;
674
}
675
676
677
678
679
680
}
// namespace ns3
src
lte
model
lte-rrc-protocol-ideal.cc
Generated on Tue May 14 2013 11:08:26 for ns-3 by
1.8.1.2