src/devices/wifi/minstrel-wifi-manager.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 26 Feb 2010 08:52:39 +0100
changeset 6079 e9b65f133d50
parent 6065 0f012e7d9128
child 6268 84e114d34b89
permissions -rw-r--r--
fix optimized builds
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
 * A struct to contain all information related to a data rate 
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
struct RateInfo
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
   * Perfect transmission time calculation, or frame calculation
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    54
   * Given a bit rate and a packet length n bytes 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    55
   */
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    56
  Time perfectTxTime;		
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
  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    59
  uint32_t retryCount;  ///< retry limit
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    60
  uint32_t adjustedRetryCount;  ///< adjust the retry limit for this rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    61
  uint32_t numRateAttempt;  ///< how many number of attempts so far
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    62
    uint32_t numRateSuccess;  ///< number of successful pkts 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    63
  uint32_t prob;  ///< (# pkts success )/(# total pkts)
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    64
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
   * EWMA calculation
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    67
   * ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    68
   */
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    69
  uint32_t ewmaProb;
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 prevNumRateAttempt;  ///< from last rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    72
  uint32_t prevNumRateSuccess;  ///< from last rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    73
  uint64_t successHist;  ///< aggregate of all successes
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    74
  uint64_t attemptHist;  ///< aggregate of all attempts
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    75
  uint32_t throughput;  ///< throughput of a 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
  
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
 * Data structure for a Minstrel Rate table 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    80
 * A vector of a struct RateInfo 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    81
 */
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    82
typedef std::vector<struct RateInfo> MinstrelRate;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    83
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    84
/**
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    85
 * Data structure for a Sample Rate table
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    86
 * A vector of a vector uint32_t 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    87
 */
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    88
typedef std::vector<std::vector<uint32_t> > SampleRate;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    89
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    90
struct MinstrelWifiRemoteStation : public WifiRemoteStation
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    91
{
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    92
  Time m_nextStatsUpdate;  ///< 10 times every second
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    93
  MinstrelRate m_minstrelTable;  ///< minstrel table	
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    94
  SampleRate m_sampleTable;  ///< sample table
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    95
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    96
  /**
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
    97
   * 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
    98
   * 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
    99
   * then we wrap back to the row 1 col 1.
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   100
   * note: there are many other ways to do this.
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   101
   */
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   102
  uint32_t m_col, m_index;							
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   103
  uint32_t m_maxTpRate;  ///< the current throughput rate 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   104
  uint32_t m_maxTpRate2;  ///< second highest throughput rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   105
  uint32_t m_maxProbRate;  ///< rate with highest prob of success
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   106
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   107
  int m_packetCount;  ///< total number of packets as of now
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   108
  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
   109
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   110
  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
   111
  uint32_t m_sampleRate;  ///< current sample rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   112
  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
   113
  uint32_t m_currentRate;  ///< current rate we are using
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   114
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   115
  uint32_t m_shortRetry;  ///< short retries such as control packts
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   116
  uint32_t m_longRetry;  ///< long retries such as data packets
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   117
  uint32_t m_retry;  ///< total retries short + long
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   118
  uint32_t m_err;  ///< retry errors
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   119
  uint32_t m_txrate;  ///< current transmit rate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   120
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   121
  bool m_initialized;  ///< for initializing tables
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   122
};
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   123
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   124
NS_OBJECT_ENSURE_REGISTERED (MinstrelWifiManager);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   125
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   126
TypeId
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   127
MinstrelWifiManager::GetTypeId (void)
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
  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
   130
    .SetParent<WifiRemoteStationManager> ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   131
    .AddConstructor<MinstrelWifiManager> ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   132
    .AddAttribute ("UpdateStatistics",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   133
                   "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
   134
                   TimeValue (Seconds (0.1)),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   135
                   MakeTimeAccessor (&MinstrelWifiManager::m_updateStats),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   136
                   MakeTimeChecker ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   137
    .AddAttribute ("LookAroundRate", 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   138
                   "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
   139
                   DoubleValue (10),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   140
                   MakeDoubleAccessor (&MinstrelWifiManager::m_lookAroundRate),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   141
                   MakeDoubleChecker<double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   142
    .AddAttribute ("EWMA", 
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   143
                   "EWMA level",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   144
                   DoubleValue (75),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   145
                   MakeDoubleAccessor (&MinstrelWifiManager::m_ewmaLevel),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   146
                   MakeDoubleChecker<double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   147
    .AddAttribute ("SegmentSize",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   148
                   "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
   149
                   DoubleValue (6000),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   150
                   MakeDoubleAccessor (&MinstrelWifiManager::m_segmentSize),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   151
                   MakeDoubleChecker <double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   152
    .AddAttribute ("SampleColumn",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   153
                   "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
   154
                   DoubleValue (10),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   155
                   MakeDoubleAccessor (&MinstrelWifiManager::m_sampleCol),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   156
                   MakeDoubleChecker <double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   157
    .AddAttribute ("PacketLength",
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   158
                   "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
   159
                   DoubleValue (1200),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   160
                   MakeDoubleAccessor (&MinstrelWifiManager::m_pktLen),
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   161
                   MakeDoubleChecker <double> ())
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   162
    ;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   163
  return tid;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   164
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   165
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   166
MinstrelWifiManager::MinstrelWifiManager ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   167
{}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   168
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   169
MinstrelWifiManager::~MinstrelWifiManager ()
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   170
{}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   171
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   172
void
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   173
MinstrelWifiManager::SetupPhy (Ptr<WifiPhy> phy)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   174
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   175
  uint32_t nModes = phy->GetNModes ();
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   176
  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
   177
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   178
      WifiMode mode = phy->GetMode (i);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   179
      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
   180
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   181
  WifiRemoteStationManager::SetupPhy (phy);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   182
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   183
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   184
Time
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   185
MinstrelWifiManager::GetCalcTxTime (WifiMode mode) const
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   186
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   187
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   188
  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
   189
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   190
      if (mode == i->second)
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   191
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   192
          return i->first;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   193
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   194
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   195
  NS_ASSERT (false);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   196
  return Seconds (0);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   197
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   198
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   199
void
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   200
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
   201
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   202
   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
   203
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   204
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   205
WifiRemoteStation *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   206
MinstrelWifiManager::DoCreateStation (void) const
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   207
{
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   208
  MinstrelWifiRemoteStation *station = new MinstrelWifiRemoteStation ();
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   209
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   210
  station->m_nextStatsUpdate = Simulator::Now () + m_updateStats;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   211
  station->m_col = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   212
  station->m_index = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   213
  station->m_maxTpRate = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   214
  station->m_maxTpRate2 = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   215
  station->m_maxProbRate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   216
  station->m_packetCount = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   217
  station->m_sampleCount = 0; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   218
  station->m_isSampling = false; 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   219
  station->m_sampleRate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   220
  station->m_sampleRateSlower = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   221
  station->m_currentRate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   222
  station->m_shortRetry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   223
  station->m_longRetry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   224
  station->m_retry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   225
  station->m_err = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   226
  station->m_txrate = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   227
  station->m_initialized = false;
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
  return station;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   230
}
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   231
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   232
void 
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   233
MinstrelWifiManager::CheckInit(MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   234
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   235
  if (!station->m_initialized)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   236
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   237
      // 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
   238
      // 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
   239
      // before we perform our own initialization.
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   240
      station->m_minstrelTable = MinstrelRate(GetNSupported (station));
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   241
      station->m_sampleTable = SampleRate(GetNSupported (station), std::vector<uint32_t> (m_sampleCol));
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   242
      InitSampleTable (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   243
      RateInit (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   244
      station->m_initialized = true;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   245
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   246
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   247
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   248
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   249
MinstrelWifiManager::DoReportRxOk (WifiRemoteStation *st,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   250
                                   double rxSnr, WifiMode txMode)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   251
{
6079
e9b65f133d50 fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 6065
diff changeset
   252
  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
   253
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   254
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   255
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   256
MinstrelWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   257
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   258
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   259
  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
   260
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   261
  station->m_shortRetry++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   262
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   263
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   264
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   265
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
   266
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   267
  NS_LOG_DEBUG ("self="<<st<<" rts ok");
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   268
}
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   269
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   270
void
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   271
MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   272
{
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   273
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   274
  UpdateRetry (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   275
  station->m_err++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   276
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   277
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   278
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   279
MinstrelWifiManager::DoReportDataFailed (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   280
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   281
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   282
  /**
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   283
   *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   284
   * Retry Chain table is implemented here
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   285
   *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   286
   * Try |         LOOKAROUND RATE              | NORMAL RATE
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   287
   *     | random < best    | random > best     |
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   288
   * --------------------------------------------------------------
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   289
   *  1  | Best throughput  | Random rate       | Best throughput
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   290
   *  2  | Random rate      | Best throughput   | Next best throughput
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   291
   *  3  | Best probability | Best probability  | Best probability
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   292
   *  4  | Lowest Baserate  | Lowest baserate   | Lowest baserate
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   293
   *
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   294
   * 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
   295
   * After a failing 7 times, DoReportFinalDataFailed will be called
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   296
   */
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   297
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   298
  CheckInit(station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   299
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   300
  station->m_longRetry++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   301
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   302
  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
   303
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   304
  /// 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
   305
  if (!station->m_isSampling)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   306
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   307
      /// use best throughput rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   308
      if (station->m_longRetry < station->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
   309
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   310
          ;  ///<  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
   311
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   312
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   313
      /// use second best throughput rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   314
      else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   315
                                        station->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
   316
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   317
          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
   318
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   319
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   320
      /// use best probability rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   321
      else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   322
                                        station->m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   323
                                        station->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
   324
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   325
          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
   326
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   327
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   328
      /// use lowest base rate	
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   329
      else if (station->m_longRetry > (station->m_minstrelTable[station->m_txrate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   330
                              station->m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   331
                              station->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
   332
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   333
          station->m_txrate = 0;
4703
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
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   337
  /// 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
   338
  else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   339
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   340
      /// 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
   341
      if (station->m_sampleRateSlower)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   342
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   343
          /// use best throughput rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   344
          if (station->m_longRetry < station->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
   345
            {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   346
              ;	///<  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
   347
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   348
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   349
          ///	use random rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   350
          else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   351
                                            station->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
   352
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   353
              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
   354
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   355
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   356
          /// use max probability rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   357
          else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   358
                                            station->m_minstrelTable[station->m_sampleRate].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   359
                                            station->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
   360
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   361
              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
   362
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   363
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   364
          /// use lowest base rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   365
          else if (station->m_longRetry > (station->m_minstrelTable[station->m_txrate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   366
                                           station->m_minstrelTable[station->m_sampleRate].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   367
                                           station->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
   368
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   369
              station->m_txrate = 0;
4703
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
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   372
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   373
        /// 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
   374
        else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   375
          {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   376
            /// use random rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   377
            if (station->m_longRetry < station->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
   378
              {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   379
                ;  ///< keep using it
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   380
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   381
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   382
            /// use the best rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   383
            else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   384
                                              station->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
   385
              {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   386
                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
   387
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   388
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   389
            /// use the best probability rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   390
            else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   391
                                              station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   392
                                              station->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
   393
              {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   394
                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
   395
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   396
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   397
            /// use the lowest base rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   398
            else if (station->m_longRetry > (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   399
                                             station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount +  
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   400
                                             station->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
   401
              {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   402
                station->m_txrate = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   403
              }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   404
          }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   405
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   406
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   407
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   408
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   409
MinstrelWifiManager::DoReportDataOk (WifiRemoteStation *st,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   410
                                     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
   411
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   412
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   413
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   414
  station->m_isSampling = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   415
  station->m_sampleRateSlower=false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   416
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   417
  CheckInit (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   418
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   419
  station->m_minstrelTable[station->m_txrate].numRateSuccess++;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   420
  station->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
   421
	
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   422
  UpdateRetry (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   423
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   424
  station->m_minstrelTable[station->m_txrate].numRateAttempt += station->m_retry;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   425
  station->m_packetCount++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   426
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   427
  if (GetNSupported (station) >= 1)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   428
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   429
      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
   430
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   431
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   432
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   433
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   434
MinstrelWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   435
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   436
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   437
  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
   438
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   439
  station->m_isSampling = false;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   440
  station->m_sampleRateSlower=false;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   441
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   442
  UpdateRetry (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   443
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   444
  station->m_minstrelTable[station->m_txrate].numRateAttempt += station->m_retry;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   445
  station->m_err++;
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
  if (GetNSupported (station) >= 1)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   448
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   449
      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
   450
    }
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
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   453
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   454
MinstrelWifiManager::UpdateRetry (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   455
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   456
  station->m_retry = station->m_shortRetry + station->m_longRetry;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   457
  station->m_shortRetry = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   458
  station->m_longRetry = 0;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   459
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   460
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   461
WifiMode
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   462
MinstrelWifiManager::DoGetDataMode (WifiRemoteStation *st,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   463
                                    uint32_t size)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   464
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   465
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   466
  if (!station->m_initialized)
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   467
    {
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   468
      CheckInit (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   469
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   470
      /// start the rate at half way
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   471
      station->m_txrate = GetNSupported (station) / 2;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   472
    }
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   473
  UpdateStats (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   474
  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
   475
}
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
WifiMode
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   478
MinstrelWifiManager::DoGetRtsMode (WifiRemoteStation *st)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   479
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   480
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   481
  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
   482
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   483
  return GetSupported (station, 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
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   486
bool 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   487
MinstrelWifiManager::IsLowLatency (void) const
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   488
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   489
  return false;
4703
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
uint32_t 
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   492
MinstrelWifiManager::GetNextSample (MinstrelWifiRemoteStation *station)
4703
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
  uint32_t bitrate;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   495
  bitrate = station->m_sampleTable[station->m_index][station->m_col];
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   496
  station->m_index++;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   497
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   498
  /// bookeeping for m_index and m_col variables
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   499
  if (station->m_index > (GetNSupported (station) - 2)) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   500
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   501
      station->m_index =0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   502
      station->m_col++;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   503
      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
   504
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   505
          station->m_col = 0;
4703
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
  return bitrate;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   509
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   510
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   511
uint32_t
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   512
MinstrelWifiManager::FindRate (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   513
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   514
  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
   515
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   516
  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
   517
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   518
      return 0;
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
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   521
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   522
  uint32_t idx;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   523
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   524
  /// 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
   525
  UniformVariable coinFlip (0, 100);
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
  /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   528
   * 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
   529
   * 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
   530
   * 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
   531
   */
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   532
  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
   533
       ((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
   534
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   535
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   536
      /// 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
   537
      idx = GetNextSample(station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   538
			
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
       * 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
   542
       * 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
   543
       */
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   544
      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
   545
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   546
		
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   547
          /// start sample count
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   548
          station->m_sampleCount++;
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
          /// set flag that we are currently sampling
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   551
          station->m_isSampling = true;
4703
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
          /// bookeeping for resetting stuff
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   554
          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
   555
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   556
              station->m_sampleCount = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   557
              station->m_packetCount = 0;
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
          /// error check
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   561
          if (idx >= GetNSupported (station) || idx < 0)
4703
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
              NS_LOG_DEBUG ("ALERT!!! ERROR");
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
          /// set the rate that we're currently sampling
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   567
          station->m_sampleRate = idx;
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 (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
   570
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   571
              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
   572
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   573
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   574
          /// is this rate slower than the current best rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   575
          station->m_sampleRateSlower = 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   576
            (station->m_minstrelTable[idx].perfectTxTime > station->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
   577
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   578
          /// using the best rate instead
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   579
          if (station->m_sampleRateSlower)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   580
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   581
              idx =  station->m_maxTpRate;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   582
            }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   583
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   584
			
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   585
    } 
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
  ///	continue using the best rate
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   588
  else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   589
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   590
      idx = station->m_maxTpRate; 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   591
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   592
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
  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
   595
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   596
  return idx;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   597
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   598
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   599
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   600
MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   601
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   602
  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
   603
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   604
      return;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   605
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   606
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   607
  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
   608
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   609
  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
   610
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   611
  Time txTime;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   612
  uint32_t tempProb;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   613
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   614
  for (uint32_t i =0; i < GetNSupported (station); i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   615
    {        
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   616
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   617
      /// calculate the perfect tx time for this rate
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   618
      txTime = station->m_minstrelTable[i].perfectTxTime;       
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
      /// just for initialization
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   621
      if (txTime.GetMicroSeconds () == 0)
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
          txTime = Seconds (1);
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
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   626
      NS_LOG_DEBUG ("m_txrate=" << station->m_txrate << 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   627
                    "\t attempt=" << station->m_minstrelTable[i].numRateAttempt << 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   628
                    "\t success=" << station->m_minstrelTable[i].numRateSuccess);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   629
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   630
      /// if we've attempted something
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   631
      if (station->m_minstrelTable[i].numRateAttempt)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   632
        {
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
           * calculate the probability of success
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   635
           * 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
   636
           */
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   637
          tempProb = (station->m_minstrelTable[i].numRateSuccess * 18000) / station->m_minstrelTable[i].numRateAttempt;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   638
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   639
          /// bookeeping
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   640
          station->m_minstrelTable[i].successHist += station->m_minstrelTable[i].numRateSuccess;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   641
          station->m_minstrelTable[i].attemptHist += station->m_minstrelTable[i].numRateAttempt;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   642
          station->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
   643
4725
4e068296f09f fix build for gcc 3.4
Craig Dowell <craigdo@ee.washington.edu>
parents: 4703
diff changeset
   644
          /// ewma probability (cast for gcc 3.4 compatibility)
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   645
          tempProb = static_cast<uint32_t>(((tempProb * (100 - m_ewmaLevel)) + (station->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
   646
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   647
          station->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
   648
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   649
          /// calculating throughput
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   650
          station->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
   651
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   652
        }
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
      /// bookeeping
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   655
      station->m_minstrelTable[i].prevNumRateAttempt = station->m_minstrelTable[i].numRateAttempt;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   656
      station->m_minstrelTable[i].prevNumRateSuccess = station->m_minstrelTable[i].numRateSuccess;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   657
      station->m_minstrelTable[i].numRateSuccess = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   658
      station->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
   659
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   660
      /// Sample less often below 10% and  above 95% of success
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   661
      if ((station->m_minstrelTable[i].ewmaProb > 17100) || (station->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
   662
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   663
          /**
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   664
           * 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
   665
           * # retry_count/2
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   666
           */
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   667
          station->m_minstrelTable[i].adjustedRetryCount = station->m_minstrelTable[i].retryCount >> 1;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   668
          if (station->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
   669
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   670
              station->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
   671
            }
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
      else
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   674
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   675
          station->m_minstrelTable[i].adjustedRetryCount = station->m_minstrelTable[i].retryCount;
4703
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
      /// if it's 0 allow one retry limit
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   679
      if (station->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
   680
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   681
          station->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
   682
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   683
    }
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
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   686
  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
   687
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   688
  /// go find max throughput, second maximum throughput, high probability succ
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   689
  for (uint32_t i =0; i < GetNSupported (station); i++) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   690
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   691
      NS_LOG_DEBUG ("throughput" << station->m_minstrelTable[i].throughput << 
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   692
                    "\n ewma" << station->m_minstrelTable[i].ewmaProb);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   693
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   694
      if (max_tp < station->m_minstrelTable[i].throughput) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   695
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   696
          index_max_tp = i;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   697
          max_tp = station->m_minstrelTable[i].throughput;
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
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   700
      if (max_prob < station->m_minstrelTable[i].ewmaProb) 
4703
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
          index_max_prob = i;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   703
          max_prob = station->m_minstrelTable[i].ewmaProb;
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
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   707
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   708
  max_tp = 0;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   709
  /// find the second highest max
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   710
  for (uint32_t i =0; i < GetNSupported (station); i++) 
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   711
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   712
      if ((i != index_max_tp) && (max_tp < station->m_minstrelTable[i].throughput))
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   713
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   714
          index_max_tp2 = i;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   715
          max_tp = station->m_minstrelTable[i].throughput;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   716
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   717
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   718
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   719
  station->m_maxTpRate = index_max_tp;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   720
  station->m_maxTpRate2 = index_max_tp2;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   721
  station->m_maxProbRate = index_max_prob;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   722
  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
   723
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   724
  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
   725
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   726
      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
   727
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   728
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   729
  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
   730
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   731
  /// reset it
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   732
  RateInit (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   733
}
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
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   736
MinstrelWifiManager::RateInit (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   737
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   738
  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
   739
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   740
  for (uint32_t i = 0; i < GetNSupported (station); i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   741
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   742
      station->m_minstrelTable[i].numRateAttempt = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   743
      station->m_minstrelTable[i].numRateSuccess = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   744
      station->m_minstrelTable[i].prob = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   745
      station->m_minstrelTable[i].ewmaProb = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   746
      station->m_minstrelTable[i].prevNumRateAttempt = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   747
      station->m_minstrelTable[i].prevNumRateSuccess = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   748
      station->m_minstrelTable[i].successHist = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   749
      station->m_minstrelTable[i].attemptHist = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   750
      station->m_minstrelTable[i].throughput = 0;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   751
      station->m_minstrelTable[i].perfectTxTime = GetCalcTxTime (GetSupported (station, i));
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   752
      station->m_minstrelTable[i].retryCount = 1;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   753
      station->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
   754
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   755
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   756
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   757
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   758
MinstrelWifiManager::InitSampleTable (MinstrelWifiRemoteStation *station)
4703
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
  NS_LOG_DEBUG ("InitSampleTable="<<this);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   761
	
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   762
  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
   763
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   764
  /// for off-seting to make rates fall between 0 and numrates 
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   765
  uint32_t numSampleRates = GetNSupported (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   766
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   767
  uint32_t newIndex;
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   768
  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
   769
    {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   770
      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
   771
        {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   772
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
           * 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
   775
           * 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
   776
           */
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   777
          UniformVariable uv (0, numSampleRates);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   778
          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
   779
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   780
          /// this loop is used for filling in other uninitilized places
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   781
          while	(station->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
   782
            {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   783
              newIndex = (newIndex + 1)%GetNSupported (station);
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   784
            }
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   785
          station->m_sampleTable[newIndex][col] = i+1;
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
}
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
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   792
MinstrelWifiManager::PrintSampleTable (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   793
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   794
  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
   795
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   796
  uint32_t numSampleRates = GetNSupported (station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   797
  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
   798
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   799
      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
   800
        {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   801
          std::cout << station->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
   802
        }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   803
      std::cout << std::endl;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   804
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   805
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   806
	
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   807
void
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   808
MinstrelWifiManager::PrintTable (MinstrelWifiRemoteStation *station)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   809
{
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   810
  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
   811
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   812
  for (uint32_t i=0; i < GetNSupported (station); i++)
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   813
    {
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5260
diff changeset
   814
      std::cout << "index(" << i << ") = " << station->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
   815
    }
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   816
}
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   817
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   818
} //namespace ns3
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   819
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   820
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   821
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   822
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   823