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");
void SetRate(DataRate rate)
Set the PHY rate to be used by this PHY.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Simulation virtual time values and global simulation resolution.
void SetGenericPhyTxEndCallback(GenericPhyTxEndCallback c)
Set the callback for the end of a TX, as part of the interconnections between the PHY and the MAC...
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 "...
Ptr< MobilityModel > m_mobility
Mobility model.
Abstract base class for Spectrum-aware PHY layers.
double Integral(const SpectrumValue &arg)
bool StartTx(Ptr< Packet > p)
Start a transmission.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
EventId m_endRxEventId
End Rx event.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the Noise Power Spectral Density.
void SetGenericPhyRxStartCallback(GenericPhyRxStartCallback c)
Set the callback for the start of RX, as part of the interconnections between the PHY and the MAC...
Channel is IDLE, no packet is being transmitted.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
SpectrumInterference m_interference
Received interference.
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
Callback - Rx error.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
virtual void DoDispose(void)
Destructor implementation.
void AddSignal(Ptr< const SpectrumValue > spd, const Time duration)
Notify that a new signal is being perceived in the medium.
Ptr< MobilityModel > GetMobility()
Get the associated MobilityModel instance.
Ptr< const SpectrumValue > m_rxPsd
Rx power spectral density.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
Trace - Tx end.
void AbortRx()
Notify that the PHY has aborted RX.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
void StartRx(Ptr< const Packet > p, Ptr< const SpectrumValue > rxPsd)
Notify that the PHY is starting a RX attempt.
TracedCallback< Ptr< const Packet > > m_phyRxStartTrace
Trace - Rx start.
TracedCallback< Ptr< const Packet > > m_phyRxAbortTrace
Trace - Rx abort.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Class for representing data rates.
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
Trace - Tx start.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
Ptr< SpectrumValue > m_txPsd
Tx power spectral density.
void SetGenericPhyRxEndOkCallback(GenericPhyRxEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
void AbortRx()
About current Rx.
virtual ~HalfDuplexIdealPhy()
GenericPhyRxEndOkCallback m_phyMacRxEndOkCallback
Callback - Rx end.
virtual void DoDispose(void)
Destructor implementation.
Ptr< AntennaModel > GetRxAntenna()
Get the AntennaModel used by the NetDevice for reception.
Ptr< SpectrumChannel > m_channel
Channel.
This PHY layer implementation realizes an ideal OFDM PHY which transmits half-duplex (i...
DataRate GetRate() const
Get the PHY rate to be used by this PHY.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the Noise Power Spectral Density in power units (Watt, Pascal...) per Hz.
void EndRx()
End current Rx.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ChangeState(State newState)
Change the PHY state.
bool EndRx()
Notify that the RX attempt has ended.
Ptr< const SpectrumModel > GetSpectrumModel() const
Ptr< NetDevice > m_netDevice
NetDevice connected to theis phy.
Ptr< Packet > m_rxPacket
Rx packet.
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...
Ptr< AntennaModel > m_antenna
Antenna model.
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
Trace - Rx end (error)
AttributeValue implementation for DataRate.
GenericPhyRxStartCallback m_phyMacRxStartCallback
Callback - Rx start.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Packet > m_txPacket
Tx packet.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void EndTx()
End the current Tx.
void SetErrorModel(Ptr< SpectrumErrorModel > e)
Set the SpectrumErrorModel to be used.
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
Trace - Tx end (ok)
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
bool IsNull(void) const
Check for null implementation.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
GenericPhyTxEndCallback m_phyMacTxEndCallback
Callback - Tx end.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in power units (Watt, Pascal...) per Hz.
a unique identifier for an interface.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.