|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #include "ns3/simulator.h"
24 #include "ns3/packet.h"
42 .SetGroupName (
"Wifi")
44 .AddTraceSource (
"State",
45 "The state of the PHY layer",
47 "ns3::WifiPhyStateHelper::StateTracedCallback")
48 .AddTraceSource (
"RxOk",
49 "A packet has been received successfully.",
51 "ns3::WifiPhyStateHelper::RxOkTracedCallback")
52 .AddTraceSource (
"RxError",
53 "A packet has been received unsuccessfully.",
55 "ns3::WifiPhyStateHelper::RxEndErrorTracedCallback")
56 .AddTraceSource (
"Tx",
"Packet transmission is starting.",
58 "ns3::WifiPhyStateHelper::TxTracedCallback")
75 m_previousStateChangeTime (
Seconds (0))
234 (*i)->NotifyTxStart (duration, txPowerDbm);
244 (*i)->NotifyRxStart (duration);
254 (*i)->NotifyRxEndOk ();
264 (*i)->NotifyRxEndError ();
274 (*i)->NotifyMaybeCcaBusyStart (duration);
284 (*i)->NotifySwitchingStart (duration);
294 (*i)->NotifySleep ();
314 (*i)->NotifyWakeup ();
344 Time ccaBusyDuration = idleStart - ccaBusyStart;
350 Time idleDuration = now - idleStart;
360 NS_LOG_FUNCTION (
this << txDuration << psdus << txPowerDbm << txVector);
363 for (
auto const& psdu : psdus)
475 std::vector<bool> statusPerMpdu;
485 NS_LOG_FUNCTION (
this << *psdu << rxSignalInfo << txVector << staId << statusPerMpdu.size () <<
486 std::all_of(statusPerMpdu.begin(), statusPerMpdu.end(), [](
bool v) { return v; }));
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool IsStateSwitching(void) const
Check whether the current state is SWITCHING.
void LogPreviousIdleAndCcaBusyStates(void)
Log the ideal and CCA states.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
bool IsStateSleep(void) const
Check whether the current state is SLEEP.
void SwitchFromOff(Time duration)
Switch from off mode.
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
receive error trace callback
TracedCallback< Ptr< const Packet >, WifiMode, WifiPreamble, uint8_t > m_txTrace
transmit trace callback
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ RX
The PHY layer is receiving a packet.
static TypeId GetTypeId(void)
Get the type ID.
void SwitchToSleep(void)
Switch to sleep mode.
bool IsNull(void) const
Check for null implementation.
void SetReceiveErrorCallback(RxErrorCallback callback)
Set a callback for a failed reception.
bool IsStateCcaBusy(void) const
Check whether the current state is CCA busy.
TracedCallback< Ptr< const Packet >, double, WifiMode, WifiPreamble > m_rxOkTrace
receive OK trace callback
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
receive notifications about PHY events.
@ IDLE
The PHY layer is IDLE.
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
Listeners m_listeners
listeners
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
void NotifyRxEndOk(void)
Notify all WifiPhyListener that the reception was successful.
@ OFF
The PHY layer is switched off.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Time m_startSwitching
start switching
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SwitchToOff(void)
Switch to off mode.
void SwitchToRx(Time rxDuration)
Switch state to RX for the given duration.
void UnregisterListener(WifiPhyListener *listener)
Remove WifiPhyListener from this WifiPhyStateHelper.
void NotifyOff(void)
Notify all WifiPhyListener that we are going to switch off.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
bool IsStateIdle(void) const
Check whether the current state is IDLE.
void SetReceiveOkCallback(RxOkCallback callback)
Set a callback for a successful reception.
Time m_startTx
start transmit
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
This objects implements the PHY state machine of the Wifi device.
void NotifyTxStart(Time duration, double txPowerDbm)
Notify all WifiPhyListener that the transmission has started for the given duration.
void SwitchMaybeToCcaBusy(Time duration)
Switch to CCA busy.
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
A base class which provides memory management and object aggregation.
void SwitchFromRxAbort(void)
Abort current reception.
std::vector< WifiPhyListener * >::iterator ListenersI
typedef for a list of WifiPhyListeners iterator
int64x64_t Abs(const int64x64_t &value)
Absolute value.
void DoSwitchFromRx(void)
Switch the state from RX.
Time m_startCcaBusy
start CCA busy
void SwitchFromRxEndError(Ptr< WifiPsdu > psdu, double snr)
Switch from RX after the reception failed.
TracedCallback< Time, Time, WifiPhyState > m_stateLogger
The trace source fired when state is changed.
WifiPreamble GetPreambleType(void) const
RxOkCallback m_rxOkCallback
receive OK callback
Simulation virtual time values and global simulation resolution.
Time m_endCcaBusy
end CCA busy
void SwitchToTx(Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, WifiTxVector txVector)
Switch state to TX for the given duration.
Time m_previousStateChangeTime
previous state change time
@ SLEEP
The PHY layer is sleeping.
void NotifySleep(void)
Notify all WifiPhyListener that we are going to sleep.
WifiPhyState
The state of the PHY layer.
bool IsStateOff(void) const
Check whether the current state is OFF.
double snr
SNR in linear scale.
@ SWITCHING
The PHY layer is switching to other channel.
void NotifyOn(void)
Notify all WifiPhyListener that we are going to switch on.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
RxSignalInfo structure containing info on the received signal.
Time Seconds(double value)
Construct a Time in the indicated unit.
void NotifyMaybeCcaBusyStart(Time duration)
Notify all WifiPhyListener that the CCA has started for the given duration.
void NotifyRxStart(Time duration)
Notify all WifiPhyListener that the reception has started for the given duration.
uint8_t GetTxPowerLevel(void) const
void SwitchFromRxEndOk(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, uint16_t staId, std::vector< bool > statusPerMpdu)
Switch from RX after the reception was successful.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
bool IsStateTx(void) const
Check whether the current state is TX.
void SwitchToChannelSwitching(Time switchingDuration)
Switch state to channel switching for the given duration.
void NotifyWakeup(void)
Notify all WifiPhyListener that we woke up.
void ContinueRxNextMpdu(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector)
Continue RX after the reception of an MPDU in an A-MPDU was successful.
Time m_startRx
start receive
Time GetLastRxStartTime(void) const
Return the time the last RX start.
bool IsStateRx(void) const
Check whether the current state is RX.
@ TX
The PHY layer is sending a packet.
void NotifyRxEndError(void)
Notify all WifiPhyListener that the reception was not successful.
Time GetLastRxEndTime(void) const
Return the time the last RX end.
Time m_endSwitching
end switching
RxErrorCallback m_rxErrorCallback
receive error callback
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay.
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.