A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-phy-state-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef WIFI_PHY_STATE_HELPER_H
21#define WIFI_PHY_STATE_HELPER_H
22
23#include "wifi-phy-common.h"
24#include "wifi-phy-state.h"
25#include "wifi-ppdu.h"
26
27#include "ns3/callback.h"
28#include "ns3/nstime.h"
29#include "ns3/object.h"
30#include "ns3/traced-callback.h"
31
32#include <vector>
33
34namespace ns3
35{
36
37class WifiPhyListener;
38class WifiTxVector;
39class WifiMode;
40class Packet;
41class WifiPsdu;
42struct RxSignalInfo;
43
54typedef Callback<void, Ptr<const WifiPsdu>, RxSignalInfo, WifiTxVector, std::vector<bool>>
62
69{
70 public:
75 static TypeId GetTypeId();
76
78
96 void RegisterListener(WifiPhyListener* listener);
102 void UnregisterListener(WifiPhyListener* listener);
108 WifiPhyState GetState() const;
114 bool IsStateCcaBusy() const;
120 bool IsStateIdle() const;
126 bool IsStateRx() const;
132 bool IsStateTx() const;
138 bool IsStateSwitching() const;
144 bool IsStateSleep() const;
150 bool IsStateOff() const;
156 Time GetDelayUntilIdle() const;
162 Time GetLastRxStartTime() const;
168 Time GetLastRxEndTime() const;
169
178 void SwitchToTx(Time txDuration,
179 WifiConstPsduMap psdus,
180 double txPowerDbm,
181 const WifiTxVector& txVector);
187 void SwitchToRx(Time rxDuration);
193 void SwitchToChannelSwitching(Time switchingDuration);
202 RxSignalInfo rxSignalInfo,
203 const WifiTxVector& txVector);
214 RxSignalInfo rxSignalInfo,
215 const WifiTxVector& txVector,
216 uint16_t staId,
217 const std::vector<bool>& statusPerMpdu);
224 void NotifyRxPsduFailed(Ptr<const WifiPsdu> psdu, double snr);
228 void SwitchFromRxEndOk();
237 void SwitchFromRxAbort(uint16_t operatingWidth);
248 void SwitchMaybeToCcaBusy(Time duration,
249 WifiChannelListType channelType,
250 const std::vector<Time>& per20MhzDurations);
254 void SwitchToSleep();
258 void SwitchFromSleep();
262 void SwitchToOff();
266 void SwitchFromOff();
267
276 typedef void (*StateTracedCallback)(Time start, Time duration, WifiPhyState state);
277
286 typedef void (*RxOkTracedCallback)(Ptr<const Packet> packet,
287 double snr,
288 WifiMode mode,
289 WifiPreamble preamble);
290
297 typedef void (*RxEndErrorTracedCallback)(Ptr<const Packet> packet, double snr);
298
307 typedef void (*TxTracedCallback)(Ptr<const Packet> packet,
308 WifiMode mode,
309 WifiPreamble preamble,
310 uint8_t power);
311
312 private:
316 typedef std::vector<WifiPhyListener*> Listeners;
317
322
329 void NotifyTxStart(Time duration, double txPowerDbm);
335 void NotifyRxStart(Time duration);
339 void NotifyRxEndOk();
343 void NotifyRxEndError();
354 void NotifyCcaBusyStart(Time duration,
355 WifiChannelListType channelType,
356 const std::vector<Time>& per20MhzDurations);
363 void NotifySwitchingStart(Time duration);
367 void NotifySleep();
371 void NotifyOff();
375 void NotifyWakeup();
379 void DoSwitchFromRx();
383 void NotifyOn();
384
389
391 bool m_isOff;
402
411};
412
413} // namespace ns3
414
415#endif /* WIFI_PHY_STATE_HELPER_H */
Callback template class.
Definition: callback.h:438
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
represent a single transmission mode
Definition: wifi-mode.h:51
receive notifications about PHY events.
This objects implements the PHY state machine of the Wifi device.
void NotifyRxEndOk()
Notify all WifiPhyListener that the reception was successful.
bool IsStateSwitching() const
Check whether the current state is SWITCHING.
void(* TxTracedCallback)(Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t power)
TracedCallback signature for transmit event.
void SwitchToRx(Time rxDuration)
Switch state to RX for the given duration.
void NotifyOn()
Notify all WifiPhyListener that we are going to switch on.
std::vector< WifiPhyListener * > Listeners
typedef for a list of WifiPhyListeners
bool IsStateCcaBusy() const
Check whether the current state is CCA busy.
Time GetDelayUntilIdle() const
Return the time before the state is back to IDLE.
bool IsStateIdle() const
Check whether the current state is IDLE.
Time GetLastRxStartTime() const
Return the time the last RX start.
void(* StateTracedCallback)(Time start, Time duration, WifiPhyState state)
TracedCallback signature for state changes.
void DoSwitchFromRx()
Switch the state from RX.
void NotifyRxEndError()
Notify all WifiPhyListener that the reception was not successful.
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay.
void SwitchFromRxEndOk()
Switch from RX after the reception was successful.
Time m_previousStateChangeTime
previous state change time
void NotifyRxStart(Time duration)
Notify all WifiPhyListener that the reception has started for the given duration.
void SwitchToChannelSwitching(Time switchingDuration)
Switch state to channel switching for the given duration.
void SwitchToOff()
Switch to off mode.
void NotifyRxMpdu(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector)
Notify the reception of an MPDU included in an A-MPDU.
TracedCallback< Ptr< const Packet >, WifiMode, WifiPreamble, uint8_t > m_txTrace
transmit trace callback
Time m_endSwitching
end switching
void SwitchToTx(Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, const WifiTxVector &txVector)
Switch state to TX for the given duration.
Time m_startSwitching
start switching
TracedCallback< Time, Time, WifiPhyState > m_stateLogger
The trace source fired when state is changed.
void LogPreviousIdleAndCcaBusyStates()
Log the idle and CCA busy states.
void NotifySleep()
Notify all WifiPhyListener that we are going to sleep.
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
void NotifyCcaBusyStart(Time duration, WifiChannelListType channelType, const std::vector< Time > &per20MhzDurations)
Notify all WifiPhyListener that the CCA has started for the given duration.
static TypeId GetTypeId()
Get the type ID.
RxOkCallback m_rxOkCallback
receive OK callback
TracedCallback< Ptr< const Packet >, double, WifiMode, WifiPreamble > m_rxOkTrace
receive OK trace callback
void NotifyRxPsduFailed(Ptr< const WifiPsdu > psdu, double snr)
Handle the unsuccessful reception of a PSDU.
bool IsStateOff() const
Check whether the current state is OFF.
void(* RxEndErrorTracedCallback)(Ptr< const Packet > packet, double snr)
TracedCallback signature for receive end error event.
void SwitchFromRxAbort(uint16_t operatingWidth)
Abort current reception following a CCA reset request.
void(* RxOkTracedCallback)(Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
TracedCallback signature for receive end OK event.
WifiPhyState GetState() const
Return the current state of WifiPhy.
RxErrorCallback m_rxErrorCallback
receive error callback
void SwitchToSleep()
Switch to sleep mode.
void SwitchMaybeToCcaBusy(Time duration, WifiChannelListType channelType, const std::vector< Time > &per20MhzDurations)
Switch to CCA busy.
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
receive error trace callback
void NotifyOff()
Notify all WifiPhyListener that we are going to switch off.
bool IsStateTx() const
Check whether the current state is TX.
void SwitchFromOff()
Switch from off mode.
Time m_startCcaBusy
start CCA busy
void NotifyWakeup()
Notify all WifiPhyListener that we woke up.
void NotifyTxStart(Time duration, double txPowerDbm)
Notify all WifiPhyListener that the transmission has started for the given duration.
Listeners m_listeners
listeners
Time GetLastRxEndTime() const
Return the time the last RX end.
void SwitchFromRxEndError()
Switch from RX after the reception failed.
void SetReceiveOkCallback(RxOkCallback callback)
Set a callback for a successful reception.
void SwitchFromSleep()
Switch from sleep mode.
bool IsStateSleep() const
Check whether the current state is SLEEP.
bool IsStateRx() const
Check whether the current state is RX.
void SetReceiveErrorCallback(RxErrorCallback callback)
Set a callback for a failed reception.
void UnregisterListener(WifiPhyListener *listener)
Remove WifiPhyListener from this WifiPhyStateHelper.
void NotifyRxPsduSucceeded(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, uint16_t staId, const std::vector< bool > &statusPerMpdu)
Handle the successful reception of a PSDU.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< void, Ptr< const WifiPsdu > > RxErrorCallback
Callback if PSDU unsuccessfuly received.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< void, Ptr< const WifiPsdu >, RxSignalInfo, WifiTxVector, std::vector< bool > > RxOkCallback
Callback if PSDU successfully received (i.e.
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:70
Declaration of the following enums:
WifiPhyState
The state of the PHY layer.
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.