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/simple-net-device.h"
30#include "ns3/simulator.h"
31#include "ns3/spectrum-signal-parameters.h"
32#include "ns3/string.h"
34#include "ns3/three-gpp-channel-model.h"
35#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
36#include "ns3/uinteger.h"
37#include "ns3/uniform-planar-array.h"
67 void DoRun()
override;
87 :
TestCase(
"Check the dimensions and the norm of the channel matrix")
102 uint64_t txAntennaElements = txAntenna->GetNumberOfElements();
103 uint64_t rxAntennaElements = rxAntenna->GetNumberOfElements();
106 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
108 double channelNorm = 0;
109 uint16_t numTotalClusters = channelMatrix->m_channel.GetNumPages();
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};
136 CreateObject<NeverLosChannelConditionModel>();
140 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
141 channelModel->SetAttribute(
"Scenario",
StringValue(
"RMa"));
142 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
161 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
163 rxMob->SetPosition(Vector(100.0, 0.0, 10.0));
187 channelModel->GetChannel(txMob, rxMob, txAntenna, rxAntenna);
191 channelMatrix->m_channel.GetNumCols(),
192 txAntennaElements[0] * txAntennaElements[1],
193 "The third dimension of H should be equal to the number of tx antenna elements");
195 channelMatrix->m_channel.GetNumRows(),
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");
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};
345 CreateObject<AlwaysLosChannelConditionModel>();
349 channelModel->SetAttribute(
"Frequency",
DoubleValue(60.0e9));
350 channelModel->SetAttribute(
"Scenario",
StringValue(
"UMa"));
351 channelModel->SetAttribute(
"ChannelConditionModel",
PointerValue(channelConditionModel));
370 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
372 rxMob->SetPosition(Vector(100.0, 0.0, 1.6));
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);
535 thisAntenna->GetBeamformingVector(completeAngle);
536 thisAntenna->SetBeamformingVector(antennaWeights);
544 for (uint8_t i = 0; i <
first->GetSpectrumModel()->GetNumBands(); i++)
559 Ptr<SpectrumValue> rxPsdNew = params.lossModel->DoCalcRxPowerSpectralDensity(params.txParams,
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>();
586 lossModel->SetChannelModelAttribute(
"Frequency",
DoubleValue(2.4e9));
587 lossModel->SetChannelModelAttribute(
"Scenario",
StringValue(
"UMa"));
588 lossModel->SetChannelModelAttribute(
589 "ChannelConditionModel",
609 txMob->SetPosition(Vector(0.0, 0.0, 10.0));
612 Vector(15.0, 0.0, 10.0));
640 double txPower = 0.1;
644 txParams->psd = txPsd->Copy();
648 lossModel->DoCalcRxPowerSpectralDensity(txParams, txMob, rxMob, txAntenna, rxAntenna);
652 lossModel->DoCalcRxPowerSpectralDensity(txParams, rxMob, txMob, rxAntenna, txAntenna);
655 "The long term for the direct and the reverse channel are different");
659 rxMob->SetPosition(Vector(10.0, 5.0, 10.0));
661 txBfVector[0] = std::complex<double>(0.0, 0.0);
662 txAntenna->SetBeamformingVector(txBfVector);
665 lossModel->DoCalcRxPowerSpectralDensity(txParams, rxMob, txMob, rxAntenna, txAntenna);
668 "Changing the BF vectors the rx PSD does not change");
675 params{lossModel, txParams, txMob, rxMob, rxPsdOld, txAntenna, rxAntenna};
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.
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 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.
AttributeValue implementation for Time.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#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
static ThreeGppChannelTestSuite myTestSuite
Static variable for test initialization.