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 .AddTraceSource (
"RxOk",
42 "A packet has been received successfully.",
44 .AddTraceSource (
"RxError",
45 "A packet has been received unsuccessfully.",
47 .AddTraceSource (
"Tx",
"Packet transmission is starting.",
55 m_endTx (Seconds (0)),
56 m_endRx (Seconds (0)),
57 m_endCcaBusy (Seconds (0)),
58 m_endSwitching (Seconds (0)),
59 m_startTx (Seconds (0)),
60 m_startRx (Seconds (0)),
61 m_startCcaBusy (Seconds (0)),
62 m_startSwitching (Seconds (0)),
63 m_previousStateChangeTime (Seconds (0))
143 retval = Seconds (0);
147 retval = Seconds (0);
150 retval =
Max (retval, Seconds (0));
191 (*i)->NotifyTxStart (duration);
199 (*i)->NotifyRxStart (duration);
207 (*i)->NotifyRxEndOk ();
215 (*i)->NotifyRxEndError ();
223 (*i)->NotifyMaybeCcaBusyStart (duration);
231 (*i)->NotifySwitchingStart (duration);
259 m_txTrace (packet, txMode, preamble, txPower);
keep track of time values and allow control of 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)
TracedCallback< Time, Time, enum WifiPhy::State > m_stateLogger
State
The state of the PHY layer.
bool IsNull(void) const
Check for null implementation.
void SwitchToChannelSwitching(Time switchingDuration)
Switch state to channel switching for the given duration.
#define NS_ASSERT(condition)
void NotifyRxEndError(void)
Notify all WifiPhyListener that the reception was not successful.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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...
#define NS_FATAL_ERROR(msg)
fatal error handling
The PHY layer is switching to other channel.
void SwitchToTx(Time txDuration, Ptr< const Packet > packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower)
Switch state to TX for the given duration.
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.
TracedCallback< Ptr< const Packet >, double, WifiMode, enum WifiPreamble > m_rxOkTrace
bool IsStateSwitching(void)
Check whether the current state is SWITCHING.
void NotifyTxStart(Time duration)
Notify all WifiPhyListener that the transmission has started for the given duration.
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.
Time m_previousStateChangeTime
void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
Set a callback for a failed reception.
void NotifyMaybeCcaBusyStart(Time duration)
Notify all WifiPhyListener that the CCA has started for the given duration.
WifiPhy::RxErrorCallback m_rxErrorCallback
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void SwitchFromRxEndError(Ptr< const Packet > packet, double snr)
Switch from RX after the reception failed.
static Time Now(void)
Return the "current simulation 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)
NS_LOG_COMPONENT_DEFINE("WifiPhyStateHelper")
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
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.
The PHY layer is receiving a packet.
void NotifyRxStart(Time duration)
Notify all WifiPhyListener that the reception has started for the given duration. ...
The PHY layer has sense the medium busy through the CCA mechanism.
a unique identifier for an interface.
The PHY layer is sending a packet.
TypeId SetParent(TypeId tid)
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
void SwitchMaybeToCcaBusy(Time duration)
Switch to CCA busy.
WifiPhy::RxOkCallback m_rxOkCallback