18 #include "ns3/abort.h"
19 #include "ns3/angles.h"
20 #include "ns3/channel-condition-model.h"
21 #include "ns3/config.h"
22 #include "ns3/constant-position-mobility-model.h"
23 #include "ns3/double.h"
24 #include "ns3/isotropic-antenna-model.h"
26 #include "ns3/node-container.h"
27 #include "ns3/pointer.h"
28 #include "ns3/simple-net-device.h"
29 #include "ns3/simulator.h"
30 #include "ns3/spectrum-signal-parameters.h"
31 #include "ns3/string.h"
33 #include "ns3/three-gpp-channel-model.h"
34 #include "ns3/three-gpp-spectrum-propagation-loss-model.h"
35 #include "ns3/uinteger.h"
36 #include "ns3/uniform-planar-array.h"
37 #include "ns3/wifi-spectrum-value-helper.h"
67 void DoRun()
override;
87 :
TestCase(
"Check the dimensions and the norm of the channel matrix")
106 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
108 double channelNorm = 0;
110 for (uint16_t cIndex = 0; cIndex < numTotalClusters; cIndex++)
112 double clusterNorm = 0;
113 for (uint64_t sIndex = 0; sIndex < txAntennaElements; sIndex++)
115 for (uint64_t uIndex = 0; uIndex < rxAntennaElements; uIndex++)
118 std::pow(std::abs(channelMatrix->
m_channel(uIndex, sIndex, cIndex)), 2);
121 channelNorm += clusterNorm;
130 uint8_t txAntennaElements[]{2, 2};
131 uint8_t rxAntennaElements[]{2, 2};
132 uint32_t updatePeriodMs = 100;
136 CreateObject<NeverLosChannelConditionModel>();
140 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
141 channelModel->SetAttribute(
"Scenario",
StringValue(
"RMa"));
142 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
187 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
192 txAntennaElements[0] * txAntennaElements[1],
193 "The third dimension of H should be equal to the number of tx antenna elements");
196 rxAntennaElements[0] * rxAntennaElements[1],
197 "The second dimension of H should be equal to the number of rx antenna elements");
200 uint16_t numIt = 1000;
201 for (uint16_t i = 0; i < numIt; i++)
216 double sampleMean = 0;
224 double sampleStd = 0;
227 sampleStd += ((i - sampleMean) * (i - sampleMean));
229 sampleStd = std::sqrt(sampleStd / (numIt - 1));
235 double t = (sampleMean - txAntennaElements[0] * txAntennaElements[1] * rxAntennaElements[0] *
236 rxAntennaElements[1]) /
237 (sampleMean / std::sqrt(numIt));
245 "We reject the hypothesis E[|H|^2] = M*N with a significance level of 0.05");
247 Simulator::Destroy();
274 void DoRun()
override;
298 :
TestCase(
"Check if the channel realizations are correctly updated during the simulation")
316 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
330 <<
" The channel matrix is not correctly updated");
339 uint8_t txAntennaElements[]{2, 2};
340 uint8_t rxAntennaElements[]{4, 4};
341 uint32_t updatePeriodMs = 100;
345 CreateObject<AlwaysLosChannelConditionModel>();
349 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
350 channelModel->SetAttribute(
"Scenario",
StringValue(
"UMa"));
351 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
397 uint32_t firstTimeMs =
411 Simulator::Schedule(
MilliSeconds(firstTimeMs + updatePeriodMs / 2),
423 Simulator::Schedule(
MilliSeconds(firstTimeMs + updatePeriodMs + 1),
434 Simulator::Destroy();
482 void DoRun()
override;
514 :
TestCase(
"Test case for the ThreeGppSpectrumPropagationLossModel class")
528 Vector aPos = thisDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
529 Vector bPos = otherDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
532 Angles completeAngle(bPos, aPos);
544 for (uint8_t i = 0; i <
first->GetSpectrumModel()->GetNumBands(); i++)
566 "The long term is not updated when the channel matrix is recomputed");
575 uint8_t txAntennaElements[]{4, 4};
576 uint8_t rxAntennaElements[]{4, 4};
585 CreateObject<ThreeGppSpectrumPropagationLossModel>();
589 "ChannelConditionModel",
612 Vector(15.0, 0.0, 10.0));
640 double txPower = 0.1;
641 uint32_t channelNumber = 1;
655 "The long term for the direct and the reverse channel are different");
661 txBfVector[0] = std::complex<double>(0.0, 0.0);
668 "Changing the BF vectors the rx PSD does not change");
675 params{lossModel, txParams, txMob, rxMob, rxPsdOld, txAntenna, rxAntenna};
682 Simulator::Destroy();
Test case for the ThreeGppChannelModel class.
void DoRun() override
Build the test scenario.
ThreeGppChannelMatrixComputationTest()
Constructor.
~ThreeGppChannelMatrixComputationTest() override
Destructor.
std::vector< double > m_normVector
each element is the norm of a channel realization
void DoComputeNorm(Ptr< ThreeGppChannelModel > channelModel, Ptr< MobilityModel > txMob, Ptr< MobilityModel > rxMob, Ptr< PhasedArrayModel > txAntenna, Ptr< PhasedArrayModel > rxAntenna)
Compute the Frobenius norm of the channel matrix and stores it in m_normVector.
Test case for the ThreeGppChannelModel class.
void DoGetChannel(Ptr< ThreeGppChannelModel > channelModel, Ptr< MobilityModel > txMob, Ptr< MobilityModel > rxMob, Ptr< PhasedArrayModel > txAntenna, Ptr< PhasedArrayModel > rxAntenna, bool update)
This method is used to schedule the channel matrix computation at different time instants and to chec...
ThreeGppChannelMatrixUpdateTest()
Constructor.
void DoRun() override
Build the test scenario.
~ThreeGppChannelMatrixUpdateTest() override
Destructor.
Ptr< const ThreeGppChannelModel::ChannelMatrix > m_currentChannel
used by DoGetChannel to store the current channel matrix
Test suite for the ThreeGppChannelModel class.
ThreeGppChannelTestSuite()
Constructor.
Test case for the ThreeGppSpectrumPropagationLossModelTest class.
void DoRun() override
Build the test scenario.
ThreeGppSpectrumPropagationLossModelTest()
Constructor.
static bool ArePsdEqual(Ptr< SpectrumValue > first, Ptr< SpectrumValue > second)
Checks if two PSDs are equal.
~ThreeGppSpectrumPropagationLossModelTest() override
Destructor.
void CheckLongTermUpdate(const CheckLongTermUpdateParams ¶ms)
Test of the long term component is correctly updated when the channel matrix is recomputed.
void DoBeamforming(Ptr< NetDevice > thisDevice, Ptr< PhasedArrayModel > thisAntenna, Ptr< NetDevice > otherDevice, Ptr< PhasedArrayModel > otherAntenna)
Points the beam of thisDevice towards otherDevice.
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'.
MatrixArray class inherits ValArray class and provides additional interfaces to ValArray which enable...
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
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.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
ComplexVector GetBeamformingVector() const
Returns the beamforming vector that is currently being used.
virtual size_t GetNumberOfElements() const =0
Returns the number of antenna elements.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< SpectrumValue > Copy() const
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, Ptr< const PhasedArrayModel > aPhasedArrayModel, Ptr< const PhasedArrayModel > bPhasedArrayModel) const override
Computes the received PSD.
void SetChannelModelAttribute(const std::string &name, const AttributeValue &value)
Sets the value of an attribute belonging to the associated MatrixBasedChannelModel instance.
AttributeValue implementation for Time.
Hold an unsigned integer type.
uint16_t GetNumRows() const
uint16_t GetNumCols() const
uint16_t GetNumPages() const
Implements Wifi SpectrumValue for the 2.4 GHz ISM band only, with a 5 MHz spectrum resolution.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint8_t channel)
Creates a SpectrumValue instance that represents the TX Power Spectral Density of a wifi device corre...
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#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...
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
A structure that holds the parameters for the function CheckLongTermUpdate.
Ptr< ThreeGppSpectrumPropagationLossModel > lossModel
the ThreeGppSpectrumPropagationLossModel object used to compute the rx PSD
Ptr< MobilityModel > txMob
the mobility model of the tx device
Ptr< SpectrumValue > rxPsdOld
the previously received PSD
Ptr< SpectrumSignalParameters > txParams
the params of the tx signal
Ptr< PhasedArrayModel > rxAntenna
the antenna array of the rx device
Ptr< MobilityModel > rxMob
the mobility model of the rx device
Ptr< PhasedArrayModel > txAntenna
the antenna array of the tx device
Complex3DVector m_channel
Channel matrix H[u][s][n].
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
static ThreeGppChannelTestSuite myTestSuite
Static variable for test initialization.