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