22 #include "ns3/simulator.h"
23 #include "ns3/trace-source-accessor.h"
37 .AddConstructor<WifiPhyStateHelper> ()
38 .AddTraceSource (
"State",
39 "The state of the PHY layer",
41 "ns3::WifiPhyStateHelper::StateTracedCallback")
42 .AddTraceSource (
"RxOk",
43 "A packet has been received successfully.",
45 "ns3::WifiPhyStateHelper::RxOkTracedCallback")
46 .AddTraceSource (
"RxError",
47 "A packet has been received unsuccessfully.",
49 "ns3::WifiPhyStateHelper::RxErrorTracedCallback")
50 .AddTraceSource (
"Tx",
"Packet transmission is starting.",
52 "ns3::WifiPhyStateHelper::TxTracedCallback")
69 m_previousStateChangeTime (
Seconds (0))
166 NS_FATAL_ERROR (
"Cannot determine when the device will wake up.");
219 (*i)->NotifyTxStart (duration, txPowerDbm);
227 (*i)->NotifyRxStart (duration);
235 (*i)->NotifyRxEndOk ();
243 (*i)->NotifyRxEndError ();
251 (*i)->NotifyMaybeCcaBusyStart (duration);
259 (*i)->NotifySwitchingStart (duration);
267 (*i)->NotifySleep ();
275 (*i)->NotifyWakeup ();
Simulation virtual time values and global simulation resolution.
void DoSwitchFromRx(void)
Switch the state from RX.
Time GetStateDuration(void)
Return the elapsed time of the current state.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
TracedCallback< Time, Time, enum WifiPhy::State > m_stateLogger
void NotifyWakeup(void)
Notify all WifiPhyListener that we woke up.
The PHY layer has sense the medium busy through the CCA mechanism.
bool IsNull(void) const
Check for null implementation.
void SwitchToChannelSwitching(Time switchingDuration)
Switch state to channel switching for the given duration.
void UnregisterListener(WifiPhyListener *listener)
Remove WifiPhyListener from this WifiPhyStateHelper.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void NotifyRxEndError(void)
Notify all WifiPhyListener that the reception was not successful.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
The PHY layer is sleeping.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
std::vector< WifiPhyListener * >::iterator ListenersI
void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
Set a callback for a successful reception.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
void SwitchFromSleep(Time duration)
Switch from sleep mode.
uint8_t GetTxPowerLevel(void) const
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
bool IsStateIdle(void)
Check whether the current state is IDLE.
Time GetDelayUntilIdle(void)
Return the time before the state is back to IDLE.
void NotifySleep(void)
Notify all WifiPhyListener that we are going to sleep.
TracedCallback< Ptr< const Packet >, double, WifiMode, enum WifiPreamble > m_rxOkTrace
bool IsStateSwitching(void)
Check whether the current state is SWITCHING.
receive notifications about phy events.
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay...
bool IsStateRx(void)
Check whether the current state is RX.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Time m_previousStateChangeTime
void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
Set a callback for a failed reception.
The PHY layer is receiving a packet.
bool IsStateSleep(void)
Check whether the current state is SLEEP.
The PHY layer is sending a packet.
void NotifyMaybeCcaBusyStart(Time duration)
Notify all WifiPhyListener that the CCA has started for the given duration.
WifiPhy::RxErrorCallback m_rxErrorCallback
The PHY layer is switching to other channel.
void SwitchToSleep(void)
Switch to sleep mode.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SwitchFromRxEndError(Ptr< const Packet > packet, double snr)
Switch from RX after the reception failed.
void NotifyTxStart(Time duration, double txPowerDbm)
Notify all WifiPhyListener that the transmission has started for the given duration.
static Time Now(void)
Return the current simulation virtual time.
void NotifyRxEndOk(void)
Notify all WifiPhyListener that the reception was successful.
void SwitchFromRxEndOk(Ptr< Packet > packet, double snr, WifiMode mode, enum WifiPreamble preamble)
Switch from RX after the reception was successful.
static TypeId GetTypeId(void)
enum WifiPhy::State GetState(void)
Return the current state of WifiPhy.
bool IsStateBusy(void)
Check whether the current state is not IDLE.
bool IsStateCcaBusy(void)
Check whether the current state is CCA busy.
TracedCallback< Ptr< const Packet >, WifiMode, WifiPreamble, uint8_t > m_txTrace
Time Seconds(double value)
Construct a Time in the indicated unit.
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
bool IsStateTx(void)
Check whether the current state is TX.
A base class which provides memory management and object aggregation.
void SwitchToRx(Time rxDuration)
Switch state to RX for the given duration.
void LogPreviousIdleAndCcaBusyStates(void)
Log the ideal and CCA states.
Time GetLastRxStartTime(void) const
Return the time the last RX start.
WifiMode GetMode(void) const
State
The state of the PHY layer.
void NotifyRxStart(Time duration)
Notify all WifiPhyListener that the reception has started for the given duration. ...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
void SwitchMaybeToCcaBusy(Time duration)
Switch to CCA busy.
void SwitchToTx(Time txDuration, Ptr< const Packet > packet, double txPowerDbm, WifiTxVector txVector, WifiPreamble preamble)
Switch state to TX for the given duration.
WifiPhy::RxOkCallback m_rxOkCallback