18 #include "ns3/abort.h"
19 #include "ns3/config.h"
20 #include "ns3/constant-position-mobility-model.h"
21 #include "ns3/double.h"
23 #include "ns3/propagation-loss-model.h"
24 #include "ns3/simulator.h"
53 void DoRun()
override;
69 :
TestCase(
"Check to see that the ns-3 Friis propagation loss model provides correct received "
92 double txPowerW = 0.05035702;
93 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
107 testVector.
m_pt = txPowerdBm;
108 testVector.
m_pr = 4.98265e-10;
113 testVector.
m_pt = txPowerdBm;
114 testVector.
m_pr = 1.99306e-11;
119 testVector.
m_pt = txPowerdBm;
120 testVector.
m_pr = 4.98265e-12;
125 testVector.
m_pt = txPowerdBm;
126 testVector.
m_pr = 1.24566e-12;
141 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
142 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
146 "Got unexpected rcv power");
164 void DoRun()
override;
180 :
TestCase(
"Check to see that the ns-3 TwoRayGround propagation loss model provides correct "
204 double txPowerW = 0.05035702;
205 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
220 testVector.
m_pt = txPowerdBm;
221 testVector.
m_pr = 4.98265e-10;
228 testVector.
m_pt = txPowerdBm;
229 testVector.
m_pr = 4.07891862e-12;
234 testVector.
m_pt = txPowerdBm;
235 testVector.
m_pr = 2.5493241375e-13;
240 testVector.
m_pt = txPowerdBm;
241 testVector.
m_pr = 1.593327585938e-14;
250 testVector.
m_pt = txPowerdBm;
251 testVector.
m_pr = 1.13303295e-11;
258 testVector.
m_pt = txPowerdBm;
259 testVector.
m_pr = 3.42742467375e-12;
266 testVector.
m_pt = txPowerdBm;
267 testVector.
m_pr = 9.36522547734e-13;
278 CreateObject<TwoRayGroundPropagationLossModel>();
283 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
284 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
288 "Got unexpected rcv power");
304 void DoRun()
override;
320 :
TestCase(
"Check to see that the ns-3 Log Distance propagation loss model provides correct "
340 double txPowerW = 0.05035702;
341 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
352 testVector.
m_pt = txPowerdBm;
353 testVector.
m_pr = 4.98265e-9;
358 testVector.
m_pt = txPowerdBm;
359 testVector.
m_pr = 6.22831e-10;
364 testVector.
m_pt = txPowerdBm;
365 testVector.
m_pr = 7.78539e-11;
370 testVector.
m_pt = txPowerdBm;
371 testVector.
m_pr = 9.73173e-12;
380 CreateObject<LogDistancePropagationLossModel>();
385 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
386 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
390 "Got unexpected rcv power");
406 void DoRun()
override;
410 :
TestCase(
"Test MatrixPropagationLossModel")
422 for (
int i = 0; i < 3; ++i)
424 m[i] = CreateObject<ConstantPositionMobilityModel>();
444 Simulator::Destroy();
459 void DoRun()
override;
463 :
TestCase(
"Test RangePropagationLossModel")
482 double txPwrdBm = -80.0;
483 double tolerance = 1e-6;
484 double resultdBm = lossModel->CalcRxPower(txPwrdBm, a, b);
487 resultdBm = lossModel->CalcRxPower(txPwrdBm, a, b);
489 Simulator::Destroy();
511 :
TestSuite(
"propagation-loss-model", UNIT)
FriisPropagationLossModel Test.
FriisPropagationLossModelTestCase()
~FriisPropagationLossModelTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
TestVectors< TestVector > m_testVectors
Test vectors.
LogDistancePropagationLossModel Test.
TestVectors< TestVector > m_testVectors
Test vectors.
~LogDistancePropagationLossModelTestCase() override
LogDistancePropagationLossModelTestCase()
void DoRun() override
Implementation to actually run this TestCase.
MatrixPropagationLossModel Test.
void DoRun() override
Implementation to actually run this TestCase.
MatrixPropagationLossModelTestCase()
~MatrixPropagationLossModelTestCase() override
Propagation models TestSuite.
PropagationLossModelsTestSuite()
RangePropagationLossModel Test.
~RangePropagationLossModelTestCase() override
RangePropagationLossModelTestCase()
void DoRun() override
Implementation to actually run this TestCase.
TwoRayGroundPropagationLossModel Test.
TwoRayGroundPropagationLossModelTestCase()
~TwoRayGroundPropagationLossModelTestCase() override
TestVectors< TestVector > m_testVectors
Test vectors.
void DoRun() override
Implementation to actually run this TestCase.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions.
void SetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double loss, bool symmetric=true)
Set loss (in dB, positive) between pair of ns-3 objects (typically, nodes).
void SetDefaultLoss(double defaultLoss)
Set the default propagation loss (in dB, positive) to be used, infinity if not set.
void SetPosition(const Vector &position)
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
A simple way to store test vectors (for stimulus or from responses)
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_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static PropagationLossModelsTestSuite g_propagationLossModelsTestSuite
Static variable for test initialization.
Vector m_position
Test node position.
double m_pt
Tx power [dBm].
double m_tolerance
Tolerance.
double m_pt
Tx power [dBm].
double m_tolerance
Tolerance.
Vector m_position
Test node position.
double m_pt
Tx power [dBm].
double m_tolerance
Tolerance.
Vector m_position
Test node position.