spectrum: doxygen fixes

This commit is contained in:
Tommaso Pecorella
2022-01-09 20:41:25 -06:00
parent df97e13ffa
commit 48e6ac5405
16 changed files with 250 additions and 86 deletions

View File

@@ -46,6 +46,7 @@ struct HalfDuplexIdealPhySignalParameters : public SpectrumSignalParameters
/**
* copy constructor
* \param p object to copy
*/
HalfDuplexIdealPhySignalParameters (const HalfDuplexIdealPhySignalParameters& p);

View File

@@ -114,10 +114,12 @@ private:
/**
* Adds a signal to the data collected.
* \param psd signal to add
*/
void AddSignal (Ptr<const SpectrumValue> psd);
/**
* Removes a signal to the data collected.
* \param psd signal to subtract
*/
void SubtractSignal (Ptr<const SpectrumValue> psd);
/**

View File

@@ -24,10 +24,19 @@
namespace ns3 {
/**
* \ingroup spectrum
* Spectrum model logger for frequencies between 300 Khz 300 Ghz
*/
Ptr<SpectrumModel> SpectrumModel300Khz300GhzLog;
/**
* \ingroup spectrum
*
* Static initializer class for Spectrum model logger
* for frequencies between 300 Khz 300 Ghz
*/
class static_SpectrumModel300Khz300GhzLog_initializer
{
public:
@@ -42,10 +51,12 @@ public:
SpectrumModel300Khz300GhzLog = Create<SpectrumModel> (freqs);
}
} static_SpectrumModel300Khz300GhzLog_initializer_instance;
};
/**
* \ingroup spectrum
* Static variable for analyzer initialization
*/
static_SpectrumModel300Khz300GhzLog_initializer g_static_SpectrumModel300Khz300GhzLog_initializer_instance;
}

View File

@@ -23,11 +23,20 @@
namespace ns3 {
/**
* \ingroup spectrum
* Spectrum model logger for frequencies in the 2.4 GHz ISM band
* with 1 MHz resolution.
*/
Ptr<SpectrumModel> SpectrumModelIsm2400MhzRes1Mhz;
/**
* \ingroup spectrum
*
* Static initializer class for Spectrum model logger for
* frequencies in the 2.4 GHz ISM band with 1 MHz resolution.
*/
class static_SpectrumModelIsm2400MhzRes1Mhz_initializer
{
public:
@@ -44,10 +53,12 @@ public:
SpectrumModelIsm2400MhzRes1Mhz = Create<SpectrumModel> (freqs);
}
} static_SpectrumModelIsm2400MhzRes1Mhz_initializer_instance;
};
/**
* \ingroup spectrum
* Static variable for analyzer initialization
*/
static_SpectrumModelIsm2400MhzRes1Mhz_initializer g_static_SpectrumModelIsm2400MhzRes1Mhz_initializer_instance;
}

View File

