23 #include "ns3/simulator.h" 24 #include "ns3/packet.h" 40 .SetGroupName (
"Wifi")
42 .AddTraceSource (
"State",
43 "The state of the PHY layer",
45 "ns3::WifiPhyStateHelper::StateTracedCallback")
46 .AddTraceSource (
"RxOk",
47 "A packet has been received successfully.",
49 "ns3::WifiPhyStateHelper::RxOkTracedCallback")
50 .AddTraceSource (
"RxError",
51 "A packet has been received unsuccessfully.",
53 "ns3::WifiPhyStateHelper::RxEndErrorTracedCallback")
54 .AddTraceSource (
"Tx",
"Packet transmission is starting.",
56 "ns3::WifiPhyStateHelper::TxTracedCallback")
74 m_previousStateChangeTime (
Seconds (0))
172 NS_FATAL_ERROR (
"Cannot determine when the device will wake up.");
176 NS_FATAL_ERROR (
"Cannot determine when the device will be switched on.");
233 (*i)->NotifyTxStart (duration, txPowerDbm);
243 (*i)->NotifyRxStart (duration);
253 (*i)->NotifyRxEndOk ();
263 (*i)->NotifyRxEndError ();
273 (*i)->NotifyMaybeCcaBusyStart (duration);
283 (*i)->NotifySwitchingStart (duration);
293 (*i)->NotifySleep ();
313 (*i)->NotifyWakeup ();
352 NS_LOG_FUNCTION (
this << txDuration << packet << txPowerDbm << txVector);
bool IsStateIdle(void) const
Check whether the current state is IDLE.
Time GetLastRxStartTime(void) const
Return the time the last RX start.
Simulation virtual time values and global simulation resolution.
void DoSwitchFromRx(void)
Switch the state from RX.
#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, WifiPhyState > m_stateLogger
The trace source fired when state is changed.
void NotifyWakeup(void)
Notify all WifiPhyListener that we woke up.
Time m_endCcaBusy
endn CCA busy
The PHY layer is sleeping.
Time m_startCcaBusy
start CCA busy
void SwitchToOff(void)
Switch to off mode.
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.
void SwitchFromRxAbort(void)
Abort current reception.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
std::vector< WifiPhyListener * >::iterator ListenersI
typedef for a list of WifiPhyListeners iterator
bool IsStateRx(void) const
Check whether the current state is RX.
bool IsStateSwitching(void) const
Check whether the current state is SWITCHING.
void SwitchFromSleep(Time duration)
Switch from sleep mode.
Time GetDelayUntilIdle(void) const
Return the time before the state is back to IDLE.
Time m_startSleep
start sleep
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiPreamble GetPreambleType(void) const
void NotifySleep(void)
Notify all WifiPhyListener that we are going to sleep.
Time m_endSwitching
end switching
bool IsStateSleep(void) const
Check whether the current state is SLEEP.
void NotifyOn(void)
Notify all WifiPhyListener that we are going to switch on.
receive notifications about phy events.
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay...
void SwitchFromRxEndError(Ptr< Packet > packet, double snr)
Switch from RX after the reception failed.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
WifiMode GetMode(void) const
The PHY layer has sense the medium busy through the CCA mechanism.
Time m_previousStateChangeTime
previous state change time
TracedCallback< Ptr< const Packet >, double, WifiMode, WifiPreamble > m_rxOkTrace
receive OK trace callback
void NotifyMaybeCcaBusyStart(Time duration)
Notify all WifiPhyListener that the CCA has started for the given duration.
RxErrorCallback m_rxErrorCallback
receive error callback
bool IsStateTx(void) const
Check whether the current state is TX.
void SwitchToTx(Time txDuration, Ptr< const Packet > packet, double txPowerDbm, WifiTxVector txVector)
Switch state to TX for the given duration.
void SwitchToSleep(void)
Switch to sleep mode.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyState
The state of the PHY layer.
Time m_startSwitching
start switching
void SetReceiveOkCallback(RxOkCallback callback)
Set a callback for a successful reception.
Time m_startTx
start transmit
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.
TracedCallback< Ptr< const Packet >, WifiMode, WifiPreamble, uint8_t > m_txTrace
transmit trace callback
static TypeId GetTypeId(void)
Get the type ID.
Time m_startRx
start receive
This objects implements the PHY state machine of the Wifi device.
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
The PHY layer is sending a packet.
void SwitchFromRxEndOk(Ptr< Packet > packet, double snr, WifiTxVector txVector)
Switch from RX after the reception was successful.
void SwitchFromOff(Time duration)
Switch from off mode.
Listeners m_listeners
listeners
Time Seconds(double value)
Construct a Time in the indicated unit.
The PHY layer is receiving a packet.
bool IsStateOff(void) const
Check whether the current state is OFF.
void SetReceiveErrorCallback(RxErrorCallback callback)
Set a callback for a failed reception.
The PHY layer is switched off.
uint8_t GetTxPowerLevel(void) const
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
receive error trace callback
The PHY layer is switching to other channel.
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.
bool IsNull(void) const
Check for null implementation.
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)
Set the parent TypeId.
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
void SwitchMaybeToCcaBusy(Time duration)
Switch to CCA busy.
RxOkCallback m_rxOkCallback
receive OK callback
void NotifyOff(void)
Notify all WifiPhyListener that we are going to switch off.
bool IsStateCcaBusy(void) const
Check whether the current state is CCA busy.