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 "ns3/object.h"
25 #include "ns3/callback.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/nstime.h"
28 #include "wifi-phy-state.h"
29 #include "wifi-phy-common.h"
30 #include "wifi-ppdu.h"
31 
32 namespace ns3 {
33 
34 class WifiPhyListener;
35 class WifiTxVector;
36 class WifiMode;
37 class Packet;
38 class WifiPsdu;
39 struct RxSignalInfo;
40 
51 typedef Callback<void, Ptr<WifiPsdu>, RxSignalInfo,
52  WifiTxVector, std::vector<bool>> RxOkCallback;
59 
65 class WifiPhyStateHelper : public Object
66 {
67 public:
72  static TypeId GetTypeId (void);
73 
75 
81  void SetReceiveOkCallback (RxOkCallback callback);
93  void RegisterListener (WifiPhyListener *listener);
99  void UnregisterListener (WifiPhyListener *listener);
105  WifiPhyState GetState (void) const;
111  bool IsStateCcaBusy (void) const;
117  bool IsStateIdle (void) const;
123  bool IsStateRx (void) const;
129  bool IsStateTx (void) const;
135  bool IsStateSwitching (void) const;
141  bool IsStateSleep (void) const;
147  bool IsStateOff (void) const;
153  Time GetDelayUntilIdle (void) const;
159  Time GetLastRxStartTime (void) const;
165  Time GetLastRxEndTime (void) const;
166 
175  void SwitchToTx (Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, WifiTxVector txVector);
181  void SwitchToRx (Time rxDuration);
187  void SwitchToChannelSwitching (Time switchingDuration);
195  void ContinueRxNextMpdu (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector);
205  void SwitchFromRxEndOk (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector,
206  uint16_t staId, std::vector<bool> statusPerMpdu);
213  void SwitchFromRxEndError (Ptr<WifiPsdu> psdu, double snr);
219  void SwitchMaybeToCcaBusy (Time duration);
223  void SwitchToSleep (void);
229  void SwitchFromSleep (Time duration);
233  void SwitchFromRxAbort (void);
237  void SwitchToOff (void);
243  void SwitchFromOff (Time duration);
244 
253  typedef void (* StateTracedCallback)(Time start, Time duration, WifiPhyState state);
254 
263  typedef void (* RxOkTracedCallback)(Ptr<const Packet> packet, double snr, WifiMode mode, WifiPreamble preamble);
264 
271  typedef void (* RxEndErrorTracedCallback)(Ptr<const Packet> packet, double snr);
272 
281  typedef void (* TxTracedCallback)(Ptr<const Packet> packet, WifiMode mode,
282  WifiPreamble preamble, uint8_t power);
283 
284 
285 private:
289  typedef std::vector<WifiPhyListener *> Listeners;
293  typedef std::vector<WifiPhyListener *>::iterator ListenersI;
294 
299 
306  void NotifyTxStart (Time duration, double txPowerDbm);
312  void NotifyRxStart (Time duration);
316  void NotifyRxEndOk (void);
320  void NotifyRxEndError (void);
326  void NotifyMaybeCcaBusyStart (Time duration);
333  void NotifySwitchingStart (Time duration);
337  void NotifySleep (void);
341  void NotifyOff (void);
345  void NotifyWakeup (void);
349  void DoSwitchFromRx (void);
353  void NotifyOn (void);
354 
359 
360  bool m_sleeping;
361  bool m_isOff;
372 
379 };
380 
381 } //namespace ns3
382 
383 #endif /* WIFI_PHY_STATE_HELPER_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::WifiPhyStateHelper::IsStateSwitching
bool IsStateSwitching(void) const
Check whether the current state is SWITCHING.
Definition: wifi-phy-state-helper.cc:133
ns3::WifiPhyStateHelper::LogPreviousIdleAndCcaBusyStates
void LogPreviousIdleAndCcaBusyStates(void)
Log the ideal and CCA states.
Definition: wifi-phy-state-helper.cc:329
ns3::WifiPhyStateHelper::IsStateSleep
bool IsStateSleep(void) const
Check whether the current state is SLEEP.
Definition: wifi-phy-state-helper.cc:139
ns3::WifiPhyStateHelper::SwitchFromOff
void SwitchFromOff(Time duration)
Switch from off mode.
Definition: wifi-phy-state-helper.cc:658
ns3::WifiPhyStateHelper::m_rxErrorTrace
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
receive error trace callback
Definition: wifi-phy-state-helper.h:375
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::WifiPhyStateHelper::m_txTrace
TracedCallback< Ptr< const Packet >, WifiMode, WifiPreamble, uint8_t > m_txTrace
transmit trace callback
Definition: wifi-phy-state-helper.h:376
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiPhyStateHelper::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-phy-state-helper.cc:38
ns3::WifiPhyStateHelper::SwitchToSleep
void SwitchToSleep(void)
Switch to sleep mode.
Definition: wifi-phy-state-helper.cc:559
ns3::WifiPhyStateHelper::SetReceiveErrorCallback
void SetReceiveErrorCallback(RxErrorCallback callback)
Set a callback for a failed reception.
Definition: wifi-phy-state-helper.cc:87
ns3::WifiPhyStateHelper::m_endRx
Time m_endRx
end receive
Definition: wifi-phy-state-helper.h:363
ns3::WifiPhyStateHelper::IsStateCcaBusy
bool IsStateCcaBusy(void) const
Check whether the current state is CCA busy.
Definition: wifi-phy-state-helper.cc:115
ns3::WifiPhyStateHelper::m_rxOkTrace
TracedCallback< Ptr< const Packet >, double, WifiMode, WifiPreamble > m_rxOkTrace
receive OK trace callback
Definition: wifi-phy-state-helper.h:374
ns3::WifiPhyListener
receive notifications about PHY events.
Definition: wifi-phy-listener.h:33
ns3::WifiPhyStateHelper::GetState
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
Definition: wifi-phy-state-helper.cc:196
ns3::WifiPhyStateHelper::m_sleeping
bool m_sleeping
sleeping
Definition: wifi-phy-state-helper.h:360
ns3::WifiPhyStateHelper::m_listeners
Listeners m_listeners
listeners
Definition: wifi-phy-state-helper.h:373
ns3::RxOkCallback
Callback< void, Ptr< WifiPsdu >, RxSignalInfo, WifiTxVector, std::vector< bool > > RxOkCallback
Callback if PSDU successfully received (i.e.
Definition: wifi-phy-state-helper.h:39
ns3::WifiPhyStateHelper::NotifyRxEndOk
void NotifyRxEndOk(void)
Notify all WifiPhyListener that the reception was successful.
Definition: wifi-phy-state-helper.cc:249
wifi-phy-common.h
Declaration of the following enums:
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::WifiConstPsduMap
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition: he-frame-exchange-manager.h:43
ns3::WifiPhyStateHelper::m_startSwitching
Time m_startSwitching
start switching
Definition: wifi-phy-state-helper.h:369
ns3::WifiPhyStateHelper::RegisterListener
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
Definition: wifi-phy-state-helper.cc:93
ns3::WifiPhyStateHelper::SwitchToOff
void SwitchToOff(void)
Switch to off mode.
Definition: wifi-phy-state-helper.cc:617
ns3::WifiPhyStateHelper::SwitchToRx
void SwitchToRx(Time rxDuration)
Switch state to RX for the given duration.
Definition: wifi-phy-state-helper.cc:401
ns3::WifiPhyStateHelper::UnregisterListener
void UnregisterListener(WifiPhyListener *listener)
Remove WifiPhyListener from this WifiPhyStateHelper.
Definition: wifi-phy-state-helper.cc:99
ns3::WifiPhyStateHelper::NotifyOff
void NotifyOff(void)
Notify all WifiPhyListener that we are going to switch off.
Definition: wifi-phy-state-helper.cc:299
ns3::WifiPhyStateHelper::RxEndErrorTracedCallback
void(* RxEndErrorTracedCallback)(Ptr< const Packet > packet, double snr)
TracedCallback signature for receive end error event.
Definition: wifi-phy-state-helper.h:271
ns3::WifiPhyStateHelper::IsStateIdle
bool IsStateIdle(void) const
Check whether the current state is IDLE.
Definition: wifi-phy-state-helper.cc:109
ns3::WifiPhyStateHelper::SetReceiveOkCallback
void SetReceiveOkCallback(RxOkCallback callback)
Set a callback for a successful reception.
Definition: wifi-phy-state-helper.cc:81
ns3::Ptr< WifiPsdu >
ns3::WifiPhyStateHelper::m_startTx
Time m_startTx
start transmit
Definition: wifi-phy-state-helper.h:366
ns3::WifiPhyStateHelper
This objects implements the PHY state machine of the Wifi device.
Definition: wifi-phy-state-helper.h:66
visualizer.core.start
def start()
Definition: core.py:1855
ns3::WifiPhyStateHelper::NotifyTxStart
void NotifyTxStart(Time duration, double txPowerDbm)
Notify all WifiPhyListener that the transmission has started for the given duration.
Definition: wifi-phy-state-helper.cc:229
ns3::WifiPhyStateHelper::SwitchMaybeToCcaBusy
void SwitchMaybeToCcaBusy(Time duration)
Switch to CCA busy.
Definition: wifi-phy-state-helper.cc:533
ns3::WifiPhyStateHelper::SwitchFromSleep
void SwitchFromSleep(Time duration)
Switch from sleep mode.
Definition: wifi-phy-state-helper.cc:587
ns3::WifiPhyStateHelper::GetDelayUntilIdle
Time GetDelayUntilIdle(void) const
Return the time before the state is back to IDLE.
Definition: wifi-phy-state-helper.cc:151
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::WifiPhyStateHelper::m_startSleep
Time m_startSleep
start sleep
Definition: wifi-phy-state-helper.h:370
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::WifiPhyStateHelper::StateTracedCallback
void(* StateTracedCallback)(Time start, Time duration, WifiPhyState state)
TracedCallback signature for state changes.
Definition: wifi-phy-state-helper.h:253
ns3::WifiPhyStateHelper::SwitchFromRxAbort
void SwitchFromRxAbort(void)
Abort current reception.
Definition: wifi-phy-state-helper.cc:605
ns3::WifiPhyStateHelper::ListenersI
std::vector< WifiPhyListener * >::iterator ListenersI
typedef for a list of WifiPhyListeners iterator
Definition: wifi-phy-state-helper.h:293
ns3::WifiPhyStateHelper::DoSwitchFromRx
void DoSwitchFromRx(void)
Switch the state from RX.
Definition: wifi-phy-state-helper.cc:522
ns3::WifiPhyStateHelper::m_startCcaBusy
Time m_startCcaBusy
start CCA busy
Definition: wifi-phy-state-helper.h:368
wifi-phy-state.h
ns3::WifiPhyStateHelper::m_isOff
bool m_isOff
switched off
Definition: wifi-phy-state-helper.h:361
wifi-ppdu.h
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.
ns3::WifiPhyStateHelper::SwitchFromRxEndError
void SwitchFromRxEndError(Ptr< WifiPsdu > psdu, double snr)
Switch from RX after the reception failed.
Definition: wifi-phy-state-helper.cc:504
ns3::WifiPhyStateHelper::RxOkTracedCallback
void(* RxOkTracedCallback)(Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
TracedCallback signature for receive end OK event.
Definition: wifi-phy-state-helper.h:263
ns3::WifiPhyStateHelper::m_stateLogger
TracedCallback< Time, Time, WifiPhyState > m_stateLogger
The trace source fired when state is changed.
Definition: wifi-phy-state-helper.h:358
ns3::WifiPhyStateHelper::m_rxOkCallback
RxOkCallback m_rxOkCallback
receive OK callback
Definition: wifi-phy-state-helper.h:377
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::WifiPhyStateHelper::m_endCcaBusy
Time m_endCcaBusy
end CCA busy
Definition: wifi-phy-state-helper.h:364
ns3::WifiPhyStateHelper::SwitchToTx
void SwitchToTx(Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, WifiTxVector txVector)
Switch state to TX for the given duration.
Definition: wifi-phy-state-helper.cc:358
ns3::WifiPhyStateHelper::m_previousStateChangeTime
Time m_previousStateChangeTime
previous state change time
Definition: wifi-phy-state-helper.h:371
ns3::WifiPhyStateHelper::NotifySleep
void NotifySleep(void)
Notify all WifiPhyListener that we are going to sleep.
Definition: wifi-phy-state-helper.cc:289
WifiPhyState
WifiPhyState
The state of the PHY layer.
Definition: wifi-phy-state.h:32
ns3::WifiPreamble
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-phy-common.h:63
ns3::WifiPhyStateHelper::IsStateOff
bool IsStateOff(void) const
Check whether the current state is OFF.
Definition: wifi-phy-state-helper.cc:145
ns3::WifiPhyStateHelper::Listeners
std::vector< WifiPhyListener * > Listeners
typedef for a list of WifiPhyListeners
Definition: wifi-phy-state-helper.h:289
ns3::WifiPhyStateHelper::NotifyOn
void NotifyOn(void)
Notify all WifiPhyListener that we are going to switch on.
Definition: wifi-phy-state-helper.cc:319
ns3::RxSignalInfo
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:67
ns3::WifiPhyStateHelper::NotifyMaybeCcaBusyStart
void NotifyMaybeCcaBusyStart(Time duration)
Notify all WifiPhyListener that the CCA has started for the given duration.
Definition: wifi-phy-state-helper.cc:269
ns3::WifiPhyStateHelper::NotifyRxStart
void NotifyRxStart(Time duration)
Notify all WifiPhyListener that the reception has started for the given duration.
Definition: wifi-phy-state-helper.cc:239
ns3::WifiPhyStateHelper::SwitchFromRxEndOk
void SwitchFromRxEndOk(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, uint16_t staId, std::vector< bool > statusPerMpdu)
Switch from RX after the reception was successful.
Definition: wifi-phy-state-helper.cc:483
ns3::WifiPhyStateHelper::IsStateTx
bool IsStateTx(void) const
Check whether the current state is TX.
Definition: wifi-phy-state-helper.cc:127
ns3::WifiPhyStateHelper::SwitchToChannelSwitching
void SwitchToChannelSwitching(Time switchingDuration)
Switch state to channel switching for the given duration.
Definition: wifi-phy-state-helper.cc:430
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::RxErrorCallback
Callback< void, Ptr< WifiPsdu > > RxErrorCallback
Callback if PSDU unsuccessfully received.
Definition: wifi-phy-state-helper.h:58
ns3::WifiPhyStateHelper::NotifyWakeup
void NotifyWakeup(void)
Notify all WifiPhyListener that we woke up.
Definition: wifi-phy-state-helper.cc:309
ns3::WifiPhyStateHelper::WifiPhyStateHelper
WifiPhyStateHelper()
Definition: wifi-phy-state-helper.cc:63
ns3::WifiPhyStateHelper::ContinueRxNextMpdu
void ContinueRxNextMpdu(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector)
Continue RX after the reception of an MPDU in an A-MPDU was successful.
Definition: wifi-phy-state-helper.cc:472
ns3::WifiPhyStateHelper::m_startRx
Time m_startRx
start receive
Definition: wifi-phy-state-helper.h:367
ns3::WifiPhyStateHelper::GetLastRxStartTime
Time GetLastRxStartTime(void) const
Return the time the last RX start.
Definition: wifi-phy-state-helper.cc:184
ns3::WifiPhyStateHelper::IsStateRx
bool IsStateRx(void) const
Check whether the current state is RX.
Definition: wifi-phy-state-helper.cc:121
ns3::WifiPhyStateHelper::NotifyRxEndError
void NotifyRxEndError(void)
Notify all WifiPhyListener that the reception was not successful.
Definition: wifi-phy-state-helper.cc:259
ns3::WifiPhyStateHelper::GetLastRxEndTime
Time GetLastRxEndTime(void) const
Return the time the last RX end.
Definition: wifi-phy-state-helper.cc:190
ns3::WifiPhyStateHelper::m_endSwitching
Time m_endSwitching
end switching
Definition: wifi-phy-state-helper.h:365
ns3::WifiPhyStateHelper::TxTracedCallback
void(* TxTracedCallback)(Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t power)
TracedCallback signature for transmit event.
Definition: wifi-phy-state-helper.h:281
ns3::WifiPhyStateHelper::m_rxErrorCallback
RxErrorCallback m_rxErrorCallback
receive error callback
Definition: wifi-phy-state-helper.h:378
ns3::WifiPhyStateHelper::NotifySwitchingStart
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay.
Definition: wifi-phy-state-helper.cc:279
ns3::WifiPhyStateHelper::m_endTx
Time m_endTx
end transmit
Definition: wifi-phy-state-helper.h:362