5G-LENA nr-v3.0-33-g7aea1e4
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-radio-environment-map-helper.h
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
3// Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4//
5// SPDX-License-Identifier: GPL-2.0-only
6
7#ifndef NR_RADIO_ENVIRONMENT_MAP_HELPER_H
8#define NR_RADIO_ENVIRONMENT_MAP_HELPER_H
9
10#include "ns3/net-device-container.h"
11#include "ns3/nr-gnb-phy.h"
12#include "ns3/nr-ue-phy.h"
13#include "ns3/simple-net-device.h"
14#include <ns3/mobility-helper.h>
15#include <ns3/object-factory.h>
16#include <ns3/three-gpp-propagation-loss-model.h>
17#include <ns3/three-gpp-spectrum-propagation-loss-model.h>
18
19#include <chrono>
20#include <fstream>
21
22namespace ns3
23{
24
25class Node;
26class NetDevice;
27class SpectrumChannel;
28class MobilityModel;
29class MobilityHelper;
30class ChannelConditionModel;
31class UniformPlanarArray;
32
92class NrRadioEnvironmentMapHelper : public Object
93{
94 public:
95 enum RemMode
96 {
97 BEAM_SHAPE,
98 COVERAGE_AREA,
99 UE_COVERAGE
100 };
101
106
111
112 // inherited from Object
113 void DoDispose() override;
114
119 static TypeId GetTypeId();
120
125 void SetRemMode(enum RemMode remType);
126
132 void SetSimTag(const std::string& simTag);
133
138 void SetMinX(double xMin);
139
144 void SetMinY(double yMin);
145
150 void SetMaxX(double xMax);
151
156 void SetMaxY(double yMax);
157
162 void SetResX(uint16_t xRes);
163
168 void SetResY(uint16_t yRes);
169
174 void SetZ(double z);
175
180 void SetNumOfItToAverage(uint16_t numOfIterationsToAverage);
181
186 void SetInstallationDelay(const Time& installationDelay);
187
192 RemMode GetRemMode() const;
193
197 double GetMinX() const;
198
202 double GetMinY() const;
203
207 double GetMaxX() const;
208
212 double GetMaxY() const;
213
218 uint16_t GetResX() const;
219
224 uint16_t GetResY() const;
225
229 double GetZ() const;
230
236 double WToDbm(double w) const;
237
243 double DbmToW(double dbm) const;
244
250 double DbToRatio(double dB) const;
251
257 double RatioToDb(double ratio) const;
258
269 void CreateRem(const NetDeviceContainer& rtdNetDev,
270 const Ptr<NetDevice>& rrdDevice,
271 uint8_t bwpId);
272
273 private:
278 struct RemPoint
279 {
280 Vector pos{0, 0, 0};
281 double avgSnrDb{0};
282 double avgSinrDb{0};
283 double avgSirDb{0};
284 double avRxPowerDbm{0};
285 };
286
291 struct RemDevice
292 {
293 Ptr<Node> node;
294 Ptr<SimpleNetDevice> dev;
295 Ptr<MobilityModel> mob;
296 Ptr<UniformPlanarArray> antenna;
297 double txPower{0};
298 double bandwidth{0};
299 double frequency{0};
300 uint16_t numerology{0};
301 Ptr<const SpectrumModel> spectrumModel{};
302
303 RemDevice()
304 {
305 node = CreateObject<Node>();
306 dev = CreateObject<SimpleNetDevice>();
307 node->AddDevice(dev);
308 MobilityHelper mobility;
309 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
310 mobility.Install(node);
311
312 mob = node->GetObject<MobilityModel>();
313 }
314 };
315
321 struct PropagationModels
322 {
323 Ptr<ThreeGppPropagationLossModel> remPropagationLossModelCopy;
324 Ptr<ThreeGppSpectrumPropagationLossModel> remSpectrumLossModelCopy;
325 };
326
331 void CreateListOfRemPoints();
332
336 void ConfigureRrd(const Ptr<NetDevice>& rrdDevice);
337
343 void ConfigureRtdList(const NetDeviceContainer& rtdDevs);
344
352 void DelayedInstall(const NetDeviceContainer& rtdNetDev, const Ptr<NetDevice>& rrdDevice);
353
359 void SaveAntennasWithUserDefinedBeams(const NetDeviceContainer& rtdNetDev,
360 const Ptr<NetDevice>& rrdDevice);
361
367 void CalcBeamShapeRemMap();
368
374 void CalcCoverageAreaRemMap();
375
383 void CalcUeCoverageRemMap();
384
389 Ptr<SpectrumValue> CalcRxPsdValue(RemDevice& device, RemDevice& otherDevice) const;
390
396 double CalculateSnr(const Ptr<SpectrumValue>& usefulSignal) const;
397
404 Ptr<SpectrumValue> GetMaxValue(const std::list<Ptr<SpectrumValue>>& values) const;
405
412 double CalculateMaxSnr(const std::list<Ptr<SpectrumValue>>& receivedPowerList) const;
413
420 double CalculateMaxSinr(const std::list<Ptr<SpectrumValue>>& receivedPowerList) const;
421
428 double CalculateMaxSir(const std::list<Ptr<SpectrumValue>>& receivedPowerList) const;
429
437 double CalculateSinr(const Ptr<SpectrumValue>& usefulSignal,
438 const std::list<Ptr<SpectrumValue>>& interferenceSignals) const;
439
447 double CalculateSir(const Ptr<SpectrumValue>& usefulSignal,
448 const std::list<Ptr<SpectrumValue>>& interferenceSignals) const;
449
455 double GetMaxValue(const std::list<double>& listOfValues) const;
456
462 double CalculateAggregatedIpsd(const std::list<Ptr<SpectrumValue>>& interferenceSignals);
463
468 double SumListElements(const std::list<double>& listOfValues);
469
473 void ConfigurePropagationModelsFactories(const Ptr<const NrPhy>& rtdPhy);
474
480 ObjectFactory ConfigureObjectFactory(const Ptr<Object>& object) const;
481
487 PropagationModels CreateTemporalPropagationModels() const;
488
492 void PrintProgressReport(uint32_t* remSizeNextReport);
493
497 void PrintGnuplottableGnbListToFile(const std::string& filename);
498
502 void PrintGnuplottableUeListToFile(const std::string& filename);
503
507 void PrintGnuplottableBuildingListToFile(const std::string& filename);
508
513 void PrintRemToFile();
514
515 /*
516 * Creates rem_plot${SimTag}.gnuplot file
517 */
518 void CreateCustomGnuplotFile();
519
523 void Finalize();
524
529 void ConfigureQuasiOmniBfv(RemDevice& device);
530
537 void ConfigureDirectPathBfv(RemDevice& device,
538 const RemDevice& otherDevice,
539 const Ptr<const UniformPlanarArray>& antenna);
540
541 std::list<RemDevice> m_remDev;
542 std::list<RemPoint> m_rem;
543
544 std::chrono::system_clock::time_point
545 m_remStartTime;
546
547 enum RemMode m_remMode;
548
549 double m_xMin{0};
550 double m_xMax{0};
551 uint16_t m_xRes{0};
552 double m_xStep{0};
553
554 double m_yMin{0};
555 double m_yMax{0};
556 uint16_t m_yRes{0};
557 double m_yStep{0};
558 double m_z{0};
559
560 uint16_t m_numOfIterationsToAverage{1};
561 Time m_installationDelay{Seconds(0)};
562
563 RemDevice m_rrd;
564
565 Ptr<NrPhy> m_rrdPhy;
566 std::map<const Ptr<NetDevice>, Ptr<NrPhy>>
567 m_rtdDeviceToPhy;
568 std::map<const Ptr<NetDevice>, Ptr<UniformPlanarArray>> m_deviceToAntenna;
569
570 Ptr<PropagationLossModel> m_propagationLossModel;
571 Ptr<PhasedArraySpectrumPropagationLossModel> m_phasedArraySpectrumLossModel;
572 ObjectFactory m_channelConditionModelFactory;
573 ObjectFactory m_matrixBasedChannelModelFactory;
574
575 Ptr<SpectrumValue> m_noisePsd; // noise figure PSD that will be used for calculations
576
577 std::string m_simTag;
578
579}; // end of `class NrRadioEnvironmentMapHelper`
580
581} // namespace ns3
582
583#endif // NR_RADIO_ENVIRONMENT_MAP_HELPER_H
void SetMaxY(double yMax)
Sets the max y coordinate of the map.
double DbToRatio(double dB) const
Convert from dB to ratio.
void SetInstallationDelay(const Time &installationDelay)
Sets the installation delay.
void SetMinX(double xMin)
Sets the min x coordinate of the map.
double WToDbm(double w) const
Convert from Watts to dBm.
void SetNumOfItToAverage(uint16_t numOfIterationsToAverage)
Sets the number of iterations to calculate the average of rem value.
RemMode GetRemMode() const
Get the type of REM Map to be generated.
void SetZ(double z)
Sets the z coordinate of the map.
void SetMinY(double yMin)
Sets the min y coordinate of the map.
void SetMaxX(double xMax)
Sets the max x coordinate of the map.
NrRadioEnvironmentMapHelper()
NrRadioEnvironmentMapHelper constructor.
double RatioToDb(double ratio) const
Convert from ratio to dB.
void SetRemMode(enum RemMode remType)
Set the type of REM Map to be generated.
void SetResY(uint16_t yRes)
Sets the resolution (number of points) of the map along the y axis.
void SetSimTag(const std::string &simTag)
Set simTag that will be concatenated to output file names.
double DbmToW(double dbm) const
Convert from dBm to Watts.
void CreateRem(const NetDeviceContainer &rtdNetDev, const Ptr< NetDevice > &rrdDevice, uint8_t bwpId)
This function is used for the creation of the REM map. When this function is called from an example,...
void SetResX(uint16_t xRes)
Sets the resolution (number of points) of the map along the x axis.