18 #include <ns3/abort.h>
19 #include <ns3/config.h>
20 #include <ns3/constant-position-mobility-model.h>
21 #include <ns3/double.h>
22 #include <ns3/isotropic-antenna-model.h>
24 #include <ns3/mobility-helper.h>
25 #include <ns3/node-container.h>
26 #include <ns3/pointer.h>
27 #include <ns3/simulator.h>
28 #include <ns3/string.h>
30 #include <ns3/three-gpp-antenna-model.h>
31 #include <ns3/three-gpp-channel-model.h>
32 #include <ns3/three-gpp-spectrum-propagation-loss-model.h>
33 #include <ns3/two-ray-spectrum-propagation-loss-model.h>
34 #include <ns3/uinteger.h>
35 #include <ns3/uniform-planar-array.h>
68 void DoRun()
override;
75 double FtrSquaredNormAverage(
96 constexpr
double FtrSquaredNormExpectedMean(
double sigma,
double k)
const;
99 static constexpr uint32_t N_MEASUREMENTS{100000};
108 static constexpr uint8_t NUM_VALUES{3};
111 static constexpr uint16_t MAX_M_VALUE{1000};
115 :
TestCase(
"Check that the average of the Fluctuating Two Ray model is consistent with the "
116 "theoretical expectation")
130 auto twoRaySplm = CreateObject<TwoRaySpectrumPropagationLossModel>();
131 twoRaySplm->AssignStreams(1);
134 double value = twoRaySplm->GetFtrFastFading(ftrParams);
143 return 2 *
sigma * (1 +
k);
149 std::array<double, NUM_VALUES>
sigma;
150 std::array<double, NUM_VALUES>
k;
151 std::array<double, NUM_VALUES>
delta;
156 double power = std::pow(2, j);
163 auto unifRv = CreateObject<UniformRandomVariable>();
215 uint16_t txNumAntennas,
216 uint16_t rxNumAntennas,
221 double expectedGain);
232 void DoRun()
override;
253 uint16_t txNumAntennas,
254 uint16_t rxNumAntennas,
262 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to "
263 "the number of antennas and the type of single element antenna"),
264 m_txAntElem(txAntElem),
265 m_rxAntElem(rxAntElem),
266 m_txNumAntennas(txNumAntennas),
267 m_rxNumAntennas(rxNumAntennas),
268 m_txPosVec(txPosVec),
269 m_rxPosVec(rxPosVec),
270 m_txBearing(txBearing),
271 m_rxBearing(rxBearing),
272 m_expectedGain(expectedGain)
283 auto twoRaySplm = CreateObject<TwoRaySpectrumPropagationLossModel>();
284 twoRaySplm->AssignStreams(1);
287 auto channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
288 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
291 auto txArray = CreateObject<UniformPlanarArray>();
292 auto rxArray = CreateObject<UniformPlanarArray>();
297 auto txPos = CreateObject<ConstantPositionMobilityModel>();
298 auto rxPos = CreateObject<ConstantPositionMobilityModel>();
299 txPos->SetAttribute(
"Position", VectorValue(
m_txPosVec));
300 rxPos->SetAttribute(
"Position", VectorValue(
m_rxPosVec));
315 txArray->SetBeamformingVector(txBfVec);
316 rxArray->SetBeamformingVector(rxBfVec);
319 double gainTxRx = twoRaySplm->CalcBeamformingGain(txPos, rxPos, txArray, rxArray);
320 double gainRxTx = twoRaySplm->CalcBeamformingGain(rxPos, txPos, rxArray, txArray);
326 "gain different from the theoretically expected value");
353 uint16_t txNumAntennas,
354 uint16_t rxNumAntennas,
356 std::string threeGppScenario);
386 void DoRun()
override;
398 static constexpr
double M_BW{200e6};
416 uint16_t txNumAntennas,
417 uint16_t rxNumAntennas,
419 std::string threeGppScenario)
422 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to"
423 "the number of antennas and the type of single element antenna"),
424 m_txAntElem(txAntElem),
425 m_rxAntElem(rxAntElem),
426 m_txNumAntennas(txNumAntennas),
427 m_rxNumAntennas(rxNumAntennas),
429 m_threeGppScenario(threeGppScenario)
448 double powerTx = 0.0;
451 std::vector<int> rbsId;
453 rbsId.reserve(numRbs);
454 for (uint32_t numrb = 0; numrb < numRbs; ++numrb)
464 rbsId.push_back(numrb);
469 double powerTxW = std::pow(10., (powerTx - 30) / 10);
470 double txPowerDensity = powerTxW /
M_BW;
472 for (
const auto& rbId : rbsId)
474 (*txPsd)[rbId] = txPowerDensity;
484 auto twoRaySplm = CreateObject<TwoRaySpectrumPropagationLossModel>();
485 auto threeGppSplm = CreateObject<ThreeGppSpectrumPropagationLossModel>();
486 auto threeGppChannelModel = CreateObject<ThreeGppChannelModel>();
487 auto channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
488 twoRaySplm->AssignStreams(1);
489 threeGppChannelModel->AssignStreams(1);
492 threeGppSplm->SetAttribute(
"ChannelModel",
PointerValue(threeGppChannelModel));
493 threeGppChannelModel->SetAttribute(
"ChannelConditionModel",
495 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
502 Vector txPosVec(0.0, 0.0, 0.0);
503 Vector rxPosVec(5.0, 0.0, 0.0);
504 positionAlloc->Add(txPosVec);
505 positionAlloc->Add(rxPosVec);
506 mobility.SetPositionAllocator(positionAlloc);
507 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
511 auto txArray = CreateObject<UniformPlanarArray>();
515 txArray->SetAttribute(
"BearingAngle",
DoubleValue(0));
528 threeGppChannelModel->SetAttribute(
"Blockage",
BooleanValue(
false));
536 signalParams->
psd = txPsd;
539 auto txBfVec = txArray->GetBeamformingVector(
Angles(rxPosVec, txPosVec));
540 txArray->SetBeamformingVector(txBfVec);
545 double threeGppGainMean = 0;
546 double twoRayGainMean = 0;
552 auto rxArray = CreateObject<UniformPlanarArray>();
556 rxArray->SetAttribute(
"BearingAngle",
DoubleValue(-M_PI));
561 auto rxBfVec = rxArray->GetBeamformingVector(
Angles(txPosVec, rxPosVec));
562 rxArray->SetBeamformingVector(rxBfVec);
564 auto twoRayRxParams =
565 twoRaySplm->DoCalcRxPowerSpectralDensity(signalParams, txMob, rxMob, txArray, rxArray);
566 auto threeGppRayRxParams = threeGppSplm->DoCalcRxPowerSpectralDensity(signalParams,
574 twoRayGainMean += (twoRayRxPower / txPower);
575 threeGppGainMean += (threeGppRxPower / txPower);
582 "The 3GPP and Two Ray models should provide similar average channel gains");
606 auto iso = CreateObject<IsotropicAntennaModel>();
607 auto tgpp = CreateObject<ThreeGppAntennaModel>();
608 const double maxTgppGain = tgpp->GetGainDb(
Angles(0.0, M_PI / 2));
619 Vector(0.0, 0.0, 0.0),
620 Vector(5.0, 0.0, 0.0),
629 Vector(0.0, 0.0, 0.0),
630 Vector(5.0, 0.0, 0.0),
639 Vector(0.0, 0.0, 0.0),
640 Vector(5.0, 0.0, 0.0),
649 Vector(0.0, 0.0, 0.0),
650 Vector(5.0, 0.0, 0.0),
659 Vector(0.0, 0.0, 0.0),
660 Vector(5.0, 0.0, 0.0),
669 Vector(0.0, 0.0, 0.0),
670 Vector(5.0, 0.0, 0.0),
679 Vector(0.0, 0.0, 0.0),
680 Vector(5.0, 0.0, 0.0),
689 Vector(0.0, 0.0, 0.0),
690 Vector(5.0, 0.0, 0.0),
699 Vector(0.0, 0.0, 0.0),
700 Vector(5.0, 0.0, 0.0),
703 10 * log10(4) + maxTgppGain),
709 Vector(0.0, 0.0, 0.0),
710 Vector(5.0, 0.0, 0.0),
713 10 * log10(16) + maxTgppGain),
719 Vector(0.0, 0.0, 0.0),
720 Vector(5.0, 0.0, 0.0),
723 10 * log10(64) + maxTgppGain),
729 Vector(0.0, 0.0, 0.0),
730 Vector(5.0, 0.0, 0.0),
739 Vector(0.0, 0.0, 0.0),
740 Vector(5.0, 0.0, 0.0),
743 10 * log10(4) + 2 * maxTgppGain),
749 Vector(0.0, 0.0, 0.0),
750 Vector(5.0, 0.0, 0.0),
753 10 * log10(16) + 2 * maxTgppGain),
759 Vector(0.0, 0.0, 0.0),
760 Vector(5.0, 0.0, 0.0),
763 10 * log10(64) + 2 * maxTgppGain),
769 Vector(0.0, 0.0, 0.0),
770 Vector(5.0, 0.0, 0.0),
773 2 * 10 * log10(4) + 2 * maxTgppGain),
779 Vector(0.0, 0.0, 0.0),
780 Vector(5.0, 0.0, 0.0),
783 2 * 10 * log10(16) + 2 * maxTgppGain),
789 Vector(0.0, 0.0, 0.0),
790 Vector(5.0, 0.0, 0.0),
793 2 * 10 * log10(64) + 2 * maxTgppGain),
809 TestCase::EXTENSIVE);
811 TestCase::EXTENSIVE);
813 TestCase::EXTENSIVE);
815 TestCase::EXTENSIVE);
817 TestCase::EXTENSIVE);
819 TestCase::EXTENSIVE);
821 TestCase::EXTENSIVE);
823 TestCase::EXTENSIVE);
825 TestCase::EXTENSIVE);
827 TestCase::EXTENSIVE);
829 TestCase::EXTENSIVE);
831 TestCase::EXTENSIVE);
double f(double x, void *params)
Test case for the TwoRaySpectrumPropagationLossModel class.
uint16_t m_txNumAntennas
the number of antenna elements of the TX antenna panel
~ArrayResponseTest() override
Destructor.
uint16_t m_rxNumAntennas
the number of antenna elements of the RX antenna panel
static constexpr double TOLERANCE
Tolerance for testing value produced by the simulator against expected theoretical value,...
double m_rxBearing
the bearing angle of the RX antenna panel [rad]
Vector m_rxPosVec
the position of the RX
Vector m_txPosVec
the position of the TX
double m_txBearing
the bearing angle of the TX antenna panel [rad]
Ptr< AntennaModel > m_txAntElem
the antenna element of the TX antenna panel
double m_expectedGain
the gain which is theoretically expected [db]
void DoRun() override
Build the test scenario.
Ptr< AntennaModel > m_rxAntElem
the antenna element of the RX antenna panel
ArrayResponseTest(Ptr< AntennaModel > txAntElem, Ptr< AntennaModel > rxAntElem, uint16_t txNumAntennas, uint16_t rxNumAntennas, Vector txPosVec, Vector rxPosVec, double txBearing, double rxBearing, double expectedGain)
The constructor of the test case.
Test case for the TwoRaySpectrumPropagationLossModel class.
static constexpr uint32_t N_MEASUREMENTS
Number of samples to draw when populating the distribution.
FtrFadingModelAverageTest()
Constructor.
static constexpr uint16_t MAX_M_VALUE
Maximum value for the m parameter.
constexpr double FtrSquaredNormExpectedMean(double sigma, double k) const
Compute the expected mean of the FTR squared norm.
double FtrSquaredNormAverage(const TwoRaySpectrumPropagationLossModel::FtrParams &ftrParams) const
Compute the average of the FTR squared norm.
static constexpr uint8_t NUM_VALUES
Number of different values for each FTR parameter.
~FtrFadingModelAverageTest() override
Destructor.
static constexpr double TOLERANCE
Tolerance for testing FTR's expectations against theoretical values, expressed as a fraction of the e...
void DoRun() override
Build the test scenario.
Test case for the TwoRaySpectrumPropagationLossModel class.
Ptr< AntennaModel > m_txAntElem
the antenna element of the TX antenna panel
uint16_t m_rxNumAntennas
the number of antenna elements of the RX antenna panel
double m_fc
the carrier frequency
static constexpr double M_RB_WIDTH
The width of a RB, which in turn specifies the resolution of the generated PSDs.
double ComputePowerSpectralDensityOverallPower(Ptr< const SpectrumValue > psd)
Computes the overall power of a PSD.
static constexpr uint32_t N_MEASUREMENTS
Number of samples to draw when estimating the average.
static constexpr double M_BW
The simulation bandwidth. Results are independent from this parameter.
std::string m_threeGppScenario
the 3GPP scenario
~OverallGainAverageTest() override
Destructor.
Ptr< AntennaModel > m_rxAntElem
the antenna element of the RX antenna panel
OverallGainAverageTest(Ptr< AntennaModel > txAntElem, Ptr< AntennaModel > rxAntElem, uint16_t txNumAntennas, uint16_t rxNumAntennas, double fc, std::string threeGppScenario)
The constructor of the test case.
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double fc)
Creates a PSD centered at fc, of bandwidth bw and sub-bands of width rbWidth.
void DoRun() override
Build the test scenario.
static constexpr double TOLERANCE
Tolerance for testing average channel gain produced by the Two Ray model with respect to the 3GPP mod...
uint16_t m_txNumAntennas
the number of antenna elements of the TX antenna panel
Test suite for the TwoRaySpectrumPropagationLossModel class.
TwoRaySplmTestSuite()
Constructor.
Class holding the azimuth and inclination angles of spherical coordinates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Hold objects of type Ptr<T>.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Integral(const SpectrumValue &arg)
std::vector< BandInfo > Bands
Container of BandInfo.
static const double TOLERANCE
Tolerance used to check reciprocal of two numbers.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
Struct holding the Fluctuating Two Ray fast-fading model parameters.
static TwoRaySplmTestSuite myTestSuite