OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
21 #ifndef WIFI_PHY_STATE_HELPER_H | 21 #ifndef WIFI_PHY_STATE_HELPER_H |
22 #define WIFI_PHY_STATE_HELPER_H | 22 #define WIFI_PHY_STATE_HELPER_H |
23 | 23 |
24 #include "wifi-phy.h" | 24 #include "wifi-phy-state.h" |
25 #include "ns3/object.h" | 25 #include "ns3/callback.h" |
| 26 #include "ns3/traced-callback.h" |
| 27 #include "ns3/packet.h" |
| 28 #include "wifi-phy-listener.h" |
| 29 #include "wifi-tx-vector.h" |
26 | 30 |
27 namespace ns3 { | 31 namespace ns3 { |
28 | 32 |
29 /** | 33 /** |
30 * \ingroup wifi | 34 * \ingroup wifi |
31 * | 35 * |
32 * This objects implements the PHY state machine of the Wifi device. | 36 * This objects implements the PHY state machine of the Wifi device. |
33 */ | 37 */ |
34 class WifiPhyStateHelper : public Object | 38 class WifiPhyStateHelper : public Object |
35 { | 39 { |
36 public: | 40 public: |
37 /** | 41 /** |
| 42 * arg1: packet received successfully |
| 43 * arg2: snr of packet |
| 44 * arg3: TXVECTOR of packet |
| 45 * arg4: type of preamble used for packet. |
| 46 */ |
| 47 typedef Callback<void, Ptr<Packet>, double, WifiTxVector> RxOkCallback; |
| 48 /** |
| 49 * arg1: packet received unsuccessfully |
| 50 * arg2: snr of packet |
| 51 */ |
| 52 typedef Callback<void, Ptr<Packet>, double> RxErrorCallback; |
| 53 |
| 54 /** |
38 * \brief Get the type ID. | 55 * \brief Get the type ID. |
39 * \return the object TypeId | 56 * \return the object TypeId |
40 */ | 57 */ |
41 static TypeId GetTypeId (void); | 58 static TypeId GetTypeId (void); |
42 | 59 |
43 WifiPhyStateHelper (); | 60 WifiPhyStateHelper (); |
44 | 61 |
45 /** | 62 /** |
46 * Set a callback for a successful reception. | 63 * Set a callback for a successful reception. |
47 * | 64 * |
48 * \param callback | 65 * \param callback |
49 */ | 66 */ |
50 void SetReceiveOkCallback (WifiPhy::RxOkCallback callback); | 67 void SetReceiveOkCallback (RxOkCallback callback); |
51 /** | 68 /** |
52 * Set a callback for a failed reception. | 69 * Set a callback for a failed reception. |
53 * | 70 * |
54 * \param callback | 71 * \param callback |
55 */ | 72 */ |
56 void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback); | 73 void SetReceiveErrorCallback (RxErrorCallback callback); |
57 /** | 74 /** |
58 * Register WifiPhyListener to this WifiPhyStateHelper. | 75 * Register WifiPhyListener to this WifiPhyStateHelper. |
59 * | 76 * |
60 * \param listener | 77 * \param listener |
61 */ | 78 */ |
62 void RegisterListener (WifiPhyListener *listener); | 79 void RegisterListener (WifiPhyListener *listener); |
63 /** | 80 /** |
64 * Remove WifiPhyListener from this WifiPhyStateHelper. | 81 * Remove WifiPhyListener from this WifiPhyStateHelper. |
65 * | 82 * |
66 * \param listener | 83 * \param listener |
67 */ | 84 */ |
68 void UnregisterListener (WifiPhyListener *listener); | 85 void UnregisterListener (WifiPhyListener *listener); |
69 /** | 86 /** |
70 * Return the current state of WifiPhy. | 87 * Return the current state of WifiPhy. |
71 * | 88 * |
72 * \return the current state of WifiPhy | 89 * \return the current state of WifiPhy |
73 */ | 90 */ |
74 WifiPhy::State GetState (void) const; | 91 WifiPhyState GetState (void) const; |
75 /** | 92 /** |
76 * Check whether the current state is CCA busy. | 93 * Check whether the current state is CCA busy. |
77 * | 94 * |
78 * \return true if the current state is CCA busy, false otherwise | 95 * \return true if the current state is CCA busy, false otherwise |
79 */ | 96 */ |
80 bool IsStateCcaBusy (void) const; | 97 bool IsStateCcaBusy (void) const; |
81 /** | 98 /** |
82 * Check whether the current state is IDLE. | 99 * Check whether the current state is IDLE. |
83 * | 100 * |
84 * \return true if the current state is IDLE, false otherwise | 101 * \return true if the current state is IDLE, false otherwise |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void SwitchFromOff (Time duration); | 224 void SwitchFromOff (Time duration); |
208 | 225 |
209 /** | 226 /** |
210 * TracedCallback signature for state changes. | 227 * TracedCallback signature for state changes. |
211 * | 228 * |
212 * \param [in] start Time when the \p state started. | 229 * \param [in] start Time when the \p state started. |
213 * \param [in] duration Amount of time we've been in (or will be in) | 230 * \param [in] duration Amount of time we've been in (or will be in) |
214 * the \p state. | 231 * the \p state. |
215 * \param [in] state The state. | 232 * \param [in] state The state. |
216 */ | 233 */ |
217 typedef void (* StateTracedCallback)(Time start, Time duration, WifiPhy::State
state); | 234 typedef void (* StateTracedCallback)(Time start, Time duration, WifiPhyState s
tate); |
218 | 235 |
219 /** | 236 /** |
220 * TracedCallback signature for receive end ok event. | 237 * TracedCallback signature for receive end ok event. |
221 * | 238 * |
222 * \param [in] packet The received packet. | 239 * \param [in] packet The received packet. |
223 * \param [in] snr The SNR of the received packet. | 240 * \param [in] snr The SNR of the received packet. |
224 * \param [in] mode The transmission mode of the packet. | 241 * \param [in] mode The transmission mode of the packet. |
225 * \param [in] preamble The preamble of the packet. | 242 * \param [in] preamble The preamble of the packet. |
226 */ | 243 */ |
227 typedef void (* RxOkTracedCallback)(Ptr<const Packet> packet, double snr, Wifi
Mode mode, WifiPreamble preamble); | 244 typedef void (* RxOkTracedCallback)(Ptr<const Packet> packet, double snr, Wifi
Mode mode, WifiPreamble preamble); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 */ | 329 */ |
313 void DoSwitchFromRx (void); | 330 void DoSwitchFromRx (void); |
314 /** | 331 /** |
315 * Notify all WifiPhyListener that we are going to switch on | 332 * Notify all WifiPhyListener that we are going to switch on |
316 */ | 333 */ |
317 void NotifyOn (void); | 334 void NotifyOn (void); |
318 | 335 |
319 /** | 336 /** |
320 * The trace source fired when state is changed. | 337 * The trace source fired when state is changed. |
321 */ | 338 */ |
322 TracedCallback<Time, Time, WifiPhy::State> m_stateLogger; | 339 TracedCallback<Time, Time, WifiPhyState> m_stateLogger; |
323 | 340 |
324 bool m_rxing; ///< receiving | 341 bool m_rxing; ///< receiving |
325 bool m_sleeping; ///< sleeping | 342 bool m_sleeping; ///< sleeping |
326 bool m_isOff; ///< switched off | 343 bool m_isOff; ///< switched off |
327 Time m_endTx; ///< end transmit | 344 Time m_endTx; ///< end transmit |
328 Time m_endRx; ///< end receive | 345 Time m_endRx; ///< end receive |
329 Time m_endCcaBusy; ///< endn CCA busy | 346 Time m_endCcaBusy; ///< endn CCA busy |
330 Time m_endSwitching; ///< end switching | 347 Time m_endSwitching; ///< end switching |
331 Time m_startTx; ///< start transmit | 348 Time m_startTx; ///< start transmit |
332 Time m_startRx; ///< start receive | 349 Time m_startRx; ///< start receive |
333 Time m_startCcaBusy; ///< start CCA busy | 350 Time m_startCcaBusy; ///< start CCA busy |
334 Time m_startSwitching; ///< start switching | 351 Time m_startSwitching; ///< start switching |
335 Time m_startSleep; ///< start sleep | 352 Time m_startSleep; ///< start sleep |
336 Time m_previousStateChangeTime; ///< previous state change time | 353 Time m_previousStateChangeTime; ///< previous state change time |
337 | 354 |
338 Listeners m_listeners; ///< listeners | 355 Listeners m_listeners; ///< listeners |
339 TracedCallback<Ptr<const Packet>, double, WifiMode, WifiPreamble> m_rxOkTrace;
///< receive OK trace callback | 356 TracedCallback<Ptr<const Packet>, double, WifiMode, WifiPreamble> m_rxOkTrace;
///< receive OK trace callback |
340 TracedCallback<Ptr<const Packet>, double> m_rxErrorTrace; ///< receive error t
race callback | 357 TracedCallback<Ptr<const Packet>, double> m_rxErrorTrace; ///< receive error t
race callback |
341 TracedCallback<Ptr<const Packet>, WifiMode, WifiPreamble, uint8_t> m_txTrace;
///< transmit trace callback | 358 TracedCallback<Ptr<const Packet>, WifiMode, WifiPreamble, uint8_t> m_txTrace;
///< transmit trace callback |
342 WifiPhy::RxOkCallback m_rxOkCallback; ///< receive OK callback | 359 RxOkCallback m_rxOkCallback; ///< receive OK callback |
343 WifiPhy::RxErrorCallback m_rxErrorCallback; ///< receive error callback | 360 RxErrorCallback m_rxErrorCallback; ///< receive error callback |
344 }; | 361 }; |
345 | 362 |
346 } //namespace ns3 | 363 } //namespace ns3 |
347 | 364 |
348 #endif /* WIFI_PHY_STATE_HELPER_H */ | 365 #endif /* WIFI_PHY_STATE_HELPER_H */ |
OLD | NEW |