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>
100 .AddConstructor<HalfDuplexIdealPhy> ()
101 .AddAttribute (
"Rate",
102 "The PHY rate used by this device",
107 .AddTraceSource (
"TxStart",
108 "Trace fired when a new transmission is started",
110 "ns3::Packet::TraceCallback")
111 .AddTraceSource (
"TxEnd",
112 "Trace fired when a previosuly started transmission is finished",
114 "ns3::Packet::TraceCallback")
115 .AddTraceSource (
"RxStart",
116 "Trace fired when the start of a signal is detected",
118 "ns3::Packet::TraceCallback")
119 .AddTraceSource (
"RxAbort",
120 "Trace fired when a previously started RX is aborted before time",
122 "ns3::Packet::TraceCallback")
123 .AddTraceSource (
"RxEndOk",
124 "Trace fired when a previosuly started RX terminates successfully",
126 "ns3::Packet::TraceCallback")
127 .AddTraceSource (
"RxEndError",
128 "Trace fired when a previosuly started RX terminates with an error (packet is corrupted)",
130 "ns3::Packet::TraceCallback")
292 txParams->duration = txTimeSeconds;
293 txParams->txPhy = GetObject<SpectrumPhy> ();
298 NS_LOG_LOGIC (
this <<
" tx power: " << 10 * std::log10 (
Integral (*(txParams->psd))) + 30 <<
" dBm");
338 NS_LOG_LOGIC (
this <<
" rx power: " << 10 * std::log10 (
Integral (*(spectrumParams->psd))) + 30 <<
" dBm");
374 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxStartCallback");
379 NS_LOG_LOGIC (
this <<
" m_phyMacRxStartCallback is NULL");
382 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << rxParams->duration);
428 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxEndOkCallback");
433 NS_LOG_LOGIC (
this <<
" m_phyMacRxEndOkCallback is NULL");
441 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxEndErrorCallback");
446 NS_LOG_LOGIC (
this <<
" m_phyMacRxEndErrorCallback is NULL");
void SetRate(DataRate rate)
set the PHY rate to be used by this PHY.
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 betweenthe 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
Abstract base class for Spectrum-aware PHY layers.
double Integral(const SpectrumValue &arg)
bool StartTx(Ptr< Packet > p)
Start a transmission.
Ptr< NetDevice > GetDevice() const
get the associated NetDevice instance
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
bool IsNull(void) const
Check for null implementation.
#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)
void SetGenericPhyRxStartCallback(GenericPhyRxStartCallback c)
set the callback for the start of RX, as part of the interconnections betweenthe 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
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
#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
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
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
TracedCallback< Ptr< const Packet > > m_phyRxAbortTrace
Ptr< const AttributeChecker > MakeDataRateChecker(void)
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
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Ptr< SpectrumValue > m_txPsd
void SetGenericPhyRxEndOkCallback(GenericPhyRxEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections betweenthe PHY and t...
virtual ~HalfDuplexIdealPhy()
GenericPhyRxEndOkCallback m_phyMacRxEndOkCallback
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void DoDispose(void)
Destructor implementation.
Ptr< AntennaModel > GetRxAntenna()
get the AntennaModel used by the NetDevice for reception
Ptr< SpectrumChannel > m_channel
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)
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ChangeState(State newState)
bool EndRx()
notify that the RX attempt has ended.
Ptr< NetDevice > m_netDevice
void SetGenericPhyRxEndErrorCallback(GenericPhyRxEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections betweenthe PHY and the...
Ptr< AntennaModel > m_antenna
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
AttributeValue implementation for DataRate.
GenericPhyRxStartCallback m_phyMacRxStartCallback
static TypeId GetTypeId(void)
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 SetErrorModel(Ptr< SpectrumErrorModel > e)
set the SpectrumErrorModel to be used.
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
GenericPhyTxEndCallback m_phyMacTxEndCallback
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.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
TypeId SetParent(TypeId tid)
Set the parent TypeId.