|
|
| 70 |
|
70 |
|
| 71 |
// the test vectors have been determined for a wavelength of 0.125 m |
71 |
// the test vectors have been determined for a wavelength of 0.125 m |
| 72 |
// which corresponds to a frequency of 2398339664.0 Hz in the vacuum |
72 |
// which corresponds to a frequency of 2398339664.0 Hz in the vacuum |
| 73 |
Config::SetDefault ("ns3::FriisPropagationLossModel::Frequency", DoubleValue (2398339664.0)); |
73 |
double frequency{2398339664.0}; |
|
|
74 |
Config::SetDefault ("ns3::FriisPropagationLossModel::Frequency", DoubleValue (frequency)); |
| 74 |
Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0)); |
75 |
Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0)); |
| 75 |
|
76 |
|
| 76 |
// Select a reference transmit power |
77 |
// Select a reference transmit power |
|
|
| 124 |
{ |
125 |
{ |
| 125 |
testVector = m_testVectors.Get (i); |
126 |
testVector = m_testVectors.Get (i); |
| 126 |
b->SetPosition (testVector.m_position); |
127 |
b->SetPosition (testVector.m_position); |
| 127 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b); |
128 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b, frequency); |
| 128 |
double resultW = std::pow (10.0, resultdBm/10.0)/1000; |
129 |
double resultW = std::pow (10.0, resultdBm/10.0)/1000; |
| 129 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
130 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
| 130 |
} |
131 |
} |
|
|
| 167 |
{ |
168 |
{ |
| 168 |
// the test vectors have been determined for a wavelength of 0.125 m |
169 |
// the test vectors have been determined for a wavelength of 0.125 m |
| 169 |
// which corresponds to a frequency of 2398339664.0 Hz in the vacuum |
170 |
// which corresponds to a frequency of 2398339664.0 Hz in the vacuum |
| 170 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Frequency", DoubleValue (2398339664.0)); |
171 |
double frequency{2398339664.0}; |
|
|
172 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Frequency", DoubleValue (frequency)); |
| 171 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0)); |
173 |
Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0)); |
| 172 |
|
174 |
|
| 173 |
// set antenna height to 1.5m above z coordinate |
175 |
// set antenna height to 1.5m above z coordinate |
|
|
| 254 |
{ |
256 |
{ |
| 255 |
testVector = m_testVectors.Get (i); |
257 |
testVector = m_testVectors.Get (i); |
| 256 |
b->SetPosition (testVector.m_position); |
258 |
b->SetPosition (testVector.m_position); |
| 257 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b); |
259 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b, frequency); |
| 258 |
double resultW = std::pow (10.0, resultdBm / 10.0) / 1000; |
260 |
double resultW = std::pow (10.0, resultdBm / 10.0) / 1000; |
| 259 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
261 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
| 260 |
} |
262 |
} |
|
|
| 293 |
LogDistancePropagationLossModelTestCase::DoRun (void) |
295 |
LogDistancePropagationLossModelTestCase::DoRun (void) |
| 294 |
{ |
296 |
{ |
| 295 |
// reference loss at 2.4 GHz is 40.045997 |
297 |
// reference loss at 2.4 GHz is 40.045997 |
| 296 |
Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997)); |
298 |
double frequency{40.045997}; |
|
|
299 |
Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (frequency)); |
| 297 |
Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3)); |
300 |
Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3)); |
| 298 |
|
301 |
|
| 299 |
// Select a reference transmit power |
302 |
// Select a reference transmit power |
|
|
| 342 |
{ |
345 |
{ |
| 343 |
testVector = m_testVectors.Get (i); |
346 |
testVector = m_testVectors.Get (i); |
| 344 |
b->SetPosition (testVector.m_position); |
347 |
b->SetPosition (testVector.m_position); |
| 345 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b); |
348 |
double resultdBm = lossModel->CalcRxPower (testVector.m_pt, a, b, frequency); |
| 346 |
double resultW = std::pow (10.0, resultdBm/10.0)/1000; |
349 |
double resultW = std::pow (10.0, resultdBm/10.0)/1000; |
| 347 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
350 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultW, testVector.m_pr, testVector.m_tolerance, "Got unexpected rcv power"); |
| 348 |
} |
351 |
} |
|
|
| 370 |
void |
373 |
void |
| 371 |
MatrixPropagationLossModelTestCase::DoRun (void) |
374 |
MatrixPropagationLossModelTestCase::DoRun (void) |
| 372 |
{ |
375 |
{ |
|
|
376 |
double frequency{0.0}; // Does not matter for MatrixPropagationLossModel |
| 373 |
Ptr<MobilityModel> m[3]; |
377 |
Ptr<MobilityModel> m[3]; |
| 374 |
for (int i = 0; i < 3; ++i) |
378 |
for (int i = 0; i < 3; ++i) |
| 375 |
{ |
379 |
{ |
|
|
| 386 |
loss.SetLoss (m[2], m[0], 100, /*symmetric = */ false); |
390 |
loss.SetLoss (m[2], m[0], 100, /*symmetric = */ false); |
| 387 |
// default from 1 to 2 |
391 |
// default from 1 to 2 |
| 388 |
|
392 |
|
| 389 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[1]), -10, "Loss 0 -> 1 incorrect"); |
393 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[1], frequency), -10, "Loss 0 -> 1 incorrect"); |
| 390 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[0]), -10, "Loss 1 -> 0 incorrect"); |
394 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[0], frequency), -10, "Loss 1 -> 0 incorrect"); |
| 391 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[2]), -30, "Loss 0 -> 2 incorrect"); |
395 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[0], m[2], frequency), -30, "Loss 0 -> 2 incorrect"); |
| 392 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[0]), -100, "Loss 2 -> 0 incorrect"); |
396 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[0], frequency), -100, "Loss 2 -> 0 incorrect"); |
| 393 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[2]), 0, "Loss 1 -> 2 incorrect"); |
397 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[1], m[2], frequency), 0, "Loss 1 -> 2 incorrect"); |
| 394 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[1]), 0, "Loss 2 -> 1 incorrect"); |
398 |
NS_TEST_ASSERT_MSG_EQ (loss.CalcRxPower (0, m[2], m[1], frequency), 0, "Loss 2 -> 1 incorrect"); |
| 395 |
|
399 |
|
| 396 |
Simulator::Destroy (); |
400 |
Simulator::Destroy (); |
| 397 |
} |
401 |
} |
|
|
| 418 |
void |
422 |
void |
| 419 |
RangePropagationLossModelTestCase::DoRun (void) |
423 |
RangePropagationLossModelTestCase::DoRun (void) |
| 420 |
{ |
424 |
{ |
|
|
425 |
double frequency{0.0}; // Does not matter for RangePropagationLossModel |
| 421 |
Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2)); |
426 |
Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2)); |
| 422 |
Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); |
427 |
Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); |
| 423 |
a->SetPosition (Vector (0,0,0)); |
428 |
a->SetPosition (Vector (0,0,0)); |
|
|
| 428 |
|
433 |
|
| 429 |
double txPwrdBm = -80.0; |
434 |
double txPwrdBm = -80.0; |
| 430 |
double tolerance = 1e-6; |
435 |
double tolerance = 1e-6; |
| 431 |
double resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b); |
436 |
double resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b, frequency); |
| 432 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, txPwrdBm, tolerance, "Got unexpected rcv power"); |
437 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, txPwrdBm, tolerance, "Got unexpected rcv power"); |
| 433 |
b->SetPosition (Vector (127.25,0,0)); // beyond range |
438 |
b->SetPosition (Vector (127.25,0,0)); // beyond range |
| 434 |
resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b); |
439 |
resultdBm = lossModel->CalcRxPower (txPwrdBm, a, b, frequency); |
| 435 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, -1000.0, tolerance, "Got unexpected rcv power"); |
440 |
NS_TEST_EXPECT_MSG_EQ_TOL (resultdBm, -1000.0, tolerance, "Got unexpected rcv power"); |
| 436 |
Simulator::Destroy (); |
441 |
Simulator::Destroy (); |
| 437 |
} |
442 |
} |