22 #include <ns3/antenna-model.h>
23 #include <ns3/double.h>
25 #include <ns3/integer.h>
26 #include <ns3/isotropic-antenna-model.h>
28 #include <ns3/pointer.h>
29 #include <ns3/simulator.h>
30 #include <ns3/string.h>
31 #include <ns3/uinteger.h>
43 : m_mobility(nullptr),
47 m_tvType(TVTYPE_8VSB),
48 m_startFrequency(500e6),
49 m_channelBandwidth(6e6),
53 m_transmitDuration(
Seconds(0.2)),
73 TypeId(
"ns3::TvSpectrumTransmitter")
75 .SetGroupName(
"Spectrum")
77 .AddAttribute(
"TvType",
78 "The type of TV transmitter/modulation to be used.",
87 .AddAttribute(
"StartFrequency",
88 "The lower end frequency (in Hz) of the TV transmitter's "
89 "signal. Must be greater than or equal to 0.",
93 .AddAttribute(
"ChannelBandwidth",
94 "The bandwidth (in Hz) of the TV transmitter's signal. Must "
95 "be greater than or equal to 0.",
99 .AddAttribute(
"BasePsd",
100 "The base power spectral density (in dBm/Hz) of the TV "
101 "transmitter's transmitted spectrum. Base PSD is the "
102 "maximum PSD of the spectrum excluding pilots. For analog "
103 "and COFDM transmitters this is the maximum PSD, but for "
104 "8-VSB transmitters this is the maximum PSD of the main "
105 "signal spectrum (flat-top segment) since the pilot "
106 "actually has the maximum PSD overall.",
109 MakeDoubleChecker<double>())
110 .AddAttribute(
"Antenna",
111 "The AntennaModel to be used. Allows classes inherited "
112 "from ns3::AntennaModel. Defaults to ns3::IsotropicAntennaModel.",
115 MakePointerChecker<AntennaModel>())
116 .AddAttribute(
"StartingTime",
117 "The time point after the simulation begins in which the TV "
118 "transmitter will begin transmitting.",
122 .AddAttribute(
"TransmitDuration",
123 "The duration of time that the TV transmitter will transmit for.",
206 : startFrequency(stFreq),
249 std::map<TvSpectrumModelId, Ptr<SpectrumModel>>::iterator iter =
g_tvSpectrumModelMap.find(key);
252 model = iter->second;
264 bi.
fc = fl + halfSubBand;
265 bi.
fh = fl + (2 * halfSubBand);
268 model = Create<SpectrumModel>(bands);
272 double basePsdWattsHz = pow(10.0, (
m_basePsd - 30) / 10.0);
276 for (
int i = 0; i <= 100; i++)
282 (*psd)[i] = 0.015 * basePsdWattsHz;
286 (*psd)[i] = 0.019 * basePsdWattsHz;
290 (*psd)[i] = 0.034 * basePsdWattsHz;
294 (*psd)[i] = 0.116 * basePsdWattsHz;
298 (*psd)[i] = 0.309 * basePsdWattsHz;
301 (*psd)[i] = (0.502 * basePsdWattsHz) + (21.577 * basePsdWattsHz);
305 (*psd)[i] = 0.696 * basePsdWattsHz;
309 (*psd)[i] = 0.913 * basePsdWattsHz;
313 (*psd)[i] = 0.978 * basePsdWattsHz;
317 (*psd)[i] = 0.990 * basePsdWattsHz;
320 (*psd)[i] = 0.502 * basePsdWattsHz;
323 (*psd)[i] = basePsdWattsHz;
330 for (
int i = 0; i <= 100; i++)
336 (*psd)[i] = 1.52e-4 * basePsdWattsHz;
340 (*psd)[i] = 2.93e-4 * basePsdWattsHz;
344 (*psd)[i] = 8.26e-4 * basePsdWattsHz;
348 (*psd)[i] = 0.0927 * basePsdWattsHz;
351 (*psd)[i] = basePsdWattsHz;
358 for (
int i = 0; i <= 100; i++)
366 (*psd)[i] = 27.07946e-08 * basePsdWattsHz;
371 (*psd)[i] = 2.51189e-07 * basePsdWattsHz;
376 (*psd)[i] = 1e-06 * basePsdWattsHz;
381 (*psd)[i] = 2.39883e-06 * basePsdWattsHz;
386 (*psd)[i] = 5.62341e-06 * basePsdWattsHz;
391 (*psd)[i] = 6.68344e-06 * basePsdWattsHz;
396 (*psd)[i] = 1.25893e-05 * basePsdWattsHz;
401 (*psd)[i] = 3.16228e-05 * basePsdWattsHz;
404 (*psd)[i] = 0.000158489 * basePsdWattsHz;
407 (*psd)[i] = basePsdWattsHz;
410 (*psd)[i] = 7.49894e-05 * basePsdWattsHz;
415 (*psd)[i] = 2.37137e-05 * basePsdWattsHz;
420 (*psd)[i] = 1.14815e-05 * basePsdWattsHz;
425 (*psd)[i] = 7.49894e-06 * basePsdWattsHz;
430 (*psd)[i] = 5.62341e-06 * basePsdWattsHz;
435 (*psd)[i] = 4.21697e-06 * basePsdWattsHz;
440 (*psd)[i] = 3.16228e-06 * basePsdWattsHz;
445 (*psd)[i] = 1.99526e-06 * basePsdWattsHz;
450 (*psd)[i] = 1.25893e-06 * basePsdWattsHz;
455 (*psd)[i] = 8.41395e-07 * basePsdWattsHz;
460 (*psd)[i] = 6.30957e-07 * basePsdWattsHz;
465 (*psd)[i] = 5.88844e-07 * basePsdWattsHz;
470 (*psd)[i] = 5.62341e-07 * basePsdWattsHz;
475 (*psd)[i] = 5.30884e-07 * basePsdWattsHz;
480 (*psd)[i] = 5.01187e-07 * basePsdWattsHz;
485 (*psd)[i] = 5.30884e-07 * basePsdWattsHz;
490 (*psd)[i] = 7.49894e-07 * basePsdWattsHz;
495 (*psd)[i] = 1.77828e-06 * basePsdWattsHz;
498 (*psd)[i] = 5.62341e-06 * basePsdWattsHz;
501 (*psd)[i] = 0.000177828 * basePsdWattsHz;
504 (*psd)[i] = 4.21697e-06 * basePsdWattsHz;
509 (*psd)[i] = 3.16228e-06 * basePsdWattsHz;
514 (*psd)[i] = 3.16228e-06 * basePsdWattsHz;
519 (*psd)[i] = 4.73151e-06 * basePsdWattsHz;
524 (*psd)[i] = 7.49894e-06 * basePsdWattsHz;
527 (*psd)[i] = 7.49894e-05 * basePsdWattsHz;
530 (*psd)[i] = 0.1 * basePsdWattsHz;
533 (*psd)[i] = 7.49894e-05 * basePsdWattsHz;
539 (*psd)[i] = 1.77828e-06 * basePsdWattsHz;
568 signal->
txPhy = GetObject<SpectrumPhy>();
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.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Abstract base class for Spectrum-aware PHY layers.
Hold variables of type string.
AttributeValue implementation for Time.
SpectrumPhy implementation that creates a customizable TV transmitter which transmits a PSD spectrum ...
Ptr< AntennaModel > m_antenna
Pointer to antenna model object.
TvType m_tvType
Type of TV transmitter.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
virtual void CreateTvPsd()
Creates power spectral density (PSD) spectrum of the TV transmitter and sets it for transmission.
double m_basePsd
Base power spectral density value (in dBm/Hz) of TV transmitter's signal.
Time m_transmitDuration
Length of time that TV transmitter will transmit for.
bool m_active
True if TV transmitter is transmitting.
Ptr< NetDevice > m_netDevice
Pointer to net device object.
virtual void Start()
Starts the TV Transmitter's transmission on the spectrum channel.
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
double m_channelBandwidth
Bandwidth (in Hz) of TV transmitter's signal.
double m_startFrequency
Start frequency (in Hz) of TV transmitter's signal.
Time m_startingTime
Timepoint after simulation begins that TV transmitter will begin transmitting.
virtual void Stop()
Stops the TV Transmitter's transmission on the spectrum channel.
virtual void SetupTx()
Sets up signal to be transmitted.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
~TvSpectrumTransmitter() override
Ptr< SpectrumValue > GetTxPsd() const
Get the power spectral density of the TV transmitter's signal.
Ptr< SpectrumChannel > GetChannel() const
Get the spectrum channel.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
static TypeId GetTypeId()
Register this type.
Ptr< SpectrumChannel > m_channel
Pointer to spectrum channel object.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< SpectrumValue > m_txPsd
Pointer to power spectral density of TV transmitter's signal.
Ptr< MobilityModel > m_mobility
Pointer to mobility model object.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#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.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< BandInfo > Bands
Container of BandInfo.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
bool operator<(const EventId &a, const EventId &b)
static std::map< TvSpectrumModelId, Ptr< SpectrumModel > > g_tvSpectrumModelMap
Stores created spectrum models.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
Ptr< AntennaModel > txAntenna
The AntennaModel instance that was used to transmit this signal.
Time duration
The duration of the packet transmission.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
Used as key for map containing created spectrum models.
TvSpectrumModelId(double stFreq, double bwidth)
Constructor.
double startFrequency
Start frequency [Hz].
double bandwidth
Bandwidth [Hz].