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 
103 static const std::string g_ueManagerStateName[UeManager::NUM_STATES] =
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 
117 static const std::string & ToString (UeManager::State s)
118 {
119  return g_ueManagerStateName[s];
120 }
121 
122 
123 NS_OBJECT_ENSURE_REGISTERED (UeManager);
124 
125 
127 {
128  NS_FATAL_ERROR ("this constructor is not espected to be used");
129 }
130 
131 
133  : m_lastAllocatedDrbid (0),
134  m_rnti (rnti),
135  m_imsi (0),
136  m_lastRrcTransactionIdentifier (0),
137  m_rrc (rrc),
138  m_state (s),
139  m_pendingRrcConnectionReconfiguration (false),
140  m_sourceX2apId (0),
141  m_sourceCellId (0),
142  m_needTransmissionModeConfiguration (false)
143 {
144  NS_LOG_FUNCTION (this);
145 }
146 
147 void
149 {
150  NS_LOG_FUNCTION (this);
152 
154  m_physicalConfigDedicated.antennaInfo.transmissionMode = m_rrc->m_defaultTransmissionMode;
159 
160  m_rrc->m_cmacSapProvider->AddUe (m_rnti);
161  m_rrc->m_cphySapProvider->AddUe (m_rnti);
162 
163  // setup the eNB side of SRB0
164  {
165  uint8_t lcid = 0;
166 
167  Ptr<LteRlc> rlc = CreateObject<LteRlcTm> ()->GetObject<LteRlc> ();
168  rlc->SetLteMacSapProvider (m_rrc->m_macSapProvider);
169  rlc->SetRnti (m_rnti);
170  rlc->SetLcId (lcid);
171 
172  m_srb0 = CreateObject<LteSignalingRadioBearerInfo> ();
173  m_srb0->m_rlc = rlc;
174  m_srb0->m_srbIdentity = 0;
175  // no need to store logicalChannelConfig as SRB0 is pre-configured
176 
178  lcinfo.rnti = m_rnti;
179  lcinfo.lcId = lcid;
180  // leave the rest of lcinfo empty as CCCH (LCID 0) is pre-configured
181  m_rrc->m_cmacSapProvider->AddLc (lcinfo, rlc->GetLteMacSapUser ());
182 
183  }
184 
185  // setup the eNB side of SRB1; the UE side will be set up upon RRC connection establishment
186  {
187  uint8_t lcid = 1;
188 
189  Ptr<LteRlc> rlc = CreateObject<LteRlcAm> ()->GetObject<LteRlc> ();
190  rlc->SetLteMacSapProvider (m_rrc->m_macSapProvider);
191  rlc->SetRnti (m_rnti);
192  rlc->SetLcId (lcid);
193 
194  Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> ();
195  pdcp->SetRnti (m_rnti);
196  pdcp->SetLcId (lcid);
197  pdcp->SetLtePdcpSapUser (m_drbPdcpSapUser);
198  pdcp->SetLteRlcSapProvider (rlc->GetLteRlcSapProvider ());
199  rlc->SetLteRlcSapUser (pdcp->GetLteRlcSapUser ());
200 
201  m_srb1 = CreateObject<LteSignalingRadioBearerInfo> ();
202  m_srb1->m_rlc = rlc;
203  m_srb1->m_pdcp = pdcp;
204  m_srb1->m_srbIdentity = 1;
205  m_srb1->m_logicalChannelConfig.priority = 0;
206  m_srb1->m_logicalChannelConfig.prioritizedBitRateKbps = 100;
207  m_srb1->m_logicalChannelConfig.bucketSizeDurationMs = 100;
208  m_srb1->m_logicalChannelConfig.logicalChannelGroup = 0;
209 
211  lcinfo.rnti = m_rnti;
212  lcinfo.lcId = lcid;
213  lcinfo.lcGroup = 0; // all SRBs always mapped to LCG 0
214  lcinfo.qci = EpsBearer::GBR_CONV_VOICE; // not sure why the FF API requires a CQI even for SRBs...
215  lcinfo.isGbr = true;
216  lcinfo.mbrUl = 1e6;
217  lcinfo.mbrDl = 1e6;
218  lcinfo.gbrUl = 1e4;
219  lcinfo.gbrDl = 1e4;
220  m_rrc->m_cmacSapProvider->AddLc (lcinfo, rlc->GetLteMacSapUser ());
221  }
222 
224  ueParams.srb0SapProvider = m_srb0->m_rlc->GetLteRlcSapProvider ();
225  ueParams.srb1SapProvider = m_srb1->m_pdcp->GetLtePdcpSapProvider ();
226  m_rrc->m_rrcSapUser->SetupUe (m_rnti, ueParams);
227 
228  // configure MAC (and scheduler)
230  req.m_rnti = m_rnti;
232  m_rrc->m_cmacSapProvider->UeUpdateConfigurationReq (req);
233 
234  // configure PHY
235  m_rrc->m_cphySapProvider->SetTransmissionMode (m_rnti, m_physicalConfigDedicated.antennaInfo.transmissionMode);
236  m_rrc->m_cphySapProvider->SetSrsConfigurationIndex (m_rnti, m_physicalConfigDedicated.soundingRsUlConfigDedicated.srsConfigIndex);
237 
238  // schedule this UeManager instance to be deleted if the UE does not give any sign of life within a reasonable time
239  Time maxConnectionDelay;
240  switch (m_state)
241  {
243  m_connectionTimeout = Simulator::Schedule (m_rrc->m_connectionTimeoutDuration,
245  m_rrc, m_rnti);
246  break;
247 
248  case HANDOVER_JOINING:
249  m_handoverJoiningTimeout = Simulator::Schedule (m_rrc->m_handoverJoiningTimeoutDuration,
251  m_rrc, m_rnti);
252  break;
253 
254  default:
255  NS_FATAL_ERROR ("unexpected state " << ToString (m_state));
256  break;
257  }
258 
259 }
260 
261 
263 {
264 }
265 
266 void
268 {
269  delete m_drbPdcpSapUser;
270  // delete eventual X2-U TEIDs
271  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
272  it != m_drbMap.end ();
273  ++it)
274  {
275  m_rrc->m_x2uTeidInfoMap.erase (it->second->m_gtpTeid);
276  }
277 
278 }
279 
281 {
282  static TypeId tid = TypeId ("ns3::UeManager")
283  .SetParent<Object> ()
284  .AddConstructor<UeManager> ()
285  .AddAttribute ("DataRadioBearerMap", "List of UE DataRadioBearerInfo by DRBID.",
286  ObjectMapValue (),
288  MakeObjectMapChecker<LteDataRadioBearerInfo> ())
289  .AddAttribute ("Srb0", "SignalingRadioBearerInfo for SRB0",
290  PointerValue (),
291  MakePointerAccessor (&UeManager::m_srb0),
292  MakePointerChecker<LteSignalingRadioBearerInfo> ())
293  .AddAttribute ("Srb1", "SignalingRadioBearerInfo for SRB1",
294  PointerValue (),
295  MakePointerAccessor (&UeManager::m_srb1),
296  MakePointerChecker<LteSignalingRadioBearerInfo> ())
297  .AddAttribute ("C-RNTI",
298  "Cell Radio Network Temporary Identifier",
299  TypeId::ATTR_GET, // read-only attribute
300  UintegerValue (0), // unused, read-only attribute
301  MakeUintegerAccessor (&UeManager::m_rnti),
302  MakeUintegerChecker<uint16_t> ())
303  .AddTraceSource ("StateTransition",
304  "fired upon every UE state transition seen by the UeManager at the eNB RRC",
306  ;
307  return tid;
308 }
309 
310 void
311 UeManager::SetSource (uint16_t sourceCellId, uint16_t sourceX2apId)
312 {
313  m_sourceX2apId = sourceX2apId;
314  m_sourceCellId = sourceCellId;
315 }
316 
317 void
318 UeManager::SetImsi (uint64_t imsi)
319 {
320  m_imsi = imsi;
321 }
322 
323 void
324 UeManager::SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint32_t gtpTeid, Ipv4Address transportLayerAddress)
325 {
326  NS_LOG_FUNCTION (this << (uint32_t) m_rnti);
327 
328  Ptr<LteDataRadioBearerInfo> drbInfo = CreateObject<LteDataRadioBearerInfo> ();
329  uint8_t drbid = AddDataRadioBearerInfo (drbInfo);
330  uint8_t lcid = Drbid2Lcid (drbid);
331  uint8_t bid = Drbid2Bid (drbid);
332  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");
333  drbInfo->m_epsBearerIdentity = bid;
334  drbInfo->m_drbIdentity = drbid;
335  drbInfo->m_logicalChannelIdentity = lcid;
336  drbInfo->m_gtpTeid = gtpTeid;
337  drbInfo->m_transportLayerAddress = transportLayerAddress;
338 
339  if (m_state == HANDOVER_JOINING)
340  {
341  // setup TEIDs for receiving data eventually forwarded over X2-U
342  LteEnbRrc::X2uTeidInfo x2uTeidInfo;
343  x2uTeidInfo.rnti = m_rnti;
344  x2uTeidInfo.drbid = drbid;
345  std::pair<std::map<uint32_t, LteEnbRrc::X2uTeidInfo>::iterator, bool>
346  ret = m_rrc->m_x2uTeidInfoMap.insert (std::pair<uint32_t, LteEnbRrc::X2uTeidInfo> (gtpTeid, x2uTeidInfo));
347  NS_ASSERT_MSG (ret.second == true, "overwriting a pre-existing entry in m_x2uTeidInfoMap");
348  }
349 
350  TypeId rlcTypeId = m_rrc->GetRlcType (bearer);
351 
352  ObjectFactory rlcObjectFactory;
353  rlcObjectFactory.SetTypeId (rlcTypeId);
354  Ptr<LteRlc> rlc = rlcObjectFactory.Create ()->GetObject<LteRlc> ();
355  rlc->SetLteMacSapProvider (m_rrc->m_macSapProvider);
356  rlc->SetRnti (m_rnti);
357 
358  drbInfo->m_rlc = rlc;
359 
360  rlc->SetLcId (lcid);
361 
362  // we need PDCP only for real RLC, i.e., RLC/UM or RLC/AM
363  // if we are using RLC/SM we don't care of anything above RLC
364  if (rlcTypeId != LteRlcSm::GetTypeId ())
365  {
366  Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> ();
367  pdcp->SetRnti (m_rnti);
368  pdcp->SetLcId (lcid);
369  pdcp->SetLtePdcpSapUser (m_drbPdcpSapUser);
370  pdcp->SetLteRlcSapProvider (rlc->GetLteRlcSapProvider ());
371  rlc->SetLteRlcSapUser (pdcp->GetLteRlcSapUser ());
372  drbInfo->m_pdcp = pdcp;
373  }
374 
376  lcinfo.rnti = m_rnti;
377  lcinfo.lcId = lcid;
378  lcinfo.lcGroup = m_rrc->GetLogicalChannelGroup (bearer);
379  lcinfo.qci = bearer.qci;
380  lcinfo.isGbr = bearer.IsGbr ();
381  lcinfo.mbrUl = bearer.gbrQosInfo.mbrUl;
382  lcinfo.mbrDl = bearer.gbrQosInfo.mbrDl;
383  lcinfo.gbrUl = bearer.gbrQosInfo.gbrUl;
384  lcinfo.gbrDl = bearer.gbrQosInfo.gbrDl;
385  m_rrc->m_cmacSapProvider->AddLc (lcinfo, rlc->GetLteMacSapUser ());
386 
387  if (rlcTypeId == LteRlcAm::GetTypeId ())
388  {
389  drbInfo->m_rlcConfig.choice = LteRrcSap::RlcConfig::AM;
390  }
391  else
392  {
393  drbInfo->m_rlcConfig.choice = LteRrcSap::RlcConfig::UM_BI_DIRECTIONAL;
394  }
395 
396  drbInfo->m_logicalChannelIdentity = lcid;
397  drbInfo->m_logicalChannelConfig.priority = m_rrc->GetLogicalChannelPriority (bearer);
398  drbInfo->m_logicalChannelConfig.logicalChannelGroup = m_rrc->GetLogicalChannelGroup (bearer);
399  if (bearer.IsGbr ())
400  {
401  drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = bearer.gbrQosInfo.gbrUl;
402  }
403  else
404  {
405  drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = 0;
406  }
407  drbInfo->m_logicalChannelConfig.bucketSizeDurationMs = 1000;
408 
410 }
411 
412 void
414 {
415  NS_LOG_FUNCTION (this << (uint32_t) m_rnti);
416  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
417  it != m_drbMap.end ();
418  ++it)
419  {
420  m_drbsToBeStarted.push_back (it->first);
421  }
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this << (uint32_t) m_rnti);
428  for (std::list <uint8_t>::iterator drbIdIt = m_drbsToBeStarted.begin ();
429  drbIdIt != m_drbsToBeStarted.end ();
430  ++drbIdIt)
431  {
432  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt = m_drbMap.find (*drbIdIt);
433  NS_ASSERT (drbIt != m_drbMap.end ());
434  drbIt->second->m_rlc->Initialize ();
435  if (drbIt->second->m_pdcp)
436  {
437  drbIt->second->m_pdcp->Initialize ();
438  }
439  }
440  m_drbsToBeStarted.clear ();
441 }
442 
443 
444 void
446 {
447  NS_LOG_FUNCTION (this << (uint32_t) m_rnti << (uint32_t) drbid);
448  uint8_t lcid = Drbid2Lcid (drbid);
449  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid);
450  NS_ASSERT_MSG (it != m_drbMap.end (), "request to remove radio bearer with unknown drbid " << drbid);
451 
452  // first delete eventual X2-U TEIDs
453  m_rrc->m_x2uTeidInfoMap.erase (it->second->m_gtpTeid);
454 
455  m_drbMap.erase (it);
456  m_rrc->m_cmacSapProvider->ReleaseLc (m_rnti, lcid);
457 
459  rrcd.havePhysicalConfigDedicated = false;
460  rrcd.drbToReleaseList.push_back (drbid);
461 
463  msg.haveMeasConfig = false;
464  msg.haveMobilityControlInfo = false;
465 
466  m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, msg);
467 }
468 
469 
470 void
472 {
473  NS_LOG_FUNCTION (this);
474  switch (m_state)
475  {
477  case CONNECTION_SETUP:
481  case HANDOVER_JOINING:
482  case HANDOVER_LEAVING:
483  // a previous reconfiguration still ongoing, we need to wait for it to be finished
485  break;
486 
487  case CONNECTED_NORMALLY:
488  {
491  m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, msg);
494  }
495  break;
496 
497  default:
498  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
499  break;
500  }
501 }
502 
503 void
504 UeManager::PrepareHandover (uint16_t cellId)
505 {
506  NS_LOG_FUNCTION (this << cellId);
507  switch (m_state)
508  {
509  case CONNECTED_NORMALLY:
510  {
511  m_targetCellId = cellId;
513  params.oldEnbUeX2apId = m_rnti;
515  params.sourceCellId = m_rrc->m_cellId;
516  params.targetCellId = cellId;
517  params.mmeUeS1apId = m_imsi;
518  params.ueAggregateMaxBitRateDownlink = 200 * 1000;
519  params.ueAggregateMaxBitRateUplink = 100 * 1000;
520  params.bearers = GetErabList ();
521 
524  hpi.asConfig.sourceDlCarrierFreq = m_rrc->m_dlEarfcn;
525  hpi.asConfig.sourceMeasConfig = m_rrc->m_ueMeasConfig;
529  hpi.asConfig.sourceSystemInformationBlockType1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity = m_rrc->m_sib1.cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity;
531  hpi.asConfig.sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIndication = m_rrc->m_sib1.cellAccessRelatedInfo.csgIndication;
532  hpi.asConfig.sourceSystemInformationBlockType1.cellAccessRelatedInfo.csgIdentity = m_rrc->m_sib1.cellAccessRelatedInfo.csgIdentity;
533  LteEnbCmacSapProvider::RachConfig rc = m_rrc->m_cmacSapProvider->GetRachConfig ();
539  params.rrcContext = m_rrc->m_rrcSapUser->EncodeHandoverPreparationInformation (hpi);
540 
541  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
542  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
543  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
544  NS_LOG_LOGIC ("mmeUeS1apId = " << params.mmeUeS1apId);
545  NS_LOG_LOGIC ("rrcContext = " << params.rrcContext);
546 
547  m_rrc->m_x2SapProvider->SendHandoverRequest (params);
549  }
550  break;
551 
552  default:
553  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
554  break;
555  }
556 
557 }
558 
559 void
561 {
562  NS_LOG_FUNCTION (this);
563 
564  NS_ASSERT_MSG (params.notAdmittedBearers.empty (), "not admission of some bearers upon handover is not supported");
565  NS_ASSERT_MSG (params.admittedBearers.size () == m_drbMap.size (), "not enough bearers in admittedBearers");
566 
567  // note: the Handover command from the target eNB to the source eNB
568  // is expected to be sent transparently to the UE; however, here we
569  // decode the message and eventually reencode it. This way we can
570  // support both a real RRC protocol implementation and an ideal one
571  // without actual RRC protocol encoding.
572 
573  Ptr<Packet> encodedHandoverCommand = params.rrcContext;
574  LteRrcSap::RrcConnectionReconfiguration handoverCommand = m_rrc->m_rrcSapUser->DecodeHandoverCommand (encodedHandoverCommand);
575  m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration (m_rnti, handoverCommand);
577  m_handoverLeavingTimeout = Simulator::Schedule (m_rrc->m_handoverLeavingTimeoutDuration,
579  m_rrc, m_rnti);
580  NS_ASSERT (handoverCommand.haveMobilityControlInfo);
581  m_rrc->m_handoverStartTrace (m_imsi, m_rrc->m_cellId, m_rnti, handoverCommand.mobilityControlInfo.targetPhysCellId);
582 
584  sst.oldEnbUeX2apId = params.oldEnbUeX2apId;
585  sst.newEnbUeX2apId = params.newEnbUeX2apId;
586  sst.sourceCellId = params.sourceCellId;
587  sst.targetCellId = params.targetCellId;
588  for ( std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt = m_drbMap.begin ();
589  drbIt != m_drbMap.end ();
590  ++drbIt)
591  {
592  // SN status transfer is only for AM RLC
593  if (0 != drbIt->second->m_rlc->GetObject<LteRlcAm> ())
594  {
595  LtePdcp::Status status = drbIt->second->m_pdcp->GetStatus ();
597  i.dlPdcpSn = status.txSn;
598  i.ulPdcpSn = status.rxSn;
599  sst.erabsSubjectToStatusTransferList.push_back (i);
600  }
601  }
602  m_rrc->m_x2SapProvider->SendSnStatusTransfer (sst);
603 }
604 
605 
608 {
609  NS_LOG_FUNCTION (this);
611 }
612 
615 {
616  NS_LOG_FUNCTION (this);
618 }
619 
620 void
622 {
623  NS_LOG_FUNCTION (this << p << (uint16_t) bid);
624  switch (m_state)
625  {
627  case CONNECTION_SETUP:
628  NS_LOG_WARN ("not connected, discarding packet");
629  return;
630  break;
631 
632  case CONNECTED_NORMALLY:
636  case HANDOVER_JOINING:
638  {
639  NS_LOG_LOGIC ("queueing data on PDCP for transmission over the air");
641  params.pdcpSdu = p;
642  params.rnti = m_rnti;
643  params.lcid = Bid2Lcid (bid);
644  uint8_t drbid = Bid2Drbid (bid);
645  LtePdcpSapProvider* pdcpSapProvider = GetDataRadioBearerInfo (drbid)->m_pdcp->GetLtePdcpSapProvider ();
646  pdcpSapProvider->TransmitPdcpSdu (params);
647  }
648  break;
649 
650  case HANDOVER_LEAVING:
651  {
652  NS_LOG_LOGIC ("forwarding data to target eNB over X2-U");
653  uint8_t drbid = Bid2Drbid (bid);
654  EpcX2Sap::UeDataParams params;
655  params.sourceCellId = m_rrc->m_cellId;
656  params.targetCellId = m_targetCellId;
657  params.gtpTeid = GetDataRadioBearerInfo (drbid)->m_gtpTeid;
658  params.ueData = p;
659  m_rrc->m_x2SapProvider->SendUeData (params);
660  }
661  break;
662 
663  default:
664  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
665  break;
666  }
667 }
668 
669 std::vector<EpcX2Sap::ErabToBeSetupItem>
671 {
672  NS_LOG_FUNCTION (this);
673  std::vector<EpcX2Sap::ErabToBeSetupItem> ret;
674  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
675  it != m_drbMap.end ();
676  ++it)
677  {
679  etbsi.erabId = it->second->m_epsBearerIdentity;
680  etbsi.erabLevelQosParameters = it->second->m_epsBearer;
681  etbsi.dlForwarding = false;
682  etbsi.transportLayerAddress = it->second->m_transportLayerAddress;
683  etbsi.gtpTeid = it->second->m_gtpTeid;
684  ret.push_back (etbsi);
685  }
686  return ret;
687 }
688 
689 void
691 {
692  NS_LOG_FUNCTION (this);
693  switch (m_state)
694  {
696  NS_LOG_INFO ("Send UE CONTEXT RELEASE from target eNB to source eNB");
697  EpcX2SapProvider::UeContextReleaseParams ueCtxReleaseParams;
698  ueCtxReleaseParams.oldEnbUeX2apId = m_sourceX2apId;
699  ueCtxReleaseParams.newEnbUeX2apId = m_rnti;
700  ueCtxReleaseParams.sourceCellId = m_sourceCellId;
701  m_rrc->m_x2SapProvider->SendUeContextRelease (ueCtxReleaseParams);
703  m_rrc->m_handoverEndOkTrace (m_imsi, m_rrc->m_cellId, m_rnti);
704  break;
705 
706  default:
707  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
708  break;
709  }
710 }
711 
712 void
714 {
715  NS_LOG_FUNCTION (this << cellId);
716  switch (m_state)
717  {
718  case HANDOVER_PREPARATION:
719  NS_ASSERT (cellId == m_targetCellId);
720  NS_LOG_INFO ("target eNB sent HO preparation failure, aborting HO");
722  break;
723 
724  default:
725  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
726  break;
727  }
728 }
729 
730 void
732 {
733  NS_LOG_FUNCTION (this);
734  for (std::vector<EpcX2Sap::ErabsSubjectToStatusTransferItem>::iterator erabIt
735  = params.erabsSubjectToStatusTransferList.begin ();
736  erabIt != params.erabsSubjectToStatusTransferList.end ();
737  ++erabIt)
738  {
739  // LtePdcp::Status status;
740  // status.txSn = erabIt->dlPdcpSn;
741  // status.rxSn = erabIt->ulPdcpSn;
742  // uint8_t drbId = Bid2Drbid (erabIt->erabId);
743  // std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt = m_drbMap.find (drbId);
744  // NS_ASSERT_MSG (drbIt != m_drbMap.end (), "could not find DRBID " << (uint32_t) drbId);
745  // drbIt->second->m_pdcp->SetStatus (status);
746  }
747 }
748 
749 void
751 {
752  NS_LOG_FUNCTION (this);
753  NS_ASSERT_MSG (m_state == HANDOVER_LEAVING, "method unexpected in state " << ToString (m_state));
755 }
756 
757 
758 // methods forwarded from RRC SAP
759 
760 void
762 {
763  NS_LOG_FUNCTION (this);
764  m_srb0->m_rlc->SetLteRlcSapUser (params.srb0SapUser);
765  m_srb1->m_pdcp->SetLtePdcpSapUser (params.srb1SapUser);
766 }
767 
768 void
770 {
771  NS_LOG_FUNCTION (this);
772  switch (m_state)
773  {
774  case INITIAL_RANDOM_ACCESS:
775  {
776  if (m_rrc->m_admitRrcConnectionRequest == true)
777  {
779  m_imsi = msg.ueIdentity;
780  if (m_rrc->m_s1SapProvider != 0)
781  {
782  m_rrc->m_s1SapProvider->InitialUeMessage (m_imsi, m_rnti);
783  }
787  m_rrc->m_rrcSapUser->SendRrcConnectionSetup (m_rnti, msg2);
790  }
791  else
792  {
794  NS_LOG_INFO ("rejecting connection request for RNTI " << m_rnti);
796  rejectMsg.waitTime = 3;
797  m_rrc->m_rrcSapUser->SendRrcConnectionReject (m_rnti, rejectMsg);
798  m_connectionRejectedTimeout = Simulator::Schedule (m_rrc->m_connectionRejectedTimeoutDuration,
800  m_rrc, m_rnti);
802  }
803  }
804  break;
805 
806  default:
807  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
808  break;
809  }
810 }
811 
812 void
814 {
815  NS_LOG_FUNCTION (this);
816  switch (m_state)
817  {
818  case CONNECTION_SETUP:
821  m_rrc->m_connectionEstablishedTrace (m_imsi, m_rrc->m_cellId, m_rnti);
822  break;
823 
824  default:
825  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
826  break;
827  }
828 }
829 
830 void
832 {
833  NS_LOG_FUNCTION (this);
834  switch (m_state)
835  {
839  {
840  // configure MAC (and scheduler)
842  req.m_rnti = m_rnti;
844  m_rrc->m_cmacSapProvider->UeUpdateConfigurationReq (req);
845 
846  // configure PHY
847  m_rrc->m_cphySapProvider->SetTransmissionMode (req.m_rnti, req.m_transmissionMode);
848 
850  }
852  m_rrc->m_connectionReconfigurationTrace (m_imsi, m_rrc->m_cellId, m_rnti);
853  break;
854 
855  case HANDOVER_LEAVING:
856  NS_LOG_INFO ("ignoring RecvRrcConnectionReconfigurationCompleted in state " << ToString (m_state));
857  break;
858 
859  case HANDOVER_JOINING:
860  {
862  NS_LOG_INFO ("Send PATH SWITCH REQUEST to the MME");
864  params.rnti = m_rnti;
865  params.cellId = m_rrc->m_cellId;
866  params.mmeUeS1Id = m_imsi;
868  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
869  it != m_drbMap.end ();
870  ++it)
871  {
873  b.epsBearerId = it->second->m_epsBearerIdentity;
874  b.teid = it->second->m_gtpTeid;
875  params.bearersToBeSwitched.push_back (b);
876  }
877  m_rrc->m_s1SapProvider->PathSwitchRequest (params);
878  }
879  break;
880 
881  default:
882  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
883  break;
884  }
885 }
886 
887 void
889 {
890  NS_LOG_FUNCTION (this);
891  switch (m_state)
892  {
893  case CONNECTED_NORMALLY:
894  break;
895 
896  case HANDOVER_LEAVING:
898  break;
899 
900  default:
901  NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state));
902  break;
903  }
904 
908  m_rrc->m_rrcSapUser->SendRrcConnectionReestablishment (m_rnti, msg2);
910 }
911 
912 void
914 {
915  NS_LOG_FUNCTION (this);
917 }
918 
919 void
921 {
922  uint8_t measId = msg.measResults.measId;
923  NS_LOG_FUNCTION (this << (uint16_t) measId);
924  NS_LOG_LOGIC ("measId " << (uint16_t) measId
925  << " haveMeasResultNeighCells " << msg.measResults.haveMeasResultNeighCells
926  << " measResultListEutra " << msg.measResults.measResultListEutra.size ());
927  NS_LOG_LOGIC ("serving cellId " << m_rrc->m_cellId
928  << " RSRP " << (uint16_t) msg.measResults.rsrpResult
929  << " RSRQ " << (uint16_t) msg.measResults.rsrqResult);
930 
931  for (std::list <LteRrcSap::MeasResultEutra>::iterator it = msg.measResults.measResultListEutra.begin ();
932  it != msg.measResults.measResultListEutra.end ();
933  ++it)
934  {
935  NS_LOG_LOGIC ("neighbour cellId " << it->physCellId
936  << " RSRP " << (it->haveRsrpResult ? (uint16_t) it->rsrpResult : 255)
937  << " RSRQ " << (it->haveRsrqResult ? (uint16_t) it->rsrqResult : 255));
938  }
939 
940  if ((m_rrc->m_handoverManagementSapProvider != 0)
941  && (m_rrc->m_handoverMeasIds.find (measId) != m_rrc->m_handoverMeasIds.end ()))
942  {
943  // this measurement was requested by the handover algorithm
944  m_rrc->m_handoverManagementSapProvider->ReportUeMeas (m_rnti,
945  msg.measResults);
946  }
947 
948  if ((m_rrc->m_anrSapProvider != 0)
949  && (m_rrc->m_anrMeasIds.find (measId) != m_rrc->m_anrMeasIds.end ()))
950  {
951  // this measurement was requested by the ANR function
952  m_rrc->m_anrSapProvider->ReportUeMeas (msg.measResults);
953  }
954 
955  // fire a trace source
956  m_rrc->m_recvMeasurementReportTrace (m_imsi, m_rrc->m_cellId, m_rnti, msg);
957 
958 } // end of UeManager::RecvMeasurementReport
959 
960 
961 // methods forwarded from CMAC SAP
962 
963 void
965 {
966  NS_LOG_FUNCTION (this << m_rnti);
967  // at this stage used only by the scheduler for updating txMode
968 
970 
972 
973  // reconfigure the UE RRC
975 }
976 
977 
978 // methods forwarded from PDCP SAP
979 
980 void
982 {
983  NS_LOG_FUNCTION (this);
984  if (params.lcid > 2)
985  {
986  // data radio bearer
987  EpsBearerTag tag;
988  tag.SetRnti (params.rnti);
989  tag.SetBid (Lcid2Bid (params.lcid));
990  params.pdcpSdu->AddPacketTag (tag);
991  m_rrc->m_forwardUpCallback (params.pdcpSdu);
992  }
993 }
994 
995 
996 uint16_t
997 UeManager::GetRnti (void) const
998 {
999  return m_rnti;
1000 }
1001 
1002 uint64_t
1004 {
1005  return m_imsi;
1006 }
1007 
1008 uint16_t
1010 {
1012 }
1013 
1014 void
1016 {
1017  NS_LOG_FUNCTION (this);
1019  m_rrc->m_cphySapProvider->SetSrsConfigurationIndex (m_rnti, srsConfIndex);
1020  switch (m_state)
1021  {
1022  case INITIAL_RANDOM_ACCESS:
1023  // do nothing, srs conf index will be correctly enforced upon
1024  // RRC connection establishment
1025  break;
1026 
1027  default:
1029  break;
1030  }
1031 }
1032 
1035 {
1036  return m_state;
1037 }
1038 
1039 uint8_t
1041 {
1042  NS_LOG_FUNCTION (this);
1043  const uint8_t MAX_DRB_ID = 32;
1044  for (int drbid = (m_lastAllocatedDrbid + 1) % MAX_DRB_ID;
1045  drbid != m_lastAllocatedDrbid;
1046  drbid = (drbid + 1) % MAX_DRB_ID)
1047  {
1048  if (drbid != 0) // 0 is not allowed
1049  {
1050  if (m_drbMap.find (drbid) == m_drbMap.end ())
1051  {
1052  m_drbMap.insert (std::pair<uint8_t, Ptr<LteDataRadioBearerInfo> > (drbid, drbInfo));
1053  drbInfo->m_drbIdentity = drbid;
1054  m_lastAllocatedDrbid = drbid;
1055  return drbid;
1056  }
1057  }
1058  }
1059  NS_FATAL_ERROR ("no more data radio bearer ids available");
1060  return 0;
1061 }
1062 
1065 {
1066  NS_LOG_FUNCTION (this << (uint32_t) drbid);
1067  NS_ASSERT (0 != drbid);
1068  std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid);
1069  NS_ABORT_IF (it == m_drbMap.end ());
1070  return it->second;
1071 }
1072 
1073 
1074 void
1076 {
1077  NS_LOG_FUNCTION (this << (uint32_t) drbid);
1078  std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid);
1079  NS_ASSERT_MSG (it != m_drbMap.end (), "request to remove radio bearer with unknown drbid " << drbid);
1080  m_drbMap.erase (it);
1081 }
1082 
1083 
1086 {
1091  msg.haveMobilityControlInfo = false;
1092  msg.haveMeasConfig = true;
1093  msg.measConfig = m_rrc->m_ueMeasConfig;
1094 
1095  return msg;
1096 }
1097 
1100 {
1102 
1103  if (m_srb1 != 0)
1104  {
1106  stam.srbIdentity = m_srb1->m_srbIdentity;
1107  stam.logicalChannelConfig = m_srb1->m_logicalChannelConfig;
1108  rrcd.srbToAddModList.push_back (stam);
1109  }
1110 
1111  for (std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.begin ();
1112  it != m_drbMap.end ();
1113  ++it)
1114  {
1116  dtam.epsBearerIdentity = it->second->m_epsBearerIdentity;
1117  dtam.drbIdentity = it->second->m_drbIdentity;
1118  dtam.rlcConfig = it->second->m_rlcConfig;
1119  dtam.logicalChannelIdentity = it->second->m_logicalChannelIdentity;
1120  dtam.logicalChannelConfig = it->second->m_logicalChannelConfig;
1121  rrcd.drbToAddModList.push_back (dtam);
1122  }
1123 
1124  rrcd.havePhysicalConfigDedicated = true;
1126  return rrcd;
1127 }
1128 
1129 uint8_t
1131 {
1133 }
1134 
1135 uint8_t
1137 {
1138  NS_ASSERT (lcid > 2);
1139  return lcid - 2;
1140 }
1141 
1142 uint8_t
1143 UeManager::Drbid2Lcid (uint8_t drbid)
1144 {
1145  return drbid + 2;
1146 }
1147 uint8_t
1148 UeManager::Lcid2Bid (uint8_t lcid)
1149 {
1150  NS_ASSERT (lcid > 2);
1151  return lcid - 2;
1152 }
1153 
1154 uint8_t
1155 UeManager::Bid2Lcid (uint8_t bid)
1156 {
1157  return bid + 2;
1158 }
1159 
1160 uint8_t
1161 UeManager::Drbid2Bid (uint8_t drbid)
1162 {
1163  return drbid;
1164 }
1165 
1166 uint8_t
1168 {
1169  return bid;
1170 }
1171 
1172 
1173 void
1175 {
1176  NS_LOG_FUNCTION (this << ToString (newState));
1177  State oldState = m_state;
1178  m_state = newState;
1179  NS_LOG_INFO (this << "IMSI " << m_imsi << " RNTI " << m_rnti << " UeManager "
1180  << ToString (oldState) << " --> " << ToString (newState));
1181  m_stateTransitionTrace (m_imsi, m_rrc->m_cellId, m_rnti, oldState, newState);
1182 
1183  switch (newState)
1184  {
1185  case INITIAL_RANDOM_ACCESS:
1186  case HANDOVER_JOINING:
1187  NS_FATAL_ERROR ("cannot switch to an initial state");
1188  break;
1189 
1190  case CONNECTION_SETUP:
1191  break;
1192 
1193  case CONNECTED_NORMALLY:
1194  {
1196  {
1198  }
1199  }
1200  break;
1201 
1203  break;
1204 
1206  break;
1207 
1208  case HANDOVER_LEAVING:
1209  break;
1210 
1211  default:
1212  break;
1213  }
1214 }
1215 
1216 
1217 
1219 // eNB RRC methods
1221 
1223 
1225  : m_x2SapProvider (0),
1226  m_cmacSapProvider (0),
1227  m_handoverManagementSapProvider (0),
1228  m_anrSapProvider (0),
1229  m_rrcSapUser (0),
1230  m_macSapProvider (0),
1231  m_s1SapProvider (0),
1232  m_cphySapProvider (0),
1233  m_configured (false),
1234  m_lastAllocatedRnti (0),
1235  m_srsCurrentPeriodicityId (0),
1236  m_lastAllocatedConfigurationIndex (0),
1237  m_reconfigureUes (false)
1238 {
1239  NS_LOG_FUNCTION (this);
1247 }
1248 
1249 
1251 {
1252  NS_LOG_FUNCTION (this);
1253 }
1254 
1255 
1256 void
1258 {
1259  NS_LOG_FUNCTION (this);
1260  m_ueMap.clear ();
1261  delete m_cmacSapUser;
1263  delete m_anrSapUser;
1264  delete m_rrcSapProvider;
1265  delete m_x2SapUser;
1266  delete m_s1SapUser;
1267  delete m_cphySapUser;
1268 }
1269 
1270 TypeId
1272 {
1273  NS_LOG_FUNCTION ("LteEnbRrc::GetTypeId");
1274  static TypeId tid = TypeId ("ns3::LteEnbRrc")
1275  .SetParent<Object> ()
1276  .AddConstructor<LteEnbRrc> ()
1277  .AddAttribute ("UeMap", "List of UeManager by C-RNTI.",
1278  ObjectMapValue (),
1280  MakeObjectMapChecker<UeManager> ())
1281  .AddAttribute ("DefaultTransmissionMode",
1282  "The default UEs' transmission mode (0: SISO)",
1283  UintegerValue (0), // default tx-mode
1284  MakeUintegerAccessor (&LteEnbRrc::m_defaultTransmissionMode),
1285  MakeUintegerChecker<uint8_t> ())
1286  .AddAttribute ("EpsBearerToRlcMapping",
1287  "Specify which type of RLC will be used for each type of EPS bearer. ",
1290  MakeEnumChecker (RLC_SM_ALWAYS, "RlcSmAlways",
1291  RLC_UM_ALWAYS, "RlcUmAlways",
1292  RLC_AM_ALWAYS, "RlcAmAlways",
1293  PER_BASED, "PacketErrorRateBased"))
1294  .AddAttribute ("SystemInformationPeriodicity",
1295  "The interval for sending system information (Time value)",
1296  TimeValue (MilliSeconds (80)),
1297  MakeTimeAccessor (&LteEnbRrc::m_systemInformationPeriodicity),
1298  MakeTimeChecker ())
1299 
1300  // SRS related attributes
1301  .AddAttribute ("SrsPeriodicity",
1302  "The SRS periodicity in milliseconds",
1303  UintegerValue (40),
1304  MakeUintegerAccessor (&LteEnbRrc::SetSrsPeriodicity,
1306  MakeUintegerChecker<uint32_t> ())
1307 
1308  // Timeout related attributes
1309  .AddAttribute ("ConnectionTimeoutDuration",
1310  "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.",
1311  TimeValue (MilliSeconds (15)),
1312  MakeTimeAccessor (&LteEnbRrc::m_connectionTimeoutDuration),
1313  MakeTimeChecker ())
1314  .AddAttribute ("ConnectionRejectedTimeoutDuration",
1315  "Time to wait between sending a RRC CONNECTION REJECT and destroying the UE context",
1316  TimeValue (MilliSeconds (30)),
1318  MakeTimeChecker ())
1319  .AddAttribute ("HandoverJoiningTimeoutDuration",
1320  "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.",
1321  TimeValue (MilliSeconds (200)),
1322  MakeTimeAccessor (&LteEnbRrc::m_handoverJoiningTimeoutDuration),
1323  MakeTimeChecker ())
1324  .AddAttribute ("HandoverLeavingTimeoutDuration",
1325  "After issuing a Handover Command, if neither RRC Connection Reestablishment nor X2 UE Context Release has been previously received, the UE context is destroyed.",
1326  TimeValue (MilliSeconds (500)),
1327  MakeTimeAccessor (&LteEnbRrc::m_handoverLeavingTimeoutDuration),
1328  MakeTimeChecker ())
1329 
1330  // Cell selection related attribute
1331  .AddAttribute ("QRxLevMin",
1332  "One of information transmitted within the SIB1 message, "
1333  "indicating the required minimum RSRP level that any UE must "
1334  "receive from this cell before it is allowed to camp to this "
1335  "cell. The default value -70 corresponds to -140 dBm and is "
1336  "the lowest possible value as defined by Section 6.3.4 of "
1337  "3GPP TS 36.133. This restriction, however, only applies to "
1338  "initial cell selection and EPC-enabled simulation.",
1340  IntegerValue (-70),
1341  MakeIntegerAccessor (&LteEnbRrc::m_qRxLevMin),
1342  MakeIntegerChecker<int8_t> (-70, -22))
1343 
1344  // Handover related attributes
1345  .AddAttribute ("AdmitHandoverRequest",
1346  "Whether to admit an X2 handover request from another eNB",
1347  BooleanValue (true),
1348  MakeBooleanAccessor (&LteEnbRrc::m_admitHandoverRequest),
1349  MakeBooleanChecker ())
1350  .AddAttribute ("AdmitRrcConnectionRequest",
1351  "Whether to admit a connection request from a UE",
1352  BooleanValue (true),
1353  MakeBooleanAccessor (&LteEnbRrc::m_admitRrcConnectionRequest),
1354  MakeBooleanChecker ())
1355 
1356  // UE measurements related attributes
1357  .AddAttribute ("RsrpFilterCoefficient",
1358  "Determines the strength of smoothing effect induced by "
1359  "layer 3 filtering of RSRP in all attached UE; "
1360  "if set to 0, no layer 3 filtering is applicable",
1361  // i.e. the variable k in 3GPP TS 36.331 section 5.5.3.2
1362  UintegerValue (4),
1363  MakeUintegerAccessor (&LteEnbRrc::m_rsrpFilterCoefficient),
1364  MakeUintegerChecker<uint8_t> (0))
1365  .AddAttribute ("RsrqFilterCoefficient",
1366  "Determines the strength of smoothing effect induced by "
1367  "layer 3 filtering of RSRQ in all attached UE; "
1368  "if set to 0, no layer 3 filtering is applicable",
1369  // i.e. the variable k in 3GPP TS 36.331 section 5.5.3.2
1370  UintegerValue (4),
1371  MakeUintegerAccessor (&LteEnbRrc::m_rsrqFilterCoefficient),
1372  MakeUintegerChecker<uint8_t> (0))
1373 
1374  // Trace sources
1375  .AddTraceSource ("NewUeContext",
1376  "trace fired upon creation of a new UE context",
1378  .AddTraceSource ("ConnectionEstablished",
1379  "trace fired upon successful RRC connection establishment",
1381  .AddTraceSource ("ConnectionReconfiguration",
1382  "trace fired upon RRC connection reconfiguration",
1384  .AddTraceSource ("HandoverStart",
1385  "trace fired upon start of a handover procedure",
1387  .AddTraceSource ("HandoverEndOk",
1388  "trace fired upon successful termination of a handover procedure",
1390  .AddTraceSource ("RecvMeasurementReport",
1391  "trace fired when measurement report is received",
1393  ;
1394  return tid;
1395 }
1396 
1397 void
1399 {
1400  NS_LOG_FUNCTION (this << s);
1401  m_x2SapProvider = s;
1402 }
1403 
1404 EpcX2SapUser*
1406 {
1407  NS_LOG_FUNCTION (this);
1408  return m_x2SapUser;
1409 }
1410 
1411 void
1413 {
1414  NS_LOG_FUNCTION (this << s);
1415  m_cmacSapProvider = s;
1416 }
1417 
1420 {
1421  NS_LOG_FUNCTION (this);
1422  return m_cmacSapUser;
1423 }
1424 
1425 void
1427 {
1428  NS_LOG_FUNCTION (this << s);
1430 }
1431 
1434 {
1435  NS_LOG_FUNCTION (this);
1437 }
1438 
1439 void
1441 {
1442  NS_LOG_FUNCTION (this << s);
1443  m_anrSapProvider = s;
1444 }
1445 
1448 {
1449  NS_LOG_FUNCTION (this);
1450  return m_anrSapUser;
1451 }
1452 
1453 void
1455 {
1456  NS_LOG_FUNCTION (this << s);
1457  m_rrcSapUser = s;
1458 }
1459 
1462 {
1463  NS_LOG_FUNCTION (this);
1464  return m_rrcSapProvider;
1465 }
1466 
1467 void
1469 {
1470  NS_LOG_FUNCTION (this);
1471  m_macSapProvider = s;
1472 }
1473 
1474 void
1476 {
1477  m_s1SapProvider = s;
1478 }
1479 
1480 
1483 {
1484  return m_s1SapUser;
1485 }
1486 
1487 void
1489 {
1490  NS_LOG_FUNCTION (this << s);
1491  m_cphySapProvider = s;
1492 }
1493 
1496 {
1497  NS_LOG_FUNCTION (this);
1498  return m_cphySapUser;
1499 }
1500 
1503 {
1504  NS_LOG_FUNCTION (this << (uint32_t) rnti);
1505  NS_ASSERT (0 != rnti);
1506  std::map<uint16_t, Ptr<UeManager> >::iterator it = m_ueMap.find (rnti);
1507  NS_ASSERT_MSG (it != m_ueMap.end (), "RNTI " << rnti << " not found in eNB with cellId " << m_cellId);
1508  return it->second;
1509 }
1510 
1511 uint8_t
1513 {
1514  NS_LOG_FUNCTION (this);
1515 
1516  // SANITY CHECK
1517 
1519  "Measurement identities and reporting configuration should not have different quantity");
1520 
1521  if (Simulator::Now () != Seconds (0))
1522  {
1523  NS_FATAL_ERROR ("AddUeMeasReportConfig may not be called after the simulation has run");
1524  }
1525 
1526  // INPUT VALIDATION
1527 
1528  switch (config.triggerQuantity)
1529  {
1533  {
1534  NS_FATAL_ERROR ("The given triggerQuantity (RSRP) does not match with the given threshold2.choice");
1535  }
1536 
1542  {
1543  NS_FATAL_ERROR ("The given triggerQuantity (RSRP) does not match with the given threshold1.choice");
1544  }
1545  break;
1546 
1550  {
1551  NS_FATAL_ERROR ("The given triggerQuantity (RSRQ) does not match with the given threshold2.choice");
1552  }
1553 
1559  {
1560  NS_FATAL_ERROR ("The given triggerQuantity (RSRQ) does not match with the given threshold1.choice");
1561  }
1562  break;
1563 
1564  default:
1565  NS_FATAL_ERROR ("unsupported triggerQuantity");
1566  break;
1567  }
1568 
1570  {
1571  NS_FATAL_ERROR ("Only REPORT_STRONGEST_CELLS purpose is supported");
1572  }
1573 
1575  {
1576  NS_LOG_WARN ("reportQuantity = BOTH will be used instead of the given reportQuantity");
1577  }
1578 
1579  uint8_t nextId = m_ueMeasConfig.reportConfigToAddModList.size () + 1;
1580 
1581  // create the reporting configuration
1582  LteRrcSap::ReportConfigToAddMod reportConfig;
1583  reportConfig.reportConfigId = nextId;
1584  reportConfig.reportConfigEutra = config;
1585 
1586  // create the measurement identity
1588  measId.measId = nextId;
1589  measId.measObjectId = 1;
1590  measId.reportConfigId = nextId;
1591 
1592  // add both to the list of UE measurement configuration
1593  m_ueMeasConfig.reportConfigToAddModList.push_back (reportConfig);
1594  m_ueMeasConfig.measIdToAddModList.push_back (measId);
1595 
1596  return nextId;
1597 }
1598 
1599 void
1600 LteEnbRrc::ConfigureCell (uint8_t ulBandwidth, uint8_t dlBandwidth,
1601  uint16_t ulEarfcn, uint16_t dlEarfcn, uint16_t cellId)
1602 {
1603  NS_LOG_FUNCTION (this << (uint16_t) ulBandwidth << (uint16_t) dlBandwidth
1604  << ulEarfcn << dlEarfcn << cellId);
1606  m_cmacSapProvider->ConfigureMac (ulBandwidth, dlBandwidth);
1607  m_cphySapProvider->SetBandwidth (ulBandwidth, dlBandwidth);
1608  m_cphySapProvider->SetEarfcn (ulEarfcn, dlEarfcn);
1609  m_dlEarfcn = dlEarfcn;
1610  m_ulEarfcn = ulEarfcn;
1611  m_dlBandwidth = dlBandwidth;
1612  m_ulBandwidth = ulBandwidth;
1613  m_cellId = cellId;
1614  m_cphySapProvider->SetCellId (cellId);
1615 
1616  /*
1617  * Initializing the list of UE measurement configuration (m_ueMeasConfig).
1618  * Only intra-frequency measurements are supported, so only one measurement
1619  * object is created.
1620  */
1621 
1622  LteRrcSap::MeasObjectToAddMod measObject;
1623  measObject.measObjectId = 1;
1624  measObject.measObjectEutra.carrierFreq = m_dlEarfcn;
1626  measObject.measObjectEutra.presenceAntennaPort1 = false;
1627  measObject.measObjectEutra.neighCellConfig = 0;
1628  measObject.measObjectEutra.offsetFreq = 0;
1629  measObject.measObjectEutra.haveCellForWhichToReportCGI = false;
1630 
1631  m_ueMeasConfig.measObjectToAddModList.push_back (measObject);
1636  m_ueMeasConfig.haveSmeasure = false;
1638 
1639  // Enabling MIB transmission
1641  mib.dlBandwidth = m_dlBandwidth;
1643 
1644  // Enabling SIB1 transmission with default values
1649  m_sib1.cellSelectionInfo.qQualMin = -34; // not used, set as minimum value
1650  m_sib1.cellSelectionInfo.qRxLevMin = m_qRxLevMin; // set as minimum value
1652 
1653  /*
1654  * Enabling transmission of other SIB. The first time System Information is
1655  * transmitted is arbitrarily assumed to be at +0.016s, and then it will be
1656  * regularly transmitted every 80 ms by default (set the
1657  * SystemInformationPeriodicity attribute to configure this).
1658  */
1659  Simulator::Schedule (MilliSeconds (16), &LteEnbRrc::SendSystemInformation, this);
1660 
1661  m_configured = true;
1662 
1663 }
1664 
1665 
1666 void
1667 LteEnbRrc::SetCellId (uint16_t cellId)
1668 {
1669  m_cellId = cellId;
1670 
1671  // update SIB1 too
1674 }
1675 
1676 bool
1678 {
1679  NS_LOG_FUNCTION (this << packet);
1680 
1681  EpsBearerTag tag;
1682  bool found = packet->RemovePacketTag (tag);
1683  NS_ASSERT_MSG (found, "no EpsBearerTag found in packet to be sent");
1684  Ptr<UeManager> ueManager = GetUeManager (tag.GetRnti ());
1685  ueManager->SendData (tag.GetBid (), packet);
1686 
1687  return true;
1688 }
1689 
1690 void
1692 {
1693  m_forwardUpCallback = cb;
1694 }
1695 
1696 void
1698 {
1699  NS_LOG_FUNCTION (this << rnti);
1701  "ConnectionTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1702  RemoveUe (rnti);
1703 }
1704 
1705 void
1707 {
1708  NS_LOG_FUNCTION (this << rnti);
1710  "ConnectionTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1711  RemoveUe (rnti);
1712 }
1713 
1714 void
1716 {
1717  NS_LOG_FUNCTION (this << rnti);
1718  NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::HANDOVER_JOINING,
1719  "HandoverJoiningTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1720  RemoveUe (rnti);
1721 }
1722 
1723 void
1725 {
1726  NS_LOG_FUNCTION (this << rnti);
1727  NS_ASSERT_MSG (GetUeManager (rnti)->GetState () == UeManager::HANDOVER_LEAVING,
1728  "HandoverLeavingTimeout in unexpected state " << ToString (GetUeManager (rnti)->GetState ()));
1729  RemoveUe (rnti);
1730 }
1731 
1732 void
1733 LteEnbRrc::SendHandoverRequest (uint16_t rnti, uint16_t cellId)
1734 {
1735  NS_LOG_FUNCTION (this << rnti << cellId);
1736  NS_LOG_LOGIC ("Request to send HANDOVER REQUEST");
1738 
1739  Ptr<UeManager> ueManager = GetUeManager (rnti);
1740  ueManager->PrepareHandover (cellId);
1741 
1742 }
1743 
1744 void
1746 {
1747  NS_LOG_FUNCTION (this << rnti);
1748  GetUeManager (rnti)->CompleteSetupUe (params);
1749 }
1750 
1751 void
1753 {
1754  NS_LOG_FUNCTION (this << rnti);
1755  GetUeManager (rnti)->RecvRrcConnectionRequest (msg);
1756 }
1757 
1758 void
1760 {
1761  NS_LOG_FUNCTION (this << rnti);
1762  GetUeManager (rnti)->RecvRrcConnectionSetupCompleted (msg);
1763 }
1764 
1765 void
1767 {
1768  NS_LOG_FUNCTION (this << rnti);
1769  GetUeManager (rnti)->RecvRrcConnectionReconfigurationCompleted (msg);
1770 }
1771 
1772 void
1774 {
1775  NS_LOG_FUNCTION (this << rnti);
1776  GetUeManager (rnti)->RecvRrcConnectionReestablishmentRequest (msg);
1777 }
1778 
1779 void
1781 {
1782  NS_LOG_FUNCTION (this << rnti);
1783  GetUeManager (rnti)->RecvRrcConnectionReestablishmentComplete (msg);
1784 }
1785 
1786 void
1788 {
1789  NS_LOG_FUNCTION (this << rnti);
1790  GetUeManager (rnti)->RecvMeasurementReport (msg);
1791 }
1792 
1793 void
1795 {
1796  Ptr<UeManager> ueManager = GetUeManager (request.rnti);
1797  ueManager->SetupDataRadioBearer (request.bearer, request.bearerId, request.gtpTeid, request.transportLayerAddress);
1798 }
1799 
1800 void
1802 {
1803  Ptr<UeManager> ueManager = GetUeManager (params.rnti);
1804  ueManager->SendUeContextRelease ();
1805 }
1806 
1807 void
1809 {
1810  NS_LOG_FUNCTION (this);
1811 
1812  NS_LOG_LOGIC ("Recv X2 message: HANDOVER REQUEST");
1813 
1814  NS_LOG_LOGIC ("oldEnbUeX2apId = " << req.oldEnbUeX2apId);
1815  NS_LOG_LOGIC ("sourceCellId = " << req.sourceCellId);
1816  NS_LOG_LOGIC ("targetCellId = " << req.targetCellId);
1817  NS_LOG_LOGIC ("mmeUeS1apId = " << req.mmeUeS1apId);
1818 
1819  NS_ASSERT (req.targetCellId == m_cellId);
1820 
1821  if (m_admitHandoverRequest == false)
1822  {
1823  NS_LOG_INFO ("rejecting handover request from cellId " << req.sourceCellId);
1825  res.oldEnbUeX2apId = req.oldEnbUeX2apId;
1826  res.sourceCellId = req.sourceCellId ;
1827  res.targetCellId = req.targetCellId ;
1828  res.cause = 0;
1829  res.criticalityDiagnostics = 0;
1831  return;
1832  }
1833 
1834  uint16_t rnti = AddUe (UeManager::HANDOVER_JOINING);
1836  if (anrcrv.valid == false)
1837  {
1838  NS_LOG_INFO (this << "failed to allocate a preamble for non-contention based RA => cannot accept HO");
1839  RemoveUe (rnti);
1840  NS_FATAL_ERROR ("should trigger HO Preparation Failure, but it is not implemented");
1841  return;
1842  }
1843 
1844  Ptr<UeManager> ueManager = GetUeManager (rnti);
1845  ueManager->SetSource (req.sourceCellId, req.oldEnbUeX2apId);
1846  ueManager->SetImsi (req.mmeUeS1apId);
1847 
1849  ackParams.oldEnbUeX2apId = req.oldEnbUeX2apId;
1850  ackParams.newEnbUeX2apId = rnti;
1851  ackParams.sourceCellId = req.sourceCellId;
1852  ackParams.targetCellId = req.targetCellId;
1853 
1854  for (std::vector <EpcX2Sap::ErabToBeSetupItem>::iterator it = req.bearers.begin ();
1855  it != req.bearers.end ();
1856  ++it)
1857  {
1858  ueManager->SetupDataRadioBearer (it->erabLevelQosParameters, it->erabId, it->gtpTeid, it->transportLayerAddress);
1860  i.erabId = it->erabId;
1861  ackParams.admittedBearers.push_back (i);
1862  }
1863 
1864  LteRrcSap::RrcConnectionReconfiguration handoverCommand = ueManager->GetRrcConnectionReconfigurationForHandover ();
1865  handoverCommand.haveMobilityControlInfo = true;
1866  handoverCommand.mobilityControlInfo.targetPhysCellId = m_cellId;
1867  handoverCommand.mobilityControlInfo.haveCarrierFreq = true;
1870  handoverCommand.mobilityControlInfo.haveCarrierBandwidth = true;
1873  handoverCommand.mobilityControlInfo.newUeIdentity = rnti;
1874  handoverCommand.mobilityControlInfo.haveRachConfigDedicated = true;
1877 
1882 
1883  Ptr<Packet> encodedHandoverCommand = m_rrcSapUser->EncodeHandoverCommand (handoverCommand);
1884 
1885  ackParams.rrcContext = encodedHandoverCommand;
1886 
1887  NS_LOG_LOGIC ("Send X2 message: HANDOVER REQUEST ACK");
1888 
1889  NS_LOG_LOGIC ("oldEnbUeX2apId = " << ackParams.oldEnbUeX2apId);
1890  NS_LOG_LOGIC ("newEnbUeX2apId = " << ackParams.newEnbUeX2apId);
1891  NS_LOG_LOGIC ("sourceCellId = " << ackParams.sourceCellId);
1892  NS_LOG_LOGIC ("targetCellId = " << ackParams.targetCellId);
1893 
1895 }
1896 
1897 void
1899 {
1900  NS_LOG_FUNCTION (this);
1901 
1902  NS_LOG_LOGIC ("Recv X2 message: HANDOVER REQUEST ACK");
1903 
1904  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1905  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
1906  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
1907  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
1908 
1909  uint16_t rnti = params.oldEnbUeX2apId;
1910  Ptr<UeManager> ueManager = GetUeManager (rnti);
1911  ueManager->RecvHandoverRequestAck (params);
1912 }
1913 
1914 void
1916 {
1917  NS_LOG_FUNCTION (this);
1918 
1919  NS_LOG_LOGIC ("Recv X2 message: HANDOVER PREPARATION FAILURE");
1920 
1921  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1922  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
1923  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
1924  NS_LOG_LOGIC ("cause = " << params.cause);
1925  NS_LOG_LOGIC ("criticalityDiagnostics = " << params.criticalityDiagnostics);
1926 
1927  uint16_t rnti = params.oldEnbUeX2apId;
1928  Ptr<UeManager> ueManager = GetUeManager (rnti);
1929  ueManager->RecvHandoverPreparationFailure (params.targetCellId);
1930 }
1931 
1932 void
1934 {
1935  NS_LOG_FUNCTION (this);
1936 
1937  NS_LOG_LOGIC ("Recv X2 message: SN STATUS TRANSFER");
1938 
1939  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1940  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
1941  NS_LOG_LOGIC ("erabsSubjectToStatusTransferList size = " << params.erabsSubjectToStatusTransferList.size ());
1942 
1943  uint16_t rnti = params.newEnbUeX2apId;
1944  Ptr<UeManager> ueManager = GetUeManager (rnti);
1945  ueManager->RecvSnStatusTransfer (params);
1946 }
1947 
1948 void
1950 {
1951  NS_LOG_FUNCTION (this);
1952 
1953  NS_LOG_LOGIC ("Recv X2 message: UE CONTEXT RELEASE");
1954 
1955  NS_LOG_LOGIC ("oldEnbUeX2apId = " << params.oldEnbUeX2apId);
1956  NS_LOG_LOGIC ("newEnbUeX2apId = " << params.newEnbUeX2apId);
1957 
1958  uint16_t rnti = params.oldEnbUeX2apId;
1959  GetUeManager (rnti)->RecvUeContextRelease (params);
1960  RemoveUe (rnti);
1961 }
1962 
1963 void
1965 {
1966  NS_LOG_FUNCTION (this);
1967 
1968  NS_LOG_LOGIC ("Recv X2 message: LOAD INFORMATION");
1969 
1970  NS_LOG_LOGIC ("Number of cellInformationItems = " << params.cellInformationList.size ());
1971 
1972  NS_ASSERT ("Processing of LOAD INFORMATION X2 message IS NOT IMPLEMENTED");
1973 }
1974 
1975 void
1977 {
1978  NS_LOG_FUNCTION (this);
1979 
1980  NS_LOG_LOGIC ("Recv X2 message: RESOURCE STATUS UPDATE");
1981 
1982  NS_LOG_LOGIC ("Number of cellMeasurementResultItems = " << params.cellMeasurementResultList.size ());
1983 
1984  NS_ASSERT ("Processing of RESOURCE STATUS UPDATE X2 message IS NOT IMPLEMENTED");
1985 }
1986 
1987 void
1989 {
1990  NS_LOG_FUNCTION (this);
1991 
1992  NS_LOG_LOGIC ("Recv UE DATA FORWARDING through X2 interface");
1993  NS_LOG_LOGIC ("sourceCellId = " << params.sourceCellId);
1994  NS_LOG_LOGIC ("targetCellId = " << params.targetCellId);
1995  NS_LOG_LOGIC ("gtpTeid = " << params.gtpTeid);
1996  NS_LOG_LOGIC ("ueData = " << params.ueData);
1997  NS_LOG_LOGIC ("ueData size = " << params.ueData->GetSize ());
1998 
1999  std::map<uint32_t, X2uTeidInfo>::iterator
2000  teidInfoIt = m_x2uTeidInfoMap.find (params.gtpTeid);
2001  if (teidInfoIt != m_x2uTeidInfoMap.end ())
2002  {
2003  GetUeManager (teidInfoIt->second.rnti)->SendData (teidInfoIt->second.drbid, params.ueData);
2004  }
2005  else
2006  {
2007  NS_FATAL_ERROR ("X2-U data received but no X2uTeidInfo found");
2008  }
2009 }
2010 
2011 
2012 uint16_t
2014 {
2015  NS_LOG_FUNCTION (this);
2017 }
2018 
2019 void
2021 {
2022  Ptr<UeManager> ueManager = GetUeManager (cmacParams.m_rnti);
2023  ueManager->CmacUeConfigUpdateInd (cmacParams);
2024 }
2025 
2026 void
2027 LteEnbRrc::DoNotifyLcConfigResult (uint16_t rnti, uint8_t lcid, bool success)
2028 {
2029  NS_LOG_FUNCTION (this << (uint32_t) rnti);
2030  NS_FATAL_ERROR ("not implemented");
2031 }
2032 
2033 
2034 uint8_t
2036 {
2037  NS_LOG_FUNCTION (this);
2038  uint8_t measId = AddUeMeasReportConfig (reportConfig);
2039  m_handoverMeasIds.insert (measId);
2040  return measId;
2041 }
2042 
2043 void
2044 LteEnbRrc::DoTriggerHandover (uint16_t rnti, uint16_t targetCellId)
2045 {
2046  NS_LOG_FUNCTION (this << rnti << targetCellId);
2047 
2048  bool isHandoverAllowed = true;
2049 
2050  if (m_anrSapProvider != 0)
2051  {
2052  // ensure that proper neighbour relationship exists between source and target cells
2053  bool noHo = m_anrSapProvider->GetNoHo (targetCellId);
2054  bool noX2 = m_anrSapProvider->GetNoX2 (targetCellId);
2055  NS_LOG_DEBUG (this << " cellId=" << m_cellId
2056  << " targetCellId=" << targetCellId
2057  << " NRT.NoHo=" << noHo << " NRT.NoX2=" << noX2);
2058 
2059  if (noHo || noX2)
2060  {
2061  isHandoverAllowed = false;
2062  NS_LOG_LOGIC (this << " handover to cell " << targetCellId
2063  << " is not allowed by ANR");
2064  }
2065  }
2066 
2067  Ptr<UeManager> ueManager = GetUeManager (rnti);
2068  NS_ASSERT_MSG (ueManager != 0, "Cannot find UE context with RNTI " << rnti);
2069 
2070  if (ueManager->GetState () != UeManager::CONNECTED_NORMALLY)
2071  {
2072  isHandoverAllowed = false;
2073  NS_LOG_LOGIC (this << " handover is not allowed because the UE"
2074  << " rnti=" << rnti << " is in "
2075  << ToString (ueManager->GetState ()) << " state");
2076  }
2077 
2078  if (isHandoverAllowed)
2079  {
2080  // initiate handover execution
2081  ueManager->PrepareHandover (targetCellId);
2082  }
2083 }
2084 
2085 uint8_t
2087 {
2088  NS_LOG_FUNCTION (this);
2089  uint8_t measId = AddUeMeasReportConfig (reportConfig);
2090  m_anrMeasIds.insert (measId);
2091  return measId;
2092 }
2093 
2094 
2095 
2096 uint16_t
2098 {
2099  NS_LOG_FUNCTION (this);
2100  bool found = false;
2101  uint16_t rnti;
2102  for (rnti = m_lastAllocatedRnti + 1;
2103  (rnti != m_lastAllocatedRnti - 1) && (!found);
2104  ++rnti)
2105  {
2106  if ((rnti != 0) && (m_ueMap.find (rnti) == m_ueMap.end ()))
2107  {
2108  found = true;
2109  break;
2110  }
2111  }
2112 
2113  NS_ASSERT_MSG (found, "no more RNTIs available (do you have more than 65535 UEs in a cell?)");
2114  m_lastAllocatedRnti = rnti;
2115  Ptr<UeManager> ueManager = CreateObject<UeManager> (this, rnti, state);
2116  m_ueMap.insert (std::pair<uint16_t, Ptr<UeManager> > (rnti, ueManager));
2117  ueManager->Initialize ();
2118  NS_LOG_DEBUG (this << " New UE RNTI " << rnti << " cellId " << m_cellId << " srs CI " << ueManager->GetSrsConfigurationIndex ());
2119  m_newUeContextTrace (m_cellId, rnti);
2120  return rnti;
2121 }
2122 
2123 void
2124 LteEnbRrc::RemoveUe (uint16_t rnti)
2125 {
2126  NS_LOG_FUNCTION (this << (uint32_t) rnti);
2127  std::map <uint16_t, Ptr<UeManager> >::iterator it = m_ueMap.find (rnti);
2128  NS_ASSERT_MSG (it != m_ueMap.end (), "request to remove UE info with unknown rnti " << rnti);
2129  uint16_t srsCi = (*it).second->GetSrsConfigurationIndex ();
2130  m_ueMap.erase (it);
2131  m_cmacSapProvider->RemoveUe (rnti);
2132  m_cphySapProvider->RemoveUe (rnti);
2133  if (m_s1SapProvider != 0)
2134  {
2136  }
2137  // need to do this after UeManager has been deleted
2138  RemoveSrsConfigurationIndex (srsCi);
2139 }
2140 
2141 TypeId
2143 {
2144  switch (m_epsBearerToRlcMapping)
2145  {
2146  case RLC_SM_ALWAYS:
2147  return LteRlcSm::GetTypeId ();
2148  break;
2149 
2150  case RLC_UM_ALWAYS:
2151  return LteRlcUm::GetTypeId ();
2152  break;
2153 
2154  case RLC_AM_ALWAYS:
2155  return LteRlcAm::GetTypeId ();
2156  break;
2157 
2158  case PER_BASED:
2159  if (bearer.GetPacketErrorLossRate () > 1.0e-5)
2160  {
2161  return LteRlcUm::GetTypeId ();
2162  }
2163  else
2164  {
2165  return LteRlcAm::GetTypeId ();
2166  }
2167  break;
2168 
2169  default:
2170  return LteRlcSm::GetTypeId ();
2171  break;
2172  }
2173 }
2174 
2175 
2176 void
2177 LteEnbRrc::AddX2Neighbour (uint16_t cellId)
2178 {
2179  NS_LOG_FUNCTION (this << cellId);
2180 
2181  if (m_anrSapProvider != 0)
2182  {
2184  }
2185 }
2186 
2187 void
2188 LteEnbRrc::SetCsgId (uint32_t csgId, bool csgIndication)
2189 {
2190  NS_LOG_FUNCTION (this << csgId << csgIndication);
2192  m_sib1.cellAccessRelatedInfo.csgIndication = csgIndication;
2194 }
2195 
2196 
2197 // from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity
2198 static const uint8_t SRS_ENTRIES = 9;
2199 static const uint16_t g_srsPeriodicity[SRS_ENTRIES] = {0, 2, 5, 10, 20, 40, 80, 160, 320};
2200 static const uint16_t g_srsCiLow[SRS_ENTRIES] = {0, 0, 2, 7, 17, 37, 77, 157, 317};
2201 static const uint16_t g_srsCiHigh[SRS_ENTRIES] = {0, 1, 6, 16, 36, 76, 156, 316, 636};
2202 
2203 void
2205 {
2206  NS_LOG_FUNCTION (this << p);
2207  for (uint32_t id = 1; id < SRS_ENTRIES; ++id)
2208  {
2209  if (g_srsPeriodicity[id] == p)
2210  {
2212  return;
2213  }
2214  }
2215  // no match found
2216  std::ostringstream allowedValues;
2217  for (uint32_t id = 1; id < SRS_ENTRIES; ++id)
2218  {
2219  allowedValues << g_srsPeriodicity[id] << " ";
2220  }
2221  NS_FATAL_ERROR ("illecit SRS periodicity value " << p << ". Allowed values: " << allowedValues.str ());
2222 }
2223 
2224 uint32_t
2226 {
2227  NS_LOG_FUNCTION (this);
2231 }
2232 
2233 
2234 uint16_t
2236 {
2238  // SRS
2241  NS_LOG_DEBUG (this << " SRS p " << g_srsPeriodicity[m_srsCurrentPeriodicityId] << " set " << m_ueSrsConfigurationIndexSet.size ());
2243  {
2244  NS_FATAL_ERROR ("too many UEs (" << m_ueSrsConfigurationIndexSet.size () + 1
2245  << ") for current SRS periodicity "
2247  << ", consider increasing the value of ns3::LteEnbRrc::SrsPeriodicity");
2248  }
2249 
2250  if (m_ueSrsConfigurationIndexSet.empty ())
2251  {
2252  // first entry
2255  }
2256  else
2257  {
2258  // find a CI from the available ones
2259  std::set<uint16_t>::reverse_iterator rit = m_ueSrsConfigurationIndexSet.rbegin ();
2260  NS_ASSERT (rit != m_ueSrsConfigurationIndexSet.rend ());
2261  NS_LOG_DEBUG (this << " lower bound " << (*rit) << " of " << g_srsCiHigh[m_srsCurrentPeriodicityId]);
2262  if ((*rit) < g_srsCiHigh[m_srsCurrentPeriodicityId])
2263  {
2264  // got it from the upper bound
2265  m_lastAllocatedConfigurationIndex = (*rit) + 1;
2267  }
2268  else
2269  {
2270  // look for released ones
2271  for (uint16_t srcCi = g_srsCiLow[m_srsCurrentPeriodicityId]; srcCi < g_srsCiHigh[m_srsCurrentPeriodicityId]; srcCi++)
2272  {
2273  std::set<uint16_t>::iterator it = m_ueSrsConfigurationIndexSet.find (srcCi);
2274  if (it==m_ueSrsConfigurationIndexSet.end ())
2275  {
2277  m_ueSrsConfigurationIndexSet.insert (srcCi);
2278  break;
2279  }
2280  }
2281  }
2282  }
2284 
2285 }
2286 
2287 
2288 void
2290 {
2291  NS_LOG_FUNCTION (this << srcCi);
2292  std::set<uint16_t>::iterator it = m_ueSrsConfigurationIndexSet.find (srcCi);
2293  NS_ASSERT_MSG (it != m_ueSrsConfigurationIndexSet.end (), "request to remove unkwown SRS CI " << srcCi);
2294  m_ueSrsConfigurationIndexSet.erase (it);
2295 }
2296 
2297 uint8_t
2299 {
2300  if (bearer.IsGbr ())
2301  {
2302  return 1;
2303  }
2304  else
2305  {
2306  return 2;
2307  }
2308 }
2309 
2310 uint8_t
2312 {
2313  return bearer.qci;
2314 }
2315 
2316 void
2318 {
2319  // NS_LOG_FUNCTION (this);
2320 
2321  /*
2322  * For simplicity, we use the same periodicity for all SIBs. Note that in real
2323  * systems the periodicy of each SIBs could be different.
2324  */
2326  si.haveSib2 = true;
2329 
2331  LteRrcSap::RachConfigCommon rachConfigCommon;
2333  rachConfigCommon.raSupervisionInfo.preambleTransMax = rc.preambleTransMax;
2335  si.sib2.radioResourceConfigCommon.rachConfigCommon = rachConfigCommon;
2336 
2339 }
2340 
2341 
2342 } // namespace ns3
2343 
virtual void AddNeighbourRelation(uint16_t cellId)=0
Add a new Neighbour Relation entry.
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.
static 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.
Both the RSRP and RSRQ quantities are to be included in the measurement report.
Definition: lte-rrc-sap.h:306
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...
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
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.
void SendSystemInformation()
method used to periodically send System Information
LteRrcSap::RadioResourceConfigDedicated GetRadioResourceConfigForHandoverPreparationInfo()
Definition: lte-enb-rrc.cc:607
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
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)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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
Reference Signal Received Quality.
Definition: lte-rrc-sap.h:300
Callback template class.
Definition: callback.h:924
void RecordDataRadioBearersToBeStarted()
Start all configured data radio bearers.
Definition: lte-enb-rrc.cc:413
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-enb-rrc.cc:267
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:750
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:311
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:713
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
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:183
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)
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
Event A1: Serving becomes better than absolute threshold.
Definition: lte-rrc-sap.h:268
std::vector< CellMeasurementResultItem > cellMeasurementResultList
Definition: epc-x2-sap.h:316
enum ns3::LteRrcSap::ReportConfigEutra::@75 reportQuantity
The quantities to be included in the measurement report, always assumed to be BOTH.
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.
enum ns3::LteRrcSap::ReportConfigEutra::@72 eventId
Choice of E-UTRA event triggered reporting criteria.
static TypeId GetTypeId(void)
uint16_t m_sourceCellId
Definition: lte-enb-rrc.h:408
virtual ~LteEnbRrc()
Destructor.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
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)
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
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
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:744
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)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
uint16_t DoAllocateTemporaryCellRnti()
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
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:825
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:318
void SetRnti(uint16_t rnti)
Definition: lte-rlc.cc:125
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:690
LteRrcSap::RrcConnectionReconfiguration GetRrcConnectionReconfigurationForHandover()
Definition: lte-enb-rrc.cc:614
void SwitchToState(State s)
Switch the UeManager to the given state.
static const std::string g_ueManagerStateName[UeManager::NUM_STATES]
Definition: lte-enb-rrc.cc:103
void RecvRrcConnectionReconfigurationCompleted(LteRrcSap::RrcConnectionReconfigurationCompleted msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionReconfigurationComplet...
Definition: lte-enb-rrc.cc:831
void ReleaseDataRadioBearer(uint8_t drbid)
Release a given radio bearer.
Definition: lte-enb-rrc.cc:445
double GetPacketErrorLossRate() const
Definition: eps-bearer.cc:144
uint8_t AddDataRadioBearerInfo(Ptr< LteDataRadioBearerInfo > radioBearerInfo)
Add a new LteDataRadioBearerInfo structure to the UeManager.
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
LteEnbCmacSapUser * m_cmacSapUser
Definition: lte-enb-rrc.h:878
Ptr< UeManager > GetUeManager(uint16_t rnti)
Event A2: Serving becomes worse than absolute threshold.
Definition: lte-rrc-sap.h:269
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
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:271
uint8_t AddUeMeasReportConfig(LteRrcSap::ReportConfigEutra config)
Add a new UE measurement reporting configuration.
RSRP is used for the threshold.
Definition: lte-rrc-sap.h:251
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 ...
Event A5: PCell becomes worse than absolute threshold1 AND Neighbour becomes better than another abso...
Definition: lte-rrc-sap.h:272
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:1008
uint16_t m_ulEarfcn
Definition: lte-enb-rrc.h:901
static TypeId GetTypeId(void)
Definition: lte-rlc-um.cc:55
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
enum ns3::LteRrcSap::SoundingRsUlConfigDedicated::@69 type
TracedCallback< uint64_t, uint16_t, uint16_t > m_connectionEstablishedTrace
Definition: lte-enb-rrc.h:961
RSRQ is used for the threshold.
Definition: lte-rrc-sap.h:252
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
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
LteMacSapUser * GetLteMacSapUser()
Definition: lte-rlc.cc:160
void SendData(uint8_t bid, Ptr< Packet > p)
Send a data packet over the appropriate Data Radio Bearer.
Definition: lte-enb-rrc.cc:621
std::set< uint8_t > m_handoverMeasIds
Definition: lte-enb-rrc.h:917
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
virtual RachConfig GetRachConfig()=0
RadioResourceConfigDedicated radioResourceConfigDedicated
Definition: lte-rrc-sap.h:532
void DoRecvUeContextRelease(EpcX2SapUser::UeContextReleaseParams params)
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:262
uint8_t m_rsrpFilterCoefficient
Definition: lte-enb-rrc.h:949
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:324
void RemoveDataRadioBearerInfo(uint8_t drbid)
remove the LteDataRadioBearerInfo corresponding to a bearer being released
static TypeId GetTypeId(void)
Definition: lte-enb-rrc.cc:280
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:731
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()
void SetLteRlcSapUser(LteRlcSapUser *s)
Definition: lte-rlc.cc:139
enum ns3::EpsBearer::Qci qci
EventId m_handoverLeavingTimeout
Definition: lte-enb-rrc.h:416
enum ns3::LteRrcSap::ThresholdEutra::@70 choice
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:813
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:981
static const uint16_t g_srsCiLow[SRS_ENTRIES]
Reference Signal Received Power.
Definition: lte-rrc-sap.h:299
TracedCallback< uint64_t, uint16_t, uint16_t, uint16_t > m_handoverStartTrace
Definition: lte-enb-rrc.h:965
std::vector< EpcX2Sap::ErabToBeSetupItem > GetErabList()
Definition: lte-enb-rrc.cc:670
virtual void SetSystemInformationBlockType1(LteRrcSap::SystemInformationBlockType1 sib1)=0
void ScheduleRrcConnectionReconfiguration()
schedule an RRC Connection Reconfiguration procedure with the UE
Definition: lte-enb-rrc.cc:471
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
uint8_t m_defaultTransmissionMode
Definition: lte-enb-rrc.h:929
void DoRecvResourceStatusUpdate(EpcX2SapUser::ResourceStatusUpdateParams params)
void SetLcId(uint8_t lcId)
Definition: lte-rlc.cc:132
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
void PrepareHandover(uint16_t cellId)
Start the handover preparation and send the handover request.
Definition: lte-enb-rrc.cc:504
CarrierBandwidthEutra carrierBandwidth
Definition: lte-rrc-sap.h:439
uint8_t DoAddUeMeasReportConfigForHandover(LteRrcSap::ReportConfigEutra reportConfig)
uint16_t GetRnti(void) const
Definition: lte-enb-rrc.cc:997
void RecvRrcConnectionReestablishmentComplete(LteRrcSap::RrcConnectionReestablishmentComplete msg)
Part of the RRC protocol. Implement the LteEnbRrcSapProvider::RecvRrcConnectionReestablishmentComplet...
Definition: lte-enb-rrc.cc:913
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
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
enum ns3::LteRrcSap::ReportConfigEutra::@74 triggerQuantity
The quantities used to evaluate the triggering condition for the event, see 3GPP TS 36...
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...
#define NS_ABORT_IF(cond)
Abnormal program termination if cond is true.
Definition: abort.h:71
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
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
static const std::string & ToString(EpcUeNas::State s)
Definition: epc-ue-nas.cc:47
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)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:203
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:425
virtual AllocateNcRaPreambleReturnValue AllocateNcRaPreamble(uint16_t rnti)=0
Allocate a random access preamble for non-contention based random access (e.g., for handover)...
static const uint16_t g_srsPeriodicity[SRS_ENTRIES]
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:888
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)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
static const uint16_t g_srsCiHigh[SRS_ENTRIES]
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:769
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
enum ns3::LteRrcSap::ReportConfigEutra::@73 purpose
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:441
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)
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
LteRlcSapProvider * GetLteRlcSapProvider()
Definition: lte-rlc.cc:146
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:64
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...
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:964
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:362
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:920
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:610
uint8_t Bid2Drbid(uint8_t bid)
static TypeId GetTypeId(void)
Definition: lte-rlc-am.cc:86
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 SetLteMacSapProvider(LteMacSapProvider *s)
Definition: lte-rlc.cc:153
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:560
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:761
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:148
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
void DoRecvHandoverRequestAck(EpcX2SapUser::HandoverRequestAckParams params)
ThresholdEutra threshold2
Threshold for event A5.
Definition: lte-rrc-sap.h:277
void DoRecvHandoverRequest(EpcX2SapUser::HandoverRequestParams params)