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")
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;
141 nodes.Get (0)->AddDevice (txDev);
143 nodes.Get (1)->AddDevice (rxDev);
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;
304 nodes.Get (0)->AddDevice (txDev);
306 nodes.Get (1)->AddDevice (rxDev);
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);
431 for (uint8_t i = 0; i <
first->GetSpectrumModel ()->GetNumBands (); i++)
455 uint8_t txAntennaElements[] {4, 4};
456 uint8_t rxAntennaElements[] {4, 4};
478 nodes.Get (0)->AddDevice (txDev);
480 nodes.Get (1)->AddDevice (rxDev);
490 nodes.Get (0)->AggregateObject (txMob);
491 nodes.Get (1)->AggregateObject (rxMob);
496 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
499 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
511 double txPower = 0.1;
512 uint32_t channelNumber = 1;
526 txBfVector [0] = std::complex<double> (0.0, 0.0);
537 this, lossModel, txPsd, txMob, rxMob, rxPsdOld);
540 Simulator::Destroy ();