23 #include <ns3/spectrum-value.h>
25 #include <ns3/double.h>
26 #include <ns3/tv-spectrum-transmitter.h>
57 double channelBandwidth,
63 virtual void DoRun (
void);
73 double startFrequency,
74 double channelBandwidth,
86 double startFrequency,
87 double channelBandwidth,
90 std::ostringstream oss;
91 oss <<
"TV type = " << tvType <<
", "
92 <<
"start frequency = " << startFrequency <<
" Hz, "
93 <<
"channel bandwidth = " << channelBandwidth <<
" Hz, "
94 <<
"base PSD = " << basePsd <<
" dBm per Hz";
99 double channelBandwidth,
102 :
TestCase (
Name (tvType, startFrequency, channelBandwidth, basePsd)),
103 m_startFrequency (startFrequency),
104 m_channelBandwidth (channelBandwidth),
133 if (*psdIter > maxValue)
139 double basePsdWattsHz = pow (10.0, (
m_basePsd - 30) / 10.0);
140 if (
m_tvType == TvSpectrumTransmitter::TVTYPE_8VSB)
142 double expectedPsd = (0.502 * basePsdWattsHz) + (21.577 * basePsdWattsHz);
147 "peak PSD value (" << maxValue <<
") is incorrect");
155 "peak PSD value (" << maxValue <<
") is incorrect");
165 "start frequency value (" << (*bandStart).fc <<
") is incorrect");
170 "end frequency value (" << (*(bandEnd - 1)).fc <<
") is incorrect");
186 :
TestSuite (
"tv-spectrum-transmitter", UNIT)
188 NS_LOG_INFO (
"creating TvSpectrumTransmitterTestSuite");
189 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
191 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
193 for (
double psd = -100; psd <= 100; psd += 20)
198 TvSpectrumTransmitter::TVTYPE_8VSB),
203 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
205 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
207 for (
double psd = -100; psd <= 100; psd += 20)
212 TvSpectrumTransmitter::TVTYPE_COFDM),
217 for (
double startFreq = 100; startFreq < 1e15; startFreq *= 10)
219 for (
double bandwidth = 100; bandwidth < 1e15; bandwidth *= 10)
221 for (
double psd = -100; psd <= 100; psd += 20)
226 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.
TvSpectrumTransmitter::TvType m_tvType
TV type.
double m_basePsd
Base Power Spectral Density (PSD).
virtual ~TvSpectrumTransmitterTestCase()
static std::string Name(TvSpectrumTransmitter::TvType tvType, double startFrequency, double channelBandwidth, double basePsd)
Build the test name.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.