22 #include <ns3/simulator.h>
24 #include <ns3/uinteger.h>
25 #include <ns3/double.h>
26 #include <ns3/integer.h>
27 #include <ns3/string.h>
28 #include <ns3/pointer.h>
29 #include <ns3/isotropic-antenna-model.h>
30 #include <ns3/antenna-model.h>
45 m_tvType (TVTYPE_8VSB),
46 m_startFrequency (500e6),
47 m_channelBandwidth (6e6),
51 m_transmitDuration (
Seconds (0.2)),
72 .SetGroupName (
"Spectrum")
74 .AddAttribute (
"TvType",
75 "The type of TV transmitter/modulation to be used.",
81 .AddAttribute (
"StartFrequency",
82 "The lower end frequency (in Hz) of the TV transmitter's "
83 "signal. Must be greater than or equal to 0.",
87 .AddAttribute (
"ChannelBandwidth",
88 "The bandwidth (in Hz) of the TV transmitter's signal. Must "
89 "be greater than or equal to 0.",
93 .AddAttribute (
"BasePsd",
94 "The base power spectral density (in dBm/Hz) of the TV "
95 "transmitter's transmitted spectrum. Base PSD is the "
96 "maximum PSD of the spectrum excluding pilots. For analog "
97 "and COFDM transmitters this is the maximum PSD, but for "
98 "8-VSB transmitters this is the maximum PSD of the main "
99 "signal spectrum (flat-top segment) since the pilot "
100 "actually has the maximum PSD overall.",
103 MakeDoubleChecker<double> ())
104 .AddAttribute (
"Antenna",
105 "The AntennaModel to be used. Allows classes inherited "
106 "from ns3::AntennaModel. Defaults to ns3::IsotropicAntennaModel.",
109 MakePointerChecker<AntennaModel> ())
110 .AddAttribute (
"StartingTime",
111 "The time point after the simulation begins in which the TV "
112 "transmitter will begin transmitting.",
116 .AddAttribute (
"TransmitDuration",
117 "The duration of time that the TV transmitter will transmit for.",
202 : startFrequency (stFreq),
246 std::map<TvSpectrumModelId, Ptr<SpectrumModel> >::iterator iter =
g_tvSpectrumModelMap.find (key);
249 model = iter->second;
260 bi.
fc = fl + halfSubBand;
261 bi.
fh = fl + (2 * halfSubBand);
262 bands.push_back (bi);
264 model = Create<SpectrumModel> (bands);
268 double basePsdWattsHz = pow (10.0, (
m_basePsd - 30) / 10.0);
273 for (
int i = 0; i <= 100; i++)
279 (*psd) [i] = 0.015 * basePsdWattsHz;
283 (*psd) [i] = 0.019 * basePsdWattsHz;
287 (*psd) [i] = 0.034 * basePsdWattsHz;
291 (*psd) [i] = 0.116 * basePsdWattsHz;
295 (*psd) [i] = 0.309 * basePsdWattsHz;
298 (*psd) [i] = (0.502 * basePsdWattsHz) + (21.577 * basePsdWattsHz);
302 (*psd) [i] = 0.696 * basePsdWattsHz;
306 (*psd) [i] = 0.913 * basePsdWattsHz;
310 (*psd) [i] = 0.978 * basePsdWattsHz;
314 (*psd) [i] = 0.990 * basePsdWattsHz;
317 (*psd) [i] = 0.502 * basePsdWattsHz;
320 (*psd) [i] = basePsdWattsHz;
328 for (
int i = 0; i <= 100; i++)
334 (*psd) [i] = 1.52e-4 * basePsdWattsHz;
338 (*psd) [i] = 2.93e-4 * basePsdWattsHz;
342 (*psd) [i] = 8.26e-4 * basePsdWattsHz;
346 (*psd) [i] = 0.0927 * basePsdWattsHz;
349 (*psd) [i] = basePsdWattsHz;
357 for (
int i = 0; i <= 100; i++)
365 (*psd) [i] = 27.07946e-08 * basePsdWattsHz;
370 (*psd) [i] = 2.51189e-07 * basePsdWattsHz;
375 (*psd) [i] = 1e-06 * basePsdWattsHz;
380 (*psd) [i] = 2.39883e-06 * basePsdWattsHz;
385 (*psd) [i] = 5.62341e-06 * basePsdWattsHz;
390 (*psd) [i] = 6.68344e-06 * basePsdWattsHz;
395 (*psd) [i] = 1.25893e-05 * basePsdWattsHz;
400 (*psd) [i] = 3.16228e-05 * basePsdWattsHz;
403 (*psd) [i] = 0.000158489 * basePsdWattsHz;
406 (*psd) [i] = basePsdWattsHz;
409 (*psd) [i] = 7.49894e-05 * basePsdWattsHz;
414 (*psd) [i] = 2.37137e-05 * basePsdWattsHz;
419 (*psd) [i] = 1.14815e-05 * basePsdWattsHz;
424 (*psd) [i] = 7.49894e-06 * basePsdWattsHz;
429 (*psd) [i] = 5.62341e-06 * basePsdWattsHz;
434 (*psd) [i] = 4.21697e-06 * basePsdWattsHz;
439 (*psd) [i] = 3.16228e-06 * basePsdWattsHz;
444 (*psd) [i] = 1.99526e-06 * basePsdWattsHz;
449 (*psd) [i] = 1.25893e-06 * basePsdWattsHz;
454 (*psd) [i] = 8.41395e-07 * basePsdWattsHz;
459 (*psd) [i] = 6.30957e-07 * basePsdWattsHz;
464 (*psd) [i] = 5.88844e-07 * basePsdWattsHz;
469 (*psd) [i] = 5.62341e-07 * basePsdWattsHz;
474 (*psd) [i] = 5.30884e-07 * basePsdWattsHz;
479 (*psd) [i] = 5.01187e-07 * basePsdWattsHz;
484 (*psd) [i] = 5.30884e-07 * basePsdWattsHz;
489 (*psd) [i] = 7.49894e-07 * basePsdWattsHz;
494 (*psd) [i] = 1.77828e-06 * basePsdWattsHz;
497 (*psd) [i] = 5.62341e-06 * basePsdWattsHz;
500 (*psd) [i] = 0.000177828 * basePsdWattsHz;
503 (*psd) [i] = 4.21697e-06 * basePsdWattsHz;
508 (*psd) [i] = 3.16228e-06 * basePsdWattsHz;
513 (*psd) [i] = 3.16228e-06 * basePsdWattsHz;
518 (*psd) [i] = 4.73151e-06 * basePsdWattsHz;
523 (*psd) [i] = 7.49894e-06 * basePsdWattsHz;
526 (*psd) [i] = 7.49894e-05 * basePsdWattsHz;
529 (*psd) [i] = 0.1 * basePsdWattsHz;
532 (*psd) [i] = 7.49894e-05 * basePsdWattsHz;
538 (*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(Time const &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 ...
virtual ~TvSpectrumTransmitter()
Ptr< AntennaModel > m_antenna
Pointer to antenna model object.
Ptr< MobilityModel > GetMobility() const
Get the associated MobilityModel instance.
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
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.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
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.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
double m_channelBandwidth
Bandwidth (in Hz) of TV transmitter's signal.
double m_startFrequency
Start frequency (in Hz) of TV transmitter's signal.
enum TvType m_tvType
Type of TV transmitter.
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.
static TypeId GetTypeId(void)
Register this type.
Ptr< SpectrumValue > GetTxPsd() const
Get the power spectral density of the TV transmitter's signal.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
Ptr< SpectrumChannel > GetChannel() const
Get the spectrum channel.
Ptr< SpectrumChannel > m_channel
Pointer to spectrum channel object.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
Ptr< SpectrumValue > m_txPsd
Pointer to power spectral density of TV transmitter's signal.
Ptr< Object > GetAntenna() const
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming 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.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
Used as key for map containing created spectrum models.
TvSpectrumModelId(double stFreq, double bwidth)
Constructor.
double startFrequency
Start frequency [Hz].
double bandwidth
Bandwidth [Hz].