15#include "nr-gnb-rrc.h"
17#include "bandwidth-part-gnb.h"
19#include "nr-eps-bearer-tag.h"
21#include "nr-radio-bearer-info.h"
28#include <ns3/fatal-error.h>
30#include <ns3/object-factory.h>
31#include <ns3/object-map.h>
32#include <ns3/packet.h>
33#include <ns3/pointer.h>
34#include <ns3/simulator.h>
39NS_LOG_COMPONENT_DEFINE(
"NrGnbRrc");
48class GnbRrcMemberNrGnbCmacSapUser :
public NrGnbCmacSapUser
57 GnbRrcMemberNrGnbCmacSapUser(NrGnbRrc* rrc, uint8_t componentCarrierId);
59 uint16_t AllocateTemporaryCellRnti()
override;
60 void NotifyLcConfigResult(uint16_t rnti, uint8_t lcid,
bool success)
override;
61 void RrcConfigurationUpdateInd(UeConfig params)
override;
62 bool IsRandomAccessCompleted(uint16_t rnti)
override;
66 uint8_t m_componentCarrierId;
69GnbRrcMemberNrGnbCmacSapUser::GnbRrcMemberNrGnbCmacSapUser(NrGnbRrc* rrc,
70 uint8_t componentCarrierId)
72 m_componentCarrierId{componentCarrierId}
77GnbRrcMemberNrGnbCmacSapUser::AllocateTemporaryCellRnti()
79 return m_rrc->DoAllocateTemporaryCellRnti(m_componentCarrierId);
83GnbRrcMemberNrGnbCmacSapUser::NotifyLcConfigResult(uint16_t rnti, uint8_t lcid,
bool success)
85 m_rrc->DoNotifyLcConfigResult(rnti, lcid, success);
89GnbRrcMemberNrGnbCmacSapUser::RrcConfigurationUpdateInd(UeConfig params)
91 m_rrc->DoRrcConfigurationUpdateInd(params);
95GnbRrcMemberNrGnbCmacSapUser::IsRandomAccessCompleted(uint16_t rnti)
97 return m_rrc->IsRandomAccessCompleted(rnti);
105static const std::string g_ueManagerStateName[NrUeManager::NUM_STATES] = {
106 "INITIAL_RANDOM_ACCESS",
108 "CONNECTION_REJECTED",
110 "CONNECTED_NORMALLY",
111 "CONNECTION_RECONFIGURATION",
112 "CONNECTION_REESTABLISHMENT",
113 "HANDOVER_PREPARATION",
115 "HANDOVER_PATH_SWITCH",
123static const std::string&
124ToString(NrUeManager::State s)
126 return g_ueManagerStateName[s];
129NS_OBJECT_ENSURE_REGISTERED(NrUeManager);
131NrUeManager::NrUeManager()
133 NS_FATAL_ERROR(
"this constructor is not expected to be used");
136NrUeManager::NrUeManager(Ptr<NrGnbRrc> rrc, uint16_t rnti,
State s, uint8_t componentCarrierId)
137 : m_lastAllocatedDrbid(0),
140 m_componentCarrierId(componentCarrierId),
141 m_lastRrcTransactionIdentifier(0),
144 m_pendingRrcConnectionReconfiguration(false),
147 m_needPhyMacConfiguration(false),
148 m_caSupportConfigured(false),
149 m_pendingStartDataRadioBearers(false)
151 NS_LOG_FUNCTION(
this);
157 NS_LOG_FUNCTION(
this);
167 NS_LOG_FUNCTION(
this);
174 m_rrc->GetNewSrsConfigurationIndex();
176 NrRrcSap::SoundingRsUlConfigDedicated::SETUP;
181 for (uint16_t i = 0; i < m_rrc->m_numberOfComponentCarriers; i++)
183 m_rrc->m_cmacSapProvider.at(i)->AddUe(m_rnti);
184 m_rrc->m_cphySapProvider.at(i)->AddUe(m_rnti);
191 NS_LOG_FUNCTION(
this);
196 Ptr<NrRlc> rlc = CreateObject<NrRlcTm>()->GetObject<
NrRlc>();
198 rlc->SetRnti(m_rnti);
201 m_srb0 = CreateObject<NrSignalingRadioBearerInfo>();
203 m_srb0->m_srbIdentity = 0;
207 lcinfo.
rnti = m_rnti;
222 m_rrc->m_ccmRrcSapProvider->ConfigureSignalBearer(lcinfo, rlc->GetNrMacSapUser());
224 m_rrc->m_cmacSapProvider.at(m_componentCarrierId)->AddLc(lcinfo, nrMacSapUser);
225 m_rrc->m_ccmRrcSapProvider->AddLc(lcinfo, nrMacSapUser);
232 NS_LOG_FUNCTION(
this);
237 Ptr<NrRlc> rlc = CreateObject<NrRlcAm>()->GetObject<
NrRlc>();
239 rlc->SetRnti(m_rnti);
242 Ptr<NrPdcp> pdcp = CreateObject<NrPdcp>();
243 pdcp->SetRnti(m_rnti);
245 pdcp->SetNrPdcpSapUser(m_drbPdcpSapUser);
246 pdcp->SetNrRlcSapProvider(rlc->GetNrRlcSapProvider());
247 rlc->SetNrRlcSapUser(pdcp->GetNrRlcSapUser());
249 m_srb1 = CreateObject<NrSignalingRadioBearerInfo>();
251 m_srb1->m_pdcp = pdcp;
252 m_srb1->m_srbIdentity = 1;
253 m_srb1->m_logicalChannelConfig.priority = 1;
254 m_srb1->m_logicalChannelConfig.prioritizedBitRateKbps = 100;
255 m_srb1->m_logicalChannelConfig.bucketSizeDurationMs = 100;
256 m_srb1->m_logicalChannelConfig.logicalChannelGroup = 0;
259 lcinfo.
rnti = m_rnti;
271 m_rrc->m_ccmRrcSapProvider->ConfigureSignalBearer(lcinfo, rlc->GetNrMacSapUser());
273 m_rrc->m_cmacSapProvider.at(m_componentCarrierId)->AddLc(lcinfo, MacSapUserForRlc);
274 m_rrc->m_ccmRrcSapProvider->AddLc(lcinfo, MacSapUserForRlc);
280 m_rrc->m_rrcSapUser->SetupUe(m_rnti, ueParams);
286 NS_LOG_FUNCTION(
this);
293 for (uint16_t i = 0; i < m_rrc->m_numberOfComponentCarriers; i++)
295 m_rrc->m_cmacSapProvider.at(i)->UeUpdateConfigurationReq(req);
296 m_rrc->m_cphySapProvider.at(i)->SetTransmissionMode(
299 m_rrc->m_cphySapProvider.at(i)->SetSrsConfigurationIndex(
305 Time maxConnectionDelay;
308 case INITIAL_RANDOM_ACCESS:
309 m_connectionRequestTimeout = Simulator::Schedule(m_rrc->m_connectionRequestTimeoutDuration,
315 case HANDOVER_JOINING:
316 m_handoverJoiningTimeout = Simulator::Schedule(m_rrc->m_handoverJoiningTimeoutDuration,
323 NS_FATAL_ERROR(
"unexpected state " << ToString(m_state));
326 m_caSupportConfigured =
false;
329NrUeManager::~NrUeManager()
334NrUeManager::DoDispose()
336 delete m_drbPdcpSapUser;
338 for (
auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it)
340 m_rrc->m_x2uTeidInfoMap.erase(it->second->m_gtpTeid);
348 TypeId(
"ns3::NrUeManager")
350 .AddConstructor<NrUeManager>()
351 .AddAttribute(
"DataRadioBearerMap",
352 "List of UE DataRadioBearerInfo by DRBID.",
354 MakeObjectMapAccessor(&NrUeManager::m_drbMap),
355 MakeObjectMapChecker<NrDataRadioBearerInfo>())
356 .AddAttribute(
"Srb0",
357 "SignalingRadioBearerInfo for SRB0",
359 MakePointerAccessor(&NrUeManager::m_srb0),
360 MakePointerChecker<NrSignalingRadioBearerInfo>())
361 .AddAttribute(
"Srb1",
362 "SignalingRadioBearerInfo for SRB1",
364 MakePointerAccessor(&NrUeManager::m_srb1),
365 MakePointerChecker<NrSignalingRadioBearerInfo>())
366 .AddAttribute(
"C-RNTI",
367 "Cell Radio Network Temporary Identifier",
370 MakeUintegerAccessor(&NrUeManager::m_rnti),
371 MakeUintegerChecker<uint16_t>())
372 .AddTraceSource(
"StateTransition",
373 "fired upon every UE state transition seen by the "
374 "NrUeManager at the gNB RRC",
375 MakeTraceSourceAccessor(&NrUeManager::m_stateTransitionTrace),
376 "ns3::NrUeManager::StateTracedCallback")
377 .AddTraceSource(
"DrbCreated",
378 "trace fired after DRB is created",
379 MakeTraceSourceAccessor(&NrUeManager::m_drbCreatedTrace),
380 "ns3::NrUeManager::ImsiCidRntiLcIdTracedCallback");
387 m_sourceX2apId = sourceX2apId;
388 m_sourceCellId = sourceCellId;
400 NS_LOG_FUNCTION(
this << m_rnti);
402 if (m_state == ATTACH_REQUEST)
404 SwitchToState(CONNECTED_NORMALLY);
408 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
416 Ipv4Address transportLayerAddress)
418 NS_LOG_FUNCTION(
this << (uint32_t)m_rnti);
420 Ptr<NrDataRadioBearerInfo> drbInfo = CreateObject<NrDataRadioBearerInfo>();
421 uint8_t drbid = AddDataRadioBearerInfo(drbInfo);
422 uint8_t lcid = Drbid2Lcid(drbid);
423 uint8_t bid = Drbid2Bid(drbid);
424 NS_ASSERT_MSG(bearerId == 0 || bid == bearerId,
425 "bearer ID mismatch (" << (uint32_t)bid <<
" != " << (uint32_t)bearerId
426 <<
", the assumption that ID are allocated in the same "
427 "way by MME and RRC is not valid any more");
428 drbInfo->m_epsBearer = bearer;
429 drbInfo->m_epsBearerIdentity = bid;
430 drbInfo->m_drbIdentity = drbid;
431 drbInfo->m_logicalChannelIdentity = lcid;
432 drbInfo->m_gtpTeid = gtpTeid;
433 drbInfo->m_transportLayerAddress = transportLayerAddress;
435 if (m_state == HANDOVER_JOINING)
438 NrGnbRrc::X2uTeidInfo x2uTeidInfo;
439 x2uTeidInfo.rnti = m_rnti;
440 x2uTeidInfo.drbid = drbid;
441 auto ret = m_rrc->m_x2uTeidInfoMap.insert(
442 std::pair<uint32_t, NrGnbRrc::X2uTeidInfo>(gtpTeid, x2uTeidInfo));
443 NS_ASSERT_MSG(ret.second ==
true,
"overwriting a pre-existing entry in m_x2uTeidInfoMap");
446 TypeId rlcTypeId = m_rrc->GetRlcType(bearer);
448 ObjectFactory rlcObjectFactory;
449 rlcObjectFactory.SetTypeId(rlcTypeId);
450 Ptr<NrRlc> rlc = rlcObjectFactory.Create()->GetObject<
NrRlc>();
452 rlc->SetRnti(m_rnti);
458 Simulator::ScheduleNow(&NrRlcSm::Initialize, rlc);
461 drbInfo->m_rlc = rlc;
469 Ptr<NrPdcp> pdcp = CreateObject<NrPdcp>();
470 pdcp->SetRnti(m_rnti);
472 pdcp->SetNrPdcpSapUser(m_drbPdcpSapUser);
473 pdcp->SetNrRlcSapProvider(rlc->GetNrRlcSapProvider());
474 rlc->SetNrRlcSapUser(pdcp->GetNrRlcSapUser());
475 drbInfo->m_pdcp = pdcp;
478 m_drbCreatedTrace(m_imsi, m_rrc->ComponentCarrierToCellId(m_componentCarrierId), m_rnti, lcid);
480 std::vector<NrCcmRrcSapProvider::LcsConfig> lcOnCcMapping =
481 m_rrc->m_ccmRrcSapProvider->SetupDataRadioBearer(bearer,
485 m_rrc->GetLogicalChannelGroup(bearer),
486 rlc->GetNrMacSapUser());
499 auto itLcOnCcMapping = lcOnCcMapping.begin();
500 NS_ASSERT_MSG(itLcOnCcMapping != lcOnCcMapping.end(),
"Problem");
501 for (itLcOnCcMapping = lcOnCcMapping.begin(); itLcOnCcMapping != lcOnCcMapping.end();
504 NS_LOG_DEBUG(
this <<
" RNTI " << itLcOnCcMapping->lc.rnti <<
"Lcid "
505 << (uint16_t)itLcOnCcMapping->lc.lcId <<
" lcGroup "
506 << (uint16_t)itLcOnCcMapping->lc.lcGroup <<
" ComponentCarrierId "
507 << itLcOnCcMapping->componentCarrierId);
508 uint8_t index = itLcOnCcMapping->componentCarrierId;
511 m_rrc->m_cmacSapProvider.at(index)->AddLc(lcinfo, msu);
512 m_rrc->m_ccmRrcSapProvider->AddLc(lcinfo, msu);
517 drbInfo->m_rlcConfig.choice = NrRrcSap::RlcConfig::AM;
521 drbInfo->m_rlcConfig.choice = NrRrcSap::RlcConfig::UM_BI_DIRECTIONAL;
524 drbInfo->m_logicalChannelIdentity = lcid;
525 drbInfo->m_logicalChannelConfig.priority = m_rrc->GetLogicalChannelPriority(bearer);
526 drbInfo->m_logicalChannelConfig.logicalChannelGroup = m_rrc->GetLogicalChannelGroup(bearer);
529 drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = bearer.
gbrQosInfo.
gbrUl;
533 drbInfo->m_logicalChannelConfig.prioritizedBitRateKbps = 0;
535 drbInfo->m_logicalChannelConfig.bucketSizeDurationMs = 1000;
543 NS_LOG_FUNCTION(
this << (uint32_t)m_rnti);
544 for (
auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it)
546 m_drbsToBeStarted.push_back(it->first);
553 NS_LOG_FUNCTION(
this << (uint32_t)m_rnti);
554 for (
auto drbIdIt = m_drbsToBeStarted.begin(); drbIdIt != m_drbsToBeStarted.end(); ++drbIdIt)
556 auto drbIt = m_drbMap.find(*drbIdIt);
557 NS_ASSERT(drbIt != m_drbMap.end());
559 m_drbsToBeStarted.clear();
565 NS_LOG_FUNCTION(
this << (uint32_t)m_rnti << (uint32_t)drbid);
566 uint8_t lcid = Drbid2Lcid(drbid);
567 auto it = m_drbMap.find(drbid);
568 NS_ASSERT_MSG(it != m_drbMap.end(),
569 "request to remove radio bearer with unknown drbid " << drbid);
572 m_rrc->m_x2uTeidInfoMap.erase(it->second->m_gtpTeid);
575 std::vector<uint8_t> ccToRelease =
576 m_rrc->m_ccmRrcSapProvider->ReleaseDataRadioBearer(m_rnti, lcid);
577 auto itCcToRelease = ccToRelease.begin();
578 NS_ASSERT_MSG(itCcToRelease != ccToRelease.end(),
579 "request to remove radio bearer with unknown drbid (ComponentCarrierManager)");
580 for (itCcToRelease = ccToRelease.begin(); itCcToRelease != ccToRelease.end(); ++itCcToRelease)
582 m_rrc->m_cmacSapProvider.at(*itCcToRelease)->ReleaseLc(m_rnti, lcid);
595 msg.haveMobilityControlInfo =
false;
596 msg.radioResourceConfigDedicated = rrcd;
597 msg.haveRadioResourceConfigDedicated =
true;
600 msg.haveNonCriticalExtension =
false;
602 m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration(m_rnti, msg);
608 NS_LOG_FUNCTION(
this << imsi << rnti << (uint16_t)bearerId);
615 ueManager->ReleaseDataRadioBearer(bearerId);
624 NS_LOG_FUNCTION(
this << m_rnti);
627 if (m_rrc->m_s1SapProvider !=
nullptr)
629 for (
const auto& it : m_drbMap)
631 NS_LOG_DEBUG(
"Sending release of bearer id : "
632 << (uint16_t)(it.first)
633 <<
"LCID : " << (uint16_t)(it.second->m_logicalChannelIdentity));
635 m_rrc->m_s1SapProvider->DoSendReleaseIndication(
GetImsi(), rnti, it.first);
643 NS_LOG_FUNCTION(
this);
646 case INITIAL_RANDOM_ACCESS:
647 case CONNECTION_SETUP:
649 case CONNECTION_RECONFIGURATION:
650 case CONNECTION_REESTABLISHMENT:
651 case HANDOVER_PREPARATION:
652 case HANDOVER_JOINING:
653 case HANDOVER_LEAVING:
655 m_pendingRrcConnectionReconfiguration =
true;
658 case CONNECTED_NORMALLY: {
659 m_pendingRrcConnectionReconfiguration =
false;
661 m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration(m_rnti, msg);
663 SwitchToState(CONNECTION_RECONFIGURATION);
668 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
676 NS_LOG_FUNCTION(
this << cellId);
679 case CONNECTED_NORMALLY: {
680 m_targetCellId = cellId;
682 auto sourceComponentCarrier = DynamicCast<BandwidthPartGnb>(
683 m_rrc->m_componentCarrierPhyConf.at(m_componentCarrierId));
684 NS_ASSERT(m_targetCellId != sourceComponentCarrier->GetCellId());
686 if (m_rrc->HasCellId(cellId))
689 NS_LOG_DEBUG(
"Intra-gNB handover for cellId " << cellId);
690 uint8_t componentCarrierId = m_rrc->CellToComponentCarrierId(cellId);
691 uint16_t rnti = m_rrc->AddUe(NrUeManager::HANDOVER_JOINING, componentCarrierId);
693 m_rrc->m_cmacSapProvider.at(componentCarrierId)->AllocateNcRaPreamble(rnti);
696 NS_LOG_INFO(
this <<
" failed to allocate a preamble for non-contention based RA => "
697 "cannot perform HO");
698 NS_FATAL_ERROR(
"should trigger HO Preparation Failure, but it is not implemented");
702 Ptr<NrUeManager> ueManager = m_rrc->GetUeManager(rnti);
703 ueManager->SetSource(sourceComponentCarrier->GetCellId(), m_rnti);
704 ueManager->SetImsi(m_imsi);
707 for (
auto& it : m_drbMap)
709 ueManager->SetupDataRadioBearer(it.second->m_epsBearer,
710 it.second->m_epsBearerIdentity,
711 it.second->m_gtpTeid,
712 it.second->m_transportLayerAddress);
726 m_rrc->m_cmacSapProvider.at(componentCarrierId)->GetRachConfig();
734 m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration(m_rnti, handoverCommand);
737 SwitchToState(HANDOVER_LEAVING);
738 m_handoverLeavingTimeout = Simulator::Schedule(m_rrc->m_handoverLeavingTimeoutDuration,
742 m_rrc->m_handoverStartTrace(m_imsi,
743 sourceComponentCarrier->GetCellId(),
750 NS_LOG_DEBUG(
"Inter-gNB handover (i.e., X2) for cellId " << cellId);
753 params.
cause = NrEpcX2SapProvider::HandoverDesirableForRadioReason;
754 params.
sourceCellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId);
768 sourceComponentCarrier->GetDlBandwidth();
772 .cellAccessRelatedInfo.plmnIdentityInfo.plmnIdentity;
774 m_rrc->ComponentCarrierToCellId(m_componentCarrierId);
776 m_rrc->m_sib1.at(m_componentCarrierId).cellAccessRelatedInfo.csgIndication;
778 m_rrc->m_sib1.at(m_componentCarrierId).cellAccessRelatedInfo.csgIdentity;
780 m_rrc->m_cmacSapProvider.at(m_componentCarrierId)->GetRachConfig();
790 sourceComponentCarrier->GetUlEarfcn();
792 sourceComponentCarrier->GetUlBandwidth();
793 params.
rrcContext = m_rrc->m_rrcSapUser->EncodeHandoverPreparationInformation(hpi);
798 NS_LOG_LOGIC(
"mmeUeS1apId = " << params.
mmeUeS1apId);
799 NS_LOG_LOGIC(
"rrcContext = " << params.
rrcContext);
801 m_rrc->m_x2SapProvider->SendHandoverRequest(params);
802 SwitchToState(HANDOVER_PREPARATION);
808 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
816 NS_LOG_FUNCTION(
this);
819 "not admission of some bearers upon handover is not supported");
821 "not enough bearers in admittedBearers");
829 Ptr<Packet> encodedHandoverCommand = params.
rrcContext;
831 m_rrc->m_rrcSapUser->DecodeHandoverCommand(encodedHandoverCommand);
837 m_rrc->m_numberOfComponentCarriers)
841 NS_FATAL_ERROR(
"The source and target eNBs have unequal number of component carriers. "
844 <<
" Source gNB CCs = " << m_rrc->m_numberOfComponentCarriers);
847 m_rrc->m_rrcSapUser->SendRrcConnectionReconfiguration(m_rnti, handoverCommand);
848 SwitchToState(HANDOVER_LEAVING);
849 m_handoverLeavingTimeout = Simulator::Schedule(m_rrc->m_handoverLeavingTimeoutDuration,
854 m_rrc->m_handoverStartTrace(m_imsi,
855 m_rrc->ComponentCarrierToCellId(m_componentCarrierId),
868 for (
auto drbIt = m_drbMap.begin(); drbIt != m_drbMap.end(); ++drbIt)
871 if (drbIt->second->m_rlc->GetObject<
NrRlcAm>())
880 m_rrc->m_x2SapProvider->SendSnStatusTransfer(sst);
886 NS_LOG_FUNCTION(
this);
887 return BuildRadioResourceConfigDedicated();
893 NS_LOG_FUNCTION(
this);
897 auto targetComponentCarrier = m_rrc->m_componentCarrierPhyConf.at(componentCarrierId);
905 targetComponentCarrier->GetDlBandwidth();
907 targetComponentCarrier->GetUlBandwidth();
909 if (m_caSupportConfigured && m_rrc->m_numberOfComponentCarriers > 1)
914 for (
auto& it : m_rrc->m_componentCarrierPhyConf)
916 uint8_t ccId = it.first;
918 if (ccId == m_componentCarrierId)
923 else if (ccId < m_componentCarrierId)
939NrUeManager::SendPacket(uint8_t bid, Ptr<Packet> p)
941 NS_LOG_FUNCTION(
this << p << (uint16_t)bid);
944 params.
rnti = m_rnti;
945 params.
lcid = Bid2Lcid(bid);
946 uint8_t drbid = Bid2Drbid(bid);
948 auto it = m_drbMap.find(drbid);
949 if (it != m_drbMap.end())
951 Ptr<NrDataRadioBearerInfo> bearerInfo = GetDataRadioBearerInfo(drbid);
954 NS_LOG_INFO(
"Send packet to PDCP layer");
964 NS_LOG_FUNCTION(
this << p << (uint16_t)bid);
967 case INITIAL_RANDOM_ACCESS:
968 case CONNECTION_SETUP:
969 NS_LOG_WARN(
"not connected, discarding packet");
972 case CONNECTED_NORMALLY:
973 case CONNECTION_RECONFIGURATION:
974 case CONNECTION_REESTABLISHMENT:
975 case HANDOVER_PREPARATION:
976 case HANDOVER_PATH_SWITCH: {
977 NS_LOG_INFO(
"queueing data on PDCP for transmission over the air");
982 case HANDOVER_JOINING: {
984 NS_LOG_INFO(
"buffering data");
985 m_packetBuffer.emplace_back(bid, p);
989 case HANDOVER_LEAVING: {
990 NS_LOG_INFO(
"forwarding data to target gNB over X2-U");
991 uint8_t drbid = Bid2Drbid(bid);
993 params.
sourceCellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId);
995 params.
gtpTeid = GetDataRadioBearerInfo(drbid)->m_gtpTeid;
997 m_rrc->m_x2SapProvider->SendUeData(params);
1002 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1007std::vector<NrEpcX2Sap::ErabToBeSetupItem>
1010 NS_LOG_FUNCTION(
this);
1011 std::vector<NrEpcX2Sap::ErabToBeSetupItem> ret;
1012 for (
auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it)
1015 etbsi.
erabId = it->second->m_epsBearerIdentity;
1019 etbsi.
gtpTeid = it->second->m_gtpTeid;
1020 ret.push_back(etbsi);
1028 NS_LOG_FUNCTION(
this);
1031 case HANDOVER_PATH_SWITCH:
1032 NS_LOG_INFO(
"Send UE CONTEXT RELEASE from target gNB to source gNB");
1038 if (!m_rrc->HasCellId(m_sourceCellId))
1040 m_rrc->m_x2SapProvider->SendUeContextRelease(ueCtxReleaseParams);
1044 NS_LOG_INFO(
"Not sending UE CONTEXT RELEASE because handover is internal");
1045 m_rrc->DoRecvUeContextRelease(ueCtxReleaseParams);
1047 SwitchToState(CONNECTED_NORMALLY);
1048 m_rrc->m_handoverEndOkTrace(m_imsi,
1049 m_rrc->ComponentCarrierToCellId(m_componentCarrierId),
1054 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1062 NS_LOG_FUNCTION(
this << cellId);
1065 case HANDOVER_PREPARATION:
1066 NS_ASSERT(cellId == m_targetCellId);
1067 NS_LOG_INFO(
"target gNB sent HO preparation failure, aborting HO");
1068 SwitchToState(CONNECTED_NORMALLY);
1070 case HANDOVER_LEAVING:
1071 NS_ASSERT(cellId == m_targetCellId);
1072 NS_LOG_INFO(
"target gNB sent HO preparation failure, aborting HO");
1073 m_handoverLeavingTimeout.Cancel();
1078 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1086 NS_LOG_FUNCTION(
this);
1092 status.
txSn = erabIt->dlPdcpSn;
1093 status.
rxSn = erabIt->ulPdcpSn;
1094 uint8_t drbId = Bid2Drbid(erabIt->erabId);
1095 auto drbIt = m_drbMap.find(drbId);
1096 NS_ASSERT_MSG(drbIt != m_drbMap.end(),
"could not find DRBID " << (uint32_t)drbId);
1097 drbIt->second->m_pdcp->SetStatus(status);
1104 NS_LOG_FUNCTION(
this);
1105 NS_ASSERT_MSG(m_state == HANDOVER_LEAVING,
"method unexpected in state " << ToString(m_state));
1106 m_handoverLeavingTimeout.Cancel();
1112 NS_LOG_FUNCTION(
this);
1113 NS_ASSERT_MSG(m_state == HANDOVER_JOINING,
"method unexpected in state " << ToString(m_state));
1114 m_handoverJoiningTimeout.Cancel();
1121 NS_LOG_FUNCTION(
this << (uint32_t)m_rnti);
1125 m_rrc->m_rrcSapUser->SendRrcConnectionRelease(m_rnti, msg);
1132 m_rrc->DoRecvIdealUeContextRemoveRequest(m_rnti);
1140 NS_LOG_FUNCTION(
this);
1141 m_srb0->m_rlc->SetNrRlcSapUser(params.
srb0SapUser);
1142 m_srb1->m_pdcp->SetNrPdcpSapUser(params.
srb1SapUser);
1148 NS_LOG_FUNCTION(
this);
1151 case INITIAL_RANDOM_ACCESS: {
1152 m_connectionRequestTimeout.Cancel();
1154 if (m_rrc->m_admitRrcConnectionRequest)
1162 m_rrc->m_rrcSapUser->SendRrcConnectionSetup(m_rnti, msg2);
1165 m_connectionSetupTimeout = Simulator::Schedule(m_rrc->m_connectionSetupTimeoutDuration,
1169 SwitchToState(CONNECTION_SETUP);
1173 NS_LOG_INFO(
"rejecting connection request for RNTI " << m_rnti);
1178 m_rrc->m_rrcSapUser->SendRrcConnectionReject(m_rnti, rejectMsg);
1180 m_connectionRejectedTimeout =
1181 Simulator::Schedule(m_rrc->m_connectionRejectedTimeoutDuration,
1185 SwitchToState(CONNECTION_REJECTED);
1191 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1199 NS_LOG_FUNCTION(
this);
1202 case CONNECTION_SETUP:
1203 m_connectionSetupTimeout.Cancel();
1204 if (!m_caSupportConfigured && m_rrc->m_numberOfComponentCarriers > 1)
1206 m_pendingRrcConnectionReconfiguration =
true;
1207 m_pendingStartDataRadioBearers =
true;
1210 if (m_rrc->m_s1SapProvider !=
nullptr)
1212 m_rrc->m_s1SapProvider->InitialUeMessage(m_imsi, m_rnti);
1213 SwitchToState(ATTACH_REQUEST);
1217 SwitchToState(CONNECTED_NORMALLY);
1219 m_rrc->m_connectionEstablishedTrace(m_imsi,
1220 m_rrc->ComponentCarrierToCellId(m_componentCarrierId),
1225 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1234 NS_LOG_FUNCTION(
this);
1237 case CONNECTION_RECONFIGURATION:
1239 if (m_needPhyMacConfiguration)
1245 for (uint16_t i = 0; i < m_rrc->m_numberOfComponentCarriers; i++)
1247 m_rrc->m_cmacSapProvider.at(i)->UeUpdateConfigurationReq(req);
1250 m_rrc->m_cphySapProvider.at(i)->SetTransmissionMode(req.
m_rnti,
1254 m_rrc->m_cphySapProvider.at(i)->SetPa(m_rnti, paDouble);
1257 m_needPhyMacConfiguration =
false;
1259 SwitchToState(CONNECTED_NORMALLY);
1260 m_rrc->m_connectionReconfigurationTrace(
1262 m_rrc->ComponentCarrierToCellId(m_componentCarrierId),
1268 case CONNECTED_NORMALLY:
1269 case HANDOVER_LEAVING:
1270 NS_LOG_INFO(
"ignoring RecvRrcConnectionReconfigurationCompleted in state "
1271 << ToString(m_state));
1274 case HANDOVER_JOINING: {
1275 m_handoverJoiningTimeout.Cancel();
1277 while (!m_packetBuffer.empty())
1279 NS_LOG_LOGIC(
"dequeueing data from buffer");
1280 std::pair<uint8_t, Ptr<Packet>> bidPacket = m_packetBuffer.front();
1281 uint8_t bid = bidPacket.first;
1282 Ptr<Packet> p = bidPacket.second;
1284 NS_LOG_LOGIC(
"queueing data on PDCP for transmission over the air");
1287 m_packetBuffer.pop_front();
1290 NS_LOG_INFO(
"Send PATH SWITCH REQUEST to the MME");
1292 params.
rnti = m_rnti;
1293 params.
cellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId);
1295 SwitchToState(HANDOVER_PATH_SWITCH);
1296 for (
auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it)
1300 b.
teid = it->second->m_gtpTeid;
1303 m_rrc->m_s1SapProvider->PathSwitchRequest(params);
1308 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1317 NS_LOG_FUNCTION(
this);
1320 case CONNECTED_NORMALLY:
1323 case HANDOVER_LEAVING:
1324 m_handoverLeavingTimeout.Cancel();
1328 NS_FATAL_ERROR(
"method unexpected in state " << ToString(m_state));
1335 m_rrc->m_rrcSapUser->SendRrcConnectionReestablishment(m_rnti, msg2);
1336 SwitchToState(CONNECTION_REESTABLISHMENT);
1343 NS_LOG_FUNCTION(
this);
1344 SwitchToState(CONNECTED_NORMALLY);
1351 NS_LOG_FUNCTION(
this << (uint16_t)measId);
1353 "measId " << (uint16_t)measId <<
" haveMeasResultNeighCells "
1358 NS_LOG_LOGIC(
"serving cellId "
1359 << m_rrc->ComponentCarrierToCellId(m_componentCarrierId) <<
" RSRP "
1367 NS_LOG_LOGIC(
"neighbour cellId " << it->physCellId <<
" RSRP "
1368 << (it->haveRsrpResult ? (uint16_t)it->rsrpResult : 255)
1370 << (it->haveRsrqResult ? (uint16_t)it->rsrqResult : 255));
1373 if ((m_rrc->m_handoverManagementSapProvider !=
nullptr) &&
1374 (m_rrc->m_handoverMeasIds.find(measId) != m_rrc->m_handoverMeasIds.end()))
1377 m_rrc->m_handoverManagementSapProvider->ReportUeMeas(m_rnti, msg.
measResults);
1380 if ((m_rrc->m_ccmRrcSapProvider !=
nullptr) &&
1381 (m_rrc->m_componentCarrierMeasIds.find(measId) != m_rrc->m_componentCarrierMeasIds.end()))
1384 m_rrc->m_ccmRrcSapProvider->ReportUeMeas(m_rnti, msg.
measResults);
1387 if ((m_rrc->m_anrSapProvider !=
nullptr) &&
1388 (m_rrc->m_anrMeasIds.find(measId) != m_rrc->m_anrMeasIds.end()))
1391 m_rrc->m_anrSapProvider->ReportUeMeas(msg.
measResults);
1396 m_rrc->m_ccmRrcSapProvider->ReportUeMeas(m_rnti, msg.
measResults);
1398 m_rrc->m_recvMeasurementReportTrace(m_imsi,
1399 m_rrc->ComponentCarrierToCellId(m_componentCarrierId),
1410 NS_LOG_FUNCTION(
this << m_rnti);
1415 m_needPhyMacConfiguration =
true;
1426 NS_LOG_FUNCTION(
this);
1427 if (params.
lcid > 2)
1433 params.
pdcpSdu->AddPacketTag(tag);
1434 m_rrc->m_forwardUpCallback(params.
pdcpSdu);
1453 return m_componentCarrierId;
1465 NS_LOG_FUNCTION(
this);
1467 for (uint16_t i = 0; i < m_rrc->m_numberOfComponentCarriers; i++)
1469 m_rrc->m_cphySapProvider.at(i)->SetSrsConfigurationIndex(m_rnti, srsConfIndex);
1473 case INITIAL_RANDOM_ACCESS:
1493 NS_LOG_FUNCTION(
this);
1496 m_needPhyMacConfiguration =
true;
1505 NS_LOG_FUNCTION(
this);
1506 m_connectionRequestTimeout.Cancel();
1507 m_connectionRejectedTimeout.Cancel();
1508 m_connectionSetupTimeout.Cancel();
1509 m_handoverJoiningTimeout.Cancel();
1510 m_handoverLeavingTimeout.Cancel();
1516 NS_LOG_FUNCTION(
this);
1520 res.
targetCellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId);
1530 NS_LOG_FUNCTION(
this);
1534 res.
sourceCellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId);
1542NrUeManager::AddDataRadioBearerInfo(Ptr<NrDataRadioBearerInfo> drbInfo)
1544 NS_LOG_FUNCTION(
this);
1545 const uint8_t MAX_DRB_ID = 32;
1546 for (
int drbid = (m_lastAllocatedDrbid + 1) % MAX_DRB_ID; drbid != m_lastAllocatedDrbid;
1547 drbid = (drbid + 1) % MAX_DRB_ID)
1551 if (m_drbMap.find(drbid) == m_drbMap.end())
1553 m_drbMap.insert(std::pair<uint8_t, Ptr<NrDataRadioBearerInfo>>(drbid, drbInfo));
1554 drbInfo->m_drbIdentity = drbid;
1555 m_lastAllocatedDrbid = drbid;
1560 NS_FATAL_ERROR(
"no more data radio bearer ids available");
1564Ptr<NrDataRadioBearerInfo>
1565NrUeManager::GetDataRadioBearerInfo(uint8_t drbid)
1567 NS_LOG_FUNCTION(
this << (uint32_t)drbid);
1568 NS_ASSERT(0 != drbid);
1569 auto it = m_drbMap.find(drbid);
1570 NS_ABORT_IF(it == m_drbMap.end());
1575NrUeManager::RemoveDataRadioBearerInfo(uint8_t drbid)
1577 NS_LOG_FUNCTION(
this << (uint32_t)drbid);
1578 auto it = m_drbMap.find(drbid);
1579 NS_ASSERT_MSG(it != m_drbMap.end(),
1580 "request to remove radio bearer with unknown drbid " << drbid);
1584NrRrcSap::RrcConnectionReconfiguration
1585NrUeManager::BuildRrcConnectionReconfiguration()
1587 NS_LOG_FUNCTION(
this);
1588 NrRrcSap::RrcConnectionReconfiguration msg{};
1589 msg.rrcTransactionIdentifier = GetNewRrcTransactionIdentifier();
1590 msg.haveRadioResourceConfigDedicated =
true;
1591 msg.radioResourceConfigDedicated = BuildRadioResourceConfigDedicated();
1592 msg.haveMobilityControlInfo =
false;
1593 msg.haveMeasConfig =
true;
1594 msg.measConfig = m_rrc->m_ueMeasConfig;
1595 if (!m_caSupportConfigured && m_rrc->m_numberOfComponentCarriers > 1)
1597 m_caSupportConfigured =
true;
1598 NS_LOG_FUNCTION(
this <<
"CA not configured. Configure now!");
1599 msg.haveNonCriticalExtension =
true;
1600 msg.nonCriticalExtension = BuildNonCriticalExtensionConfigurationCa();
1601 NS_LOG_FUNCTION(
this <<
" haveNonCriticalExtension " << msg.haveNonCriticalExtension);
1605 msg.haveNonCriticalExtension =
false;
1611NrRrcSap::RadioResourceConfigDedicated
1612NrUeManager::BuildRadioResourceConfigDedicated()
1614 NS_LOG_FUNCTION(
this);
1615 NrRrcSap::RadioResourceConfigDedicated rrcd;
1619 NrRrcSap::SrbToAddMod stam;
1620 stam.srbIdentity = m_srb1->m_srbIdentity;
1621 stam.logicalChannelConfig = m_srb1->m_logicalChannelConfig;
1622 rrcd.srbToAddModList.push_back(stam);
1625 for (
auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it)
1627 NrRrcSap::DrbToAddMod dtam;
1628 dtam.epsBearerIdentity = it->second->m_epsBearerIdentity;
1629 dtam.drbIdentity = it->second->m_drbIdentity;
1630 dtam.rlcConfig = it->second->m_rlcConfig;
1631 dtam.logicalChannelIdentity = it->second->m_logicalChannelIdentity;
1632 dtam.logicalChannelConfig = it->second->m_logicalChannelConfig;
1633 rrcd.drbToAddModList.push_back(dtam);
1636 rrcd.havePhysicalConfigDedicated =
true;
1637 rrcd.physicalConfigDedicated = m_physicalConfigDedicated;
1642NrUeManager::GetNewRrcTransactionIdentifier()
1644 NS_LOG_FUNCTION(
this);
1645 ++m_lastRrcTransactionIdentifier;
1646 m_lastRrcTransactionIdentifier %= 4;
1647 return m_lastRrcTransactionIdentifier;
1651NrUeManager::Lcid2Drbid(uint8_t lcid)
1653 NS_ASSERT(lcid > 2);
1658NrUeManager::Drbid2Lcid(uint8_t drbid)
1664NrUeManager::Lcid2Bid(uint8_t lcid)
1666 NS_ASSERT(lcid > 2);
1671NrUeManager::Bid2Lcid(uint8_t bid)
1677NrUeManager::Drbid2Bid(uint8_t drbid)
1683NrUeManager::Bid2Drbid(uint8_t bid)
1689NrUeManager::SwitchToState(State newState)
1691 NS_LOG_FUNCTION(
this << ToString(newState));
1692 State oldState = m_state;
1694 NS_LOG_INFO(
this <<
" IMSI " << m_imsi <<
" RNTI " << m_rnti <<
" NrUeManager "
1695 << ToString(oldState) <<
" --> " << ToString(newState));
1696 m_stateTransitionTrace(m_imsi,
1697 m_rrc->ComponentCarrierToCellId(m_componentCarrierId),
1704 case INITIAL_RANDOM_ACCESS:
1705 case HANDOVER_JOINING:
1706 NS_FATAL_ERROR(
"cannot switch to an initial state");
1709 case CONNECTION_SETUP:
1710 case ATTACH_REQUEST:
1713 case CONNECTED_NORMALLY: {
1714 if (m_pendingRrcConnectionReconfiguration)
1718 if (m_pendingStartDataRadioBearers && m_caSupportConfigured)
1725 case CONNECTION_RECONFIGURATION:
1726 case CONNECTION_REESTABLISHMENT:
1727 case HANDOVER_LEAVING:
1733NrRrcSap::NonCriticalExtensionConfiguration
1734NrUeManager::BuildNonCriticalExtensionConfigurationCa()
1736 NS_LOG_FUNCTION(
this);
1737 NrRrcSap::NonCriticalExtensionConfiguration ncec;
1739 for (
auto& it : m_rrc->m_componentCarrierPhyConf)
1741 uint8_t ccId = it.first;
1743 if (ccId == m_componentCarrierId)
1748 else if (ccId < m_componentCarrierId)
1754 Ptr<BandwidthPartGnb> eNbCcm = it.second;
1755 NrRrcSap::SCellToAddMod component;
1756 component.sCellIndex = ccId;
1757 component.cellIdentification.physCellId = eNbCcm->GetCellId();
1758 component.cellIdentification.dlCarrierFreq = eNbCcm->GetDlEarfcn();
1759 component.radioResourceConfigCommonSCell.haveNonUlConfiguration =
true;
1760 component.radioResourceConfigCommonSCell.nonUlConfiguration.dlBandwidth =
1761 eNbCcm->GetDlBandwidth();
1762 component.radioResourceConfigCommonSCell.nonUlConfiguration.antennaInfoCommon
1763 .antennaPortsCount = 0;
1764 component.radioResourceConfigCommonSCell.nonUlConfiguration.pdschConfigCommon
1765 .referenceSignalPower = m_rrc->m_cphySapProvider.at(0)->GetReferenceSignalPower();
1766 component.radioResourceConfigCommonSCell.nonUlConfiguration.pdschConfigCommon.pb = 0;
1767 component.radioResourceConfigCommonSCell.haveUlConfiguration =
true;
1768 component.radioResourceConfigCommonSCell.ulConfiguration.ulFreqInfo.ulCarrierFreq =
1769 eNbCcm->GetUlEarfcn();
1770 component.radioResourceConfigCommonSCell.ulConfiguration.ulFreqInfo.ulBandwidth =
1771 eNbCcm->GetUlBandwidth();
1772 component.radioResourceConfigCommonSCell.ulConfiguration.ulPowerControlCommonSCell.alpha =
1776 component.radioResourceConfigCommonSCell.ulConfiguration.soundingRsUlConfigCommon
1777 .srsBandwidthConfig = 0;
1778 component.radioResourceConfigCommonSCell.ulConfiguration.soundingRsUlConfigCommon
1779 .srsSubframeConfig = 0;
1780 component.radioResourceConfigCommonSCell.ulConfiguration.prachConfigSCell.index = 0;
1782 component.haveRadioResourceConfigDedicatedSCell =
true;
1783 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1784 .haveNonUlConfiguration =
true;
1785 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1786 .haveAntennaInfoDedicated =
true;
1787 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell.antennaInfo
1788 .transmissionMode = m_rrc->m_defaultTransmissionMode;
1789 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1790 .crossCarrierSchedulingConfig =
false;
1791 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1792 .havePdschConfigDedicated =
true;
1793 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1794 .pdschConfigDedicated.pa = NrRrcSap::PdschConfigDedicated::dB0;
1795 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1796 .haveUlConfiguration =
true;
1797 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1798 .haveAntennaInfoUlDedicated =
true;
1799 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell.antennaInfoUl
1800 .transmissionMode = m_rrc->m_defaultTransmissionMode;
1801 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1802 .pushConfigDedicatedSCell.nPuschIdentity = 0;
1803 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1804 .ulPowerControlDedicatedSCell.pSrsOffset = 0;
1805 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1806 .haveSoundingRsUlConfigDedicated =
true;
1807 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1809 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1810 .soundingRsUlConfigDedicated.type = NrRrcSap::SoundingRsUlConfigDedicated::SETUP;
1811 component.radioResourceConfigDedicatedSCell.physicalConfigDedicatedSCell
1812 .soundingRsUlConfigDedicated.srsBandwidth = 0;
1814 ncec.sCellToAddModList.push_back(component);
1824NS_OBJECT_ENSURE_REGISTERED(NrGnbRrc);
1827 : m_x2SapProvider(nullptr),
1828 m_cmacSapProvider(0),
1829 m_handoverManagementSapProvider(nullptr),
1830 m_ccmRrcSapProvider(nullptr),
1831 m_anrSapProvider(nullptr),
1832 m_rrcSapUser(nullptr),
1833 m_macSapProvider(nullptr),
1834 m_s1SapProvider(nullptr),
1835 m_cphySapProvider(0),
1836 m_configured(false),
1837 m_lastAllocatedRnti(0),
1838 m_srsCurrentPeriodicityId(0),
1839 m_lastAllocatedConfigurationIndex(0),
1840 m_reconfigureUes(false),
1841 m_numberOfComponentCarriers(0),
1842 m_carriersConfigured(false)
1844 NS_LOG_FUNCTION(
this);
1858 NS_ASSERT_MSG(!m_carriersConfigured,
"Secondary carriers can be configured only once.");
1859 m_componentCarrierPhyConf = ccPhyConf;
1860 NS_ABORT_MSG_IF(m_numberOfComponentCarriers != m_componentCarrierPhyConf.size(),
1861 " Number of component carriers "
1862 "are not equal to the number of he component carrier configuration provided");
1864 for (uint16_t i = 1; i < m_numberOfComponentCarriers; i++)
1869 m_carriersConfigured =
true;
1870 Object::DoInitialize();
1875 NS_LOG_FUNCTION(
this);
1879NrGnbRrc::DoDispose()
1881 NS_LOG_FUNCTION(
this);
1882 for (uint16_t i = 0; i < m_numberOfComponentCarriers; i++)
1884 delete m_cphySapUser[i];
1885 delete m_cmacSapUser[i];
1888 m_cphySapUser.erase(m_cphySapUser.begin(), m_cphySapUser.end());
1889 m_cphySapUser.clear();
1891 m_cmacSapUser.erase(m_cmacSapUser.begin(), m_cmacSapUser.end());
1892 m_cmacSapUser.clear();
1894 delete m_handoverManagementSapUser;
1895 delete m_ccmRrcSapUser;
1896 delete m_anrSapUser;
1897 delete m_rrcSapProvider;
1906 TypeId(
"ns3::NrGnbRrc")
1907 .SetParent<Object>()
1910 .AddAttribute(
"UeMap",
1911 "List of NrUeManager by C-RNTI.",
1913 MakeObjectMapAccessor(&NrGnbRrc::m_ueMap),
1914 MakeObjectMapChecker<NrUeManager>())
1915 .AddAttribute(
"DefaultTransmissionMode",
1916 "The default UEs' transmission mode (0: SISO)",
1918 MakeUintegerAccessor(&NrGnbRrc::m_defaultTransmissionMode),
1919 MakeUintegerChecker<uint8_t>())
1921 "EpsBearerToRlcMapping",
1922 "Specify which type of RLC will be used for each type of EPS bearer.",
1923 EnumValue(RLC_SM_ALWAYS),
1924 MakeEnumAccessor<NrEpsBearerToRlcMapping_t>(&NrGnbRrc::m_epsBearerToRlcMapping),
1925 MakeEnumChecker(RLC_SM_ALWAYS,
1932 "PacketErrorRateBased"))
1933 .AddAttribute(
"SystemInformationPeriodicity",
1934 "The interval for sending system information (Time value)",
1935 TimeValue(MilliSeconds(80)),
1936 MakeTimeAccessor(&NrGnbRrc::m_systemInformationPeriodicity),
1942 "The SRS periodicity in milliseconds",
1945 MakeUintegerChecker<uint32_t>())
1948 .AddAttribute(
"ConnectionRequestTimeoutDuration",
1949 "After a RA attempt, if no RRC CONNECTION REQUEST is "
1950 "received before this time, the UE context is destroyed. "
1951 "Must account for reception of RAR and transmission of "
1952 "RRC CONNECTION REQUEST over UL GRANT. The value of this"
1953 "timer should not be greater than T300 timer at UE RRC",
1954 TimeValue(MilliSeconds(15)),
1955 MakeTimeAccessor(&NrGnbRrc::m_connectionRequestTimeoutDuration),
1956 MakeTimeChecker(MilliSeconds(1), MilliSeconds(15)))
1957 .AddAttribute(
"ConnectionSetupTimeoutDuration",
1958 "After accepting connection request, if no RRC CONNECTION "
1959 "SETUP COMPLETE is received before this time, the UE "
1960 "context is destroyed. Must account for the UE's reception "
1961 "of RRC CONNECTION SETUP and transmission of RRC CONNECTION "
1963 TimeValue(MilliSeconds(150)),
1964 MakeTimeAccessor(&NrGnbRrc::m_connectionSetupTimeoutDuration),
1966 .AddAttribute(
"ConnectionRejectedTimeoutDuration",
1967 "Time to wait between sending a RRC CONNECTION REJECT and "
1968 "destroying the UE context",
1969 TimeValue(MilliSeconds(30)),
1970 MakeTimeAccessor(&NrGnbRrc::m_connectionRejectedTimeoutDuration),
1972 .AddAttribute(
"HandoverJoiningTimeoutDuration",
1973 "After accepting a handover request, if no RRC CONNECTION "
1974 "RECONFIGURATION COMPLETE is received before this time, the "
1975 "UE context is destroyed. Must account for reception of "
1976 "X2 HO REQ ACK by source eNB, transmission of the Handover "
1977 "Command, non-contention-based random access and reception "
1978 "of the RRC CONNECTION RECONFIGURATION COMPLETE message.",
1979 TimeValue(MilliSeconds(200)),
1980 MakeTimeAccessor(&NrGnbRrc::m_handoverJoiningTimeoutDuration),
1982 .AddAttribute(
"HandoverLeavingTimeoutDuration",
1983 "After issuing a Handover Command, if neither RRC "
1984 "CONNECTION RE-ESTABLISHMENT nor X2 UE Context Release has "
1985 "been previously received, the UE context is destroyed.",
1986 TimeValue(MilliSeconds(500)),
1987 MakeTimeAccessor(&NrGnbRrc::m_handoverLeavingTimeoutDuration),
1991 .AddAttribute(
"QRxLevMin",
1992 "One of information transmitted within the SIB1 message, "
1993 "indicating the required minimum RSRP level that any UE must "
1994 "receive from this cell before it is allowed to camp to this "
1995 "cell. The default value -70 corresponds to -140 dBm and is "
1996 "the lowest possible value as defined by Section 6.3.4 of "
1997 "3GPP TS 36.133. This restriction, however, only applies to "
1998 "initial cell selection and EPC-enabled simulation.",
1999 TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT,
2001 MakeIntegerAccessor(&NrGnbRrc::m_qRxLevMin),
2002 MakeIntegerChecker<int8_t>(-70, -22))
2003 .AddAttribute(
"NumberOfComponentCarriers",
2004 "Number of Component Carriers",
2006 MakeIntegerAccessor(&NrGnbRrc::m_numberOfComponentCarriers),
2007 MakeIntegerChecker<int16_t>(nr::MIN_NO_CC, nr::MAX_NO_CC))
2010 .AddAttribute(
"AdmitHandoverRequest",
2011 "Whether to admit an X2 handover request from another eNB",
2013 MakeBooleanAccessor(&NrGnbRrc::m_admitHandoverRequest),
2014 MakeBooleanChecker())
2015 .AddAttribute(
"AdmitRrcConnectionRequest",
2016 "Whether to admit a connection request from a UE",
2018 MakeBooleanAccessor(&NrGnbRrc::m_admitRrcConnectionRequest),
2019 MakeBooleanChecker())
2022 .AddAttribute(
"RsrpFilterCoefficient",
2023 "Determines the strength of smoothing effect induced by "
2024 "layer 3 filtering of RSRP in all attached UE; "
2025 "if set to 0, no layer 3 filtering is applicable",
2028 MakeUintegerAccessor(&NrGnbRrc::m_rsrpFilterCoefficient),
2029 MakeUintegerChecker<uint8_t>(0))
2030 .AddAttribute(
"RsrqFilterCoefficient",
2031 "Determines the strength of smoothing effect induced by "
2032 "layer 3 filtering of RSRQ in all attached UE; "
2033 "if set to 0, no layer 3 filtering is applicable",
2036 MakeUintegerAccessor(&NrGnbRrc::m_rsrqFilterCoefficient),
2037 MakeUintegerChecker<uint8_t>(0))
2040 .AddTraceSource(
"NewUeContext",
2041 "Fired upon creation of a new UE context.",
2042 MakeTraceSourceAccessor(&NrGnbRrc::m_newUeContextTrace),
2043 "ns3::NrGnbRrc::NewUeContextTracedCallback")
2044 .AddTraceSource(
"ConnectionEstablished",
2045 "Fired upon successful RRC connection establishment.",
2046 MakeTraceSourceAccessor(&NrGnbRrc::m_connectionEstablishedTrace),
2047 "ns3::NrGnbRrc::ConnectionHandoverTracedCallback")
2048 .AddTraceSource(
"ConnectionReconfiguration",
2049 "trace fired upon RRC connection reconfiguration",
2050 MakeTraceSourceAccessor(&NrGnbRrc::m_connectionReconfigurationTrace),
2051 "ns3::NrGnbRrc::ConnectionHandoverTracedCallback")
2052 .AddTraceSource(
"HandoverStart",
2053 "trace fired upon start of a handover procedure",
2054 MakeTraceSourceAccessor(&NrGnbRrc::m_handoverStartTrace),
2055 "ns3::NrGnbRrc::HandoverStartTracedCallback")
2056 .AddTraceSource(
"HandoverEndOk",
2057 "trace fired upon successful termination of a handover procedure",
2058 MakeTraceSourceAccessor(&NrGnbRrc::m_handoverEndOkTrace),
2059 "ns3::NrGnbRrc::ConnectionHandoverTracedCallback")
2060 .AddTraceSource(
"RecvMeasurementReport",
2061 "trace fired when measurement report is received",
2062 MakeTraceSourceAccessor(&NrGnbRrc::m_recvMeasurementReportTrace),
2063 "ns3::NrGnbRrc::ReceiveReportTracedCallback")
2064 .AddTraceSource(
"NotifyConnectionRelease",
2065 "trace fired when an UE is released",
2066 MakeTraceSourceAccessor(&NrGnbRrc::m_connectionReleaseTrace),
2067 "ns3::NrGnbRrc::ConnectionHandoverTracedCallback")
2068 .AddTraceSource(
"RrcTimeout",
2069 "trace fired when a timer expires",
2070 MakeTraceSourceAccessor(&NrGnbRrc::m_rrcTimeoutTrace),
2071 "ns3::NrGnbRrc::TimerExpiryTracedCallback")
2073 "HandoverFailureNoPreamble",
2074 "trace fired upon handover failure due to non-allocation of non-contention based "
2075 "preamble at gNB for UE to handover due to max count reached",
2076 MakeTraceSourceAccessor(&NrGnbRrc::m_handoverFailureNoPreambleTrace),
2077 "ns3::NrGnbRrc::HandoverFailureTracedCallback")
2079 "HandoverFailureMaxRach",
2080 "trace fired upon handover failure due to max RACH attempts from UE to target eNB",
2081 MakeTraceSourceAccessor(&NrGnbRrc::m_handoverFailureMaxRachTrace),
2082 "ns3::NrGnbRrc::HandoverFailureTracedCallback")
2084 "HandoverFailureLeaving",
2085 "trace fired upon handover failure due to handover leaving timeout at source eNB",
2086 MakeTraceSourceAccessor(&NrGnbRrc::m_handoverFailureLeavingTrace),
2087 "ns3::NrGnbRrc::HandoverFailureTracedCallback")
2089 "HandoverFailureJoining",
2090 "trace fired upon handover failure due to handover joining timeout at target eNB",
2091 MakeTraceSourceAccessor(&NrGnbRrc::m_handoverFailureJoiningTrace),
2092 "ns3::NrGnbRrc::HandoverFailureTracedCallback");
2099 NS_LOG_FUNCTION(
this << s);
2100 m_x2SapProvider = s;
2106 NS_LOG_FUNCTION(
this);
2113 NS_LOG_FUNCTION(
this << s);
2114 m_cmacSapProvider.at(0) = s;
2120 NS_LOG_FUNCTION(
this << s);
2121 if (m_cmacSapProvider.size() > pos)
2123 m_cmacSapProvider.at(pos) = s;
2127 m_cmacSapProvider.push_back(s);
2128 NS_ABORT_IF(m_cmacSapProvider.size() - 1 != pos);
2135 NS_LOG_FUNCTION(
this);
2136 return m_cmacSapUser.at(0);
2142 NS_LOG_FUNCTION(
this);
2143 return m_cmacSapUser.at(pos);
2149 NS_LOG_FUNCTION(
this << s);
2150 m_handoverManagementSapProvider = s;
2156 NS_LOG_FUNCTION(
this);
2157 return m_handoverManagementSapUser;
2163 NS_LOG_FUNCTION(
this << s);
2164 m_ccmRrcSapProvider = s;
2170 NS_LOG_FUNCTION(
this);
2171 return m_ccmRrcSapUser;
2177 NS_LOG_FUNCTION(
this << s);
2178 m_anrSapProvider = s;
2184 NS_LOG_FUNCTION(
this);
2185 return m_anrSapUser;
2191 NS_LOG_FUNCTION(
this << s);
2198 NS_LOG_FUNCTION(
this);
2199 return m_rrcSapProvider;
2205 NS_LOG_FUNCTION(
this);
2206 m_macSapProvider = s;
2212 m_s1SapProvider = s;
2224 NS_LOG_FUNCTION(
this << s);
2225 if (!m_cphySapProvider.empty())
2227 m_cphySapProvider.at(0) = s;
2231 m_cphySapProvider.push_back(s);
2238 NS_LOG_FUNCTION(
this);
2239 return m_cphySapUser.at(0);
2245 NS_LOG_FUNCTION(
this << s);
2246 if (m_cphySapProvider.size() > pos)
2248 m_cphySapProvider.at(pos) = s;
2252 m_cphySapProvider.push_back(s);
2253 NS_ABORT_IF(m_cphySapProvider.size() - 1 != pos);
2260 NS_LOG_FUNCTION(
this);
2261 return m_cphySapUser.at(pos);
2267 NS_LOG_FUNCTION(
this << (uint32_t)rnti);
2268 auto it = m_ueMap.find(rnti);
2269 return (it != m_ueMap.end());
2275 NS_LOG_FUNCTION(
this << (uint32_t)rnti);
2276 NS_ASSERT(0 != rnti);
2277 auto it = m_ueMap.find(rnti);
2278 NS_ASSERT_MSG(it != m_ueMap.end(),
"UE manager for RNTI " << rnti <<
" not found");
2285 NS_LOG_FUNCTION(
this);
2292 "Measurement identities and reporting configuration should not have different quantity");
2294 if (Simulator::Now() != Seconds(0))
2296 NS_FATAL_ERROR(
"AddUeMeasReportConfig may not be called after the simulation has run");
2308 "The given triggerQuantity (RSRP) does not match with the given threshold2.choice");
2318 "The given triggerQuantity (RSRP) does not match with the given threshold1.choice");
2327 "The given triggerQuantity (RSRQ) does not match with the given threshold2.choice");
2337 "The given triggerQuantity (RSRQ) does not match with the given threshold1.choice");
2342 NS_FATAL_ERROR(
"unsupported triggerQuantity");
2346 if (config.
purpose != NrRrcSap::ReportConfigEutra::REPORT_STRONGEST_CELLS)
2348 NS_FATAL_ERROR(
"Only REPORT_STRONGEST_CELLS purpose is supported");
2353 NS_LOG_WARN(
"reportQuantity = BOTH will be used instead of the given reportQuantity");
2366 std::vector<uint8_t> measIds;
2376 measIdToAddMod.
measId = measId;
2381 measIds.push_back(measId);
2390 auto it = ccPhyConf.begin();
2391 NS_ASSERT(it != ccPhyConf.end());
2392 uint16_t ulBandwidth = it->second->GetUlBandwidth();
2393 uint16_t dlBandwidth = it->second->GetDlBandwidth();
2394 uint32_t ulEarfcn = it->second->GetUlEarfcn();
2395 uint32_t dlEarfcn = it->second->GetDlEarfcn();
2396 NS_LOG_FUNCTION(
this << ulBandwidth << dlBandwidth << ulEarfcn << dlEarfcn);
2397 NS_ASSERT_MSG(!m_configured,
"NrGnbRrc::ConfigureCell called more than once");
2399 for (
const auto& it : ccPhyConf)
2401 m_cphySapProvider.at(it.first)->SetBandwidth(it.second->GetUlBandwidth(),
2402 it.second->GetDlBandwidth());
2403 m_cphySapProvider.at(it.first)->SetEarfcn(it.second->GetUlEarfcn(),
2404 it.second->GetDlEarfcn());
2405 m_cphySapProvider.at(it.first)->SetCellId(it.second->GetCellId());
2406 m_cmacSapProvider.at(it.first)->ConfigureMac(it.second->GetUlBandwidth(),
2407 it.second->GetDlBandwidth());
2410 m_dlEarfcn = dlEarfcn;
2411 m_ulEarfcn = ulEarfcn;
2412 m_dlBandwidth = dlBandwidth;
2413 m_ulBandwidth = ulBandwidth;
2420 for (
const auto& it : ccPhyConf)
2442 m_sib1.reserve(ccPhyConf.size());
2443 for (
const auto& it : ccPhyConf)
2449 m_cphySapProvider.at(it.first)->SetMasterInformationBlock(mib);
2459 m_sib1.push_back(sib1);
2460 m_cphySapProvider.at(it.first)->SetSystemInformationBlockType1(sib1);
2468 Simulator::Schedule(MilliSeconds(16), &NrGnbRrc::SendSystemInformation,
this);
2470 m_configured =
true;
2477 m_sib1.at(0).cellAccessRelatedInfo.cellIdentity = cellId;
2478 m_cphySapProvider.at(0)->SetSystemInformationBlockType1(m_sib1.at(0));
2485 m_sib1.at(ccIndex).cellAccessRelatedInfo.cellIdentity = cellId;
2486 m_cphySapProvider.at(ccIndex)->SetSystemInformationBlockType1(m_sib1.at(ccIndex));
2492 NS_LOG_FUNCTION(
this << cellId);
2493 for (
auto& it : m_componentCarrierPhyConf)
2495 if (it.second->GetCellId() == cellId)
2500 NS_FATAL_ERROR(
"Cell " << cellId <<
" not found in CC map");
2506 NS_LOG_FUNCTION(
this << +componentCarrierId);
2507 return m_componentCarrierPhyConf.at(componentCarrierId)->GetCellId();
2513 for (
auto& it : m_componentCarrierPhyConf)
2515 if (it.second->GetCellId() == cellId)
2526 NS_LOG_FUNCTION(
this << packet);
2528 bool found = packet->RemovePacketTag(tag);
2529 NS_ASSERT_MSG(found,
"no NrEpsBearerTag found in packet to be sent");
2532 NS_LOG_INFO(
"Sending a packet of " << packet->GetSize() <<
" bytes to IMSI "
2533 << ueManager->GetImsi() <<
", RNTI " << ueManager->GetRnti()
2534 <<
", BID " << (uint16_t)tag.
GetBid());
2535 ueManager->SendData(tag.
GetBid(), packet);
2543 m_forwardUpCallback = cb;
2549 NS_LOG_FUNCTION(
this << rnti);
2550 NS_ASSERT_MSG(
GetUeManager(rnti)->GetState() == NrUeManager::INITIAL_RANDOM_ACCESS,
2551 "ConnectionRequestTimeout in unexpected state "
2556 "ConnectionRequestTimeout");
2563 NS_LOG_FUNCTION(
this << rnti);
2564 NS_ASSERT_MSG(
GetUeManager(rnti)->GetState() == NrUeManager::CONNECTION_SETUP,
2565 "ConnectionSetupTimeout in unexpected state "
2570 "ConnectionSetupTimeout");
2577 NS_LOG_FUNCTION(
this << rnti);
2578 NS_ASSERT_MSG(
GetUeManager(rnti)->GetState() == NrUeManager::CONNECTION_REJECTED,
2579 "ConnectionRejectedTimeout in unexpected state "
2584 "ConnectionRejectedTimeout");
2591 NS_LOG_FUNCTION(
this << rnti);
2592 NS_ASSERT_MSG(
GetUeManager(rnti)->GetState() == NrUeManager::HANDOVER_JOINING,
2593 "HandoverJoiningTimeout in unexpected state "
2595 m_handoverFailureJoiningTrace(
2619 NS_LOG_FUNCTION(
this << rnti);
2620 NS_ASSERT_MSG(
GetUeManager(rnti)->GetState() == NrUeManager::HANDOVER_LEAVING,
2621 "HandoverLeavingTimeout in unexpected state "
2623 m_handoverFailureLeavingTrace(
2638 ueManager->SendRrcConnectionRelease();
2645 NS_LOG_FUNCTION(
this << rnti << cellId);
2646 NS_LOG_LOGIC(
"Request to send HANDOVER REQUEST");
2647 NS_ASSERT(m_configured);
2650 ueManager->PrepareHandover(cellId);
2656 NS_LOG_FUNCTION(
this << rnti);
2661NrGnbRrc::DoRecvRrcConnectionRequest(uint16_t rnti, NrRrcSap::RrcConnectionRequest msg)
2663 NS_LOG_FUNCTION(
this << rnti);
2668NrGnbRrc::DoRecvRrcConnectionSetupCompleted(uint16_t rnti,
2669 NrRrcSap::RrcConnectionSetupCompleted msg)
2671 NS_LOG_FUNCTION(
this << rnti);
2672 GetUeManager(rnti)->RecvRrcConnectionSetupCompleted(msg);
2676NrGnbRrc::DoRecvRrcConnectionReconfigurationCompleted(
2678 NrRrcSap::RrcConnectionReconfigurationCompleted msg)
2680 NS_LOG_FUNCTION(
this << rnti);
2681 GetUeManager(rnti)->RecvRrcConnectionReconfigurationCompleted(msg);
2685NrGnbRrc::DoRecvRrcConnectionReestablishmentRequest(
2687 NrRrcSap::RrcConnectionReestablishmentRequest msg)
2689 NS_LOG_FUNCTION(
this << rnti);
2690 GetUeManager(rnti)->RecvRrcConnectionReestablishmentRequest(msg);
2694NrGnbRrc::DoRecvRrcConnectionReestablishmentComplete(
2696 NrRrcSap::RrcConnectionReestablishmentComplete msg)
2698 NS_LOG_FUNCTION(
this << rnti);
2699 GetUeManager(rnti)->RecvRrcConnectionReestablishmentComplete(msg);
2703NrGnbRrc::DoRecvMeasurementReport(uint16_t rnti, NrRrcSap::MeasurementReport msg)
2705 NS_LOG_FUNCTION(
this << rnti);
2710NrGnbRrc::DoInitialContextSetupRequest(NrEpcGnbS1SapUser::InitialContextSetupRequestParameters msg)
2712 NS_LOG_FUNCTION(
this);
2714 ueManager->InitialContextSetupRequest();
2718NrGnbRrc::DoRecvIdealUeContextRemoveRequest(uint16_t rnti)
2720 NS_LOG_FUNCTION(
this << rnti);
2727 if (ueManager->GetState() == NrUeManager::HANDOVER_JOINING)
2729 m_handoverFailureMaxRachTrace(
2739 NrEpcX2Sap::HandoverPreparationFailureParams msg = ueManager->BuildHoPrepFailMsg();
2743 GetUeManager(rnti)->RecvIdealUeContextRemoveRequest(rnti);
2750NrGnbRrc::DoDataRadioBearerSetupRequest(
2751 NrEpcGnbS1SapUser::DataRadioBearerSetupRequestParameters request)
2753 NS_LOG_FUNCTION(
this);
2754 Ptr<NrUeManager> ueManager =
GetUeManager(request.rnti);
2755 ueManager->SetupDataRadioBearer(request.bearer,
2758 request.transportLayerAddress);
2762NrGnbRrc::DoPathSwitchRequestAcknowledge(
2763 NrEpcGnbS1SapUser::PathSwitchRequestAcknowledgeParameters params)
2765 NS_LOG_FUNCTION(
this);
2766 Ptr<NrUeManager> ueManager =
GetUeManager(params.rnti);
2767 ueManager->SendUeContextRelease();
2771NrGnbRrc::DoRecvHandoverRequest(NrEpcX2SapUser::HandoverRequestParams req)
2773 NS_LOG_FUNCTION(
this);
2775 NS_LOG_LOGIC(
"Recv X2 message: HANDOVER REQUEST");
2777 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << req.oldGnbUeX2apId);
2778 NS_LOG_LOGIC(
"sourceCellId = " << req.sourceCellId);
2779 NS_LOG_LOGIC(
"targetCellId = " << req.targetCellId);
2780 NS_LOG_LOGIC(
"mmeUeS1apId = " << req.mmeUeS1apId);
2783 if (!m_admitHandoverRequest || IsMaxSrsReached())
2785 NS_LOG_INFO(
"rejecting handover request from cellId " << req.sourceCellId);
2786 NrEpcX2Sap::HandoverPreparationFailureParams res;
2787 res.oldGnbUeX2apId = req.oldGnbUeX2apId;
2788 res.sourceCellId = req.sourceCellId;
2789 res.targetCellId = req.targetCellId;
2791 res.criticalityDiagnostics = 0;
2797 uint16_t rnti = AddUe(NrUeManager::HANDOVER_JOINING, componentCarrierId);
2799 ueManager->SetSource(req.sourceCellId, req.oldGnbUeX2apId);
2800 ueManager->SetImsi(req.mmeUeS1apId);
2801 NrGnbCmacSapProvider::AllocateNcRaPreambleReturnValue anrcrv =
2802 m_cmacSapProvider.at(componentCarrierId)->AllocateNcRaPreamble(rnti);
2807 <<
" failed to allocate a preamble for non-contention based RA => cannot accept HO");
2808 m_handoverFailureNoPreambleTrace(
2818 NrEpcX2Sap::HandoverPreparationFailureParams msg = ueManager->BuildHoPrepFailMsg();
2824 NrEpcX2SapProvider::HandoverRequestAckParams ackParams;
2825 ackParams.oldGnbUeX2apId = req.oldGnbUeX2apId;
2826 ackParams.newGnbUeX2apId = rnti;
2827 ackParams.sourceCellId = req.sourceCellId;
2828 ackParams.targetCellId = req.targetCellId;
2830 for (
auto it = req.bearers.begin(); it != req.bearers.end(); ++it)
2832 ueManager->SetupDataRadioBearer(it->erabLevelQosParameters,
2835 it->transportLayerAddress);
2836 NrEpcX2Sap::ErabAdmittedItem i;
2837 i.erabId = it->erabId;
2838 ackParams.admittedBearers.push_back(i);
2841 NrRrcSap::RrcConnectionReconfiguration handoverCommand =
2842 ueManager->GetRrcConnectionReconfigurationForHandover(componentCarrierId);
2844 handoverCommand.mobilityControlInfo.newUeIdentity = rnti;
2845 handoverCommand.mobilityControlInfo.haveRachConfigDedicated =
true;
2846 handoverCommand.mobilityControlInfo.rachConfigDedicated.raPreambleIndex = anrcrv.raPreambleId;
2847 handoverCommand.mobilityControlInfo.rachConfigDedicated.raPrachMaskIndex =
2848 anrcrv.raPrachMaskIndex;
2850 NrGnbCmacSapProvider::RachConfig rc = m_cmacSapProvider.at(componentCarrierId)->GetRachConfig();
2851 handoverCommand.mobilityControlInfo.radioResourceConfigCommon.rachConfigCommon.preambleInfo
2852 .numberOfRaPreambles = rc.numberOfRaPreambles;
2853 handoverCommand.mobilityControlInfo.radioResourceConfigCommon.rachConfigCommon.raSupervisionInfo
2854 .preambleTransMax = rc.preambleTransMax;
2855 handoverCommand.mobilityControlInfo.radioResourceConfigCommon.rachConfigCommon.raSupervisionInfo
2856 .raResponseWindowSize = rc.raResponseWindowSize;
2857 handoverCommand.mobilityControlInfo.radioResourceConfigCommon.rachConfigCommon.txFailParam
2858 .connEstFailCount = rc.connEstFailCount;
2862 ackParams.rrcContext = encodedHandoverCommand;
2864 NS_LOG_LOGIC(
"Send X2 message: HANDOVER REQUEST ACK");
2866 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << ackParams.oldGnbUeX2apId);
2867 NS_LOG_LOGIC(
"newGnbUeX2apId = " << ackParams.newGnbUeX2apId);
2868 NS_LOG_LOGIC(
"sourceCellId = " << ackParams.sourceCellId);
2869 NS_LOG_LOGIC(
"targetCellId = " << ackParams.targetCellId);
2875NrGnbRrc::DoRecvHandoverRequestAck(NrEpcX2SapUser::HandoverRequestAckParams params)
2877 NS_LOG_FUNCTION(
this);
2879 NS_LOG_LOGIC(
"Recv X2 message: HANDOVER REQUEST ACK");
2881 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << params.oldGnbUeX2apId);
2882 NS_LOG_LOGIC(
"newGnbUeX2apId = " << params.newGnbUeX2apId);
2883 NS_LOG_LOGIC(
"sourceCellId = " << params.sourceCellId);
2884 NS_LOG_LOGIC(
"targetCellId = " << params.targetCellId);
2886 uint16_t rnti = params.oldGnbUeX2apId;
2888 ueManager->RecvHandoverRequestAck(params);
2892NrGnbRrc::DoRecvHandoverPreparationFailure(NrEpcX2SapUser::HandoverPreparationFailureParams params)
2894 NS_LOG_FUNCTION(
this);
2896 NS_LOG_LOGIC(
"Recv X2 message: HANDOVER PREPARATION FAILURE");
2898 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << params.oldGnbUeX2apId);
2899 NS_LOG_LOGIC(
"sourceCellId = " << params.sourceCellId);
2900 NS_LOG_LOGIC(
"targetCellId = " << params.targetCellId);
2901 NS_LOG_LOGIC(
"cause = " << params.cause);
2902 NS_LOG_LOGIC(
"criticalityDiagnostics = " << params.criticalityDiagnostics);
2904 uint16_t rnti = params.oldGnbUeX2apId;
2910 ueManager->RecvHandoverPreparationFailure(params.targetCellId);
2915NrGnbRrc::DoRecvSnStatusTransfer(NrEpcX2SapUser::SnStatusTransferParams params)
2917 NS_LOG_FUNCTION(
this);
2919 NS_LOG_LOGIC(
"Recv X2 message: SN STATUS TRANSFER");
2921 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << params.oldGnbUeX2apId);
2922 NS_LOG_LOGIC(
"newGnbUeX2apId = " << params.newGnbUeX2apId);
2923 NS_LOG_LOGIC(
"erabsSubjectToStatusTransferList size = "
2924 << params.erabsSubjectToStatusTransferList.size());
2926 uint16_t rnti = params.newGnbUeX2apId;
2932 ueManager->RecvSnStatusTransfer(params);
2937NrGnbRrc::DoRecvUeContextRelease(NrEpcX2SapUser::UeContextReleaseParams params)
2939 NS_LOG_FUNCTION(
this);
2941 NS_LOG_LOGIC(
"Recv X2 message: UE CONTEXT RELEASE");
2943 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << params.oldGnbUeX2apId);
2944 NS_LOG_LOGIC(
"newGnbUeX2apId = " << params.newGnbUeX2apId);
2946 uint16_t rnti = params.oldGnbUeX2apId;
2957NrGnbRrc::DoRecvLoadInformation(NrEpcX2SapUser::LoadInformationParams params)
2959 NS_LOG_FUNCTION(
this);
2961 NS_LOG_LOGIC(
"Recv X2 message: LOAD INFORMATION");
2963 NS_LOG_LOGIC(
"Number of cellInformationItems = " << params.cellInformationList.size());
2967NrGnbRrc::DoRecvResourceStatusUpdate(NrEpcX2SapUser::ResourceStatusUpdateParams params)
2969 NS_LOG_FUNCTION(
this);
2971 NS_LOG_LOGIC(
"Recv X2 message: RESOURCE STATUS UPDATE");
2974 "Number of cellMeasurementResultItems = " << params.cellMeasurementResultList.size());
2976 NS_ASSERT(
"Processing of RESOURCE STATUS UPDATE X2 message IS NOT IMPLEMENTED");
2980NrGnbRrc::DoRecvUeData(NrEpcX2SapUser::UeDataParams params)
2982 NS_LOG_FUNCTION(
this);
2984 NS_LOG_LOGIC(
"Recv UE DATA FORWARDING through X2 interface");
2985 NS_LOG_LOGIC(
"sourceCellId = " << params.sourceCellId);
2986 NS_LOG_LOGIC(
"targetCellId = " << params.targetCellId);
2987 NS_LOG_LOGIC(
"gtpTeid = " << params.gtpTeid);
2988 NS_LOG_LOGIC(
"ueData = " << params.ueData);
2989 NS_LOG_LOGIC(
"ueData size = " << params.ueData->GetSize());
2991 auto teidInfoIt = m_x2uTeidInfoMap.find(params.gtpTeid);
2992 if (teidInfoIt != m_x2uTeidInfoMap.end())
2994 GetUeManager(teidInfoIt->second.rnti)->SendData(teidInfoIt->second.drbid, params.ueData);
2998 NS_FATAL_ERROR(
"X2-U data received but no X2uTeidInfo found");
3003NrGnbRrc::DoRecvHandoverCancel(NrEpcX2SapUser::HandoverCancelParams params)
3005 NS_LOG_FUNCTION(
this);
3007 NS_LOG_LOGIC(
"Recv X2 message: HANDOVER CANCEL");
3009 NS_LOG_LOGIC(
"oldGnbUeX2apId = " << params.oldGnbUeX2apId);
3010 NS_LOG_LOGIC(
"newGnbUeX2apId = " << params.newGnbUeX2apId);
3011 NS_LOG_LOGIC(
"sourceCellId = " << params.sourceCellId);
3012 NS_LOG_LOGIC(
"targetCellId = " << params.targetCellId);
3013 NS_LOG_LOGIC(
"cause = " << params.cause);
3015 uint16_t rnti = params.newGnbUeX2apId;
3019 ueManager->RecvHandoverCancel(params);
3020 GetUeManager(rnti)->RecvIdealUeContextRemoveRequest(rnti);
3025NrGnbRrc::DoAllocateTemporaryCellRnti(uint8_t componentCarrierId)
3027 NS_LOG_FUNCTION(
this << +componentCarrierId);
3029 if (IsMaxSrsReached())
3031 NS_LOG_WARN(
"Not enough SRS configuration indices, UE context not created");
3034 return AddUe(NrUeManager::INITIAL_RANDOM_ACCESS, componentCarrierId);
3038NrGnbRrc::DoRrcConfigurationUpdateInd(NrGnbCmacSapUser::UeConfig cmacParams)
3040 Ptr<NrUeManager> ueManager =
GetUeManager(cmacParams.m_rnti);
3041 ueManager->CmacUeConfigUpdateInd(cmacParams);
3045NrGnbRrc::DoNotifyLcConfigResult(uint16_t rnti, uint8_t lcid,
bool success)
3047 NS_LOG_FUNCTION(
this << (uint32_t)rnti);
3048 NS_FATAL_ERROR(
"not implemented");
3052NrGnbRrc::DoAddUeMeasReportConfigForHandover(NrRrcSap::ReportConfigEutra reportConfig)
3054 NS_LOG_FUNCTION(
this);
3056 m_handoverMeasIds.insert(measIds.begin(), measIds.end());
3061NrGnbRrc::DoAddUeMeasReportConfigForComponentCarrier(NrRrcSap::ReportConfigEutra reportConfig)
3063 NS_LOG_FUNCTION(
this);
3065 m_componentCarrierMeasIds.insert(measId);
3070NrGnbRrc::DoSetNumberOfComponentCarriers(uint16_t numberOfComponentCarriers)
3072 m_numberOfComponentCarriers = numberOfComponentCarriers;
3076NrGnbRrc::DoTriggerHandover(uint16_t rnti, uint16_t targetCellId)
3078 NS_LOG_FUNCTION(
this << rnti << targetCellId);
3080 bool isHandoverAllowed =
true;
3083 NS_ASSERT_MSG(ueManager,
"Cannot find UE context with RNTI " << rnti);
3085 if (m_anrSapProvider !=
nullptr && !
HasCellId(targetCellId))
3088 bool noHo = m_anrSapProvider->
GetNoHo(targetCellId);
3089 bool noX2 = m_anrSapProvider->
GetNoX2(targetCellId);
3090 NS_LOG_DEBUG(
this <<
" cellId="
3092 <<
" targetCellId=" << targetCellId <<
" NRT.NoHo=" << noHo
3093 <<
" NRT.NoX2=" << noX2);
3097 isHandoverAllowed =
false;
3098 NS_LOG_LOGIC(
this <<
" handover to cell " << targetCellId <<
" is not allowed by ANR");
3102 if (ueManager->GetState() != NrUeManager::CONNECTED_NORMALLY)
3104 isHandoverAllowed =
false;
3105 NS_LOG_LOGIC(
this <<
" handover is not allowed because the UE"
3106 <<
" rnti=" << rnti <<
" is in " << ToString(ueManager->GetState())
3110 if (isHandoverAllowed)
3113 ueManager->PrepareHandover(targetCellId);
3118NrGnbRrc::DoAddUeMeasReportConfigForAnr(NrRrcSap::ReportConfigEutra reportConfig)
3120 NS_LOG_FUNCTION(
this);
3122 m_anrMeasIds.insert(measId);
3127NrGnbRrc::DoSetPdschConfigDedicated(uint16_t rnti,
3128 NrRrcSap::PdschConfigDedicated pdschConfigDedicated)
3130 NS_LOG_FUNCTION(
this);
3132 ueManager->SetPdschConfigDedicated(pdschConfigDedicated);
3136NrGnbRrc::DoSendLoadInformation(NrEpcX2Sap::LoadInformationParams params)
3138 NS_LOG_FUNCTION(
this);
3146 NS_LOG_FUNCTION(
this);
3149 for (rnti = m_lastAllocatedRnti + 1; (rnti != m_lastAllocatedRnti - 1) && (!found); ++rnti)
3151 if ((rnti != 0) && (m_ueMap.find(rnti) == m_ueMap.end()))
3158 NS_ASSERT_MSG(found,
"no more RNTIs available (do you have more than 65535 UEs in a cell?)");
3159 m_lastAllocatedRnti = rnti;
3160 Ptr<NrUeManager> ueManager = CreateObject<NrUeManager>(
this, rnti, state, componentCarrierId);
3161 m_ccmRrcSapProvider->
AddUe(rnti, (uint8_t)state);
3162 m_ueMap.insert(std::pair<uint16_t, Ptr<NrUeManager>>(rnti, ueManager));
3163 ueManager->Configure();
3165 NS_LOG_DEBUG(
this <<
" New UE RNTI " << rnti <<
" cellId " << cellId <<
" srs CI "
3166 << ueManager->GetSrsConfigurationIndex());
3167 m_newUeContextTrace(cellId, rnti);
3172NrGnbRrc::RemoveUe(uint16_t rnti)
3174 NS_LOG_FUNCTION(
this << (uint32_t)rnti);
3175 auto it = m_ueMap.find(rnti);
3176 NS_ASSERT_MSG(it != m_ueMap.end(),
"request to remove UE info with unknown rnti " << rnti);
3177 uint64_t imsi = it->second->GetImsi();
3178 uint16_t srsCi = (*it).second->GetSrsConfigurationIndex();
3180 it->second->CancelPendingEvents();
3182 m_connectionReleaseTrace(imsi,
3186 for (uint16_t i = 0; i < m_numberOfComponentCarriers; i++)
3188 m_cmacSapProvider.at(i)->RemoveUe(rnti);
3189 m_cphySapProvider.at(i)->RemoveUe(rnti);
3191 if (m_s1SapProvider !=
nullptr)
3195 m_ccmRrcSapProvider->
RemoveUe(rnti);
3199 RemoveSrsConfigurationIndex(srsCi);
3206NrGnbRrc::GetRlcType(NrEpsBearer bearer)
3208 switch (m_epsBearerToRlcMapping)
3220 if (bearer.GetPacketErrorLossRate() > 1.0e-5)
3237 NS_LOG_FUNCTION(
this << cellId);
3239 if (m_anrSapProvider !=
nullptr)
3248 NS_LOG_FUNCTION(
this << csgId << csgIndication);
3249 for (std::size_t componentCarrierId = 0; componentCarrierId < m_sib1.size();
3250 componentCarrierId++)
3252 m_sib1.at(componentCarrierId).cellAccessRelatedInfo.csgIdentity = csgId;
3253 m_sib1.at(componentCarrierId).cellAccessRelatedInfo.csgIndication = csgIndication;
3254 m_cphySapProvider.at(componentCarrierId)
3255 ->SetSystemInformationBlockType1(m_sib1.at(componentCarrierId));
3260static const uint8_t SRS_ENTRIES = 9;
3265static const uint16_t g_srsPeriodicity[SRS_ENTRIES] = {0, 2, 5, 10, 20, 40, 80, 160, 320};
3271static const uint16_t g_srsCiLow[SRS_ENTRIES] = {0, 0, 2, 7, 17, 37, 77, 157, 317};
3277static const uint16_t g_srsCiHigh[SRS_ENTRIES] = {0, 1, 6, 16, 36, 76, 156, 316, 636};
3282 NS_LOG_FUNCTION(
this << p);
3283 for (uint32_t
id = 1;
id < SRS_ENTRIES; ++id)
3285 if (g_srsPeriodicity[
id] == p)
3287 m_srsCurrentPeriodicityId = id;
3292 std::ostringstream allowedValues;
3293 for (uint32_t
id = 1;
id < SRS_ENTRIES; ++id)
3295 allowedValues << g_srsPeriodicity[id] <<
" ";
3297 NS_FATAL_ERROR(
"illecit SRS periodicity value " << p
3298 <<
". Allowed values: " << allowedValues.str());
3304 NS_LOG_FUNCTION(
this);
3305 NS_ASSERT(m_srsCurrentPeriodicityId > 0);
3306 NS_ASSERT(m_srsCurrentPeriodicityId < SRS_ENTRIES);
3307 return g_srsPeriodicity[m_srsCurrentPeriodicityId];
3311NrGnbRrc::GetNewSrsConfigurationIndex()
3313 NS_LOG_FUNCTION(
this << m_ueSrsConfigurationIndexSet.size());
3315 NS_ASSERT(m_srsCurrentPeriodicityId > 0);
3316 NS_ASSERT(m_srsCurrentPeriodicityId < SRS_ENTRIES);
3317 NS_LOG_DEBUG(
this <<
" SRS p " << g_srsPeriodicity[m_srsCurrentPeriodicityId] <<
" set "
3318 << m_ueSrsConfigurationIndexSet.size());
3319 if (m_ueSrsConfigurationIndexSet.size() >= g_srsPeriodicity[m_srsCurrentPeriodicityId])
3321 NS_FATAL_ERROR(
"too many UEs ("
3322 << m_ueSrsConfigurationIndexSet.size() + 1
3323 <<
") for current SRS periodicity "
3324 << g_srsPeriodicity[m_srsCurrentPeriodicityId]
3325 <<
", consider increasing the value of ns3::NrGnbRrc::SrsPeriodicity");
3328 if (m_ueSrsConfigurationIndexSet.empty())
3331 m_lastAllocatedConfigurationIndex = g_srsCiLow[m_srsCurrentPeriodicityId];
3332 m_ueSrsConfigurationIndexSet.insert(m_lastAllocatedConfigurationIndex);
3337 auto rit = m_ueSrsConfigurationIndexSet.rbegin();
3338 NS_ASSERT(rit != m_ueSrsConfigurationIndexSet.rend());
3339 NS_LOG_DEBUG(
this <<
" lower bound " << (*rit) <<
" of "
3340 << g_srsCiHigh[m_srsCurrentPeriodicityId]);
3341 if ((*rit) < g_srsCiHigh[m_srsCurrentPeriodicityId])
3344 m_lastAllocatedConfigurationIndex = (*rit) + 1;
3345 m_ueSrsConfigurationIndexSet.insert(m_lastAllocatedConfigurationIndex);
3350 for (uint16_t srcCi = g_srsCiLow[m_srsCurrentPeriodicityId];
3351 srcCi < g_srsCiHigh[m_srsCurrentPeriodicityId];
3354 auto it = m_ueSrsConfigurationIndexSet.find(srcCi);
3355 if (it == m_ueSrsConfigurationIndexSet.end())
3357 m_lastAllocatedConfigurationIndex = srcCi;
3358 m_ueSrsConfigurationIndexSet.insert(srcCi);
3364 return m_lastAllocatedConfigurationIndex;
3368NrGnbRrc::RemoveSrsConfigurationIndex(uint16_t srcCi)
3370 NS_LOG_FUNCTION(
this << srcCi);
3371 auto it = m_ueSrsConfigurationIndexSet.find(srcCi);
3372 NS_ASSERT_MSG(it != m_ueSrsConfigurationIndexSet.end(),
3373 "request to remove unknown SRS CI " << srcCi);
3374 m_ueSrsConfigurationIndexSet.erase(it);
3378NrGnbRrc::IsMaxSrsReached()
3380 NS_ASSERT(m_srsCurrentPeriodicityId > 0);
3381 NS_ASSERT(m_srsCurrentPeriodicityId < SRS_ENTRIES);
3382 NS_LOG_DEBUG(
this <<
" SRS p " << g_srsPeriodicity[m_srsCurrentPeriodicityId] <<
" set "
3383 << m_ueSrsConfigurationIndexSet.size());
3384 return m_ueSrsConfigurationIndexSet.size() >= g_srsPeriodicity[m_srsCurrentPeriodicityId];
3388NrGnbRrc::GetLogicalChannelGroup(NrEpsBearer bearer)
3390 if (bearer.GetResourceType() > 0)
3401NrGnbRrc::GetLogicalChannelPriority(NrEpsBearer bearer)
3407NrGnbRrc::SendSystemInformation()
3411 for (
auto& it : m_componentCarrierPhyConf)
3413 uint8_t ccId = it.first;
3415 NrRrcSap::SystemInformation si;
3417 si.sib2.freqInfo.ulCarrierFreq = it.second->GetUlEarfcn();
3418 si.sib2.freqInfo.ulBandwidth = it.second->GetUlBandwidth();
3419 si.sib2.radioResourceConfigCommon.pdschConfigCommon.referenceSignalPower =
3420 m_cphySapProvider.at(ccId)->GetReferenceSignalPower();
3421 si.sib2.radioResourceConfigCommon.pdschConfigCommon.pb = 0;
3423 NrGnbCmacSapProvider::RachConfig rc = m_cmacSapProvider.at(ccId)->GetRachConfig();
3424 NrRrcSap::RachConfigCommon rachConfigCommon;
3425 rachConfigCommon.preambleInfo.numberOfRaPreambles = rc.numberOfRaPreambles;
3426 rachConfigCommon.raSupervisionInfo.preambleTransMax = rc.preambleTransMax;
3427 rachConfigCommon.raSupervisionInfo.raResponseWindowSize = rc.raResponseWindowSize;
3428 rachConfigCommon.txFailParam.connEstFailCount = rc.connEstFailCount;
3429 si.sib2.radioResourceConfigCommon.rachConfigCommon = rachConfigCommon;
3438 Simulator::Schedule(m_systemInformationPeriodicity, &NrGnbRrc::SendSystemInformation,
this);
3442NrGnbRrc::IsRandomAccessCompleted(uint16_t rnti)
3444 NS_LOG_FUNCTION(
this << (uint32_t)rnti);
3446 switch (ueManager->GetState())
3448 case NrUeManager::CONNECTED_NORMALLY:
3449 case NrUeManager::CONNECTION_RECONFIGURATION:
GNB bandwidth part representation.
Service Access Point (SAP) offered by the ANR instance to the eNodeB RRC instance.
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).
virtual void AddNeighbourRelation(uint16_t cellId)=0
Add a new Neighbour Relation entry.
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).
Service Access Point (SAP) offered by the eNodeB RRC instance to the ANR instance.
Service Access Point (SAP) offered by the Component Carrier Manager (CCM) instance to the eNodeB RRC ...
virtual void RemoveUe(uint16_t rnti)=0
Remove an existing UE.
virtual void AddUe(uint16_t rnti, uint8_t state)=0
Add a new UE in the NrGnbComponentCarrierManager.
Service Access Point (SAP) offered by the eNodeB RRC instance to the component carrier manager (CCM) ...
virtual void UeContextRelease(uint16_t rnti)=0
virtual void DoSendReleaseIndication(uint64_t imsi, uint16_t rnti, uint8_t bearerId)=0
Triggers epc-gnb-application to send ERAB Release Indication message towards MME.
virtual void SendLoadInformation(LoadInformationParams params)=0
virtual void SendHandoverPreparationFailure(HandoverPreparationFailureParams params)=0
virtual void SendHandoverCancel(HandoverCancelParams params)=0
Send handover Cancel to the target gNB.
virtual void SendHandoverRequestAck(HandoverRequestAckParams params)=0
This class contains the specification of EPS Bearers.
uint16_t GetPacketDelayBudgetMs() const
NrGbrQosInformation gbrQosInfo
GBR QOS information.
uint8_t GetResourceType() const
@ GBR_CONV_VOICE
GBR Conversational Voice.
void SetRnti(uint16_t rnti)
void SetForwardUpCallback(Callback< void, Ptr< Packet > > cb)
friend class NrMemberEpcGnbS1SapUser< NrGnbRrc >
allow MemberNrGnbRrcSapProvider<NrGnbRrc> class friend access
void ConfigureCarriers(std::map< uint8_t, Ptr< BandwidthPartGnb > > ccPhyConf)
Configure carriers.
NrGnbRrcSapProvider * GetNrGnbRrcSapProvider()
void ConnectionRejectedTimeout(uint16_t rnti)
friend class MemberNrAnrSapUser< NrGnbRrc >
allow MemberNrAnrSapUser<NrGnbRrc> class friend access
Ptr< NrUeManager > GetUeManager(uint16_t rnti)
void SetNrAnrSapProvider(NrAnrSapProvider *s)
friend class MemberNrCcmRrcSapUser< NrGnbRrc >
allow MemberNrCcmRrcSapUser<NrGnbRrc> class friend access
NrCcmRrcSapUser * GetNrCcmRrcSapUser()
uint8_t CellToComponentCarrierId(uint16_t cellId)
std::vector< uint8_t > AddUeMeasReportConfig(NrRrcSap::ReportConfigEutra config)
Add a new UE measurement reporting configuration.
friend class GnbRrcMemberNrGnbCmacSapUser
allow GnbRrcMemberNrGnbCmacSapUser class friend access
void AddX2Neighbour(uint16_t cellId)
NrHandoverManagementSapUser * GetNrHandoverManagementSapUser()
void SetNrCcmRrcSapProvider(NrCcmRrcSapProvider *s)
void HandoverJoiningTimeout(uint16_t rnti)
void ConnectionSetupTimeout(uint16_t rnti)
void SetNrGnbCphySapProvider(NrGnbCphySapProvider *s)
bool HasUeManager(uint16_t rnti) const
bool HasCellId(uint16_t cellId) const
NrGnbCmacSapUser * GetNrGnbCmacSapUser()
void SetEpcX2SapProvider(NrEpcX2SapProvider *s)
void DoSendReleaseDataRadioBearer(uint64_t imsi, uint16_t rnti, uint8_t bearerId)
This function acts as an interface to trigger Release indication messages towards gNB and EPC.
void SetCellId(uint16_t m_cellId)
bool SendData(Ptr< Packet > p)
static TypeId GetTypeId()
Get the type ID.
void SendHandoverRequest(uint16_t rnti, uint16_t cellId)
uint32_t GetSrsPeriodicity() const
friend class NrEpcX2SpecificEpcX2SapUser< NrGnbRrc >
allow NrMemberEpcGnbS1SapUser<NrGnbRrc> class friend access
uint16_t ComponentCarrierToCellId(uint8_t componentCarrierId)
NrGnbCphySapUser * GetNrGnbCphySapUser()
NrAnrSapUser * GetNrAnrSapUser()
void SetSrsPeriodicity(uint32_t p)
void ConnectionRequestTimeout(uint16_t rnti)
friend class MemberNrHandoverManagementSapUser< NrGnbRrc >
allow MemberNrHandoverManagementSapUser<NrGnbRrc> class friend access
NrEpcGnbS1SapUser * GetS1SapUser()
void SetNrGnbRrcSapUser(NrGnbRrcSapUser *s)
void ConfigureCell(const std::map< uint8_t, Ptr< BandwidthPartGnb > > &ccPhyConf)
Configure cell-specific parameters.
NrEpcX2SapUser * GetEpcX2SapUser()
void SetCsgId(uint32_t csgId, bool csgIndication)
Associate this RRC entity with a particular CSG information.
void HandoverLeavingTimeout(uint16_t rnti)
void SetNrMacSapProvider(NrMacSapProvider *s)
void SetS1SapProvider(NrEpcGnbS1SapProvider *s)
friend class MemberNrGnbRrcSapProvider< NrGnbRrc >
allow MemberNrGnbRrcSapProvider<NrGnbRrc> class friend access
void SetNrHandoverManagementSapProvider(NrHandoverManagementSapProvider *s)
void SetNrGnbCmacSapProvider(NrGnbCmacSapProvider *s)
Part of the RRC protocol. This Service Access Point (SAP) is used to let the gNB RRC receive a messag...
Part of the RRC protocol. This Service Access Point (SAP) is used by the gNB RRC to send messages to ...
virtual void SendSystemInformation(uint16_t cellId, 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 UE function.
virtual Ptr< Packet > EncodeHandoverCommand(RrcConnectionReconfiguration msg)=0
Encode handover command.
Service Access Point (SAP) offered by the handover algorithm instance to the eNodeB RRC instance.
Service Access Point (SAP) offered by the eNodeB RRC instance to the handover algorithm instance.
virtual void TransmitPdcpSdu(TransmitPdcpSduParameters params)=0
static TypeId GetTypeId()
Get the type ID.
void SetNrMacSapProvider(NrMacSapProvider *s)
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
static double ConvertPdschConfigDedicated2Double(PdschConfigDedicated pdschConfigDedicated)
NrRrcSap::RrcConnectionReconfiguration GetRrcConnectionReconfigurationForHandover(uint8_t componentCarrierId)
std::vector< NrEpcX2Sap::ErabToBeSetupItem > GetErabList()
void RecvRrcConnectionSetupCompleted(NrRrcSap::RrcConnectionSetupCompleted msg)
void SetSource(uint16_t sourceCellId, uint16_t sourceX2apId)
uint16_t GetSrsConfigurationIndex() const
void PrepareHandover(uint16_t cellId)
void RecvRrcConnectionRequest(NrRrcSap::RrcConnectionRequest msg)
void RecvHandoverCancel(NrEpcX2SapUser::HandoverCancelParams params)
void DoReceivePdcpSdu(NrPdcpSapUser::ReceivePdcpSduParameters params)
NrEpcX2Sap::HandoverPreparationFailureParams BuildHoPrepFailMsg()
build handover preparation failure message
void CancelPendingEvents()
void ScheduleRrcConnectionReconfiguration()
void SendData(uint8_t bid, Ptr< Packet > p)
void ConfigureMacPhy()
Configure MAC and PHY aspects.
void ReleaseDataRadioBearer(uint8_t drbid)
void Configure()
Perform post-creation configuration steps.
uint8_t GetComponentCarrierId() const
void CmacUeConfigUpdateInd(NrGnbCmacSapUser::UeConfig cmacParams)
void ConfigureSrb0()
Initialize the gNB side of SRB0.
void StartDataRadioBearers()
void RecvHandoverPreparationFailure(uint16_t cellId)
void InitialContextSetupRequest()
NrEpcX2Sap::HandoverCancelParams BuildHoCancelMsg()
build handover cancel message
void RecvRrcConnectionReestablishmentComplete(NrRrcSap::RrcConnectionReestablishmentComplete msg)
void SetImsi(uint64_t imsi)
void ConfigureSrb1()
Initialize the gNB side of SRB1.
void RecvRrcConnectionReconfigurationCompleted(NrRrcSap::RrcConnectionReconfigurationCompleted msg)
void SendRrcConnectionRelease()
This function acts as an interface to trigger the connection release towards gNB, EPC and UE.
void RecvHandoverRequestAck(NrEpcX2SapUser::HandoverRequestAckParams params)
void RecvUeContextRelease(NrEpcX2SapUser::UeContextReleaseParams params)
void RecvSnStatusTransfer(NrEpcX2SapUser::SnStatusTransferParams params)
void CompleteSetupUe(NrGnbRrcSapProvider::CompleteSetupUeParameters params)
void ConfigureSap()
Initialize the SAP objects.
void RecvRrcConnectionReestablishmentRequest(NrRrcSap::RrcConnectionReestablishmentRequest msg)
void SetSrsConfigurationIndex(uint16_t srsConfIndex)
void RecordDataRadioBearersToBeStarted()
void RecvMeasurementReport(NrRrcSap::MeasurementReport msg)
void SendUeContextRelease()
static TypeId GetTypeId()
Get the type ID.
void SetPdschConfigDedicated(NrRrcSap::PdschConfigDedicated pdschConfigDedicated)
NrRrcSap::RadioResourceConfigDedicated GetRadioResourceConfigForHandoverPreparationInfo()
void RecvIdealUeContextRemoveRequest(uint16_t rnti)
void SetupDataRadioBearer(NrEpsBearer bearer, uint8_t bearerId, uint32_t gtpTeid, Ipv4Address transportLayerAddress)
friend class NrPdcpSpecificNrPdcpSapUser< NrUeManager >
allow NrPdcpSpecificNrPdcpSapUser<NrUeManager> class friend access
BearerToBeSwitched structure.
uint8_t epsBearerId
Bearer ID.
PathSwitchRequestParameters structure.
std::list< BearerToBeSwitched > bearersToBeSwitched
list of bearers to be switched
uint32_t mmeUeS1Id
mmeUeS1Id in practice, we use the IMSI
NrEpsBearer erabLevelQosParameters
E-RAB level QOS parameters.
bool dlForwarding
DL forwarding.
Ipv4Address transportLayerAddress
transport layer address
ErabsSubjectToStatusTransferItem structure.
uint16_t dlPdcpSn
DL PDCP SN.
uint16_t ulPdcpSn
UL PDCP SN.
Parameters of the HANDOVER CANCEL message.
uint16_t targetCellId
target cell ID
uint16_t oldGnbUeX2apId
old gNB UE X2 AP ID
uint16_t newGnbUeX2apId
new gNB UE X2 AP ID
uint16_t sourceCellId
source cell ID
Parameters of the HANDOVER PREPARATION FAILURE message.
uint16_t oldGnbUeX2apId
old gNB UE X2 AP ID
uint16_t criticalityDiagnostics
criticality diagnostics
uint16_t targetCellId
target cell ID
uint16_t sourceCellId
source cell ID
Parameters of the HANDOVER REQUEST ACKNOWLEDGE message.
std::vector< ErabNotAdmittedItem > notAdmittedBearers
not admitted bearers
Ptr< Packet > rrcContext
RRC context.
uint16_t newGnbUeX2apId
new gNB UE X2 AP ID
uint16_t oldGnbUeX2apId
old gNB UE X2 AP ID
uint16_t targetCellId
target cell ID
uint16_t sourceCellId
source cell ID
std::vector< ErabAdmittedItem > admittedBearers
admitted bearers
Parameters of the HANDOVER REQUEST message.
uint16_t sourceCellId
source cell ID
uint64_t ueAggregateMaxBitRateDownlink
UE aggregate max bit rate downlink.
uint16_t targetCellId
target cell ID
uint32_t mmeUeS1apId
MME UE S1 AP ID.
std::vector< ErabToBeSetupItem > bearers
bearers
Ptr< Packet > rrcContext
RRC context.
uint64_t ueAggregateMaxBitRateUplink
UE aggregate max bit rate uplink.
uint16_t oldGnbUeX2apId
old gNB UE X2 AP ID
Parameters of the SN STATUS TRANSFER message.
std::vector< ErabsSubjectToStatusTransferItem > erabsSubjectToStatusTransferList
ERABs subject to status transfer list.
uint16_t oldGnbUeX2apId
old gNB UE X2 AP ID
uint16_t newGnbUeX2apId
new gNB UE X2 AP ID
uint16_t sourceCellId
source cell ID
uint16_t targetCellId
target cell ID
Parameters of the UE CONTEXT RELEASE message.
uint16_t oldGnbUeX2apId
old gNB UE X2 AP ID
uint16_t targetCellId
target cell ID
uint16_t sourceCellId
source cell ID
uint16_t newGnbUeX2apId
new gNB UE X2 AP ID
Parameters of the UE DATA primitive.
uint32_t gtpTeid
GTP TEID.
uint16_t targetCellId
target cell ID
uint16_t sourceCellId
source cell ID
Ptr< Packet > ueData
UE data.
AllocateNcRaPreambleReturnValue structure.
uint8_t raPrachMaskIndex
PRACH mask index.
bool valid
true if a valid RA config was allocated, false otherwise
uint8_t raPreambleId
random access preamble id
uint8_t connEstFailCount
the counter value for T300 timer expiration
uint8_t preambleTransMax
preamble transmit maximum
uint8_t raResponseWindowSize
RA response window size.
uint8_t numberOfRaPreambles
number of RA preambles
Parameters for [re]configuring the UE.
uint8_t m_transmissionMode
Parameters for [re]configuring the UE.
uint8_t m_transmissionMode
CompleteSetupUeParameters structure.
NrPdcpSapUser * srb1SapUser
SRB1 SAP user.
NrRlcSapUser * srb0SapUser
SRB0 SAP user.
SetupUeParameters structure.
NrPdcpSapProvider * srb1SapProvider
SRB1 SAP provider.
NrRlcSapProvider * srb0SapProvider
SRB0 SAP provider.
uint16_t rxSn
RX sequence number.
uint16_t txSn
TX sequence number.
uint8_t transmissionMode
transmission mode
SystemInformationBlockType1 sourceSystemInformationBlockType1
source system information block type 1
RadioResourceConfigDedicated sourceRadioResourceConfig
source radio resource config
MasterInformationBlock sourceMasterInformationBlock
source master information block
MeasConfig sourceMeasConfig
source measure config
uint16_t sourceUeIdentity
source UE identity
SystemInformationBlockType2 sourceSystemInformationBlockType2
source system information block type 2
uint32_t sourceDlCarrierFreq
source DL carrier frequency
uint16_t dlBandwidth
DL bandwidth.
uint16_t ulBandwidth
UL bandwidth.
uint32_t ulCarrierFreq
UL carrier frequency.
uint32_t dlCarrierFreq
DL carrier frequency.
int8_t qQualMin
INTEGER (-34..-3), actual value = IE value [dB].
int8_t qRxLevMin
INTEGER (-70..-22), actual value = IE value * 2 [dBm].
uint16_t ulBandwidth
UL bandwidth.
uint32_t ulCarrierFreq
UL carrier frequency.
HandoverPreparationInfo structure.
AsConfig asConfig
AS config.
std::list< ReportConfigToAddMod > reportConfigToAddModList
report config to add mod list
bool haveQuantityConfig
have quantity config?
bool haveSpeedStatePars
have speed state parameters?
std::list< MeasObjectToAddMod > measObjectToAddModList
measure object to add mod list
bool haveSmeasure
have S measure?
QuantityConfig quantityConfig
quantity config
bool haveMeasGapConfig
have measure gap config?
std::list< MeasIdToAddMod > measIdToAddModList
measure ID to add mod list
MeasIdToAddMod structure.
uint8_t measObjectId
measure object ID
uint8_t reportConfigId
report config ID
uint32_t carrierFreq
carrier frequency
uint16_t allowedMeasBandwidth
allowed measure bandwidth
uint8_t neighCellConfig
neighbor cell config
bool haveCellForWhichToReportCGI
have cell for which to report CGI?
bool presenceAntennaPort1
antenna port 1 present?
int8_t offsetFreq
offset frequency
MeasObjectToAddMod structure.
MeasObjectEutra measObjectEutra
measure object eutra
uint8_t measObjectId
measure object ID
uint8_t rsrpResult
the RSRP result
uint8_t rsrqResult
the RSRQ result
bool haveMeasResultNeighCells
have measure result neighbor cells
std::list< MeasResultServFreq > measResultServFreqList
MeasResultServFreqList-r10.
MeasResultPCell measResultPCell
measurement result primary cell
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
bool haveMeasResultServFreqList
has measResultServFreqList-r10
MeasurementReport structure.
MeasResults measResults
measure results
uint16_t newUeIdentity
new UE identity
RachConfigDedicated rachConfigDedicated
RACH config dedicated.
bool haveCarrierFreq
have carrier frequency?
uint16_t targetPhysCellId
target Phy cell ID
bool haveCarrierBandwidth
have carrier bandwidth?
bool haveRachConfigDedicated
Have RACH config dedicated?
CarrierBandwidthEutra carrierBandwidth
carrier bandwidth
CarrierFreqEutra carrierFreq
carrier frequency
RadioResourceConfigCommon radioResourceConfigCommon
radio resource config common
std::list< SCellToAddMod > sCellToAddModList
SCell to add mod list.
std::list< uint8_t > sCellToReleaseList
SCell to release list.
PdschConfigDedicated structure.
bool haveSoundingRsUlConfigDedicated
have sounding RS UL config dedicated?
SoundingRsUlConfigDedicated soundingRsUlConfigDedicated
sounding RS UL config dedicated
PdschConfigDedicated pdschConfigDedicated
PDSCH config dedicated.
AntennaInfoDedicated antennaInfo
antenna info
bool havePdschConfigDedicated
have PDSCH config dedicated?
bool haveAntennaInfoDedicated
have antenna info dedicated?
uint32_t plmnIdentity
PLMN identity.
uint8_t numberOfRaPreambles
number of RA preambles
uint8_t filterCoefficientRSRP
filter coefficient RSRP
uint8_t filterCoefficientRSRQ
filter coefficient RSRQ
uint8_t raResponseWindowSize
RA response window size.
uint8_t preambleTransMax
preamble transmit maximum
PreambleInfo preambleInfo
preamble info
RaSupervisionInfo raSupervisionInfo
RA supervision info.
TxFailParam txFailParam
txFailParams
uint8_t raPreambleIndex
RA preamble index.
uint8_t raPrachMaskIndex
RA PRACH mask index.
RachConfigCommon rachConfigCommon
RACH config common.
RachConfigCommon rachConfigCommon
RACH config common.
RadioResourceConfigDedicated structure.
PhysicalConfigDedicated physicalConfigDedicated
physical config dedicated
std::list< uint8_t > drbToReleaseList
DRB to release list.
bool havePhysicalConfigDedicated
have physical config dedicated?
Specifies criteria for triggering of an E-UTRA measurement reporting event.
enum ns3::NrRrcSap::ReportConfigEutra::@5 triggerQuantity
Trigger type enumeration.
enum ns3::NrRrcSap::ReportConfigEutra::@6 reportQuantity
Report type enumeration.
@ RSRP
Reference Signal Received Power.
@ RSRQ
Reference Signal Received Quality.
@ EVENT_A2
Event A2: Serving becomes worse than absolute threshold.
@ EVENT_A1
Event A1: Serving becomes better than absolute threshold.
@ EVENT_A4
Event A4: Neighbour becomes better than absolute threshold.
ThresholdEutra threshold2
Threshold for event A5.
enum ns3::NrRrcSap::ReportConfigEutra::@4 eventId
Event enumeration.
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
ReportConfigToAddMod structure.
uint8_t reportConfigId
report config ID
ReportConfigEutra reportConfigEutra
report config eutra
RrcConnectionReconfigurationCompleted structure.
RrcConnectionReconfiguration structure.
MobilityControlInfo mobilityControlInfo
mobility control info
bool haveNonCriticalExtension
bool haveMobilityControlInfo
have mobility control info
NonCriticalExtensionConfiguration nonCriticalExtension
bool haveMeasConfig
have measure config
RrcConnectionReestablishmentComplete structure.
RrcConnectionReestablishment structure.
RadioResourceConfigDedicated radioResourceConfigDedicated
radio resource config dedicated
uint8_t rrcTransactionIdentifier
RRC transaction identifier.
RrcConnectionReestablishmentRequest structure.
RrcConnectionReject structure.
uint8_t waitTime
wait time
RrcConnectionRelease structure.
uint8_t rrcTransactionIdentifier
RRC transaction identifier.
RrcConnectionRequest structure.
uint64_t ueIdentity
UE identity.
RrcConnectionSetupCompleted structure.
RrcConnectionSetup structure.
RadioResourceConfigDedicated radioResourceConfigDedicated
radio resource config dedicated
uint8_t rrcTransactionIdentifier
RRC transaction identifier.
uint16_t srsConfigIndex
SRS config index.
uint16_t srsBandwidth
SRS bandwidth.
enum ns3::NrRrcSap::ThresholdEutra::@2 choice
Threshold enumeration.
@ THRESHOLD_RSRQ
RSRQ is used for the threshold.
@ THRESHOLD_RSRP
RSRP is used for the threshold.
uint8_t connEstFailCount
Number of times that the UE detects T300 expiry on the same cell.