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"
67 virtual void DoRun (
void);
83 :
TestCase (
"Check the dimensions and the norm of the channel matrix")
99 double channelNorm = 0;
100 uint8_t numTotClusters = channelMatrix->
m_channel.at (0).at (0).size ();
101 for (uint8_t cIndex = 0; cIndex < numTotClusters; cIndex++)
103 double clusterNorm = 0;
104 for (uint64_t sIndex = 0; sIndex < txAntennaElements; sIndex++)
106 for (uint32_t uIndex = 0; uIndex < rxAntennaElements; uIndex++)
108 clusterNorm += std::pow (std::abs (channelMatrix->
m_channel.at (uIndex).at (sIndex).at (cIndex)), 2);
111 channelNorm += clusterNorm;
120 uint8_t txAntennaElements[] {2, 2};
121 uint8_t rxAntennaElements[] {2, 2};
122 uint32_t updatePeriodMs = 100;
129 channelModel->SetAttribute (
"Frequency",
DoubleValue (60.0e9));
130 channelModel->SetAttribute (
"Scenario",
StringValue (
"RMa"));
131 channelModel->SetAttribute (
"ChannelConditionModel",
PointerValue (channelConditionModel));
143 nodes.Get (0)->AddDevice (txDev);
144 txDev->SetNode (
nodes.Get (0));
145 nodes.Get (1)->AddDevice (rxDev);
146 rxDev->SetNode (
nodes.Get (1));
155 nodes.Get (0)->AggregateObject (txMob);
156 nodes.Get (1)->AggregateObject (rxMob);
161 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
164 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
170 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");
171 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");
174 uint16_t numIt = 1000;
175 for (uint16_t i = 0; i < numIt; i++)
183 double sampleMean = 0;
191 double sampleStd = 0;
194 sampleStd += ((i - sampleMean) * (i - sampleMean));
196 sampleStd = std::sqrt (sampleStd / (numIt - 1));
202 double t = (sampleMean - txAntennaElements [0] * txAntennaElements [1] * rxAntennaElements [0] * rxAntennaElements [1]) / (sampleMean / std::sqrt (numIt));
206 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");
208 Simulator::Destroy ();
235 virtual void DoRun (
void);
253 :
TestCase (
"Check if the channel realizations are correctly updated during the simulation")
285 uint8_t txAntennaElements[] {2, 2};
286 uint8_t rxAntennaElements[] {4, 4};
287 uint32_t updatePeriodMs = 100;
294 channelModel->SetAttribute (
"Frequency",
DoubleValue (60.0e9));
295 channelModel->SetAttribute (
"Scenario",
StringValue (
"UMa"));
296 channelModel->SetAttribute (
"ChannelConditionModel",
PointerValue (channelConditionModel));
308 nodes.Get (0)->AddDevice (txDev);
309 txDev->SetNode (
nodes.Get (0));
310 nodes.Get (1)->AddDevice (rxDev);
311 rxDev->SetNode (
nodes.Get (1));
320 nodes.Get (0)->AggregateObject (txMob);
321 nodes.Get (1)->AggregateObject (rxMob);
326 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
329 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
334 uint32_t firstTimeMs = 1;
336 this, channelModel, txMob, rxMob, txAntenna, rxAntenna,
true);
341 this, channelModel, txMob, rxMob, txAntenna, rxAntenna,
false);
346 this, channelModel, txMob, rxMob, txAntenna, rxAntenna,
true);
349 Simulator::Destroy ();
419 virtual void DoRun (
void);
447 :
TestCase (
"Test case for the ThreeGppSpectrumPropagationLossModel class")
462 Angles completeAngle (bPos,aPos);
472 for (uint8_t i = 0; i <
first->GetSpectrumModel ()->GetNumBands (); i++)
496 uint8_t txAntennaElements[] {4, 4};
497 uint8_t rxAntennaElements[] {4, 4};
519 nodes.Get (0)->AddDevice (txDev);
520 txDev->SetNode (
nodes.Get (0));
521 nodes.Get (1)->AddDevice (rxDev);
522 rxDev->SetNode (
nodes.Get (1));
531 nodes.Get (0)->AggregateObject (txMob);
532 nodes.Get (1)->AggregateObject (rxMob);
537 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
540 "AntennaElement",
PointerValue(CreateObject<IsotropicAntennaModel> ()));
548 double txPower = 0.1;
549 uint32_t channelNumber = 1;
563 txBfVector [0] = std::complex<double> (0.0, 0.0);
577 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.
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.
void CheckLongTermUpdate(CheckLongTermUpdateParams ¶ms)
Test of the long term component is correctly updated when the channel matrix is recomputed.
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)
virtual Ptr< Node > GetNode(void) const =0
keep track of a set of node pointers.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
ComplexVector GetBeamformingVector(void) const
Returns the beamforming vector that is currently being used.
virtual uint64_t GetNumberOfElements(void) 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.
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 SpectrumValue > txPsd, 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(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.
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< PhasedArrayModel > rxAntenna
the antenna array of the rx device
Ptr< MobilityModel > rxMob
the mobility model of the rx device
CheckLongTermUpdateParams(Ptr< ThreeGppSpectrumPropagationLossModel > pLossModel, Ptr< SpectrumValue > pTxPsd, Ptr< MobilityModel > pTxMob, Ptr< MobilityModel > pRxMob, Ptr< SpectrumValue > pRxPsdOld, Ptr< PhasedArrayModel > pTxAntenna, Ptr< PhasedArrayModel > pRxAntenna)
Constructor.
Ptr< PhasedArrayModel > txAntenna
the antenna array of the tx device
Ptr< SpectrumValue > txPsd
the PSD of the tx signal
Complex3DVector m_channel
channel matrix H[u][s][n].
static ThreeGppChannelTestSuite myTestSuite
Static variable for test initialization.
static Vector GetPosition(Ptr< Node > node)