25 #include <ns3/antenna-model.h>
26 #include <ns3/callback.h>
28 #include <ns3/object-factory.h>
29 #include <ns3/packet-burst.h>
30 #include <ns3/simulator.h>
31 #include <ns3/trace-source-accessor.h>
43 : m_mobility(nullptr),
105 TypeId(
"ns3::HalfDuplexIdealPhy")
107 .SetGroupName(
"Spectrum")
111 "The PHY rate used by this device",
114 MakeDataRateChecker())
115 .AddTraceSource(
"TxStart",
116 "Trace fired when a new transmission is started",
118 "ns3::Packet::TracedCallback")
119 .AddTraceSource(
"TxEnd",
120 "Trace fired when a previously started transmission is finished",
122 "ns3::Packet::TracedCallback")
123 .AddTraceSource(
"RxStart",
124 "Trace fired when the start of a signal is detected",
126 "ns3::Packet::TracedCallback")
127 .AddTraceSource(
"RxAbort",
128 "Trace fired when a previously started RX is aborted before time",
130 "ns3::Packet::TracedCallback")
131 .AddTraceSource(
"RxEndOk",
132 "Trace fired when a previously started RX terminates successfully",
134 "ns3::Packet::TracedCallback")
135 .AddTraceSource(
"RxEndError",
136 "Trace fired when a previously started RX terminates with an error "
137 "(packet is corrupted)",
139 "ns3::Packet::TracedCallback");
289 Create<HalfDuplexIdealPhySignalParameters>();
291 txParams->duration = txTimeSeconds;
292 txParams->txPhy = GetObject<SpectrumPhy>();
343 DynamicCast<HalfDuplexIdealPhySignalParameters>(spectrumParams);
372 NS_LOG_LOGIC(
this <<
" calling m_phyMacRxStartCallback");
377 NS_LOG_LOGIC(
this <<
" m_phyMacRxStartCallback is NULL");
380 NS_LOG_LOGIC(
this <<
" scheduling EndRx with delay " << rxParams->duration);
424 NS_LOG_LOGIC(
this <<
" calling m_phyMacRxEndOkCallback");
429 NS_LOG_LOGIC(
this <<
" m_phyMacRxEndOkCallback is NULL");
437 NS_LOG_LOGIC(
this <<
" calling m_phyMacRxEndErrorCallback");
442 NS_LOG_LOGIC(
this <<
" m_phyMacRxEndErrorCallback is NULL");
bool IsNull() const
Check for null implementation.
Class for representing data rates.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
This PHY layer implementation realizes an ideal OFDM PHY which transmits half-duplex (i....
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
Trace - Tx end (ok)
void SetGenericPhyTxEndCallback(GenericPhyTxEndCallback c)
Set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC.
Ptr< const SpectrumValue > m_rxPsd
Rx power spectral density.
GenericPhyTxEndCallback m_phyMacTxEndCallback
Callback - Tx end.
void SetGenericPhyRxEndErrorCallback(GenericPhyRxEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections between the PHY and th...
void SetRate(DataRate rate)
Set the PHY rate to be used by this PHY.
SpectrumInterference m_interference
Received interference.
DataRate GetRate() const
Get the PHY rate to be used by this PHY.
Ptr< MobilityModel > m_mobility
Mobility model.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
TracedCallback< Ptr< const Packet > > m_phyRxStartTrace
Trace - Rx start.
Ptr< AntennaModel > m_antenna
Antenna model.
TracedCallback< Ptr< const Packet > > m_phyRxAbortTrace
Trace - Rx abort.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
Trace - Tx start.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void SetGenericPhyRxEndOkCallback(GenericPhyRxEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
GenericPhyRxStartCallback m_phyMacRxStartCallback
Callback - Rx start.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
Ptr< SpectrumChannel > m_channel
Channel.
EventId m_endRxEventId
End Rx event.
void ChangeState(State newState)
Change the PHY state.
void EndRx()
End current Rx.
Ptr< Packet > m_rxPacket
Rx packet.
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the Noise Power Spectral Density in power units (Watt, Pascal...) per Hz.
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
Callback - Rx error.
Ptr< NetDevice > m_netDevice
NetDevice connected to this phy.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< Packet > m_txPacket
Tx packet.
void EndTx()
End the current Tx.
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
Trace - Rx end (error)
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
~HalfDuplexIdealPhy() override
void AbortRx()
About current Rx.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in power units (Watt, Pascal......
bool StartTx(Ptr< Packet > p)
Start a transmission.
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Ptr< SpectrumValue > m_txPsd
Tx power spectral density.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Trace - Tx end.
void SetGenericPhyRxStartCallback(GenericPhyRxStartCallback c)
Set the callback for the start of RX, as part of the interconnections between the PHY and the MAC.
GenericPhyRxEndOkCallback m_phyMacRxEndOkCallback
Callback - Rx end.
virtual void DoDispose()
Destructor implementation.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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.
void AbortRx()
Notify that the PHY has aborted RX.
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the Noise Power Spectral Density.
bool EndRx()
Notify that the RX attempt has ended.
void SetErrorModel(Ptr< SpectrumErrorModel > e)
Set the SpectrumErrorModel to be used.
void StartRx(Ptr< const Packet > p, Ptr< const SpectrumValue > rxPsd)
Notify that the PHY is starting a RX attempt.
void AddSignal(Ptr< const SpectrumValue > spd, const Time duration)
Notify that a new signal is being perceived in the medium.
Abstract base class for Spectrum-aware PHY layers.
Ptr< const SpectrumModel > GetSpectrumModel() const
Simulation virtual time values and global simulation resolution.
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,...
#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 ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Integral(const SpectrumValue &arg)
std::ostream & operator<<(std::ostream &os, const Angles &a)
@ IDLE
Channel is IDLE, no packet is being transmitted.
Time duration
The duration of the packet transmission.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.