A Discrete-Event Network Simulator
API
wifi-phy-state-helper.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005,2006 INRIA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20
21#ifndef WIFI_PHY_STATE_HELPER_H
22#define WIFI_PHY_STATE_HELPER_H
23
24#include <vector>
25#include "ns3/object.h"
26#include "ns3/callback.h"
27#include "ns3/traced-callback.h"
28#include "ns3/nstime.h"
29#include "wifi-phy-state.h"
30#include "wifi-phy-common.h"
31#include "wifi-ppdu.h"
32
33namespace ns3 {
34
35class WifiPhyListener;
36class WifiTxVector;
37class WifiMode;
38class Packet;
39class WifiPsdu;
40struct RxSignalInfo;
41
52typedef Callback<void, Ptr<const WifiPsdu>, RxSignalInfo,
53 WifiTxVector, std::vector<bool>> RxOkCallback;
60
67{
68public:
73 static TypeId GetTypeId (void);
74
76
82 void SetReceiveOkCallback (RxOkCallback callback);
94 void RegisterListener (WifiPhyListener *listener);
100 void UnregisterListener (WifiPhyListener *listener);
106 WifiPhyState GetState (void) const;
112 bool IsStateCcaBusy (void) const;
118 bool IsStateIdle (void) const;
124 bool IsStateRx (void) const;
130 bool IsStateTx (void) const;
136 bool IsStateSwitching (void) const;
142 bool IsStateSleep (void) const;
148 bool IsStateOff (void) const;
154 Time GetDelayUntilIdle (void) const;
160 Time GetLastRxStartTime (void) const;
166 Time GetLastRxEndTime (void) const;
167
176 void SwitchToTx (Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, const WifiTxVector& txVector);
182 void SwitchToRx (Time rxDuration);
188 void SwitchToChannelSwitching (Time switchingDuration);
196 void NotifyRxMpdu (Ptr<const WifiPsdu> psdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector);
207 const WifiTxVector& txVector, uint16_t staId,
208 const std::vector<bool>& statusPerMpdu);
215 void NotifyRxPsduFailed (Ptr<const WifiPsdu> psdu, double snr);
219 void SwitchFromRxEndOk (void);
223 void SwitchFromRxEndError (void);
228 void SwitchFromRxAbort (uint16_t operatingWidth);
239 void SwitchMaybeToCcaBusy (Time duration, WifiChannelListType channelType,
240 const std::vector<Time>& per20MhzDurations);
244 void SwitchToSleep (void);
248 void SwitchFromSleep (void);
252 void SwitchToOff (void);
256 void SwitchFromOff (void);
257
266 typedef void (* StateTracedCallback)(Time start, Time duration, WifiPhyState state);
267
276 typedef void (* RxOkTracedCallback)(Ptr<const Packet> packet, double snr, WifiMode mode, WifiPreamble preamble);
277
284 typedef void (* RxEndErrorTracedCallback)(Ptr<const Packet> packet, double snr);
285
294 typedef void (* TxTracedCallback)(Ptr<const Packet> packet, WifiMode mode,
295 WifiPreamble preamble, uint8_t power);
296
297
298private:
302 typedef std::vector<WifiPhyListener *> Listeners;
303
308
315 void NotifyTxStart (Time duration, double txPowerDbm);
321 void NotifyRxStart (Time duration);
325 void NotifyRxEndOk (void);
329 void NotifyRxEndError (void);
340 void NotifyCcaBusyStart (Time duration,
341 WifiChannelListType channelType,
342 const std::vector<Time>& per20MhzDurations);
349 void NotifySwitchingStart (Time duration);
353 void NotifySleep (void);
357 void NotifyOff (void);
361 void NotifyWakeup (void);
365 void DoSwitchFromRx (void);
369 void NotifyOn (void);
370
375
377 bool m_isOff;
388
395};
396
397} //namespace ns3
398
399#endif /* WIFI_PHY_STATE_HELPER_H */
Callback template class.
Definition: callback.h:422
A base class which provides memory management and object aggregation.
Definition: object.h:88
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
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:48
receive notifications about PHY events.
This objects implements the PHY state machine of the Wifi device.
bool IsStateSleep(void) const
Check whether the current state is SLEEP.
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.
bool IsStateCcaBusy(void) const
Check whether the current state is CCA busy.
void SwitchFromSleep(void)
Switch from sleep mode.
Time GetLastRxEndTime(void) const
Return the time the last RX end.
Time GetDelayUntilIdle(void) const
Return the time before the state is back to IDLE.
void DoSwitchFromRx(void)
Switch the state from RX.
Time GetLastRxStartTime(void) const
Return the time the last RX start.
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
bool IsStateOff(void) const
Check whether the current state is OFF.
void(* StateTracedCallback)(Time start, Time duration, WifiPhyState state)
TracedCallback signature for state changes.
bool IsStateTx(void) const
Check whether the current state is TX.
void NotifyOn(void)
Notify all WifiPhyListener that we are going to switch on.
bool IsStateRx(void) const
Check whether the current state is RX.
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay.
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 NotifyRxEndOk(void)
Notify all WifiPhyListener that the reception was successful.
void SwitchFromOff(void)
Switch from 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
std::vector< WifiPhyListener * > Listeners
typedef for a list of WifiPhyListeners
TracedCallback< Time, Time, WifiPhyState > m_stateLogger
The trace source fired when state is changed.
void LogPreviousIdleAndCcaBusyStates(void)
Log the idle and CCA busy states.
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.
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.
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.
bool IsStateSwitching(void) const
Check whether the current state is SWITCHING.
void(* RxOkTracedCallback)(Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
TracedCallback signature for receive end OK event.
RxErrorCallback m_rxErrorCallback
receive error callback
void SwitchFromRxEndOk(void)
Switch from RX after the reception was successful.
void SwitchMaybeToCcaBusy(Time duration, WifiChannelListType channelType, const std::vector< Time > &per20MhzDurations)
Switch to CCA busy.
void NotifyOff(void)
Notify all WifiPhyListener that we are going to switch off.
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
receive error trace callback
Time m_startCcaBusy
start CCA busy
void NotifyTxStart(Time duration, double txPowerDbm)
Notify all WifiPhyListener that the transmission has started for the given duration.
Listeners m_listeners
listeners
static TypeId GetTypeId(void)
Get the type ID.
void SwitchToOff(void)
Switch to off mode.
void SetReceiveOkCallback(RxOkCallback callback)
Set a callback for a successful reception.
void SwitchFromRxEndError(void)
Switch from RX after the reception failed.
void SwitchToSleep(void)
Switch to sleep mode.
bool IsStateIdle(void) const
Check whether the current state is IDLE.
void NotifyRxEndError(void)
Notify all WifiPhyListener that the reception was not successful.
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.
void NotifySleep(void)
Notify all WifiPhyListener that we are going to sleep.
void NotifyWakeup(void)
Notify all WifiPhyListener that we woke up.
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 unsuccessfully 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.
def start()
Definition: core.py:1852
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:69
Declaration of the following enums:
WifiPhyState
The state of the PHY layer.
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.