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>
101 .AddConstructor<HalfDuplexIdealPhy> ()
102 .AddAttribute (
"Rate",
103 "The PHY rate used by this device",
107 MakeDataRateChecker ())
108 .AddTraceSource (
"TxStart",
109 "Trace fired when a new transmission is started",
111 .AddTraceSource (
"TxEnd",
112 "Trace fired when a previosuly started transmission is finished",
114 .AddTraceSource (
"RxStart",
115 "Trace fired when the start of a signal is detected",
117 .AddTraceSource (
"RxAbort",
118 "Trace fired when a previously started RX is aborted before time",
120 .AddTraceSource (
"RxEndOk",
121 "Trace fired when a previosuly started RX terminates successfully",
123 .AddTraceSource (
"RxEndError",
124 "Trace fired when a previosuly started RX terminates with an error (packet is corrupted)",
176 return m_txPsd->GetSpectrumModel ();
287 txParams->duration = Seconds (txTimeSeconds);
288 txParams->txPhy = GetObject<SpectrumPhy> ();
293 NS_LOG_LOGIC (
this <<
" tx power: " << 10 * std::log10 (
Integral (*(txParams->psd))) + 30 <<
" dBm");
333 NS_LOG_LOGIC (
this <<
" rx power: " << 10 * std::log10 (
Integral (*(spectrumParams->psd))) + 30 <<
" dBm");
369 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxStartCallback");
374 NS_LOG_LOGIC (
this <<
" m_phyMacRxStartCallback is NULL");
377 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << rxParams->duration);
423 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxEndOkCallback");
428 NS_LOG_LOGIC (
this <<
" m_phyMacRxEndOkCallback is NULL");
436 NS_LOG_LOGIC (
this <<
" calling m_phyMacRxEndErrorCallback");
441 NS_LOG_LOGIC (
this <<
" m_phyMacRxEndErrorCallback is NULL");
void SetRate(DataRate rate)
set the PHY rate to be used by this PHY.
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)
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.
bool IsNull(void) const
Check for null implementation.
#define NS_ASSERT(condition)
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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.
SpectrumInterference m_interference
uint32_t GetSize(void) const
GenericPhyRxEndErrorCallback m_phyMacRxEndErrorCallback
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void AddSignal(Ptr< const SpectrumValue > spd, const Time duration)
notify that a new signal is being perceived in the medium.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
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
Class for representing data rates.
TracedCallback< Ptr< const Packet > > m_phyTxStartTrace
double CalculateTxTime(uint32_t bytes) const
Calculate transmission time.
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
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
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Ptr< AntennaModel > GetRxAntenna()
get the AntennaModel used by the NetDevice for reception
Ptr< SpectrumChannel > m_channel
NS_LOG_COMPONENT_DEFINE("HalfDuplexIdealPhy")
#define NS_LOG_LOGIC(msg)
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Ptr< NetDevice > GetDevice()
get the associated NetDevice instance
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
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
hold objects of type ns3::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)