14#include <ns3/antenna-model.h>
15#include <ns3/callback.h>
17#include <ns3/object-factory.h>
18#include <ns3/packet-burst.h>
19#include <ns3/simulator.h>
20#include <ns3/trace-source-accessor.h>
32 : m_mobility(nullptr),
94 TypeId(
"ns3::HalfDuplexIdealPhy")
96 .SetGroupName(
"Spectrum")
100 "The PHY rate used by this device",
104 .AddTraceSource(
"TxStart",
105 "Trace fired when a new transmission is started",
107 "ns3::Packet::TracedCallback")
108 .AddTraceSource(
"TxEnd",
109 "Trace fired when a previously started transmission is finished",
111 "ns3::Packet::TracedCallback")
112 .AddTraceSource(
"RxStart",
113 "Trace fired when the start of a signal is detected",
115 "ns3::Packet::TracedCallback")
116 .AddTraceSource(
"RxAbort",
117 "Trace fired when a previously started RX is aborted before time",
119 "ns3::Packet::TracedCallback")
120 .AddTraceSource(
"RxEndOk",
121 "Trace fired when a previously started RX terminates successfully",
123 "ns3::Packet::TracedCallback")
124 .AddTraceSource(
"RxEndError",
125 "Trace fired when a previously started RX terminates with an error "
126 "(packet is corrupted)",
128 "ns3::Packet::TracedCallback");
172 return m_txPsd->GetSpectrumModel();
280 txParams->duration = txTimeSeconds;
360 NS_LOG_LOGIC(
this <<
" calling m_phyMacRxStartCallback");
365 NS_LOG_LOGIC(
this <<
" m_phyMacRxStartCallback is NULL");
368 NS_LOG_LOGIC(
this <<
" scheduling EndRx with delay " << rxParams->duration);
412 NS_LOG_LOGIC(
this <<
" calling m_phyMacRxEndOkCallback");
417 NS_LOG_LOGIC(
this <<
" m_phyMacRxEndOkCallback is NULL");
425 NS_LOG_LOGIC(
this <<
" calling m_phyMacRxEndErrorCallback");
430 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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoDispose()
Destructor implementation.
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.
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,...
Callback< R, Args... > MakeNullCallback()
#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.
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
std::ostream & operator<<(std::ostream &os, const Angles &a)
double Integral(const SpectrumValue &arg)
Ptr< const AttributeChecker > MakeDataRateChecker()
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
@ IDLE
Channel is IDLE, no packet is being transmitted.