20 #include "ns3/abort.h"
22 #include "ns3/config.h"
23 #include "ns3/double.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/string.h"
26 #include "ns3/angles.h"
27 #include "ns3/pointer.h"
28 #include "ns3/node-container.h"
29 #include "ns3/constant-position-mobility-model.h"
30 #include "ns3/uniform-planar-array.h"
31 #include "ns3/isotropic-antenna-model.h"
32 #include "ns3/three-gpp-channel-model.h"
33 #include "ns3/simple-net-device.h"
34 #include "ns3/simulator.h"
35 #include "ns3/channel-condition-model.h"
36 #include "ns3/three-gpp-spectrum-propagation-loss-model.h"
37 #include "ns3/wifi-spectrum-value-helper.h"
65 virtual void DoRun (
void);
81 :
TestCase (
"Check the dimensions and the norm of the channel matrix")
92 uint64_t txAntennaElements = txAntenna->GetNumberOfElements ();
93 uint64_t rxAntennaElements = rxAntenna->GetNumberOfElements ();
97 double channelNorm = 0;
98 uint8_t numTotClusters = channelMatrix->
m_channel.at (0).at (0).size ();
99 for (uint8_t cIndex = 0; cIndex < numTotClusters; cIndex++)
101 double clusterNorm = 0;
102 for (uint64_t sIndex = 0; sIndex < txAntennaElements; sIndex++)
104 for (uint32_t uIndex = 0; uIndex < rxAntennaElements; uIndex++)
106 clusterNorm += std::pow (std::abs (channelMatrix->
m_channel.at (uIndex).at (sIndex).at (cIndex)), 2);
109 channelNorm += clusterNorm;
118 uint8_t txAntennaElements[] {2, 2};
119 uint8_t rxAntennaElements[] {2, 2};
120 uint32_t updatePeriodMs = 100;
127 channelModel->SetAttribute (
"Frequency",
DoubleValue (60.0e9));
128 channelModel->SetAttribute (
"Scenario",
StringValue (
"RMa"));
129 channelModel->SetAttribute (
"ChannelConditionModel",
PointerValue (channelConditionModel));
141 nodes.Get (0)->AddDevice (txDev);
142 txDev->SetNode (
nodes.Get (0));
143 nodes.Get (1)->AddDevice (rxDev);
144 rxDev->SetNode (
nodes.Get (1));
153 nodes.Get (0)->AggregateObject (txMob);
154 nodes.Get (1)->AggregateObject (rxMob);
159 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
162 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
168 NS_TEST_ASSERT_MSG_EQ (channelMatrix->
m_channel.at (0).size (), txAntennaElements [0] * txAntennaElements [1],
"The second dimension of H should be equal to the number of tx antenna elements");
169 NS_TEST_ASSERT_MSG_EQ (channelMatrix->
m_channel.size (), rxAntennaElements [0] * rxAntennaElements [1],
"The first dimension of H should be equal to the number of rx antenna elements");
172 uint16_t numIt = 1000;
173 for (uint16_t i = 0; i < numIt; i++)
181 double sampleMean = 0;
189 double sampleStd = 0;
192 sampleStd += ((i - sampleMean) * (i - sampleMean));
194 sampleStd = std::sqrt (sampleStd / (numIt - 1));
200 double t = (sampleMean - txAntennaElements [0] * txAntennaElements [1] * rxAntennaElements [0] * rxAntennaElements [1]) / (sampleMean / std::sqrt (numIt));
204 NS_TEST_ASSERT_MSG_EQ_TOL (std::abs (t), 0, 1.65,
"We reject the hypothesis E[|H|^2] = M*N with a significance level of 0.05");
206 Simulator::Destroy ();
231 virtual void DoRun (
void);
249 :
TestCase (
"Check if the channel realizations are correctly updated during the simulation")
281 uint8_t txAntennaElements[] {2, 2};
282 uint8_t rxAntennaElements[] {4, 4};
283 uint32_t updatePeriodMs = 100;
290 channelModel->SetAttribute (
"Frequency",
DoubleValue (60.0e9));
291 channelModel->SetAttribute (
"Scenario",
StringValue (
"UMa"));
292 channelModel->SetAttribute (
"ChannelConditionModel",
PointerValue (channelConditionModel));
304 nodes.Get (0)->AddDevice (txDev);
305 txDev->SetNode (
nodes.Get (0));
306 nodes.Get (1)->AddDevice (rxDev);
307 rxDev->SetNode (
nodes.Get (1));
316 nodes.Get (0)->AggregateObject (txMob);
317 nodes.Get (1)->AggregateObject (rxMob);
322 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
325 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
330 uint32_t firstTimeMs = 1;
332 this, channelModel, txMob, rxMob, txAntenna, rxAntenna,
true);
337 this, channelModel, txMob, rxMob, txAntenna, rxAntenna,
false);
342 this, channelModel, txMob, rxMob, txAntenna, rxAntenna,
true);
345 Simulator::Destroy ();
373 virtual void DoRun (
void);
406 :
TestCase (
"Test case for the ThreeGppSpectrumPropagationLossModel class")
421 Angles completeAngle (bPos,aPos);
424 thisAntenna->SetBeamformingVector (antennaWeights);
431 for (uint8_t i = 0; i <
first->GetSpectrumModel ()->GetNumBands (); i++)
445 Ptr<SpectrumValue> rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txPsd, txMob, rxMob);
455 uint8_t txAntennaElements[] {4, 4};
456 uint8_t rxAntennaElements[] {4, 4};
465 lossModel->SetChannelModelAttribute (
"Frequency",
DoubleValue(2.4e9));
466 lossModel->SetChannelModelAttribute (
"Scenario",
StringValue(
"UMa"));
467 lossModel->SetChannelModelAttribute (
"ChannelConditionModel",
PointerValue (condModel));
478 nodes.Get (0)->AddDevice (txDev);
479 txDev->SetNode (
nodes.Get (0));
480 nodes.Get (1)->AddDevice (rxDev);
481 rxDev->SetNode (
nodes.Get (1));
490 nodes.Get (0)->AggregateObject (txMob);
491 nodes.Get (1)->AggregateObject (rxMob);
496 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
499 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
502 lossModel->AddDevice (txDev, txAntenna);
503 lossModel->AddDevice (rxDev, rxAntenna);
511 double txPower = 0.1;
512 uint32_t channelNumber = 1;
516 Ptr<SpectrumValue> rxPsdOld = lossModel->DoCalcRxPowerSpectralDensity (txPsd, txMob, rxMob);
519 Ptr<SpectrumValue> rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txPsd, rxMob, txMob);
526 txBfVector [0] = std::complex<double> (0.0, 0.0);
527 txAntenna->SetBeamformingVector (txBfVector);
529 rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txPsd, rxMob, txMob);
537 this, lossModel, txPsd, txMob, rxMob, rxPsdOld);
540 Simulator::Destroy ();
Test case for the ThreeGppChannelModel class.
virtual ~ThreeGppChannelMatrixComputationTest()
Destructor.
virtual void DoRun(void)
Build the test scenario.
ThreeGppChannelMatrixComputationTest()
Constructor.
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...
virtual ~ThreeGppChannelMatrixUpdateTest()
Destructor.
ThreeGppChannelMatrixUpdateTest()
Constructor.
virtual void DoRun(void)
Build the test scenario.
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 CheckLongTermUpdate(Ptr< ThreeGppSpectrumPropagationLossModel > lossModel, Ptr< SpectrumValue > txPsd, Ptr< MobilityModel > txMob, Ptr< MobilityModel > rxMob, Ptr< SpectrumValue > rxPsdOld)
Test of the long term component is correctly updated when the channel matrix is recomputed.
ThreeGppSpectrumPropagationLossModelTest()
Constructor.
static bool ArePsdEqual(Ptr< SpectrumValue > first, Ptr< SpectrumValue > second)
Checks if two PSDs are equal.
virtual void DoRun(void)
Build the test scenario.
void DoBeamforming(Ptr< NetDevice > thisDevice, Ptr< PhasedArrayModel > thisAntenna, Ptr< NetDevice > otherDevice, Ptr< PhasedArrayModel > otherAntenna)
Points the beam of thisDevice towards otherDevice.
virtual ~ThreeGppSpectrumPropagationLossModelTest()
Destructor.
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.
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.
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.
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(void)
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.
Complex3DVector m_channel
channel matrix H[u][s][n].
static ThreeGppChannelTestSuite myTestSuite
static Vector GetPosition(Ptr< Node > node)