@@ -28,7 +28,12 @@ namespace ns3 {
/**
* \defgroup spectrum Spectrum Models
*
*/
/**
* \ingroup spectrum
* \ingroup tests
* \defgroup spectrum-tests Spectrum Models tests
*/
/**

View File

@@ -66,6 +66,7 @@ struct SpectrumSignalParameters : public SimpleRefCount<SpectrumSignalParameters
/**
* copy constructor
* \param p object to copy
*/
SpectrumSignalParameters (const SpectrumSignalParameters& p);

View File

@@ -572,10 +572,12 @@ private:
void ChangeSign ();
/**
* Shift the values to the left
* \param n number of positions to shift
*/
void ShiftLeft (int n);
/**
* Shift the values to the right
* \param n number of positions to shift
*/
void ShiftRight (int n);
/**

View File

@@ -103,9 +103,6 @@ public:
* Analog PSD approximated from Figure 4 of the following paper:
* Stephen Shellhammer, Ahmed Sadek, and Wenyi Zhang. "Technical Challenges
* for Cognitive Radio in the TV White Space Spectrum." Qualcomm Incorporated.
*
*
* @return a pointer to the power spectral density of the TV transmitter
*/
virtual void CreateTvPsd ();

View File

@@ -64,9 +64,21 @@ PhyRxEndOkTrace (std::string context, Ptr<const Packet> p)
}
/**
* \ingroup spectrum-tests
*
* \brief Ideal Spectrum PHY Test
*/
class SpectrumIdealPhyTestCase : public TestCase
{
public:
/**
* Constructor
* \param snrLinear SNR (linear)
* \param phyRate PHY rate (bps)
* \param rateIsAchievable Check if the rate is achievable
* \param channelType Channel type
*/
SpectrumIdealPhyTestCase (double snrLinear,
uint64_t phyRate,
bool rateIsAchievable,
@@ -75,12 +87,19 @@ public:
private:
virtual void DoRun (void);
/**
* Get the test name
* \param channelType Channel type
* \param snrLinear SNR (linear)
* \param phyRate PHY rate (bps)
* \return the test name
*/
static std::string Name (std::string channelType, double snrLinear, uint64_t phyRate);
double m_snrLinear;
uint64_t m_phyRate;
bool m_rateIsAchievable;
std::string m_channelType;
double m_snrLinear; //!< SNR (linear)
uint64_t m_phyRate; //!< PHY rate (bps)
bool m_rateIsAchievable; //!< Check if the rate is achievable
std::string m_channelType; //!< Channel type
};
std::string
@@ -210,7 +229,11 @@ SpectrumIdealPhyTestCase::DoRun (void)
/**
* \ingroup spectrum-tests
*
* \brief Ideal Spectrum PHY TestSuite
*/
class SpectrumIdealPhyTestSuite : public TestSuite
{
public:
@@ -245,4 +268,5 @@ SpectrumIdealPhyTestSuite::SpectrumIdealPhyTestSuite ()
}
}
/// Static variable for test initialization
static SpectrumIdealPhyTestSuite g_spectrumIdealPhyTestSuite;

View File

@@ -34,19 +34,35 @@ NS_LOG_COMPONENT_DEFINE ("SpectrumInterferenceTest");
/**
* \ingroup spectrum-tests
*
* \brief Spectrum Interference Test
*/
class SpectrumInterferenceTestCase : public TestCase
{
public:
/**
* Constructor
* \param s Spectrum value
* \param txBytes number of bytes to transmit
* \param rxCorrect extected Rx bytes
* \param name test name
*/
SpectrumInterferenceTestCase (Ptr<SpectrumValue> s, uint32_t txBytes, bool rxCorrect, std::string name);
virtual ~SpectrumInterferenceTestCase ();
virtual void DoRun (void);
/**
* Retrieve the test results
* \param si SpectrumInterference instance
*/
void RetrieveTestResult (SpectrumInterference* si);
private:
Ptr<SpectrumValue> m_s;
uint32_t m_txBytes;
uint32_t m_rxCorrectKnownOutcome;
Ptr<const SpectrumModel> m_mySpectrumModel;
Ptr<SpectrumValue> m_s; //!< Spectrum value
uint32_t m_txBytes; //!< number of bytes to transmit
uint32_t m_rxCorrectKnownOutcome; //!< extected Rx bytes
Ptr<const SpectrumModel> m_mySpectrumModel; //!< Spectrum model pointer
};
@@ -130,6 +146,11 @@ SpectrumInterferenceTestCase::RetrieveTestResult (SpectrumInterference* si)
/**
* \ingroup spectrum-tests
*
* \brief Spectrum Interference TestSuite
*/
class SpectrumInterferenceTestSuite : public TestSuite
{
public:
@@ -191,4 +212,5 @@ SpectrumInterferenceTestSuite::SpectrumInterferenceTestSuite ()
}
/// Static variable for test initialization
static SpectrumInterferenceTestSuite spectrumInterferenceTestSuite;

View File

