src/wifi/model/wifi-phy-state-helper.h
author Stefano Avallone <stefano.avallone@unina.it>
Fri, 05 Sep 2014 16:33:57 -0700
changeset 10883 d919e7194e23
parent 10483 e3a02ed14587
child 11086 65914b1ed5b3
permissions -rw-r--r--
add support for a Wifi sleep mode
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7141
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3898
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     2
/*
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     4
 *
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
3898
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     7
 * published by the Free Software Foundation;
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     8
 *
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    12
 * GNU General Public License for more details.
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    13
 *
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    14
 * You should have received a copy of the GNU General Public License
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    15
 * along with this program; if not, write to the Free Software
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    17
 *
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
0d0517e7a557 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3897
diff changeset
    19
 */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#ifndef WIFI_PHY_STATE_HELPER_H
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#define WIFI_PHY_STATE_HELPER_H
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include "wifi-phy.h"
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/traced-callback.h"
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3898
diff changeset
    25
#include "ns3/object.h"
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <vector>
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
namespace ns3 {
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
7139
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    30
/**
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    31
 * \ingroup wifi
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    32
 *
7139
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    33
 * This objects implements the PHY state machine of the Wifi device.
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    34
 */
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3898
diff changeset
    35
class WifiPhyStateHelper : public Object
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
{
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
public:
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3898
diff changeset
    38
  static TypeId GetTypeId (void);
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3898
diff changeset
    39
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
  WifiPhyStateHelper ();
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    42
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    43
   * Set a callback for a successful reception.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    44
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    45
   * \param callback
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    46
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
    47
  void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    48
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    49
   * Set a callback for a failed reception.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    50
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    51
   * \param callback
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    52
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
    53
  void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    54
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    55
   * Register WifiPhyListener to this WifiPhyStateHelper.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    56
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    57
   * \param listener
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    58
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
  void RegisterListener (WifiPhyListener *listener);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    60
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    61
   * Return the current state of WifiPhy.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    62
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    63
   * \return the current state of WifiPhy
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    64
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
  enum WifiPhy::State GetState (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    66
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    67
   * Check whether the current state is CCA busy.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    68
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    69
   * \return true if the current state is CCA busy, false otherwise
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    70
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  bool IsStateCcaBusy (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    72
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    73
   * Check whether the current state is IDLE.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    74
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    75
   * \return true if the current state is IDLE, false otherwise
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    76
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  bool IsStateIdle (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    78
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    79
   * Check whether the current state is not IDLE.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    80
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    81
   * \return true if the current state is not IDLE, false otherwise
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    82
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
  bool IsStateBusy (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    84
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    85
   * Check whether the current state is RX.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    86
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    87
   * \return true if the current state is RX, false otherwise
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    88
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
    89
  bool IsStateRx (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    90
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    91
   * Check whether the current state is TX.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    92
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    93
   * \return true if the current state is TX, false otherwise
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    94
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
  bool IsStateTx (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    96
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    97
   * Check whether the current state is SWITCHING.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    98
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    99
   * \return true if the current state is SWITCHING, false otherwise
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   100
   */
5189
8fcdf87a790a Channel switching support for Wifi
Ramon Bauza
parents: 3905
diff changeset
   101
  bool IsStateSwitching (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   102
  /**
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   103
   * Check whether the current state is SLEEP.
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   104
   *
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   105
   * \return true if the current state is SLEEP, false otherwise
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   106
   */
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   107
  bool IsStateSleep (void);
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   108
  /**
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   109
   * Return the elapsed time of the current state.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   110
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   111
   * \return the elapsed time of the current state
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   112
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  Time GetStateDuration (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   114
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   115
   * Return the time before the state is back to IDLE.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   116
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   117
   * \return the delay before the state is back to IDLE
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   118
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  Time GetDelayUntilIdle (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   120
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   121
   * Return the time the last RX start.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   122
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   123
   * \return the time the last RX start.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   124
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
  Time GetLastRxStartTime (void) const;
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   127
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   128
   * Switch state to TX for the given duration.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   129
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   130
   * \param txDuration the duration of the TX
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   131
   * \param packet the packet
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   132
   * \param txPowerDbm the nominal tx power in dBm
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   133
   * \param txVector the tx vector of the packet
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   134
   * \param preamble the preamble of the packet
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   135
   */
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   136
  void SwitchToTx (Time txDuration, Ptr<const Packet> packet, double txPowerDbm, WifiTxVector txVector, WifiPreamble preamble);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   137
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   138
   * Switch state to RX for the given duration.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   139
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   140
   * \param rxDuration the duration of the RX
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   141
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   142
  void SwitchToRx (Time rxDuration);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   143
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   144
   * Switch state to channel switching for the given duration.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   145
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   146
   * \param switchingDuration the duration of required to switch the channel
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   147
   */
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   148
  void SwitchToChannelSwitching (Time switchingDuration);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   149
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   150
   * Switch from RX after the reception was successful.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   151
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   152
   * \param packet the successfully received packet
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   153
   * \param snr the SNR of the received packet
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   154
   * \param mode the transmission mode of the packet
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   155
   * \param preamble the preamble of the received packet
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   156
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   157
  void SwitchFromRxEndOk (Ptr<Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   158
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   159
   * Switch from RX after the reception failed.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   160
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   161
   * \param packet the packet that we failed to received
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   162
   * \param snr the SNR of the received packet
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   163
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   164
  void SwitchFromRxEndError (Ptr<const Packet> packet, double snr);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   165
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   166
   * Switch to CCA busy.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   167
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   168
   * \param duration the duration of CCA busy state
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   169
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
  void SwitchMaybeToCcaBusy (Time duration);
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   171
  /**
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   172
   * Switch to sleep mode.
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   173
   */
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   174
  void SwitchToSleep (void);
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   175
  /**
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   176
   * Switch from sleep mode.
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   177
   *
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   178
   * \param duration the duration of CCA busy state
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   179
   */
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   180
  void SwitchFromSleep (Time duration);
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3898
diff changeset
   182
  TracedCallback<Time,Time,enum WifiPhy::State> m_stateLogger;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
private:
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   184
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   185
   * typedef for a list of WifiPhyListeners
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   186
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
  typedef std::vector<WifiPhyListener *> Listeners;
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   189
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   190
   * Log the ideal and CCA states.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   191
   */
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
  void LogPreviousIdleAndCcaBusyStates (void);
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   194
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   195
   * Notify all WifiPhyListener that the transmission has started for the given duration.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   196
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   197
   * \param duration the duration of the transmission
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   198
   * \param txPowerDbm the nominal tx power in dBm
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   199
   */
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   200
  void NotifyTxStart (Time duration, double txPowerDbm);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   201
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   202
   * Notify all WifiPhyListener that the reception has started for the given duration.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   203
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   204
   * \param duration the duration of the reception
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   205
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   206
  void NotifyRxStart (Time duration);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   207
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   208
   * Notify all WifiPhyListener that the reception was successful.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   209
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   210
  void NotifyRxEndOk (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   211
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   212
   * Notify all WifiPhyListener that the reception was not successful.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   213
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   214
  void NotifyRxEndError (void);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   215
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   216
   * Notify all WifiPhyListener that the CCA has started for the given duration.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   217
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   218
   * \param duration the duration of the CCA state
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   219
   */
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3900
diff changeset
   220
  void NotifyMaybeCcaBusyStart (Time duration);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   221
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   222
   * Notify all WifiPhyListener that we are switching channel with the given channel
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   223
   * switching delay.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   224
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   225
   * \param duration the delay to switch the channel
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   226
   */
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   227
  void NotifySwitchingStart (Time duration);
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   228
  /**
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   229
   * Notify all WifiPhyListener that we are going to sleep
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   230
   */
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   231
  void NotifySleep (void);
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   232
  /**
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   233
   * Notify all WifiPhyListener that we woke up
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   234
   */
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   235
  void NotifyWakeup (void);
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   236
  /**
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   237
   * Switch the state from RX.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   238
   */
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   239
  void DoSwitchFromRx (void);
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   241
  bool m_rxing;
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   242
  bool m_sleeping;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
  Time m_endTx;
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   244
  Time m_endRx;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
  Time m_endCcaBusy;
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   246
  Time m_endSwitching;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
  Time m_startTx;
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   248
  Time m_startRx;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
  Time m_startCcaBusy;
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   250
  Time m_startSwitching;
10883
d919e7194e23 add support for a Wifi sleep mode
Stefano Avallone <stefano.avallone@unina.it>
parents: 10483
diff changeset
   251
  Time m_startSleep;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
  Time m_previousStateChangeTime;
3900
1687492ff059 re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3898
diff changeset
   253
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
  Listeners m_listeners;
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
  TracedCallback<Ptr<const Packet>, double, WifiMode, enum WifiPreamble> m_rxOkTrace;
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
  TracedCallback<Ptr<const Packet>, double> m_rxErrorTrace;
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
  TracedCallback<Ptr<const Packet>,WifiMode,WifiPreamble,uint8_t> m_txTrace;
5820
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   258
  WifiPhy::RxOkCallback m_rxOkCallback;
1c02054740eb Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
Timo Bingmann <tbns@idlebox.net>
parents: 5819
diff changeset
   259
  WifiPhy::RxErrorCallback m_rxErrorCallback;
3897
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
};
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
} // namespace ns3
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
44645cec42f2 split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
#endif /* WIFI_PHY_STATE_HELPER_H */