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