21 #include <ns3/object-factory.h>
24 #include <ns3/simulator.h>
25 #include <ns3/trace-source-accessor.h>
26 #include <ns3/packet-burst.h>
27 #include <ns3/callback.h>
28 #include <ns3/antenna-model.h>
106 .SetGroupName (
"Spectrum")
108 .AddAttribute (
"Rate",
109 "The PHY rate used by this device",
114 .AddTraceSource (
"TxStart",
115 "Trace fired when a new transmission is started",
117 "ns3::Packet::TracedCallback")
118 .AddTraceSource (
"TxEnd",
119 "Trace fired when a previously started transmission is finished",
121 "ns3::Packet::TracedCallback")
122 .AddTraceSource (
"RxStart",
123 "Trace fired when the start of a signal is detected",
125 "ns3::Packet::TracedCallback")
126 .AddTraceSource (
"RxAbort",
127 "Trace fired when a previously started RX is aborted before time",
129 "ns3::Packet::TracedCallback")
130 .AddTraceSource (
"RxEndOk",
131 "Trace fired when a previously started RX terminates successfully",
133 "ns3::Packet::TracedCallback")
134 .AddTraceSource (
"RxEndError",
135 "Trace fired when a previously started RX terminates with an error (packet is corrupted)",
137 "ns3::Packet::TracedCallback")
299 txParams->duration = txTimeSeconds;
300 txParams->txPhy = GetObject<SpectrumPhy> ();
305 NS_LOG_LOGIC (
this <<
" tx power: " << 10 * std::log10 (
Integral (*(txParams->psd))) + 30 <<
" dBm");
345 NS_LOG_LOGIC (
this <<
" rx power: " << 10 * std::log10 (
Integral (*(spectrumParams->psd))) + 30 <<
" dBm");
381 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxStartCallback");
386 NS_LOG_LOGIC (
this <<
" m_phyMacRxStartCallback is NULL");
389 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << rxParams->duration);
435 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxEndOkCallback");
440 NS_LOG_LOGIC (
this <<
" m_phyMacRxEndOkCallback is NULL");
448 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxEndErrorCallback");
453 NS_LOG_LOGIC (
this <<
" m_phyMacRxEndErrorCallback is NULL");
bool IsNull(void) const
Check for null implementation.
Class for representing data rates.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
AttributeValue implementation for DataRate.
void Cancel(void)
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....
Ptr< MobilityModel > GetMobility() const
Get the associated MobilityModel instance.
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.
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
SpectrumInterference m_interference
Received interference.
DataRate GetRate() const
Get the PHY rate to be used by this PHY.
Ptr< MobilityModel > m_mobility
Mobility model.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
TracedCallback< Ptr< const Packet > > m_phyRxStartTrace
Trace - Rx start.
Ptr< AntennaModel > m_antenna
Antenna model.
TracedCallback< Ptr< const Packet > > m_phyRxAbortTrace
Trace - Rx abort.
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
Trace - Tx start.
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.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
virtual void DoDispose(void)
Destructor implementation.
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.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
Callback - Rx error.
Ptr< NetDevice > m_netDevice
NetDevice connected to theis phy.
Ptr< Packet > m_txPacket
Tx packet.
Ptr< Object > GetAntenna() const
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void EndTx()
End the current Tx.
virtual ~HalfDuplexIdealPhy()
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
Trace - Rx end (error)
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
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.
Ptr< SpectrumValue > m_txPsd
Tx power spectral density.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Trace - Tx end.
static TypeId GetTypeId(void)
Get the type ID.
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.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
virtual void DoDispose(void)
Destructor implementation.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static EventId Schedule(Time const &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,...
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
#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.
#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.