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;
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 sigma[j] = std::pow(2, j);
157 k[j] = std::pow(2, j);
161 auto unifRv = CreateObject<UniformRandomVariable>();
213 uint16_t txNumAntennas,
214 uint16_t rxNumAntennas,
219 double expectedGain);
230 void DoRun()
override;
251 uint16_t txNumAntennas,
252 uint16_t rxNumAntennas,
260 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to"
261 "the number of antennas and the type of single element antenna"),
262 m_txAntElem(txAntElem),
263 m_rxAntElem(rxAntElem),
264 m_txNumAntennas(txNumAntennas),
265 m_rxNumAntennas(rxNumAntennas),
266 m_txPosVec(txPosVec),
267 m_rxPosVec(rxPosVec),
268 m_txBearing(txBearing),
269 m_rxBearing(rxBearing),
270 m_expectedGain(expectedGain)
281 auto twoRaySplm = CreateObject<TwoRaySpectrumPropagationLossModel>();
282 twoRaySplm->AssignStreams(1);
285 auto channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
286 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
289 auto txArray = CreateObject<UniformPlanarArray>();
290 auto rxArray = CreateObject<UniformPlanarArray>();
295 auto txPos = CreateObject<ConstantPositionMobilityModel>();
296 auto rxPos = CreateObject<ConstantPositionMobilityModel>();
313 txArray->SetBeamformingVector(txBfVec);
314 rxArray->SetBeamformingVector(rxBfVec);
317 double gainTxRx = twoRaySplm->CalcBeamformingGain(txPos, rxPos, txArray, rxArray);
318 double gainRxTx = twoRaySplm->CalcBeamformingGain(rxPos, txPos, rxArray, txArray);
324 "gain different from the theoretically expected value");
351 uint16_t txNumAntennas,
352 uint16_t rxNumAntennas,
354 std::string threeGppScenario);
384 void DoRun()
override;
396 static constexpr double M_BW{200e6};
414 uint16_t txNumAntennas,
415 uint16_t rxNumAntennas,
417 std::string threeGppScenario)
420 :
TestCase(
"Check that the overall array response gain has the proper trend with respect to"
421 "the number of antennas and the type of single element antenna"),
422 m_txAntElem(txAntElem),
423 m_rxAntElem(rxAntElem),
424 m_txNumAntennas(txNumAntennas),
425 m_rxNumAntennas(rxNumAntennas),
427 m_threeGppScenario(threeGppScenario)
446 double powerTx = 0.0;
449 std::vector<int> rbsId;
451 rbsId.reserve(numRbs);
452 for (
uint32_t numrb = 0; numrb < numRbs; ++numrb)
462 rbsId.push_back(numrb);
467 double powerTxW = std::pow(10., (powerTx - 30) / 10);
468 double txPowerDensity = powerTxW /
M_BW;
470 for (
const auto& rbId : rbsId)
472 (*txPsd)[rbId] = txPowerDensity;
482 auto twoRaySplm = CreateObject<TwoRaySpectrumPropagationLossModel>();
483 auto threeGppSplm = CreateObject<ThreeGppSpectrumPropagationLossModel>();
484 auto threeGppChannelModel = CreateObject<ThreeGppChannelModel>();
485 auto channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
486 twoRaySplm->AssignStreams(1);
487 threeGppChannelModel->AssignStreams(1);
490 threeGppSplm->SetAttribute(
"ChannelModel",
PointerValue(threeGppChannelModel));
491 threeGppChannelModel->SetAttribute(
"ChannelConditionModel",
493 twoRaySplm->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
500 Vector txPosVec(0.0, 0.0, 0.0);
501 Vector rxPosVec(5.0, 0.0, 0.0);
502 positionAlloc->Add(txPosVec);
503 positionAlloc->Add(rxPosVec);
504 mobility.SetPositionAllocator(positionAlloc);
505 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
506 mobility.Install(
nodes);
509 auto txArray = CreateObject<UniformPlanarArray>();
513 txArray->SetAttribute(
"BearingAngle",
DoubleValue(0));
526 threeGppChannelModel->SetAttribute(
"Blockage",
BooleanValue(
false));
534 signalParams->psd = txPsd;
537 auto txBfVec = txArray->GetBeamformingVector(
Angles(rxPosVec, txPosVec));
538 txArray->SetBeamformingVector(txBfVec);
543 double threeGppGainMean = 0;
544 double twoRayGainMean = 0;
550 auto rxArray = CreateObject<UniformPlanarArray>();
554 rxArray->SetAttribute(
"BearingAngle",
DoubleValue(-M_PI));
559 auto rxBfVec = rxArray->GetBeamformingVector(
Angles(txPosVec, rxPosVec));
560 rxArray->SetBeamformingVector(rxBfVec);
563 twoRaySplm->DoCalcRxPowerSpectralDensity(signalParams, txMob, rxMob, txArray, rxArray);
564 auto threeGppRayRxPsd = threeGppSplm->DoCalcRxPowerSpectralDensity(signalParams,
572 twoRayGainMean += (twoRayRxPower / txPower);
573 threeGppGainMean += (threeGppRxPower / txPower);
580 "The 3GPP and Two Ray models should provide similar average channel gains");
604 auto iso = CreateObject<IsotropicAntennaModel>();
605 auto tgpp = CreateObject<ThreeGppAntennaModel>();
606 const double maxTgppGain = tgpp->GetGainDb(
Angles(0.0, M_PI / 2));
617 Vector(0.0, 0.0, 0.0),
618 Vector(5.0, 0.0, 0.0),
627 Vector(0.0, 0.0, 0.0),
628 Vector(5.0, 0.0, 0.0),
637 Vector(0.0, 0.0, 0.0),
638 Vector(5.0, 0.0, 0.0),
647 Vector(0.0, 0.0, 0.0),
648 Vector(5.0, 0.0, 0.0),
657 Vector(0.0, 0.0, 0.0),
658 Vector(5.0, 0.0, 0.0),
667 Vector(0.0, 0.0, 0.0),
668 Vector(5.0, 0.0, 0.0),
677 Vector(0.0, 0.0, 0.0),
678 Vector(5.0, 0.0, 0.0),
687 Vector(0.0, 0.0, 0.0),
688 Vector(5.0, 0.0, 0.0),
697 Vector(0.0, 0.0, 0.0),
698 Vector(5.0, 0.0, 0.0),
701 10 * log10(4) + maxTgppGain),
707 Vector(0.0, 0.0, 0.0),
708 Vector(5.0, 0.0, 0.0),
711 10 * log10(16) + maxTgppGain),
717 Vector(0.0, 0.0, 0.0),
718 Vector(5.0, 0.0, 0.0),
721 10 * log10(64) + maxTgppGain),
727 Vector(0.0, 0.0, 0.0),
728 Vector(5.0, 0.0, 0.0),
737 Vector(0.0, 0.0, 0.0),
738 Vector(5.0, 0.0, 0.0),
741 10 * log10(4) + 2 * maxTgppGain),
747 Vector(0.0, 0.0, 0.0),
748 Vector(5.0, 0.0, 0.0),
751 10 * log10(16) + 2 * maxTgppGain),
757 Vector(0.0, 0.0, 0.0),
758 Vector(5.0, 0.0, 0.0),
761 10 * log10(64) + 2 * maxTgppGain),
767 Vector(0.0, 0.0, 0.0),
768 Vector(5.0, 0.0, 0.0),
771 2 * 10 * log10(4) + 2 * maxTgppGain),
777 Vector(0.0, 0.0, 0.0),
778 Vector(5.0, 0.0, 0.0),
781 2 * 10 * log10(16) + 2 * maxTgppGain),
787 Vector(0.0, 0.0, 0.0),
788 Vector(5.0, 0.0, 0.0),
791 2 * 10 * log10(64) + 2 * maxTgppGain),
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.
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.
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>.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
@ EXTENSIVE
Medium length test.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
AttributeValue implementation for Vector.
#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.
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