20 #include <ns3/double.h>
23 #include <ns3/spectrum-value.h>
25 #include <ns3/tv-spectrum-transmitter.h>
56 double channelBandwidth,
62 void DoRun()
override;
72 double startFrequency,
73 double channelBandwidth,
84 double startFrequency,
85 double channelBandwidth,
88 std::ostringstream oss;
89 oss <<
"TV type = " << tvType <<
", "
90 <<
"start frequency = " << startFrequency <<
" Hz, "
91 <<
"channel bandwidth = " << channelBandwidth <<
" Hz, "
92 <<
"base PSD = " << basePsd <<
" dBm per Hz";
97 double channelBandwidth,
100 :
TestCase(
Name(tvType, startFrequency, channelBandwidth, basePsd)),
101 m_startFrequency(startFrequency),
102 m_channelBandwidth(channelBandwidth),
131 if (*psdIter > maxValue)
137 double basePsdWattsHz = pow(10.0, (
m_basePsd - 30) / 10.0);
138 if (
m_tvType == TvSpectrumTransmitter::TVTYPE_8VSB)
140 double expectedPsd = (0.502 * basePsdWattsHz) + (21.577 * basePsdWattsHz);
145 "peak PSD value (" << maxValue <<
") is incorrect");
153 "peak PSD value (" << maxValue <<
") is incorrect");
163 "start frequency value (" << (*bandStart).fc <<
") is incorrect");
169 "end frequency value (" << (*(bandEnd - 1)).fc <<
") is incorrect");
184 :
TestSuite(
"tv-spectrum-transmitter", UNIT)
186 NS_LOG_INFO(
"creating TvSpectrumTransmitterTestSuite");
187 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
189 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
191 for (
double psd = -100; psd <= 100; psd += 20)
196 TvSpectrumTransmitter::TVTYPE_8VSB),
201 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
203 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
205 for (
double psd = -100; psd <= 100; psd += 20)
210 TvSpectrumTransmitter::TVTYPE_COFDM),
215 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
217 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
219 for (
double psd = -100; psd <= 100; psd += 20)
224 TvSpectrumTransmitter::TVTYPE_ANALOG),
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.
Values::const_iterator ConstValuesBegin() const
Bands::const_iterator ConstBandsEnd() const
Bands::const_iterator ConstBandsBegin() const
Values::const_iterator ConstValuesEnd() const
void AddTestCase(TestCase *testCase, TestDuration 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.
#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.