author | Vedran Miletić <rivanvx@gmail.com> |
Tue, 02 Aug 2011 17:42:33 -0400 | |
changeset 7385 | 10beb0e53130 |
parent 7141 | 072fb225b714 |
child 9705 | 43fa2408aa05 |
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; -*- */ |
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2004,2005,2006 INRIA |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
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 |
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
21 |
#include "arf-wifi-manager.h" |
1917
d781597e35c0
port ArfMacStations to new MacStation API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1895
diff
changeset
|
22 |
#include "ns3/assert.h" |
2004
59eb6fb7b722
control the rate control algorithms with default values.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1997
diff
changeset
|
23 |
#include "ns3/log.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
24 |
#include "ns3/uinteger.h" |
2004
59eb6fb7b722
control the rate control algorithms with default values.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1997
diff
changeset
|
25 |
|
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2545
diff
changeset
|
26 |
NS_LOG_COMPONENT_DEFINE ("ns3::ArfWifiManager"); |
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
namespace ns3 { |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
|
6065 | 31 |
struct ArfWifiRemoteStation : public WifiRemoteStation |
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
{ |
6065 | 33 |
uint32_t m_timer; |
34 |
uint32_t m_success; |
|
35 |
uint32_t m_failed; |
|
36 |
bool m_recovery; |
|
37 |
uint32_t m_retry; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
38 |
|
6065 | 39 |
uint32_t m_timerTimeout; |
40 |
uint32_t m_successThreshold; |
|
2269
06c660ffc070
add MacStation::ReportFinal* methods for onoe rate control model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2268
diff
changeset
|
41 |
|
6065 | 42 |
uint32_t m_rate; |
43 |
}; |
|
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
45 |
NS_OBJECT_ENSURE_REGISTERED (ArfWifiManager); |
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
47 |
TypeId |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
48 |
ArfWifiManager::GetTypeId (void) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
49 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2545
diff
changeset
|
50 |
static TypeId tid = TypeId ("ns3::ArfWifiManager") |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
51 |
.SetParent<WifiRemoteStationManager> () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
52 |
.AddConstructor<ArfWifiManager> () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
53 |
.AddAttribute ("TimerThreshold", "The 'timer' threshold in the ARF algorithm.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2784
diff
changeset
|
54 |
UintegerValue (15), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
55 |
MakeUintegerAccessor (&ArfWifiManager::m_timerThreshold), |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
56 |
MakeUintegerChecker<uint32_t> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
57 |
.AddAttribute ("SuccessThreshold", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
58 |
"The minimum number of sucessfull transmissions to try a new rate.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2784
diff
changeset
|
59 |
UintegerValue (10), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
60 |
MakeUintegerAccessor (&ArfWifiManager::m_successThreshold), |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
61 |
MakeUintegerChecker<uint32_t> ()) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
62 |
; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
63 |
return tid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
64 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
65 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
66 |
ArfWifiManager::ArfWifiManager () |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
67 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
68 |
} |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
69 |
ArfWifiManager::~ArfWifiManager () |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
70 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
71 |
} |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2269
diff
changeset
|
72 |
WifiRemoteStation * |
6065 | 73 |
ArfWifiManager::DoCreateStation (void) const |
74 |
{ |
|
75 |
ArfWifiRemoteStation *station = new ArfWifiRemoteStation (); |
|
76 |
||
77 |
station->m_successThreshold = m_successThreshold; |
|
78 |
station->m_timerTimeout = m_timerThreshold; |
|
79 |
station->m_rate = 0; |
|
80 |
station->m_success = 0; |
|
81 |
station->m_failed = 0; |
|
82 |
station->m_recovery = false; |
|
83 |
station->m_retry = 0; |
|
84 |
station->m_timer = 0; |
|
85 |
||
86 |
return station; |
|
87 |
} |
|
88 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
89 |
void |
6065 | 90 |
ArfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
91 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
92 |
} |
6065 | 93 |
/** |
94 |
* It is important to realize that "recovery" mode starts after failure of |
|
95 |
* the first transmission after a rate increase and ends at the first successful |
|
96 |
* transmission. Specifically, recovery mode transcends retransmissions boundaries. |
|
97 |
* Fundamentally, ARF handles each data transmission independently, whether it |
|
98 |
* is the initial transmission of a packet or the retransmission of a packet. |
|
99 |
* The fundamental reason for this is that there is a backoff between each data |
|
100 |
* transmission, be it an initial transmission or a retransmission. |
|
101 |
*/ |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
102 |
void |
6065 | 103 |
ArfWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
104 |
{ |
6065 | 105 |
ArfWifiRemoteStation *station = (ArfWifiRemoteStation *)st; |
106 |
station->m_timer++; |
|
107 |
station->m_failed++; |
|
108 |
station->m_retry++; |
|
109 |
station->m_success = 0; |
|
110 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
111 |
if (station->m_recovery) |
6065 | 112 |
{ |
113 |
NS_ASSERT (station->m_retry >= 1); |
|
114 |
if (station->m_retry == 1) |
|
115 |
{ |
|
116 |
// need recovery fallback |
|
117 |
if (station->m_rate != 0) |
|
118 |
{ |
|
119 |
station->m_rate--; |
|
120 |
} |
|
121 |
} |
|
122 |
station->m_timer = 0; |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
123 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
124 |
else |
6065 | 125 |
{ |
126 |
NS_ASSERT (station->m_retry >= 1); |
|
127 |
if (((station->m_retry - 1) % 2) == 1) |
|
128 |
{ |
|
129 |
// need normal fallback |
|
130 |
if (station->m_rate != 0) |
|
131 |
{ |
|
132 |
station->m_rate--; |
|
133 |
} |
|
134 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
135 |
if (station->m_retry >= 2) |
6065 | 136 |
{ |
137 |
station->m_timer = 0; |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
141 |
void |
6065 | 142 |
ArfWifiManager::DoReportRxOk (WifiRemoteStation *station, |
143 |
double rxSnr, WifiMode txMode) |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
144 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
145 |
} |
6065 | 146 |
void ArfWifiManager::DoReportRtsOk (WifiRemoteStation *station, |
147 |
double ctsSnr, WifiMode ctsMode, double rtsSnr) |
|
148 |
{ |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
149 |
NS_LOG_DEBUG ("station=" << station << " rts ok"); |
6065 | 150 |
} |
151 |
void ArfWifiManager::DoReportDataOk (WifiRemoteStation *st, |
|
152 |
double ackSnr, WifiMode ackMode, double dataSnr) |
|
153 |
{ |
|
154 |
ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |
|
155 |
station->m_timer++; |
|
156 |
station->m_success++; |
|
157 |
station->m_failed = 0; |
|
158 |
station->m_recovery = false; |
|
159 |
station->m_retry = 0; |
|
160 |
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
|
161 |
if ((station->m_success == m_successThreshold |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
162 |
|| station->m_timer == m_timerThreshold) |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
163 |
&& (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1))) |
6065 | 164 |
{ |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
165 |
NS_LOG_DEBUG ("station=" << station << " inc rate"); |
6065 | 166 |
station->m_rate++; |
167 |
station->m_timer = 0; |
|
168 |
station->m_success = 0; |
|
169 |
station->m_recovery = true; |
|
170 |
} |
|
171 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
172 |
void |
6065 | 173 |
ArfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
174 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
175 |
} |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
176 |
void |
6065 | 177 |
ArfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
178 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
179 |
} |
6065 | 180 |
|
181 |
WifiMode |
|
182 |
ArfWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) |
|
183 |
{ |
|
184 |
ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |
|
185 |
return GetSupported (station, station->m_rate); |
|
186 |
} |
|
187 |
WifiMode |
|
188 |
ArfWifiManager::DoGetRtsMode (WifiRemoteStation *st) |
|
189 |
{ |
|
190 |
// XXX: we could/should implement the Arf algorithm for |
|
191 |
// RTS only by picking a single rate within the BasicRateSet. |
|
192 |
ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |
|
193 |
return GetSupported (station, 0); |
|
194 |
} |
|
195 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
196 |
bool |
6065 | 197 |
ArfWifiManager::IsLowLatency (void) const |
198 |
{ |
|
199 |
return true; |
|
1895
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
200 |
} |
6c2d6a5631bc
add more files to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
201 |
|
1917
d781597e35c0
port ArfMacStations to new MacStation API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1895
diff
changeset
|
202 |
} // namespace ns3 |