author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Thu, 14 Nov 2013 16:58:28 -0800 | |
changeset 10410 | 4d4eb8097fa3 |
parent 10139 | 17a71cd49da3 |
child 10483 | e3a02ed14587 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7141
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4334
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 |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4334
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 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
30 |
#define Min(a,b) ((a < b) ? a : b) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
31 |
#define Max(a,b) ((a > b) ? a : b) |
6065 | 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; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
45 |
|
6065 | 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 |
|
10410
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10139
diff
changeset
|
56 |
NS_OBJECT_ENSURE_REGISTERED (AarfcdWifiManager) |
4d4eb8097fa3
doxygen] Suppress "warning: Member NS_OBJECT_ENSURE_REGISTERED is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10139
diff
changeset
|
57 |
; |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
58 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
59 |
TypeId |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
60 |
AarfcdWifiManager::GetTypeId (void) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
61 |
{ |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
62 |
static TypeId tid = TypeId ("ns3::AarfcdWifiManager") |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
63 |
.SetParent<WifiRemoteStationManager> () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
64 |
.AddConstructor<AarfcdWifiManager> () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
65 |
.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
|
66 |
DoubleValue (2.0), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
67 |
MakeDoubleAccessor (&AarfcdWifiManager::m_successK), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
68 |
MakeDoubleChecker<double> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
69 |
.AddAttribute ("TimerK", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
70 |
"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
|
71 |
DoubleValue (2.0), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
72 |
MakeDoubleAccessor (&AarfcdWifiManager::m_timerK), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
73 |
MakeDoubleChecker<double> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
74 |
.AddAttribute ("MaxSuccessThreshold", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
75 |
"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
|
76 |
UintegerValue (60), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
77 |
MakeUintegerAccessor (&AarfcdWifiManager::m_maxSuccessThreshold), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
78 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
79 |
.AddAttribute ("MinTimerThreshold", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
80 |
"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
|
81 |
UintegerValue (15), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
82 |
MakeUintegerAccessor (&AarfcdWifiManager::m_minTimerThreshold), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
83 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
84 |
.AddAttribute ("MinSuccessThreshold", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
85 |
"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
|
86 |
UintegerValue (10), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
87 |
MakeUintegerAccessor (&AarfcdWifiManager::m_minSuccessThreshold), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
88 |
MakeUintegerChecker<uint32_t> ()) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
89 |
.AddAttribute ("MinRtsWnd", |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
90 |
"Minimum value for Rts window of Aarf-CD", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
91 |
UintegerValue (1), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
92 |
MakeUintegerAccessor (&AarfcdWifiManager::m_minRtsWnd), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
93 |
MakeUintegerChecker<uint32_t> ()) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
94 |
.AddAttribute ("MaxRtsWnd", |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
95 |
"Maximum value for Rts window of Aarf-CD", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
96 |
UintegerValue (40), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
97 |
MakeUintegerAccessor (&AarfcdWifiManager::m_maxRtsWnd), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
98 |
MakeUintegerChecker<uint32_t> ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
99 |
.AddAttribute ("TurnOffRtsAfterRateDecrease", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
100 |
"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
|
101 |
BooleanValue (true), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
102 |
MakeBooleanAccessor (&AarfcdWifiManager::m_turnOffRtsAfterRateDecrease), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
103 |
MakeBooleanChecker ()) |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
104 |
.AddAttribute ("TurnOnRtsAfterRateIncrease", |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
105 |
"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
|
106 |
BooleanValue (true), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
107 |
MakeBooleanAccessor (&AarfcdWifiManager::m_turnOnRtsAfterRateIncrease), |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
108 |
MakeBooleanChecker ()) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
109 |
; |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
110 |
return tid; |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
111 |
} |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
112 |
AarfcdWifiManager::AarfcdWifiManager () |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
113 |
: WifiRemoteStationManager () |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
114 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
115 |
NS_LOG_FUNCTION (this); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
116 |
} |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
117 |
AarfcdWifiManager::~AarfcdWifiManager () |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
118 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
119 |
NS_LOG_FUNCTION (this); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
120 |
} |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
121 |
WifiRemoteStation * |
6065 | 122 |
AarfcdWifiManager::DoCreateStation (void) const |
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
123 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
124 |
NS_LOG_FUNCTION (this); |
6065 | 125 |
AarfcdWifiRemoteStation *station = new AarfcdWifiRemoteStation (); |
126 |
||
127 |
// aarf fields below |
|
128 |
station->m_successThreshold = m_minSuccessThreshold; |
|
129 |
station->m_timerTimeout = m_minTimerThreshold; |
|
130 |
station->m_rate = 0; |
|
131 |
station->m_success = 0; |
|
132 |
station->m_failed = 0; |
|
133 |
station->m_recovery = false; |
|
134 |
station->m_retry = 0; |
|
135 |
station->m_timer = 0; |
|
136 |
||
137 |
// aarf-cd specific fields below |
|
138 |
station->m_rtsOn = false; |
|
139 |
station->m_rtsWnd = m_minRtsWnd; |
|
140 |
station->m_rtsCounter = 0; |
|
141 |
station->m_justModifyRate = true; |
|
142 |
station->m_haveASuccess = false; |
|
143 |
||
144 |
return station; |
|
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
145 |
} |
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
146 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
147 |
void |
6065 | 148 |
AarfcdWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
149 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
150 |
NS_LOG_FUNCTION (this << station); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
151 |
} |
6065 | 152 |
/** |
153 |
* It is important to realize that "recovery" mode starts after failure of |
|
154 |
* the first transmission after a rate increase and ends at the first successful |
|
155 |
* transmission. Specifically, recovery mode transcends retransmissions boundaries. |
|
156 |
* Fundamentally, ARF handles each data transmission independently, whether it |
|
157 |
* is the initial transmission of a packet or the retransmission of a packet. |
|
158 |
* The fundamental reason for this is that there is a backoff between each data |
|
159 |
* transmission, be it an initial transmission or a retransmission. |
|
160 |
*/ |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
161 |
void |
6065 | 162 |
AarfcdWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
163 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
164 |
NS_LOG_FUNCTION (this << st); |
6065 | 165 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *)st; |
166 |
station->m_timer++; |
|
167 |
station->m_failed++; |
|
168 |
station->m_retry++; |
|
169 |
station->m_success = 0; |
|
170 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
171 |
if (!station->m_rtsOn) |
6065 | 172 |
{ |
173 |
TurnOnRts (station); |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
174 |
if (!station->m_justModifyRate && !station->m_haveASuccess) |
6065 | 175 |
{ |
176 |
IncreaseRtsWnd (station); |
|
177 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
178 |
else |
6065 | 179 |
{ |
180 |
ResetRtsWnd (station); |
|
181 |
} |
|
182 |
station->m_rtsCounter = station->m_rtsWnd; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
183 |
if (station->m_retry >= 2) |
6065 | 184 |
{ |
185 |
station->m_timer = 0; |
|
186 |
} |
|
187 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
188 |
else if (station->m_recovery) |
6065 | 189 |
{ |
190 |
NS_ASSERT (station->m_retry >= 1); |
|
191 |
station->m_justModifyRate = false; |
|
192 |
station->m_rtsCounter = station->m_rtsWnd; |
|
193 |
if (station->m_retry == 1) |
|
194 |
{ |
|
195 |
// need recovery fallback |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
196 |
if (m_turnOffRtsAfterRateDecrease) |
6065 | 197 |
{ |
198 |
TurnOffRts (station); |
|
199 |
} |
|
200 |
station->m_justModifyRate = true; |
|
201 |
station->m_successThreshold = (int)(Min (station->m_successThreshold * m_successK, |
|
202 |
m_maxSuccessThreshold)); |
|
203 |
station->m_timerTimeout = (int)(Max (station->m_timerTimeout * m_timerK, |
|
204 |
m_minSuccessThreshold)); |
|
205 |
if (station->m_rate != 0) |
|
206 |
{ |
|
207 |
station->m_rate--; |
|
208 |
} |
|
209 |
} |
|
210 |
station->m_timer = 0; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
211 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
212 |
else |
6065 | 213 |
{ |
214 |
NS_ASSERT (station->m_retry >= 1); |
|
215 |
station->m_justModifyRate = false; |
|
216 |
station->m_rtsCounter = station->m_rtsWnd; |
|
217 |
if (((station->m_retry - 1) % 2) == 1) |
|
218 |
{ |
|
219 |
// need normal fallback |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
220 |
if (m_turnOffRtsAfterRateDecrease) |
6065 | 221 |
{ |
222 |
TurnOffRts (station); |
|
223 |
} |
|
224 |
station->m_justModifyRate = true; |
|
225 |
station->m_timerTimeout = m_minTimerThreshold; |
|
226 |
station->m_successThreshold = m_minSuccessThreshold; |
|
227 |
if (station->m_rate != 0) |
|
228 |
{ |
|
229 |
station->m_rate--; |
|
230 |
} |
|
231 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
232 |
if (station->m_retry >= 2) |
6065 | 233 |
{ |
234 |
station->m_timer = 0; |
|
235 |
} |
|
236 |
} |
|
237 |
CheckRts (station); |
|
238 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
239 |
void |
6065 | 240 |
AarfcdWifiManager::DoReportRxOk (WifiRemoteStation *station, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
241 |
double rxSnr, WifiMode txMode) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
242 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
243 |
NS_LOG_FUNCTION (this << station << rxSnr << txMode); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
244 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
245 |
void |
6065 | 246 |
AarfcdWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
247 |
double ctsSnr, WifiMode ctsMode, double rtsSnr) |
6065 | 248 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
249 |
NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); |
6065 | 250 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
251 |
NS_LOG_DEBUG ("station=" << station << " rts ok"); |
|
252 |
station->m_rtsCounter--; |
|
253 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
254 |
void |
6065 | 255 |
AarfcdWifiManager::DoReportDataOk (WifiRemoteStation *st, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
256 |
double ackSnr, WifiMode ackMode, double dataSnr) |
6065 | 257 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
258 |
NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
6065 | 259 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
260 |
station->m_timer++; |
|
261 |
station->m_success++; |
|
262 |
station->m_failed = 0; |
|
263 |
station->m_recovery = false; |
|
264 |
station->m_retry = 0; |
|
265 |
station->m_justModifyRate = false; |
|
266 |
station->m_haveASuccess = true; |
|
267 |
NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer); |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
268 |
if ((station->m_success == station->m_successThreshold |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
269 |
|| station->m_timer == station->m_timerTimeout) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
270 |
&& (station->m_rate < (GetNSupported (station) - 1))) |
6065 | 271 |
{ |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
272 |
NS_LOG_DEBUG ("station=" << station << " inc rate"); |
6065 | 273 |
station->m_rate++; |
274 |
station->m_timer = 0; |
|
275 |
station->m_success = 0; |
|
276 |
station->m_recovery = true; |
|
277 |
station->m_justModifyRate = true; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
278 |
if (m_turnOnRtsAfterRateIncrease) |
6065 | 279 |
{ |
280 |
TurnOnRts (station); |
|
281 |
ResetRtsWnd (station); |
|
282 |
station->m_rtsCounter = station->m_rtsWnd; |
|
283 |
} |
|
284 |
} |
|
285 |
CheckRts (station); |
|
286 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
287 |
void |
6065 | 288 |
AarfcdWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
289 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
290 |
NS_LOG_FUNCTION (this << station); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
291 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
292 |
void |
6065 | 293 |
AarfcdWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
294 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
295 |
NS_LOG_FUNCTION (this << station); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
296 |
} |
6065 | 297 |
|
10139 | 298 |
WifiTxVector |
299 |
AarfcdWifiManager::DoGetDataTxVector (WifiRemoteStation *st, uint32_t size) |
|
6065 | 300 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
301 |
NS_LOG_FUNCTION (this << st << size); |
6065 | 302 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
10139 | 303 |
return WifiTxVector (GetSupported (station, station->m_rate), GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntennas (station), GetStbc (station)); |
6065 | 304 |
} |
10139 | 305 |
WifiTxVector |
306 |
AarfcdWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
|
6065 | 307 |
{ |
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
308 |
NS_LOG_FUNCTION (this << st); |
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9705
diff
changeset
|
309 |
/// \todo we could/should implement the Aarf algorithm for |
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9705
diff
changeset
|
310 |
/// RTS only by picking a single rate within the BasicRateSet. |
6065 | 311 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
10139 | 312 |
return WifiTxVector (GetSupported (station, 0), GetDefaultTxPowerLevel (), GetShortRetryCount (station), GetShortGuardInterval (station), Min (GetNumberOfReceiveAntennas (station),GetNumberOfTransmitAntennas()), GetNumberOfTransmitAntennas (station), GetStbc (station)); |
6065 | 313 |
} |
314 |
||
315 |
bool |
|
316 |
AarfcdWifiManager::DoNeedRts (WifiRemoteStation *st, |
|
317 |
Ptr<const Packet> packet, bool normally) |
|
318 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
319 |
NS_LOG_FUNCTION (this << st << packet << normally); |
6065 | 320 |
AarfcdWifiRemoteStation *station = (AarfcdWifiRemoteStation *) st; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
321 |
NS_LOG_INFO ("" << station << " rate=" << station->m_rate << " rts=" << (station->m_rtsOn ? "RTS" : "BASIC") << |
6065 | 322 |
" rtsCounter=" << station->m_rtsCounter); |
323 |
return station->m_rtsOn; |
|
324 |
} |
|
325 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
326 |
bool |
6065 | 327 |
AarfcdWifiManager::IsLowLatency (void) const |
328 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
329 |
NS_LOG_FUNCTION (this); |
6065 | 330 |
return true; |
331 |
} |
|
332 |
||
333 |
void |
|
334 |
AarfcdWifiManager::CheckRts (AarfcdWifiRemoteStation *station) |
|
335 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
336 |
NS_LOG_FUNCTION (this << station); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
337 |
if (station->m_rtsCounter == 0 && station->m_rtsOn) |
6065 | 338 |
{ |
339 |
TurnOffRts (station); |
|
340 |
} |
|
341 |
} |
|
342 |
||
343 |
void |
|
344 |
AarfcdWifiManager::TurnOffRts (AarfcdWifiRemoteStation *station) |
|
345 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
346 |
NS_LOG_FUNCTION (this << station); |
6065 | 347 |
station->m_rtsOn = false; |
348 |
station->m_haveASuccess = false; |
|
349 |
} |
|
350 |
||
351 |
void |
|
352 |
AarfcdWifiManager::TurnOnRts (AarfcdWifiRemoteStation *station) |
|
353 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
354 |
NS_LOG_FUNCTION (this << station); |
6065 | 355 |
station->m_rtsOn = true; |
356 |
} |
|
357 |
||
358 |
void |
|
359 |
AarfcdWifiManager::IncreaseRtsWnd (AarfcdWifiRemoteStation *station) |
|
360 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
361 |
NS_LOG_FUNCTION (this << station); |
6065 | 362 |
if (station->m_rtsWnd == m_maxRtsWnd) |
363 |
{ |
|
364 |
return; |
|
365 |
} |
|
366 |
||
367 |
station->m_rtsWnd *= 2; |
|
368 |
if (station->m_rtsWnd > m_maxRtsWnd) |
|
369 |
{ |
|
370 |
station->m_rtsWnd = m_maxRtsWnd; |
|
371 |
} |
|
372 |
} |
|
373 |
||
374 |
void |
|
375 |
AarfcdWifiManager::ResetRtsWnd (AarfcdWifiRemoteStation *station) |
|
376 |
{ |
|
9705
43fa2408aa05
Partially clean up function logging of wifi module.
Edvin Močibob <edvin.mocibob@gmail.com>
parents:
7385
diff
changeset
|
377 |
NS_LOG_FUNCTION (this << station); |
6065 | 378 |
station->m_rtsWnd = m_minRtsWnd; |
379 |
} |
|
380 |
||
381 |
||
4334
12b3fcf84fc5
bug 536: aarf-cd rate control
Federico Maguolo <maguolof@dei.unipd.it>
parents:
diff
changeset
|
382 |
} // namespace ns3 |