22 #include <ns3/object-factory.h>
24 #include <ns3/simulator.h>
25 #include <ns3/double.h>
26 #include <ns3/packet-burst.h>
27 #include <ns3/antenna-model.h>
29 #include "waveform-generator.h"
35 NS_OBJECT_ENSURE_REGISTERED (WaveformGenerator);
37 WaveformGenerator::WaveformGenerator ()
41 m_txPowerSpectralDensity (0),
49 WaveformGenerator::~WaveformGenerator ()
65 WaveformGenerator::GetTypeId (
void)
69 .AddConstructor<WaveformGenerator> ()
70 .AddAttribute (
"Period",
71 "the period (=1/frequency)",
76 .AddAttribute (
"DutyCycle",
77 "the duty cycle of the generator, i.e., the fraction of the period that is occupied by a signal",
81 MakeDoubleChecker<double> ())
82 .AddTraceSource (
"TxStart",
83 "Trace fired when a new transmission is started",
85 .AddTraceSource (
"TxEnd",
86 "Trace fired when a previosuly started transmission is finished",
148 m_txPowerSpectralDensity = txPsd;
181 m_dutyCycle = dutyCycle;
192 WaveformGenerator::GenerateWaveform ()
197 txParams->duration =
Time (m_period * m_dutyCycle);
198 txParams->psd = m_txPowerSpectralDensity;
199 txParams->txPhy = GetObject<SpectrumPhy> ();
200 txParams->txAntenna = m_antenna;
202 NS_LOG_LOGIC (
"generating waveform : " << *m_txPowerSpectralDensity);
203 m_phyTxStartTrace (0);
204 m_channel->StartTx (txParams);
220 NS_LOG_LOGIC (
"generator was not active, now starting");
222 m_startTime =
Now ();
#define NS_LOG_FUNCTION(parameters)
#define NS_LOG_COMPONENT_DEFINE(name)
#define NS_LOG_FUNCTION_NOARGS()
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
hold objects of type ns3::Time
#define NS_LOG_LOGIC(msg)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Hold an floating point type.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)