12#include <ns3/spectrum-value.h>
14#include <ns3/tv-spectrum-transmitter.h>
45 double channelBandwidth,
51 void DoRun()
override;
61 double startFrequency,
62 double channelBandwidth,
73 double startFrequency,
74 double channelBandwidth,
77 std::ostringstream oss;
78 oss <<
"TV type = " << tvType <<
", "
79 <<
"start frequency = " << startFrequency <<
" Hz, "
80 <<
"channel bandwidth = " << channelBandwidth <<
" Hz, "
81 <<
"base PSD = " << basePsd <<
" dBm per Hz";
86 double channelBandwidth,
89 :
TestCase(
Name(tvType, startFrequency, channelBandwidth, basePsd)),
90 m_startFrequency(startFrequency),
91 m_channelBandwidth(channelBandwidth),
116 auto psdIter = psd->ConstValuesBegin();
118 while (psdIter != psd->ConstValuesEnd())
120 if (*psdIter > maxValue)
126 double basePsdWattsHz = pow(10.0, (
m_basePsd - 30) / 10.0);
129 double expectedPsd = (0.502 * basePsdWattsHz) + (21.577 * basePsdWattsHz);
134 "peak PSD value (" << maxValue <<
") is incorrect");
142 "peak PSD value (" << maxValue <<
") is incorrect");
146 auto bandStart = psd->ConstBandsBegin();
147 auto bandEnd = psd->ConstBandsEnd();
152 "start frequency value (" << (*bandStart).fc <<
") is incorrect");
158 "end frequency value (" << (*(bandEnd - 1)).fc <<
") is incorrect");
175 NS_LOG_INFO(
"creating TvSpectrumTransmitterTestSuite");
176 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
178 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
180 for (
double psd = -100; psd <= 100; psd += 20)
186 TestCase::Duration::QUICK);
190 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
192 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
194 for (
double psd = -100; psd <= 100; psd += 20)
200 TestCase::Duration::QUICK);
204 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
206 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
208 for (
double psd = -100; psd <= 100; psd += 20)
214 TestCase::Duration::QUICK);
This test verifies the accuracy of the spectrum/PSD model in the TvSpectrumTransmitter class.
TvSpectrumTransmitterTestCase(double startFrequency, double channelBandwidth, double basePsd, TvSpectrumTransmitter::TvType tvType)
Constructor.
double m_startFrequency
Start frequency.
void DoRun() override
Implementation to actually run this TestCase.
TvSpectrumTransmitter::TvType m_tvType
TV type.
~TvSpectrumTransmitterTestCase() override
double m_basePsd
Base Power Spectral Density (PSD).
static std::string Name(TvSpectrumTransmitter::TvType tvType, double startFrequency, double channelBandwidth, double basePsd)
Build the test name.
double m_channelBandwidth
Channel Bandwidth.
Test suite for the TvSpectrumTransmitter class.
TvSpectrumTransmitterTestSuite()
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
Smart pointer class similar to boost::intrusive_ptr.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TvType
types of TV transmitters: analog, digital 8-VSB, or digital COFDM
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const double TOLERANCE
Tolerance used to check reciprocal of two numbers.
static std::string Name(std::string str, uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t serverReadSize, uint32_t serverWriteSize, uint32_t sourceReadSize, bool useIpv6)
static TvSpectrumTransmitterTestSuite g_tvSpectrumTransmitterTestSuite
Static variable for test initialization.