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;
109 uint8_t numTotClusters = channelMatrix->
m_channel.at(0).at(0).size();
110 for (uint8_t cIndex = 0; cIndex < numTotClusters; cIndex++)
112 double clusterNorm = 0;
113 for (uint64_t sIndex = 0; sIndex < txAntennaElements; sIndex++)
115 for (
uint32_t uIndex = 0; uIndex < rxAntennaElements; uIndex++)
118 std::pow(std::abs(channelMatrix->
m_channel.at(uIndex).at(sIndex).at(cIndex)),
122 channelNorm += clusterNorm;
131 uint8_t txAntennaElements[]{2, 2};
132 uint8_t rxAntennaElements[]{2, 2};
137 CreateObject<NeverLosChannelConditionModel>();
141 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
142 channelModel->SetAttribute(
"Scenario",
StringValue(
"RMa"));
143 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
188 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
193 txAntennaElements[0] * txAntennaElements[1],
194 "The second dimension of H should be equal to the number of tx antenna elements");
197 rxAntennaElements[0] * rxAntennaElements[1],
198 "The first dimension of H should be equal to the number of rx antenna elements");
201 uint16_t numIt = 1000;
202 for (uint16_t i = 0; i < numIt; i++)
217 double sampleMean = 0;
225 double sampleStd = 0;
228 sampleStd += ((i - sampleMean) * (i - sampleMean));
230 sampleStd = std::sqrt(sampleStd / (numIt - 1));
236 double t = (sampleMean - txAntennaElements[0] * txAntennaElements[1] * rxAntennaElements[0] *
237 rxAntennaElements[1]) /
238 (sampleMean / std::sqrt(numIt));
246 "We reject the hypothesis E[|H|^2] = M*N with a significance level of 0.05");
248 Simulator::Destroy();
275 void DoRun()
override;
299 :
TestCase(
"Check if the channel realizations are correctly updated during the simulation")
317 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
331 <<
" The channel matrix is not correctly updated");
340 uint8_t txAntennaElements[]{2, 2};
341 uint8_t rxAntennaElements[]{4, 4};
346 CreateObject<AlwaysLosChannelConditionModel>();
350 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
351 channelModel->SetAttribute(
"Scenario",
StringValue(
"UMa"));
352 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
412 Simulator::Schedule(
MilliSeconds(firstTimeMs + updatePeriodMs / 2),
424 Simulator::Schedule(
MilliSeconds(firstTimeMs + updatePeriodMs + 1),
435 Simulator::Destroy();
483 void DoRun()
override;
515 :
TestCase(
"Test case for the ThreeGppSpectrumPropagationLossModel class")
529 Vector aPos = thisDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
530 Vector bPos = otherDevice->GetNode()->GetObject<
MobilityModel>()->GetPosition();
533 Angles completeAngle(bPos, aPos);
545 for (uint8_t i = 0; i <
first->GetSpectrumModel()->GetNumBands(); i++)
567 "The long term is not updated when the channel matrix is recomputed");
576 uint8_t txAntennaElements[]{4, 4};
577 uint8_t rxAntennaElements[]{4, 4};
586 CreateObject<ThreeGppSpectrumPropagationLossModel>();
590 "ChannelConditionModel",
613 Vector(15.0, 0.0, 10.0));
641 double txPower = 0.1;
656 "The long term for the direct and the reverse channel are different");
662 txBfVector[0] = std::complex<double>(0.0, 0.0);
669 "Changing the BF vectors the rx PSD does not change");
676 params{lossModel, txParams, txMob, rxMob, rxPsdOld, txAntenna, rxAntenna};
683 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'.
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 uint64_t GetNumberOfElements() const =0
Returns the number of antenna elements.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
std::vector< std::complex< double > > ComplexVector
type definition for complex vectors
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.
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.
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.