9#include <ns3/constant-position-mobility-model.h>
10#include <ns3/double.h>
11#include <ns3/isotropic-antenna-model.h>
13#include <ns3/mobility-helper.h>
14#include <ns3/node-container.h>
15#include <ns3/pointer.h>
16#include <ns3/simulator.h>
17#include <ns3/string.h>
19#include <ns3/three-gpp-antenna-model.h>
20#include <ns3/three-gpp-channel-model.h>
21#include <ns3/three-gpp-spectrum-propagation-loss-model.h>
22#include <ns3/two-ray-spectrum-propagation-loss-model.h>
23#include <ns3/uinteger.h>
24#include <ns3/uniform-planar-array.h>
57 void DoRun()
override;
104 :
TestCase(
"Check that the average of the Fluctuating Two Ray model is consistent with the "
105 "theoretical expectation")
120 twoRaySplm->AssignStreams(1);
123 double value = twoRaySplm->GetFtrFastFading(ftrParams);
132 return 2 * sigma * (1 + k);
138 std::array<double, NUM_VALUES> sigma;
139 std::array<double, NUM_VALUES> k;
140 std::array<double, NUM_VALUES> delta;
145 double power = std::pow(2, j);
204 uint16_t txNumAntennas,
205 uint16_t rxNumAntennas,
210 double expectedGain);
221 void DoRun()
override;
242 uint16_t txNumAntennas,
243 uint16_t rxNumAntennas,
251 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to "
252 "the number of antennas and the type of single element antenna"),
253 m_txAntElem(txAntElem),
254 m_rxAntElem(rxAntElem),
255 m_txNumAntennas(txNumAntennas),
256 m_rxNumAntennas(rxNumAntennas),
257 m_txPosVec(txPosVec),
258 m_rxPosVec(rxPosVec),
259 m_txBearing(txBearing),
260 m_rxBearing(rxBearing),
261 m_expectedGain(expectedGain)
273 twoRaySplm->AssignStreams(1);
277 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
288 txPos->SetAttribute(
"Position", VectorValue(
m_txPosVec));
289 rxPos->SetAttribute(
"Position", VectorValue(
m_rxPosVec));
304 txArray->SetBeamformingVector(txBfVec);
305 rxArray->SetBeamformingVector(rxBfVec);
308 double gainTxRx = twoRaySplm->CalcBeamformingGain(txPos, rxPos, txArray, rxArray);
309 double gainRxTx = twoRaySplm->CalcBeamformingGain(rxPos, txPos, rxArray, txArray);
315 "gain different from the theoretically expected value");
342 uint16_t txNumAntennas,
343 uint16_t rxNumAntennas,
345 std::string threeGppScenario);
375 void DoRun()
override;
387 static constexpr double M_BW{200e6};
405 uint16_t txNumAntennas,
406 uint16_t rxNumAntennas,
408 std::string threeGppScenario)
411 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to"
412 "the number of antennas and the type of single element antenna"),
413 m_txAntElem(txAntElem),
414 m_rxAntElem(rxAntElem),
415 m_txNumAntennas(txNumAntennas),
416 m_rxNumAntennas(rxNumAntennas),
418 m_threeGppScenario(threeGppScenario)
437 double powerTx = 0.0;
440 std::vector<int> rbsId;
442 rbsId.reserve(numRbs);
443 for (
uint32_t numrb = 0; numrb < numRbs; ++numrb)
453 rbsId.push_back(numrb);
458 double powerTxW = std::pow(10., (powerTx - 30) / 10);
459 double txPowerDensity = powerTxW /
M_BW;
461 for (
const auto& rbId : rbsId)
463 (*txPsd)[rbId] = txPowerDensity;
477 twoRaySplm->AssignStreams(1);
478 threeGppChannelModel->AssignStreams(1);
481 threeGppSplm->SetAttribute(
"ChannelModel",
PointerValue(threeGppChannelModel));
482 threeGppChannelModel->SetAttribute(
"ChannelConditionModel",
484 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
491 Vector txPosVec(0.0, 0.0, 0.0);
492 Vector rxPosVec(5.0, 0.0, 0.0);
493 positionAlloc->Add(txPosVec);
494 positionAlloc->Add(rxPosVec);
495 mobility.SetPositionAllocator(positionAlloc);
496 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
497 mobility.Install(
nodes);
504 txArray->SetAttribute(
"BearingAngle",
DoubleValue(0));
517 threeGppChannelModel->SetAttribute(
"Blockage",
BooleanValue(
false));
525 signalParams->psd = txPsd;
528 auto txBfVec = txArray->GetBeamformingVector(
Angles(rxPosVec, txPosVec));
529 txArray->SetBeamformingVector(txBfVec);
534 double threeGppGainMean = 0;
535 double twoRayGainMean = 0;
545 rxArray->SetAttribute(
"BearingAngle",
DoubleValue(-M_PI));
550 auto rxBfVec = rxArray->GetBeamformingVector(
Angles(txPosVec, rxPosVec));
551 rxArray->SetBeamformingVector(rxBfVec);
553 auto twoRayRxParams =
554 twoRaySplm->DoCalcRxPowerSpectralDensity(signalParams, txMob, rxMob, txArray, rxArray);
555 auto threeGppRayRxParams = threeGppSplm->DoCalcRxPowerSpectralDensity(signalParams,
563 twoRayGainMean += (twoRayRxPower / txPower);
564 threeGppGainMean += (threeGppRxPower / txPower);
571 "The 3GPP and Two Ray models should provide similar average channel gains");
597 const double maxTgppGain = tgpp->GetGainDb(
Angles(0.0, M_PI / 2));
608 Vector(0.0, 0.0, 0.0),
609 Vector(5.0, 0.0, 0.0),
613 TestCase::Duration::QUICK);
618 Vector(0.0, 0.0, 0.0),
619 Vector(5.0, 0.0, 0.0),
623 TestCase::Duration::QUICK);
628 Vector(0.0, 0.0, 0.0),
629 Vector(5.0, 0.0, 0.0),
633 TestCase::Duration::QUICK);
638 Vector(0.0, 0.0, 0.0),
639 Vector(5.0, 0.0, 0.0),
643 TestCase::Duration::QUICK);
648 Vector(0.0, 0.0, 0.0),
649 Vector(5.0, 0.0, 0.0),
653 TestCase::Duration::QUICK);
658 Vector(0.0, 0.0, 0.0),
659 Vector(5.0, 0.0, 0.0),
663 TestCase::Duration::QUICK);
668 Vector(0.0, 0.0, 0.0),
669 Vector(5.0, 0.0, 0.0),
673 TestCase::Duration::QUICK);
678 Vector(0.0, 0.0, 0.0),
679 Vector(5.0, 0.0, 0.0),
683 TestCase::Duration::QUICK);
688 Vector(0.0, 0.0, 0.0),
689 Vector(5.0, 0.0, 0.0),
692 10 * log10(4) + maxTgppGain),
693 TestCase::Duration::QUICK);
698 Vector(0.0, 0.0, 0.0),
699 Vector(5.0, 0.0, 0.0),
702 10 * log10(16) + maxTgppGain),
703 TestCase::Duration::QUICK);
708 Vector(0.0, 0.0, 0.0),
709 Vector(5.0, 0.0, 0.0),
712 10 * log10(64) + maxTgppGain),
713 TestCase::Duration::QUICK);
718 Vector(0.0, 0.0, 0.0),
719 Vector(5.0, 0.0, 0.0),
723 TestCase::Duration::QUICK);
728 Vector(0.0, 0.0, 0.0),
729 Vector(5.0, 0.0, 0.0),
732 10 * log10(4) + 2 * maxTgppGain),
733 TestCase::Duration::QUICK);
738 Vector(0.0, 0.0, 0.0),
739 Vector(5.0, 0.0, 0.0),
742 10 * log10(16) + 2 * maxTgppGain),
743 TestCase::Duration::QUICK);
748 Vector(0.0, 0.0, 0.0),
749 Vector(5.0, 0.0, 0.0),
752 10 * log10(64) + 2 * maxTgppGain),
753 TestCase::Duration::QUICK);
758 Vector(0.0, 0.0, 0.0),
759 Vector(5.0, 0.0, 0.0),
762 2 * 10 * log10(4) + 2 * maxTgppGain),
763 TestCase::Duration::QUICK);
768 Vector(0.0, 0.0, 0.0),
769 Vector(5.0, 0.0, 0.0),
772 2 * 10 * log10(16) + 2 * maxTgppGain),
773 TestCase::Duration::QUICK);
778 Vector(0.0, 0.0, 0.0),
779 Vector(5.0, 0.0, 0.0),
782 2 * 10 * log10(64) + 2 * maxTgppGain),
783 TestCase::Duration::QUICK);
790 TestCase::Duration::EXTENSIVE);
792 TestCase::Duration::EXTENSIVE);
794 TestCase::Duration::EXTENSIVE);
796 TestCase::Duration::EXTENSIVE);
798 TestCase::Duration::EXTENSIVE);
800 TestCase::Duration::EXTENSIVE);
802 TestCase::Duration::EXTENSIVE);
804 TestCase::Duration::EXTENSIVE);
806 TestCase::Duration::EXTENSIVE);
808 TestCase::Duration::EXTENSIVE);
810 TestCase::Duration::EXTENSIVE);
812 TestCase::Duration::EXTENSIVE);
814 TestCase::Duration::EXTENSIVE);
816 TestCase::Duration::EXTENSIVE);
818 TestCase::Duration::EXTENSIVE);
820 TestCase::Duration::EXTENSIVE);
822 TestCase::Duration::EXTENSIVE);
824 TestCase::Duration::EXTENSIVE);
826 TestCase::Duration::EXTENSIVE);
828 TestCase::Duration::EXTENSIVE);
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.
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.
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.
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 TwoRaySplmTestSuite myTestSuite