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> ();
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
double bandwidth
Bandwidth [Hz].
Ptr< SpectrumChannel > m_channel
Pointer to spectrum channel object.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
double startFrequency
Start frequency [Hz].
Abstract base class for Spectrum-aware PHY layers.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Hold variables of type string.
Ptr< SpectrumChannel > GetChannel() const
Get the spectrum channel.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< AntennaModel > m_antenna
Pointer to antenna model object.
virtual void CreateTvPsd()
Creates power spectral density (PSD) spectrum of the TV transmitter and sets it for transmission...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< NetDevice > m_netDevice
Pointer to net device object.
static std::map< TvSpectrumModelId, Ptr< SpectrumModel > > g_tvSpectrumModelMap
Stores created spectrum models.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
virtual void Stop()
Stops the TV Transmitter's transmission on the spectrum channel.
Ptr< AntennaModel > GetRxAntenna()
Get the AntennaModel used by the NetDevice for reception.
enum TvType m_tvType
Type of TV transmitter.
std::vector< BandInfo > Bands
Container of BandInfo.
bool m_active
True if TV transmitter is transmitting.
bool operator<(const EventId &a, const EventId &b)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< SpectrumValue > m_txPsd
Pointer to power spectral density of TV transmitter's signal.
double m_startFrequency
Start frequency (in Hz) of TV transmitter's signal.
virtual void Start()
Starts the TV Transmitter's transmission on the spectrum channel.
Ptr< MobilityModel > GetMobility()
Get the associated MobilityModel instance.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Hold variables of type enum.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
virtual ~TvSpectrumTransmitter()
AttributeValue implementation for Time.
double fc
center frequency
double m_channelBandwidth
Bandwidth (in Hz) of TV transmitter's signal.
Time m_transmitDuration
Length of time that TV transmitter will transmit for.
Time m_startingTime
Timepoint after simulation begins that TV transmitter will begin transmitting.
virtual void SetupTx()
Sets up signal to be transmitted.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double fl
lower limit of subband
Used as key for map containing created spectrum models.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
SpectrumPhy implementation that creates a customizable TV transmitter which transmits a PSD spectrum ...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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 AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
TvSpectrumModelId(double stFreq, double bwidth)
Constructor.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< MobilityModel > m_mobility
Pointer to mobility model object.
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
double m_basePsd
Base power spectral density value (in dBm/Hz) of TV transmitter's signal.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
static TypeId GetTypeId(void)
Register this type.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
double fh
upper limit of subband
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Ptr< SpectrumValue > GetTxPsd() const
Get the power spectral density of the TV transmitter's signal.
The building block of a SpectrumModel.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.