src/devices/wifi/minstrel-wifi-manager.cc
author Quincy Tse <quincy.tse@gmail.com>
Tue, 26 Oct 2010 14:16:10 +0200
changeset 6645 b89ac19713c6
parent 6337 92c95748a915
permissions -rw-r--r--
closes bug 993
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     2
/*
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     3
 * Copyright (c) 2009 Duy Nguyen 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     4
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     8
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    13
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    17
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    18
 * Author: Duy Nguyen <duy@soe.ucsc.edu>
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    19
 * 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    20
 * Some Comments: 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    21
 * 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    22
 * 1) Segment Size is declared for completeness but not used  because it has 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    23
 *    to do more with the requirement of the specific hardware.
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    24
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    25
 * 2) By default, Minstrel applies the multi-rate retry(the core of Minstrel 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    26
 *    algorithm). Otherwise, please use ConstantRateWifiManager instead.
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    27
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    28
 * http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/minstrel
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    29
 */
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    30
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    31
#include "minstrel-wifi-manager.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    32
#include "wifi-phy.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    33
#include "ns3/random-variable.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    34
#include "ns3/simulator.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    35
#include "ns3/log.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    36
#include "ns3/uinteger.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    37
#include "ns3/double.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    38
#include "ns3/wifi-mac.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    39
#include "ns3/assert.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    40
#include <vector>
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    41
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    42
NS_LOG_COMPONENT_DEFINE ("MinstrelWifiManager");
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    43
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    44
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    45
namespace ns3 {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    46
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    47
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    48
struct MinstrelWifiRemoteStation : public WifiRemoteStation
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    49
{
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    50
  Time m_nextStatsUpdate;  ///< 10 times every second
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    51
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    52
  /**
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    53
   * To keep track of the current position in the our random sample table
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    54
   * going row by row from 1st column until the 10th column(Minstrel defines 10)
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    55
   * then we wrap back to the row 1 col 1.
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    56
   * note: there are many other ways to do this.
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    57
   */
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    58
  uint32_t m_col, m_index;							
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    59
  uint32_t m_maxTpRate;  ///< the current throughput rate 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    60
  uint32_t m_maxTpRate2;  ///< second highest throughput rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    61
  uint32_t m_maxProbRate;  ///< rate with highest prob of success
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    62
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    63
  int m_packetCount;  ///< total number of packets as of now
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    64
  int m_sampleCount;  ///< how many packets we have sample so far
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    65
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    66
  bool m_isSampling;  ///< a flag to indicate we are currently sampling
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    67
  uint32_t m_sampleRate;  ///< current sample rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    68
  bool 	m_sampleRateSlower;  ///< a flag to indicate sample rate is slower
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    69
  uint32_t m_currentRate;  ///< current rate we are using
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    70
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    71
  uint32_t m_shortRetry;  ///< short retries such as control packts
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    72
  uint32_t m_longRetry;  ///< long retries such as data packets
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    73
  uint32_t m_retry;  ///< total retries short + long
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    74
  uint32_t m_err;  ///< retry errors
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    75
  uint32_t m_txrate;  ///< current transmit rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    76
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    77
  bool m_initialized;  ///< for initializing tables
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    78
};
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    79
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    80
NS_OBJECT_ENSURE_REGISTERED (MinstrelWifiManager);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    81
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    82
TypeId
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    83
MinstrelWifiManager::GetTypeId (void)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    84
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    85
  static TypeId tid = TypeId ("ns3::MinstrelWifiManager")
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    86
    .SetParent<WifiRemoteStationManager> ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    87
    .AddConstructor<MinstrelWifiManager> ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    88
    .AddAttribute ("UpdateStatistics",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    89
                   "The interval between updating statistics table ",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    90
                   TimeValue (Seconds (0.1)),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    91
                   MakeTimeAccessor (&MinstrelWifiManager::m_updateStats),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    92
                   MakeTimeChecker ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    93
    .AddAttribute ("LookAroundRate", 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    94
                   "the percentage to try other rates",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    95
                   DoubleValue (10),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    96
                   MakeDoubleAccessor (&MinstrelWifiManager::m_lookAroundRate),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    97
                   MakeDoubleChecker<double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    98
    .AddAttribute ("EWMA", 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    99
                   "EWMA level",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   100
                   DoubleValue (75),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   101
                   MakeDoubleAccessor (&MinstrelWifiManager::m_ewmaLevel),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   102
                   MakeDoubleChecker<double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   103
    .AddAttribute ("SegmentSize",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   104
                   "The largest allowable segment size packet",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   105
                   DoubleValue (6000),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   106
                   MakeDoubleAccessor (&MinstrelWifiManager::m_segmentSize),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   107
                   MakeDoubleChecker <double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   108
    .AddAttribute ("SampleColumn",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   109
                   "The number of columns used for sampling",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   110
                   DoubleValue (10),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   111
                   MakeDoubleAccessor (&MinstrelWifiManager::m_sampleCol),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   112
                   MakeDoubleChecker <double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   113
    .AddAttribute ("PacketLength",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   114
                   "The packet length used for calculating mode TxTime",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   115
                   DoubleValue (1200),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   116
                   MakeDoubleAccessor (&MinstrelWifiManager::m_pktLen),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   117
                   MakeDoubleChecker <double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   118
    ;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   119
  return tid;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   120
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   121
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   122
MinstrelWifiManager::MinstrelWifiManager ()
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   123
{
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   124
  m_nsupported = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   125
}
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   126
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   127
MinstrelWifiManager::~MinstrelWifiManager ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   128
{}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   129
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   130
void
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   131
MinstrelWifiManager::SetupPhy (Ptr<WifiPhy> phy)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   132
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   133
  uint32_t nModes = phy->GetNModes ();
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   134
  for (uint32_t i = 0; i < nModes; i++)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   135
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   136
      WifiMode mode = phy->GetMode (i);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   137
      AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, mode, WIFI_PREAMBLE_LONG));
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   138
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   139
  WifiRemoteStationManager::SetupPhy (phy);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   140
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   141
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   142
Time
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   143
MinstrelWifiManager::GetCalcTxTime (WifiMode mode) const
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   144
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   145
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   146
  for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (); i++)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   147
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   148
      if (mode == i->second)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   149
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   150
          return i->first;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   151
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   152
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   153
  NS_ASSERT (false);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   154
  return Seconds (0);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   155
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   156
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   157
void
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   158
MinstrelWifiManager::AddCalcTxTime (WifiMode mode, Time t)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   159
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   160
   m_calcTxTime.push_back (std::make_pair (t, mode));
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   161
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   162
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   163
WifiRemoteStation *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   164
MinstrelWifiManager::DoCreateStation (void) const
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   165
{
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   166
  MinstrelWifiRemoteStation *station = new MinstrelWifiRemoteStation ();
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   167
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   168
  station->m_nextStatsUpdate = Simulator::Now () + m_updateStats;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   169
  station->m_col = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   170
  station->m_index = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   171
  station->m_maxTpRate = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   172
  station->m_maxTpRate2 = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   173
  station->m_maxProbRate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   174
  station->m_packetCount = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   175
  station->m_sampleCount = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   176
  station->m_isSampling = false; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   177
  station->m_sampleRate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   178
  station->m_sampleRateSlower = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   179
  station->m_currentRate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   180
  station->m_shortRetry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   181
  station->m_longRetry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   182
  station->m_retry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   183
  station->m_err = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   184
  station->m_txrate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   185
  station->m_initialized = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   186
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   187
  return station;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   188
}
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   189
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   190
void 
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   191
MinstrelWifiManager::CheckInit(MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   192
{
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   193
  if (!station->m_initialized && GetNSupported (station) > 1)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   194
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   195
      // Note: we appear to be doing late initialization of the table 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   196
      // to make sure that the set of supported rates has been initialized
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   197
      // before we perform our own initialization.
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   198
      m_nsupported = GetNSupported (station);
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   199
      m_minstrelTable = MinstrelRate(m_nsupported);
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   200
      m_sampleTable = SampleRate(m_nsupported, std::vector<uint32_t> (m_sampleCol));
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   201
      InitSampleTable (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   202
      RateInit (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   203
      station->m_initialized = true;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   204
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   205
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   206
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   207
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   208
MinstrelWifiManager::DoReportRxOk (WifiRemoteStation *st,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   209
                                   double rxSnr, WifiMode txMode)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   210
{
6079
e9b65f133d50 fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6065
diff changeset
   211
  NS_LOG_DEBUG("DoReportRxOk m_txrate=" << ((MinstrelWifiRemoteStation *)st)->m_txrate);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   212
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   213
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   214
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   215
MinstrelWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   216
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   217
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   218
  NS_LOG_DEBUG("DoReportRtsFailed m_txrate=" << station->m_txrate);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   219
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   220
  station->m_shortRetry++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   221
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   222
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   223
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   224
MinstrelWifiManager::DoReportRtsOk (WifiRemoteStation *st, double ctsSnr, WifiMode ctsMode, double rtsSnr)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   225
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   226
  NS_LOG_DEBUG ("self="<<st<<" rts ok");
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   227
}
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   228
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   229
void
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   230
MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   231
{
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   232
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   233
  UpdateRetry (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   234
  station->m_err++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   235
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   236
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   237
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   238
MinstrelWifiManager::DoReportDataFailed (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   239
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   240
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   241
  /**
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   242
   *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   243
   * Retry Chain table is implemented here
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   244
   *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   245
   * Try |         LOOKAROUND RATE              | NORMAL RATE
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   246
   *     | random < best    | random > best     |
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   247
   * --------------------------------------------------------------
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   248
   *  1  | Best throughput  | Random rate       | Best throughput
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   249
   *  2  | Random rate      | Best throughput   | Next best throughput
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   250
   *  3  | Best probability | Best probability  | Best probability
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   251
   *  4  | Lowest Baserate  | Lowest baserate   | Lowest baserate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   252
   *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   253
   * Note: For clarity, multiple blocks of if's and else's are used
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   254
   * After a failing 7 times, DoReportFinalDataFailed will be called
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   255
   */
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   256
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   257
  CheckInit(station);
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   258
  if (!station->m_initialized)
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   259
    {
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   260
      return;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   261
    }
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   262
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   263
  station->m_longRetry++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   264
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   265
  NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m_txrate << "\tlongRetry \t" << station->m_longRetry);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   266
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   267
  /// for normal rate, we're not currently sampling random rates
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   268
  if (!station->m_isSampling)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   269
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   270
      /// use best throughput rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   271
      if (station->m_longRetry < m_minstrelTable[station->m_txrate].adjustedRetryCount)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   272
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   273
          ;  ///<  there's still a few retries left
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   274
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   275
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   276
      /// use second best throughput rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   277
      else if (station->m_longRetry <= (m_minstrelTable[station->m_txrate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   278
                                        m_minstrelTable[station->m_maxTpRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   279
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   280
          station->m_txrate = station->m_maxTpRate2;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   281
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   282
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   283
      /// use best probability rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   284
      else if (station->m_longRetry <= (m_minstrelTable[station->m_txrate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   285
                                        m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   286
                                        m_minstrelTable[station->m_maxTpRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   287
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   288
          station->m_txrate = station->m_maxProbRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   289
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   290
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   291
      /// use lowest base rate	
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   292
      else if (station->m_longRetry > (m_minstrelTable[station->m_txrate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   293
                              m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   294
                              m_minstrelTable[station->m_maxTpRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   295
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   296
          station->m_txrate = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   297
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   298
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   299
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   300
  /// for look-around rate, we're currently sampling random rates
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   301
  else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   302
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   303
      /// current sampling rate is slower than the current best rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   304
      if (station->m_sampleRateSlower)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   305
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   306
          /// use best throughput rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   307
          if (station->m_longRetry < m_minstrelTable[station->m_txrate].adjustedRetryCount)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   308
            {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   309
              ;	///<  there are a few retries left
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   310
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   311
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   312
          ///	use random rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   313
          else if (station->m_longRetry <= (m_minstrelTable[station->m_txrate].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   314
                                            m_minstrelTable[station->m_maxTpRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   315
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   316
              station->m_txrate = station->m_sampleRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   317
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   318
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   319
          /// use max probability rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   320
          else if (station->m_longRetry <= (m_minstrelTable[station->m_txrate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   321
                                            m_minstrelTable[station->m_sampleRate].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   322
                                            m_minstrelTable[station->m_maxTpRate].adjustedRetryCount ))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   323
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   324
              station->m_txrate = station->m_maxProbRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   325
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   326
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   327
          /// use lowest base rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   328
          else if (station->m_longRetry > (m_minstrelTable[station->m_txrate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   329
                                           m_minstrelTable[station->m_sampleRate].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   330
                                           m_minstrelTable[station->m_maxTpRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   331
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   332
              station->m_txrate = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   333
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   334
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   335
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   336
        /// current sampling rate is better than current best rate 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   337
        else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   338
          {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   339
            /// use random rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   340
            if (station->m_longRetry < m_minstrelTable[station->m_txrate].adjustedRetryCount)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   341
              {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   342
                ;  ///< keep using it
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   343
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   344
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   345
            /// use the best rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   346
            else if (station->m_longRetry <= (m_minstrelTable[station->m_txrate].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   347
                                              m_minstrelTable[station->m_sampleRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   348
              {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   349
                station->m_txrate = station->m_maxTpRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   350
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   351
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   352
            /// use the best probability rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   353
            else if (station->m_longRetry <= (m_minstrelTable[station->m_txrate].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   354
                                              m_minstrelTable[station->m_maxTpRate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   355
                                              m_minstrelTable[station->m_sampleRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   356
              {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   357
                station->m_txrate = station->m_maxProbRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   358
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   359
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   360
            /// use the lowest base rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   361
            else if (station->m_longRetry > (m_minstrelTable[station->m_txrate].adjustedRetryCount + 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   362
                                             m_minstrelTable[station->m_maxTpRate].adjustedRetryCount +  
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   363
                                             m_minstrelTable[station->m_sampleRate].adjustedRetryCount))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   364
              {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   365
                station->m_txrate = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   366
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   367
          }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   368
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   369
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   370
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   371
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   372
MinstrelWifiManager::DoReportDataOk (WifiRemoteStation *st,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   373
                                     double ackSnr, WifiMode ackMode, double dataSnr)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   374
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   375
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   376
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   377
  station->m_isSampling = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   378
  station->m_sampleRateSlower=false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   379
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   380
  CheckInit (station);
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   381
  if (!station->m_initialized)
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   382
    {
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   383
      return;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   384
    }
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   385
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   386
  m_minstrelTable[station->m_txrate].numRateSuccess++;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   387
  m_minstrelTable[station->m_txrate].numRateAttempt++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   388
	
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   389
  UpdateRetry (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   390
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   391
  m_minstrelTable[station->m_txrate].numRateAttempt += station->m_retry;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   392
  station->m_packetCount++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   393
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   394
  if (m_nsupported >= 1)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   395
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   396
      station->m_txrate = FindRate (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   397
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   398
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   399
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   400
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   401
MinstrelWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   402
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   403
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   404
  NS_LOG_DEBUG ("DoReportFinalDataFailed m_txrate=" << station->m_txrate);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   405
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   406
  station->m_isSampling = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   407
  station->m_sampleRateSlower=false;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   408
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   409
  UpdateRetry (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   410
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   411
  m_minstrelTable[station->m_txrate].numRateAttempt += station->m_retry;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   412
  station->m_err++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   413
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   414
  if (m_nsupported >= 1)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   415
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   416
      station->m_txrate = FindRate (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   417
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   418
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   419
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   420
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   421
MinstrelWifiManager::UpdateRetry (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   422
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   423
  station->m_retry = station->m_shortRetry + station->m_longRetry;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   424
  station->m_shortRetry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   425
  station->m_longRetry = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   426
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   427
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   428
WifiMode
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   429
MinstrelWifiManager::DoGetDataMode (WifiRemoteStation *st,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   430
                                    uint32_t size)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   431
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   432
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   433
  if (!station->m_initialized)
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   434
    {
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   435
      CheckInit (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   436
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   437
      /// start the rate at half way
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   438
      station->m_txrate = m_nsupported / 2;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   439
    }
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   440
  UpdateStats (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   441
  return GetSupported (station, station->m_txrate);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   442
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   443
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   444
WifiMode
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   445
MinstrelWifiManager::DoGetRtsMode (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   446
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   447
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   448
  NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   449
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   450
  return GetSupported (station, 0);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   451
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   452
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   453
bool 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   454
MinstrelWifiManager::IsLowLatency (void) const
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   455
{
6268
84e114d34b89 Bug 802 - Minstrel algorithm causes segmentation fault
Duy Nguyen <dnlove@gmail.com>
parents: 6079
diff changeset
   456
  return true;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   457
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   458
uint32_t 
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   459
MinstrelWifiManager::GetNextSample (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   460
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   461
  uint32_t bitrate;
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   462
  bitrate = m_sampleTable[station->m_index][station->m_col];
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   463
  station->m_index++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   464
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   465
  /// bookeeping for m_index and m_col variables
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   466
  if (station->m_index > (m_nsupported - 2)) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   467
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   468
      station->m_index =0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   469
      station->m_col++;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   470
      if (station->m_col >= m_sampleCol)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   471
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   472
          station->m_col = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   473
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   474
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   475
  return bitrate;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   476
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   477
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   478
uint32_t
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   479
MinstrelWifiManager::FindRate (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   480
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   481
  NS_LOG_DEBUG ("FindRate " << "packet=" << station->m_packetCount );
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   482
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   483
  if ((station->m_sampleCount + station->m_packetCount) == 0)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   484
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   485
      return 0;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   486
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   487
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   488
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   489
  uint32_t idx;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   490
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   491
  /// for determining when to try a sample rate 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   492
  UniformVariable coinFlip (0, 100);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   493
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   494
  /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   495
   * if we are below the target of look around rate percentage, look around
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   496
   * note: do it randomly by flipping a coin instead sampling 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   497
   * all at once until it reaches the look around rate
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   498
   */
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   499
  if ( (((100* station->m_sampleCount) / (station->m_sampleCount + station->m_packetCount )) < m_lookAroundRate) &&
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   500
       ((int)coinFlip.GetValue ()) % 2 == 1 )
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   501
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   502
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   503
      /// now go through the table and find an index rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   504
      idx = GetNextSample(station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   505
			
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   506
			
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   507
      /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   508
       * This if condition is used to make sure that we don't need to use
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   509
       * the sample rate it is the same as our current rate
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   510
       */
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   511
      if (idx != station->m_maxTpRate && idx != station->m_txrate) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   512
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   513
		
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   514
          /// start sample count
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   515
          station->m_sampleCount++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   516
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   517
          /// set flag that we are currently sampling
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   518
          station->m_isSampling = true;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   519
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   520
          /// bookeeping for resetting stuff
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   521
          if (station->m_packetCount >= 10000) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   522
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   523
              station->m_sampleCount = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   524
              station->m_packetCount = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   525
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   526
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   527
          /// error check
6645
b89ac19713c6 closes bug 993
Quincy Tse <quincy.tse@gmail.com>
parents: 6337
diff changeset
   528
          if (idx >= m_nsupported)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   529
            {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   530
              NS_LOG_DEBUG ("ALERT!!! ERROR");
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   531
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   532
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   533
          /// set the rate that we're currently sampling
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   534
          station->m_sampleRate = idx;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   535
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   536
          if (station->m_sampleRate == station->m_maxTpRate)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   537
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   538
              station->m_sampleRate = station->m_maxTpRate2;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   539
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   540
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   541
          /// is this rate slower than the current best rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   542
          station->m_sampleRateSlower = 
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   543
            (m_minstrelTable[idx].perfectTxTime > m_minstrelTable[station->m_maxTpRate].perfectTxTime);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   544
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   545
          /// using the best rate instead
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   546
          if (station->m_sampleRateSlower)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   547
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   548
              idx =  station->m_maxTpRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   549
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   550
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   551
			
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   552
    } 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   553
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   554
  ///	continue using the best rate
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   555
  else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   556
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   557
      idx = station->m_maxTpRate; 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   558
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   559
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   560
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   561
  NS_LOG_DEBUG ("FindRate " << "sample rate=" << idx);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   562
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   563
  return idx;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   564
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   565
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   566
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   567
MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   568
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   569
  if (Simulator::Now () <  station->m_nextStatsUpdate)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   570
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   571
      return;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   572
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   573
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   574
  if (!station->m_initialized)
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   575
    {
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   576
      return;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   577
    }
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   578
  NS_LOG_DEBUG ("Updating stats="<<this);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   579
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   580
  station->m_nextStatsUpdate = Simulator::Now () + m_updateStats;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   581
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   582
  Time txTime;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   583
  uint32_t tempProb;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   584
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   585
  for (uint32_t i =0; i < m_nsupported; i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   586
    {        
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   587
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   588
      /// calculate the perfect tx time for this rate
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   589
      txTime = m_minstrelTable[i].perfectTxTime;       
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   590
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   591
      /// just for initialization
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   592
      if (txTime.GetMicroSeconds () == 0)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   593
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   594
          txTime = Seconds (1);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   595
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   596
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   597
      NS_LOG_DEBUG ("m_txrate=" << station->m_txrate << 
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   598
                    "\t attempt=" << m_minstrelTable[i].numRateAttempt << 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   599
                    "\t success=" << m_minstrelTable[i].numRateSuccess);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   600
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   601
      /// if we've attempted something
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   602
      if (m_minstrelTable[i].numRateAttempt)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   603
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   604
          /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   605
           * calculate the probability of success
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   606
           * assume probability scales from 0 to 18000
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   607
           */
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   608
          tempProb = (m_minstrelTable[i].numRateSuccess * 18000) / m_minstrelTable[i].numRateAttempt;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   609
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   610
          /// bookeeping
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   611
          m_minstrelTable[i].successHist += m_minstrelTable[i].numRateSuccess;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   612
          m_minstrelTable[i].attemptHist += m_minstrelTable[i].numRateAttempt;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   613
          m_minstrelTable[i].prob = tempProb;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   614
4725
4e068296f09f fix build for gcc 3.4
Craig Dowell <craigdo@ee.washington.edu>
parents: 4703
diff changeset
   615
          /// ewma probability (cast for gcc 3.4 compatibility)
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   616
          tempProb = static_cast<uint32_t>(((tempProb * (100 - m_ewmaLevel)) + (m_minstrelTable[i].ewmaProb * m_ewmaLevel) )/100);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   617
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   618
          m_minstrelTable[i].ewmaProb = tempProb;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   619
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   620
          /// calculating throughput
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   621
          m_minstrelTable[i].throughput = tempProb * (1000000 / txTime.GetMicroSeconds());
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   622
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   623
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   624
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   625
      /// bookeeping
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   626
      m_minstrelTable[i].prevNumRateAttempt = m_minstrelTable[i].numRateAttempt;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   627
      m_minstrelTable[i].prevNumRateSuccess = m_minstrelTable[i].numRateSuccess;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   628
      m_minstrelTable[i].numRateSuccess = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   629
      m_minstrelTable[i].numRateAttempt = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   630
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   631
      /// Sample less often below 10% and  above 95% of success
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   632
      if ((m_minstrelTable[i].ewmaProb > 17100) || (m_minstrelTable[i].ewmaProb < 1800)) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   633
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   634
          /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   635
           * retry count denotes the number of retries permitted for each rate
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   636
           * # retry_count/2
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   637
           */
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   638
          m_minstrelTable[i].adjustedRetryCount = m_minstrelTable[i].retryCount >> 1;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   639
          if (m_minstrelTable[i].adjustedRetryCount > 2)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   640
            {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   641
              m_minstrelTable[i].adjustedRetryCount = 2 ;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   642
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   643
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   644
      else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   645
        {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   646
          m_minstrelTable[i].adjustedRetryCount = m_minstrelTable[i].retryCount;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   647
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   648
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   649
      /// if it's 0 allow one retry limit
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   650
      if (m_minstrelTable[i].adjustedRetryCount == 0)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   651
        {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   652
          m_minstrelTable[i].adjustedRetryCount = 1;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   653
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   654
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   655
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   656
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   657
  uint32_t max_prob = 0, index_max_prob =0, max_tp =0, index_max_tp=0, index_max_tp2=0;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   658
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   659
  /// go find max throughput, second maximum throughput, high probability succ
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   660
  for (uint32_t i =0; i < m_nsupported; i++) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   661
    {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   662
      NS_LOG_DEBUG ("throughput" << m_minstrelTable[i].throughput << 
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   663
                    "\n ewma" << m_minstrelTable[i].ewmaProb);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   664
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   665
      if (max_tp < m_minstrelTable[i].throughput) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   666
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   667
          index_max_tp = i;
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   668
          max_tp = m_minstrelTable[i].throughput;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   669
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   670
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   671
      if (max_prob < m_minstrelTable[i].ewmaProb) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   672
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   673
          index_max_prob = i;
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   674
          max_prob = m_minstrelTable[i].ewmaProb;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   675
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   676
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   677
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   678
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   679
  max_tp = 0;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   680
  /// find the second highest max
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   681
  for (uint32_t i =0; i < m_nsupported; i++) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   682
    {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   683
      if ((i != index_max_tp) && (max_tp < m_minstrelTable[i].throughput))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   684
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   685
          index_max_tp2 = i;
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   686
          max_tp = m_minstrelTable[i].throughput;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   687
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   688
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   689
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   690
  station->m_maxTpRate = index_max_tp;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   691
  station->m_maxTpRate2 = index_max_tp2;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   692
  station->m_maxProbRate = index_max_prob;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   693
  station->m_currentRate = index_max_tp;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   694
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   695
  if (index_max_tp > station->m_txrate)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   696
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   697
      station->m_txrate = index_max_tp;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   698
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   699
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   700
  NS_LOG_DEBUG ("max tp="<< index_max_tp << "\nmax tp2="<< index_max_tp2<< "\nmax prob="<< index_max_prob);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   701
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   702
  /// reset it
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   703
  RateInit (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   704
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   705
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   706
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   707
MinstrelWifiManager::RateInit (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   708
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   709
  NS_LOG_DEBUG ("RateInit="<<station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   710
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   711
  for (uint32_t i = 0; i < m_nsupported; i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   712
    {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   713
      m_minstrelTable[i].numRateAttempt = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   714
      m_minstrelTable[i].numRateSuccess = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   715
      m_minstrelTable[i].prob = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   716
      m_minstrelTable[i].ewmaProb = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   717
      m_minstrelTable[i].prevNumRateAttempt = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   718
      m_minstrelTable[i].prevNumRateSuccess = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   719
      m_minstrelTable[i].successHist = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   720
      m_minstrelTable[i].attemptHist = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   721
      m_minstrelTable[i].throughput = 0;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   722
      m_minstrelTable[i].perfectTxTime = GetCalcTxTime (GetSupported (station, i));
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   723
      m_minstrelTable[i].retryCount = 1;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   724
      m_minstrelTable[i].adjustedRetryCount = 1;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   725
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   726
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   727
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   728
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   729
MinstrelWifiManager::InitSampleTable (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   730
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   731
  NS_LOG_DEBUG ("InitSampleTable="<<this);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   732
	
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   733
  station->m_col = station->m_index = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   734
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   735
  /// for off-seting to make rates fall between 0 and numrates 
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   736
  uint32_t numSampleRates = m_nsupported;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   737
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   738
  uint32_t newIndex;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   739
  for (uint32_t col = 0; col < m_sampleCol; col++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   740
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   741
      for (uint32_t i = 0; i < numSampleRates; i++ )
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   742
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   743
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   744
          /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   745
           * The next two lines basically tries to generate a random number
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   746
           * between 0 and the number of available rates 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   747
           */
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   748
          UniformVariable uv (0, numSampleRates);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   749
          newIndex = (i + (uint32_t)uv.GetValue	()) % numSampleRates;	
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   750
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   751
          /// this loop is used for filling in other uninitilized places
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   752
          while	(m_sampleTable[newIndex][col] != 0)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   753
            {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   754
              newIndex = (newIndex + 1) % m_nsupported;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   755
            }
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   756
          m_sampleTable[newIndex][col] = i;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   757
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   758
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   759
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   760
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   761
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   762
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   763
MinstrelWifiManager::PrintSampleTable (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   764
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   765
  NS_LOG_DEBUG ("PrintSampleTable="<<station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   766
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   767
  uint32_t numSampleRates = m_nsupported;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   768
  for (uint32_t i = 0; i < numSampleRates; i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   769
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   770
      for (uint32_t j = 0; j < m_sampleCol; j++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   771
        {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   772
          std::cout << m_sampleTable[i][j] << "\t";
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   773
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   774
      std::cout << std::endl;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   775
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   776
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   777
	
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   778
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   779
MinstrelWifiManager::PrintTable (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   780
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   781
  NS_LOG_DEBUG ("PrintTable="<<station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   782
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   783
  for (uint32_t i=0; i < m_nsupported; i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   784
    {
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6268
diff changeset
   785
      std::cout << "index(" << i << ") = " << m_minstrelTable[i].perfectTxTime<< "\n";
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   786
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   787
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   788
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   789
} //namespace ns3
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   790
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   791
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   792
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   793
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   794