5G-LENA nr-v4.0
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
bwp-manager-ue.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "bwp-manager-ue.h"
6
7#include "bwp-manager-algorithm.h"
8#include "nr-control-messages.h"
9
10#include "ns3/log.h"
11#include "ns3/pointer.h"
12
13namespace ns3
14{
15
16NS_LOG_COMPONENT_DEFINE("BwpManagerUe");
17NS_OBJECT_ENSURE_REGISTERED(BwpManagerUe);
18
21{
22 NS_LOG_FUNCTION(this);
23}
24
26{
27 NS_LOG_FUNCTION(this);
28}
29
30void
31BwpManagerUe::SetBwpManagerAlgorithm(const Ptr<BwpManagerAlgorithm>& algorithm)
32{
33 NS_LOG_FUNCTION(this);
34 m_algorithm = algorithm;
35}
36
37TypeId
39{
40 static TypeId tid = TypeId("ns3::BwpManagerUe")
42 .SetGroupName("nr")
43 .AddConstructor<BwpManagerUe>()
44 .AddAttribute("BwpManagerAlgorithm",
45 "The algorithm pointer",
46 PointerValue(),
47 MakePointerAccessor(&BwpManagerUe::m_algorithm),
48 MakePointerChecker<BwpManagerAlgorithm>());
49 return tid;
50}
51
52void
54{
55 NS_LOG_FUNCTION(this);
56 NS_ASSERT(m_algorithm != nullptr);
57
58 uint8_t bwpIndex = m_algorithm->GetBwpForEpsBearer(m_lcToBearerMap.at(params.lcid));
59
60 NS_LOG_DEBUG("BSR of size " << params.txQueueSize
61 << " from RLC for LCID = " << static_cast<uint32_t>(params.lcid)
62 << " traffic type " << m_lcToBearerMap.at(params.lcid)
63 << " reported to CcId " << static_cast<uint32_t>(bwpIndex));
64
65 m_componentCarrierLcMap.at(bwpIndex).at(params.lcid)->BufferStatusReport(params);
66}
67
68std::vector<NrUeCcmRrcSapProvider::LcsConfig>
71 NrMacSapUser* msu)
72{
73 NS_LOG_FUNCTION(this);
74
75 NS_LOG_INFO("For LC ID " << static_cast<uint32_t>(lcId) << " bearer qci "
76 << static_cast<uint32_t>(lcConfig.priority) << " from priority "
77 << static_cast<uint32_t>(lcConfig.priority));
78
79 // see nr-gnb-rrc.cc
80 m_lcToBearerMap.insert(std::make_pair(lcId, static_cast<NrEpsBearer::Qci>(lcConfig.priority)));
81
82 return NrSimpleUeComponentCarrierManager::DoAddLc(lcId, lcConfig, msu);
83}
84
88 NrMacSapUser* msu)
89{
90 NS_LOG_FUNCTION(this);
91
92 m_lcToBearerMap.insert(std::make_pair(lcId, static_cast<NrEpsBearer::Qci>(lcConfig.priority)));
93
95}
96
97uint8_t
99{
100 NS_LOG_FUNCTION(this);
101
102 return m.m_bwpIndex;
103}
104
105void
106BwpManagerUe::SetOutputLink(uint32_t sourceBwp, uint32_t outputBwp)
107{
108 NS_LOG_FUNCTION(this);
109 m_outputLinks.insert(std::make_pair(sourceBwp, outputBwp));
110}
111
112uint8_t
113BwpManagerUe::RouteOutgoingCtrlMsg(const Ptr<NrControlMessage>& msg, uint8_t sourceBwpId) const
114{
115 NS_LOG_FUNCTION(this);
116
117 NS_LOG_INFO("Msg type " << msg->GetMessageType() << " that wants to go out from UE");
118
119 if (m_outputLinks.empty())
120 {
121 NS_LOG_INFO("No linked BWP, routing outgoing msg to the source: " << +sourceBwpId);
122 return sourceBwpId;
123 }
124
125 auto it = m_outputLinks.find(sourceBwpId);
126 if (it == m_outputLinks.end())
127 {
128 NS_LOG_INFO("Source BWP not in the map, routing outgoing msg to itself: " << +sourceBwpId);
129 return sourceBwpId;
130 }
131
132 NS_LOG_INFO("routing outgoing msg to bwp: " << +it->second);
133 return it->second;
134}
135
136uint8_t
137BwpManagerUe::RouteIngoingCtrlMsg(const Ptr<NrControlMessage>& msg, uint8_t sourceBwpId) const
138{
139 NS_LOG_FUNCTION(this);
140
141 NS_LOG_INFO("Msg type " << msg->GetMessageType() << " comes from BWP " << +sourceBwpId
142 << " that wants to go in the UE, goes in BWP " << msg->GetSourceBwp());
143 return msg->GetSourceBwp();
144}
145
146Ptr<const BwpManagerAlgorithm>
148{
149 return m_algorithm;
150}
151
152} // namespace ns3
The BwpManagerUe class.
uint8_t RouteIngoingCtrlMsg(const Ptr< NrControlMessage > &msg, uint8_t sourceBwpId) const
Decide the BWP for the control message received.
NrMacSapUser * DoConfigureSignalBearer(uint8_t lcId, NrUeCmacSapProvider::LogicalChannelConfig lcConfig, NrMacSapUser *msu) override
Configure signal bearer function.
Ptr< const BwpManagerAlgorithm > GetAlgorithm() const
~BwpManagerUe() override
~BwpManagerUe
void SetBwpManagerAlgorithm(const Ptr< BwpManagerAlgorithm > &algorithm)
Set the algorithm.
uint8_t RouteDlHarqFeedback(const DlHarqInfo &m) const
The UE received a HARQ feedback from spectrum. Where this feedback should be forwarded?
std::vector< NrUeCcmRrcSapProvider::LcsConfig > DoAddLc(uint8_t lcId, NrUeCmacSapProvider::LogicalChannelConfig lcConfig, NrMacSapUser *msu) override
Add LC function.
static TypeId GetTypeId()
GetTypeId.
uint8_t RouteOutgoingCtrlMsg(const Ptr< NrControlMessage > &msg, uint8_t sourceBwpId) const
Route the outgoing messages to the right BWP.
void SetOutputLink(uint32_t sourceBwp, uint32_t outputBwp)
Set a mapping between two BWP.
BwpManagerUe()
BwpManagerUe constructor.
void DoTransmitBufferStatusReport(NrMacSapProvider::BufferStatusReportParameters params) override
Buffer status report function.
Component carrier manager implementation which simply does nothing.
virtual NrMacSapUser * DoConfigureSignalBearer(uint8_t lcId, NrUeCmacSapProvider::LogicalChannelConfig lcConfig, NrMacSapUser *msu)
Configure signal bearer function.
virtual std::vector< NrUeCcmRrcSapProvider::LcsConfig > DoAddLc(uint8_t lcId, NrUeCmacSapProvider::LogicalChannelConfig lcConfig, NrMacSapUser *msu)
Add LC function.
std::map< uint8_t, std::map< uint8_t, NrMacSapProvider * > > m_componentCarrierLcMap
Flow configuration per flow Id of this UE.
A struct that contains info for the DL HARQ.
uint8_t m_bwpIndex
BWP identifier, uniquely identifies BWP within the UE.