/usr/include/ns3.27/ns3/wifi-phy-state-helper.h is in libns3-dev 3.27+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef WIFI_PHY_STATE_HELPER_H
#define WIFI_PHY_STATE_HELPER_H
#include "wifi-phy.h"
#include "ns3/object.h"
namespace ns3 {
/**
* \ingroup wifi
*
* This objects implements the PHY state machine of the Wifi device.
*/
class WifiPhyStateHelper : public Object
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
WifiPhyStateHelper ();
/**
* Set a callback for a successful reception.
*
* \param callback
*/
void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
/**
* Set a callback for a failed reception.
*
* \param callback
*/
void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
/**
* Register WifiPhyListener to this WifiPhyStateHelper.
*
* \param listener
*/
void RegisterListener (WifiPhyListener *listener);
/**
* Remove WifiPhyListener from this WifiPhyStateHelper.
*
* \param listener
*/
void UnregisterListener (WifiPhyListener *listener);
/**
* Return the current state of WifiPhy.
*
* \return the current state of WifiPhy
*/
WifiPhy::State GetState (void) const;
/**
* Check whether the current state is CCA busy.
*
* \return true if the current state is CCA busy, false otherwise
*/
bool IsStateCcaBusy (void) const;
/**
* Check whether the current state is IDLE.
*
* \return true if the current state is IDLE, false otherwise
*/
bool IsStateIdle (void) const;
/**
* Check whether the current state is not IDLE.
*
* \return true if the current state is not IDLE, false otherwise
*/
bool IsStateBusy (void) const;
/**
* Check whether the current state is RX.
*
* \return true if the current state is RX, false otherwise
*/
bool IsStateRx (void) const;
/**
* Check whether the current state is TX.
*
* \return true if the current state is TX, false otherwise
*/
bool IsStateTx (void) const;
/**
* Check whether the current state is SWITCHING.
*
* \return true if the current state is SWITCHING, false otherwise
*/
bool IsStateSwitching (void) const;
/**
* Check whether the current state is SLEEP.
*
* \return true if the current state is SLEEP, false otherwise
*/
bool IsStateSleep (void) const;
/**
* Return the elapsed time of the current state.
*
* \return the elapsed time of the current state
*/
Time GetStateDuration (void) const;
/**
* Return the time before the state is back to IDLE.
*
* \return the delay before the state is back to IDLE
*/
Time GetDelayUntilIdle (void) const;
/**
* Return the time the last RX start.
*
* \return the time the last RX start.
*/
Time GetLastRxStartTime (void) const;
/**
* Switch state to TX for the given duration.
*
* \param txDuration the duration of the TX
* \param packet the packet
* \param txPowerDbm the nominal tx power in dBm
* \param txVector the tx vector of the packet
*/
void SwitchToTx (Time txDuration, Ptr<const Packet> packet, double txPowerDbm, WifiTxVector txVector);
/**
* Switch state to RX for the given duration.
*
* \param rxDuration the duration of the RX
*/
void SwitchToRx (Time rxDuration);
/**
* Switch state to channel switching for the given duration.
*
* \param switchingDuration the duration of required to switch the channel
*/
void SwitchToChannelSwitching (Time switchingDuration);
/**
* Switch from RX after the reception was successful.
*
* \param packet the successfully received packet
* \param snr the SNR of the received packet
* \param txVector TXVECTOR of the packet
*/
void SwitchFromRxEndOk (Ptr<Packet> packet, double snr, WifiTxVector txVector);
/**
* Switch from RX after the reception failed.
*
* \param packet the packet that we failed to received
* \param snr the SNR of the received packet
*/
void SwitchFromRxEndError (Ptr<Packet> packet, double snr);
/**
* Switch to CCA busy.
*
* \param duration the duration of CCA busy state
*/
void SwitchMaybeToCcaBusy (Time duration);
/**
* Switch to sleep mode.
*/
void SwitchToSleep (void);
/**
* Switch from sleep mode.
*
* \param duration the duration of CCA busy state
*/
void SwitchFromSleep (Time duration);
/**
* Abort current reception
*/
void SwitchFromRxAbort (void);
/**
* TracedCallback signature for state changes.
*
* \param [in] start Time when the \p state started.
* \param [in] duration Amount of time we've been in (or will be in)
* the \p state.
* \param [in] state The state.
*/
typedef void (* StateTracedCallback)(Time start, Time duration, WifiPhy::State state);
/**
* TracedCallback signature for receive end ok event.
*
* \param [in] packet The received packet.
* \param [in] snr The SNR of the received packet.
* \param [in] mode The transmission mode of the packet.
* \param [in] preamble The preamble of the packet.
*/
typedef void (* RxOkTracedCallback)(Ptr<const Packet> packet, double snr, WifiMode mode, WifiPreamble preamble);
/**
* TracedCallback signature for receive end error event.
*
* \param [in] packet The received packet.
* \param [in] snr The SNR of the received packet.
*/
typedef void (* RxEndErrorTracedCallback)(Ptr<const Packet> packet, double snr);
/**
* TracedCallback signature for transmit event.
*
* \param [in] packet The received packet.
* \param [in] mode The transmission mode of the packet.
* \param [in] preamble The preamble of the packet.
* \param [in] power The transmit power level.
*/
typedef void (* TxTracedCallback)(Ptr<const Packet> packet, WifiMode mode,
WifiPreamble preamble, uint8_t power);
private:
/**
* typedef for a list of WifiPhyListeners
*/
typedef std::vector<WifiPhyListener *> Listeners;
/**
* typedef for a list of WifiPhyListeners iterator
*/
typedef std::vector<WifiPhyListener *>::iterator ListenersI;
/**
* Log the ideal and CCA states.
*/
void LogPreviousIdleAndCcaBusyStates (void);
/**
* Notify all WifiPhyListener that the transmission has started for the given duration.
*
* \param duration the duration of the transmission
* \param txPowerDbm the nominal tx power in dBm
*/
void NotifyTxStart (Time duration, double txPowerDbm);
/**
* Notify all WifiPhyListener that the reception has started for the given duration.
*
* \param duration the duration of the reception
*/
void NotifyRxStart (Time duration);
/**
* Notify all WifiPhyListener that the reception was successful.
*/
void NotifyRxEndOk (void);
/**
* Notify all WifiPhyListener that the reception was not successful.
*/
void NotifyRxEndError (void);
/**
* Notify all WifiPhyListener that the CCA has started for the given duration.
*
* \param duration the duration of the CCA state
*/
void NotifyMaybeCcaBusyStart (Time duration);
/**
* Notify all WifiPhyListener that we are switching channel with the given channel
* switching delay.
*
* \param duration the delay to switch the channel
*/
void NotifySwitchingStart (Time duration);
/**
* Notify all WifiPhyListener that we are going to sleep
*/
void NotifySleep (void);
/**
* Notify all WifiPhyListener that we woke up
*/
void NotifyWakeup (void);
/**
* Switch the state from RX.
*/
void DoSwitchFromRx (void);
/**
* The trace source fired when state is changed.
*/
TracedCallback<Time, Time, WifiPhy::State> m_stateLogger;
bool m_rxing; ///< receiving
bool m_sleeping; ///< sleeping
Time m_endTx; ///< end transmit
Time m_endRx; ///< end receive
Time m_endCcaBusy; ///< endn CCA busy
Time m_endSwitching; ///< end switching
Time m_startTx; ///< start transmit
Time m_startRx; ///< start receive
Time m_startCcaBusy; ///< start CCA busy
Time m_startSwitching; ///< start switching
Time m_startSleep; ///< start sleep
Time m_previousStateChangeTime; ///< previous state change time
Listeners m_listeners; ///< listeners
TracedCallback<Ptr<const Packet>, double, WifiMode, WifiPreamble> m_rxOkTrace; ///< receive OK trace callback
TracedCallback<Ptr<const Packet>, double> m_rxErrorTrace; ///< receive error trace callback
TracedCallback<Ptr<const Packet>, WifiMode, WifiPreamble, uint8_t> m_txTrace; ///< transmit trace callback
WifiPhy::RxOkCallback m_rxOkCallback; ///< receive OK callback
WifiPhy::RxErrorCallback m_rxErrorCallback; ///< receive error callback
};
} //namespace ns3
#endif /* WIFI_PHY_STATE_HELPER_H */
|