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/ism-spectrum-value-helper.h"
25 #include "ns3/isotropic-antenna-model.h"
27 #include "ns3/node-container.h"
28 #include "ns3/pointer.h"
29 #include "ns3/rng-seed-manager.h"
30 #include "ns3/simple-net-device.h"
31 #include "ns3/simulator.h"
32 #include "ns3/spectrum-signal-parameters.h"
33 #include "ns3/string.h"
35 #include "ns3/three-gpp-antenna-model.h"
36 #include "ns3/three-gpp-channel-model.h"
37 #include "ns3/three-gpp-spectrum-propagation-loss-model.h"
38 #include "ns3/uinteger.h"
39 #include "ns3/uniform-planar-array.h"
68 uint32_t rxAntennaElements = 2,
70 uint32_t rxPorts = 1);
81 void DoRun()
override;
98 uint32_t m_txAntennaElements{4};
99 uint32_t m_rxAntennaElements{4};
100 uint32_t m_txPorts{1};
101 uint32_t m_rxPorts{1};
105 uint32_t txAntennaElements,
106 uint32_t rxAntennaElements,
109 :
TestCase(
"Check the dimensions and the norm of the channel matrix")
128 uint64_t txAntennaElements = txAntenna->
GetNumElems();
129 uint64_t rxAntennaElements = rxAntenna->
GetNumElems();
132 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
134 double channelNorm = 0;
136 for (uint16_t cIndex = 0; cIndex < numTotalClusters; cIndex++)
138 double clusterNorm = 0;
139 for (uint64_t sIndex = 0; sIndex < txAntennaElements; sIndex++)
141 for (uint64_t uIndex = 0; uIndex < rxAntennaElements; uIndex++)
144 std::pow(std::abs(channelMatrix->
m_channel(uIndex, sIndex, cIndex)), 2);
147 channelNorm += clusterNorm;
155 RngSeedManager::SetSeed(1);
156 RngSeedManager::SetRun(1);
158 uint32_t updatePeriodMs = 100;
162 CreateObject<NeverLosChannelConditionModel>();
166 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
167 channelModel->SetAttribute(
"Scenario",
StringValue(
"RMa"));
168 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
170 channelModel->AssignStreams(1);
206 "NumHorizontalPorts",
218 "NumHorizontalPorts",
222 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
228 "The third dimension of H should be equal to the number of tx antenna elements");
232 "The second dimension of H should be equal to the number of rx antenna elements");
235 uint16_t numIt = 1000;
236 for (uint16_t i = 0; i < numIt; i++)
251 double sampleMean = 0;
259 double sampleStd = 0;
262 sampleStd += ((i - sampleMean) * (i - sampleMean));
264 sampleStd = std::sqrt(sampleStd / (numIt - 1));
272 (sampleStd / std::sqrt(numIt));
280 "We reject the hypothesis E[|H|^2] = M*N with a significance level of 0.05");
282 Simulator::Destroy();
306 uint32_t rxAntennaElements = 4,
307 uint32_t txPorts = 1,
308 uint32_t rxPorts = 1);
319 void DoRun()
override;
347 uint32_t rxAntennaElements,
350 :
TestCase(
"Check if the channel realizations are correctly updated during the simulation")
372 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
386 <<
" The channel matrix is not correctly updated");
394 uint32_t updatePeriodMs = 100;
398 CreateObject<AlwaysLosChannelConditionModel>();
402 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
403 channelModel->SetAttribute(
"Scenario",
StringValue(
"UMa"));
404 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
441 "NumHorizontalPorts",
453 "NumHorizontalPorts",
459 uint32_t firstTimeMs =
473 Simulator::Schedule(
MilliSeconds(firstTimeMs + updatePeriodMs / 2),
485 Simulator::Schedule(
MilliSeconds(firstTimeMs + updatePeriodMs + 1),
496 Simulator::Destroy();
542 uint32_t rxAntennaElements = 4,
543 uint32_t txPorts = 1,
544 uint32_t rxPorts = 1);
554 void DoRun()
override;
583 uint32_t txAntennaElements,
584 uint32_t rxAntennaElements,
587 :
TestCase(
"Test case for the ThreeGppSpectrumPropagationLossModel class")
605 Vector aPos = thisDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
606 Vector bPos = otherDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
609 Angles completeAngle(bPos, aPos);
620 auto rxPsdNewParams =
params.lossModel->DoCalcRxPowerSpectralDensity(
params.txParams,
627 "The long term is not updated when the channel matrix is recomputed");
643 CreateObject<ThreeGppSpectrumPropagationLossModel>();
647 "ChannelConditionModel",
670 Vector(15.0, 0.0, 10.0));
686 "NumHorizontalPorts",
698 "NumHorizontalPorts",
707 double txPower = 0.1;
708 uint32_t channelNumber = 1;
722 "The long term for the direct and the reverse channel are different");
728 txBfVector[0] = std::complex<double>(0.0, 0.0);
735 "Changing the BF vectors the rx PSD does not change");
738 (*rxParamsOld->spectrumChannelMatrix == *rxParamsNew->spectrumChannelMatrix),
740 "Changing the BF should change de frequency domain channel matrix");
743 rxParamsOld = rxParamsNew;
747 params{lossModel, txParams, txMob, rxMob, rxParamsOld->psd, txAntenna, rxAntenna};
754 Simulator::Destroy();
800 void DoRun()
override;
804 :
TestCase(
"Check long term channel matrix generation when multiple ports at TX and RX are "
818 CreateObject<AlwaysLosChannelConditionModel>();
822 channelModel->SetAttribute(
"Frequency",
DoubleValue(2.0e9));
823 channelModel->SetAttribute(
"Scenario",
StringValue(
"RMa"));
824 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
860 "NumHorizontalPorts",
872 "NumHorizontalPorts",
884 channelModel->GetChannel(txMob, rxMob, txAntenna1, rxAntenna1);
889 CreateObject<ThreeGppSpectrumPropagationLossModel>();
892 threeGppSplm->CalcLongTerm(channelMatrixM0, txAntenna1, rxAntenna1);
904 "NumHorizontalPorts",
916 "NumHorizontalPorts",
923 threeGppSplm->CalcLongTerm(channelMatrixM0, txAntenna2, rxAntenna2);
935 "NumHorizontalPorts",
937 "AntennaHorizontalSpacing",
949 "NumHorizontalPorts",
951 "AntennaHorizontalSpacing",
955 Create<ThreeGppChannelModel::ChannelMatrix>();
956 channelMatrixMA->m_channel = *matrixA;
962 threeGppSplm->CalcLongTerm(channelMatrixMA, txAntenna3, rxAntenna3);
966 "Matrix B and Matrix C should be equal.");
969 Simulator::Destroy();
1048 std::valarray<std::complex<double>> testChannel,
1060 void DoRun()
override;
1075 std::valarray<std::complex<double>>
1082 std::string testCaseName,
1087 std::valarray<std::complex<double>> testChannel,
1089 :
TestCase(
"Test MIMO using dual polarization." + testCaseName),
1091 m_txParams(txParams),
1093 m_rxParams(rxParams),
1094 m_testChannel(testChannel),
1095 m_tolerance(tolerance)
1110 antenna = CreateObject<IsotropicAntennaModel>();
1114 antenna = CreateObject<ThreeGppAntennaModel>();
1117 return CreateObjectWithAttributes<UniformPlanarArray>(
"NumColumns",
1125 "NumHorizontalPorts",
1138 RngSeedManager::SetSeed(1);
1139 RngSeedManager::SetRun(1);
1142 channelModel->SetAttribute(
"Frequency",
DoubleValue(60e9));
1143 channelModel->SetAttribute(
"Scenario",
StringValue(
"RMa"));
1144 channelModel->SetAttribute(
"ChannelConditionModel",
1145 PointerValue(CreateObject<AlwaysLosChannelConditionModel>()));
1147 int64_t randomStream = 1;
1148 randomStream += channelModel->AssignStreams(randomStream);
1186 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
1198 std::valarray<std::complex<double>>(strongestClusterPtr, matrixSize));
1204 NS_LOG_INFO(
"Channel matrix:" << strongestCluster);
1205 NS_LOG_INFO(
"Test channel matrix: " << testChannel);
1210 "The strongest cluster and the test channel matrix should be almost equal");
1213 Simulator::Destroy();
1257 std::valarray<std::complex<double>> testChannel1 =
1258 {5.9, 5.9, 0, 0, 5.9, 5.9, 0, 0, 0, 0, -5.8, -5.8, 0, 0, -5.8, -5.8};
1283 {5, 5, 3, 3, 5, 5, 3, 3, 3, 3, -5, -5, 3, 3, -5, -5},
1302 {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -4, -4, 4, 4, -4, -4},
1316 "Face-to-face. 90 and 0 pol. slant angles.",
1321 {0, 0, 5.8, 5.8, 0, 0, 5.8, 5.8, 5.9, 5.9, 0, 0, 5.9, 5.9, 0, 0},
1340 "angles. 0 and 0 pol. slant angles.",
1343 Vector{6.363961031, 6.363961031, 3},
1360 "Not face-to-face. Different heights. 0 and 0 pol. slant angles.",
Test case that test the correct use of the multi-port antennas in spectrum.
~ThreeGppCalcLongTermMultiPortTest() override
Destructor.
void DoRun() override
Build the test scenario.
ThreeGppCalcLongTermMultiPortTest()
Constructor.
Test case for the ThreeGppChannelModel class.
ThreeGppChannelMatrixComputationTest(uint32_t txAntennaElements=2, uint32_t rxAntennaElements=2, uint32_t txPorts=1, uint32_t rxPorts=1)
Constructor.
void DoRun() override
Build the test scenario.
uint32_t m_rxPorts
number of horizontal and vertical ports of rx antenna array
~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.
uint32_t m_rxAntennaElements
number of rows and columns of rx antenna array
uint32_t m_txAntennaElements
number of rows and columns of tx antenna array
uint32_t m_txPorts
number of horizontal and vertical ports of tx antenna array
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(uint32_t txAntennaElements=2, uint32_t rxAntennaElements=4, uint32_t txPorts=1, uint32_t rxPorts=1)
Constructor.
uint32_t m_txAntennaElements
number of rows and columns of tx antenna array
void DoRun() override
Build the test scenario.
~ThreeGppChannelMatrixUpdateTest() override
Destructor.
uint32_t m_rxPorts
number of horizontal and vertical ports of rx antenna array
Ptr< const ThreeGppChannelModel::ChannelMatrix > m_currentChannel
used by DoGetChannel to store the current channel matrix
uint32_t m_txPorts
number of horizontal and vertical ports of tx antenna array
uint32_t m_rxAntennaElements
number of rows and columns of rx antenna array
Test suite for the ThreeGppChannelModel class.
ThreeGppChannelTestSuite()
Constructor.
This test tests that the channel matrix is correctly generated when dual-polarized antennas are being...
void DoRun() override
Build the test scenario.
ThreeGppMimoPolarizationTest(std::string testCaseName, Vector txLoc, const MimoPolarizationAntennaParams &txAntennaParams, Vector rxLoc, const MimoPolarizationAntennaParams &rxAntennaParams, std::valarray< std::complex< double >> testChannel, double tolerance)
Constructor that receives MIMO polarization parameters of TX and RX devices.
Vector m_txLoc
Position of the TX device.
Vector m_rxLoc
Position of the RX device.
Ptr< PhasedArrayModel > CreateAndConfigureAntenna(const MimoPolarizationAntennaParams ¶ms)
Function that can be used to configure the antenna using the set of parameters.
MimoPolarizationAntennaParams m_txParams
Parameters used to configure the TX antenna array.
double m_tolerance
The tolerance to be used when comparing the channel matrix with the test matrix.
std::valarray< std::complex< double > > m_testChannel
The test value for the matrix representing the strongest cluster.
~ThreeGppMimoPolarizationTest() override
Destructor.
MimoPolarizationAntennaParams m_rxParams
Parameters used to configure the RX antenna array.
Test case for the ThreeGppSpectrumPropagationLossModelTest class.
ThreeGppSpectrumPropagationLossModelTest(uint32_t txAntennaElements=4, uint32_t rxAntennaElements=4, uint32_t txPorts=1, uint32_t rxPorts=1)
Constructor.
void DoRun() override
Build the test scenario.
uint32_t m_txPorts
number of horizontal and vertical ports of tx antenna array
uint32_t m_rxAntennaElements
number of rows and columns of rx antenna array
uint32_t m_rxPorts
number of horizontal and vertical ports of rx antenna array
~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.
uint32_t m_txAntennaElements
number of rows and columns of tx antenna array
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.
Vector GetPosition() const
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.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
virtual size_t GetNumElems() const =0
Returns the number of antenna elements.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
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...
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< SpectrumSignalParameters > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > spectrumSignalParams, 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.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Hold an unsigned integer type.
T * GetPagePtr(size_t pageIndex)
Get a data pointer to a specific 2D array for use in linear algebra libraries.
bool IsAlmostEqual(const ValArray< T > &rhs, T tol) const
Compare Valarray up to a given absolute tolerance.
size_t GetNumPages() const
size_t GetNumRows() const
size_t GetNumCols() const
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
void SetDefault(std::string name, const AttributeValue &value)
#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_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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
Structure that contains some of the main configuration parameters of the antenna array that are used ...
uint32_t m_rows
the number of rows of antenna array
double m_bearingAngle
bearing angle of the antenna array
MimoPolarizationAntennaParams(bool isotropic, double polSlantAngle=0, double bearingAngle=0)
Constructor Currently only configurable through constructor are polSlantAngle and bearingAngle.
bool m_isotropic
defines whether the antenna elements are isotropic
uint32_t m_hPorts
the number of horizontal ports of antenna array
double m_polSlantAngle
polarization angle of the antenna array
uint32_t m_cols
the number of columns of antenna array
uint32_t m_vPorts
the number of vertical ports of antenna array
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.