author | Lalith Suresh <suresh.lalith@gmail.com> |
Fri, 04 Mar 2011 01:26:54 +0000 | |
changeset 6852 | 8f1a53d3f6ca |
parent 6848 | src/devices/wifi/model/aarfcd-wifi-manager.cc@1f453ad50ef3 |
child 7141 | 072fb225b714 |
permissions | -rw-r--r-- |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
2 |
/* |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
3 |
* Copyright (c) 2004,2005,2006 INRIA |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
4 |
* |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
8 |
* |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
13 |
* |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
17 |
* |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
18 |
* Author: Federico Maguolo <maguolof@dei.unipd.it> |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
19 |
*/ |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
20 |
|
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
21 |
#include "aarfcd-wifi-manager.h" |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
22 |
#include "ns3/assert.h" |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
23 |
#include "ns3/log.h" |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
24 |
#include "ns3/simulator.h" |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
25 |
#include "ns3/boolean.h" |
6065 | 26 |
#include "ns3/double.h" |
27 |
#include "ns3/uinteger.h" |
|
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
28 |
#include <algorithm> |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
29 |
|
6065 | 30 |
#define Min(a,b) ((a<b)?a:b) |
31 |
#define Max(a,b) ((a>b)?a:b) |
|
32 |
||
4336
6886a39dfc47
coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4334
diff
changeset
|
33 |
NS_LOG_COMPONENT_DEFINE ("Aarfcd"); |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
34 |
|
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
35 |
namespace ns3 { |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
36 |
|
6065 | 37 |
struct AarfcdWifiRemoteStation : public WifiRemoteStation |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
38 |
{ |
6065 | 39 |
uint32_t m_timer; |
40 |
uint32_t m_success; |
|
41 |
uint32_t m_failed; |
|
42 |
bool m_recovery; |
|
43 |
bool m_justModifyRate; |
|
44 |
uint32_t m_retry; |
|
45 |
||
46 |
uint32_t m_successThreshold; |
|
47 |
uint32_t m_timerTimeout; |
|
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
48 |
|
6065 | 49 |
uint32_t m_rate; |
50 |
bool m_rtsOn; |
|
51 |
uint32_t m_rtsWnd; |
|
52 |
uint32_t m_rtsCounter; |
|
53 |
bool m_haveASuccess; |
|
54 |
}; |
|
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
55 |
|
6065 | 56 |
NS_OBJECT_ENSURE_REGISTERED(AarfcdWifiManager); |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
57 |
|
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
58 |
TypeId |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
59 |
AarfcdWifiManager::GetTypeId (void) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
60 |
{ |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
61 |
static TypeId tid = TypeId ("ns3::AarfcdWifiManager") |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
62 |
.SetParent<WifiRemoteStationManager> () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
63 |
.AddConstructor<AarfcdWifiManager> () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
64 |
.AddAttribute ("SuccessK", "Multiplication factor for the success threshold in the AARF algorithm.", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
65 |
DoubleValue (2.0), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
66 |
MakeDoubleAccessor (&AarfcdWifiManager::m_successK), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
67 |
MakeDoubleChecker<double> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
68 |
.AddAttribute ("TimerK", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
69 |
"Multiplication factor for the timer threshold in the AARF algorithm.", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
70 |
DoubleValue (2.0), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
71 |
MakeDoubleAccessor (&AarfcdWifiManager::m_timerK), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
72 |
MakeDoubleChecker<double> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
73 |
.AddAttribute ("MaxSuccessThreshold", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
74 |
"Maximum value of the success threshold in the AARF algorithm.", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
75 |
UintegerValue (60), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
76 |
MakeUintegerAccessor (&AarfcdWifiManager::m_maxSuccessThreshold), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
77 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
78 |
.AddAttribute ("MinTimerThreshold", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
79 |
"The minimum value for the 'timer' threshold in the AARF algorithm.", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
80 |
UintegerValue (15), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
81 |
MakeUintegerAccessor (&AarfcdWifiManager::m_minTimerThreshold), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
82 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
83 |
.AddAttribute ("MinSuccessThreshold", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
84 |
"The minimum value for the success threshold in the AARF algorithm.", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
85 |
UintegerValue (10), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
86 |
MakeUintegerAccessor (&AarfcdWifiManager::m_minSuccessThreshold), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
87 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
88 |
.AddAttribute ("MinRtsWnd", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
89 |
"Minimum value for Rts window of Aarf-CD", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
90 |
UintegerValue (1), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
91 |
MakeUintegerAccessor (&AarfcdWifiManager::m_minRtsWnd), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
92 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
93 |
.AddAttribute ("MaxRtsWnd", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
94 |
"Maximum value for Rts window of Aarf-CD", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
95 |
UintegerValue (40), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
96 |
MakeUintegerAccessor (&AarfcdWifiManager::m_maxRtsWnd), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
97 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
98 |
.AddAttribute ("TurnOffRtsAfterRateDecrease", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
99 |
"If true the RTS mechanism will be turned off when the rate will be decreased", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
100 |
BooleanValue (true), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
101 |
MakeBooleanAccessor (&AarfcdWifiManager::m_turnOffRtsAfterRateDecrease), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
102 |
MakeBooleanChecker ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
103 |
.AddAttribute ("TurnOnRtsAfterRateIncrease", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
104 |
"If true the RTS mechanism will be turned on when the rate will be increased", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
105 |
BooleanValue (true), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
106 |
MakeBooleanAccessor (&AarfcdWifiManager::m_turnOnRtsAfterRateIncrease), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
107 |
MakeBooleanChecker ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
108 |
; |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
109 |
return tid; |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
110 |
} |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
111 |
AarfcdWifiManager::AarfcdWifiManager () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
112 |
: WifiRemoteStationManager () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
113 |
{} |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
114 |
AarfcdWifiManager::~AarfcdWifiManager () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
115 |
{} |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
116 |
WifiRemoteStation * |
6065 | 117 |
AarfcdWifiManager::DoCreateStation (void) const |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
118 |
{ |
6065 | 119 |
AarfcdWifiRemoteStation *station = new AarfcdWifiRemoteStation (); |
120 |
||
121 |
// aarf fields below |
|
122 |
station->m_successThreshold = m_minSuccessThreshold; |
|
123 |
station->m_timerTimeout = m_minTimerThreshold; |
|
124 |
station->m_rate = 0; |
|
125 |
station->m_success = 0; |
|
126 |
station->m_failed = 0; |
|
127 |
station->m_recovery = false; |
|
128 |
station->m_retry = 0; |
|
129 |
station->m_timer = 0; |
|
130 |
||
131 |
// aarf-cd specific fields below |
|
132 |
station->m_rtsOn = false; |
|
133 |
station->m_rtsWnd = m_minRtsWnd; |
|
134 |
station->m_rtsCounter = 0; |
|
135 |
station->m_justModifyRate = true; |
|
136 |
station->m_haveASuccess = false; |
|
137 |
||
138 |
return station; |
|
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
139 |
} |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
140 |
|
6065 | 141 |
void |
142 |
AarfcdWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
|
143 |
{} |
|
144 |
/** |
|
145 |
* It is important to realize that "recovery" mode starts after failure of |
|
146 |
* the first transmission after a rate increase and ends at the first successful |
|
147 |
* transmission. Specifically, recovery mode transcends retransmissions boundaries. |
|
148 |
* Fundamentally, ARF handles each data transmission independently, whether it |
|
149 |
* is the initial transmission of a packet or the retransmission of a packet. |
|
150 |
* The fundamental reason for this is that there is a backoff between each data |
|
151 |
* transmission, be it an initial transmission or a retransmission. |
|
152 |
*/ |
|
153 |
void |
|
154 |
AarfcdWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
|
155 |
{ |
|
156 |
||
157 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *)st; |
|
158 |
station->m_timer++; |
|
159 |
station->m_failed++; |
|
160 |
station->m_retry++; |
|
161 |
station->m_success = 0; |
|
162 |
||
163 |
if (!station->m_rtsOn) |
|
164 |
{ |
|
165 |
TurnOnRts (station); |
|
166 |
if (!station->m_justModifyRate && !station->m_haveASuccess) |
|
167 |
{ |
|
168 |
IncreaseRtsWnd (station); |
|
169 |
} |
|
170 |
else |
|
171 |
{ |
|
172 |
ResetRtsWnd (station); |
|
173 |
} |
|
174 |
station->m_rtsCounter = station->m_rtsWnd; |
|
175 |
if (station->m_retry >= 2) |
|
176 |
{ |
|
177 |
station->m_timer = 0; |
|
178 |
} |
|
179 |
} |
|
180 |
else if (station->m_recovery) |
|
181 |
{ |
|
182 |
NS_ASSERT (station->m_retry >= 1); |
|
183 |
station->m_justModifyRate = false; |
|
184 |
station->m_rtsCounter = station->m_rtsWnd; |
|
185 |
if (station->m_retry == 1) |
|
186 |
{ |
|
187 |
// need recovery fallback |
|
188 |
if (m_turnOffRtsAfterRateDecrease) |
|
189 |
{ |
|
190 |
TurnOffRts (station); |
|
191 |
} |
|
192 |
station->m_justModifyRate = true; |
|
193 |
station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK, |
|
194 |
m_maxSuccessThreshold)); |
|
195 |
station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK, |
|
196 |
m_minSuccessThreshold)); |
|
197 |
if (station->m_rate != 0) |
|
198 |
{ |
|
199 |
station->m_rate--; |
|
200 |
} |
|
201 |
} |
|
202 |
station->m_timer = 0; |
|
203 |
} |
|
204 |
else |
|
205 |
{ |
|
206 |
NS_ASSERT (station->m_retry >= 1); |
|
207 |
station->m_justModifyRate = false; |
|
208 |
station->m_rtsCounter = station->m_rtsWnd; |
|
209 |
if (((station->m_retry - 1) % 2) == 1) |
|
210 |
{ |
|
211 |
// need normal fallback |
|
212 |
if (m_turnOffRtsAfterRateDecrease) |
|
213 |
{ |
|
214 |
TurnOffRts (station); |
|
215 |
} |
|
216 |
station->m_justModifyRate = true; |
|
217 |
station->m_timerTimeout = m_minTimerThreshold; |
|
218 |
station->m_successThreshold = m_minSuccessThreshold; |
|
219 |
if (station->m_rate != 0) |
|
220 |
{ |
|
221 |
station->m_rate--; |
|
222 |
} |
|
223 |
} |
|
224 |
if (station->m_retry >= 2) |
|
225 |
{ |
|
226 |
station->m_timer = 0; |
|
227 |
} |
|
228 |
} |
|
229 |
CheckRts (station); |
|
230 |
} |
|
231 |
void |
|
232 |
AarfcdWifiManager::DoReportRxOk (WifiRemoteStation *station, |
|
233 |
double rxSnr, WifiMode txMode) |
|
234 |
{} |
|
235 |
void |
|
236 |
AarfcdWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
|
237 |
double ctsSnr, WifiMode ctsMode, double rtsSnr) |
|
238 |
{ |
|
239 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
|
240 |
NS_LOG_DEBUG ("station=" << station << " rts ok"); |
|
241 |
station->m_rtsCounter--; |
|
242 |
} |
|
243 |
void |
|
244 |
AarfcdWifiManager::DoReportDataOk (WifiRemoteStation *st, |
|
245 |
double ackSnr, WifiMode ackMode, double dataSnr) |
|
246 |
{ |
|
247 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
|
248 |
station->m_timer++; |
|
249 |
station->m_success++; |
|
250 |
station->m_failed = 0; |
|
251 |
station->m_recovery = false; |
|
252 |
station->m_retry = 0; |
|
253 |
station->m_justModifyRate = false; |
|
254 |
station->m_haveASuccess = true; |
|
255 |
NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer); |
|
256 |
if ((station->m_success == station->m_successThreshold || |
|
257 |
station->m_timer == station->m_timerTimeout) && |
|
258 |
(station->m_rate < (GetNSupported (station) - 1))) |
|
259 |
{ |
|
260 |
NS_LOG_DEBUG ("station="<<station<<" inc rate"); |
|
261 |
station->m_rate++; |
|
262 |
station->m_timer = 0; |
|
263 |
station->m_success = 0; |
|
264 |
station->m_recovery = true; |
|
265 |
station->m_justModifyRate = true; |
|
266 |
if (m_turnOnRtsAfterRateIncrease) |
|
267 |
{ |
|
268 |
TurnOnRts (station); |
|
269 |
ResetRtsWnd (station); |
|
270 |
station->m_rtsCounter = station->m_rtsWnd; |
|
271 |
} |
|
272 |
} |
|
273 |
CheckRts (station); |
|
274 |
} |
|
275 |
void |
|
276 |
AarfcdWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
|
277 |
{} |
|
278 |
void |
|
279 |
AarfcdWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
|
280 |
{} |
|
281 |
||
282 |
WifiMode |
|
283 |
AarfcdWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) |
|
284 |
{ |
|
285 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
|
286 |
return GetSupported (station, station->m_rate); |
|
287 |
} |
|
288 |
WifiMode |
|
289 |
AarfcdWifiManager::DoGetRtsMode (WifiRemoteStation *st) |
|
290 |
{ |
|
291 |
// XXX: we could/should implement the Aarf algorithm for |
|
292 |
// RTS only by picking a single rate within the BasicRateSet. |
|
293 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
|
294 |
return GetSupported (station, 0); |
|
295 |
} |
|
296 |
||
297 |
bool |
|
298 |
AarfcdWifiManager::DoNeedRts (WifiRemoteStation *st, |
|
299 |
Ptr<const Packet> packet, bool normally) |
|
300 |
{ |
|
301 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
|
302 |
NS_LOG_INFO ("" << station << " rate=" << station->m_rate << " rts=" << (station->m_rtsOn?"RTS":"BASIC") << |
|
303 |
" rtsCounter=" << station->m_rtsCounter); |
|
304 |
return station->m_rtsOn; |
|
305 |
} |
|
306 |
||
307 |
bool |
|
308 |
AarfcdWifiManager::IsLowLatency (void) const |
|
309 |
{ |
|
310 |
return true; |
|
311 |
} |
|
312 |
||
313 |
void |
|
314 |
AarfcdWifiManager::CheckRts (AarfcdWifiRemoteStation *station) |
|
315 |
{ |
|
316 |
if (station->m_rtsCounter == 0 && station->m_rtsOn) |
|
317 |
{ |
|
318 |
TurnOffRts (station); |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
void |
|
323 |
AarfcdWifiManager::TurnOffRts (AarfcdWifiRemoteStation *station) |
|
324 |
{ |
|
325 |
station->m_rtsOn = false; |
|
326 |
station->m_haveASuccess = false; |
|
327 |
} |
|
328 |
||
329 |
void |
|
330 |
AarfcdWifiManager::TurnOnRts (AarfcdWifiRemoteStation *station) |
|
331 |
{ |
|
332 |
station->m_rtsOn = true; |
|
333 |
} |
|
334 |
||
335 |
void |
|
336 |
AarfcdWifiManager::IncreaseRtsWnd (AarfcdWifiRemoteStation *station) |
|
337 |
{ |
|
338 |
if (station->m_rtsWnd == m_maxRtsWnd) |
|
339 |
{ |
|
340 |
return; |
|
341 |
} |
|
342 |
||
343 |
station->m_rtsWnd *= 2; |
|
344 |
if (station->m_rtsWnd > m_maxRtsWnd) |
|
345 |
{ |
|
346 |
station->m_rtsWnd = m_maxRtsWnd; |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
void |
|
351 |
AarfcdWifiManager::ResetRtsWnd (AarfcdWifiRemoteStation *station) |
|
352 |
{ |
|
353 |
station->m_rtsWnd = m_minRtsWnd; |
|
354 |
} |
|
355 |
||
356 |
||
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
357 |
} // namespace ns3 |