A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-enb-rrc.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 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  * Authors: Nicola Baldo <nbaldo@cttc.es>
19  * Marco Miozzo <mmiozzo@cttc.es>
20  * Manuel Requena <manuel.requena@cttc.es>
21  */
22 
23 #include "lte-enb-rrc.h"
24 
25 #include <ns3/fatal-error.h>
26 #include <ns3/log.h>
27 #include <ns3/abort.h>
28 
29 #include <ns3/pointer.h>
30 #include <ns3/object-map.h>
31 #include <ns3/object-factory.h>
32 #include <ns3/simulator.h>
33 
34 #include <ns3/lte-radio-bearer-info.h>
35 #include <ns3/eps-bearer-tag.h>
36 #include <ns3/packet.h>
37 
38 #include <ns3/lte-rlc.h>
39 #include <ns3/lte-rlc-tm.h>
40 #include <ns3/lte-rlc-um.h>
41 #include <ns3/lte-rlc-am.h>
42 #include <ns3/lte-pdcp.h>
43 
44 
45 
46 
47 NS_LOG_COMPONENT_DEFINE ("LteEnbRrc");
48 
49 
50 namespace ns3 {
51 
52 
54 // CMAC SAP forwarder
56 
61 {
62 public:
64 
65  virtual uint16_t AllocateTemporaryCellRnti ();
66  virtual void NotifyLcConfigResult (uint16_t rnti, uint8_t lcid, bool success);
67  virtual void RrcConfigurationUpdateInd (UeConfig params);
68 
69 private:
71 };
72 
74  : m_rrc (rrc)
75 {
76 }
77 
78 uint16_t
80 {
82 }
83 
84 void
85 EnbRrcMemberLteEnbCmacSapUser::NotifyLcConfigResult (uint16_t rnti, uint8_t lcid, bool success)
86 {
87  m_rrc->DoNotifyLcConfigResult (rnti, lcid, success);
88 }
89 
90 void
92 {
94 }
95 
96 
97 
99 // UeManager
101 
102 
104 {
105  "INITIAL_RANDOM_ACCESS",
106  "CONNECTION_SETUP",
107  "CONNECTION_REJECTED",
108  "CONNECTED_NORMALLY",
109  "CONNECTION_RECONFIGURATION",
110  "CONNECTION_REESTABLISHMENT",
111  "HANDOVER_PREPARATION",
112  "HANDOVER_JOINING",
113  "HANDOVER_PATH_SWITCH",
114  "HANDOVER_LEAVING",
115 };
116 
118 {
119  return std::string (g_ueManagerStateName[s]);
120 }
121 
122 
123 NS_OBJECT_ENSURE_REGISTERED (UeManager)
124  ;
125 
126 
128 {
129  NS_FATAL_ERROR ("this constructor is not espected to be used");
130 }
131 
132 
134  : m_lastAllocatedDrbid (0),
135  m_rnti (rnti),
136  m_imsi (0),
137  m_lastRrcTransactionIdentifier (0),
138  m_rrc (rrc),
139  m_state (s),
140  m_pendingRrcConnectionReconfiguration (false),
141  m_sourceX2apId (0),
142  m_sourceCellId (0),
143  m_needTransmissionModeConfiguration (false)
144 {
145  NS_LOG_FUNCTION (this);
146 }
147 
148 void
150 {
151  NS_LOG_FUNCTION (this);
153 
155  m_physicalConfigDedicated.antennaInfo.transmissionMode = m_rrc->m_defaultTransmissionMode;
160 
161  m_rrc->m_cmacSapProvider->AddUe (m_rnti);
162  m_rrc->m_cphySapProvider->AddUe (m_rnti);
163 
164  // setup the eNB side of SRB0
165  {
166  uint8_t lcid = 0;
167 
168  Ptr<LteRlc> rlc = CreateObject<LteRlcTm> ()->GetObject<LteRlc> ();
169  rlc->SetLteMacSapProvider (m_rrc->m_macSapProvider);
170  rlc->SetRnti (m_rnti);
171  rlc->SetLcId (lcid);
172 
173  m_srb0 = CreateObject<LteSignalingRadioBearerInfo> ();
174  m_srb0->m_rlc = rlc;
175  m_srb0->m_srbIdentity = 0;
176  // no need to store logicalChannelConfig as SRB0 is pre-configured
177 
179  lcinfo.rnti = m_rnti;
180  lcinfo.lcId = lcid;
181  // leave the rest of lcinfo empty as CCCH (LCID 0) is pre-configured
182  m_rrc->m_cmacSapProvider->AddLc (lcinfo, rlc->GetLteMacSapUser ());
183 
184  }
185 
186  // setup the eNB side of SRB1; the UE side will be set up upon RRC connection establishment
187  {
188  uint8_t lcid = 1;
189 
190  Ptr<LteRlc> rlc = CreateObject<LteRlcAm> ()->GetObject<LteRlc> ();
191  rlc->SetLteMacSapProvider (m_rrc->m_macSapProvider);
192  rlc->SetRnti (m_rnti);
193  rlc->SetLcId (lcid);
194 
195  Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> ();
196  pdcp->SetRnti (m_rnti);
197  pdcp->SetLcId (lcid);
198  pdcp->SetLtePdcpSapUser (m_drbPdcpSapUser);
199  pdcp->SetLteRlcSapProvider (rlc->GetLteRlcSapProvider ());
200  rlc->SetLteRlcSapUser (pdcp->GetLteRlcSapUser ());
201 
202  m_srb1 = CreateObject<LteSignalingRadioBearerInfo> ();
203  m_srb1->m_rlc = rlc;
204  m_srb1->m_pdcp = pdcp;
205  m_srb1->m_srbIdentity = 1;
206  m_srb1->m_logicalChannelConfig.priority = 0;
207  m_srb1->m_logicalChannelConfig.prioritizedBitRateKbps = 100;
208  m_srb1->m_logicalChannelConfig.bucketSizeDurationMs = 100;
209  m_srb1->m_logicalChannelConfig.logicalChannelGroup = 0;
210 
212  lcinfo.rnti = m_rnti;
213  lcinfo.lcId = lcid;
214  lcinfo.lcGroup = 0; // all SRBs always mapped to LCG 0
215  lcinfo.qci = EpsBearer::GBR_CONV_VOICE; // not sure why the FF API requires a CQI even for SRBs...
216  lcinfo.isGbr = true;
217  lcinfo.mbrUl = 1e6;
218  lcinfo.mbrDl = 1e6;
219  lcinfo.gbrUl = 1e4;
220  lcinfo.gbrDl = 1e4;
221  m_rrc->m_cmacSapProvider->AddLc (lcinfo, rlc->GetLteMacSapUser ());
222  }
223 
225  ueParams.srb0SapProvider = m_srb0->m_rlc->GetLteRlcSapProvider ();
226  ueParams.srb1SapProvider = m_srb1->m_pdcp->GetLtePdcpSapProvider ();
227  m_rrc->m_rrcSapUser->SetupUe (m_rnti, ueParams);
228 
229  // configure MAC (and scheduler)
231  req.m_rnti = m_rnti;
233  m_rrc->m_cmacSapProvider->UeUpdateConfigurationReq (req);
234 
235  // configure PHY
236  m_rrc->m_cphySapProvider->SetTransmissionMode (m_rnti, m_physicalConfigDedicated.antennaInfo.transmissionMode);
237  m_rrc->m_cphySapProvider->SetSrsConfigurationIndex (m_rnti, m_physicalConfigDedicated.soundingRsUlConfigDedicated.srsConfigIndex);
238 
239  // schedule this UeManager instance to be deleted if the UE does not give any sign of life within a reasonable time
240  Time maxConnectionDelay;
241  switch (m_state)
242  {
244  m_connectionTimeout = Simulator::Schedule (m_rrc->m_connectionTimeoutDuration,
246  m_rrc, m_rnti);
247  break;
248 
249  case HANDOVER_JOINING:
250  m_handoverJoiningTimeout = Simulator::Schedule (m_rrc->m_handoverJoiningTimeoutDuration,
252  m_rrc, m_rnti);
253  break;
254 
255  default:
256  NS_FATAL_ERROR ("unexpected state " << ToString (m_state));
257  break;
258  }
259 
260 }
261 
262 
264 {
265 }
266 
267 void
269 {
270  delete m_drbPdcpSapUser;
271  // delete eventual X2-U TEIDs
272  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
273  it != m_drbMap.end ();
274  ++it)
275  {
276  m_rrc->m_x2uTeidInfoMap.erase (it->second->m_gtpTeid);
277  }
278 
279 }
280 
282 {
283  static TypeId tid = TypeId ("ns3::UeManager")
284  .SetParent<Object> ()
285  .AddConstructor<UeManager> ()
286  .AddAttribute ("DataRadioBearerMap", "List of UE DataRadioBearerInfo by DRBID.",
287  ObjectMapValue (),
289  MakeObjectMapChecker<LteDataRadioBearerInfo> ())
290  .AddAttribute ("Srb0", "SignalingRadioBearerInfo for SRB0",
291  PointerValue (),
292  MakePointerAccessor (&UeManager::m_srb0),
293  MakePointerChecker<LteSignalingRadioBearerInfo> ())
294  .AddAttribute ("Srb1", "SignalingRadioBearerInfo for SRB1",
295  PointerValue (),
296  MakePointerAccessor (&UeManager::m_srb1),
297  MakePointerChecker<LteSignalingRadioBearerInfo> ())
298  .AddAttribute ("C-RNTI",
299  "Cell Radio Network Temporary Identifier",
300  TypeId::ATTR_GET, // read-only attribute
301  UintegerValue (0), // unused, read-only attribute
302  MakeUintegerAccessor (&UeManager::m_rnti),
303  MakeUintegerChecker<uint16_t> ())
304  .AddTraceSource ("StateTransition",
305  "fired upon every UE state transition seen by the UeManager at the eNB RRC",
307  ;
308  return tid;
309 }
310 
311 void
312 UeManager::SetSource (uint16_t sourceCellId, uint16_t sourceX2apId)
313 {
314  m_sourceX2apId = sourceX2apId;
315  m_sourceCellId = sourceCellId;
316 }
317 
318 void
319 UeManager::SetImsi (uint64_t imsi)
320 {
321  m_imsi = imsi;
322 }
323 
324 void
325 UeManager::SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint32_t gtpTeid, Ipv4Address transportLayerAddress)
326 {
327  NS_LOG_FUNCTION (this << (uint32_t) m_rnti);
328 
329  Ptr<LteDataRadioBearerInfo> drbInfo = CreateObject<LteDataRadioBearerInfo> ();
330  uint8_t drbid = AddDataRadioBearerInfo (drbInfo);
331  uint8_t lcid = Drbid2Lcid (drbid);
332  uint8_t bid = Drbid2Bid (drbid);
333  NS_ASSERT_MSG ( bearerId == 0 || bid == bearerId, "bearer ID mismatch (" << (uint32_t) bid << " != " << (uint32_t) bearerId << ", the assumption that ID are allocated in the same way by MME and RRC is not valid any more");
334  drbInfo->m_epsBearerIdentity = bid;
335  drbInfo->m_drbIdentity = drbid;
336  drbInfo->m_logicalChannelIdentity = lcid;
337  drbInfo->m_gtpTeid = gtpTeid;
338  drbInfo->m_transportLayerAddress = transportLayerAddress;
339 
340  if (m_state == HANDOVER_JOINING)
341  {
342  // setup TEIDs for receiving data eventually forwarded over X2-U
343  LteEnbRrc::X2uTeidInfo x2uTeidInfo;
344  x2uTeidInfo.rnti = m_rnti;
345  x2uTeidInfo.drbid = drbid;
346  std::pair<std::map<uint32_t, LteEnbRrc::X2uTeidInfo>::iterator, bool>
347  ret = m_rrc->m_x2uTeidInfoMap.insert (std::pair<uint32_t, LteEnbRrc::X2uTeidInfo> (gtpTeid, x2uTeidInfo));
348  NS_ASSERT_MSG (ret.second == true, "overwriting a pre-existing entry in m_x2uTeidInfoMap");
349  }
350 
351  TypeId rlcTypeId = m_rrc->GetRlcType (bearer);
352 
353  ObjectFactory rlcObjectFactory;
354  rlcObjectFactory.SetTypeId (rlcTypeId);
355  Ptr<LteRlc> rlc = rlcObjectFactory.Create ()->GetObject<LteRlc> ();
356  rlc->SetLteMacSapProvider (m_rrc->m_macSapProvider);
357  rlc->SetRnti (m_rnti);
358 
359  drbInfo->m_rlc = rlc;
360 
361  rlc->SetLcId (lcid);
362 
363  // we need PDCP only for real RLC, i.e., RLC/UM or RLC/AM
364  // if we are using RLC/SM we don't care of anything above RLC
365  if (rlcTypeId != LteRlcSm::GetTypeId ())
366  {
367  Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> ();
368  pdcp->SetRnti (m_rnti);
369  pdcp->SetLcId (lcid);
370  pdcp->SetLtePdcpSapUser (m_drbPdcpSapUser);
371  pdcp->SetLteRlcSapProvider (rlc->GetLteRlcSapProvider ());
372  rlc->SetLteRlcSapUser (pdcp->GetLteRlcSapUser ());
373  drbInfo->m_pdcp = pdcp;
374  }
375 
377  lcinfo.rnti = m_rnti;
378  lcinfo.lcId = lcid;
379  lcinfo.lcGroup = m_rrc->GetLogicalChannelGroup (bearer);
380  lcinfo.qci = bearer.qci;
381  lcinfo.isGbr = bearer.IsGbr ();
382  lcinfo.mbrUl = bearer.gbrQosInfo.mbrUl;
383  lcinfo.mbrDl = bearer.gbrQosInfo.mbrDl;
384  lcinfo.gbrUl = bearer.gbrQosInfo.gbrUl;
385  lcinfo.gbrDl = bearer.gbrQosInfo.gbrDl;
386  m_rrc->m_cmacSapProvider->AddLc (lcinfo, rlc->GetLteMacSapUser ());
387 
388  if (rlcTypeId == LteRlcAm::GetTypeId ())
389  {
390  drbInfo->m_rlcConfig.choice = LteRrcSap::RlcConfig::AM;
391  }
392  else
393  {
394  drbInfo->m_rlcConfig.choice = LteRrcSap::RlcConfig::UM_BI_DIRECTIONAL;
395  }
396 
397  drbInfo->m_logicalChannelIdentity = lcid;
398  drbInfo->m_logicalChannelConfig.priority = m_rrc->GetLogicalChannelPriority (bearer);
399  drbInfo->m_logicalChannelConfig.logicalChannelGroup = m_rrc->GetLogicalChannelGroup (bearer);
400  if (bearer.IsGbr ())
401  {
402  drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = bearer.gbrQosInfo.gbrUl;
403  }
404  else
405  {
406  drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = 0;
407  }
408  drbInfo->m_logicalChannelConfig.bucketSizeDurationMs = 1000;
409 
411 }
412 
413 void
415 {
416  NS_LOG_FUNCTION (this << (uint32_t) m_rnti);
417  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
418  it != m_drbMap.end ();
419  ++it)
420  {
421  m_drbsToBeStarted.push_back (it->first);
422  }
423 }
424 
425 void
427 {
428  NS_LOG_FUNCTION (this << (uint32_t) m_rnti);
429  for (std::list <uint8_t>::iterator drbIdIt = m_drbsToBeStarted.begin ();
430  drbIdIt != m_drbsToBeStarted.end ();
431  ++drbIdIt)
432  {
433  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt = m_drbMap.find (*drbIdIt);
434  NS_ASSERT (drbIt != m_drbMap.end ());
435  drbIt->second->m_rlc->Initialize ();
436  if (drbIt->second->m_pdcp)
437  {
438  drbIt->second->m_pdcp->Initialize ();
439  }
440  }
441  m_drbsToBeStarted.clear ();
442 }
443 
444 
445 void
447 {
448  NS_LOG_FUNCTION (this << (uint32_t) m_rnti << (uint32_t) drbid);
449  uint8_t lcid = Drbid2Lcid (drbid);
450  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid);
451  NS_ASSERT_MSG (it != m_drbMap.end (), "request to remove radio bearer with unknown drbid " << drbid);
452 
453  // first delete eventual X2-U TEIDs
454  m_rrc->m_x2uTeidInfoMap.erase (it->second->m_gtpTeid);
455 
456  m_drbMap.erase (it);
457  m_rrc->m_cmacSapProvider->ReleaseLc (m_rnti, lcid);
458 
460  rrcd.havePhysicalConfigDedicated = false;
461  rrcd.drbToReleaseList.push_back (drbid);
462 
464  msg.haveMeasConfig = false;
465  msg.haveMobilityControlInfo = false;
466 
467  m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, msg);
468 }
469 
470 
471 void
473 {
474  NS_LOG_FUNCTION (this);
475  switch (m_state)
476  {
478  case CONNECTION_SETUP:
482  case HANDOVER_JOINING:
483  case HANDOVER_LEAVING:
484  // a previous reconfiguration still ongoing, we need to wait for it to be finished
486  break;
487 
488  case CONNECTED_NORMALLY:
489  {
492  m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, msg);
495  }
496  break;
497 
498  default:
499  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
500  break;
501  }
502 }
503 
504 void
505 UeManager::PrepareHandover (uint16_t cellId)
506 {
507  NS_LOG_FUNCTION (this << cellId);
508  switch (m_state)
509  {
510  case CONNECTED_NORMALLY:
511  {
512  m_targetCellId = cellId;
514  params.oldEnbUeX2apId = m_rnti;
516  params.sourceCellId = m_rrc->m_cellId;
517  params.targetCellId = cellId;
518  params.mmeUeS1apId = m_imsi;
519  params.ueAggregateMaxBitRateDownlink = 200 * 1000;
520  params.ueAggregateMaxBitRateUplink = 100 * 1000;
521  params.bearers = GetErabList ();
522 
525  hpi.asConfig.sourceDlCarrierFreq = m_rrc->m_dlEarfcn;
526  hpi.asConfig.sourceMeasConfig = m_rrc->m_ueMeasConfig;
530  hpi.asConfig.sourceSystemInformationBlockType1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity = m_rrc->m_sib1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity;
532  hpi.asConfig.sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIndication = m_rrc->m_sib1.cellAccessRelatedInfo.csgIndication;
533  hpi.asConfig.sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIdentity = m_rrc->m_sib1.cellAccessRelatedInfo.csgIdentity;
534  LteEnbCmacSapProvider::RachConfig rc = m_rrc->m_cmacSapProvider->GetRachConfig ();
540  params.rrcContext = m_rrc->m_rrcSapUser->EncodeHandoverPreparationInformation (hpi);
541 
542  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
543  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
544  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
545  NS_LOG_LOGIC ("mmeUeS1apId = " << params.mmeUeS1apId);
546  NS_LOG_LOGIC ("rrcContext = " << params.rrcContext);
547 
548  m_rrc->m_x2SapProvider->SendHandoverRequest (params);
550  }
551  break;
552 
553  default:
554  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
555  break;
556  }
557 
558 }
559 
560 void
562 {
563  NS_LOG_FUNCTION (this);
564 
565  NS_ASSERT_MSG (params.notAdmittedBearers.empty (), "not admission of some bearers upon handover is not supported");
566  NS_ASSERT_MSG (params.admittedBearers.size () == m_drbMap.size (), "not enough bearers in admittedBearers");
567 
568  // note: the Handover command from the target eNB to the source eNB
569  // is expected to be sent transparently to the UE; however, here we
570  // decode the message and eventually reencode it. This way we can
571  // support both a real RRC protocol implementation and an ideal one
572  // without actual RRC protocol encoding.
573 
574  Ptr<Packet> encodedHandoverCommand = params.rrcContext;
575  LteRrcSap::RrcConnectionReconfiguration handoverCommand = m_rrc->m_rrcSapUser->DecodeHandoverCommand (encodedHandoverCommand);
576  m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, handoverCommand);
578  m_handoverLeavingTimeout = Simulator::Schedule (m_rrc->m_handoverLeavingTimeoutDuration,
580  m_rrc, m_rnti);
581  NS_ASSERT (handoverCommand.haveMobilityControlInfo);
582  m_rrc->m_handoverStartTrace (m_imsi, m_rrc->m_cellId, m_rnti, handoverCommand.mobilityControlInfo.targetPhysCellId);
583 
585  sst.oldEnbUeX2apId = params.oldEnbUeX2apId;
586  sst.newEnbUeX2apId = params.newEnbUeX2apId;
587  sst.sourceCellId = params.sourceCellId;
588  sst.targetCellId = params.targetCellId;
589  for ( std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt = m_drbMap.begin ();
590  drbIt != m_drbMap.end ();
591  ++drbIt)
592  {
593  // SN status transfer is only for AM RLC
594  if (0 != drbIt->second->m_rlc->GetObject<LteRlcAm> ())
595  {
596  LtePdcp::Status status = drbIt->second->m_pdcp->GetStatus ();
598  i.dlPdcpSn = status.txSn;
599  i.ulPdcpSn = status.rxSn;
600  sst.erabsSubjectToStatusTransferList.push_back (i);
601  }
602  }
603  m_rrc->m_x2SapProvider->SendSnStatusTransfer (sst);
604 }
605 
606 
609 {
610  NS_LOG_FUNCTION (this);
612 }
613 
616 {
617  NS_LOG_FUNCTION (this);
619 }
620 
621 void
623 {
624  NS_LOG_FUNCTION (this << p << (uint16_t) bid);
625  switch (m_state)
626  {
628  case CONNECTION_SETUP:
629  NS_LOG_WARN ("not connected, discarding packet");
630  return;
631  break;
632 
633  case CONNECTED_NORMALLY:
637  case HANDOVER_JOINING:
639  {
640  NS_LOG_LOGIC ("queueing data on PDCP for transmission over the air");
642  params.pdcpSdu = p;
643  params.rnti = m_rnti;
644  params.lcid = Bid2Lcid (bid);
645  uint8_t drbid = Bid2Drbid (bid);
646  LtePdcpSapProvider* pdcpSapProvider = GetDataRadioBearerInfo (drbid)->m_pdcp->GetLtePdcpSapProvider ();
647  pdcpSapProvider->TransmitPdcpSdu (params);
648  }
649  break;
650 
651  case HANDOVER_LEAVING:
652  {
653  NS_LOG_LOGIC ("forwarding data to target eNB over X2-U");
654  uint8_t drbid = Bid2Drbid (bid);
655  EpcX2Sap::UeDataParams params;
656  params.sourceCellId = m_rrc->m_cellId;
657  params.targetCellId = m_targetCellId;
658  params.gtpTeid = GetDataRadioBearerInfo (drbid)->m_gtpTeid;
659  params.ueData = p;
660  m_rrc->m_x2SapProvider->SendUeData (params);
661  }
662  break;
663 
664  default:
665  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
666  break;
667  }
668 }
669 
670 std::vector<EpcX2Sap::ErabToBeSetupItem>
672 {
673  NS_LOG_FUNCTION (this);
674  std::vector<EpcX2Sap::ErabToBeSetupItem> ret;
675  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
676  it != m_drbMap.end ();
677  ++it)
678  {
680  etbsi.erabId = it->second->m_epsBearerIdentity;
681  etbsi.erabLevelQosParameters = it->second->m_epsBearer;
682  etbsi.dlForwarding = false;
683  etbsi.transportLayerAddress = it->second->m_transportLayerAddress;
684  etbsi.gtpTeid = it->second->m_gtpTeid;
685  ret.push_back (etbsi);
686  }
687  return ret;
688 }
689 
690 void
692 {
693  NS_LOG_FUNCTION (this);
694  switch (m_state)
695  {
697  NS_LOG_INFO ("Send UE CONTEXT RELEASE from target eNB to source eNB");
698  EpcX2SapProvider::UeContextReleaseParams ueCtxReleaseParams;
699  ueCtxReleaseParams.oldEnbUeX2apId = m_sourceX2apId;
700  ueCtxReleaseParams.newEnbUeX2apId = m_rnti;
701  ueCtxReleaseParams.sourceCellId = m_sourceCellId;
702  m_rrc->m_x2SapProvider->SendUeContextRelease (ueCtxReleaseParams);
704  m_rrc->m_handoverEndOkTrace (m_imsi, m_rrc->m_cellId, m_rnti);
705  break;
706 
707  default:
708  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
709  break;
710  }
711 }
712 
713 void
715 {
716  NS_LOG_FUNCTION (this << cellId);
717  switch (m_state)
718  {
719  case HANDOVER_PREPARATION:
720  NS_ASSERT (cellId == m_targetCellId);
721  NS_LOG_INFO ("target eNB sent HO preparation failure, aborting HO");
723  break;
724 
725  default:
726  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
727  break;
728  }
729 }
730 
731 void
733 {
734  NS_LOG_FUNCTION (this);
735  for (std::vector<EpcX2Sap::ErabsSubjectToStatusTransferItem>::iterator erabIt
736  = params.erabsSubjectToStatusTransferList.begin ();
737  erabIt != params.erabsSubjectToStatusTransferList.end ();
738  ++erabIt)
739  {
740  // LtePdcp::Status status;
741  // status.txSn = erabIt->dlPdcpSn;
742  // status.rxSn = erabIt->ulPdcpSn;
743  // uint8_t drbId = Bid2Drbid (erabIt->erabId);
744  // std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt = m_drbMap.find (drbId);
745  // NS_ASSERT_MSG (drbIt != m_drbMap.end (), "could not find DRBID " << (uint32_t) drbId);
746  // drbIt->second->m_pdcp->SetStatus (status);
747  }
748 }
749 
750 void
752 {
753  NS_LOG_FUNCTION (this);
754  NS_ASSERT_MSG (m_state == HANDOVER_LEAVING, "method unexpected in state " << ToString (m_state));
756 }
757 
758 
759 // methods forwarded from RRC SAP
760 
761 void
763 {
764  NS_LOG_FUNCTION (this);
765  m_srb0->m_rlc->SetLteRlcSapUser (params.srb0SapUser);
766  m_srb1->m_pdcp->SetLtePdcpSapUser (params.srb1SapUser);
767 }
768 
769 void
771 {
772  NS_LOG_FUNCTION (this);
773  switch (m_state)
774  {
775  case INITIAL_RANDOM_ACCESS:
776  {
777  if (m_rrc->m_admitRrcConnectionRequest == true)
778  {
780  m_imsi = msg.ueIdentity;
781  if (m_rrc->m_s1SapProvider != 0)
782  {
783  m_rrc->m_s1SapProvider->InitialUeMessage (m_imsi, m_rnti);
784  }
788  m_rrc->m_rrcSapUser->SendRrcConnectionSetup (m_rnti, msg2);
791  }
792  else
793  {
795  NS_LOG_INFO ("rejecting connection request for RNTI " << m_rnti);
797  rejectMsg.waitTime = 3;
798  m_rrc->m_rrcSapUser->SendRrcConnectionReject (m_rnti, rejectMsg);
799  m_connectionRejectedTimeout = Simulator::Schedule (m_rrc->m_connectionRejectedTimeoutDuration,
801  m_rrc, m_rnti);
803  }
804  }
805  break;
806 
807  default:
808  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
809  break;
810  }
811 }
812 
813 void
815 {
816  NS_LOG_FUNCTION (this);
817  switch (m_state)
818  {
819  case CONNECTION_SETUP:
822  m_rrc->m_connectionEstablishedTrace (m_imsi, m_rrc->m_cellId, m_rnti);
823  break;
824 
825  default:
826  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
827  break;
828  }
829 }
830 
831 void
833 {
834  NS_LOG_FUNCTION (this);
835  switch (m_state)
836  {
840  {
841  // configure MAC (and scheduler)
843  req.m_rnti = m_rnti;
845  m_rrc->m_cmacSapProvider->UeUpdateConfigurationReq (req);
846 
847  // configure PHY
848  m_rrc->m_cphySapProvider->SetTransmissionMode (req.m_rnti, req.m_transmissionMode);
849 
851  }
853  m_rrc->m_connectionReconfigurationTrace (m_imsi, m_rrc->m_cellId, m_rnti);
854  break;
855 
856  case HANDOVER_LEAVING:
857  NS_LOG_INFO ("ignoring RecvRrcConnectionReconfigurationCompleted in state " << ToString (m_state));
858  break;
859 
860  case HANDOVER_JOINING:
861  {
863  NS_LOG_INFO ("Send PATH SWITCH REQUEST to the MME");
865  params.rnti = m_rnti;
866  params.cellId = m_rrc->m_cellId;
867  params.mmeUeS1Id = m_imsi;
869  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
870  it != m_drbMap.end ();
871  ++it)
872  {
874  b.epsBearerId = it->second->m_epsBearerIdentity;
875  b.teid = it->second->m_gtpTeid;
876  params.bearersToBeSwitched.push_back (b);
877  }
878  m_rrc->m_s1SapProvider->PathSwitchRequest (params);
879  }
880  break;
881 
882  default:
883  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
884  break;
885  }
886 }
887 
888 void
890 {
891  NS_LOG_FUNCTION (this);
892  switch (m_state)
893  {
894  case CONNECTED_NORMALLY:
895  break;
896 
897  case HANDOVER_LEAVING:
899  break;
900 
901  default:
902  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
903  break;
904  }
905 
909  m_rrc->m_rrcSapUser->SendRrcConnectionReestablishment (m_rnti, msg2);
911 }
912 
913 void
915 {
916  NS_LOG_FUNCTION (this);
918 }
919 
920 void
922 {
923  uint8_t measId = msg.measResults.measId;
924  NS_LOG_FUNCTION (this << (uint16_t) measId);
925  NS_LOG_LOGIC ("measId " << (uint16_t) measId
926  << " haveMeasResultNeighCells " << msg.measResults.haveMeasResultNeighCells
927  << " measResultListEutra " << msg.measResults.measResultListEutra.size ());
928  NS_LOG_LOGIC ("serving cellId " << m_rrc->m_cellId
929  << " RSRP " << (uint16_t) msg.measResults.rsrpResult
930  << " RSRQ " << (uint16_t) msg.measResults.rsrqResult);
931 
932  for (std::list <LteRrcSap::MeasResultEutra>::iterator it = msg.measResults.measResultListEutra.begin ();
933  it != msg.measResults.measResultListEutra.end ();
934  ++it)
935  {
936  NS_LOG_LOGIC ("neighbour cellId " << it->physCellId
937  << " RSRP " << (it->haveRsrpResult ? (uint16_t) it->rsrpResult : 255)
938  << " RSRQ " << (it->haveRsrqResult ? (uint16_t) it->rsrqResult : 255));
939  }
940 
941  if ((m_rrc->m_handoverManagementSapProvider != 0)
942  && (m_rrc->m_handoverMeasIds.find (measId) != m_rrc->m_handoverMeasIds.end ()))
943  {
944  // this measurement was requested by the handover algorithm
945  m_rrc->m_handoverManagementSapProvider->ReportUeMeas (m_rnti,
946  msg.measResults);
947  }
948 
949  if ((m_rrc->m_anrSapProvider != 0)
950  && (m_rrc->m_anrMeasIds.find (measId) != m_rrc->m_anrMeasIds.end ()))
951  {
952  // this measurement was requested by the ANR function
953  m_rrc->m_anrSapProvider->ReportUeMeas (msg.measResults);
954  }
955 
956  // fire a trace source
957  m_rrc->m_recvMeasurementReportTrace (m_imsi, m_rrc->m_cellId, m_rnti, msg);
958 
959 } // end of UeManager::RecvMeasurementReport
960 
961 
962 // methods forwarded from CMAC SAP
963 
964 void
966 {
967  NS_LOG_FUNCTION (this << m_rnti);
968  // at this stage used only by the scheduler for updating txMode
969 
971 
973 
974  // reconfigure the UE RRC
976 }
977 
978 
979 // methods forwarded from PDCP SAP
980 
981 void
983 {
984  NS_LOG_FUNCTION (this);
985  if (params.lcid > 2)
986  {
987  // data radio bearer
988  EpsBearerTag tag;
989  tag.SetRnti (params.rnti);
990  tag.SetBid (Lcid2Bid (params.lcid));
991  params.pdcpSdu->AddPacketTag (tag);
992  m_rrc->m_forwardUpCallback (params.pdcpSdu);
993  }
994 }
995 
996 
997 uint16_t
998 UeManager::GetRnti (void) const
999 {
1000  return m_rnti;
1001 }
1002 
1003 uint64_t
1005 {
1006  return m_imsi;
1007 }
1008 
1009 uint16_t
1011 {
1013 }
1014 
1015 void
1017 {
1018  NS_LOG_FUNCTION (this);
1020  m_rrc->m_cphySapProvider->SetSrsConfigurationIndex (m_rnti, srsConfIndex);
1021  switch (m_state)
1022  {
1023  case INITIAL_RANDOM_ACCESS:
1024  // do nothing, srs conf index will be correctly enforced upon
1025  // RRC connection establishment
1026  break;
1027 
1028  default:
1030  break;
1031  }
1032 }
1033 
1036 {
1037  return m_state;
1038 }
1039 
1040 uint8_t
1042 {
1043  NS_LOG_FUNCTION (this);
1044  const uint8_t MAX_DRB_ID = 32;
1045  for (uint8_t drbid = (m_lastAllocatedDrbid + 1) % MAX_DRB_ID;
1046  drbid != m_lastAllocatedDrbid;
1047  drbid = (drbid + 1) % MAX_DRB_ID)
1048  {
1049  if (drbid != 0) // 0 is not allowed
1050  {
1051  if (m_drbMap.find (drbid) == m_drbMap.end ())
1052  {
1053  m_drbMap.insert (std::pair<uint8_t, Ptr<LteDataRadioBearerInfo> > (drbid, drbInfo));
1054  drbInfo->m_drbIdentity = drbid;
1055  m_lastAllocatedDrbid = drbid;
1056  return drbid;
1057  }
1058  }
1059  }
1060  NS_FATAL_ERROR ("no more data radio bearer ids available");
1061  return 0;
1062 }
1063 
1066 {
1067  NS_LOG_FUNCTION (this << (uint32_t) drbid);
1068  NS_ASSERT (0 != drbid);
1069  std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid);
1070  NS_ABORT_IF (it == m_drbMap.end ());
1071  return it->second;
1072 }
1073 
1074 
1075 void
1077 {
1078  NS_LOG_FUNCTION (this << (uint32_t) drbid);
1079  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid);
1080  NS_ASSERT_MSG (it != m_drbMap.end (), "request to remove radio bearer with unknown drbid " << drbid);
1081  m_drbMap.erase (it);
1082 }
1083 
1084 
1087 {
1092  msg.haveMobilityControlInfo = false;
1093  msg.haveMeasConfig = true;
1094  msg.measConfig = m_rrc->m_ueMeasConfig;
1095 
1096  return msg;
1097 }
1098 
1101 {
1103 
1104  if (m_srb1 != 0)
1105  {
1107  stam.srbIdentity = m_srb1->m_srbIdentity;
1108  stam.logicalChannelConfig = m_srb1->m_logicalChannelConfig;
1109  rrcd.srbToAddModList.push_back (stam);
1110  }
1111 
1112  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
1113  it != m_drbMap.end ();
1114  ++it)
1115  {
1117  dtam.epsBearerIdentity = it->second->m_epsBearerIdentity;
1118  dtam.drbIdentity = it->second->m_drbIdentity;
1119  dtam.rlcConfig = it->second->m_rlcConfig;
1120  dtam.logicalChannelIdentity = it->second->m_logicalChannelIdentity;
1121  dtam.logicalChannelConfig = it->second->m_logicalChannelConfig;
1122  rrcd.drbToAddModList.push_back (dtam);
1123  }
1124 
1125  rrcd.havePhysicalConfigDedicated = true;
1127  return rrcd;
1128 }
1129 
1130 uint8_t
1132 {
1134 }
1135 
1136 uint8_t
1138 {
1139  NS_ASSERT (lcid > 2);
1140  return lcid - 2;
1141 }
1142 
1143 uint8_t
1144 UeManager::Drbid2Lcid (uint8_t drbid)
1145 {
1146  return drbid + 2;
1147 }
1148 uint8_t
1149 UeManager::Lcid2Bid (uint8_t lcid)
1150 {
1151  NS_ASSERT (lcid > 2);
1152  return lcid - 2;
1153 }
1154 
1155 uint8_t
1156 UeManager::Bid2Lcid (uint8_t bid)
1157 {
1158  return bid + 2;
1159 }
1160 
1161 uint8_t
1162 UeManager::Drbid2Bid (uint8_t drbid)
1163 {
1164  return drbid;
1165 }
1166 
1167 uint8_t
1169 {
1170  return bid;
1171 }
1172 
1173 
1174 void
1176 {
1177  NS_LOG_FUNCTION (this << ToString (newState));
1178  State oldState = m_state;
1179  m_state = newState;
1180  NS_LOG_INFO (this << "IMSI " << m_imsi << " RNTI " << m_rnti << " UeManager "
1181  << ToString (oldState) << " --> " << ToString (newState));
1182  m_stateTransitionTrace (m_imsi, m_rrc->m_cellId, m_rnti, oldState, newState);
1183 
1184  switch (newState)
1185  {
1186  case INITIAL_RANDOM_ACCESS:
1187  case HANDOVER_JOINING:
1188  NS_FATAL_ERROR ("cannot switch to an initial state");
1189  break;
1190 
1191  case CONNECTION_SETUP:
1192  break;
1193 
1194  case CONNECTED_NORMALLY:
1195  {
1197  {
1199  }
1200  }
1201  break;
1202 
1204  break;
1205 
1207  break;
1208 
1209  case HANDOVER_LEAVING:
1210  break;
1211 
1212  default:
1213  break;
1214  }
1215 }
1216 
1217 
1218 
1220 // eNB RRC methods
1222 
1224  ;
1225 
1227  : m_x2SapProvider (0),
1228  m_cmacSapProvider (0),
1229  m_handoverManagementSapProvider (0),
1230  m_anrSapProvider (0),
1231  m_rrcSapUser (0),
1232  m_macSapProvider (0),
1233  m_s1SapProvider (0),
1234  m_cphySapProvider (0),
1235  m_configured (false),
1236  m_lastAllocatedRnti (0),
1237  m_srsCurrentPeriodicityId (0),
1238  m_lastAllocatedConfigurationIndex (0),
1239  m_reconfigureUes (false)
1240 {
1241  NS_LOG_FUNCTION (this);
1249 }
1250 
1251 
1253 {
1254  NS_LOG_FUNCTION (this);
1255 }
1256 
1257 
1258 void
1260 {
1261  NS_LOG_FUNCTION (this);
1262  m_ueMap.clear ();
1263  delete m_cmacSapUser;
1265  delete m_anrSapUser;
1266  delete m_rrcSapProvider;
1267  delete m_x2SapUser;
1268  delete m_s1SapUser;
1269  delete m_cphySapUser;
1270 }
1271 
1272 TypeId
1274 {
1275  NS_LOG_FUNCTION ("LteEnbRrc::GetTypeId");
1276  static TypeId tid = TypeId ("ns3::LteEnbRrc")
1277  .SetParent<Object> ()
1278  .AddConstructor<LteEnbRrc> ()
1279  .AddAttribute ("UeMap", "List of UeManager by C-RNTI.",
1280  ObjectMapValue (),
1282  MakeObjectMapChecker<UeManager> ())
1283  .AddAttribute ("DefaultTransmissionMode",
1284  "The default UEs' transmission mode (0: SISO)",
1285  UintegerValue (0), // default tx-mode
1286  MakeUintegerAccessor (&LteEnbRrc::m_defaultTransmissionMode),
1287  MakeUintegerChecker<uint8_t> ())
1288  .AddAttribute ("EpsBearerToRlcMapping",
1289  "Specify which type of RLC will be used for each type of EPS bearer. ",
1292  MakeEnumChecker (RLC_SM_ALWAYS, "RlcSmAlways",
1293  RLC_UM_ALWAYS, "RlcUmAlways",
1294  RLC_AM_ALWAYS, "RlcAmAlways",
1295  PER_BASED, "PacketErrorRateBased"))
1296  .AddAttribute ("SystemInformationPeriodicity",
1297  "The interval for sending system information (Time value)",
1298  TimeValue (MilliSeconds (80)),
1299  MakeTimeAccessor (&LteEnbRrc::m_systemInformationPeriodicity),
1300  MakeTimeChecker ())
1301 
1302  // SRS related attributes
1303  .AddAttribute ("SrsPeriodicity",
1304  "The SRS periodicity in milliseconds",
1305  UintegerValue (40),
1306  MakeUintegerAccessor (&LteEnbRrc::SetSrsPeriodicity,
1308  MakeUintegerChecker<uint32_t> ())
1309 
1310  // Timeout related attributes
1311  .AddAttribute ("ConnectionTimeoutDuration",
1312  "After a RA attempt, if no RRC Connection Request is received before this time, the UE context is destroyed. Must account for reception of RAR and transmission of RRC CONNECTION REQUEST over UL GRANT.",
1313  TimeValue (MilliSeconds (15)),
1314  MakeTimeAccessor (&LteEnbRrc::m_connectionTimeoutDuration),
1315  MakeTimeChecker ())
1316  .AddAttribute ("ConnectionRejectedTimeoutDuration",
1317  "Time to wait between sending a RRC CONNECTION REJECT and destroying the UE context",
1318  TimeValue (MilliSeconds (30)),
1320  MakeTimeChecker ())
1321  .AddAttribute ("HandoverJoiningTimeoutDuration",
1322  "After accepting a handover request, if no RRC Connection Reconfiguration Completed is received before this time, the UE context is destroyed. Must account for reception of X2 HO REQ ACK by source eNB, transmission of the Handover Command, non-contention-based random access and reception of the RRC Connection Reconfiguration Completed message.",
1323  TimeValue (MilliSeconds (200)),
1324  MakeTimeAccessor (&LteEnbRrc::m_handoverJoiningTimeoutDuration),
1325  MakeTimeChecker ())
1326  .AddAttribute ("HandoverLeavingTimeoutDuration",
1327  "After issuing a Handover Command, if neither RRC Connection Reestablishment nor X2 UE Context Release has been previously received, the UE context is destroyed.",
1328  TimeValue (MilliSeconds (500)),
1329  MakeTimeAccessor (&LteEnbRrc::m_handoverLeavingTimeoutDuration),
1330  MakeTimeChecker ())
1331 
1332  // Cell selection related attribute
1333  .AddAttribute ("QRxLevMin",
1334  "One of information transmitted within the SIB1 message, "
1335  "indicating the required minimum RSRP level that any UE must "
1336  "receive from this cell before it is allowed to camp to this "
1337  "cell. The default value -70 corresponds to -140 dBm and is "
1338  "the lowest possible value as defined by Section 6.3.4 of "
1339  "3GPP TS 36.133. This restriction, however, only applies to "
1340  "initial cell selection and EPC-enabled simulation.",
1342  IntegerValue (-70),
1343  MakeIntegerAccessor (&LteEnbRrc::m_qRxLevMin),
1344  MakeIntegerChecker<int8_t> (-70, -22))
1345 
1346  // Handover related attributes
1347  .AddAttribute ("AdmitHandoverRequest",
1348  "Whether to admit an X2 handover request from another eNB",
1349  BooleanValue (true),
1350  MakeBooleanAccessor (&LteEnbRrc::m_admitHandoverRequest),
1351  MakeBooleanChecker ())
1352  .AddAttribute ("AdmitRrcConnectionRequest",
1353  "Whether to admit a connection request from a UE",
1354  BooleanValue (true),
1355  MakeBooleanAccessor (&LteEnbRrc::m_admitRrcConnectionRequest),
1356  MakeBooleanChecker ())
1357 
1358  // UE measurements related attributes
1359  .AddAttribute ("RsrpFilterCoefficient",
1360  "Determines the strength of smoothing effect induced by "
1361  "layer 3 filtering of RSRP in all attached UE; "
1362  "if set to 0, no layer 3 filtering is applicable",
1363  // i.e. the variable k in 3GPP TS 36.331 section 5.5.3.2
1364  UintegerValue (4),
1365  MakeUintegerAccessor (&LteEnbRrc::m_rsrpFilterCoefficient),
1366  MakeUintegerChecker<uint8_t> (0))
1367  .AddAttribute ("RsrqFilterCoefficient",
1368  "Determines the strength of smoothing effect induced by "
1369  "layer 3 filtering of RSRQ in all attached UE; "
1370  "if set to 0, no layer 3 filtering is applicable",
1371  // i.e. the variable k in 3GPP TS 36.331 section 5.5.3.2
1372  UintegerValue (4),
1373  MakeUintegerAccessor (&LteEnbRrc::m_rsrqFilterCoefficient),
1374  MakeUintegerChecker<uint8_t> (0))
1375 
1376  // Trace sources
1377  .AddTraceSource ("NewUeContext",
1378  "trace fired upon creation of a new UE context",
1380  .AddTraceSource ("ConnectionEstablished",
1381  "trace fired upon successful RRC connection establishment",
1383  .AddTraceSource ("ConnectionReconfiguration",
1384  "trace fired upon RRC connection reconfiguration",
1386  .AddTraceSource ("HandoverStart",
1387  "trace fired upon start of a handover procedure",
1389  .AddTraceSource ("HandoverEndOk",
1390  "trace fired upon successful termination of a handover procedure",
1392  .AddTraceSource ("RecvMeasurementReport",
1393  "trace fired when measurement report is received",
1395  ;
1396  return tid;
1397 }
1398 
1399 void
1401 {
1402  NS_LOG_FUNCTION (this << s);
1403  m_x2SapProvider = s;
1404 }
1405 
1406 EpcX2SapUser*
1408 {
1409  NS_LOG_FUNCTION (this);
1410  return m_x2SapUser;
1411 }
1412 
1413 void
1415 {
1416  NS_LOG_FUNCTION (this << s);
1417  m_cmacSapProvider = s;
1418 }
1419 
1422 {
1423  NS_LOG_FUNCTION (this);
1424  return m_cmacSapUser;
1425 }
1426 
1427 void
1429 {
1430  NS_LOG_FUNCTION (this << s);
1432 }
1433 
1436 {
1437  NS_LOG_FUNCTION (this);
1439 }
1440 
1441 void
1443 {
1444  NS_LOG_FUNCTION (this << s);
1445  m_anrSapProvider = s;
1446 }
1447 
1450 {
1451  NS_LOG_FUNCTION (this);
1452  return m_anrSapUser;
1453 }
1454 
1455 void
1457 {
1458  NS_LOG_FUNCTION (this << s);
1459  m_rrcSapUser = s;
1460 }
1461 
1464 {
1465  NS_LOG_FUNCTION (this);
1466  return m_rrcSapProvider;
1467 }
1468 
1469 void
1471 {
1472  NS_LOG_FUNCTION (this);
1473  m_macSapProvider = s;
1474 }
1475 
1476 void
1478 {
1479  m_s1SapProvider = s;
1480 }
1481 
1482 
1485 {
1486  return m_s1SapUser;
1487 }
1488 
1489 void
1491 {
1492  NS_LOG_FUNCTION (this << s);
1493  m_cphySapProvider = s;
1494 }
1495 
1498 {
1499  NS_LOG_FUNCTION (this);
1500  return m_cphySapUser;
1501 }
1502 
1505 {
1506  NS_LOG_FUNCTION (this << (uint32_t) rnti);
1507  NS_ASSERT (0 != rnti);
1508  std::map<uint16_t, Ptr<UeManager> >::iterator it = m_ueMap.find (rnti);
1509  NS_ASSERT_MSG (it != m_ueMap.end (), "RNTI " << rnti << " not found in eNB with cellId " << m_cellId);
1510  return it->second;
1511 }
1512 
1513 uint8_t
1515 {
1516  NS_LOG_FUNCTION (this);
1517 
1518  // SANITY CHECK
1519 
1521  "Measurement identities and reporting configuration should not have different quantity");
1522 
1523  if (Simulator::Now () != Seconds (0))
1524  {
1525  NS_FATAL_ERROR ("AddUeMeasReportConfig may not be called after the simulation has run");
1526  }
1527 
1528  // INPUT VALIDATION
1529 
1530  switch (config.triggerQuantity)
1531  {
1535  {
1536  NS_FATAL_ERROR ("The given triggerQuantity (RSRP) does not match with the given threshold2.choice");
1537  }
1538 
1544  {
1545  NS_FATAL_ERROR ("The given triggerQuantity (RSRP) does not match with the given threshold1.choice");
1546  }
1547  break;
1548 
1552  {
1553  NS_FATAL_ERROR ("The given triggerQuantity (RSRQ) does not match with the given threshold2.choice");
1554  }
1555 
1561  {
1562  NS_FATAL_ERROR ("The given triggerQuantity (RSRQ) does not match with the given threshold1.choice");
1563  }
1564  break;
1565 
1566  default:
1567  NS_FATAL_ERROR ("unsupported triggerQuantity");
1568  break;
1569  }
1570 
1572  {
1573  NS_FATAL_ERROR ("Only REPORT_STRONGEST_CELLS purpose is supported");
1574  }
1575 
1577  {
1578  NS_LOG_WARN ("reportQuantity = BOTH will be used instead of the given reportQuantity");
1579  }
1580 
1581  uint8_t nextId = m_ueMeasConfig.reportConfigToAddModList.size () + 1;
1582 
1583  // create the reporting configuration
1584  LteRrcSap::ReportConfigToAddMod reportConfig;
1585  reportConfig.reportConfigId = nextId;
1586  reportConfig.reportConfigEutra = config;
1587 
1588  // create the measurement identity
1590  measId.measId = nextId;
1591  measId.measObjectId = 1;
1592  measId.reportConfigId = nextId;
1593 
1594  // add both to the list of UE measurement configuration
1595  m_ueMeasConfig.reportConfigToAddModList.push_back (reportConfig);
1596  m_ueMeasConfig.measIdToAddModList.push_back (measId);
1597 
1598  return nextId;
1599 }
1600 
1601 void
1602 LteEnbRrc::ConfigureCell (uint8_t ulBandwidth, uint8_t dlBandwidth,
1603  uint16_t ulEarfcn, uint16_t dlEarfcn, uint16_t cellId)
1604 {
1605  NS_LOG_FUNCTION (this << (uint16_t) ulBandwidth << (uint16_t) dlBandwidth
1606  << ulEarfcn << dlEarfcn << cellId);
1608  m_cmacSapProvider->ConfigureMac (ulBandwidth, dlBandwidth);
1609  m_cphySapProvider->SetBandwidth (ulBandwidth, dlBandwidth);
1610  m_cphySapProvider->SetEarfcn (ulEarfcn, dlEarfcn);
1611  m_dlEarfcn = dlEarfcn;
1612  m_ulEarfcn = ulEarfcn;
1613  m_dlBandwidth = dlBandwidth;
1614  m_ulBandwidth = ulBandwidth;
1615  m_cellId = cellId;
1616  m_cphySapProvider->SetCellId (cellId);
1617 
1618  /*
1619  * Initializing the list of UE measurement configuration (m_ueMeasConfig).
1620  * Only intra-frequency measurements are supported, so only one measurement
1621  * object is created.
1622  */
1623 
1624  LteRrcSap::MeasObjectToAddMod measObject;
1625  measObject.measObjectId = 1;
1626  measObject.measObjectEutra.carrierFreq = m_dlEarfcn;
1628  measObject.measObjectEutra.presenceAntennaPort1 = false;
1629  measObject.measObjectEutra.neighCellConfig = 0;
1630  measObject.measObjectEutra.offsetFreq = 0;
1631  measObject.measObjectEutra.haveCellForWhichToReportCGI = false;
1632 
1633  m_ueMeasConfig.measObjectToAddModList.push_back (measObject);
1638  m_ueMeasConfig.haveSmeasure = false;
1640 
1641  // Enabling MIB transmission
1643  mib.dlBandwidth = m_dlBandwidth;
1645 
1646  // Enabling SIB1 transmission with default values
1651  m_sib1.cellSelectionInfo.qQualMin = -34; // not used, set as minimum value
1652  m_sib1.cellSelectionInfo.qRxLevMin = m_qRxLevMin; // set as minimum value
1654 
1655  /*
1656  * Enabling transmission of other SIB. The first time System Information is
1657  * transmitted is arbitrarily assumed to be at +0.016s, and then it will be
1658  * regularly transmitted every 80 ms by default (set the
1659  * SystemInformationPeriodicity attribute to configure this).
1660  */
1661  Simulator::Schedule (MilliSeconds (16), &LteEnbRrc::SendSystemInformation, this);
1662 
1663  m_configured = true;
1664 
1665 }
1666 
1667 
1668 void
1669 LteEnbRrc::SetCellId (uint16_t cellId)
1670 {
1671  m_cellId = cellId;
1672 
1673  // update SIB1 too
1676 }
1677 
1678 bool
1680 {
1681  NS_LOG_FUNCTION (this << packet);
1682 
1683  EpsBearerTag tag;
1684  bool found = packet->RemovePacketTag (tag);
1685  NS_ASSERT_MSG (found, "no EpsBearerTag found in packet to be sent");
1686  Ptr<UeManager> ueManager = GetUeManager (tag.GetRnti ());
1687  ueManager->SendData (tag.GetBid (), packet);
1688 
1689  return true;
1690 }
1691 
1692 void
1694 {
1695  m_forwardUpCallback = cb;
1696 }
1697 
1698 void
1700 {
1701  NS_LOG_FUNCTION (this << rnti);
1703  "ConnectionTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1704  RemoveUe (rnti);
1705 }
1706 
1707 void
1709 {
1710  NS_LOG_FUNCTION (this << rnti);
1712  "ConnectionTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1713  RemoveUe (rnti);
1714 }
1715 
1716 void
1718 {
1719  NS_LOG_FUNCTION (this << rnti);
1720  NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::HANDOVER_JOINING,
1721  "HandoverJoiningTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1722  RemoveUe (rnti);
1723 }
1724 
1725 void
1727 {
1728  NS_LOG_FUNCTION (this << rnti);
1729  NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::HANDOVER_LEAVING,
1730  "HandoverLeavingTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1731  RemoveUe (rnti);
1732 }
1733 
1734 void
1735 LteEnbRrc::SendHandoverRequest (uint16_t rnti, uint16_t cellId)
1736 {
1737  NS_LOG_FUNCTION (this << rnti << cellId);
1738  NS_LOG_LOGIC ("Request to send HANDOVER REQUEST");
1740 
1741  Ptr<UeManager> ueManager = GetUeManager (rnti);
1742  ueManager->PrepareHandover (cellId);
1743 
1744 }
1745 
1746 void
1748 {
1749  NS_LOG_FUNCTION (this << rnti);
1750  GetUeManager (rnti)->CompleteSetupUe (params);
1751 }
1752 
1753 void
1755 {
1756  NS_LOG_FUNCTION (this << rnti);
1757  GetUeManager (rnti)->RecvRrcConnectionRequest (msg);
1758 }
1759 
1760 void
1762 {
1763  NS_LOG_FUNCTION (this << rnti);
1764  GetUeManager (rnti)->RecvRrcConnectionSetupCompleted (msg);
1765 }
1766 
1767 void
1769 {
1770  NS_LOG_FUNCTION (this << rnti);
1771  GetUeManager (rnti)->RecvRrcConnectionReconfigurationCompleted (msg);
1772 }
1773 
1774 void
1776 {
1777  NS_LOG_FUNCTION (this << rnti);
1778  GetUeManager (rnti)->RecvRrcConnectionReestablishmentRequest (msg);
1779 }
1780 
1781 void
1783 {
1784  NS_LOG_FUNCTION (this << rnti);
1785  GetUeManager (rnti)->RecvRrcConnectionReestablishmentComplete (msg);
1786 }
1787 
1788 void
1790 {
1791  NS_LOG_FUNCTION (this << rnti);
1792  GetUeManager (rnti)->RecvMeasurementReport (msg);
1793 }
1794 
1795 void
1797 {
1798  Ptr<UeManager> ueManager = GetUeManager (request.rnti);
1799  ueManager->SetupDataRadioBearer (request.bearer, request.bearerId, request.gtpTeid, request.transportLayerAddress);
1800 }
1801 
1802 void
1804 {
1805  Ptr<UeManager> ueManager = GetUeManager (params.rnti);
1806  ueManager->SendUeContextRelease ();
1807 }
1808 
1809 void
1811 {
1812  NS_LOG_FUNCTION (this);
1813 
1814  NS_LOG_LOGIC ("Recv X2 message: HANDOVER REQUEST");
1815 
1816  NS_LOG_LOGIC ("oldEnbUeX2apId = " << req.oldEnbUeX2apId);
1817  NS_LOG_LOGIC ("sourceCellId = " << req.sourceCellId);
1818  NS_LOG_LOGIC ("targetCellId = " << req.targetCellId);
1819  NS_LOG_LOGIC ("mmeUeS1apId = " << req.mmeUeS1apId);
1820 
1821  NS_ASSERT (req.targetCellId == m_cellId);
1822 
1823  if (m_admitHandoverRequest == false)
1824  {
1825  NS_LOG_INFO ("rejecting handover request from cellId " << req.sourceCellId);
1827  res.oldEnbUeX2apId = req.oldEnbUeX2apId;
1828  res.sourceCellId = req.sourceCellId ;
1829  res.targetCellId = req.targetCellId ;
1830  res.cause = 0;
1831  res.criticalityDiagnostics = 0;
1833  return;
1834  }
1835 
1836  uint16_t rnti = AddUe (UeManager::HANDOVER_JOINING);
1838  if (anrcrv.valid == false)
1839  {
1840  NS_LOG_INFO (this << "failed to allocate a preamble for non-contention based RA => cannot accept HO");
1841  RemoveUe (rnti);
1842  NS_FATAL_ERROR ("should trigger HO Preparation Failure, but it is not implemented");
1843  return;
1844  }
1845 
1846  Ptr<UeManager> ueManager = GetUeManager (rnti);
1847  ueManager->SetSource (req.sourceCellId, req.oldEnbUeX2apId);
1848  ueManager->SetImsi (req.mmeUeS1apId);
1849 
1851  ackParams.oldEnbUeX2apId = req.oldEnbUeX2apId;
1852  ackParams.newEnbUeX2apId = rnti;
1853  ackParams.sourceCellId = req.sourceCellId;
1854  ackParams.targetCellId = req.targetCellId;
1855 
1856  for (std::vector <EpcX2Sap::ErabToBeSetupItem>::iterator it = req.bearers.begin ();
1857  it != req.bearers.end ();
1858  ++it)
1859  {
1860  ueManager->SetupDataRadioBearer (it->erabLevelQosParameters, it->erabId, it->gtpTeid, it->transportLayerAddress);
1862  i.erabId = it->erabId;
1863  ackParams.admittedBearers.push_back (i);
1864  }
1865 
1866  LteRrcSap::RrcConnectionReconfiguration handoverCommand = ueManager->GetRrcConnectionReconfigurationForHandover ();
1867  handoverCommand.haveMobilityControlInfo = true;
1868  handoverCommand.mobilityControlInfo.targetPhysCellId = m_cellId;
1869  handoverCommand.mobilityControlInfo.haveCarrierFreq = true;
1872  handoverCommand.mobilityControlInfo.haveCarrierBandwidth = true;
1875  handoverCommand.mobilityControlInfo.newUeIdentity = rnti;
1876  handoverCommand.mobilityControlInfo.haveRachConfigDedicated = true;
1879 
1884 
1885  Ptr<Packet> encodedHandoverCommand = m_rrcSapUser->EncodeHandoverCommand (handoverCommand);
1886 
1887  ackParams.rrcContext = encodedHandoverCommand;
1888 
1889  NS_LOG_LOGIC ("Send X2 message: HANDOVER REQUEST ACK");
1890 
1891  NS_LOG_LOGIC ("oldEnbUeX2apId = " << ackParams.oldEnbUeX2apId);
1892  NS_LOG_LOGIC ("newEnbUeX2apId = " << ackParams.newEnbUeX2apId);
1893  NS_LOG_LOGIC ("sourceCellId = " << ackParams.sourceCellId);
1894  NS_LOG_LOGIC ("targetCellId = " << ackParams.targetCellId);
1895 
1897 }
1898 
1899 void
1901 {
1902  NS_LOG_FUNCTION (this);
1903 
1904  NS_LOG_LOGIC ("Recv X2 message: HANDOVER REQUEST ACK");
1905 
1906  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1907  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
1908  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
1909  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
1910 
1911  uint16_t rnti = params.oldEnbUeX2apId;
1912  Ptr<UeManager> ueManager = GetUeManager (rnti);
1913  ueManager->RecvHandoverRequestAck (params);
1914 }
1915 
1916 void
1918 {
1919  NS_LOG_FUNCTION (this);
1920 
1921  NS_LOG_LOGIC ("Recv X2 message: HANDOVER PREPARATION FAILURE");
1922 
1923  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1924  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
1925  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
1926  NS_LOG_LOGIC ("cause = " << params.cause);
1927  NS_LOG_LOGIC ("criticalityDiagnostics = " << params.criticalityDiagnostics);
1928 
1929  uint16_t rnti = params.oldEnbUeX2apId;
1930  Ptr<UeManager> ueManager = GetUeManager (rnti);
1931  ueManager->RecvHandoverPreparationFailure (params.targetCellId);
1932 }
1933 
1934 void
1936 {
1937  NS_LOG_FUNCTION (this);
1938 
1939  NS_LOG_LOGIC ("Recv X2 message: SN STATUS TRANSFER");
1940 
1941  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1942  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
1943  NS_LOG_LOGIC ("erabsSubjectToStatusTransferList size = " << params.erabsSubjectToStatusTransferList.size ());
1944 
1945  uint16_t rnti = params.newEnbUeX2apId;
1946  Ptr<UeManager> ueManager = GetUeManager (rnti);
1947  ueManager->RecvSnStatusTransfer (params);
1948 }
1949 
1950 void
1952 {
1953  NS_LOG_FUNCTION (this);
1954 
1955  NS_LOG_LOGIC ("Recv X2 message: UE CONTEXT RELEASE");
1956 
1957  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1958  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
1959 
1960  uint16_t rnti = params.oldEnbUeX2apId;
1961  GetUeManager (rnti)->RecvUeContextRelease (params);
1962  RemoveUe (rnti);
1963 }
1964 
1965 void
1967 {
1968  NS_LOG_FUNCTION (this);
1969 
1970  NS_LOG_LOGIC ("Recv X2 message: LOAD INFORMATION");
1971 
1972  NS_LOG_LOGIC ("Number of cellInformationItems = " << params.cellInformationList.size ());
1973 
1974  NS_ASSERT ("Processing of LOAD INFORMATION X2 message IS NOT IMPLEMENTED");
1975 }
1976 
1977 void
1979 {
1980  NS_LOG_FUNCTION (this);
1981 
1982  NS_LOG_LOGIC ("Recv X2 message: RESOURCE STATUS UPDATE");
1983 
1984  NS_LOG_LOGIC ("Number of cellMeasurementResultItems = " << params.cellMeasurementResultList.size ());
1985 
1986  NS_ASSERT ("Processing of RESOURCE STATUS UPDATE X2 message IS NOT IMPLEMENTED");
1987 }
1988 
1989 void
1991 {
1992  NS_LOG_FUNCTION (this);
1993 
1994  NS_LOG_LOGIC ("Recv UE DATA FORWARDING through X2 interface");
1995  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
1996  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
1997  NS_LOG_LOGIC ("gtpTeid = " << params.gtpTeid);
1998  NS_LOG_LOGIC ("ueData = " << params.ueData);
1999  NS_LOG_LOGIC ("ueData size = " << params.ueData->GetSize ());
2000 
2001  std::map<uint32_t, X2uTeidInfo>::iterator
2002  teidInfoIt = m_x2uTeidInfoMap.find (params.gtpTeid);
2003  if (teidInfoIt != m_x2uTeidInfoMap.end ())
2004  {
2005  GetUeManager (teidInfoIt->second.rnti)->SendData (teidInfoIt->second.drbid, params.ueData);
2006  }
2007  else
2008  {
2009  NS_FATAL_ERROR ("X2-U data received but no X2uTeidInfo found");
2010  }
2011 }
2012 
2013 
2014 uint16_t
2016 {
2017  NS_LOG_FUNCTION (this);
2019 }
2020 
2021 void
2023 {
2024  Ptr<UeManager> ueManager = GetUeManager (cmacParams.m_rnti);
2025  ueManager->CmacUeConfigUpdateInd (cmacParams);
2026 }
2027 
2028 void
2029 LteEnbRrc::DoNotifyLcConfigResult (uint16_t rnti, uint8_t lcid, bool success)
2030 {
2031  NS_LOG_FUNCTION (this << (uint32_t) rnti);
2032  NS_FATAL_ERROR ("not implemented");
2033 }
2034 
2035 
2036 uint8_t
2038 {
2039  NS_LOG_FUNCTION (this);
2040  uint8_t measId = AddUeMeasReportConfig (reportConfig);
2041  m_handoverMeasIds.insert (measId);
2042  return measId;
2043 }
2044 
2045 void
2046 LteEnbRrc::DoTriggerHandover (uint16_t rnti, uint16_t targetCellId)
2047 {
2048  NS_LOG_FUNCTION (this << rnti << targetCellId);
2049 
2050  bool isHandoverAllowed = true;
2051 
2052  if (m_anrSapProvider != 0)
2053  {
2054  // ensure that proper neighbour relationship exists between source and target cells
2055  bool noHo = m_anrSapProvider->GetNoHo (targetCellId);
2056  bool noX2 = m_anrSapProvider->GetNoX2 (targetCellId);
2057  NS_LOG_DEBUG (this << " cellId=" << m_cellId
2058  << " targetCellId=" << targetCellId
2059  << " NRT.NoHo=" << noHo << " NRT.NoX2=" << noX2);
2060 
2061  if (noHo || noX2)
2062  {
2063  isHandoverAllowed = false;
2064  NS_LOG_LOGIC (this << " handover to cell " << targetCellId
2065  << " is not allowed by ANR");
2066  }
2067  }
2068 
2069  Ptr<UeManager> ueManager = GetUeManager (rnti);
2070  NS_ASSERT_MSG (ueManager != 0, "Cannot find UE context with RNTI " << rnti);
2071 
2072  if (ueManager->GetState () != UeManager::CONNECTED_NORMALLY)
2073  {
2074  isHandoverAllowed = false;
2075  NS_LOG_LOGIC (this << " handover is not allowed because the UE"
2076  << " rnti=" << rnti << " is in "
2077  << ToString (ueManager->GetState ()) << " state");
2078  }
2079 
2080  if (isHandoverAllowed)
2081  {
2082  // initiate handover execution
2083  ueManager->PrepareHandover (targetCellId);
2084  }
2085 }
2086 
2087 uint8_t
2089 {
2090  NS_LOG_FUNCTION (this);
2091  uint8_t measId = AddUeMeasReportConfig (reportConfig);
2092  m_anrMeasIds.insert (measId);
2093  return measId;
2094 }
2095 
2096 
2097 
2098 uint16_t
2100 {
2101  NS_LOG_FUNCTION (this);
2102  bool found = false;
2103  uint16_t rnti;
2104  for (rnti = m_lastAllocatedRnti + 1;
2105  (rnti != m_lastAllocatedRnti - 1) && (!found);
2106  ++rnti)
2107  {
2108  if ((rnti != 0) && (m_ueMap.find (rnti) == m_ueMap.end ()))
2109  {
2110  found = true;
2111  break;
2112  }
2113  }
2114 
2115  NS_ASSERT_MSG (found, "no more RNTIs available (do you have more than 65535 UEs in a cell?)");
2116  m_lastAllocatedRnti = rnti;
2117  Ptr<UeManager> ueManager = CreateObject<UeManager> (this, rnti, state);
2118  m_ueMap.insert (std::pair<uint16_t, Ptr<UeManager> > (rnti, ueManager));
2119  ueManager->Initialize ();
2120  NS_LOG_DEBUG (this << " New UE RNTI " << rnti << " cellId " << m_cellId << " srs CI " << ueManager->GetSrsConfigurationIndex ());
2121  m_newUeContextTrace (m_cellId, rnti);
2122  return rnti;
2123 }
2124 
2125 void
2126 LteEnbRrc::RemoveUe (uint16_t rnti)
2127 {
2128  NS_LOG_FUNCTION (this << (uint32_t) rnti);
2129  std::map <uint16_t, Ptr<UeManager> >::iterator it = m_ueMap.find (rnti);
2130  NS_ASSERT_MSG (it != m_ueMap.end (), "request to remove UE info with unknown rnti " << rnti);
2131  uint16_t srsCi = (*it).second->GetSrsConfigurationIndex ();
2132  m_ueMap.erase (it);
2133  m_cmacSapProvider->RemoveUe (rnti);
2134  m_cphySapProvider->RemoveUe (rnti);
2135  if (m_s1SapProvider != 0)
2136  {
2138  }
2139  // need to do this after UeManager has been deleted
2140  RemoveSrsConfigurationIndex (srsCi);
2141 }
2142 
2143 TypeId
2145 {
2146  switch (m_epsBearerToRlcMapping)
2147  {
2148  case RLC_SM_ALWAYS:
2149  return LteRlcSm::GetTypeId ();
2150  break;
2151 
2152  case RLC_UM_ALWAYS:
2153  return LteRlcUm::GetTypeId ();
2154  break;
2155 
2156  case RLC_AM_ALWAYS:
2157  return LteRlcAm::GetTypeId ();
2158  break;
2159 
2160  case PER_BASED:
2161  if (bearer.GetPacketErrorLossRate () > 1.0e-5)
2162  {
2163  return LteRlcUm::GetTypeId ();
2164  }
2165  else
2166  {
2167  return LteRlcAm::GetTypeId ();
2168  }
2169  break;
2170 
2171  default:
2172  return LteRlcSm::GetTypeId ();
2173  break;
2174  }
2175 }
2176 
2177 
2178 void
2179 LteEnbRrc::AddX2Neighbour (uint16_t cellId)
2180 {
2181  NS_LOG_FUNCTION (this << cellId);
2182 
2183  if (m_anrSapProvider != 0)
2184  {
2186  }
2187 }
2188 
2189 void
2190 LteEnbRrc::SetCsgId (uint32_t csgId, bool csgIndication)
2191 {
2192  NS_LOG_FUNCTION (this << csgId << csgIndication);
2194  m_sib1.cellAccessRelatedInfo.csgIndication = csgIndication;
2196 }
2197 
2198 
2199 // from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity
2200 const uint8_t SRS_ENTRIES = 9;
2201 uint16_t g_srsPeriodicity[SRS_ENTRIES] = {0, 2, 5, 10, 20, 40, 80, 160, 320};
2202 uint16_t g_srsCiLow[SRS_ENTRIES] = {0, 0, 2, 7, 17, 37, 77, 157, 317};
2203 uint16_t g_srsCiHigh[SRS_ENTRIES] = {0, 1, 6, 16, 36, 76, 156, 316, 636};
2204 
2205 void
2207 {
2208  NS_LOG_FUNCTION (this << p);
2209  for (uint32_t id = 1; id < SRS_ENTRIES; ++id)
2210  {
2211  if (g_srsPeriodicity[id] == p)
2212  {
2214  return;
2215  }
2216  }
2217  // no match found
2218  std::ostringstream allowedValues;
2219  for (uint32_t id = 1; id < SRS_ENTRIES; ++id)
2220  {
2221  allowedValues << g_srsPeriodicity[id] << " ";
2222  }
2223  NS_FATAL_ERROR ("illecit SRS periodicity value " << p << ". Allowed values: " << allowedValues.str ());
2224 }
2225 
2226 uint32_t
2228 {
2229  NS_LOG_FUNCTION (this);
2233 }
2234 
2235 
2236 uint16_t
2238 {
2240  // SRS
2243  NS_LOG_DEBUG (this << " SRS p " << g_srsPeriodicity[m_srsCurrentPeriodicityId] << " set " << m_ueSrsConfigurationIndexSet.size ());
2245  {
2246  NS_FATAL_ERROR ("too many UEs (" << m_ueSrsConfigurationIndexSet.size () + 1
2247  << ") for current SRS periodicity "
2249  << ", consider increasing the value of ns3::LteEnbRrc::SrsPeriodicity");
2250  }
2251 
2252  if (m_ueSrsConfigurationIndexSet.empty ())
2253  {
2254  // first entry
2257  }
2258  else
2259  {
2260  // find a CI from the available ones
2261  std::set<uint16_t>::reverse_iterator rit = m_ueSrsConfigurationIndexSet.rbegin ();
2262  NS_ASSERT (rit != m_ueSrsConfigurationIndexSet.rend ());
2263  NS_LOG_DEBUG (this << " lower bound " << (*rit) << " of " << g_srsCiHigh[m_srsCurrentPeriodicityId]);
2264  if ((*rit) < g_srsCiHigh[m_srsCurrentPeriodicityId])
2265  {
2266  // got it from the upper bound
2267  m_lastAllocatedConfigurationIndex = (*rit) + 1;
2269  }
2270  else
2271  {
2272  // look for released ones
2273  for (uint16_t srcCi = g_srsCiLow[m_srsCurrentPeriodicityId]; srcCi < g_srsCiHigh[m_srsCurrentPeriodicityId]; srcCi++)
2274  {
2275  std::set<uint16_t>::iterator it = m_ueSrsConfigurationIndexSet.find (srcCi);
2276  if (it==m_ueSrsConfigurationIndexSet.end ())
2277  {
2279  m_ueSrsConfigurationIndexSet.insert (srcCi);
2280  break;
2281  }
2282  }
2283  }
2284  }
2286 
2287 }
2288 
2289 
2290 void
2292 {
2293  NS_LOG_FUNCTION (this << srcCi);
2294  std::set<uint16_t>::iterator it = m_ueSrsConfigurationIndexSet.find (srcCi);
2295  NS_ASSERT_MSG (it != m_ueSrsConfigurationIndexSet.end (), "request to remove unkwown SRS CI " << srcCi);
2296  m_ueSrsConfigurationIndexSet.erase (it);
2297 }
2298 
2299 uint8_t
2301 {
2302  if (bearer.IsGbr ())
2303  {
2304  return 1;
2305  }
2306  else
2307  {
2308  return 2;
2309  }
2310 }
2311 
2312 uint8_t
2314 {
2315  return bearer.qci;
2316 }
2317 
2318 void
2320 {
2321  // NS_LOG_FUNCTION (this);
2322 
2323  /*
2324  * For simplicity, we use the same periodicity for all SIBs. Note that in real
2325  * systems the periodicy of each SIBs could be different.
2326  */
2328  si.haveSib2 = true;
2331 
2333  LteRrcSap::RachConfigCommon rachConfigCommon;
2335  rachConfigCommon.raSupervisionInfo.preambleTransMax = rc.preambleTransMax;
2337  si.sib2.radioResourceConfigCommon.rachConfigCommon = rachConfigCommon;
2338 
2341 }
2342 
2343 
2344 } // namespace ns3
2345 
virtual void AddNeighbourRelation(uint16_t cellId)=0
Add a new Neighbour Relation entry.
enum ns3::LteRrcSap::ReportConfigEutra::@73 reportQuantity
The quantities to be included in the measurement report, always assumed to be BOTH.
Callback< void, Ptr< Packet > > m_forwardUpCallback
Definition: lte-enb-rrc.h:873
Ipv4Address transportLayerAddress
IP Address of the SGW, see 36.423 9.2.1.
const uint8_t SRS_ENTRIES
virtual void SetMasterInformationBlock(LteRrcSap::MasterInformationBlock mib)=0
TracedCallback< uint64_t, uint16_t, uint16_t, State, State > m_stateTransitionTrace
Definition: lte-enb-rrc.h:406
TracedCallback< uint64_t, uint16_t, uint16_t > m_handoverEndOkTrace
Definition: lte-enb-rrc.h:967
SystemInformationBlockType2 sourceSystemInformationBlockType2
Definition: lte-rrc-sap.h:490
Parameters passed to DataRadioBearerSetupRequest ()
void SetEpcX2SapProvider(EpcX2SapProvider *s)
Set the X2 SAP this RRC should interact with.
Template for the implementation of the EpcEnbS1SapUser as a member of an owner class of type C to whi...
This class implements the Service Access Point (SAP) between the LteEnbRrc and the EpcEnbApplication...
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
Ptr< LteSignalingRadioBearerInfo > m_srb1
Definition: lte-enb-rrc.h:395
void SendHandoverRequest(uint16_t rnti, uint16_t cellId)
Send a HandoverRequest through the X2 SAP interface.
uint16_t g_srsPeriodicity[SRS_ENTRIES]
void SendSystemInformation()
method used to periodically send System Information
LteRrcSap::RadioResourceConfigDedicated GetRadioResourceConfigForHandoverPreparationInfo()
Definition: lte-enb-rrc.cc:608
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
These service primitives of this part of the X2 SAP are provided by the X2 entity and issued by RRC e...
Definition: epc-x2-sap.h:340
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
E-RABs admitted item as it is used in the HANDOVER REQUEST ACKNOWLEDGE message.
Definition: epc-x2-sap.h:75
LteEnbRrc()
create an RRC instance for use within an eNB
uint16_t AddUe(UeManager::State state)
Allocate a new RNTI for a new UE.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Definition: enum.cc:178
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:71
Hold a bool native type.
Definition: boolean.h:38
Callback template class.
Definition: callback.h:920
void RecordDataRadioBearersToBeStarted()
Start all configured data radio bearers.
Definition: lte-enb-rrc.cc:414
RSRP is used for the threshold.
Definition: lte-rrc-sap.h:251
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-enb-rrc.cc:268
uint16_t m_dlBandwidth
Definition: lte-enb-rrc.h:902
void RecvUeContextRelease(EpcX2SapUser::UeContextReleaseParams params)
Take the necessary actions in response to the reception of an X2 UE CONTEXT RELEASE message...
Definition: lte-enb-rrc.cc:751
This class implements the Service Access Point (SAP) between the LteEnbRrc and the EpcEnbApplication...
void SetSource(uint16_t sourceCellId, uint16_t sourceX2apId)
Set the identifiers of the source eNB for the case where a UE joins the current eNB as part of a hand...
Definition: lte-enb-rrc.cc:312
std::list< MeasObjectToAddMod > measObjectToAddModList
Definition: lte-rrc-sap.h:400
void RecvHandoverPreparationFailure(uint16_t cellId)
Take the necessary actions in response to the reception of an X2 HO preparation failure message...
Definition: lte-enb-rrc.cc:714
NS_LOG_COMPONENT_DEFINE("LteEnbRrc")
void DoNotifyLcConfigResult(uint16_t rnti, uint8_t lcid, bool success)
uint16_t m_rnti
UE id within this cell.
SoundingRsUlConfigDedicated soundingRsUlConfigDedicated
Definition: lte-rrc-sap.h:140
virtual void SetEarfcn(uint16_t ulEarfcn, uint16_t dlEarfcn)=0
static TypeId GetTypeId(void)
Definition: lte-rlc.cc:185
void SetCellId(uint16_t m_cellId)
set the cell id of this eNB
uint8_t GetLogicalChannelGroup(EpsBearer bearer)
uint8_t m_transmissionMode
Transmission mode 1..7
void AddX2Neighbour(uint16_t cellId)
Add a neighbour with an X2 interface.
QuantityConfig quantityConfig
Definition: lte-rrc-sap.h:406
uint8_t Drbid2Bid(uint8_t drbid)
enum ns3::LteRrcSap::ReportConfigEutra::@70 eventId
Choice of E-UTRA event triggered reporting criteria.
uint16_t txSn
TX sequence number.
Definition: lte-pdcp.h:97
uint16_t rnti
the RNTI identifying the UE for which the DataRadioBearer is to be created
bool m_admitHandoverRequest
Definition: lte-enb-rrc.h:945
std::vector< CellMeasurementResultItem > cellMeasurementResultList
Definition: epc-x2-sap.h:316
friend class EnbRrcMemberLteEnbCmacSapUser
Definition: lte-enb-rrc.h:430
std::list< MeasResultEutra > measResultListEutra
Definition: lte-rrc-sap.h:519
Parameters of the HANDOVER REQUEST message.
Definition: epc-x2-sap.h:225
int8_t qRxLevMin
INTEGER (-70..-22), actual value = IE value * 2 [dBm].
Definition: lte-rrc-sap.h:82
Part of the RRC protocol.
Definition: lte-rrc-sap.h:840
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
Definition: lte-rrc-sap.h:276
void DoRecvRrcConnectionReconfigurationCompleted(uint16_t rnti, LteRrcSap::RrcConnectionReconfigurationCompleted msg)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::RecvRrcConnectionReconfigurationCompleted ...
Template for the implementation of the LteHandoverManagementSapUser as a member of an owner class of ...
Status variables of the PDCP.
Definition: lte-pdcp.h:95
Class for forwarding CMAC SAP User functions.
Definition: lte-enb-rrc.cc:60
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:841
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:258
void SetCsgId(uint32_t csgId, bool csgIndication)
Associate this RRC entity with a particular CSG information.
uint16_t GetSrsConfigurationIndex(void) const
uint8_t qci
QoS Class Identifier.
static TypeId GetTypeId(void)
uint16_t m_sourceCellId
Definition: lte-enb-rrc.h:408
virtual ~LteEnbRrc()
Destructor.
#define NS_ASSERT(condition)
Definition: assert.h:64
uint16_t m_rnti
Definition: lte-enb-rrc.h:397
std::list< SrbToAddMod > srbToAddModList
Definition: lte-rrc-sap.h:190
Hold a signed integer type.
Definition: integer.h:45
uint8_t Lcid2Bid(uint8_t lcid)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void SendHandoverPreparationFailure(HandoverPreparationFailureParams params)=0
void SetLteHandoverManagementSapProvider(LteHandoverManagementSapProvider *s)
set the Handover Management SAP this RRC should interact with
EpcX2SapUser * GetEpcX2SapUser()
Get the X2 SAP offered by this RRC.
RadioResourceConfigDedicated radioResourceConfigDedicated
Definition: lte-rrc-sap.h:548
void SetLteEnbCphySapProvider(LteEnbCphySapProvider *s)
set the CPHY SAP this RRC should use to interact with the PHY
bool m_needTransmissionModeConfiguration
Definition: lte-enb-rrc.h:411
uint16_t m_lastAllocatedRnti
Definition: lte-enb-rrc.h:904
uint16_t GetNewSrsConfigurationIndex(void)
Allocate a new SRS configuration index for a new UE.
void SetTypeId(TypeId tid)
std::list< BearerToBeSwitched > bearersToBeSwitched
uint32_t GetSize(void) const
Definition: packet.h:650
LteEnbCmacSapUser * GetLteEnbCmacSapUser()
Get the CMAC SAP offered by this RRC.
uint8_t m_transmissionMode
Transmission mode 1..7
Tag used to define the RNTI and EPS bearer ID for packets interchanged between the EpcEnbApplication ...
uint16_t m_ulBandwidth
Definition: lte-enb-rrc.h:903
uint8_t m_lastRrcTransactionIdentifier
Definition: lte-enb-rrc.h:399
uint16_t m_srsCurrentPeriodicityId
Definition: lte-enb-rrc.h:936
The LTE Radio Resource Control entity at the eNB.
Definition: lte-enb-rrc.h:427
void SetLteEnbRrcSapUser(LteEnbRrcSapUser *s)
set the RRC SAP this RRC should interact with
void SetLteEnbCmacSapProvider(LteEnbCmacSapProvider *s)
set the CMAC SAP this RRC should interact with
#define NS_LOG_INFO(msg)
Definition: log.h:298
uint16_t DoAllocateTemporaryCellRnti()
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberContainer)
Definition: object-map.h:51
uint64_t m_imsi
Definition: lte-enb-rrc.h:398
virtual uint16_t AllocateTemporaryCellRnti()
request the allocation of a Temporary C-RNTI
Definition: lte-enb-rrc.cc:79
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
EpsBearer bearer
the characteristics of the bearer to be set up
The attribute can be written at construction-time.
Definition: type-id.h:58
Time m_handoverLeavingTimeoutDuration
Definition: lte-enb-rrc.h:956
uint64_t mbrDl
maximum bitrate in downlink
void SetBid(uint8_t bid)
Set the bearer id to the given value.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:824
uint8_t GetBid(void) const
Time m_connectionRejectedTimeoutDuration
Definition: lte-enb-rrc.h:954
LteMacSapProvider * m_macSapProvider
Definition: lte-enb-rrc.h:890
LteHandoverManagementSapUser * GetLteHandoverManagementSapUser()
Get the Handover Management SAP offered by this RRC.
LteEnbRrcSapProvider * m_rrcSapProvider
Definition: lte-enb-rrc.h:888
RachConfigDedicated rachConfigDedicated
Definition: lte-rrc-sap.h:443
uint16_t GetRnti(void) const
bool IsGbr() const
Definition: eps-bearer.cc:61
void RemoveSrsConfigurationIndex(uint16_t srcCi)
remove a previously allocated SRS configuration index
virtual void RrcConfigurationUpdateInd(UeConfig params)
Notify the RRC of a UE config updated requested by the MAC (normally, by the scheduler) ...
Definition: lte-enb-rrc.cc:91
State GetState() const
void SetImsi(uint64_t imsi)
Set the IMSI.
Definition: lte-enb-rrc.cc:319
void SetLteMacSapProvider(LteMacSapProvider *s)
set the MAC SAP provider.
void SendUeContextRelease()
send the UE CONTEXT RELEASE X2 message to the source eNB, thus successfully terminating an X2 handove...
Definition: lte-enb-rrc.cc:691
LteRrcSap::RrcConnectionReconfiguration GetRrcConnectionReconfigurationForHandover()
Definition: lte-enb-rrc.cc:615
void SwitchToState(State s)
Switch the UeManager to the given state.
void RecvRrcConnectionReconfigurationCompleted(LteRrcSap::RrcConnectionReconfigurationCompleted msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionReconfigurationComplet...
Definition: lte-enb-rrc.cc:832
void ReleaseDataRadioBearer(uint8_t drbid)
Release a given radio bearer.
Definition: lte-enb-rrc.cc:446
double GetPacketErrorLossRate() const
Definition: eps-bearer.cc:144
uint8_t AddDataRadioBearerInfo(Ptr< LteDataRadioBearerInfo > radioBearerInfo)
Add a new LteDataRadioBearerInfo structure to the UeManager.
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
EpcX2SapUser * m_x2SapUser
Definition: lte-enb-rrc.h:875
uint8_t m_rsrqFilterCoefficient
Definition: lte-enb-rrc.h:950
LteEnbRrcSapUser * m_rrcSapUser
Definition: lte-enb-rrc.h:887
uint16_t m_dlEarfcn
Definition: lte-enb-rrc.h:900
Ptr< LteEnbRrc > m_rrc
Definition: lte-enb-rrc.h:401
EpcEnbS1SapProvider * m_s1SapProvider
Definition: lte-enb-rrc.h:892
LteRrcSap::SystemInformationBlockType1 m_sib1
the System Information Block Type 1 that is currently broadcasted over BCH
Definition: lte-enb-rrc.h:907
void SetForwardUpCallback(Callback< void, Ptr< Packet > > cb)
set the callback used to forward data packets up the stack
void DoRecvRrcConnectionSetupCompleted(uint16_t rnti, LteRrcSap::RrcConnectionSetupCompleted msg)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::RecvRrcConnectionSetupCompleted interface ...
void DoRecvRrcConnectionReestablishmentComplete(uint16_t rnti, LteRrcSap::RrcConnectionReestablishmentComplete msg)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentComplete i...
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:41
The attribute can be read.
Definition: type-id.h:56
LteHandoverManagementSapUser * m_handoverManagementSapUser
Definition: lte-enb-rrc.h:881
void DoCompleteSetupUe(uint16_t rnti, LteEnbRrcSapProvider::CompleteSetupUeParameters params)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::CompleteSetupUe interface to UeManager::Co...
SystemInformationBlockType1 sourceSystemInformationBlockType1
Definition: lte-rrc-sap.h:489
TracedCallback< uint16_t, uint16_t > m_newUeContextTrace
Definition: lte-enb-rrc.h:959
Service Access Point (SAP) offered by the MAC to the RRC See Femto Forum MAC Scheduler Interface Spec...
EventId m_connectionTimeout
Definition: lte-enb-rrc.h:413
enum ns3::LteRrcSap::ReportConfigEutra::@71 purpose
LteEnbCmacSapUser * m_cmacSapUser
Definition: lte-enb-rrc.h:878
Ptr< UeManager > GetUeManager(uint16_t rnti)
Parameters for LtePdcpSapUser::ReceivePdcpSdu.
Definition: lte-pdcp-sap.h:76
uint8_t lcId
logical channel identifier
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
uint16_t m_rnti
UE id within this cell.
bool m_admitRrcConnectionRequest
Definition: lte-enb-rrc.h:946
int8_t m_qRxLevMin
Definition: lte-enb-rrc.h:942
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-pdcp-sap.h:79
LtePdcpSapUser * m_drbPdcpSapUser
Definition: lte-enb-rrc.h:403
uint8_t AddUeMeasReportConfig(LteRrcSap::ReportConfigEutra config)
Add a new UE measurement reporting configuration.
EventId m_connectionRejectedTimeout
Definition: lte-enb-rrc.h:414
virtual void UeContextRelease(uint16_t rnti)=0
release UE context at the S1 Application of the source eNB after reception of the UE CONTEXT RELEASE ...
hold variables of type 'enum'
Definition: enum.h:37
LteRrcSap::RrcConnectionReconfiguration BuildRrcConnectionReconfiguration()
Ptr< LteSignalingRadioBearerInfo > m_srb0
Definition: lte-enb-rrc.h:394
void DoRecvRrcConnectionRequest(uint16_t rnti, LteRrcSap::RrcConnectionRequest msg)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::RecvRrcConnectionRequest interface to UeMa...
hold objects of type ns3::Time
Definition: nstime.h:961
uint16_t m_ulEarfcn
Definition: lte-enb-rrc.h:901
static TypeId GetTypeId(void)
Definition: lte-rlc-um.cc:56
void SetSrsConfigurationIndex(uint16_t srsConfIndex)
Set the SRS configuration index and do the necessary reconfiguration.
void DoTriggerHandover(uint16_t rnti, uint16_t targetCellId)
LogicalChannelConfig logicalChannelConfig
Definition: lte-rrc-sap.h:149
Ptr< Object > Create(void) const
TracedCallback< uint64_t, uint16_t, uint16_t > m_connectionEstablishedTrace
Definition: lte-enb-rrc.h:961
Parameters of the HANDOVER PREPARATION FAILURE message.
Definition: epc-x2-sap.h:259
virtual bool GetNoHo(uint16_t cellId) const =0
Get the value of No HO field of a neighbouring cell from the Neighbour Relation Table (NRT)...
Hold an unsigned integer type.
Definition: uinteger.h:46
Logical Channel information to be passed to CmacSapProvider::ConfigureLc.
Ptr< SampleEmitter > s
virtual void SetCellId(uint16_t cellId)=0
GbrQosInformation gbrQosInfo
Definition: eps-bearer.h:90
void DoPathSwitchRequestAcknowledge(EpcEnbS1SapUser::PathSwitchRequestAcknowledgeParameters params)
virtual void SetBandwidth(uint8_t ulBandwidth, uint8_t dlBandwidth)=0
virtual void NotifyLcConfigResult(uint16_t rnti, uint8_t lcid, bool success)
notify the result of the last LC config operation
Definition: lte-enb-rrc.cc:85
std::vector< ErabAdmittedItem > admittedBearers
Definition: epc-x2-sap.h:249
Both the RSRP and RSRQ quantities are to be included in the measurement report.
Definition: lte-rrc-sap.h:306
std::vector< CellInformationItem > cellInformationList
Definition: epc-x2-sap.h:303
uint16_t rnti
the C-RNTI identifying the UE
Definition: lte-pdcp-sap.h:46
std::list< MeasIdToAddMod > measIdToAddModList
Definition: lte-rrc-sap.h:404
Parameters of the SN STATUS TRANSFER message.
Definition: epc-x2-sap.h:273
PhysicalConfigDedicated physicalConfigDedicated
Definition: lte-rrc-sap.h:194
LteEnbCphySapProvider * m_cphySapProvider
Definition: lte-enb-rrc.h:896
Service Access Point (SAP) offered by the eNodeB RRC instance to the ANR instance.
Definition: lte-anr-sap.h:97
Parameters for LtePdcpSapProvider::TransmitPdcpSdu.
Definition: lte-pdcp-sap.h:43
uint32_t gtpTeid
S1-bearer GTP tunnel endpoint identifier, see 36.423 9.2.1.
Template for the implementation of the LteEnbCphySapUser as a member of an owner class of type C to w...
uint8_t Drbid2Lcid(uint8_t drbid)
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:40
uint16_t rxSn
RX sequence number.
Definition: lte-pdcp.h:98
void SendData(uint8_t bid, Ptr< Packet > p)
Send a data packet over the appropriate Data Radio Bearer.
Definition: lte-enb-rrc.cc:622
std::set< uint8_t > m_handoverMeasIds
Definition: lte-enb-rrc.h:917
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
virtual RachConfig GetRachConfig()=0
RadioResourceConfigDedicated radioResourceConfigDedicated
Definition: lte-rrc-sap.h:532
void DoRecvUeContextRelease(EpcX2SapUser::UeContextReleaseParams params)
#define NS_ABORT_IF(cond)
Abnormal program termination if cond is true.
Definition: abort.h:69
uint8_t m_lastAllocatedDrbid
Definition: lte-enb-rrc.h:396
uint8_t Bid2Lcid(uint8_t bid)
uint16_t m_sourceX2apId
Definition: lte-enb-rrc.h:407
Parameters for [re]configuring the UE.
std::map< uint32_t, X2uTeidInfo > m_x2uTeidInfoMap
Definition: lte-enb-rrc.h:927
TracedCallback< uint64_t, uint16_t, uint16_t, LteRrcSap::MeasurementReport > m_recvMeasurementReportTrace
Definition: lte-enb-rrc.h:970
void SetRnti(uint16_t rnti)
Set the RNTI to the given value.
virtual ~UeManager(void)
Definition: lte-enb-rrc.cc:263
uint8_t m_rsrpFilterCoefficient
Definition: lte-enb-rrc.h:949
Event A2: Serving becomes worse than absolute threshold.
Definition: lte-rrc-sap.h:269
const char * g_ueManagerStateName[UeManager::NUM_STATES]
Definition: lte-enb-rrc.cc:103
E-RABs to be setup item as it is used in the HANDOVER REQUEST message.
Definition: epc-x2-sap.h:59
RadioResourceConfigDedicated sourceRadioResourceConfig
Definition: lte-rrc-sap.h:486
Part of the RRC protocol.
Definition: lte-rrc-sap.h:752
uint8_t DoAddUeMeasReportConfigForAnr(LteRrcSap::ReportConfigEutra reportConfig)
void SetupDataRadioBearer(EpsBearer bearer, uint8_t bearerId, uint32_t gtpTeid, Ipv4Address transportLayerAddress)
Setup a new data radio bearer, including both the configuration within the eNB and the necessary RRC ...
Definition: lte-enb-rrc.cc:325
void RemoveDataRadioBearerInfo(uint8_t drbid)
remove the LteDataRadioBearerInfo corresponding to a bearer being released
static TypeId GetTypeId(void)
Definition: lte-enb-rrc.cc:281
void RecvSnStatusTransfer(EpcX2SapUser::SnStatusTransferParams params)
Take the necessary actions in response to the reception of an X2 SN STATUS TRANSFER message...
Definition: lte-enb-rrc.cc:732
EpcX2SapProvider * m_x2SapProvider
Definition: lte-enb-rrc.h:876
Parameters of the RESOURCE STATUS UPDATE message.
Definition: epc-x2-sap.h:311
hold objects of type Ptr
Definition: pointer.h:33
void ConnectionTimeout(uint16_t rnti)
Method triggered when a UE is expected to get connected but does not do so in a reasonable time...
virtual void SendHandoverRequestAck(HandoverRequestAckParams params)=0
LteRrcSap::RadioResourceConfigDedicated BuildRadioResourceConfigDedicated()
enum ns3::EpsBearer::Qci qci
EventId m_handoverLeavingTimeout
Definition: lte-enb-rrc.h:416
uint8_t lcGroup
logical channel group
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void SetLteAnrSapProvider(LteAnrSapProvider *s)
set the ANR SAP this RRC should interact with
Parameters of the UE CONTEXT RELEASE message.
Definition: epc-x2-sap.h:287
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:43
Parameters of the HANDOVER REQUEST ACKNOWLEDGE message.
Definition: epc-x2-sap.h:243
void RecvRrcConnectionSetupCompleted(LteRrcSap::RrcConnectionSetupCompleted msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionSetupCompleted interfa...
Definition: lte-enb-rrc.cc:814
RadioResourceConfigDedicated radioResourceConfigDedicated
Definition: lte-rrc-sap.h:566
std::list< uint8_t > m_drbsToBeStarted
Definition: lte-enb-rrc.h:410
void DoReceivePdcpSdu(LtePdcpSapUser::ReceivePdcpSduParameters params)
Definition: lte-enb-rrc.cc:982
TracedCallback< uint64_t, uint16_t, uint16_t, uint16_t > m_handoverStartTrace
Definition: lte-enb-rrc.h:965
uint16_t g_srsCiLow[SRS_ENTRIES]
std::vector< EpcX2Sap::ErabToBeSetupItem > GetErabList()
Definition: lte-enb-rrc.cc:671
virtual void SetSystemInformationBlockType1(LteRrcSap::SystemInformationBlockType1 sib1)=0
void ScheduleRrcConnectionReconfiguration()
schedule an RRC Connection Reconfiguration procedure with the UE
Definition: lte-enb-rrc.cc:472
These service primitives of this part of the X2 SAP are provided by the RRC entity and issued by the ...
Definition: epc-x2-sap.h:371
LteAnrSapUser * GetLteAnrSapUser()
Get the ANR SAP offered by this RRC.
Parameters for [re]configuring the UE.
Time m_systemInformationPeriodicity
Definition: lte-enb-rrc.h:933
LteEnbRrcSapProvider * GetLteEnbRrcSapProvider()
RadioResourceConfigCommonSib radioResourceConfigCommon
Definition: lte-rrc-sap.h:473
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
std::vector< ErabToBeSetupItem > bearers
Definition: epc-x2-sap.h:234
Reference Signal Received Quality.
Definition: lte-rrc-sap.h:300
uint8_t m_defaultTransmissionMode
Definition: lte-enb-rrc.h:929
void DoRecvResourceStatusUpdate(EpcX2SapUser::ResourceStatusUpdateParams params)
void DoRecvUeData(EpcX2SapUser::UeDataParams params)
virtual void TransmitPdcpSdu(TransmitPdcpSduParameters params)=0
Send a RRC PDU to the RDCP for transmission This method is to be called when upper RRC entity has a R...
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
RadioResourceConfigCommon radioResourceConfigCommon
Definition: lte-rrc-sap.h:441
uint64_t GetImsi(void) const
EnbRrcMemberLteEnbCmacSapUser(LteEnbRrc *rrc)
Definition: lte-enb-rrc.cc:73
Event A5: PCell becomes worse than absolute threshold1 AND Neighbour becomes better than another abso...
Definition: lte-rrc-sap.h:272
enum ns3::LteRrcSap::ReportConfigEutra::@72 triggerQuantity
The quantities used to evaluate the triggering condition for the event, see 3GPP TS 36...
void PrepareHandover(uint16_t cellId)
Start the handover preparation and send the handover request.
Definition: lte-enb-rrc.cc:505
CarrierBandwidthEutra carrierBandwidth
Definition: lte-rrc-sap.h:439
uint8_t DoAddUeMeasReportConfigForHandover(LteRrcSap::ReportConfigEutra reportConfig)
uint16_t GetRnti(void) const
Definition: lte-enb-rrc.cc:998
void RecvRrcConnectionReestablishmentComplete(LteRrcSap::RrcConnectionReestablishmentComplete msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentComplet...
Definition: lte-enb-rrc.cc:914
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
EpcEnbS1SapUser * m_s1SapUser
Definition: lte-enb-rrc.h:893
std::set< uint16_t > m_ueSrsConfigurationIndexSet
Definition: lte-enb-rrc.h:937
void SetSrsPeriodicity(uint32_t p)
uint16_t rnti
C-RNTI identifying the UE.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
TypeId GetRlcType(EpsBearer bearer)
LogicalChannelConfig logicalChannelConfig
Definition: lte-rrc-sap.h:158
uint64_t mbrUl
maximum bitrate in uplink
void HandoverJoiningTimeout(uint16_t rnti)
Method triggered when a UE is expected to join the cell for a handover but does not do so in a reason...
uint16_t g_srsCiHigh[SRS_ENTRIES]
instantiate subclasses of ns3::Object.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
uint64_t gbrUl
guaranteed bitrate in uplink
std::string ToString(EpcUeNas::State s)
Definition: epc-ue-nas.cc:47
Service Access Point (SAP) offered by the PDCP entity to the RRC entity See 3GPP 36.323 Packet Data Convergence Protocol (PDCP) specification.
Definition: lte-pdcp-sap.h:35
LteAnrSapUser * m_anrSapUser
Definition: lte-enb-rrc.h:884
Template for the implementation of the LteEnbRrcSapProvider as a member of an owner class of type C t...
Definition: lte-rrc-sap.h:1242
bool m_pendingRrcConnectionReconfiguration
Definition: lte-enb-rrc.h:404
std::vector< ErabNotAdmittedItem > notAdmittedBearers
Definition: epc-x2-sap.h:250
Service Access Point (SAP) offered by the ANR instance to the eNodeB RRC instance.
Definition: lte-anr-sap.h:37
void DoRrcConfigurationUpdateInd(LteEnbCmacSapUser::UeConfig params)
virtual void ConfigureMac(uint8_t ulBandwidth, uint8_t dlBandwidth)=0
struct defining the RACH configuration of the MAC
void DoRecvHandoverPreparationFailure(EpcX2SapUser::HandoverPreparationFailureParams params)
#define NS_LOG_WARN(msg)
Definition: log.h:280
Service Access Point (SAP) offered by the handover algorithm instance to the eNodeB RRC instance...
void StartDataRadioBearers()
Start the data radio bearers that have been previously recorded to be started using RecordDataRadioBe...
Definition: lte-enb-rrc.cc:426
enum ns3::LteRrcSap::ThresholdEutra::@68 choice
virtual AllocateNcRaPreambleReturnValue AllocateNcRaPreamble(uint16_t rnti)=0
Allocate a random access preamble for non-contention based random access (e.g., for handover)...
EpcEnbS1SapUser * GetS1SapUser()
std::list< DrbToAddMod > drbToAddModList
Definition: lte-rrc-sap.h:191
void RecvRrcConnectionReestablishmentRequest(LteRrcSap::RrcConnectionReestablishmentRequest msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentRequest...
Definition: lte-enb-rrc.cc:889
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:848
LteEnbCmacSapProvider * m_cmacSapProvider
Definition: lte-enb-rrc.h:879
LteRrcSap::PhysicalConfigDedicated m_physicalConfigDedicated
Definition: lte-enb-rrc.h:400
std::map< uint16_t, Ptr< UeManager > > m_ueMap
Definition: lte-enb-rrc.h:909
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
Parameters of the LOAD INFORMATION message.
Definition: epc-x2-sap.h:300
virtual Ptr< Packet > EncodeHandoverCommand(RrcConnectionReconfiguration msg)=0
void RecvRrcConnectionRequest(LteRrcSap::RrcConnectionRequest msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionRequest interface...
Definition: lte-enb-rrc.cc:770
SystemInformationBlockType2 sib2
Definition: lte-rrc-sap.h:480
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:36
std::map< uint8_t, Ptr< LteDataRadioBearerInfo > > m_drbMap
Definition: lte-enb-rrc.h:393
TracedCallback< uint64_t, uint16_t, uint16_t > m_connectionReconfigurationTrace
Definition: lte-enb-rrc.h:963
uint8_t GetLogicalChannelPriority(EpsBearer bearer)
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-pdcp-sap.h:80
bool valid
true if a valid RA config was allocated, false otherwise
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:271
uint8_t GetNewRrcTransactionIdentifier()
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
void DoRecvSnStatusTransfer(EpcX2SapUser::SnStatusTransferParams params)
LteEnbCphySapUser * GetLteEnbCphySapUser()
void ConnectionRejectedTimeout(uint16_t rnti)
Method triggered a while after sending RRC Connection Rejected.
uint32_t GetSrsPeriodicity() const
Ptr< LteDataRadioBearerInfo > GetDataRadioBearerInfo(uint8_t drbid)
Reference Signal Received Power.
Definition: lte-rrc-sap.h:299
Template for the implementation of the LteAnrSapUser as a member of an owner class of type C to which...
Definition: lte-anr-sap.h:200
Time m_handoverJoiningTimeoutDuration
Definition: lte-enb-rrc.h:955
uint16_t m_lastAllocatedConfigurationIndex
Definition: lte-enb-rrc.h:938
virtual void SendSystemInformation(SystemInformation msg)=0
Send a SystemInformation message to all attached UEs during a system information acquisition procedur...
virtual void RemoveUe(uint16_t rnti)=0
remove the UE, e.g., after handover or termination of the RRC connection
void HandoverLeavingTimeout(uint16_t rnti)
Method triggered when a UE is expected to leave a cell for a handover but no feedback is received in ...
LTE RLC Acknowledged Mode (AM), see 3GPP TS 36.322.
Definition: lte-rlc-am.h:36
LteHandoverManagementSapProvider * m_handoverManagementSapProvider
Definition: lte-enb-rrc.h:882
a base class which provides memory management and object aggregation
Definition: object.h:63
std::set< uint8_t > m_anrMeasIds
Definition: lte-enb-rrc.h:918
contain a set of ns3::Object pointers.
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:42
void ConfigureCell(uint8_t ulBandwidth, uint8_t dlBandwidth, uint16_t ulEarfcn, uint16_t dlEarfcn, uint16_t cellId)
Configure cell-specific parameters.
void DoRecvRrcConnectionReestablishmentRequest(uint16_t rnti, LteRrcSap::RrcConnectionReestablishmentRequest msg)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentRequest in...
enum ns3::LteRrcSap::SoundingRsUlConfigDedicated::@67 type
Service Access Point (SAP) offered by the eNB MAC to the eNB RRC See Femto Forum MAC Scheduler Interf...
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
void RemoveUe(uint16_t rnti)
remove a UE from the cell
uint64_t gbrDl
guaranteed bitrate in downlink
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Definition: lte-pdcp-sap.h:47
void DoRecvMeasurementReport(uint16_t rnti, LteRrcSap::MeasurementReport msg)
Part of the RRC protocol. Forwarding LteEnbRrcSapProvider::RecvMeasurementReport interface to UeManag...
void CmacUeConfigUpdateInd(LteEnbCmacSapUser::UeConfig cmacParams)
Definition: lte-enb-rrc.cc:965
Parameters of the UE DATA primitive.
Definition: epc-x2-sap.h:325
enum LteEpsBearerToRlcMapping_t m_epsBearerToRlcMapping
Definition: lte-enb-rrc.h:931
Ptr< T > GetObject(void) const
Definition: object.h:361
std::vector< ErabsSubjectToStatusTransferItem > erabsSubjectToStatusTransferList
Definition: epc-x2-sap.h:279
void RecvMeasurementReport(LteRrcSap::MeasurementReport msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvMeasurementReport interface...
Definition: lte-enb-rrc.cc:921
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE...
Definition: lte-rlc.h:50
a unique identifier for an interface.
Definition: type-id.h:49
virtual bool GetNoX2(uint16_t cellId) const =0
Get the value of No X2 field of a neighbouring cell from the Neighbour Relation Table (NRT)...
uint16_t m_targetCellId
Definition: lte-enb-rrc.h:409
std::list< ReportConfigToAddMod > reportConfigToAddModList
Definition: lte-rrc-sap.h:402
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
uint8_t Bid2Drbid(uint8_t bid)
static TypeId GetTypeId(void)
Definition: lte-rlc-am.cc:87
void SetS1SapProvider(EpcEnbS1SapProvider *s)
Set the S1 SAP Provider.
uint8_t Lcid2Drbid(uint8_t lcid)
virtual void RemoveUe(uint16_t rnti)=0
Remove an UE from the the cell.
LteEnbCphySapUser * m_cphySapUser
Definition: lte-enb-rrc.h:895
LteAnrSapProvider * m_anrSapProvider
Definition: lte-enb-rrc.h:885
Service Access Point (SAP) offered by the eNodeB RRC instance to the handover algorithm instance...
void DoDataRadioBearerSetupRequest(EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params)
void DoRecvLoadInformation(EpcX2SapUser::LoadInformationParams params)
RaSupervisionInfo raSupervisionInfo
Definition: lte-rrc-sap.h:175
void RecvHandoverRequestAck(EpcX2SapUser::HandoverRequestAckParams params)
take the necessary actions in response to the reception of an X2 HANDOVER REQUEST ACK message ...
Definition: lte-enb-rrc.cc:561
bool SendData(Ptr< Packet > p)
Enqueue an IP data packet on the proper bearer for downlink transmission.
EventId m_handoverJoiningTimeout
Definition: lte-enb-rrc.h:415
bool isGbr
true if the bearer is GBR, false if the bearer is NON-GBR
Time m_connectionTimeoutDuration
Definition: lte-enb-rrc.h:953
void CompleteSetupUe(LteEnbRrcSapProvider::CompleteSetupUeParameters params)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::CompleteSetupUe interface.
Definition: lte-enb-rrc.cc:762
uint16_t m_cellId
Definition: lte-enb-rrc.h:899
virtual void DoInitialize()
This method is called only once by Object::Initialize.
Definition: lte-enb-rrc.cc:149
MasterInformationBlock sourceMasterInformationBlock
Definition: lte-rrc-sap.h:488
LteRrcSap::MeasConfig m_ueMeasConfig
List of measurement configuration which are active in every UE attached to this eNodeB instance...
Definition: lte-enb-rrc.h:915
int8_t qQualMin
INTEGER (-34..-3), actual value = IE value [dB].
Definition: lte-rrc-sap.h:83
RSRQ is used for the threshold.
Definition: lte-rrc-sap.h:252
Event A1: Serving becomes better than absolute threshold.
Definition: lte-rrc-sap.h:268
void DoRecvHandoverRequestAck(EpcX2SapUser::HandoverRequestAckParams params)
ThresholdEutra threshold2
Threshold for event A5.
Definition: lte-rrc-sap.h:277
void DoRecvHandoverRequest(EpcX2SapUser::HandoverRequestParams params)