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 
21 #include "lte-rrc-protocol-real.h"
22 
23 #include "lte-enb-net-device.h"
24 #include "lte-enb-rrc.h"
25 #include "lte-rrc-header.h"
26 #include "lte-ue-net-device.h"
27 #include "lte-ue-rrc.h"
28 
29 #include <ns3/fatal-error.h>
30 #include <ns3/log.h>
31 #include <ns3/node-list.h>
32 #include <ns3/node.h>
33 #include <ns3/nstime.h>
34 #include <ns3/simulator.h>
35 
36 namespace ns3
37 {
38 
39 NS_LOG_COMPONENT_DEFINE("LteRrcProtocolReal");
40 
43 
45 
47  : m_ueRrcSapProvider(nullptr),
48  m_enbRrcSapProvider(nullptr)
49 {
55 }
56 
58 {
59 }
60 
61 void
63 {
64  NS_LOG_FUNCTION(this);
65  delete m_ueRrcSapUser;
68  m_rrc = nullptr;
69 }
70 
71 TypeId
73 {
74  static TypeId tid = TypeId("ns3::LteUeRrcProtocolReal")
75  .SetParent<Object>()
76  .SetGroupName("Lte")
77  .AddConstructor<LteUeRrcProtocolReal>();
78  return tid;
79 }
80 
81 void
83 {
85 }
86 
89 {
90  return m_ueRrcSapUser;
91 }
92 
93 void
95 {
96  m_rrc = rrc;
97 }
98 
99 void
101 {
102  NS_LOG_FUNCTION(this);
103 
104  m_setupParameters.srb0SapProvider = params.srb0SapProvider;
105  m_setupParameters.srb1SapProvider = params.srb1SapProvider;
107 }
108 
109 void
111 {
112  // initialize the RNTI and get the EnbLteRrcSapProvider for the
113  // eNB we are currently attached to
114  m_rnti = m_rrc->GetRnti();
116 
117  Ptr<Packet> packet = Create<Packet>();
118 
119  RrcConnectionRequestHeader rrcConnectionRequestHeader;
120  rrcConnectionRequestHeader.SetMessage(msg);
121 
122  packet->AddHeader(rrcConnectionRequestHeader);
123 
124  LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
125  transmitPdcpPduParameters.pdcpPdu = packet;
126  transmitPdcpPduParameters.rnti = m_rnti;
127  transmitPdcpPduParameters.lcid = 0;
128 
129  m_setupParameters.srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
130 }
131 
132 void
135 {
136  Ptr<Packet> packet = Create<Packet>();
137 
138  RrcConnectionSetupCompleteHeader rrcConnectionSetupCompleteHeader;
139  rrcConnectionSetupCompleteHeader.SetMessage(msg);
140 
141  packet->AddHeader(rrcConnectionSetupCompleteHeader);
142 
143  LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
144  transmitPdcpSduParameters.pdcpSdu = packet;
145  transmitPdcpSduParameters.rnti = m_rnti;
146  transmitPdcpSduParameters.lcid = 1;
147 
149  {
150  m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
151  }
152 }
153 
154 void
157 {
158  // re-initialize the RNTI and get the EnbLteRrcSapProvider for the
159  // eNB we are currently attached to
160  m_rnti = m_rrc->GetRnti();
162 
163  Ptr<Packet> packet = Create<Packet>();
164 
165  RrcConnectionReconfigurationCompleteHeader rrcConnectionReconfigurationCompleteHeader;
166  rrcConnectionReconfigurationCompleteHeader.SetMessage(msg);
167 
168  packet->AddHeader(rrcConnectionReconfigurationCompleteHeader);
169 
170  LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
171  transmitPdcpSduParameters.pdcpSdu = packet;
172  transmitPdcpSduParameters.rnti = m_rnti;
173  transmitPdcpSduParameters.lcid = 1;
174 
175  m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
176 }
177 
178 void
180 {
181  // re-initialize the RNTI and get the EnbLteRrcSapProvider for the
182  // eNB we are currently attached to
183  m_rnti = m_rrc->GetRnti();
185 
186  Ptr<Packet> packet = Create<Packet>();
187 
188  MeasurementReportHeader measurementReportHeader;
189  measurementReportHeader.SetMessage(msg);
190 
191  packet->AddHeader(measurementReportHeader);
192 
193  LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
194  transmitPdcpSduParameters.pdcpSdu = packet;
195  transmitPdcpSduParameters.rnti = m_rnti;
196  transmitPdcpSduParameters.lcid = 1;
197 
198  m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
199 }
200 
201 void
203 {
204  NS_LOG_FUNCTION(this << rnti);
205  uint16_t cellId = m_rrc->GetCellId();
206  // re-initialize the RNTI and get the EnbLteRrcSapProvider for the
207  // eNB we are currently attached to or attempting random access to
208  // a target eNB
209  m_rnti = m_rrc->GetRnti();
210 
211  NS_LOG_DEBUG("RNTI " << rnti << " sending UE context remove request to cell id " << cellId);
212  NS_ABORT_MSG_IF(m_rnti != rnti, "RNTI mismatch");
213 
214  SetEnbRrcSapProvider(); // the provider has to be reset since the cell might
215  // have changed due to handover
216  // ideally informing eNB
220  rnti);
221 }
222 
223 void
226 {
227  Ptr<Packet> packet = Create<Packet>();
228 
229  RrcConnectionReestablishmentRequestHeader rrcConnectionReestablishmentRequestHeader;
230  rrcConnectionReestablishmentRequestHeader.SetMessage(msg);
231 
232  packet->AddHeader(rrcConnectionReestablishmentRequestHeader);
233 
234  LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
235  transmitPdcpPduParameters.pdcpPdu = packet;
236  transmitPdcpPduParameters.rnti = m_rnti;
237  transmitPdcpPduParameters.lcid = 0;
238 
239  m_setupParameters.srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
240 }
241 
242 void
245 {
246  Ptr<Packet> packet = Create<Packet>();
247 
248  RrcConnectionReestablishmentCompleteHeader rrcConnectionReestablishmentCompleteHeader;
249  rrcConnectionReestablishmentCompleteHeader.SetMessage(msg);
250 
251  packet->AddHeader(rrcConnectionReestablishmentCompleteHeader);
252 
253  LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
254  transmitPdcpSduParameters.pdcpSdu = packet;
255  transmitPdcpSduParameters.rnti = m_rnti;
256  transmitPdcpSduParameters.lcid = 1;
257 
258  m_setupParameters.srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
259 }
260 
261 void
263 {
264  NS_LOG_FUNCTION(this);
265 
266  uint16_t cellId = m_rrc->GetCellId();
267 
268  NS_LOG_DEBUG("RNTI " << m_rnti << " connected to cell " << cellId);
269 
270  // walk list of all nodes to get the peer eNB
271  Ptr<LteEnbNetDevice> enbDev;
272  auto listEnd = NodeList::End();
273  bool found = false;
274  for (auto i = NodeList::Begin(); (i != listEnd) && (!found); ++i)
275  {
276  Ptr<Node> node = *i;
277  int nDevs = node->GetNDevices();
278  for (int j = 0; (j < nDevs) && (!found); j++)
279  {
280  enbDev = node->GetDevice(j)->GetObject<LteEnbNetDevice>();
281  if (!enbDev)
282  {
283  continue;
284  }
285  else
286  {
287  if (enbDev->HasCellId(cellId))
288  {
289  found = true;
290  break;
291  }
292  }
293  }
294  }
295  NS_ASSERT_MSG(found, " Unable to find eNB with CellId =" << cellId);
296  m_enbRrcSapProvider = enbDev->GetRrc()->GetLteEnbRrcSapProvider();
297  Ptr<LteEnbRrcProtocolReal> enbRrcProtocolReal =
298  enbDev->GetRrc()->GetObject<LteEnbRrcProtocolReal>();
299  enbRrcProtocolReal->SetUeRrcSapProvider(m_rnti, m_ueRrcSapProvider);
300 }
301 
302 void
304 {
305  // Get type of message received
306  RrcDlCcchMessage rrcDlCcchMessage;
307  p->PeekHeader(rrcDlCcchMessage);
308 
309  // Declare possible headers to receive
310  RrcConnectionReestablishmentHeader rrcConnectionReestablishmentHeader;
311  RrcConnectionReestablishmentRejectHeader rrcConnectionReestablishmentRejectHeader;
312  RrcConnectionSetupHeader rrcConnectionSetupHeader;
313  RrcConnectionRejectHeader rrcConnectionRejectHeader;
314 
315  // Declare possible messages
316  LteRrcSap::RrcConnectionReestablishment rrcConnectionReestablishmentMsg;
317  LteRrcSap::RrcConnectionReestablishmentReject rrcConnectionReestablishmentRejectMsg;
318  LteRrcSap::RrcConnectionSetup rrcConnectionSetupMsg;
319  LteRrcSap::RrcConnectionReject rrcConnectionRejectMsg;
320 
321  // Deserialize packet and call member recv function with appropriate structure
322  switch (rrcDlCcchMessage.GetMessageType())
323  {
324  case 0:
325  // RrcConnectionReestablishment
326  p->RemoveHeader(rrcConnectionReestablishmentHeader);
327  rrcConnectionReestablishmentMsg = rrcConnectionReestablishmentHeader.GetMessage();
328  m_ueRrcSapProvider->RecvRrcConnectionReestablishment(rrcConnectionReestablishmentMsg);
329  break;
330  case 1:
331  // RrcConnectionReestablishmentReject
332  p->RemoveHeader(rrcConnectionReestablishmentRejectHeader);
333  rrcConnectionReestablishmentRejectMsg =
334  rrcConnectionReestablishmentRejectHeader.GetMessage();
335  // m_ueRrcSapProvider->RecvRrcConnectionReestablishmentReject
336  // (rrcConnectionReestablishmentRejectMsg);
337  break;
338  case 2:
339  // RrcConnectionReject
340  p->RemoveHeader(rrcConnectionRejectHeader);
341  rrcConnectionRejectMsg = rrcConnectionRejectHeader.GetMessage();
342  m_ueRrcSapProvider->RecvRrcConnectionReject(rrcConnectionRejectMsg);
343  break;
344  case 3:
345  // RrcConnectionSetup
346  p->RemoveHeader(rrcConnectionSetupHeader);
347  rrcConnectionSetupMsg = rrcConnectionSetupHeader.GetMessage();
348  m_ueRrcSapProvider->RecvRrcConnectionSetup(rrcConnectionSetupMsg);
349  break;
350  }
351 }
352 
353 void
355 {
356  // Get type of message received
357  RrcDlDcchMessage rrcDlDcchMessage;
358  params.pdcpSdu->PeekHeader(rrcDlDcchMessage);
359 
360  // Declare possible headers to receive
361  RrcConnectionReconfigurationHeader rrcConnectionReconfigurationHeader;
362  RrcConnectionReleaseHeader rrcConnectionReleaseHeader;
363 
364  // Declare possible messages to receive
365  LteRrcSap::RrcConnectionReconfiguration rrcConnectionReconfigurationMsg;
366  LteRrcSap::RrcConnectionRelease rrcConnectionReleaseMsg;
367 
368  // Deserialize packet and call member recv function with appropriate structure
369  switch (rrcDlDcchMessage.GetMessageType())
370  {
371  case 4:
372  params.pdcpSdu->RemoveHeader(rrcConnectionReconfigurationHeader);
373  rrcConnectionReconfigurationMsg = rrcConnectionReconfigurationHeader.GetMessage();
374  m_ueRrcSapProvider->RecvRrcConnectionReconfiguration(rrcConnectionReconfigurationMsg);
375  break;
376  case 5:
377  params.pdcpSdu->RemoveHeader(rrcConnectionReleaseHeader);
378  rrcConnectionReleaseMsg = rrcConnectionReleaseHeader.GetMessage();
379  // m_ueRrcSapProvider->RecvRrcConnectionRelease (rrcConnectionReleaseMsg);
380  break;
381  }
382 }
383 
385 
387  : m_enbRrcSapProvider(nullptr)
388 {
389  NS_LOG_FUNCTION(this);
391 }
392 
394 {
395  NS_LOG_FUNCTION(this);
396 }
397 
398 void
400 {
401  NS_LOG_FUNCTION(this);
402  delete m_enbRrcSapUser;
403  for (auto it = m_completeSetupUeParametersMap.begin();
404  it != m_completeSetupUeParametersMap.end();
405  ++it)
406  {
407  delete it->second.srb0SapUser;
408  delete it->second.srb1SapUser;
409  }
411 }
412 
413 TypeId
415 {
416  static TypeId tid = TypeId("ns3::LteEnbRrcProtocolReal")
417  .SetParent<Object>()
418  .SetGroupName("Lte")
419  .AddConstructor<LteEnbRrcProtocolReal>();
420  return tid;
421 }
422 
423 void
425 {
427 }
428 
431 {
432  return m_enbRrcSapUser;
433 }
434 
435 void
437 {
438  m_cellId = cellId;
439 }
440 
443 {
444  auto it = m_enbRrcSapProviderMap.find(rnti);
445  NS_ASSERT_MSG(it != m_enbRrcSapProviderMap.end(), "could not find RNTI = " << rnti);
446  return it->second;
447 }
448 
449 void
451 {
452  auto it = m_enbRrcSapProviderMap.find(rnti);
453  // assign UE RRC only if the RNTI is found at eNB
454  if (it != m_enbRrcSapProviderMap.end())
455  {
456  it->second = p;
457  }
458 }
459 
460 void
462 {
463  NS_LOG_FUNCTION(this << rnti);
464 
465  // // walk list of all nodes to get the peer UE RRC SAP Provider
466  // Ptr<LteUeRrc> ueRrc;
467  // NodeList::Iterator listEnd = NodeList::End ();
468  // bool found = false;
469  // for (NodeList::Iterator i = NodeList::Begin (); (i != listEnd) && (found == false); i++)
470  // {
471  // Ptr<Node> node = *i;
472  // int nDevs = node->GetNDevices ();
473  // for (int j = 0; j < nDevs; j++)
474  // {
475  // Ptr<LteUeNetDevice> ueDev = node->GetDevice (j)->GetObject <LteUeNetDevice> ();
476  // if (!ueDev)
477  // {
478  // continue;
479  // }
480  // else
481  // {
482  // ueRrc = ueDev->GetRrc ();
483  // if ((ueRrc->GetRnti () == rnti) && (ueRrc->GetCellId () == m_cellId))
484  // {
485  // found = true;
486  // break;
487  // }
488  // }
489  // }
490  // }
491  // NS_ASSERT_MSG (found , " Unable to find UE with RNTI=" << rnti << " cellId=" << m_cellId);
492  // m_enbRrcSapProviderMap[rnti] = ueRrc->GetLteUeRrcSapProvider ();
493 
494  // just create empty entry, the UeRrcSapProvider will be set by the
495  // ue upon connection request or connection reconfiguration
496  // completed
497  m_enbRrcSapProviderMap[rnti] = nullptr;
498 
499  // Store SetupUeParameters
501 
502  LteEnbRrcSapProvider::CompleteSetupUeParameters completeSetupUeParameters;
503  auto csupIt = m_completeSetupUeParametersMap.find(rnti);
504  if (csupIt == m_completeSetupUeParametersMap.end())
505  {
506  // Create LteRlcSapUser, LtePdcpSapUser
507  LteRlcSapUser* srb0SapUser = new RealProtocolRlcSapUser(this, rnti);
508  LtePdcpSapUser* srb1SapUser =
510  completeSetupUeParameters.srb0SapUser = srb0SapUser;
511  completeSetupUeParameters.srb1SapUser = srb1SapUser;
512  // Store LteRlcSapUser, LtePdcpSapUser
513  m_completeSetupUeParametersMap[rnti] = completeSetupUeParameters;
514  }
515  else
516  {
517  completeSetupUeParameters = csupIt->second;
518  }
519  m_enbRrcSapProvider->CompleteSetupUe(rnti, completeSetupUeParameters);
520 }
521 
522 void
524 {
525  NS_LOG_FUNCTION(this << rnti);
526  auto it = m_completeSetupUeParametersMap.find(rnti);
528  delete it->second.srb0SapUser;
529  delete it->second.srb1SapUser;
531  m_enbRrcSapProviderMap.erase(rnti);
532  m_setupUeParametersMap.erase(rnti);
533 }
534 
535 void
537 {
538  NS_LOG_FUNCTION(this << cellId);
539  // walk list of all nodes to get UEs with this cellId
540  Ptr<LteUeRrc> ueRrc;
541  for (auto i = NodeList::Begin(); i != NodeList::End(); ++i)
542  {
543  Ptr<Node> node = *i;
544  int nDevs = node->GetNDevices();
545  for (int j = 0; j < nDevs; ++j)
546  {
547  Ptr<LteUeNetDevice> ueDev = node->GetDevice(j)->GetObject<LteUeNetDevice>();
548  if (ueDev)
549  {
550  Ptr<LteUeRrc> ueRrc = ueDev->GetRrc();
551  NS_LOG_LOGIC("considering UE IMSI " << ueDev->GetImsi() << " that has cellId "
552  << ueRrc->GetCellId());
553  if (ueRrc->GetCellId() == cellId)
554  {
555  NS_LOG_LOGIC("sending SI to IMSI " << ueDev->GetImsi());
556 
560  ueRrc->GetLteUeRrcSapProvider(),
561  msg);
562  }
563  }
564  }
565  }
566 }
567 
568 void
570 {
571  Ptr<Packet> packet = Create<Packet>();
572 
573  RrcConnectionSetupHeader rrcConnectionSetupHeader;
574  rrcConnectionSetupHeader.SetMessage(msg);
575 
576  packet->AddHeader(rrcConnectionSetupHeader);
577 
578  LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
579  transmitPdcpPduParameters.pdcpPdu = packet;
580  transmitPdcpPduParameters.rnti = rnti;
581  transmitPdcpPduParameters.lcid = 0;
582 
583  m_setupUeParametersMap.at(rnti).srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
584 }
585 
586 void
588 {
589  Ptr<Packet> packet = Create<Packet>();
590 
591  RrcConnectionRejectHeader rrcConnectionRejectHeader;
592  rrcConnectionRejectHeader.SetMessage(msg);
593 
594  packet->AddHeader(rrcConnectionRejectHeader);
595 
596  LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
597  transmitPdcpPduParameters.pdcpPdu = packet;
598  transmitPdcpPduParameters.rnti = rnti;
599  transmitPdcpPduParameters.lcid = 0;
600 
601  m_setupUeParametersMap[rnti].srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
602 }
603 
604 void
606  uint16_t rnti,
608 {
609  Ptr<Packet> packet = Create<Packet>();
610 
611  RrcConnectionReconfigurationHeader rrcConnectionReconfigurationHeader;
612  rrcConnectionReconfigurationHeader.SetMessage(msg);
613 
614  packet->AddHeader(rrcConnectionReconfigurationHeader);
615 
616  LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
617  transmitPdcpSduParameters.pdcpSdu = packet;
618  transmitPdcpSduParameters.rnti = rnti;
619  transmitPdcpSduParameters.lcid = 1;
620 
621  m_setupUeParametersMap[rnti].srb1SapProvider->TransmitPdcpSdu(transmitPdcpSduParameters);
622 }
623 
624 void
626  uint16_t rnti,
628 {
629  Ptr<Packet> packet = Create<Packet>();
630 
631  RrcConnectionReestablishmentHeader rrcConnectionReestablishmentHeader;
632  rrcConnectionReestablishmentHeader.SetMessage(msg);
633 
634  packet->AddHeader(rrcConnectionReestablishmentHeader);
635 
636  LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
637  transmitPdcpPduParameters.pdcpPdu = packet;
638  transmitPdcpPduParameters.rnti = rnti;
639  transmitPdcpPduParameters.lcid = 0;
640 
641  m_setupUeParametersMap[rnti].srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
642 }
643 
644 void
646  uint16_t rnti,
648 {
649  Ptr<Packet> packet = Create<Packet>();
650 
651  RrcConnectionReestablishmentRejectHeader rrcConnectionReestablishmentRejectHeader;
652  rrcConnectionReestablishmentRejectHeader.SetMessage(msg);
653 
654  packet->AddHeader(rrcConnectionReestablishmentRejectHeader);
655 
656  LteRlcSapProvider::TransmitPdcpPduParameters transmitPdcpPduParameters;
657  transmitPdcpPduParameters.pdcpPdu = packet;
658  transmitPdcpPduParameters.rnti = rnti;
659  transmitPdcpPduParameters.lcid = 0;
660 
661  m_setupUeParametersMap[rnti].srb0SapProvider->TransmitPdcpPdu(transmitPdcpPduParameters);
662 }
663 
664 void
667 {
668  // The code below is commented so RRC connection release can be sent in an ideal way
669  /*
670  Ptr<Packet> packet = Create<Packet> ();
671 
672  RrcConnectionReleaseHeader rrcConnectionReleaseHeader;
673  rrcConnectionReleaseHeader.SetMessage (msg);
674 
675  packet->AddHeader (rrcConnectionReleaseHeader);
676 
677  LtePdcpSapProvider::TransmitPdcpSduParameters transmitPdcpSduParameters;
678  transmitPdcpSduParameters.pdcpSdu = packet;
679  transmitPdcpSduParameters.rnti = rnti;
680  transmitPdcpSduParameters.lcid = 1;
681 
682  m_setupUeParametersMap[rnti].srb1SapProvider->TransmitPdcpSdu (transmitPdcpSduParameters);
683  */
692  NS_LOG_FUNCTION(this << rnti);
695  GetUeRrcSapProvider(rnti),
696  msg);
697 }
698 
699 void
701 {
702  // Get type of message received
703  RrcUlCcchMessage rrcUlCcchMessage;
704  p->PeekHeader(rrcUlCcchMessage);
705 
706  // Declare possible headers to receive
707  RrcConnectionReestablishmentRequestHeader rrcConnectionReestablishmentRequestHeader;
708  RrcConnectionRequestHeader rrcConnectionRequestHeader;
709 
710  // Deserialize packet and call member recv function with appropriate structure
711  switch (rrcUlCcchMessage.GetMessageType())
712  {
713  case 0:
714  p->RemoveHeader(rrcConnectionReestablishmentRequestHeader);
715  LteRrcSap::RrcConnectionReestablishmentRequest rrcConnectionReestablishmentRequestMsg;
716  rrcConnectionReestablishmentRequestMsg =
717  rrcConnectionReestablishmentRequestHeader.GetMessage();
719  rnti,
720  rrcConnectionReestablishmentRequestMsg);
721  break;
722  case 1:
723  p->RemoveHeader(rrcConnectionRequestHeader);
724  LteRrcSap::RrcConnectionRequest rrcConnectionRequestMsg;
725  rrcConnectionRequestMsg = rrcConnectionRequestHeader.GetMessage();
726  m_enbRrcSapProvider->RecvRrcConnectionRequest(rnti, rrcConnectionRequestMsg);
727  break;
728  }
729 }
730 
731 void
733 {
734  // Get type of message received
735  RrcUlDcchMessage rrcUlDcchMessage;
736  params.pdcpSdu->PeekHeader(rrcUlDcchMessage);
737 
738  // Declare possible headers to receive
739  MeasurementReportHeader measurementReportHeader;
740  RrcConnectionReconfigurationCompleteHeader rrcConnectionReconfigurationCompleteHeader;
741  RrcConnectionReestablishmentCompleteHeader rrcConnectionReestablishmentCompleteHeader;
742  RrcConnectionSetupCompleteHeader rrcConnectionSetupCompleteHeader;
743 
744  // Declare possible messages to receive
745  LteRrcSap::MeasurementReport measurementReportMsg;
746  LteRrcSap::RrcConnectionReconfigurationCompleted rrcConnectionReconfigurationCompleteMsg;
747  LteRrcSap::RrcConnectionReestablishmentComplete rrcConnectionReestablishmentCompleteMsg;
748  LteRrcSap::RrcConnectionSetupCompleted rrcConnectionSetupCompletedMsg;
749 
750  // Deserialize packet and call member recv function with appropriate structure
751  switch (rrcUlDcchMessage.GetMessageType())
752  {
753  case 1:
754  params.pdcpSdu->RemoveHeader(measurementReportHeader);
755  measurementReportMsg = measurementReportHeader.GetMessage();
756  m_enbRrcSapProvider->RecvMeasurementReport(params.rnti, measurementReportMsg);
757  break;
758  case 2:
759  params.pdcpSdu->RemoveHeader(rrcConnectionReconfigurationCompleteHeader);
760  rrcConnectionReconfigurationCompleteMsg =
761  rrcConnectionReconfigurationCompleteHeader.GetMessage();
763  params.rnti,
764  rrcConnectionReconfigurationCompleteMsg);
765  break;
766  case 3:
767  params.pdcpSdu->RemoveHeader(rrcConnectionReestablishmentCompleteHeader);
768  rrcConnectionReestablishmentCompleteMsg =
769  rrcConnectionReestablishmentCompleteHeader.GetMessage();
771  params.rnti,
772  rrcConnectionReestablishmentCompleteMsg);
773  break;
774  case 4:
775  params.pdcpSdu->RemoveHeader(rrcConnectionSetupCompleteHeader);
776  rrcConnectionSetupCompletedMsg = rrcConnectionSetupCompleteHeader.GetMessage();
778  rrcConnectionSetupCompletedMsg);
779  break;
780  }
781 }
782 
786 {
788  h.SetMessage(msg);
789 
790  Ptr<Packet> p = Create<Packet>();
791  p->AddHeader(h);
792  return p;
793 }
794 
797 {
799  p->RemoveHeader(h);
801  return msg;
802 }
803 
806 {
808  h.SetMessage(msg);
809  Ptr<Packet> p = Create<Packet>();
810  p->AddHeader(h);
811  return p;
812 }
813 
816 {
818  p->RemoveHeader(h);
820  return msg;
821 }
822 
824 
826  : m_pdcp(pdcp),
827  m_rnti(rnti)
828 {
829 }
830 
832 {
833 }
834 
835 void
837 {
839 }
840 
841 } // 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
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:77
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:571
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
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:931
#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:1338
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