A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
two-ray-splm-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 SIGNET Lab, Department of Information Engineering,
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#include <ns3/abort.h>
8#include <ns3/config.h>
9#include <ns3/constant-position-mobility-model.h>
10#include <ns3/double.h>
11#include <ns3/isotropic-antenna-model.h>
12#include <ns3/log.h>
13#include <ns3/mobility-helper.h>
14#include <ns3/node-container.h>
15#include <ns3/pointer.h>
16#include <ns3/simulator.h>
17#include <ns3/string.h>
18#include <ns3/test.h>
19#include <ns3/three-gpp-antenna-model.h>
20#include <ns3/three-gpp-channel-model.h>
21#include <ns3/three-gpp-spectrum-propagation-loss-model.h>
22#include <ns3/two-ray-spectrum-propagation-loss-model.h>
23#include <ns3/uinteger.h>
24#include <ns3/uniform-planar-array.h>
25
26#include <array>
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE("TwoRaySplmTestSuite");
31
32/**
33 * \ingroup spectrum-tests
34 *
35 * Test case for the TwoRaySpectrumPropagationLossModel class.
36 *
37 * Check that the average of the Fluctuating Two Ray (FTR) fading model
38 * is consistent with the theoretical value.
39 */
41{
42 public:
43 /**
44 * Constructor
45 */
47
48 /**
49 * Destructor
50 */
52
53 private:
54 /**
55 * Build the test scenario
56 */
57 void DoRun() override;
58
59 /**
60 * Compute the average of the FTR squared norm.
61 * \param [in] ftrParams The FTR parameters.
62 * \returns The average of \c N_MEASUREMENTS FTR samples.
63 */
66
67 /**
68 * Compute the expected mean of the FTR squared norm.
69 *
70 * The expected mean \f$ \mathbb{E} \left[ h^2 \right] \f$ can be computed as
71 * \f$ \mathbb{E}\left[ |h|^2 \right] = V_1^2 + V_2^2 + 2*\sigma \f$, where:
72 * \f$ \sigma^2 \f$ is the variance of the Gaussian distributed random variables
73 * which model the real and complex component of the specular terms and
74 * \f$ V_1 \f$ and \f$ V_2 \f$ are the constant amplitudes of the reflected components.รน
75 * In turn, this equals to \f$ 2*\sigma^2 \left( 1 + K \right) \f$.
76 *
77 * See J. M. Romero-Jerez, F. J. Lopez-Martinez, J. F. Paris and A. Goldsmith, "The Fluctuating
78 * Two-Ray Fading Model for mmWave Communications," 2016 IEEE Globecom Workshops (GC Wkshps) for
79 * further details.
80 *
81 * \param [in] sigma The sigma parameter of the FTR model.
82 * \param [in] k The k parameter of the FTR model.
83 * \returns The expected mean.
84 */
85 constexpr double FtrSquaredNormExpectedMean(double sigma, double k) const;
86
87 /// Number of samples to draw when populating the distribution.
88 static constexpr uint32_t N_MEASUREMENTS{100000};
89
90 /**
91 * Tolerance for testing FTR's expectations against theoretical values,
92 * expressed as a fraction of the expected mean.
93 */
94 static constexpr double TOLERANCE{1e-2};
95
96 /// Number of different values for each FTR parameter.
97 static constexpr uint8_t NUM_VALUES{3};
98
99 /// Maximum value for the m parameter.
100 static constexpr uint16_t MAX_M_VALUE{1000};
101};
102
104 : TestCase("Check that the average of the Fluctuating Two Ray model is consistent with the "
105 "theoretical expectation")
106{
107}
108
112
113double
116{
117 NS_LOG_FUNCTION(this);
118 double sum = 0.0;
120 twoRaySplm->AssignStreams(1);
121 for (uint32_t i = 0; i < N_MEASUREMENTS; ++i)
122 {
123 double value = twoRaySplm->GetFtrFastFading(ftrParams);
124 sum += value;
125 }
126 double valueMean = sum / N_MEASUREMENTS;
127 return valueMean;
128}
129
130double constexpr FtrFadingModelAverageTest::FtrSquaredNormExpectedMean(double sigma, double k) const
131{
132 return 2 * sigma * (1 + k);
133}
134
135void
137{
138 std::array<double, NUM_VALUES> sigma;
139 std::array<double, NUM_VALUES> k;
140 std::array<double, NUM_VALUES> delta;
141
142 // Generate a set of values for the FTR model parameters
143 for (uint8_t j = 0; j < NUM_VALUES; j++)
144 {
145 double power = std::pow(2, j);
146
147 sigma[j] = power;
148 k[j] = power;
149 delta[j] = double(j) / NUM_VALUES; // Delta must be in [0, 1]
150 }
151
153
154 // Check the consistency of the empirical average for a set of values of the FTR model
155 // parameters
156 for (uint8_t l = 0; l < NUM_VALUES; l++)
157 {
158 for (uint8_t m = 0; m < NUM_VALUES; m++)
159 {
160 for (uint8_t n = 0; n < NUM_VALUES; n++)
161 {
163 unifRv->GetInteger(1, MAX_M_VALUE),
164 sigma[l], // Average should be independent from m
165 k[m],
166 delta[n]);
167 double valueMean = FtrSquaredNormAverage(ftrParams);
168 double expectedMean = FtrSquaredNormExpectedMean(ftrParams.m_sigma, ftrParams.m_k);
169
171 expectedMean,
172 expectedMean * TOLERANCE,
173 "wrong mean value");
174 }
175 }
176 }
177}
178
179/**
180 * \ingroup spectrum-tests
181 *
182 * Test case for the TwoRaySpectrumPropagationLossModel class.
183 *
184 * Check that the overall array response at boresight coincides with the
185 * expected theoretical values
186 */
188{
189 public:
190 /**
191 * The constructor of the test case
192 * \param txAntElem the antenna element of the TX antenna panel
193 * \param rxAntElem the antenna element of the RX antenna panel
194 * \param txNumAntennas the number of antenna elements of the TX antenna panel
195 * \param rxNumAntennas the number of antenna elements of the RX antenna panel
196 * \param txPosVec the position of the TX
197 * \param rxPosVec the position of the RX
198 * \param txBearing the bearing angle of the TX antenna panel
199 * \param rxBearing the bearing angle of the RX antenna panel
200 * \param expectedGain the theoretically expected gain for the above parameters
201 */
203 Ptr<AntennaModel> rxAntElem,
204 uint16_t txNumAntennas,
205 uint16_t rxNumAntennas,
206 Vector txPosVec,
207 Vector rxPosVec,
208 double txBearing,
209 double rxBearing,
210 double expectedGain);
211
212 /**
213 * Destructor
214 */
215 ~ArrayResponseTest() override;
216
217 private:
218 /**
219 * Build the test scenario
220 */
221 void DoRun() override;
222
223 /**
224 * Tolerance for testing value produced by the simulator against
225 * expected theoretical value, as a fraction of the expected value.
226 */
227 static constexpr double TOLERANCE{1e-8};
228
229 Ptr<AntennaModel> m_txAntElem; //!< the antenna element of the TX antenna panel
230 Ptr<AntennaModel> m_rxAntElem; //!< the antenna element of the RX antenna panel
231 uint16_t m_txNumAntennas; //!< the number of antenna elements of the TX antenna panel
232 uint16_t m_rxNumAntennas; //!< the number of antenna elements of the RX antenna panel
233 Vector m_txPosVec; //!< the position of the TX
234 Vector m_rxPosVec; //!< the position of the RX
235 double m_txBearing; //!< the bearing angle of the TX antenna panel [rad]
236 double m_rxBearing; //!< the bearing angle of the RX antenna panel [rad]
237 double m_expectedGain; //!< the gain which is theoretically expected [db]
238};
239
241 Ptr<AntennaModel> rxAntElem,
242 uint16_t txNumAntennas,
243 uint16_t rxNumAntennas,
244 Vector txPosVec,
245 Vector rxPosVec,
246 double txBearing,
247 double rxBearing,
248 double expectedGain)
249 // TODO: Create a string with the test parameters as the test case name like in
250 // test-uniform-planar-array ?
251 : TestCase("Check that the overall array response gain has the proper trend with respect to "
252 "the number of antennas and the type of single element antenna"),
253 m_txAntElem(txAntElem),
254 m_rxAntElem(rxAntElem),
255 m_txNumAntennas(txNumAntennas),
256 m_rxNumAntennas(rxNumAntennas),
257 m_txPosVec(txPosVec),
258 m_rxPosVec(rxPosVec),
259 m_txBearing(txBearing),
260 m_rxBearing(rxBearing),
261 m_expectedGain(expectedGain)
262{
263}
264
268
269void
271{
273 twoRaySplm->AssignStreams(1);
274
275 // Create and assign the channel condition model
276 auto channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
277 twoRaySplm->SetAttribute("ChannelConditionModel", PointerValue(channelConditionModel));
278
279 // Create the TX and RX antenna arrays
280 auto txArray = CreateObject<UniformPlanarArray>();
281 auto rxArray = CreateObject<UniformPlanarArray>();
282 txArray->SetAttribute("AntennaElement", PointerValue(m_txAntElem));
283 rxArray->SetAttribute("AntennaElement", PointerValue(m_rxAntElem));
284
285 // Create the corresponding mobility models
288 txPos->SetAttribute("Position", VectorValue(m_txPosVec));
289 rxPos->SetAttribute("Position", VectorValue(m_rxPosVec));
290
291 // Rotate the arrays
292 txArray->SetAttribute("BearingAngle", DoubleValue(m_txBearing));
293 rxArray->SetAttribute("BearingAngle", DoubleValue(m_rxBearing));
294
295 // Set the antenna arrays dimensions. Arrays are assumed to be squared.
296 txArray->SetAttribute("NumRows", UintegerValue(std::sqrt(m_txNumAntennas)));
297 txArray->SetAttribute("NumColumns", UintegerValue(std::sqrt(m_txNumAntennas)));
298 rxArray->SetAttribute("NumRows", UintegerValue(std::sqrt(m_rxNumAntennas)));
299 rxArray->SetAttribute("NumColumns", UintegerValue(std::sqrt(m_rxNumAntennas)));
300
301 // Compute the beamforming vectors
302 auto txBfVec = txArray->GetBeamformingVector(Angles(m_rxPosVec, m_txPosVec));
303 auto rxBfVec = rxArray->GetBeamformingVector(Angles(m_txPosVec, m_rxPosVec));
304 txArray->SetBeamformingVector(txBfVec);
305 rxArray->SetBeamformingVector(rxBfVec);
306
307 // Compute the overall array response
308 double gainTxRx = twoRaySplm->CalcBeamformingGain(txPos, rxPos, txArray, rxArray);
309 double gainRxTx = twoRaySplm->CalcBeamformingGain(rxPos, txPos, rxArray, txArray);
310
311 NS_TEST_EXPECT_MSG_EQ_TOL(gainTxRx, gainRxTx, gainTxRx * TOLERANCE, "gain should be symmetric");
312 NS_TEST_EXPECT_MSG_EQ_TOL(10 * log10(gainTxRx),
315 "gain different from the theoretically expected value");
316}
317
318/**
319 * \ingroup spectrum-tests
320 *
321 * Test case for the TwoRaySpectrumPropagationLossModel class.
322 *
323 * Check that the average overall channel gain obtained using the
324 * TwoRaySpectrumPropagationLossModel class is close (it is, after all,
325 * a simplified and performance-oriented model) to the one obtained using
326 * the ThreeGppSpectrumPropagationLossModel
327 */
329{
330 public:
331 /**
332 * The constructor of the test case
333 * \param txAntElem the antenna element of the TX antenna panel
334 * \param rxAntElem the antenna element of the RX antenna panel
335 * \param txNumAntennas the number of antenna elements of the TX antenna panel
336 * \param rxNumAntennas the number of antenna elements of the RX antenna panel
337 * \param fc the carrier frequency
338 * \param threeGppScenario the 3GPP scenario
339 */
341 Ptr<AntennaModel> rxAntElem,
342 uint16_t txNumAntennas,
343 uint16_t rxNumAntennas,
344 double fc,
345 std::string threeGppScenario);
346
347 /**
348 * Computes the overall power of a PSD
349 *
350 * \param psd the PSD
351 * \returns the overall power of the PSD, obtained as the integral of the
352 * sub-bands power over the PSD domain
353 */
355
356 /**
357 * Creates a PSD centered at fc, of bandwidth bw and sub-bands of
358 * width rbWidth
359 *
360 * \param fc the central frequency of the PSD
361 * \returns a PSD centered at fc, of bandwidth bw and sub-bands of
362 * width rbWidths
363 */
365
366 /**
367 * Destructor
368 */
369 ~OverallGainAverageTest() override;
370
371 private:
372 /**
373 * Build the test scenario
374 */
375 void DoRun() override;
376
377 /**
378 * Tolerance for testing average channel gain produced by the Two Ray model with
379 * respect to the 3GPP model, which serves as the reference.
380 */
381 static constexpr double TOLERANCE{0.02};
382
383 /// Number of samples to draw when estimating the average.
384 static constexpr uint32_t N_MEASUREMENTS{1000};
385
386 /// The simulation bandwidth. Results are independent from this parameter.
387 static constexpr double M_BW{200e6};
388
389 /**
390 * The width of a RB, which in turn specifies the resolution of the generated PSDs.
391 * Results are independent from this parameter.
392 */
393 static constexpr double M_RB_WIDTH{1e6};
394
395 Ptr<AntennaModel> m_txAntElem; //!< the antenna element of the TX antenna panel
396 Ptr<AntennaModel> m_rxAntElem; //!< the antenna element of the RX antenna panel
397 uint16_t m_txNumAntennas; //!< the number of antenna elements of the TX antenna panel
398 uint16_t m_rxNumAntennas; //!< the number of antenna elements of the RX antenna panel
399 double m_fc; //!< the carrier frequency
400 std::string m_threeGppScenario; //!< the 3GPP scenario
401};
402
404 Ptr<AntennaModel> rxAntElem,
405 uint16_t txNumAntennas,
406 uint16_t rxNumAntennas,
407 double fc,
408 std::string threeGppScenario)
409 // TODO: Create a string with the test parameters as the test case name like in
410 // test-uniform-planar-array ?
411 : TestCase("Check that the overall array response gain has the proper trend with respect to"
412 "the number of antennas and the type of single element antenna"),
413 m_txAntElem(txAntElem),
414 m_rxAntElem(rxAntElem),
415 m_txNumAntennas(txNumAntennas),
416 m_rxNumAntennas(rxNumAntennas),
417 m_fc(fc),
418 m_threeGppScenario(threeGppScenario)
419{
420}
421
425
426double
431
434{
435 uint32_t numRbs = std::floor(M_BW / M_RB_WIDTH);
436 double f = fc - (numRbs * M_RB_WIDTH / 2.0);
437 double powerTx = 0.0;
438
439 Bands rbs; // A vector representing each resource block
440 std::vector<int> rbsId; // A vector representing the resource block IDs
441 rbs.reserve(numRbs);
442 rbsId.reserve(numRbs);
443 for (uint32_t numrb = 0; numrb < numRbs; ++numrb)
444 {
445 BandInfo rb;
446 rb.fl = f;
447 f += M_RB_WIDTH / 2;
448 rb.fc = f;
449 f += M_RB_WIDTH / 2;
450 rb.fh = f;
451
452 rbs.push_back(rb);
453 rbsId.push_back(numrb);
454 }
457
458 double powerTxW = std::pow(10., (powerTx - 30) / 10);
459 double txPowerDensity = powerTxW / M_BW;
460
461 for (const auto& rbId : rbsId)
462 {
463 (*txPsd)[rbId] = txPowerDensity;
464 }
465
466 return txPsd;
467}
468
469void
471{
472 // Create the Two Ray and 3GPP SPLMs
475 auto threeGppChannelModel = CreateObject<ThreeGppChannelModel>();
476 auto channelConditionModel = CreateObject<AlwaysLosChannelConditionModel>();
477 twoRaySplm->AssignStreams(1);
478 threeGppChannelModel->AssignStreams(1);
479
480 // Pass the needed pointers between the various spectrum instances
481 threeGppSplm->SetAttribute("ChannelModel", PointerValue(threeGppChannelModel));
482 threeGppChannelModel->SetAttribute("ChannelConditionModel",
483 PointerValue(channelConditionModel));
484 twoRaySplm->SetAttribute("ChannelConditionModel", PointerValue(channelConditionModel));
485
486 // Create the TX and RX nodes and mobility models
488 nodes.Create(2);
489 MobilityHelper mobility;
491 Vector txPosVec(0.0, 0.0, 0.0);
492 Vector rxPosVec(5.0, 0.0, 0.0);
493 positionAlloc->Add(txPosVec);
494 positionAlloc->Add(rxPosVec);
495 mobility.SetPositionAllocator(positionAlloc);
496 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
497 mobility.Install(nodes);
498
499 // Create the TX antenna array
500 auto txArray = CreateObject<UniformPlanarArray>();
501 txArray->SetAttribute("AntennaElement", PointerValue(m_txAntElem));
502
503 // Rotate the array
504 txArray->SetAttribute("BearingAngle", DoubleValue(0));
505
506 // Set the antenna array dimensions. Arrays are assumed to be squared.
507 txArray->SetAttribute("NumRows", UintegerValue(std::sqrt(m_txNumAntennas)));
508 txArray->SetAttribute("NumColumns", UintegerValue(std::sqrt(m_txNumAntennas)));
509
510 // Set the channel simulation parameters
511 threeGppChannelModel->SetAttribute("Frequency", DoubleValue(m_fc));
512 twoRaySplm->SetAttribute("Frequency", DoubleValue(m_fc));
513 threeGppChannelModel->SetAttribute("Scenario", StringValue(m_threeGppScenario));
514 twoRaySplm->SetAttribute("Scenario", StringValue(m_threeGppScenario));
515
516 // Disable blockage in order to prevent unwanted variations around the mean value
517 threeGppChannelModel->SetAttribute("Blockage", BooleanValue(false));
518
519 // Create the TX PSD
521 double txPower = ComputePowerSpectralDensityOverallPower(txPsd);
522
523 // Create TX signal parameters
525 signalParams->psd = txPsd;
526
527 // Compute and set the TX beamforming vector
528 auto txBfVec = txArray->GetBeamformingVector(Angles(rxPosVec, txPosVec));
529 txArray->SetBeamformingVector(txBfVec);
530
533
534 double threeGppGainMean = 0;
535 double twoRayGainMean = 0;
536
537 // Compute the overall array responses
538 for (uint32_t i = 0; i < N_MEASUREMENTS; ++i)
539 {
540 // Re-create the RX array at each iteration, to force resampling of the 3GPP channel
541 auto rxArray = CreateObject<UniformPlanarArray>();
542
543 // Rotate the RX antenna array and set its dimensions
544 rxArray->SetAttribute("AntennaElement", PointerValue(m_rxAntElem));
545 rxArray->SetAttribute("BearingAngle", DoubleValue(-M_PI));
546 rxArray->SetAttribute("NumRows", UintegerValue(std::sqrt(m_rxNumAntennas)));
547 rxArray->SetAttribute("NumColumns", UintegerValue(std::sqrt(m_rxNumAntennas)));
548
549 // Compute and set the RX beamforming vector
550 auto rxBfVec = rxArray->GetBeamformingVector(Angles(txPosVec, rxPosVec));
551 rxArray->SetBeamformingVector(rxBfVec);
552
553 auto twoRayRxParams =
554 twoRaySplm->DoCalcRxPowerSpectralDensity(signalParams, txMob, rxMob, txArray, rxArray);
555 auto threeGppRayRxParams = threeGppSplm->DoCalcRxPowerSpectralDensity(signalParams,
556 txMob,
557 rxMob,
558 txArray,
559 rxArray);
560 double twoRayRxPower = ComputePowerSpectralDensityOverallPower(twoRayRxParams->psd);
561 double threeGppRxPower = ComputePowerSpectralDensityOverallPower(threeGppRayRxParams->psd);
562
563 twoRayGainMean += (twoRayRxPower / txPower);
564 threeGppGainMean += (threeGppRxPower / txPower);
565 }
566
568 twoRayGainMean / N_MEASUREMENTS,
569 threeGppGainMean / N_MEASUREMENTS,
570 twoRayGainMean * TOLERANCE,
571 "The 3GPP and Two Ray models should provide similar average channel gains");
572}
573
574/**
575 * \ingroup spectrum-tests
576 *
577 * Test suite for the TwoRaySpectrumPropagationLossModel class
578 */
580{
581 public:
582 /**
583 * Constructor
584 */
586};
587
589 : TestSuite("two-ray-splm-suite", Type::UNIT)
590{
591 // Test the GetFtrFastFading function of the TwoRaySpectrumPropagationLossModel class
592 AddTestCase(new FtrFadingModelAverageTest, TestCase::Duration::QUICK);
593
594 // Test the CalcBeamformingGain function of the TwoRaySpectrumPropagationLossModel class
597 const double maxTgppGain = tgpp->GetGainDb(Angles(0.0, M_PI / 2));
598
599 // Deploy 2 squared antenna arrays which face each other. Steer their beam towards the boresight
600 // and check the resulting array gain. SE = single element radiation pattern, N = number of
601 // radiating elements, Phi = bearing angle
602 // SE tx, SE rx, N tx, N rx, position tx, position
603 // rx, Phi tx, Phi rx, expected gain
605 iso,
606 1,
607 1,
608 Vector(0.0, 0.0, 0.0),
609 Vector(5.0, 0.0, 0.0),
610 0.0,
611 -M_PI,
612 0.0),
613 TestCase::Duration::QUICK);
615 iso,
616 4,
617 1,
618 Vector(0.0, 0.0, 0.0),
619 Vector(5.0, 0.0, 0.0),
620 0.0,
621 -M_PI,
622 10 * log10(4)),
623 TestCase::Duration::QUICK);
625 iso,
626 16,
627 1,
628 Vector(0.0, 0.0, 0.0),
629 Vector(5.0, 0.0, 0.0),
630 0.0,
631 -M_PI,
632 10 * log10(16)),
633 TestCase::Duration::QUICK);
635 iso,
636 64,
637 1,
638 Vector(0.0, 0.0, 0.0),
639 Vector(5.0, 0.0, 0.0),
640 0.0,
641 -M_PI,
642 10 * log10(64)),
643 TestCase::Duration::QUICK);
645 iso,
646 4,
647 4,
648 Vector(0.0, 0.0, 0.0),
649 Vector(5.0, 0.0, 0.0),
650 0.0,
651 -M_PI,
652 2 * 10 * log10(4)),
653 TestCase::Duration::QUICK);
655 iso,
656 16,
657 16,
658 Vector(0.0, 0.0, 0.0),
659 Vector(5.0, 0.0, 0.0),
660 0.0,
661 -M_PI,
662 2 * 10 * log10(16)),
663 TestCase::Duration::QUICK);
665 iso,
666 64,
667 64,
668 Vector(0.0, 0.0, 0.0),
669 Vector(5.0, 0.0, 0.0),
670 0.0,
671 -M_PI,
672 2 * 10 * log10(64)),
673 TestCase::Duration::QUICK);
675 iso,
676 1,
677 1,
678 Vector(0.0, 0.0, 0.0),
679 Vector(5.0, 0.0, 0.0),
680 0.0,
681 -M_PI,
682 maxTgppGain),
683 TestCase::Duration::QUICK);
685 iso,
686 4,
687 1,
688 Vector(0.0, 0.0, 0.0),
689 Vector(5.0, 0.0, 0.0),
690 0.0,
691 -M_PI,
692 10 * log10(4) + maxTgppGain),
693 TestCase::Duration::QUICK);
695 iso,
696 16,
697 1,
698 Vector(0.0, 0.0, 0.0),
699 Vector(5.0, 0.0, 0.0),
700 0.0,
701 -M_PI,
702 10 * log10(16) + maxTgppGain),
703 TestCase::Duration::QUICK);
705 iso,
706 64,
707 1,
708 Vector(0.0, 0.0, 0.0),
709 Vector(5.0, 0.0, 0.0),
710 0.0,
711 -M_PI,
712 10 * log10(64) + maxTgppGain),
713 TestCase::Duration::QUICK);
715 tgpp,
716 1,
717 1,
718 Vector(0.0, 0.0, 0.0),
719 Vector(5.0, 0.0, 0.0),
720 0.0,
721 -M_PI,
722 2 * maxTgppGain),
723 TestCase::Duration::QUICK);
725 tgpp,
726 4,
727 1,
728 Vector(0.0, 0.0, 0.0),
729 Vector(5.0, 0.0, 0.0),
730 0.0,
731 -M_PI,
732 10 * log10(4) + 2 * maxTgppGain),
733 TestCase::Duration::QUICK);
735 tgpp,
736 16,
737 1,
738 Vector(0.0, 0.0, 0.0),
739 Vector(5.0, 0.0, 0.0),
740 0.0,
741 -M_PI,
742 10 * log10(16) + 2 * maxTgppGain),
743 TestCase::Duration::QUICK);
745 tgpp,
746 64,
747 1,
748 Vector(0.0, 0.0, 0.0),
749 Vector(5.0, 0.0, 0.0),
750 0.0,
751 -M_PI,
752 10 * log10(64) + 2 * maxTgppGain),
753 TestCase::Duration::QUICK);
755 tgpp,
756 4,
757 4,
758 Vector(0.0, 0.0, 0.0),
759 Vector(5.0, 0.0, 0.0),
760 0.0,
761 -M_PI,
762 2 * 10 * log10(4) + 2 * maxTgppGain),
763 TestCase::Duration::QUICK);
765 tgpp,
766 16,
767 16,
768 Vector(0.0, 0.0, 0.0),
769 Vector(5.0, 0.0, 0.0),
770 0.0,
771 -M_PI,
772 2 * 10 * log10(16) + 2 * maxTgppGain),
773 TestCase::Duration::QUICK);
775 tgpp,
776 64,
777 64,
778 Vector(0.0, 0.0, 0.0),
779 Vector(5.0, 0.0, 0.0),
780 0.0,
781 -M_PI,
782 2 * 10 * log10(64) + 2 * maxTgppGain),
783 TestCase::Duration::QUICK);
784
785 // Deploy 2 squared antenna arrays which face each other. Steer their beam towards the boresight
786 // and check the overall resulting channel gain. SE = single element radiation pattern, N =
787 // number of radiating elements, Fc = carrier frequency, Scen = 3GPP scenario
788 // SE tx, SE rx, N tx, N rx, Fc, Scen
789 AddTestCase(new OverallGainAverageTest(iso, iso, 1, 1, 10e9, "RMa"),
790 TestCase::Duration::EXTENSIVE);
791 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 1, 1, 10e9, "RMa"),
792 TestCase::Duration::EXTENSIVE);
793 AddTestCase(new OverallGainAverageTest(iso, iso, 4, 4, 10e9, "RMa"),
794 TestCase::Duration::EXTENSIVE);
795 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 4, 4, 10e9, "RMa"),
796 TestCase::Duration::EXTENSIVE);
797 AddTestCase(new OverallGainAverageTest(iso, iso, 1, 1, 10e9, "UMa"),
798 TestCase::Duration::EXTENSIVE);
799 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 1, 1, 10e9, "UMa"),
800 TestCase::Duration::EXTENSIVE);
801 AddTestCase(new OverallGainAverageTest(iso, iso, 4, 4, 10e9, "UMa"),
802 TestCase::Duration::EXTENSIVE);
803 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 4, 4, 10e9, "UMa"),
804 TestCase::Duration::EXTENSIVE);
805 AddTestCase(new OverallGainAverageTest(iso, iso, 1, 1, 60e9, "UMi-StreetCanyon"),
806 TestCase::Duration::EXTENSIVE);
807 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 1, 1, 60e9, "UMi-StreetCanyon"),
808 TestCase::Duration::EXTENSIVE);
809 AddTestCase(new OverallGainAverageTest(iso, iso, 4, 4, 60e9, "UMi-StreetCanyon"),
810 TestCase::Duration::EXTENSIVE);
811 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 4, 4, 60e9, "UMi-StreetCanyon"),
812 TestCase::Duration::EXTENSIVE);
813 AddTestCase(new OverallGainAverageTest(iso, iso, 1, 1, 60e9, "InH-OfficeOpen"),
814 TestCase::Duration::EXTENSIVE);
815 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 1, 1, 60e9, "InH-OfficeOpen"),
816 TestCase::Duration::EXTENSIVE);
817 AddTestCase(new OverallGainAverageTest(iso, iso, 4, 4, 60e9, "InH-OfficeOpen"),
818 TestCase::Duration::EXTENSIVE);
819 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 4, 4, 60e9, "InH-OfficeOpen"),
820 TestCase::Duration::EXTENSIVE);
821 AddTestCase(new OverallGainAverageTest(iso, iso, 1, 1, 100e9, "InH-OfficeMixed"),
822 TestCase::Duration::EXTENSIVE);
823 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 1, 1, 100e9, "InH-OfficeMixed"),
824 TestCase::Duration::EXTENSIVE);
825 AddTestCase(new OverallGainAverageTest(iso, iso, 4, 4, 100e9, "InH-OfficeMixed"),
826 TestCase::Duration::EXTENSIVE);
827 AddTestCase(new OverallGainAverageTest(tgpp, tgpp, 4, 4, 100e9, "InH-OfficeMixed"),
828 TestCase::Duration::EXTENSIVE);
829}
830
831// Static variable for test initialization
Test case for the TwoRaySpectrumPropagationLossModel class.
uint16_t m_txNumAntennas
the number of antenna elements of the TX antenna panel
~ArrayResponseTest() override
Destructor.
uint16_t m_rxNumAntennas
the number of antenna elements of the RX antenna panel
static constexpr double TOLERANCE
Tolerance for testing value produced by the simulator against expected theoretical value,...
double m_rxBearing
the bearing angle of the RX antenna panel [rad]
Vector m_rxPosVec
the position of the RX
Vector m_txPosVec
the position of the TX
double m_txBearing
the bearing angle of the TX antenna panel [rad]
Ptr< AntennaModel > m_txAntElem
the antenna element of the TX antenna panel
double m_expectedGain
the gain which is theoretically expected [db]
void DoRun() override
Build the test scenario.
Ptr< AntennaModel > m_rxAntElem
the antenna element of the RX antenna panel
ArrayResponseTest(Ptr< AntennaModel > txAntElem, Ptr< AntennaModel > rxAntElem, uint16_t txNumAntennas, uint16_t rxNumAntennas, Vector txPosVec, Vector rxPosVec, double txBearing, double rxBearing, double expectedGain)
The constructor of the test case.
Test case for the TwoRaySpectrumPropagationLossModel class.
static constexpr uint32_t N_MEASUREMENTS
Number of samples to draw when populating the distribution.
static constexpr uint16_t MAX_M_VALUE
Maximum value for the m parameter.
double FtrSquaredNormAverage(const TwoRaySpectrumPropagationLossModel::FtrParams &ftrParams) const
Compute the average of the FTR squared norm.
static constexpr uint8_t NUM_VALUES
Number of different values for each FTR parameter.
~FtrFadingModelAverageTest() override
Destructor.
static constexpr double TOLERANCE
Tolerance for testing FTR's expectations against theoretical values, expressed as a fraction of the e...
void DoRun() override
Build the test scenario.
constexpr double FtrSquaredNormExpectedMean(double sigma, double k) const
Compute the expected mean of the FTR squared norm.
Test case for the TwoRaySpectrumPropagationLossModel class.
Ptr< AntennaModel > m_txAntElem
the antenna element of the TX antenna panel
uint16_t m_rxNumAntennas
the number of antenna elements of the RX antenna panel
double m_fc
the carrier frequency
static constexpr double M_RB_WIDTH
The width of a RB, which in turn specifies the resolution of the generated PSDs.
double ComputePowerSpectralDensityOverallPower(Ptr< const SpectrumValue > psd)
Computes the overall power of a PSD.
static constexpr uint32_t N_MEASUREMENTS
Number of samples to draw when estimating the average.
static constexpr double M_BW
The simulation bandwidth. Results are independent from this parameter.
std::string m_threeGppScenario
the 3GPP scenario
~OverallGainAverageTest() override
Destructor.
Ptr< AntennaModel > m_rxAntElem
the antenna element of the RX antenna panel
OverallGainAverageTest(Ptr< AntennaModel > txAntElem, Ptr< AntennaModel > rxAntElem, uint16_t txNumAntennas, uint16_t rxNumAntennas, double fc, std::string threeGppScenario)
The constructor of the test case.
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double fc)
Creates a PSD centered at fc, of bandwidth bw and sub-bands of width rbWidth.
void DoRun() override
Build the test scenario.
static constexpr double TOLERANCE
Tolerance for testing average channel gain produced by the Two Ray model with respect to the 3GPP mod...
uint16_t m_txNumAntennas
the number of antenna elements of the TX antenna panel
Test suite for the TwoRaySpectrumPropagationLossModel class.
Class holding the azimuth and inclination angles of spherical coordinates.
Definition angles.h:107
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition object.h:511
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
Definition string.h:45
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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 ...
Definition test.h:500
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition test.h:327
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Integral(const SpectrumValue &arg)
std::vector< BandInfo > Bands
Container of BandInfo.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
Struct holding the Fluctuating Two Ray fast-fading model parameters.
static TwoRaySplmTestSuite myTestSuite