5#include "bwp-manager-gnb.h"
7#include "bwp-manager-algorithm.h"
8#include "nr-control-messages.h"
11#include "ns3/object-map.h"
12#include "ns3/pointer.h"
13#include "ns3/uinteger.h"
18NS_LOG_COMPONENT_DEFINE(
"BwpManagerGnb");
19NS_OBJECT_ENSURE_REGISTERED(BwpManagerGnb);
21BwpManagerGnb::BwpManagerGnb()
22 : NrRrComponentCarrierManager()
24 NS_LOG_FUNCTION(
this);
27BwpManagerGnb::~BwpManagerGnb()
29 NS_LOG_FUNCTION(
this);
33BwpManagerGnb::GetTypeId()
35 static TypeId tid = TypeId(
"ns3::BwpManagerGnb")
36 .SetParent<NrNoOpComponentCarrierManager>()
38 .AddConstructor<BwpManagerGnb>()
39 .AddAttribute(
"BwpManagerAlgorithm",
40 "The algorithm pointer",
42 MakePointerAccessor(&BwpManagerGnb::m_algorithm),
43 MakePointerChecker<BwpManagerAlgorithm>());
48BwpManagerGnb::SetBwpManagerAlgorithm(
const Ptr<BwpManagerAlgorithm>& algorithm)
50 NS_LOG_FUNCTION(
this);
51 m_algorithm = algorithm;
57 NS_ASSERT_MSG(m_ueInfo.find(params.
rnti) != m_ueInfo.end(),
58 "Trying to check the QoS of unknown UE");
59 NS_ASSERT_MSG(m_ueInfo.at(params.
rnti).m_rlcLcInstantiated.find(params.
lcid) !=
60 m_ueInfo.at(params.
rnti).m_rlcLcInstantiated.end(),
61 "Trying to check the QoS of unknown logical channel");
62 return (m_ueInfo[params.
rnti].m_rlcLcInstantiated[params.
lcid]).resourceType;
65std::vector<NrCcmRrcSapProvider::LcsConfig>
73 NS_LOG_FUNCTION(
this);
75 std::vector<NrCcmRrcSapProvider::LcsConfig> lcsConfig =
76 NrRrComponentCarrierManager::DoSetupDataRadioBearer(bearer,
86BwpManagerGnb::GetBwpIndex(uint16_t rnti, uint8_t lcid)
88 NS_LOG_FUNCTION(
this);
89 NS_ASSERT(m_algorithm !=
nullptr);
90 NS_ASSERT_MSG(m_ueInfo.find(rnti) != m_ueInfo.end(),
"Unknown UE");
91 NS_ASSERT_MSG(m_ueInfo.at(rnti).m_rlcLcInstantiated.find(lcid) !=
92 m_ueInfo.at(rnti).m_rlcLcInstantiated.end(),
93 "Unknown logical channel of UE");
95 uint8_t qci = m_ueInfo[rnti].m_rlcLcInstantiated[lcid].qci;
103BwpManagerGnb::PeekBwpIndex(uint16_t rnti, uint8_t lcid)
const
105 NS_LOG_FUNCTION(
this);
106 NS_ASSERT(m_algorithm !=
nullptr);
108 NS_ASSERT_MSG(m_ueInfo.find(rnti) != m_ueInfo.end(),
"Unknown UE");
109 NS_ASSERT_MSG(m_ueInfo.at(rnti).m_rlcLcInstantiated.find(lcid) !=
110 m_ueInfo.at(rnti).m_rlcLcInstantiated.end(),
111 "Unknown logical channel of UE");
113 uint8_t qci = m_ueInfo.at(rnti).m_rlcLcInstantiated.at(lcid).qci;
121BwpManagerGnb::RouteIngoingCtrlMsgs(
const Ptr<NrControlMessage>& msg, uint8_t sourceBwpId)
const
123 NS_LOG_FUNCTION(
this);
125 NS_LOG_INFO(
"Msg type " << msg->GetMessageType() <<
" from bwp " << +sourceBwpId
126 <<
" that wants to go in the gnb, goes in BWP " << msg->GetSourceBwp());
127 return msg->GetSourceBwp();
131BwpManagerGnb::RouteOutgoingCtrlMsg(
const Ptr<NrControlMessage>& msg, uint8_t sourceBwpId)
const
133 NS_LOG_FUNCTION(
this);
135 NS_LOG_INFO(
"Msg type " << msg->GetMessageType() <<
" from bwp " << +sourceBwpId
136 <<
" that wants to go out from gnb");
138 if (m_outputLinks.empty())
140 NS_LOG_INFO(
"No linked BWP, routing outgoing msg to the source: " << +sourceBwpId);
144 auto it = m_outputLinks.find(sourceBwpId);
145 if (it == m_outputLinks.end())
147 NS_LOG_INFO(
"Source BWP not in the map, routing outgoing msg to itself: " << +sourceBwpId);
151 NS_LOG_INFO(
"routing outgoing msg to bwp: " << +it->second);
156BwpManagerGnb::SetOutputLink(uint32_t sourceBwp, uint32_t outputBwp)
158 NS_LOG_FUNCTION(
this);
159 m_outputLinks.insert(std::make_pair(sourceBwp, outputBwp));
165 NS_LOG_FUNCTION(
this);
167 uint8_t bwpIndex = GetBwpIndex(params.
rnti, params.
lcid);
169 if (m_macSapProvidersMap.find(bwpIndex) != m_macSapProvidersMap.end())
171 m_macSapProvidersMap.find(bwpIndex)->second->BufferStatusReport(params);
175 NS_ABORT_MSG(
"Bwp index " << +bwpIndex <<
" not valid.");
182 NS_LOG_FUNCTION(
this);
183 std::map<uint16_t, NrUeInfo>::iterator rntiIt = m_ueInfo.find(txOpParams.
rnti);
184 NS_ASSERT_MSG(rntiIt != m_ueInfo.end(),
"could not find RNTI" << txOpParams.
rnti);
186 std::map<uint8_t, NrMacSapUser*>::iterator lcidIt =
187 rntiIt->second.m_ueAttached.find(txOpParams.
lcid);
188 NS_ASSERT_MSG(lcidIt != rntiIt->second.m_ueAttached.end(),
189 "could not find LCID " << (uint16_t)txOpParams.
lcid);
191 (*lcidIt).second->NotifyTxOpportunity(txOpParams);
197 NS_LOG_FUNCTION(
this);
198 NS_ASSERT(m_algorithm !=
nullptr);
199 NS_ASSERT_MSG(bsr.m_macCeType == nr::MacCeListElement_s::BSR,
200 "Received a Control Message not allowed " << bsr.m_macCeType);
201 NS_ASSERT_MSG(m_ccmMacSapProviderMap.find(componentCarrierId) != m_ccmMacSapProviderMap.end(),
202 "Mac sap provider does not exist.");
204 NS_LOG_DEBUG(
"Routing BSR for UE " << bsr.
m_rnti <<
" to source CC id "
205 <<
static_cast<uint32_t
>(componentCarrierId));
207 if (m_ccmMacSapProviderMap.find(componentCarrierId) != m_ccmMacSapProviderMap.end())
209 m_ccmMacSapProviderMap.find(componentCarrierId)->second->ReportMacCeToScheduler(bsr);
213 NS_ABORT_MSG(
"Bwp index not valid.");
218BwpManagerGnb::DoUlReceiveSr(uint16_t rnti, uint8_t componentCarrierId)
220 NS_LOG_FUNCTION(
this);
221 NS_ASSERT(m_algorithm !=
nullptr);
223 NS_LOG_DEBUG(
"Routing SR for UE " << rnti <<
" to source CC id "
224 <<
static_cast<uint32_t
>(componentCarrierId));
226 auto it = m_ccmMacSapProviderMap.find(componentCarrierId);
227 NS_ABORT_IF(it == m_ccmMacSapProviderMap.end());
229 m_ccmMacSapProviderMap.find(componentCarrierId)->second->ReportSrToScheduler(rnti);
This class contains the specification of EPS Bearers.
See section 4.3.14 macCEListElement.