20 #include "ns3/abort.h"
22 #include "ns3/config.h"
23 #include "ns3/double.h"
24 #include "ns3/propagation-loss-model.h"
25 #include "ns3/constant-position-mobility-model.h"
26 #include "ns3/simulator.h"
56 virtual void DoRun (
void);
71 :
TestCase (
"Check to see that the ns-3 Friis propagation loss model provides correct received power"), m_testVectors ()
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;
161 virtual void DoRun (
void);
176 :
TestCase (
"Check to see that the ns-3 TwoRayGround propagation loss model provides correct received power"),
198 double txPowerW = 0.05035702;
199 double txPowerdBm = 10 * std::log10 (txPowerW) + 30;
214 testVector.
m_pt = txPowerdBm;
215 testVector.
m_pr = 4.98265e-10;
222 testVector.
m_pt = txPowerdBm;
223 testVector.
m_pr = 4.07891862e-12;
228 testVector.
m_pt = txPowerdBm;
229 testVector.
m_pr = 2.5493241375e-13;
234 testVector.
m_pt = txPowerdBm;
235 testVector.
m_pr = 1.593327585938e-14;
244 testVector.
m_pt = txPowerdBm;
245 testVector.
m_pr = 1.13303295e-11;
252 testVector.
m_pt = txPowerdBm;
253 testVector.
m_pr = 3.42742467375e-12;
260 testVector.
m_pt = txPowerdBm;
261 testVector.
m_pr = 9.36522547734e-13;
277 double resultdBm = lossModel->CalcRxPower (testVector.
m_pt, a, b);
278 double resultW = std::pow (10.0, resultdBm / 10.0) / 1000;
296 virtual void DoRun (
void);
311 :
TestCase (
"Check to see that the ns-3 Log Distance propagation loss model provides correct received power"), m_testVectors ()
328 double txPowerW = 0.05035702;
329 double txPowerdBm = 10 * std::log10 (txPowerW) + 30;
340 testVector.
m_pt = txPowerdBm;
341 testVector.
m_pr = 4.98265e-9;
346 testVector.
m_pt = txPowerdBm;
347 testVector.
m_pr = 6.22831e-10;
352 testVector.
m_pt = txPowerdBm;
353 testVector.
m_pr = 7.78539e-11;
358 testVector.
m_pt = txPowerdBm;
359 testVector.
m_pr = 9.73173e-12;
372 double resultdBm = lossModel->CalcRxPower (testVector.
m_pt, a, b);
373 double resultW = std::pow (10.0, resultdBm/10.0)/1000;
390 virtual void DoRun (
void);
394 :
TestCase (
"Test MatrixPropagationLossModel")
406 for (
int i = 0; i < 3; ++i)
408 m[i] = CreateObject<ConstantPositionMobilityModel> ();
417 loss.
SetLoss (m[0], m[2], 30,
false);
418 loss.
SetLoss (m[2], m[0], 100,
false);
428 Simulator::Destroy ();
443 virtual void DoRun (
void);
447 :
TestCase (
"Test RangePropagationLossModel")
466 double txPwrdBm = -80.0;
467 double tolerance = 1e-6;
468 double resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
471 resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b);
473 Simulator::Destroy ();
495 :
TestSuite (
"propagation-loss-model", UNIT)
FriisPropagationLossModel Test.
FriisPropagationLossModelTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
TestVectors< TestVector > m_testVectors
Test vectors.
virtual ~FriisPropagationLossModelTestCase()
LogDistancePropagationLossModel Test.
virtual void DoRun(void)
Implementation to actually run this TestCase.
TestVectors< TestVector > m_testVectors
Test vectors.
virtual ~LogDistancePropagationLossModelTestCase()
LogDistancePropagationLossModelTestCase()
MatrixPropagationLossModel Test.
MatrixPropagationLossModelTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~MatrixPropagationLossModelTestCase()
Propagation models TestSuite.
PropagationLossModelsTestSuite()
RangePropagationLossModel Test.
virtual ~RangePropagationLossModelTestCase()
RangePropagationLossModelTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
TwoRayGroundPropagationLossModel Test.
TwoRayGroundPropagationLossModelTestCase()
virtual ~TwoRayGroundPropagationLossModelTestCase()
TestVectors< TestVector > m_testVectors
Test vectors.
virtual void DoRun(void)
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.