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-- |
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 | 47 |
/** |
48 |
* A struct to contain all information related to a data rate |
|
49 |
*/ |
|
50 |
struct RateInfo |
|
51 |
{ |
|
52 |
/** |
|
53 |
* Perfect transmission time calculation, or frame calculation |
|
54 |
* Given a bit rate and a packet length n bytes |
|
55 |
*/ |
|
56 |
Time perfectTxTime; |
|
57 |
||
58 |
||
59 |
uint32_t retryCount; ///< retry limit |
|
60 |
uint32_t adjustedRetryCount; ///< adjust the retry limit for this rate |
|
61 |
uint32_t numRateAttempt; ///< how many number of attempts so far |
|
62 |
uint32_t numRateSuccess; ///< number of successful pkts |
|
63 |
uint32_t prob; ///< (# pkts success )/(# total pkts) |
|
64 |
||
65 |
/** |
|
66 |
* EWMA calculation |
|
67 |
* ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100 |
|
68 |
*/ |
|
69 |
uint32_t ewmaProb; |
|
70 |
||
71 |
uint32_t prevNumRateAttempt; ///< from last rate |
|
72 |
uint32_t prevNumRateSuccess; ///< from last rate |
|
73 |
uint64_t successHist; ///< aggregate of all successes |
|
74 |
uint64_t attemptHist; ///< aggregate of all attempts |
|
75 |
uint32_t throughput; ///< throughput of a rate |
|
76 |
}; |
|
77 |
||
78 |
/** |
|
79 |
* Data structure for a Minstrel Rate table |
|
80 |
* A vector of a struct RateInfo |
|
81 |
*/ |
|
82 |
typedef std::vector<struct RateInfo> MinstrelRate; |
|
83 |
||
84 |
/** |
|
85 |
* Data structure for a Sample Rate table |
|
86 |
* A vector of a vector uint32_t |
|
87 |
*/ |
|
88 |
typedef std::vector<std::vector<uint32_t> > SampleRate; |
|
89 |
||
90 |
struct MinstrelWifiRemoteStation : public WifiRemoteStation |
|
91 |
{ |
|
92 |
Time m_nextStatsUpdate; ///< 10 times every second |
|
93 |
MinstrelRate m_minstrelTable; ///< minstrel table |
|
94 |
SampleRate m_sampleTable; ///< sample table |
|
95 |
||
96 |
/** |
|
97 |
* To keep track of the current position in the our random sample table |
|
98 |
* going row by row from 1st column until the 10th column(Minstrel defines 10) |
|
99 |
* then we wrap back to the row 1 col 1. |
|
100 |
* note: there are many other ways to do this. |
|
101 |
*/ |
|
102 |
uint32_t m_col, m_index; |
|
103 |
uint32_t m_maxTpRate; ///< the current throughput rate |
|
104 |
uint32_t m_maxTpRate2; ///< second highest throughput rate |
|
105 |
uint32_t m_maxProbRate; ///< rate with highest prob of success |
|
106 |
||
107 |
int m_packetCount; ///< total number of packets as of now |
|
108 |
int m_sampleCount; ///< how many packets we have sample so far |
|
109 |
||
110 |
bool m_isSampling; ///< a flag to indicate we are currently sampling |
|
111 |
uint32_t m_sampleRate; ///< current sample rate |
|
112 |
bool m_sampleRateSlower; ///< a flag to indicate sample rate is slower |
|
113 |
uint32_t m_currentRate; ///< current rate we are using |
|
114 |
||
115 |
uint32_t m_shortRetry; ///< short retries such as control packts |
|
116 |
uint32_t m_longRetry; ///< long retries such as data packets |
|
117 |
uint32_t m_retry; ///< total retries short + long |
|
118 |
uint32_t m_err; ///< retry errors |
|
119 |
uint32_t m_txrate; ///< current transmit rate |
|
120 |
||
121 |
bool m_initialized; ///< for initializing tables |
|
122 |
}; |
|
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 | 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 | 205 |
WifiRemoteStation * |
206 |
MinstrelWifiManager::DoCreateStation (void) const |
|
207 |
{ |
|
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 | 210 |
station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; |
211 |
station->m_col = 0; |
|
212 |
station->m_index = 0; |
|
213 |
station->m_maxTpRate = 0; |
|
214 |
station->m_maxTpRate2 = 0; |
|
215 |
station->m_maxProbRate = 0; |
|
216 |
station->m_packetCount = 0; |
|
217 |
station->m_sampleCount = 0; |
|
218 |
station->m_isSampling = false; |
|
219 |
station->m_sampleRate = 0; |
|
220 |
station->m_sampleRateSlower = false; |
|
221 |
station->m_currentRate = 0; |
|
222 |
station->m_shortRetry = 0; |
|
223 |
station->m_longRetry = 0; |
|
224 |
station->m_retry = 0; |
|
225 |
station->m_err = 0; |
|
226 |
station->m_txrate = 0; |
|
227 |
station->m_initialized = false; |
|
228 |
||
229 |
return station; |
|
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 | 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 | 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 | 237 |
// Note: we appear to be doing late initialization of the table |
238 |
// to make sure that the set of supported rates has been initialized |
|
239 |
// before we perform our own initialization. |
|
240 |
station->m_minstrelTable = MinstrelRate(GetNSupported (station)); |
|
241 |
station->m_sampleTable = SampleRate(GetNSupported (station), std::vector<uint32_t> (m_sampleCol)); |
|
242 |
InitSampleTable (station); |
|
243 |
RateInit (station); |
|
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 | 249 |
MinstrelWifiManager::DoReportRxOk (WifiRemoteStation *st, |
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 | 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 | 258 |
MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
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 | 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 | 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 | 267 |
NS_LOG_DEBUG ("self="<<st<<" rts ok"); |
268 |
} |
|
269 |
||
270 |
void |
|
271 |
MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) |
|
272 |
{ |
|
273 |
MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
|
274 |
UpdateRetry (station); |
|
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 | 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 | 281 |
MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
282 |
/** |
|
283 |
* |
|
284 |
* Retry Chain table is implemented here |
|
285 |
* |
|
286 |
* Try | LOOKAROUND RATE | NORMAL RATE |
|
287 |
* | random < best | random > best | |
|
288 |
* -------------------------------------------------------------- |
|
289 |
* 1 | Best throughput | Random rate | Best throughput |
|
290 |
* 2 | Random rate | Best throughput | Next best throughput |
|
291 |
* 3 | Best probability | Best probability | Best probability |
|
292 |
* 4 | Lowest Baserate | Lowest baserate | Lowest baserate |
|
293 |
* |
|
294 |
* Note: For clarity, multiple blocks of if's and else's are used |
|
295 |
* After a failing 7 times, DoReportFinalDataFailed will be called |
|
296 |
*/ |
|
4703
e1259e2fdaad
add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff
changeset
|
297 |
|
6065 | 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 | 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 | 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 | 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 | 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 | 314 |
else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
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 | 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 | 321 |
else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
322 |
station->m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount + |
|
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 | 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 | 329 |
else if (station->m_longRetry > (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
330 |
station->m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount + |
|
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 | 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 | 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 | 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 | 350 |
else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
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 | 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 | 357 |
else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
358 |
station->m_minstrelTable[station->m_sampleRate].adjustedRetryCount + |
|
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 | 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 | 365 |
else if (station->m_longRetry > (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
366 |
station->m_minstrelTable[station->m_sampleRate].adjustedRetryCount + |
|
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 | 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 | 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 | 383 |
else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
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 | 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 | 390 |
else if (station->m_longRetry <= (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
391 |
station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount + |
|
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 | 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 | 398 |
else if (station->m_longRetry > (station->m_minstrelTable[station->m_txrate].adjustedRetryCount + |
399 |
station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount + |
|
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 | 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 | 409 |
MinstrelWifiManager::DoReportDataOk (WifiRemoteStation *st, |
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 | 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 | 414 |
station->m_isSampling = false; |
415 |
station->m_sampleRateSlower=false; |
|
416 |
||
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 | 419 |
station->m_minstrelTable[station->m_txrate].numRateSuccess++; |
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 | 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 | 424 |
station->m_minstrelTable[station->m_txrate].numRateAttempt += station->m_retry; |
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 | 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 | 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 | 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 | 436 |
MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
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 | 439 |
station->m_isSampling = false; |
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 | 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 | 444 |
station->m_minstrelTable[station->m_txrate].numRateAttempt += station->m_retry; |
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 | 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 | 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 | 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 | 456 |
station->m_retry = station->m_shortRetry + station->m_longRetry; |
457 |
station->m_shortRetry = 0; |
|
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 | 461 |
WifiMode |
462 |
MinstrelWifiManager::DoGetDataMode (WifiRemoteStation *st, |
|
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 | 465 |
MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
466 |
if (!station->m_initialized) |
|
467 |
{ |
|
468 |
CheckInit (station); |
|
469 |
||
470 |
/// start the rate at half way |
|
471 |
station->m_txrate = GetNSupported (station) / 2; |
|
472 |
} |
|
473 |
UpdateStats (station); |
|
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 | 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 | 480 |
MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
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 | 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 | 486 |
bool |
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 | 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 | 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 | 495 |
bitrate = station->m_sampleTable[station->m_index][station->m_col]; |
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 | 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 | 501 |
station->m_index =0; |
502 |
station->m_col++; |
|
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 | 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 | 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 | 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 | 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 | 532 |
if ( (((100* station->m_sampleCount) / (station->m_sampleCount + station->m_packetCount )) < m_lookAroundRate) && |
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 | 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 | 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 | 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 | 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 | 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 | 556 |
station->m_sampleCount = 0; |
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 | 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 | 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 | 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 | 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 | 575 |
station->m_sampleRateSlower = |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 626 |
NS_LOG_DEBUG ("m_txrate=" << station->m_txrate << |
627 |
"\t attempt=" << station->m_minstrelTable[i].numRateAttempt << |
|
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 | 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 | 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 | 640 |
station->m_minstrelTable[i].successHist += station->m_minstrelTable[i].numRateSuccess; |
641 |
station->m_minstrelTable[i].attemptHist += station->m_minstrelTable[i].numRateAttempt; |
|
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 | 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 | 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 | 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 | 655 |
station->m_minstrelTable[i].prevNumRateAttempt = station->m_minstrelTable[i].numRateAttempt; |
656 |
station->m_minstrelTable[i].prevNumRateSuccess = station->m_minstrelTable[i].numRateSuccess; |
|
657 |
station->m_minstrelTable[i].numRateSuccess = 0; |
|
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 | 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 | 667 |
station->m_minstrelTable[i].adjustedRetryCount = station->m_minstrelTable[i].retryCount >> 1; |
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 | 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 | 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 | 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 | 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 | 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 | 691 |
NS_LOG_DEBUG ("throughput" << station->m_minstrelTable[i].throughput << |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 719 |
station->m_maxTpRate = index_max_tp; |
720 |
station->m_maxTpRate2 = index_max_tp2; |
|
721 |
station->m_maxProbRate = index_max_prob; |
|
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 | 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 | 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 | 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 | 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 | 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 | 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 | 742 |
station->m_minstrelTable[i].numRateAttempt = 0; |
743 |
station->m_minstrelTable[i].numRateSuccess = 0; |
|
744 |
station->m_minstrelTable[i].prob = 0; |
|
745 |
station->m_minstrelTable[i].ewmaProb = 0; |
|
746 |
station->m_minstrelTable[i].prevNumRateAttempt = 0; |
|
747 |
station->m_minstrelTable[i].prevNumRateSuccess = 0; |
|
748 |
station->m_minstrelTable[i].successHist = 0; |
|
749 |
station->m_minstrelTable[i].attemptHist = 0; |
|
750 |
station->m_minstrelTable[i].throughput = 0; |
|
751 |
station->m_minstrelTable[i].perfectTxTime = GetCalcTxTime (GetSupported (station, i)); |
|
752 |
station->m_minstrelTable[i].retryCount = 1; |
|
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 796 |
uint32_t numSampleRates = GetNSupported (station); |
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 | 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 | 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 | 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 | 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 | 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 | 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 |