9#include "ns3/boolean.h"
10#include "ns3/buildings-channel-condition-model.h"
11#include "ns3/buildings-module.h"
12#include "ns3/channel-condition-model.h"
13#include "ns3/config.h"
14#include "ns3/constant-position-mobility-model.h"
15#include "ns3/core-module.h"
16#include "ns3/double.h"
18#include "ns3/simulator.h"
20#include "ns3/three-gpp-v2v-channel-condition-model.h"
21#include "ns3/three-gpp-v2v-propagation-loss-model.h"
22#include "ns3/uinteger.h"
54 void DoRun()
override;
71 :
TestCase(
"Test case for the ThreeGppV2vUrban and ThreeGppV2vHighway ChannelConditionModel "
91 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOS;
97 testVector.
m_losCond = ChannelCondition::LosConditionValue::LOS;
102 testVector.
m_positionB = Vector(1000.0, 11.0, 1.5);
103 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOSv;
110 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOS;
116 testVector.
m_losCond = ChannelCondition::LosConditionValue::LOS;
121 testVector.
m_positionB = Vector(1000.0, 11.0, 1.5);
122 testVector.
m_losCond = ChannelCondition::LosConditionValue::NLOSv;
140 building->SetNRoomsX(1);
141 building->SetNRoomsY(1);
142 building->SetNFloors(1);
143 building->SetBoundaries(
Box(0.0, 10.0, 0.0, 10.0, 0.0, 5.0));
153 condModel->AssignStreams(1);
158 buildingInfoA->MakeConsistent(a);
160 buildingInfoB->MakeConsistent(b);
162 cond = condModel->GetChannelCondition(a, b);
164 NS_LOG_DEBUG(
"Got " << cond->GetLosCondition() <<
" expected condition "
168 "Got unexpected channel condition");
198 void DoRun()
override;
227 :
TestCase(
"Test case for the class ThreeGppV2vUrbanChannelConditionModel"),
242 if (cond->GetLosCondition() == ChannelCondition::LosConditionValue::LOS)
260 testVector.
m_pLos = std::min(1.0, 1.05 * exp(-0.0114 * 10.0));
266 testVector.
m_pLos = std::min(1.0, 1.05 * exp(-0.0114 * 100.0));
272 testVector.
m_pLos = std::min(1.0, 1.05 * exp(-0.0114 * 1000.0));
303 buildingInfoA->MakeConsistent(a);
305 buildingInfoB->MakeConsistent(b);
314 for (
uint32_t j = 0; j < numberOfReps; j++)
330 <<
" numberOfReps " << numberOfReps <<
" resultPlos "
331 << resultPlos <<
" ref " << testVector.
m_pLos);
335 "Got unexpected LOS probability");
363 void DoRun()
override;
392 :
TestCase(
"Test case for the class ThreeGppV2vHighwayChannelConditionModel"),
407 if (cond->GetLosCondition() == ChannelCondition::LosConditionValue::LOS)
425 testVector.
m_pLos = std::min(1.0, 0.0000021013 * 10.0 * 10.0 - 0.002 * 10.0 + 1.0193);
431 testVector.
m_pLos = std::min(1.0, 0.0000021013 * 100.0 * 100.0 - 0.002 * 100.0 + 1.0193);
437 testVector.
m_pLos = std::max(0.0, 0.54 - 0.001 * (1000.0 - 475));
475 for (
uint32_t j = 0; j < numberOfReps; j++)
488 double resultPlos =
static_cast<double>(
m_numLos) /
static_cast<double>(numberOfReps);
491 <<
" numberOfReps " << numberOfReps <<
" resultPlos "
492 << resultPlos <<
" ref " << testVector.
m_pLos);
496 "Got unexpected LOS probability");
529 :
TestSuite(
"three-gpp-v2v-channel-condition-model",
Type::SYSTEM)
532 TestCase::Duration::QUICK);
535 TestCase::Duration::QUICK);
538 TestCase::Duration::QUICK);
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
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
LosConditionValue
Possible values for Line-of-Sight condition.
mobility buildings information (to be used by mobility models)
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.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
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)
Computes the channel condition for the V2V Highway scenario.
static TypeId GetTypeId()
Get the type ID.
Computes the channel condition for the V2V Urban scenario.
static TypeId GetTypeId()
Get the type ID.
AttributeValue implementation for Time.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
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.