19 #include "ns3/abort.h"
20 #include "ns3/boolean.h"
21 #include "ns3/buildings-channel-condition-model.h"
22 #include "ns3/buildings-module.h"
23 #include "ns3/channel-condition-model.h"
24 #include "ns3/config.h"
25 #include "ns3/constant-position-mobility-model.h"
26 #include "ns3/core-module.h"
27 #include "ns3/double.h"
29 #include "ns3/simulator.h"
31 #include "ns3/three-gpp-v2v-channel-condition-model.h"
32 #include "ns3/three-gpp-v2v-propagation-loss-model.h"
33 #include "ns3/uinteger.h"
66 void DoRun()
override;
83 :
TestCase(
"Test case for the ThreeGppV2vUrban and ThreeGppV2vHighway ChannelConditionModel "
96 RngSeedManager::SetSeed(1);
97 RngSeedManager::SetRun(1);
103 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOS;
104 testVector.
m_typeId = ThreeGppV2vUrbanChannelConditionModel::GetTypeId();
109 testVector.
m_losCond = ChannelCondition::LosConditionValue::LOS;
110 testVector.
m_typeId = ThreeGppV2vUrbanChannelConditionModel::GetTypeId();
114 testVector.
m_positionB = Vector(1000.0, 11.0, 1.5);
115 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOSv;
116 testVector.
m_typeId = ThreeGppV2vUrbanChannelConditionModel::GetTypeId();
122 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOS;
123 testVector.
m_typeId = ThreeGppV2vHighwayChannelConditionModel::GetTypeId();
128 testVector.
m_losCond = ChannelCondition::LosConditionValue::LOS;
129 testVector.
m_typeId = ThreeGppV2vHighwayChannelConditionModel::GetTypeId();
133 testVector.
m_positionB = Vector(1000.0, 11.0, 1.5);
134 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOSv;
135 testVector.
m_typeId = ThreeGppV2vHighwayChannelConditionModel::GetTypeId();
152 building->SetNRoomsX(1);
153 building->SetNRoomsY(1);
154 building->SetNFloors(1);
155 building->SetBoundaries(
Box(0.0, 10.0, 0.0, 10.0, 0.0, 5.0));
157 BuildingsHelper::Install(
nodes);
164 DynamicCast<ChannelConditionModel>(condModelFactory.
Create());
165 condModel->AssignStreams(1);
170 buildingInfoA->MakeConsistent(a);
172 buildingInfoB->MakeConsistent(b);
174 cond = condModel->GetChannelCondition(a, b);
176 NS_LOG_DEBUG(
"Got " << cond->GetLosCondition() <<
" expected condition "
180 "Got unexpected channel condition");
183 Simulator::Destroy();
210 void DoRun()
override;
239 :
TestCase(
"Test case for the class ThreeGppV2vUrbanChannelConditionModel"),
254 if (cond->GetLosCondition() == ChannelCondition::LosConditionValue::LOS)
263 RngSeedManager::SetSeed(1);
264 RngSeedManager::SetRun(1);
273 testVector.
m_typeId = ThreeGppV2vUrbanChannelConditionModel::GetTypeId();
279 testVector.
m_typeId = ThreeGppV2vUrbanChannelConditionModel::GetTypeId();
285 testVector.
m_typeId = ThreeGppV2vUrbanChannelConditionModel::GetTypeId();
303 BuildingsHelper::Install(
nodes);
306 uint32_t numberOfReps = 500000;
315 buildingInfoA->MakeConsistent(a);
317 buildingInfoB->MakeConsistent(b);
326 for (uint32_t j = 0; j < numberOfReps; j++)
337 Simulator::Destroy();
339 double resultPlos = double(
m_numLos) / double(numberOfReps);
342 <<
" numberOfReps " << numberOfReps <<
" resultPlos "
343 << resultPlos <<
" ref " << testVector.
m_pLos);
347 "Got unexpected LOS probability");
375 void DoRun()
override;
404 :
TestCase(
"Test case for the class ThreeGppV2vHighwayChannelConditionModel"),
419 if (cond->GetLosCondition() == ChannelCondition::LosConditionValue::LOS)
428 RngSeedManager::SetSeed(1);
429 RngSeedManager::SetRun(1);
437 testVector.
m_pLos =
std::min(1.0, 0.0000021013 * 10.0 * 10.0 - 0.002 * 10.0 + 1.0193);
438 testVector.
m_typeId = ThreeGppV2vHighwayChannelConditionModel::GetTypeId();
443 testVector.
m_pLos =
std::min(1.0, 0.0000021013 * 100.0 * 100.0 - 0.002 * 100.0 + 1.0193);
444 testVector.
m_typeId = ThreeGppV2vHighwayChannelConditionModel::GetTypeId();
450 testVector.
m_typeId = ThreeGppV2vHighwayChannelConditionModel::GetTypeId();
468 BuildingsHelper::Install(
nodes);
471 uint32_t numberOfReps = 500000;
487 for (uint32_t j = 0; j < numberOfReps; j++)
498 Simulator::Destroy();
500 double resultPlos =
static_cast<double>(
m_numLos) /
static_cast<double>(numberOfReps);
503 <<
" numberOfReps " << numberOfReps <<
" resultPlos "
504 << resultPlos <<
" ref " << testVector.
m_pLos);
508 "Got unexpected LOS probability");
542 :
TestSuite(
"three-gpp-v2v-channel-condition-model", SYSTEM)
Test case for the classes ThreeGppV2vUrbanChannelConditionModel, and ThreeGppV2vHighwayChannelConditi...
ThreeGppV2vBuildingsChCondModelTestCase()
Constructor.
void DoRun() override
Builds the simulation scenario and perform the tests.
~ThreeGppV2vBuildingsChCondModelTestCase() override
Destructor.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
Test suite for the 3GPP V2V channel condition model.
ThreeGppV2vChCondModelsTestSuite()
Test case for the 3GPP V2V Highway channel condition models (probabilistic model for LOS/NLOSv states...
void EvaluateChannelCondition(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Evaluates the channel condition between two nodes by calling the method GetChannelCondition on m_cond...
double m_tolerance
tolerance
ThreeGppV2vHighwayLosNlosvChCondModelTestCase()
Constructor.
void DoRun() override
Builds the simulation scenario and perform the tests.
~ThreeGppV2vHighwayLosNlosvChCondModelTestCase() override
Destructor.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
uint64_t m_numLos
the number of LOS occurrences
Ptr< ThreeGppV2vHighwayChannelConditionModel > m_condModel
the channel condition model
Test case for the 3GPP V2V Urban channel condition models (probabilistic model for LOS/NLOSv states).
Ptr< ThreeGppV2vUrbanChannelConditionModel > m_condModel
the channel condition model
ThreeGppV2vUrbanLosNlosvChCondModelTestCase()
Constructor.
double m_tolerance
tolerance
void DoRun() override
Builds the simulation scenario and perform the tests.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
void EvaluateChannelCondition(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Evaluates the channel condition between two nodes by calling the method GetChannelCondition on m_cond...
~ThreeGppV2vUrbanLosNlosvChCondModelTestCase() override
Destructor.
uint64_t m_numLos
the number of LOS occurrences
LosConditionValue
Possible values for Line-of-Sight condition.
mobility buildings information (to be used by mobility models)
void SetPosition(const Vector &position)
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
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)
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Retrieve the condition of the channel between a and b.
Computes the channel condition for the V2V Highway scenario.
Computes the channel condition for the V2V Urban scenario.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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 ...
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.
Struct containing the parameters for each test.
TypeId m_typeId
the type ID of the channel condition model to be used
Vector m_positionA
the position of the first node
Vector m_positionB
the position of the second node
ChannelCondition::LosConditionValue m_losCond
the correct channel condition
Struct containing the parameters for each test.
TypeId m_typeId
the type ID of the channel condition model to be used
Vector m_positionB
the position of the second node
Vector m_positionA
the position of the first node
double m_pLos
LOS probability.
Struct containing the parameters for each test.
Vector m_positionA
the position of the first node
double m_pLos
LOS probability.
TypeId m_typeId
the type ID of the channel condition model to be used
Vector m_positionB
the position of the second node
static ThreeGppV2vChCondModelsTestSuite ThreeGppV2vChCondModelsTestSuite
Static variable for test initialization.