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;
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);
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);
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);
431 for (uint8_t i = 0; i <
first->GetSpectrumModel ()->GetNumBands (); i++)
433 if ((*
first) [i] != (*second) [i])
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);
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);
529 rxPsdNew = lossModel->DoCalcRxPowerSpectralDensity (txPsd, rxMob, txMob);
537 this, lossModel, txPsd, txMob, rxMob, rxPsdOld);
540 Simulator::Destroy ();
ThreeGppChannelMatrixUpdateTest()
Constructor.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
virtual uint64_t GetNumberOfElements(void) const =0
Returns the number of antenna elements.
virtual Ptr< Node > GetNode(void) const =0
Class holding the azimuth and inclination angles of spherical coordinates.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
ComplexVector GetBeamformingVector(void) const
Returns the beamforming vector that is currently being used.
ThreeGppSpectrumPropagationLossModelTest()
Constructor.
virtual void DoRun(void)
Build the test scenario.
static bool ArePsdEqual(Ptr< SpectrumValue > first, Ptr< SpectrumValue > second)
Checks if two PSDs are equal.
static Vector GetPosition(Ptr< Node > node)
Test case for the ThreeGppChannelModel class.
Keep track of the current position and velocity of an object.
virtual void SetNode(Ptr< Node > node)
virtual ~ThreeGppSpectrumPropagationLossModelTest()
Destructor.
AttributeValue implementation for Time.
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.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::vector< double > m_normVector
each element is the norm of a channel realization
Hold an unsigned integer type.
#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.
Test case for the ThreeGppSpectrumPropagationLossModelTest class.
#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...
static ThreeGppChannelTestSuite myTestSuite
Complex3DVector m_channel
channel matrix H[u][s][n].
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetBeamformingVector(const ComplexVector &beamformingVector)
Sets the beamforming vector to be used.
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...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
Test suite for the ThreeGppChannelModel class.
Ptr< const ThreeGppChannelModel::ChannelMatrix > m_currentChannel
used by DoGetChannel to store the current channel matrix
ThreeGppChannelMatrixComputationTest()
Constructor.
ThreeGppChannelTestSuite()
Constructor.
void SetPosition(const Vector &position)
Ptr< const ChannelMatrix > GetChannel(Ptr< const MobilityModel > aMob, Ptr< const MobilityModel > bMob, Ptr< const PhasedArrayModel > aAntenna, Ptr< const PhasedArrayModel > bAntenna) override
Looks for the channel matrix associated to the aMob and bMob pair in m_channelMap.
virtual ~ThreeGppChannelMatrixComputationTest()
Destructor.
std::vector< std::complex< double > > ComplexVector
type definition for complex vectors
virtual void DoRun(void)
Build the test scenario.
void SetDefault(std::string name, const AttributeValue &value)
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.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Ptr< SpectrumValue > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumValue > txPsd, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the received PSD.
void DoBeamforming(Ptr< NetDevice > thisDevice, Ptr< PhasedArrayModel > thisAntenna, Ptr< NetDevice > otherDevice, Ptr< PhasedArrayModel > otherAntenna)
Points the beam of thisDevice towards otherDevice.
virtual ~ThreeGppChannelMatrixUpdateTest()
Destructor.
Test case for the ThreeGppChannelModel class.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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...
Implements Wifi SpectrumValue for the 2.4 GHz ISM band only, with a 5 MHz spectrum resolution...
virtual void DoRun(void)
Build the test scenario.