@@ -25,6 +25,14 @@
/**
* \ingroup spectrum
* \defgroup spectrum-test Spectrum module tests
*/
/**
* \ingroup spectrum-tests
*
* \brief Test if two SpectrumModel instances are equal within a given tolerance.
*
* This test compares component-by-component the two SpectrumModel
@@ -38,20 +46,16 @@
*
*/
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \
NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL (actual, expected, tol, msg, __FILE__, __LINE__)
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
do \
{ \
Bands::const_iterator i = (actual).Begin (); \
Bands::const_iterator j = (expected).Begin (); \
uint32_t k = 0; \
while (i != (actual).End () && j != (expected).End ()) \
{ \
if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) \
|| (i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) \
|| (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
do \
{ \
Bands::const_iterator i = (actual).Begin (); \
Bands::const_iterator j = (expected).Begin (); \
uint32_t k = 0; \
while (i != (actual).End () && j != (expected).End ()) \
{ \
if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) \
|| (i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) \
|| (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
{ \
ASSERT_ON_FAILURE; \
std::ostringstream indexStream; \
@@ -63,7 +67,7 @@
std::ostringstream expectedStream; \
expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh; \
ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (), \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
actualStream.str (), expectedStream.str (), msgStream.str (), ( __FILE__), ( __LINE__)); \
CONTINUE_ON_FAILURE; \
} \
++i; \
@@ -79,13 +83,15 @@
std::ostringstream expectedStream; \
expectedStream << (j != (expected).End ()); \
ReportTestFailure ("Bands::iterator == End ()", \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
actualStream.str (), expectedStream.str (), msgStream.str (), ( __FILE__), ( __LINE__)); \
} \
} \
while (false); \
/**
* \ingroup spectrum-tests
*
* \brief Test if two SpectrumValue instances are equal within a given tolerance.
*
* This test compares component-by-component the two SpectrumValue
@@ -99,12 +105,8 @@
*
*/
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL (actual, expected, tol, msg, __FILE__, __LINE__)
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
do \
{ \
do \
{ \
Values::const_iterator i = (actual).ConstValuesBegin (); \
Values::const_iterator j = (expected).ConstValuesBegin (); \
uint32_t k = 0; \
@@ -122,7 +124,7 @@
std::ostringstream expectedStream; \
expectedStream << expected; \
ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (), \
actualStream.str (), expectedStream.str (), msgStream.str (), file, line); \
actualStream.str (), expectedStream.str (), msgStream.str (), __FILE__, __LINE__); \
CONTINUE_ON_FAILURE; \
} \
++i; \
@@ -138,7 +140,7 @@
std::ostringstream expectedStream; \
expectedStream << (j != (expected).ConstValuesEnd ()); \
ReportTestFailure ("Values::const_iterator == ConstValuesEnd ()", \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
actualStream.str (), expectedStream.str (), msgStream.str (), ( __FILE__), ( __LINE__)); \
} \
} \
while (false); \

View File

