8#include "ns3/boolean.h"
10#include "ns3/constant-position-mobility-model.h"
11#include "ns3/double.h"
12#include "ns3/isotropic-antenna-model.h"
14#include "ns3/mobility-helper.h"
15#include "ns3/node-container.h"
16#include "ns3/pointer.h"
17#include "ns3/simulator.h"
18#include "ns3/string.h"
20#include "ns3/three-gpp-antenna-model.h"
21#include "ns3/three-gpp-channel-model.h"
22#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
23#include "ns3/two-ray-spectrum-propagation-loss-model.h"
24#include "ns3/uinteger.h"
25#include "ns3/uniform-planar-array.h"
58 void DoRun()
override;
105 :
TestCase(
"Check that the average of the Fluctuating Two Ray model is consistent with the "
106 "theoretical expectation")
121 twoRaySplm->AssignStreams(1);
124 double value = twoRaySplm->GetFtrFastFading(ftrParams);
133 return 2 * sigma * (1 + k);
139 std::array<double, NUM_VALUES> sigma;
140 std::array<double, NUM_VALUES> k;
141 std::array<double, NUM_VALUES> delta;
146 double power = std::pow(2, j);
205 uint16_t txNumAntennas,
206 uint16_t rxNumAntennas,
211 double expectedGain);
222 void DoRun()
override;
243 uint16_t txNumAntennas,
244 uint16_t rxNumAntennas,
252 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to "
253 "the number of antennas and the type of single element antenna"),
274 twoRaySplm->AssignStreams(1);
278 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
289 txPos->SetAttribute(
"Position", VectorValue(
m_txPosVec));
290 rxPos->SetAttribute(
"Position", VectorValue(
m_rxPosVec));
305 txArray->SetBeamformingVector(txBfVec);
306 rxArray->SetBeamformingVector(rxBfVec);
309 double gainTxRx = twoRaySplm->CalcBeamformingGain(txPos, rxPos, txArray, rxArray);
310 double gainRxTx = twoRaySplm->CalcBeamformingGain(rxPos, txPos, rxArray, txArray);
316 "gain different from the theoretically expected value");
343 uint16_t txNumAntennas,
344 uint16_t rxNumAntennas,
346 std::string threeGppScenario);
376 void DoRun()
override;
388 static constexpr double M_BW{200e6};
406 uint16_t txNumAntennas,
407 uint16_t rxNumAntennas,
409 std::string threeGppScenario)
412 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to"
413 "the number of antennas and the type of single element antenna"),
438 double powerTx = 0.0;
441 std::vector<int> rbsId;
443 rbsId.reserve(numRbs);
444 for (
uint32_t numrb = 0; numrb < numRbs; ++numrb)
454 rbsId.push_back(numrb);
459 double powerTxW = std::pow(10., (powerTx - 30) / 10);
460 double txPowerDensity = powerTxW /
M_BW;
462 for (
const auto& rbId : rbsId)
464 (*txPsd)[rbId] = txPowerDensity;
478 twoRaySplm->AssignStreams(1);
479 threeGppChannelModel->AssignStreams(1);
482 threeGppSplm->SetAttribute(
"ChannelModel",
PointerValue(threeGppChannelModel));
483 threeGppChannelModel->SetAttribute(
"ChannelConditionModel",
485 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
492 Vector txPosVec(0.0, 0.0, 0.0);
493 Vector rxPosVec(5.0, 0.0, 0.0);
494 positionAlloc->Add(txPosVec);
495 positionAlloc->Add(rxPosVec);
496 mobility.SetPositionAllocator(positionAlloc);
497 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
498 mobility.Install(
nodes);
505 txArray->SetAttribute(
"BearingAngle",
DoubleValue(0));
518 threeGppChannelModel->SetAttribute(
"Blockage",
BooleanValue(
false));
526 signalParams->psd = txPsd;
529 auto txBfVec = txArray->GetBeamformingVector(
Angles(rxPosVec, txPosVec));
530 txArray->SetBeamformingVector(txBfVec);
535 double threeGppGainMean = 0;
536 double twoRayGainMean = 0;
546 rxArray->SetAttribute(
"BearingAngle",
DoubleValue(-M_PI));
551 auto rxBfVec = rxArray->GetBeamformingVector(
Angles(txPosVec, rxPosVec));
552 rxArray->SetBeamformingVector(rxBfVec);
554 auto twoRayRxParams =
555 twoRaySplm->DoCalcRxPowerSpectralDensity(signalParams, txMob, rxMob, txArray, rxArray);
556 auto threeGppRayRxParams = threeGppSplm->DoCalcRxPowerSpectralDensity(signalParams,
564 twoRayGainMean += (twoRayRxPower / txPower);
565 threeGppGainMean += (threeGppRxPower / txPower);
572 "The 3GPP and Two Ray models should provide similar average channel gains");
598 const double maxTgppGain = tgpp->GetGainDb(
Angles(0.0, M_PI / 2));
609 Vector(0.0, 0.0, 0.0),
610 Vector(5.0, 0.0, 0.0),
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),
693 10 * log10(4) + maxTgppGain),
699 Vector(0.0, 0.0, 0.0),
700 Vector(5.0, 0.0, 0.0),
703 10 * log10(16) + maxTgppGain),
709 Vector(0.0, 0.0, 0.0),
710 Vector(5.0, 0.0, 0.0),
713 10 * log10(64) + maxTgppGain),
719 Vector(0.0, 0.0, 0.0),
720 Vector(5.0, 0.0, 0.0),
729 Vector(0.0, 0.0, 0.0),
730 Vector(5.0, 0.0, 0.0),
733 10 * log10(4) + 2 * maxTgppGain),
739 Vector(0.0, 0.0, 0.0),
740 Vector(5.0, 0.0, 0.0),
743 10 * log10(16) + 2 * maxTgppGain),
749 Vector(0.0, 0.0, 0.0),
750 Vector(5.0, 0.0, 0.0),
753 10 * log10(64) + 2 * maxTgppGain),
759 Vector(0.0, 0.0, 0.0),
760 Vector(5.0, 0.0, 0.0),
763 2 * 10 * log10(4) + 2 * maxTgppGain),
769 Vector(0.0, 0.0, 0.0),
770 Vector(5.0, 0.0, 0.0),
773 2 * 10 * log10(16) + 2 * maxTgppGain),
779 Vector(0.0, 0.0, 0.0),
780 Vector(5.0, 0.0, 0.0),
783 2 * 10 * log10(64) + 2 * maxTgppGain),
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.
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.
constexpr double FtrSquaredNormExpectedMean(double sigma, double k) const
Compute the expected mean of the FTR squared norm.
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.
AttributeValue implementation for Boolean.
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.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
@ EXTENSIVE
Medium length test.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Hold an unsigned integer type.
#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 ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
Struct holding the Fluctuating Two Ray fast-fading model parameters.
static ThreeGppChannelTestSuite myTestSuite
Static variable for test initialization.