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"
81 void DoRun()
override;
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;
135 uint16_t numTotalClusters = channelMatrix->m_channel.GetNumPages();
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;
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);
188 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
190 rxMob->SetPosition(Vector(100.0, 0.0, 10.0));
206 "NumHorizontalPorts",
218 "NumHorizontalPorts",
222 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
226 channelMatrix->m_channel.GetNumCols(),
228 "The third dimension of H should be equal to the number of tx antenna elements");
230 channelMatrix->m_channel.GetNumRows(),
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");
319 void DoRun()
override;
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");
398 CreateObject<AlwaysLosChannelConditionModel>();
402 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
403 channelModel->SetAttribute(
"Scenario",
StringValue(
"UMa"));
404 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
423 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
425 rxMob->SetPosition(Vector(100.0, 0.0, 1.6));
441 "NumHorizontalPorts",
453 "NumHorizontalPorts",
554 void DoRun()
override;
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);
612 thisAntenna->GetBeamformingVector(completeAngle);
613 thisAntenna->SetBeamformingVector(antennaWeights);
620 auto rxPsdNewParams = params.lossModel->DoCalcRxPowerSpectralDensity(params.txParams,
627 "The long term is not updated when the channel matrix is recomputed");
643 CreateObject<ThreeGppSpectrumPropagationLossModel>();
644 lossModel->SetChannelModelAttribute(
"Frequency",
DoubleValue(2.4e9));
645 lossModel->SetChannelModelAttribute(
"Scenario",
StringValue(
"UMa"));
646 lossModel->SetChannelModelAttribute(
647 "ChannelConditionModel",
667 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
670 Vector(15.0, 0.0, 10.0));
686 "NumHorizontalPorts",
698 "NumHorizontalPorts",
707 double txPower = 0.1;
711 txParams->psd = txPsd->Copy();
715 lossModel->DoCalcRxPowerSpectralDensity(txParams, txMob, rxMob, txAntenna, rxAntenna);
719 lossModel->DoCalcRxPowerSpectralDensity(txParams, rxMob, txMob, rxAntenna, txAntenna);
722 "The long term for the direct and the reverse channel are different");
726 rxMob->SetPosition(Vector(10.0, 5.0, 10.0));
728 txBfVector[0] = std::complex<double>(0.0, 0.0);
729 txAntenna->SetBeamformingVector(txBfVector);
732 lossModel->DoCalcRxPowerSpectralDensity(txParams, rxMob, txMob, rxAntenna, txAntenna);
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};
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));
842 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
844 rxMob->SetPosition(Vector(10.0, 0.0, 10.0));
860 "NumHorizontalPorts",
872 "NumHorizontalPorts",
876 Angles completeAngleTxRx(rxMob->GetPosition(), txMob->GetPosition());
877 Angles completeAngleRxTx(txMob->GetPosition(), rxMob->GetPosition());
879 txAntenna1->SetBeamformingVector(txAntenna1->GetBeamformingVector(completeAngleTxRx));
880 rxAntenna1->SetBeamformingVector(rxAntenna1->GetBeamformingVector(completeAngleRxTx));
884 channelModel->GetChannel(txMob, rxMob, txAntenna1, rxAntenna1);
889 CreateObject<ThreeGppSpectrumPropagationLossModel>();
892 threeGppSplm->CalcLongTerm(channelMatrixM0, txAntenna1, rxAntenna1);
904 "NumHorizontalPorts",
916 "NumHorizontalPorts",
919 txAntenna2->SetBeamformingVector(txAntenna2->GetBeamformingVector(completeAngleTxRx));
920 rxAntenna2->SetBeamformingVector(rxAntenna2->GetBeamformingVector(completeAngleRxTx));
923 threeGppSplm->CalcLongTerm(channelMatrixM0, txAntenna2, rxAntenna2);
935 "NumHorizontalPorts",
937 "AntennaHorizontalSpacing",
949 "NumHorizontalPorts",
951 "AntennaHorizontalSpacing",
955 Create<ThreeGppChannelModel::ChannelMatrix>();
956 channelMatrixMA->m_channel = *matrixA;
958 txAntenna3->SetBeamformingVector(txAntenna3->GetBeamformingVector(completeAngleTxRx));
959 rxAntenna3->SetBeamformingVector(rxAntenna3->GetBeamformingVector(completeAngleRxTx));
962 threeGppSplm->CalcLongTerm(channelMatrixMA, txAntenna3, rxAntenna3);
966 "Matrix B and Matrix C should be equal.");
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)
1108 if (params.m_isotropic)
1110 antenna = CreateObject<IsotropicAntennaModel>();
1114 antenna = CreateObject<ThreeGppAntennaModel>();
1117 return CreateObjectWithAttributes<UniformPlanarArray>(
"NumColumns",
1125 "NumHorizontalPorts",
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);
1179 txAntenna->SetBeamformingVector(
1180 txAntenna->GetBeamformingVector(
Angles(rxMob->GetPosition(), txMob->GetPosition())));
1181 rxAntenna->SetBeamformingVector(
1182 rxAntenna->GetBeamformingVector(
Angles(txMob->GetPosition(), rxMob->GetPosition())));
1186 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
1191 const std::complex<double>* strongestClusterPtr = channelMatrix->m_channel.GetPagePtr(0);
1193 channelMatrix->m_channel.GetNumRows() * channelMatrix->m_channel.GetNumCols();
1196 channelMatrix->m_channel.GetNumRows(),
1197 channelMatrix->m_channel.GetNumCols(),
1198 std::valarray<std::complex<double>>(strongestClusterPtr, matrixSize));
1201 channelMatrix->m_channel.GetNumCols(),
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");
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.
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(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.
~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.
AttributeValue implementation for Boolean.
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.
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.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
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...
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
Hold an unsigned integer type.
bool IsAlmostEqual(const ValArray< T > &rhs, T tol) const
Compare Valarray up to a given absolute tolerance.
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.
#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.
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].
static ThreeGppChannelTestSuite myTestSuite
Static variable for test initialization.