9#include "ns3/constant-position-mobility-model.h"
10#include "ns3/double.h"
12#include "ns3/propagation-loss-model.h"
13#include "ns3/simulator.h"
42 void DoRun()
override;
58 :
TestCase(
"Check to see that the ns-3 Friis propagation loss model provides correct received "
81 double txPowerW = 0.05035702;
82 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
96 testVector.
m_pt = txPowerdBm;
97 testVector.
m_pr = 4.98265e-10;
102 testVector.
m_pt = txPowerdBm;
103 testVector.
m_pr = 1.99306e-11;
108 testVector.
m_pt = txPowerdBm;
109 testVector.
m_pr = 4.98265e-12;
114 testVector.
m_pt = txPowerdBm;
115 testVector.
m_pr = 1.24566e-12;
122 a->SetPosition(Vector(0, 0, 0));
130 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
131 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
135 "Got unexpected rcv power");
153 void DoRun()
override;
169 :
TestCase(
"Check to see that the ns-3 TwoRayGround propagation loss model provides correct "
193 double txPowerW = 0.05035702;
194 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
209 testVector.
m_pt = txPowerdBm;
210 testVector.
m_pr = 4.98265e-10;
217 testVector.
m_pt = txPowerdBm;
218 testVector.
m_pr = 4.07891862e-12;
223 testVector.
m_pt = txPowerdBm;
224 testVector.
m_pr = 2.5493241375e-13;
229 testVector.
m_pt = txPowerdBm;
230 testVector.
m_pr = 1.593327585938e-14;
239 testVector.
m_pt = txPowerdBm;
240 testVector.
m_pr = 1.13303295e-11;
247 testVector.
m_pt = txPowerdBm;
248 testVector.
m_pr = 3.42742467375e-12;
255 testVector.
m_pt = txPowerdBm;
256 testVector.
m_pr = 9.36522547734e-13;
263 a->SetPosition(Vector(0, 0, 0));
272 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
273 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
277 "Got unexpected rcv power");
293 void DoRun()
override;
309 :
TestCase(
"Check to see that the ns-3 Log Distance propagation loss model provides correct "
329 double txPowerW = 0.05035702;
330 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
341 testVector.
m_pt = txPowerdBm;
342 testVector.
m_pr = 4.98265e-9;
347 testVector.
m_pt = txPowerdBm;
348 testVector.
m_pr = 6.22831e-10;
353 testVector.
m_pt = txPowerdBm;
354 testVector.
m_pr = 7.78539e-11;
359 testVector.
m_pt = txPowerdBm;
360 testVector.
m_pr = 9.73173e-12;
365 a->SetPosition(Vector(0, 0, 0));
374 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
375 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
379 "Got unexpected rcv power");
395 void DoRun()
override;
399 :
TestCase(
"Test MatrixPropagationLossModel")
411 for (
int i = 0; i < 3; ++i)
422 loss.
SetLoss(m[0], m[2], 30,
false);
423 loss.
SetLoss(m[2], m[0], 100,
false);
448 void DoRun()
override;
452 :
TestCase(
"Test RangePropagationLossModel")
465 a->SetPosition(Vector(0, 0, 0));
467 b->SetPosition(Vector(127.1, 0, 0));
471 double txPwrdBm = -80.0;
472 double tolerance = 1e-6;
473 double resultdBm = lossModel->CalcRxPower(txPwrdBm, a, b);
475 b->SetPosition(Vector(127.25, 0, 0));
476 resultdBm = lossModel->CalcRxPower(txPwrdBm, a, b);
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.
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.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
void AddTestCase(TestCase *testCase, Duration duration=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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.