@@ -34,17 +34,35 @@ using namespace ns3;
#define TOLERANCE 1e-6
/**
* \ingroup spectrum-tests
*
* \brief Spectrum Value Test
*/
class SpectrumValueTestCase : public TestCase
{
public:
/**
* Constructor
* \param a first SpectrumValue
* \param b second SpectrumValue
* \param name test name
*/
SpectrumValueTestCase (SpectrumValue a, SpectrumValue b, std::string name);
virtual ~SpectrumValueTestCase ();
virtual void DoRun (void);
private:
/**
* Check that two SpectrumValue are equal withing a tolerance
* \param x first SpectrumValue
* \param y second SpectrumValue
* \return true if the two values are withing the tolerance
*/
bool MoreOrLessEqual (SpectrumValue x, SpectrumValue y);
SpectrumValue m_a;
SpectrumValue m_b;
SpectrumValue m_a; //!< first SpectrumValue
SpectrumValue m_b; //!< second SpectrumValue
};
@@ -78,10 +96,11 @@ SpectrumValueTestCase::DoRun (void)
/**
* \ingroup spectrum-tests
*
* \brief Spectrum Value TestSuite
*/
class SpectrumValueTestSuite : public TestSuite
{
public:
@@ -246,10 +265,11 @@ SpectrumValueTestSuite::SpectrumValueTestSuite ()
/**
* \ingroup spectrum-tests
*
* \brief Spectrum Converter TestSuite
*/
class SpectrumConverterTestSuite : public TestSuite
{
public:
@@ -327,15 +347,11 @@ SpectrumConverterTestSuite::SpectrumConverterTestSuite ()
// NS_LOG_LOGIC(t21b);
// NS_LOG_LOGIC(*res);
AddTestCase (new SpectrumValueTestCase (t21b, *res, ""), TestCase::QUICK);
}
// static instance of test suites
/// Static variable for test initialization
static SpectrumValueTestSuite g_SpectrumValueTestSuite;
/// Static variable for test initialization
static SpectrumConverterTestSuite g_SpectrumConverterTestSuite;

View File

@@ -28,20 +28,36 @@ using namespace ns3;
/**
* \ingroup spectrum-tests
*
* \brief Waveform generator Test
*/
class WaveformGeneratorTestCase : public TestCase
{
public:
/**
* Constructor
*
* \param period waveform period (seconds)
* \param dutyCycle waveform duty cycle
* \param stop stop time (seconds)
*/
WaveformGeneratorTestCase (double period, double dutyCycle, double stop);
virtual ~WaveformGeneratorTestCase ();
private:
virtual void DoRun (void);
/**
* Trace if the waveform is active
* \param newPkt unused.
*/
void TraceWave (Ptr<const Packet> newPkt);
double m_period;
double m_dutyCycle;
double m_stop;
int m_fails;
double m_period; //!< waveform period (seconds)
double m_dutyCycle; //!< waveform duty cycle
double m_stop; //!< stop time (seconds)
int m_fails; //!< failure check
};
void
@@ -101,6 +117,11 @@ WaveformGeneratorTestCase::DoRun (void)
}
/**
* \ingroup spectrum-tests
*
* \brief Waveform generator TestSuite
*/
class WaveformGeneratorTestSuite : public TestSuite
{
public:
@@ -118,4 +139,5 @@ WaveformGeneratorTestSuite::WaveformGeneratorTestSuite ()
AddTestCase (new WaveformGeneratorTestCase (1.0, 0.5, 1.7), TestCase::QUICK);
}
/// Static variable for test initialization
static WaveformGeneratorTestSuite g_waveformGeneratorTestSuite;

View File

@@ -41,6 +41,8 @@ using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("ThreeGppChannelTestSuite");
/**
* \ingroup spectrum-tests
*
* Test case for the ThreeGppChannelModel class.
* 1) check if the channel matrix has the correct dimensions
* 2) check if the channel matrix is correctly normalized
@@ -207,6 +209,8 @@ ThreeGppChannelMatrixComputationTest::DoRun (void)
}
/**
* \ingroup spectrum-tests
*
* Test case for the ThreeGppChannelModel class.
* It checks if the channel realizations are correctly updated during the
* simulation.
@@ -346,6 +350,7 @@ ThreeGppChannelMatrixUpdateTest::DoRun (void)
}
/**
* \ingroup spectrum-tests
* \brief A structure that holds the parameters for the function
* CheckLongTermUpdate. In this way the problem with the limited
* number of parameters of method Schedule is avoided.
@@ -385,6 +390,8 @@ struct CheckLongTermUpdateParams
};
/**
* \ingroup spectrum-tests
*
* Test case for the ThreeGppSpectrumPropagationLossModelTest class.
* 1) checks if the long term components for the direct and the reverse link
* are the same
@@ -571,7 +578,7 @@ ThreeGppSpectrumPropagationLossModelTest::DoRun ()
}
/**
* \ingroup spectrum
* \ingroup spectrum-tests
*
* Test suite for the ThreeGppChannelModel class
*/
@@ -592,4 +599,5 @@ ThreeGppChannelTestSuite::ThreeGppChannelTestSuite ()
AddTestCase (new ThreeGppSpectrumPropagationLossModelTest, TestCase::QUICK);
}
/// Static variable for test initialization
static ThreeGppChannelTestSuite myTestSuite;

View File

