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