23 #include "ns3/fatal-error.h"
25 #include "ns3/abort.h"
26 #include "ns3/pointer.h"
27 #include "ns3/object-map.h"
28 #include "ns3/object-factory.h"
29 #include "ns3/simulator.h"
46 #include <ns3/simulator.h>
100 "INITIAL_RANDOM_ACCESS",
102 "CONNECTION_REJECTED",
103 "CONNECTED_NORMALLY",
104 "CONNECTION_RECONFIGURATION",
105 "CONNECTION_REESTABLISHMENT",
106 "HANDOVER_PREPARATION",
108 "HANDOVER_PATH_SWITCH",
134 : m_lastAllocatedDrbid (0),
137 m_lastRrcTransactionIdentifier (0),
140 m_pendingRrcConnectionReconfiguration (false),
143 m_needTransmissionModeConfiguration (false)
168 Ptr<LteRlc> rlc = CreateObject<LteRlcTm> ()->GetObject<LteRlc> ();
173 m_srb0 = CreateObject<LteSignalingRadioBearerInfo> ();
190 Ptr<LteRlc> rlc = CreateObject<LteRlcAm> ()->GetObject<LteRlc> ();
202 m_srb1 = CreateObject<LteSignalingRadioBearerInfo> ();
240 Time maxConnectionDelay;
291 .AddConstructor<UeManager> ()
292 .AddAttribute (
"DataRadioBearerMap",
"List of UE DataRadioBearerInfo by DRBID.",
295 MakeObjectMapChecker<LteDataRadioBearerInfo> ())
296 .AddAttribute (
"Srb0",
"SignalingRadioBearerInfo for SRB0",
299 MakePointerChecker<LteSignalingRadioBearerInfo> ())
300 .AddAttribute (
"Srb1",
"SignalingRadioBearerInfo for SRB1",
303 MakePointerChecker<LteSignalingRadioBearerInfo> ())
304 .AddAttribute (
"C-RNTI",
305 "Cell Radio Network Temporary Identifier",
309 MakeUintegerChecker<uint16_t> ())
310 .AddTraceSource (
"StateTransition",
311 "fired upon every UE state transition seen by the UeManager at the eNB RRC",
339 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");
351 x2uTeidInfo.
drbid = drbid;
352 std::pair<std::map<uint32_t, LteEnbRrc::X2uTeidInfo>::iterator,
bool>
353 ret =
m_rrc->
m_x2uTeidInfoMap.insert (std::pair<uint32_t, LteEnbRrc::X2uTeidInfo> (gtpTeid, x2uTeidInfo));
354 NS_ASSERT_MSG (ret.second ==
true,
"overwriting a pre-existing entry in m_x2uTeidInfoMap");
365 drbInfo->
m_rlc = rlc;
439 std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbIt =
m_drbMap.find (*drbIdIt);
441 drbIt->second->m_rlc->Initialize ();
442 if (drbIt->second->m_pdcp)
444 drbIt->second->m_pdcp->Initialize ();
456 std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it =
m_drbMap.find (drbid);
457 NS_ASSERT_MSG (it !=
m_drbMap.end (),
"request to remove radio bearer with unknown drbid " << drbid);
600 if (0 != drbIt->second->m_rlc->GetObject<
LteRlcAm> ())
646 NS_LOG_LOGIC (
"queueing data on PDCP for transmission over the air");
659 NS_LOG_LOGIC (
"forwarding data to target eNB over X2-U");
676 std::vector<EpcX2Sap::ErabToBeSetupItem>
680 std::vector<EpcX2Sap::ErabToBeSetupItem> ret;
686 etbsi.
erabId = it->second->m_epsBearerIdentity;
690 etbsi.
gtpTeid = it->second->m_gtpTeid;
691 ret.push_back (etbsi);
703 NS_LOG_INFO (
"Send UE CONTEXT RELEASE from target eNB to source eNB");
727 NS_LOG_INFO (
"target eNB sent HO preparation failure, aborting HO");
741 for (std::vector<EpcX2Sap::ErabsSubjectToStatusTransferItem>::iterator erabIt
869 NS_LOG_INFO (
"Send PATH SWITCH REQUEST to the MME");
881 b.
teid = it->second->m_gtpTeid;
942 <<
" RSRP " << (it->haveRsrpResult ? (uint16_t) it->rsrpResult : 255)
943 <<
" RSRQ " << (it->haveRsrqResult ? (uint16_t) it->rsrqResult : 255));
950 "Measure identity is unknown");
965 uint8_t bestNeighbourRsrq = 0;
971 if (it->second->m_rsrq > bestNeighbourRsrq)
974 if ((neighbourRelation->
m_noHo ==
false) &&
975 (neighbourRelation->
m_noX2 ==
false))
977 bestNeighbour = it->second;
978 bestNeighbourRsrq = it->second->
m_rsrq;
986 uint16_t targetCellId = bestNeighbour->
m_cellId;
987 NS_LOG_LOGIC (
"Best neighbour cellId " << targetCellId);
991 NS_LOG_LOGIC (
"Trigger Handover to cellId " << targetCellId);
1010 NS_ASSERT_MSG (it->haveRsrqResult ==
true,
"RSRQ measure missing for cellId " << it->physCellId);
1020 if (neighbourRelation->
m_noX2 ==
false)
1022 neighbourRelation->
m_noHo =
false;
1031 neighbourRelation->
m_noHo =
true;
1032 neighbourRelation->
m_noX2 =
true;
1042 neighbourCellMeasures->
m_cellId = it->physCellId;
1043 neighbourCellMeasures->
m_rsrq = it->rsrqResult;
1044 neighbourCellMeasures->
m_rsrp = 0;
1048 neighbourCellMeasures = CreateObject <UeMeasure> ();
1049 neighbourCellMeasures->
m_cellId = it->physCellId;
1050 neighbourCellMeasures->
m_rsrq = it->rsrqResult;
1051 neighbourCellMeasures->
m_rsrp = 0;
1089 if (params.
lcid > 2)
1148 const uint8_t MAX_DRB_ID = 32;
1151 drbid = (drbid + 1) % MAX_DRB_ID)
1173 std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it =
m_drbMap.find (drbid);
1183 std::map <uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it =
m_drbMap.find (drbid);
1184 NS_ASSERT_MSG (it !=
m_drbMap.end (),
"request to remove radio bearer with unknown drbid " << drbid);
1290 dtam.
rlcConfig = it->second->m_rlcConfig;
1396 : m_x2SapProvider (0),
1397 m_cmacSapProvider (0),
1399 m_macSapProvider (0),
1400 m_s1SapProvider (0),
1401 m_cphySapProvider (0),
1402 m_configured (false),
1403 m_lastAllocatedRnti (0),
1404 m_srsCurrentPeriodicityId (0),
1405 m_lastAllocatedConfigurationIndex (0),
1406 m_reconfigureUes (false)
1443 .AddConstructor<LteEnbRrc> ()
1444 .AddAttribute (
"UeMap",
"List of UeManager by C-RNTI.",
1447 MakeObjectMapChecker<UeManager> ())
1448 .AddAttribute (
"DefaultTransmissionMode",
1449 "The default UEs' transmission mode (0: SISO)",
1452 MakeUintegerChecker<uint8_t> ())
1453 .AddAttribute (
"EpsBearerToRlcMapping",
1454 "Specify which type of RLC will be used for each type of EPS bearer. ",
1461 .AddAttribute (
"SystemInformationPeriodicity",
1462 "The interval for sending system information (Time value)",
1466 .AddAttribute (
"SrsPeriodicity",
1467 "The SRS periodicity in milliseconds",
1471 MakeUintegerChecker<uint32_t> ())
1472 .AddAttribute (
"ConnectionTimeoutDuration",
1473 "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.",
1477 .AddAttribute (
"ConnectionRejectedTimeoutDuration",
1478 "Time to wait between sending a RRC CONNECTION REJECT and destroying the UE context",
1482 .AddAttribute (
"HandoverJoiningTimeoutDuration",
1483 "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.",
1487 .AddAttribute (
"HandoverLeavingTimeoutDuration",
1488 "After issuing a Handover Command, if neither RRC Connection Reestablishment nor X2 UE Context Release has been previously received, the UE context is destroyed.",
1492 .AddAttribute (
"AdmitHandoverRequest",
1493 "Whether to admit an X2 handover request from another eNB",
1496 MakeBooleanChecker ())
1497 .AddAttribute (
"AdmitRrcConnectionRequest",
1498 "Whether to admit a connection request from a Ue",
1501 MakeBooleanChecker ())
1502 .AddAttribute (
"EventA2Threshold",
1503 "Threshold of the event A2 (Serving becomes worse than threshold)",
1506 MakeUintegerChecker<uint8_t> ())
1507 .AddAttribute (
"EventA4Threshold",
1508 "Threshold of the event A4 (Neighbour becomes better than threshold)",
1511 MakeUintegerChecker<uint8_t> ())
1512 .AddAttribute (
"ServingCellHandoverThreshold",
1513 "If serving cell is worse than this threshold, neighbour cells are consider for Handover",
1516 MakeUintegerChecker<uint8_t> ())
1517 .AddAttribute (
"NeighbourCellHandoverOffset",
1518 "Minimum offset between serving and best neighbour cell to trigger the Handover",
1521 MakeUintegerChecker<uint8_t> ())
1522 .AddTraceSource (
"NewUeContext",
1523 "trace fired upon creation of a new UE context",
1525 .AddTraceSource (
"ConnectionEstablished",
1526 "trace fired upon successful RRC connection establishment",
1528 .AddTraceSource (
"ConnectionReconfiguration",
1529 "trace fired upon RRC connection reconfiguration",
1531 .AddTraceSource (
"HandoverStart",
1532 "trace fired upon start of a handover procedure",
1534 .AddTraceSource (
"HandoverEndOk",
1535 "trace fired upon successful termination of a handover procedure",
1537 .AddTraceSource (
"RecvMeasurementReport",
1538 "trace fired when measurement report is received",
1625 std::map<uint16_t, Ptr<UeManager> >::iterator it =
m_ueMap.find (rnti);
1667 NS_ASSERT_MSG (found,
"no EpsBearerTag found in packet to be sent");
1821 if (anrcrv.
valid ==
false)
1823 NS_LOG_INFO (
this <<
"failed to allocate a preamble for non-contention based RA => cannot accept HO");
1825 NS_FATAL_ERROR (
"should trigger HO Preparation Failure, but it is not implemented");
1839 for (std::vector <EpcX2Sap::ErabToBeSetupItem>::iterator it = req.
bearers.begin ();
1843 ueManager->
SetupDataRadioBearer (it->erabLevelQosParameters, it->erabId, it->gtpTeid, it->transportLayerAddress);
1870 ackParams.
rrcContext = encodedHandoverCommand;
1872 NS_LOG_LOGIC (
"Send X2 message: HANDOVER REQUEST ACK");
1887 NS_LOG_LOGIC (
"Recv X2 message: HANDOVER REQUEST ACK");
1904 NS_LOG_LOGIC (
"Recv X2 message: HANDOVER PREPARATION FAILURE");
1957 NS_ASSERT (
"Processing of LOAD INFORMATION X2 message IS NOT IMPLEMENTED");
1965 NS_LOG_LOGIC (
"Recv X2 message: RESOURCE STATUS UPDATE");
1969 NS_ASSERT (
"Processing of RESOURCE STATUS UPDATE X2 message IS NOT IMPLEMENTED");
1977 NS_LOG_LOGIC (
"Recv UE DATA FORWARDING through X2 interface");
1984 std::map<uint32_t, X2uTeidInfo>::iterator
2037 NS_ASSERT_MSG (found,
"no more RNTIs available (do you have more than 65535 UEs in a cell?)");
2039 Ptr<UeManager> ueManager = CreateObject<UeManager> (
this, rnti, state);
2051 std::map <uint16_t, Ptr<UeManager> >::iterator it =
m_ueMap.find (rnti);
2053 uint16_t srsCi = (*it).second->GetSrsConfigurationIndex ();
2105 "There is already an entry in the Neighbour Relation Table for cellId " << cellId);
2109 neighbourRelation->m_noRemove =
true;
2110 neighbourRelation->m_noHo =
true;
2111 neighbourRelation->m_noX2 =
false;
2112 neighbourRelation->m_detectedAsNeighbour =
false;
2136 std::ostringstream allowedValues;
2141 NS_FATAL_ERROR (
"illecit SRS periodicity value " << p <<
". Allowed values: " << allowedValues.str ());
2165 <<
") for current SRS periodicity "
2167 <<
", consider increasing the value of ns3::LteEnbRrc::SrsPeriodicity");
2182 if ((*rit) <
g_srsCiHigh[m_srsCurrentPeriodicityId])
2220 if (bearer.
IsGbr ())