@@ -22,7 +22,13 @@
#include <ns3/log.h>
#include <ns3/tv-spectrum-transmitter-helper.h>
NS_LOG_COMPONENT_DEFINE ("TvHelperDistributionTest");
using namespace ns3;
/**
* \ingroup spectrum-tests
*
* This test verifies the accuracy of the private GetRandomNumTransmitters()
* method in the TvSpectrumTransmitterHelper class. The method generates a
* random number corresponding to the number of TV transmitters to create based
@@ -40,21 +46,26 @@
* 41 and 60 transmitters can be created (all inclusive). This is tested with
* various cases.
*/
NS_LOG_COMPONENT_DEFINE ("TvHelperDistributionTest");
using namespace ns3;
class TvHelperDistributionTestCase : public TestCase
{
public:
/**
* Constructor
*
* \param maxNumTransmitters maximum number of transmitters.
*/
TvHelperDistributionTestCase (uint32_t maxNumTransmitters);
virtual ~TvHelperDistributionTestCase ();
private:
virtual void DoRun (void);
/**
* Build the test name
* \param maxNumTransmitters maximum number of transmitters.
* \return The test name
*/
static std::string Name (uint32_t maxNumTransmitters);
uint32_t m_maxNumTransmitters;
uint32_t m_maxNumTransmitters; //!< Maximum number of transmitters.
};
std::string
@@ -120,6 +131,11 @@ TvHelperDistributionTestCase::DoRun (void)
}
/**
* \ingroup spectrum-tests
*
* Test suite for the TvSpectrumTransmitterHelper class
*/
class TvHelperDistributionTestSuite : public TestSuite
{
public:
@@ -137,4 +153,5 @@ TvHelperDistributionTestSuite::TvHelperDistributionTestSuite ()
}
}
/// Static variable for test initialization
static TvHelperDistributionTestSuite g_TvHelperDistributionTestSuite;

View File

@@ -25,13 +25,6 @@
#include <ns3/double.h>
#include <ns3/tv-spectrum-transmitter.h>
/**
* This test verifies the accuracy of the spectrum/PSD model in the
* TvSpectrumTransmitter class. To do so, it tests if the max power spectral
* density, start frequency, and end frequency comply with expected values.
* Values for TV/modulation type, start frequency, channel bandwidth, and
* base PSD are swept and tested for each case.
*/
NS_LOG_COMPONENT_DEFINE ("TvSpectrumTransmitterTest");
using namespace ns3;
@@ -41,9 +34,25 @@ const double TOLERANCE = 1e-15;
// Follows http://realtimecollisiondetection.net/blog/?p=89
double epsilon;
/**
* \ingroup spectrum-tests
*
* This test verifies the accuracy of the spectrum/PSD model in the
* TvSpectrumTransmitter class. To do so, it tests if the max power spectral
* density, start frequency, and end frequency comply with expected values.
* Values for TV/modulation type, start frequency, channel bandwidth, and
* base PSD are swept and tested for each case.
*/
class TvSpectrumTransmitterTestCase : public TestCase
{
public:
/**
* Constructor
* \param startFrequency Start frequency.
* \param channelBandwidth Channel Bandwidth.
* \param basePsd Base Power Spectral Density (PSD).
* \param tvType TV type.
*/
TvSpectrumTransmitterTestCase (double startFrequency,
double channelBandwidth,
double basePsd,
@@ -52,15 +61,23 @@ public:
private:
virtual void DoRun (void);
/**
* Build the test name
* \param tvType TV type.
* \param startFrequency Start frequency.
* \param channelBandwidth Channel Bandwidth.
* \param basePsd Base Power Spectral Density (PSD).
* \return The test name
*/
static std::string Name (TvSpectrumTransmitter::TvType tvType,
double startFrequency,
double channelBandwidth,
double basePsd);
double m_startFrequency;
double m_channelBandwidth;
double m_basePsd;
TvSpectrumTransmitter::TvType m_tvType;
double m_startFrequency; //!< Start frequency.
double m_channelBandwidth; //!< Channel Bandwidth.
double m_basePsd; //!< Base Power Spectral Density (PSD).
TvSpectrumTransmitter::TvType m_tvType; //!< TV type.
};
@@ -154,6 +171,11 @@ TvSpectrumTransmitterTestCase::DoRun (void)
}
/**
* \ingroup spectrum-tests
*
* Test suite for the TvSpectrumTransmitter class
*/
class TvSpectrumTransmitterTestSuite : public TestSuite
{
public:
@@ -208,4 +230,5 @@ TvSpectrumTransmitterTestSuite::TvSpectrumTransmitterTestSuite ()
}
}
/// Static variable for test initialization
static TvSpectrumTransmitterTestSuite g_tvSpectrumTransmitterTestSuite;