5G-LENA nr-v4.1
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-initial-association.h
1// Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#ifndef NR_INITIAL_ASSOC_H
6#define NR_INITIAL_ASSOC_H
7#include "ns3/nr-module.h"
8#include "ns3/object.h"
9
10namespace ns3
11{
12const uint16_t NR_NUM_BANDS_FOR_SSB = 20;
13const double TRANSMIT_POWER_INIT_ASSOC = 30.0;
14
17{
18 double rowAng = 90;
19 double colAng = 90;
20};
21
30
31class NrInitialAssociation : public Object
32{
33 public:
34 NrInitialAssociation() = default;
35
40 {
41 Ptr<ThreeGppChannelModel> channelModel{nullptr};
42 Ptr<ThreeGppPropagationLossModel> pathLossModel{nullptr};
43 Ptr<const SpectrumModel> spectralModel{nullptr};
44 Ptr<ThreeGppSpectrumPropagationLossModel> spectrumPropModel{nullptr};
45 };
46
50 {
51 Ptr<MobilityModel> ueMobility{nullptr};
52 Ptr<MobilityModel> gnbMobility{nullptr};
53 };
54
58 {
59 Ptr<UniformPlanarArray> gnbArrayModel{
60 nullptr};
61 std::vector<Ptr<UniformPlanarArray>>
63 };
64
68 {
69 ChannelParams chParams;
70 Mobilities mobility;
71 AntennaArrayModels antennaArrays;
72 double maxPsdFound = 0.0;
73 };
74
77 bool CheckNumBeamsAllowed() const;
78
81 static TypeId GetTypeId();
82
85 void SetNumMainInterfererGnb(uint8_t numInterfere);
86
89 uint8_t GetNumMainInterfererGnb() const;
90
94 void SetHandoffMargin(double margin);
95
98 double GetCarrierFrequency() const;
99
102 double GetHandoffMargin() const;
103
106 std::vector<double> GetRowBeamAngles() const;
107
110 void SetRowBeamAngles(std::vector<double> rowVect);
111
114 std::vector<double> GetColBeamAngles() const;
115
118 void SetColBeamAngles(std::vector<double> colVect);
119
122 void SetUeDevice(const Ptr<NetDevice>& ueDev);
123
126 void SetGnbDevices(const NetDeviceContainer& gnbDevices);
127
130 Ptr<const NetDevice> GetUeDevice() const;
131
138 void InitializeIntfSet(uint16_t numIntfs, bool useRelRsrp, double relRsrpThreshold);
139
143 std::vector<double> GetInterference(const std::vector<uint16_t>& idxVal) const;
144
149 double GetTotalInterference(const std::vector<double>& cumSumIntf) const;
150
158 size_t GetNumIntfGnbsByRelRsrp(const std::vector<double> cumSumIntf,
159 const double relRsrpThreshold,
160 const double totalInterference) const;
161
167 std::pair<Ptr<NetDevice>, double> FindAssociatedGnb();
168
171 Ptr<NetDevice> GetAssociatedGnb() const;
172
175 NetDeviceContainer GetInterferingGnbs() const;
176
180 double GetMaxRsrp(uint64_t gnbId) const;
181
185 NrAnglePair GetBestBfv(uint64_t gnbId) const;
186
189 double GetRelativeRsrpRatio() const;
190
193 void SetStartSsbRb(uint16_t startSsb);
194
197 void SetNumSsbRb(uint16_t numSsbRb);
198
201 double GetAssociatedRsrp() const;
202
205 void SetUeActivePanel(int8_t panelIndex) const;
206
209 uint8_t GetUeActivePanel() const;
210
213 void SetPrimaryCarrier(double index);
214
216 double GetPrimaryCarrier() const;
217
218 private:
221 LocalSearchParams ExtractUeParameters() const;
222
228 Ptr<UniformPlanarArray> ExtractGnbParameters(const Ptr<NetDevice>& gnbDevice,
229 LocalSearchParams& searchParam) const;
230
235 double ComputeMaxRsrp(const Ptr<NetDevice>& gnbDevice, LocalSearchParams& lsps);
236
240 double ComputeRxPsd(Ptr<const SpectrumSignalParameters> spectrumSigParam) const;
241
247 PhasedArrayModel::ComplexVector GenBeamforming(double angRow,
248 double angCol,
249 Ptr<UniformPlanarArray> gnbArrayModel) const;
250
254 double ComputeRsrpRatio(double totalRsrp, std::vector<uint16_t> idxVal);
255
258 void PopulateRsrps(LocalSearchParams& lsps);
259
260 /***
261 * @brief Parse string with angles and set column angles
262 * @param colAngles String with angles separated by vertical bar e.g. 0|10|20
263 */
264 void ParseColBeamAngles(std::string colAngles);
265 /***
266 * @brief Parse string with angles and set row angles
267 * @param rowAngles String with angles separated by vertical bar e.g. 0|10|20
268 */
269 void ParseRowBeamAngles(std::string rowAngles);
270
271 Ptr<const NetDevice> m_ueDevice{
272 nullptr};
273 NetDeviceContainer m_gnbDevices;
274 double m_freq;
275 double m_handoffMargin{0.0};
276 size_t m_startSsb{0};
277 size_t m_numBandsSsb{NR_NUM_BANDS_FOR_SSB};
278
279 uint8_t m_numMainInterfererGnb{6};
280 size_t m_numIntfGnbs{m_numMainInterfererGnb};
281 double m_rsrpRatio{0.0};
282 NetDeviceContainer m_intfGnbDevs;
283 std::vector<double> m_maxRsrps;
284 double m_rsrpAsscGnb;
285 Ptr<NetDevice> m_associatedGnb{nullptr};
286
287 std::vector<NrAnglePair> m_bestBfVectors;
288 PhasedArrayModel::ComplexVector m_beamformingVector;
290 std::vector<double> m_rowBeamAngles;
292 std::vector<double> m_colBeamAngles;
294
295 double m_primaryCarrierIndex{0};
296};
297} // namespace ns3
298#endif // NR_INITIAL_ASSOC_H
Ptr< const NetDevice > GetUeDevice() const
Get UE device for which initial association is required.
static TypeId GetTypeId()
Get the type ID.
void SetNumMainInterfererGnb(uint8_t numInterfere)
Set number of main interferer gNBs.
Ptr< NetDevice > GetAssociatedGnb() const
Get the gNB associated gNB with the UE.
void SetUeActivePanel(int8_t panelIndex) const
Set the active panel for the UE device in NrSpectrumPhy.
double GetAssociatedRsrp() const
Get RSRP of associated gNB.
std::vector< double > GetColBeamAngles() const
Get col angles of the beam used.
size_t GetNumIntfGnbsByRelRsrp(const std::vector< double > cumSumIntf, const double relRsrpThreshold, const double totalInterference) const
Get the number of interference gNB based on Relative RSRP value.
void SetPrimaryCarrier(double index)
Set the primary BWP or carrier.
double GetCarrierFrequency() const
Get carrier frequency.
void SetUeDevice(const Ptr< NetDevice > &ueDev)
Set UE device for which initial association is required.
uint8_t GetUeActivePanel() const
Get the index of the active panel for the UE device in NrSpectrumPhy.
void SetHandoffMargin(double margin)
Set hand off margin in dB.
void SetColBeamAngles(std::vector< double > colVect)
Set column beam angles.
NetDeviceContainer GetInterferingGnbs() const
Get the gNBs which are main interferer with the UE.
std::pair< Ptr< NetDevice >, double > FindAssociatedGnb()
Find the gNB associated with the UE.
bool CheckNumBeamsAllowed() const
Check whether number of beams is corresponds to standard.
void InitializeIntfSet(uint16_t numIntfs, bool useRelRsrp, double relRsrpThreshold)
Create a container of gNBs forming a main interfering set with the UE.
double GetTotalInterference(const std::vector< double > &cumSumIntf) const
Calculate total interference based on RSRP values from gNBs.
std::vector< double > GetInterference(const std::vector< uint16_t > &idxVal) const
Calculate the cumulative sum of RSRP values from gNBs.
double GetPrimaryCarrier() const
Get the primary BWP or carrier.
void SetRowBeamAngles(std::vector< double > rowVect)
Set row beam angles.
uint8_t GetNumMainInterfererGnb() const
Get number of main interferer gNBs.
NrAnglePair GetBestBfv(uint64_t gnbId) const
Get the best beam from a given gNB to the UE.
void SetGnbDevices(const NetDeviceContainer &gnbDevices)
Set gnb devices among which association is done.
void SetStartSsbRb(uint16_t startSsb)
Set start RB for SSB.
double GetHandoffMargin() const
Get handoff margin.
double GetMaxRsrp(uint64_t gnbId) const
Get the max RSRP from a given gNB.
double GetRelativeRsrpRatio() const
Get relative RSRP of remaining gNBs to that of the main one.
std::vector< double > GetRowBeamAngles() const
Get row angles of the beam used.
void SetNumSsbRb(uint16_t numSsbRb)
Set number of RBs for association.
Angle pair in degrees for the row and column angle of beam direction for uniform planar array NrIniti...
AntennaArrayModels struct to store copy of antenna array of gNB and UE to do beamforming later.
std::vector< Ptr< UniformPlanarArray > > ueArrayModel
Copy of UE antenna panels' array model.
Ptr< UniformPlanarArray > gnbArrayModel
Copy of gNB antenna array model. Modified to reduce complexity.
ChannelParams struct to set channel model, pathloss model, spectral model and spectrumprop model to e...
LocalSearchParams struct format to keep ChannelParams, Mobilities, and AntennaArrayModels of UE and g...
Mobilities struct to keep mobility model of ue and gNB.