9#include "ns3/constant-position-mobility-model.h"
10#include "ns3/double.h"
12#include "ns3/node-container.h"
13#include "ns3/propagation-loss-model.h"
14#include "ns3/simulator.h"
43 void DoRun()
override;
59 :
TestCase(
"Check to see that the ns-3 Friis propagation loss model provides correct received "
82 double txPowerW = 0.05035702;
83 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
97 testVector.
m_pt = txPowerdBm;
98 testVector.
m_pr = 4.98265e-10;
103 testVector.
m_pt = txPowerdBm;
104 testVector.
m_pr = 1.99306e-11;
109 testVector.
m_pt = txPowerdBm;
110 testVector.
m_pr = 4.98265e-12;
115 testVector.
m_pt = txPowerdBm;
116 testVector.
m_pr = 1.24566e-12;
123 a->SetPosition(Vector(0, 0, 0));
131 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
132 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
136 "Got unexpected rcv power");
154 void DoRun()
override;
170 :
TestCase(
"Check to see that the ns-3 TwoRayGround propagation loss model provides correct "
194 double txPowerW = 0.05035702;
195 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
210 testVector.
m_pt = txPowerdBm;
211 testVector.
m_pr = 4.98265e-10;
218 testVector.
m_pt = txPowerdBm;
219 testVector.
m_pr = 4.07891862e-12;
224 testVector.
m_pt = txPowerdBm;
225 testVector.
m_pr = 2.5493241375e-13;
230 testVector.
m_pt = txPowerdBm;
231 testVector.
m_pr = 1.593327585938e-14;
240 testVector.
m_pt = txPowerdBm;
241 testVector.
m_pr = 1.13303295e-11;
248 testVector.
m_pt = txPowerdBm;
249 testVector.
m_pr = 3.42742467375e-12;
256 testVector.
m_pt = txPowerdBm;
257 testVector.
m_pr = 9.36522547734e-13;
264 a->SetPosition(Vector(0, 0, 0));
273 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
274 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
278 "Got unexpected rcv power");
294 void DoRun()
override;
310 :
TestCase(
"Check to see that the ns-3 Log Distance propagation loss model provides correct "
330 double txPowerW = 0.05035702;
331 double txPowerdBm = 10 * std::log10(txPowerW) + 30;
342 testVector.
m_pt = txPowerdBm;
343 testVector.
m_pr = 4.98265e-9;
348 testVector.
m_pt = txPowerdBm;
349 testVector.
m_pr = 6.22831e-10;
354 testVector.
m_pt = txPowerdBm;
355 testVector.
m_pr = 7.78539e-11;
360 testVector.
m_pt = txPowerdBm;
361 testVector.
m_pr = 9.73173e-12;
366 a->SetPosition(Vector(0, 0, 0));
375 double resultdBm = lossModel->CalcRxPower(testVector.
m_pt, a, b);
376 double resultW = std::pow(10.0, resultdBm / 10.0) / 1000;
380 "Got unexpected rcv power");
396 void DoRun()
override;
400 :
TestCase(
"Test MatrixPropagationLossModel")
413 for (
int i = 0; i < 3; ++i)
425 loss.
SetLoss(m[0], m[2], 30,
false);
426 loss.
SetLoss(m[2], m[0], 100,
false);
451 void DoRun()
override;
455 :
TestCase(
"Test RangePropagationLossModel")
468 a->SetPosition(Vector(0, 0, 0));
470 b->SetPosition(Vector(127.1, 0, 0));
474 double txPwrdBm = -80.0;
475 double tolerance = 1e-6;
476 double resultdBm = lossModel->CalcRxPower(txPwrdBm, a, b);
478 b->SetPosition(Vector(127.25, 0, 0));
479 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.
keep track of a set of node pointers.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
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.
TestCase(const TestCase &)=delete
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new 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.