A Discrete-Event Network Simulator
API
lte-rrc-protocol-real.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Nicola Baldo <nbaldo@cttc.es>
18 * Lluis Parcerisa <lparcerisa@cttc.cat>
19 */
20
22
23#include "lte-enb-net-device.h"
24#include "lte-enb-rrc.h"
25#include "lte-ue-net-device.h"
26#include "lte-ue-rrc.h"
27
28#include <ns3/fatal-error.h>
29#include <ns3/log.h>
30#include <ns3/node-list.h>
31#include <ns3/node.h>
32#include <ns3/nstime.h>
33#include <ns3/simulator.h>
34
35namespace ns3
36{
37
38NS_LOG_COMPONENT_DEFINE("LteRrcProtocolReal");
39
42
44
46 : m_ueRrcSapProvider(nullptr),
47 m_enbRrcSapProvider(nullptr)
48{
54}
55
57{
58}
59
60void
62{
63 NS_LOG_FUNCTION(this);
64 delete m_ueRrcSapUser;
67 m_rrc = nullptr;
68}
69
72{
73 static TypeId tid = TypeId("ns3::LteUeRrcProtocolReal")
75 .SetGroupName("Lte")
76 .AddConstructor<LteUeRrcProtocolReal>();
77 return tid;
78}
79
80void
82{
84}
85
88{
89 return m_ueRrcSapUser;
90}
91
92void
94{
95 m_rrc = rrc;
96}
97
98void
100{
101 NS_LOG_FUNCTION(this);
102
103 m_setupParameters.srb0SapProvider = params.srb0SapProvider;
104 m_setupParameters.srb1SapProvider = params.srb1SapProvider;
106}
107
108void
110{
111 // initialize the RNTI and get the EnbLteRrcSapProvider for the
112 // eNB we are currently attached to
113 m_rnti = m_rrc->GetRnti();
115
116 Ptr<Packet> packet = Create<Packet>();
117
118 RrcConnectionRequestHeader rrcConnectionRequestHeader;
119 rrcConnectionRequestHeader.SetMessage(msg);
120
121 packet->AddHeader(rrcConnectionRequestHeader);
122
123 LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
124 transmitPdcpPduParameters.pdcpPdu = packet;
125 transmitPdcpPduParameters.rnti = m_rnti;
126 transmitPdcpPduParameters.lcid = 0;
127
128 m_setupParameters.srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
129}
130
131void
134{
135 Ptr<Packet> packet = Create<Packet>();
136
137 RrcConnectionSetupCompleteHeader rrcConnectionSetupCompleteHeader;
138 rrcConnectionSetupCompleteHeader.SetMessage(msg);
139
140 packet->AddHeader(rrcConnectionSetupCompleteHeader);
141
142 LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
143 transmitPdcpSduParameters.pdcpSdu = packet;
144 transmitPdcpSduParameters.rnti = m_rnti;
145 transmitPdcpSduParameters.lcid = 1;
146
148 {
149 m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
150 }
151}
152
153void
156{
157 // re-initialize the RNTI and get the EnbLteRrcSapProvider for the
158 // eNB we are currently attached to
159 m_rnti = m_rrc->GetRnti();
161
162 Ptr<Packet> packet = Create<Packet>();
163
164 RrcConnectionReconfigurationCompleteHeader rrcConnectionReconfigurationCompleteHeader;
165 rrcConnectionReconfigurationCompleteHeader.SetMessage(msg);
166
167 packet->AddHeader(rrcConnectionReconfigurationCompleteHeader);
168
169 LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
170 transmitPdcpSduParameters.pdcpSdu = packet;
171 transmitPdcpSduParameters.rnti = m_rnti;
172 transmitPdcpSduParameters.lcid = 1;
173
174 m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
175}
176
177void
179{
180 // re-initialize the RNTI and get the EnbLteRrcSapProvider for the
181 // eNB we are currently attached to
182 m_rnti = m_rrc->GetRnti();
184
185 Ptr<Packet> packet = Create<Packet>();
186
187 MeasurementReportHeader measurementReportHeader;
188 measurementReportHeader.SetMessage(msg);
189
190 packet->AddHeader(measurementReportHeader);
191
192 LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
193 transmitPdcpSduParameters.pdcpSdu = packet;
194 transmitPdcpSduParameters.rnti = m_rnti;
195 transmitPdcpSduParameters.lcid = 1;
196
197 m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
198}
199
200void
202{
203 NS_LOG_FUNCTION(this << rnti);
204 uint16_t cellId = m_rrc->GetCellId();
205 // re-initialize the RNTI and get the EnbLteRrcSapProvider for the
206 // eNB we are currently attached to or attempting random access to
207 // a target eNB
208 m_rnti = m_rrc->GetRnti();
209
210 NS_LOG_DEBUG("RNTI " << rnti << " sending UE context remove request to cell id " << cellId);
211 NS_ABORT_MSG_IF(m_rnti != rnti, "RNTI mismatch");
212
213 SetEnbRrcSapProvider(); // the provider has to be reset since the cell might
214 // have changed due to handover
215 // ideally informing eNB
219 rnti);
220}
221
222void
225{
226 Ptr<Packet> packet = Create<Packet>();
227
228 RrcConnectionReestablishmentRequestHeader rrcConnectionReestablishmentRequestHeader;
229 rrcConnectionReestablishmentRequestHeader.SetMessage(msg);
230
231 packet->AddHeader(rrcConnectionReestablishmentRequestHeader);
232
233 LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
234 transmitPdcpPduParameters.pdcpPdu = packet;
235 transmitPdcpPduParameters.rnti = m_rnti;
236 transmitPdcpPduParameters.lcid = 0;
237
238 m_setupParameters.srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
239}
240
241void
244{
245 Ptr<Packet> packet = Create<Packet>();
246
247 RrcConnectionReestablishmentCompleteHeader rrcConnectionReestablishmentCompleteHeader;
248 rrcConnectionReestablishmentCompleteHeader.SetMessage(msg);
249
250 packet->AddHeader(rrcConnectionReestablishmentCompleteHeader);
251
252 LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
253 transmitPdcpSduParameters.pdcpSdu = packet;
254 transmitPdcpSduParameters.rnti = m_rnti;
255 transmitPdcpSduParameters.lcid = 1;
256
257 m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
258}
259
260void
262{
263 NS_LOG_FUNCTION(this);
264
265 uint16_t cellId = m_rrc->GetCellId();
266
267 NS_LOG_DEBUG("RNTI " << m_rnti << " connected to cell " << cellId);
268
269 // walk list of all nodes to get the peer eNB
272 bool found = false;
273 for (NodeList::Iterator i = NodeList::Begin(); (i != listEnd) && (!found); ++i)
274 {
275 Ptr<Node> node = *i;
276 int nDevs = node->GetNDevices();
277 for (int j = 0; (j < nDevs) && (!found); j++)
278 {
279 enbDev = node->GetDevice(j)->GetObject<LteEnbNetDevice>();
280 if (!enbDev)
281 {
282 continue;
283 }
284 else
285 {
286 if (enbDev->HasCellId(cellId))
287 {
288 found = true;
289 break;
290 }
291 }
292 }
293 }
294 NS_ASSERT_MSG(found, " Unable to find eNB with CellId =" << cellId);
295 m_enbRrcSapProvider = enbDev->GetRrc()->GetLteEnbRrcSapProvider();
296 Ptr<LteEnbRrcProtocolReal> enbRrcProtocolReal =
297 enbDev->GetRrc()->GetObject<LteEnbRrcProtocolReal>();
298 enbRrcProtocolReal->SetUeRrcSapProvider(m_rnti, m_ueRrcSapProvider);
299}
300
301void
303{
304 // Get type of message received
305 RrcDlCcchMessage rrcDlCcchMessage;
306 p->PeekHeader(rrcDlCcchMessage);
307
308 // Declare possible headers to receive
309 RrcConnectionReestablishmentHeader rrcConnectionReestablishmentHeader;
310 RrcConnectionReestablishmentRejectHeader rrcConnectionReestablishmentRejectHeader;
311 RrcConnectionSetupHeader rrcConnectionSetupHeader;
312 RrcConnectionRejectHeader rrcConnectionRejectHeader;
313
314 // Declare possible messages
315 LteRrcSap::RrcConnectionReestablishment rrcConnectionReestablishmentMsg;
316 LteRrcSap::RrcConnectionReestablishmentReject rrcConnectionReestablishmentRejectMsg;
317 LteRrcSap::RrcConnectionSetup rrcConnectionSetupMsg;
318 LteRrcSap::RrcConnectionReject rrcConnectionRejectMsg;
319
320 // Deserialize packet and call member recv function with appropriate structure
321 switch (rrcDlCcchMessage.GetMessageType())
322 {
323 case 0:
324 // RrcConnectionReestablishment
325 p->RemoveHeader(rrcConnectionReestablishmentHeader);
326 rrcConnectionReestablishmentMsg = rrcConnectionReestablishmentHeader.GetMessage();
327 m_ueRrcSapProvider->RecvRrcConnectionReestablishment(rrcConnectionReestablishmentMsg);
328 break;
329 case 1:
330 // RrcConnectionReestablishmentReject
331 p->RemoveHeader(rrcConnectionReestablishmentRejectHeader);
332 rrcConnectionReestablishmentRejectMsg =
333 rrcConnectionReestablishmentRejectHeader.GetMessage();
334 // m_ueRrcSapProvider->RecvRrcConnectionReestablishmentReject
335 // (rrcConnectionReestablishmentRejectMsg);
336 break;
337 case 2:
338 // RrcConnectionReject
339 p->RemoveHeader(rrcConnectionRejectHeader);
340 rrcConnectionRejectMsg = rrcConnectionRejectHeader.GetMessage();
341 m_ueRrcSapProvider->RecvRrcConnectionReject(rrcConnectionRejectMsg);
342 break;
343 case 3:
344 // RrcConnectionSetup
345 p->RemoveHeader(rrcConnectionSetupHeader);
346 rrcConnectionSetupMsg = rrcConnectionSetupHeader.GetMessage();
347 m_ueRrcSapProvider->RecvRrcConnectionSetup(rrcConnectionSetupMsg);
348 break;
349 }
350}
351
352void
354{
355 // Get type of message received
356 RrcDlDcchMessage rrcDlDcchMessage;
357 params.pdcpSdu->PeekHeader(rrcDlDcchMessage);
358
359 // Declare possible headers to receive
360 RrcConnectionReconfigurationHeader rrcConnectionReconfigurationHeader;
361 RrcConnectionReleaseHeader rrcConnectionReleaseHeader;
362
363 // Declare possible messages to receive
364 LteRrcSap::RrcConnectionReconfiguration rrcConnectionReconfigurationMsg;
365 LteRrcSap::RrcConnectionRelease rrcConnectionReleaseMsg;
366
367 // Deserialize packet and call member recv function with appropriate structure
368 switch (rrcDlDcchMessage.GetMessageType())
369 {
370 case 4:
371 params.pdcpSdu->RemoveHeader(rrcConnectionReconfigurationHeader);
372 rrcConnectionReconfigurationMsg = rrcConnectionReconfigurationHeader.GetMessage();
373 m_ueRrcSapProvider->RecvRrcConnectionReconfiguration(rrcConnectionReconfigurationMsg);
374 break;
375 case 5:
376 params.pdcpSdu->RemoveHeader(rrcConnectionReleaseHeader);
377 rrcConnectionReleaseMsg = rrcConnectionReleaseHeader.GetMessage();
378 // m_ueRrcSapProvider->RecvRrcConnectionRelease (rrcConnectionReleaseMsg);
379 break;
380 }
381}
382
384
386 : m_enbRrcSapProvider(nullptr)
387{
388 NS_LOG_FUNCTION(this);
390}
391
393{
394 NS_LOG_FUNCTION(this);
395}
396
397void
399{
400 NS_LOG_FUNCTION(this);
401 delete m_enbRrcSapUser;
402 for (std::map<uint16_t, LteEnbRrcSapProvider::CompleteSetupUeParameters>::iterator it =
405 ++it)
406 {
407 delete it->second.srb0SapUser;
408 delete it->second.srb1SapUser;
409 }
411}
412
413TypeId
415{
416 static TypeId tid = TypeId("ns3::LteEnbRrcProtocolReal")
417 .SetParent<Object>()
418 .SetGroupName("Lte")
419 .AddConstructor<LteEnbRrcProtocolReal>();
420 return tid;
421}
422
423void
425{
427}
428
431{
432 return m_enbRrcSapUser;
433}
434
435void
437{
438 m_cellId = cellId;
439}
440
443{
444 std::map<uint16_t, LteUeRrcSapProvider*>::const_iterator it;
445 it = m_enbRrcSapProviderMap.find(rnti);
446 NS_ASSERT_MSG(it != m_enbRrcSapProviderMap.end(), "could not find RNTI = " << rnti);
447 return it->second;
448}
449
450void
452{
453 std::map<uint16_t, LteUeRrcSapProvider*>::iterator it;
454 it = m_enbRrcSapProviderMap.find(rnti);
455 // assign UE RRC only if the RNTI is found at eNB
456 if (it != m_enbRrcSapProviderMap.end())
457 {
458 it->second = p;
459 }
460}
461
462void
464{
465 NS_LOG_FUNCTION(this << rnti);
466
467 // // walk list of all nodes to get the peer UE RRC SAP Provider
468 // Ptr<LteUeRrc> ueRrc;
469 // NodeList::Iterator listEnd = NodeList::End ();
470 // bool found = false;
471 // for (NodeList::Iterator i = NodeList::Begin (); (i != listEnd) && (found == false); i++)
472 // {
473 // Ptr<Node> node = *i;
474 // int nDevs = node->GetNDevices ();
475 // for (int j = 0; j < nDevs; j++)
476 // {
477 // Ptr<LteUeNetDevice> ueDev = node->GetDevice (j)->GetObject <LteUeNetDevice> ();
478 // if (!ueDev)
479 // {
480 // continue;
481 // }
482 // else
483 // {
484 // ueRrc = ueDev->GetRrc ();
485 // if ((ueRrc->GetRnti () == rnti) && (ueRrc->GetCellId () == m_cellId))
486 // {
487 // found = true;
488 // break;
489 // }
490 // }
491 // }
492 // }
493 // NS_ASSERT_MSG (found , " Unable to find UE with RNTI=" << rnti << " cellId=" << m_cellId);
494 // m_enbRrcSapProviderMap[rnti] = ueRrc->GetLteUeRrcSapProvider ();
495
496 // just create empty entry, the UeRrcSapProvider will be set by the
497 // ue upon connection request or connection reconfiguration
498 // completed
499 m_enbRrcSapProviderMap[rnti] = nullptr;
500
501 // Store SetupUeParameters
503
504 LteEnbRrcSapProvider::CompleteSetupUeParameters completeSetupUeParameters;
505 std::map<uint16_t, LteEnbRrcSapProvider::CompleteSetupUeParameters>::iterator csupIt =
507 if (csupIt == m_completeSetupUeParametersMap.end())
508 {
509 // Create LteRlcSapUser, LtePdcpSapUser
510 LteRlcSapUser* srb0SapUser = new RealProtocolRlcSapUser(this, rnti);
511 LtePdcpSapUser* srb1SapUser =
513 completeSetupUeParameters.srb0SapUser = srb0SapUser;
514 completeSetupUeParameters.srb1SapUser = srb1SapUser;
515 // Store LteRlcSapUser, LtePdcpSapUser
516 m_completeSetupUeParametersMap[rnti] = completeSetupUeParameters;
517 }
518 else
519 {
520 completeSetupUeParameters = csupIt->second;
521 }
522 m_enbRrcSapProvider->CompleteSetupUe(rnti, completeSetupUeParameters);
523}
524
525void
527{
528 NS_LOG_FUNCTION(this << rnti);
529 std::map<uint16_t, LteEnbRrcSapProvider::CompleteSetupUeParameters>::iterator it =
532 delete it->second.srb0SapUser;
533 delete it->second.srb1SapUser;
535 m_enbRrcSapProviderMap.erase(rnti);
536 m_setupUeParametersMap.erase(rnti);
537}
538
539void
541{
542 NS_LOG_FUNCTION(this << cellId);
543 // walk list of all nodes to get UEs with this cellId
544 Ptr<LteUeRrc> ueRrc;
545 for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i)
546 {
547 Ptr<Node> node = *i;
548 int nDevs = node->GetNDevices();
549 for (int j = 0; j < nDevs; ++j)
550 {
551 Ptr<LteUeNetDevice> ueDev = node->GetDevice(j)->GetObject<LteUeNetDevice>();
552 if (ueDev)
553 {
554 Ptr<LteUeRrc> ueRrc = ueDev->GetRrc();
555 NS_LOG_LOGIC("considering UE IMSI " << ueDev->GetImsi() << " that has cellId "
556 << ueRrc->GetCellId());
557 if (ueRrc->GetCellId() == cellId)
558 {
559 NS_LOG_LOGIC("sending SI to IMSI " << ueDev->GetImsi());
560
564 ueRrc->GetLteUeRrcSapProvider(),
565 msg);
566 }
567 }
568 }
569 }
570}
571
572void
574{
575 Ptr<Packet> packet = Create<Packet>();
576
577 RrcConnectionSetupHeader rrcConnectionSetupHeader;
578 rrcConnectionSetupHeader.SetMessage(msg);
579
580 packet->AddHeader(rrcConnectionSetupHeader);
581
582 LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
583 transmitPdcpPduParameters.pdcpPdu = packet;
584 transmitPdcpPduParameters.rnti = rnti;
585 transmitPdcpPduParameters.lcid = 0;
586
587 m_setupUeParametersMap.at(rnti).srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
588}
589
590void
592{
593 Ptr<Packet> packet = Create<Packet>();
594
595 RrcConnectionRejectHeader rrcConnectionRejectHeader;
596 rrcConnectionRejectHeader.SetMessage(msg);
597
598 packet->AddHeader(rrcConnectionRejectHeader);
599
600 LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
601 transmitPdcpPduParameters.pdcpPdu = packet;
602 transmitPdcpPduParameters.rnti = rnti;
603 transmitPdcpPduParameters.lcid = 0;
604
605 m_setupUeParametersMap[rnti].srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
606}
607
608void
610 uint16_t rnti,
612{
613 Ptr<Packet> packet = Create<Packet>();
614
615 RrcConnectionReconfigurationHeader rrcConnectionReconfigurationHeader;
616 rrcConnectionReconfigurationHeader.SetMessage(msg);
617
618 packet->AddHeader(rrcConnectionReconfigurationHeader);
619
620 LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
621 transmitPdcpSduParameters.pdcpSdu = packet;
622 transmitPdcpSduParameters.rnti = rnti;
623 transmitPdcpSduParameters.lcid = 1;
624
625 m_setupUeParametersMap[rnti].srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
626}
627
628void
630 uint16_t rnti,
632{
633 Ptr<Packet> packet = Create<Packet>();
634
635 RrcConnectionReestablishmentHeader rrcConnectionReestablishmentHeader;
636 rrcConnectionReestablishmentHeader.SetMessage(msg);
637
638 packet->AddHeader(rrcConnectionReestablishmentHeader);
639
640 LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
641 transmitPdcpPduParameters.pdcpPdu = packet;
642 transmitPdcpPduParameters.rnti = rnti;
643 transmitPdcpPduParameters.lcid = 0;
644
645 m_setupUeParametersMap[rnti].srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
646}
647
648void
650 uint16_t rnti,
652{
653 Ptr<Packet> packet = Create<Packet>();
654
655 RrcConnectionReestablishmentRejectHeader rrcConnectionReestablishmentRejectHeader;
656 rrcConnectionReestablishmentRejectHeader.SetMessage(msg);
657
658 packet->AddHeader(rrcConnectionReestablishmentRejectHeader);
659
660 LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
661 transmitPdcpPduParameters.pdcpPdu = packet;
662 transmitPdcpPduParameters.rnti = rnti;
663 transmitPdcpPduParameters.lcid = 0;
664
665 m_setupUeParametersMap[rnti].srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
666}
667
668void
671{
672 // The code below is commented so RRC connection release can be sent in an ideal way
673 /*
674 Ptr<Packet> packet = Create<Packet> ();
675
676 RrcConnectionReleaseHeader rrcConnectionReleaseHeader;
677 rrcConnectionReleaseHeader.SetMessage (msg);
678
679 packet->AddHeader (rrcConnectionReleaseHeader);
680
681 LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
682 transmitPdcpSduParameters.pdcpSdu = packet;
683 transmitPdcpSduParameters.rnti = rnti;
684 transmitPdcpSduParameters.lcid = 1;
685
686 m_setupUeParametersMap[rnti].srb1SapProvider->TransmitPdcpSdu (transmitPdcpSduParameters);
687 */
696 NS_LOG_FUNCTION(this << rnti);
700 msg);
701}
702
703void
705{
706 // Get type of message received
707 RrcUlCcchMessage rrcUlCcchMessage;
708 p->PeekHeader(rrcUlCcchMessage);
709
710 // Declare possible headers to receive
711 RrcConnectionReestablishmentRequestHeader rrcConnectionReestablishmentRequestHeader;
712 RrcConnectionRequestHeader rrcConnectionRequestHeader;
713
714 // Deserialize packet and call member recv function with appropriate structure
715 switch (rrcUlCcchMessage.GetMessageType())
716 {
717 case 0:
718 p->RemoveHeader(rrcConnectionReestablishmentRequestHeader);
719 LteRrcSap::RrcConnectionReestablishmentRequest rrcConnectionReestablishmentRequestMsg;
720 rrcConnectionReestablishmentRequestMsg =
721 rrcConnectionReestablishmentRequestHeader.GetMessage();
723 rnti,
724 rrcConnectionReestablishmentRequestMsg);
725 break;
726 case 1:
727 p->RemoveHeader(rrcConnectionRequestHeader);
728 LteRrcSap::RrcConnectionRequest rrcConnectionRequestMsg;
729 rrcConnectionRequestMsg = rrcConnectionRequestHeader.GetMessage();
730 m_enbRrcSapProvider->RecvRrcConnectionRequest(rnti, rrcConnectionRequestMsg);
731 break;
732 }
733}
734
735void
737{
738 // Get type of message received
739 RrcUlDcchMessage rrcUlDcchMessage;
740 params.pdcpSdu->PeekHeader(rrcUlDcchMessage);
741
742 // Declare possible headers to receive
743 MeasurementReportHeader measurementReportHeader;
744 RrcConnectionReconfigurationCompleteHeader rrcConnectionReconfigurationCompleteHeader;
745 RrcConnectionReestablishmentCompleteHeader rrcConnectionReestablishmentCompleteHeader;
746 RrcConnectionSetupCompleteHeader rrcConnectionSetupCompleteHeader;
747
748 // Declare possible messages to receive
749 LteRrcSap::MeasurementReport measurementReportMsg;
750 LteRrcSap::RrcConnectionReconfigurationCompleted rrcConnectionReconfigurationCompleteMsg;
751 LteRrcSap::RrcConnectionReestablishmentComplete rrcConnectionReestablishmentCompleteMsg;
752 LteRrcSap::RrcConnectionSetupCompleted rrcConnectionSetupCompletedMsg;
753
754 // Deserialize packet and call member recv function with appropriate structure
755 switch (rrcUlDcchMessage.GetMessageType())
756 {
757 case 1:
758 params.pdcpSdu->RemoveHeader(measurementReportHeader);
759 measurementReportMsg = measurementReportHeader.GetMessage();
760 m_enbRrcSapProvider->RecvMeasurementReport(params.rnti, measurementReportMsg);
761 break;
762 case 2:
763 params.pdcpSdu->RemoveHeader(rrcConnectionReconfigurationCompleteHeader);
764 rrcConnectionReconfigurationCompleteMsg =
765 rrcConnectionReconfigurationCompleteHeader.GetMessage();
767 params.rnti,
768 rrcConnectionReconfigurationCompleteMsg);
769 break;
770 case 3:
771 params.pdcpSdu->RemoveHeader(rrcConnectionReestablishmentCompleteHeader);
772 rrcConnectionReestablishmentCompleteMsg =
773 rrcConnectionReestablishmentCompleteHeader.GetMessage();
775 params.rnti,
776 rrcConnectionReestablishmentCompleteMsg);
777 break;
778 case 4:
779 params.pdcpSdu->RemoveHeader(rrcConnectionSetupCompleteHeader);
780 rrcConnectionSetupCompletedMsg = rrcConnectionSetupCompleteHeader.GetMessage();
782 rrcConnectionSetupCompletedMsg);
783 break;
784 }
785}
786
790{
792 h.SetMessage(msg);
793
794 Ptr<Packet> p = Create<Packet>();
795 p->AddHeader(h);
796 return p;
797}
798
801{
803 p->RemoveHeader(h);
805 return msg;
806}
807
810{
812 h.SetMessage(msg);
813 Ptr<Packet> p = Create<Packet>();
814 p->AddHeader(h);
815 return p;
816}
817
820{
822 p->RemoveHeader(h);
824 return msg;
825}
826
828
830 : m_pdcp(pdcp),
831 m_rnti(rnti)
832{
833}
834
836{
837}
838
839void
841{
843}
844
845} // namespace ns3
This class manages the serialization/deserialization of HandoverPreparationInfo IE.
void SetMessage(LteRrcSap::HandoverPreparationInfo msg)
Receives a HandoverPreparationInfo IE and stores the contents into the class attributes.
LteRrcSap::HandoverPreparationInfo GetMessage() const
Returns a HandoverPreparationInfo IE from the values in the class attributes.
The eNodeB device implementation.
bool HasCellId(uint16_t cellId) const
Ptr< LteEnbRrc > GetRrc() const
Models the transmission of RRC messages from the UE to the eNB in a real fashion, by creating real RR...
void DoSendRrcConnectionRelease(uint16_t rnti, LteRrcSap::RrcConnectionRelease msg)
Send RRC connection release function.
static TypeId GetTypeId()
Get the type ID.
std::map< uint16_t, LteEnbRrcSapProvider::CompleteSetupUeParameters > m_completeSetupUeParametersMap
complete setup UE parameters map
friend class LtePdcpSpecificLtePdcpSapUser< LteEnbRrcProtocolReal >
allow LtePdcpSpecificLtePdcpSapUser<LteEnbRrcProtocolReal> class friend access
void DoSetupUe(uint16_t rnti, LteEnbRrcSapUser::SetupUeParameters params)
Setup UE function.
LteUeRrcSapProvider * GetUeRrcSapProvider(uint16_t rnti)
Get UE RRC SAP provider function.
void SetCellId(uint16_t cellId)
Set cell ID function.
void DoReceivePdcpSdu(LtePdcpSapUser::ReceivePdcpSduParameters params)
Receive PDCP SDU function.
void DoSendRrcConnectionReestablishmentReject(uint16_t rnti, LteRrcSap::RrcConnectionReestablishmentReject msg)
Send RRC connection reestabishment reject function.
void DoSendSystemInformation(uint16_t cellId, LteRrcSap::SystemInformation msg)
Send system information function.
void DoReceivePdcpPdu(uint16_t rnti, Ptr< Packet > p)
Receive PDCP PDU function.
LteEnbRrcSapProvider * m_enbRrcSapProvider
ENB RRC SAP provider.
Ptr< Packet > DoEncodeHandoverCommand(LteRrcSap::RrcConnectionReconfiguration msg)
Encode handover command function.
LteEnbRrcSapUser * GetLteEnbRrcSapUser()
Get LTE ENB RRC SAP user function.
void DoSendRrcConnectionSetup(uint16_t rnti, LteRrcSap::RrcConnectionSetup msg)
Send RRC connection setup function.
friend class MemberLteEnbRrcSapUser< LteEnbRrcProtocolReal >
allow MemberLteEnbRrcSapUser<LteEnbRrcProtocolReal> class friend access
void DoRemoveUe(uint16_t rnti)
Remove UE function.
Ptr< Packet > DoEncodeHandoverPreparationInformation(LteRrcSap::HandoverPreparationInfo msg)
Encode handover preparation information function.
void SetLteEnbRrcSapProvider(LteEnbRrcSapProvider *p)
Set LTE ENB RRC SAP provider function.
LteEnbRrcSapUser * m_enbRrcSapUser
ENB RRC SAP user.
void DoSendRrcConnectionReject(uint16_t rnti, LteRrcSap::RrcConnectionReject msg)
Send RRC connection reject function.
friend class RealProtocolRlcSapUser
allow RealProtocolRlcSapUser class friend access
void DoDispose() override
Destructor implementation.
std::map< uint16_t, LteEnbRrcSapUser::SetupUeParameters > m_setupUeParametersMap
setup UE parameters map
LteRrcSap::RrcConnectionReconfiguration DoDecodeHandoverCommand(Ptr< Packet > p)
Decode handover command function.
LteRrcSap::HandoverPreparationInfo DoDecodeHandoverPreparationInformation(Ptr< Packet > p)
Decode handover preparation information function.
void DoSendRrcConnectionReestablishment(uint16_t rnti, LteRrcSap::RrcConnectionReestablishment msg)
Send RRC connection reestabishment function.
void SetUeRrcSapProvider(uint16_t rnti, LteUeRrcSapProvider *p)
Set UE RRC SAP provider function.
void DoSendRrcConnectionReconfiguration(uint16_t rnti, LteRrcSap::RrcConnectionReconfiguration msg)
Send RRC connection reconfiguration function.
std::map< uint16_t, LteUeRrcSapProvider * > m_enbRrcSapProviderMap
ENB RRC SAP provider map.
Part of the RRC protocol.
Definition: lte-rrc-sap.h:1244
virtual void RecvRrcConnectionReestablishmentRequest(uint16_t rnti, RrcConnectionReestablishmentRequest msg)=0
Receive an RRCConnectionReestablishmentRequest message from a UE during an RRC connection re-establis...
virtual void RecvRrcConnectionReestablishmentComplete(uint16_t rnti, RrcConnectionReestablishmentComplete msg)=0
Receive an RRCConnectionReestablishmentComplete message from a UE during an RRC connection re-establi...
virtual void RecvRrcConnectionReconfigurationCompleted(uint16_t rnti, RrcConnectionReconfigurationCompleted msg)=0
Receive an RRCConnectionReconfigurationComplete message from a UE during an RRC connection reconfigur...
virtual void RecvRrcConnectionRequest(uint16_t rnti, RrcConnectionRequest msg)=0
Receive an RRCConnectionRequest message from a UE during an RRC connection establishment procedure (S...
virtual void RecvRrcConnectionSetupCompleted(uint16_t rnti, RrcConnectionSetupCompleted msg)=0
Receive an RRCConnectionSetupComplete message from a UE during an RRC connection establishment proced...
virtual void RecvMeasurementReport(uint16_t rnti, MeasurementReport msg)=0
Receive a MeasurementReport message from a UE during a measurement reporting procedure (Section 5....
virtual void CompleteSetupUe(uint16_t rnti, CompleteSetupUeParameters params)=0
Complete setup UE function.
virtual void RecvIdealUeContextRemoveRequest(uint16_t rnti)=0
Receive ideal UE context remove request from the UE RRC.
Part of the RRC protocol.
Definition: lte-rrc-sap.h:1124
virtual void TransmitPdcpSdu(TransmitPdcpSduParameters params)=0
Send RRC PDU parameters to the PDCP for transmission.
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36....
Definition: lte-pdcp-sap.h:69
virtual void TransmitPdcpPdu(TransmitPdcpPduParameters params)=0
Send a PDCP PDU to the RLC for transmission This method is to be called when upper PDCP entity has a ...
Service Access Point (SAP) offered by the UM-RLC and AM-RLC entities to the PDCP entity See 3GPP 36....
Definition: lte-rlc-sap.h:67
The LteUeNetDevice class implements the UE net device.
Models the transmission of RRC messages from the UE to the eNB in a real fashion, by creating real RR...
LteEnbRrcSapProvider * m_enbRrcSapProvider
ENB RRC SAP provider.
LteUeRrcSapProvider * m_ueRrcSapProvider
UE RRC SAP provider.
LteUeRrcSapUser::SetupParameters m_setupParameters
setup parameters
void SetEnbRrcSapProvider()
Set ENB RRC SAP provider.
void DoSendRrcConnectionReconfigurationCompleted(LteRrcSap::RrcConnectionReconfigurationCompleted msg)
Send RRC connection reconfiguration setup completed function.
void SetLteUeRrcSapProvider(LteUeRrcSapProvider *p)
Set LTE UE RRC SAP provider function.
static TypeId GetTypeId()
Get the type ID.
friend class MemberLteUeRrcSapUser< LteUeRrcProtocolReal >
allow MemberLteUeRrcSapUser<LteUeRrcProtocolReal> class friend access
void DoSendRrcConnectionReestablishmentRequest(LteRrcSap::RrcConnectionReestablishmentRequest msg) const
Send RRC connection reestablishment request function.
void DoReceivePdcpPdu(Ptr< Packet > p)
Receive PDCP PDU function.
void DoSendRrcConnectionReestablishmentComplete(LteRrcSap::RrcConnectionReestablishmentComplete msg) const
Send RRC connection reestablishment complete function.
Ptr< LteUeRrc > m_rrc
the RRC
void DoReceivePdcpSdu(LtePdcpSapUser::ReceivePdcpSduParameters params)
Receive PDCP SDU function.
void DoSetup(LteUeRrcSapUser::SetupParameters params)
Setup function.
void DoSendRrcConnectionSetupCompleted(LteRrcSap::RrcConnectionSetupCompleted msg) const
Send RRC connection setup completed function.
void SetUeRrc(Ptr< LteUeRrc > rrc)
Set UE RRC function.
LteUeRrcSapUser * m_ueRrcSapUser
UE RRC SAP user.
void DoSendMeasurementReport(LteRrcSap::MeasurementReport msg)
Send measurement report function.
friend class LtePdcpSpecificLtePdcpSapUser< LteUeRrcProtocolReal >
allow LtePdcpSpecificLtePdcpSapUser<LteUeRrcProtocolReal> class friend access
LteUeRrcSapUser * GetLteUeRrcSapUser()
Get LTE UE RRC SAP user function.
void DoSendIdealUeContextRemoveRequest(uint16_t rnti)
Send ideal UE context remove request function.
void DoDispose() override
Destructor implementation.
void DoSendRrcConnectionRequest(LteRrcSap::RrcConnectionRequest msg)
Send RRC connection request function.
LteUeRrcSapProvider::CompleteSetupParameters m_completeSetupParameters
complete setup parameters
friend class LteRlcSpecificLteRlcSapUser< LteUeRrcProtocolReal >
allow LteRlcSpecificLteRlcSapUser<LteUeRrcProtocolReal> class friend access
Part of the RRC protocol.
Definition: lte-rrc-sap.h:1045
virtual void RecvRrcConnectionReconfiguration(RrcConnectionReconfiguration msg)=0
Receive an RRCConnectionReconfiguration message from the serving eNodeB during an RRC connection reco...
virtual void RecvRrcConnectionReject(RrcConnectionReject msg)=0
Receive an RRCConnectionReject message from the serving eNodeB during an RRC connection establishment...
virtual void RecvSystemInformation(SystemInformation msg)=0
Receive a SystemInformation message from the serving eNodeB during a system information acquisition p...
virtual void CompleteSetup(CompleteSetupParameters params)=0
Complete setup function.
virtual void RecvRrcConnectionRelease(RrcConnectionRelease msg)=0
Receive an RRCConnectionRelease message from the serving eNodeB during an RRC connection release proc...
virtual void RecvRrcConnectionSetup(RrcConnectionSetup msg)=0
Receive an RRCConnectionSetup message from the serving eNodeB during an RRC connection establishment ...
virtual void RecvRrcConnectionReestablishment(RrcConnectionReestablishment msg)=0
Receive an RRCConnectionReestablishment message from the serving eNodeB during an RRC connection re-e...
Part of the RRC protocol.
Definition: lte-rrc-sap.h:960
This class manages the serialization/deserialization of MeasurementReport IE.
LteRrcSap::MeasurementReport GetMessage() const
Returns a MeasurementReport IE from the values in the class attributes.
void SetMessage(LteRrcSap::MeasurementReport msg)
Receives a MeasurementReport IE and stores the contents into the class attributes.
uint32_t GetNDevices() const
Definition: node.cc:162
uint32_t GetId() const
Definition: node.cc:117
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:152
static Iterator Begin()
Definition: node-list.cc:237
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition: node-list.h:44
static Iterator End()
Definition: node-list.cc:244
A base class which provides memory management and object aggregation.
Definition: object.h:89
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:305
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
LteEnbRrcProtocolReal * m_pdcp
PDCP.
void ReceivePdcpPdu(Ptr< Packet > p) override
Called by the RLC entity to notify the PDCP entity of the reception of a new PDCP PDU.
int GetMessageType() const
Get message type.
This class manages the serialization/deserialization of RrcConnectionSetupComplete IE.
LteRrcSap::RrcConnectionReconfigurationCompleted GetMessage() const
Returns a RrcConnectionReconfigurationCompleted IE from the values in the class attributes.
void SetMessage(LteRrcSap::RrcConnectionReconfigurationCompleted msg)
Receives a RrcConnectionReconfigurationCompleted IE and stores the contents into the class attributes...
This class manages the serialization/deserialization of RrcConnectionReconfiguration IE.
LteRrcSap::RrcConnectionReconfiguration GetMessage() const
Returns a RrcConnectionReconfiguration IE from the values in the class attributes.
void SetMessage(LteRrcSap::RrcConnectionReconfiguration msg)
Receives a RrcConnectionReconfiguration IE and stores the contents into the class attributes.
This class manages the serialization/deserialization of RrcConnectionReestablishmentComplete IE.
void SetMessage(LteRrcSap::RrcConnectionReestablishmentComplete msg)
Receives a RrcConnectionReestablishmentComplete IE and stores the contents into the class attributes.
LteRrcSap::RrcConnectionReestablishmentComplete GetMessage() const
Returns a RrcConnectionReestablishmentComplete IE from the values in the class attributes.
This class manages the serialization/deserialization of RrcConnectionReestablishment IE.
LteRrcSap::RrcConnectionReestablishment GetMessage() const
Returns a RrcConnectionReestablishment IE from the values in the class attributes.
void SetMessage(LteRrcSap::RrcConnectionReestablishment msg)
Receives a RrcConnectionReestablishment IE and stores the contents into the class attributes.
This class manages the serialization/deserialization of RrcConnectionReestablishmentReject IE.
void SetMessage(LteRrcSap::RrcConnectionReestablishmentReject msg)
Receives a RrcConnectionReestablishmentReject IE and stores the contents into the class attributes.
LteRrcSap::RrcConnectionReestablishmentReject GetMessage() const
Returns a RrcConnectionReestablishmentReject IE from the values in the class attributes.
This class manages the serialization/deserialization of RRCConnectionReestablishmentRequest IE.
LteRrcSap::RrcConnectionReestablishmentRequest GetMessage() const
Returns a RrcConnectionReestablishmentRequest IE from the values in the class attributes.
void SetMessage(LteRrcSap::RrcConnectionReestablishmentRequest msg)
Receives a RrcConnectionReestablishmentRequest IE and stores the contents into the class attributes.
This class manages the serialization/deserialization of RrcConnectionReject IE.
LteRrcSap::RrcConnectionReject GetMessage() const
Returns a RrcConnectionReject IE from the values in the class attributes.
void SetMessage(LteRrcSap::RrcConnectionReject msg)
Receives a RrcConnectionReject IE and stores the contents into the class attributes.
This class manages the serialization/deserialization of RrcConnectionRelease IE.
LteRrcSap::RrcConnectionRelease GetMessage() const
Returns a RrcConnectionRelease IE from the values in the class attributes.
This class manages the serialization/deserialization of RrcConnectionRequest IE.
void SetMessage(LteRrcSap::RrcConnectionRequest msg)
Receives a RrcConnectionRequest IE and stores the contents into the class attributes.
LteRrcSap::RrcConnectionRequest GetMessage() const
Returns a RrcConnectionRequest IE from the values in the class attributes.
This class manages the serialization/deserialization of RrcConnectionSetupComplete IE.
LteRrcSap::RrcConnectionSetupCompleted GetMessage() const
Returns a RrcConnectionSetupCompleted IE from the values in the class attributes.
void SetMessage(LteRrcSap::RrcConnectionSetupCompleted msg)
Receives a RrcConnectionSetupCompleted IE and stores the contents into the class attributes.
This class manages the serialization/deserialization of RrcConnectionSetup IE.
void SetMessage(LteRrcSap::RrcConnectionSetup msg)
Receives a RrcConnectionSetup IE and stores the contents into the class attributes.
LteRrcSap::RrcConnectionSetup GetMessage() const
Returns a RrcConnectionSetup IE from the values in the class attributes.
This class only serves to discriminate which message type has been received in downlink (eNb to ue) f...
This class only serves to discriminate which message type has been received in downlink (eNb to ue) f...
This class only serves to discriminate which message type has been received in uplink (ue to eNb) for...
This class only serves to discriminate which message type has been received in uplink (ue to eNb) for...
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:587
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const Time RRC_REAL_MSG_DELAY
RRC real message delay.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
CompleteSetupUeParameters structure.
Definition: lte-rrc-sap.h:1248
SetupUeParameters structure.
Definition: lte-rrc-sap.h:1128
Parameters for LtePdcpSapProvider::TransmitPdcpSdu.
Definition: lte-pdcp-sap.h:44
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-pdcp-sap.h:47
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-pdcp-sap.h:46
Parameters for LtePdcpSapUser::ReceivePdcpSdu.
Definition: lte-pdcp-sap.h:77
Parameters for LteRlcSapProvider::TransmitPdcpPdu.
Definition: lte-rlc-sap.h:44
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-rlc-sap.h:47
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-rlc-sap.h:46
HandoverPreparationInfo structure.
Definition: lte-rrc-sap.h:942
MeasurementReport structure.
Definition: lte-rrc-sap.h:948
RrcConnectionReconfigurationCompleted structure.
Definition: lte-rrc-sap.h:898
RrcConnectionReconfiguration structure.
Definition: lte-rrc-sap.h:881
RrcConnectionReestablishmentComplete structure.
Definition: lte-rrc-sap.h:919
RrcConnectionReestablishment structure.
Definition: lte-rrc-sap.h:911
RrcConnectionReestablishmentReject structure.
Definition: lte-rrc-sap.h:925
RrcConnectionReestablishmentRequest structure.
Definition: lte-rrc-sap.h:904
RrcConnectionReject structure.
Definition: lte-rrc-sap.h:936
RrcConnectionRelease structure.
Definition: lte-rrc-sap.h:930
RrcConnectionRequest structure.
Definition: lte-rrc-sap.h:730
RrcConnectionSetupCompleted structure.
Definition: lte-rrc-sap.h:744
RrcConnectionSetup structure.
Definition: lte-rrc-sap.h:736
SystemInformation structure.
Definition: lte-rrc-sap.h:643
LtePdcpSapUser * srb1SapUser
SRB1 SAP user.
Definition: lte-rrc-sap.h:1051
SetupParameters structure.
Definition: lte-rrc-sap.h:964
LteRlcSapProvider * srb0SapProvider
SRB0 SAP provider.
Definition: lte-rrc-sap.h:965
LtePdcpSapProvider * srb1SapProvider
SRB1 SAP provider.
Definition: lte-rrc-sap.h:966