LEFT | RIGHT |
(no file at all) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2014 Universidad de la República - Uruguay | 3 * Copyright (c) 2014 Universidad de la República - Uruguay |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 25 matching lines...) Expand all Loading... |
36 * information required by the APARF Wifi manager | 36 * information required by the APARF Wifi manager |
37 */ | 37 */ |
38 struct | 38 struct |
39 AparfWifiRemoteStation : public WifiRemoteStation | 39 AparfWifiRemoteStation : public WifiRemoteStation |
40 { | 40 { |
41 uint32_t m_nSuccess; //!< Number of successful transmission a
ttempts. | 41 uint32_t m_nSuccess; //!< Number of successful transmission a
ttempts. |
42 uint32_t m_nFailed; //!< Number of failed transmission attem
pts. | 42 uint32_t m_nFailed; //!< Number of failed transmission attem
pts. |
43 uint32_t m_pCount; //!< Number of power changes. | 43 uint32_t m_pCount; //!< Number of power changes. |
44 uint32_t m_successThreshold; //!< The minimum number of successful tr
ansmissions to try a new power or rate. | 44 uint32_t m_successThreshold; //!< The minimum number of successful tr
ansmissions to try a new power or rate. |
45 uint32_t m_failThreshold; //!< The minimum number of failed transm
issions to try a new power or rate. | 45 uint32_t m_failThreshold; //!< The minimum number of failed transm
issions to try a new power or rate. |
46 uint32_t m_rate; //!< Current rate. | 46 uint32_t m_prevRateIndex; //!< Rate index of the previous transmis
sion. |
47 uint32_t m_rateCrit; //!< Critical rate. | 47 uint32_t m_rateIndex; //!< Current rate index. |
48 uint8_t m_power; //!< Current power. | 48 uint32_t m_critRateIndex; //!< Critical rate. |
| 49 uint8_t m_prevPowerLevel; //!< Power level of the previous transmi
ssion. |
| 50 uint8_t m_powerLevel; //!< Current power level. |
49 uint32_t m_nSupported; //!< Number of supported rates by the re
mote station. | 51 uint32_t m_nSupported; //!< Number of supported rates by the re
mote station. |
50 bool m_initialized; //!< For initializing variables. | 52 bool m_initialized; //!< For initializing variables. |
51 AparfWifiManager::State m_aparfState; //!< The estimated state of the channel. | 53 AparfWifiManager::State m_aparfState; //!< The estimated state of the channel. |
52 }; | 54 }; |
53 | 55 |
54 NS_OBJECT_ENSURE_REGISTERED (AparfWifiManager); | 56 NS_OBJECT_ENSURE_REGISTERED (AparfWifiManager); |
55 | 57 |
56 TypeId | 58 TypeId |
57 AparfWifiManager::GetTypeId (void) | 59 AparfWifiManager::GetTypeId (void) |
58 { | 60 { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 AparfWifiRemoteStation *station = new AparfWifiRemoteStation (); | 139 AparfWifiRemoteStation *station = new AparfWifiRemoteStation (); |
138 | 140 |
139 station->m_successThreshold = m_succesMax1; | 141 station->m_successThreshold = m_succesMax1; |
140 station->m_failThreshold = m_failMax; | 142 station->m_failThreshold = m_failMax; |
141 station->m_nSuccess = 0; | 143 station->m_nSuccess = 0; |
142 station->m_nFailed = 0; | 144 station->m_nFailed = 0; |
143 station->m_pCount = 0; | 145 station->m_pCount = 0; |
144 station->m_aparfState = AparfWifiManager::High; | 146 station->m_aparfState = AparfWifiManager::High; |
145 station->m_initialized = false; | 147 station->m_initialized = false; |
146 | 148 |
147 NS_LOG_DEBUG ("create station=" << station << ", rate=" << station->m_rate | 149 NS_LOG_DEBUG ("create station=" << station << ", rate=" << station->m_rateInde
x |
148 << ", power=" << (int)station->m_power); | 150 << ", power=" << (int)station->m_powerLevel); |
149 | 151 |
150 return station; | 152 return station; |
151 } | 153 } |
152 | 154 |
153 void | 155 void |
154 AparfWifiManager::CheckInit (AparfWifiRemoteStation *station) | 156 AparfWifiManager::CheckInit (AparfWifiRemoteStation *station) |
155 { | 157 { |
156 if (!station->m_initialized) | 158 if (!station->m_initialized) |
157 { | 159 { |
158 station->m_nSupported = GetNSupported (station); | 160 station->m_nSupported = GetNSupported (station); |
159 station->m_rate = station->m_nSupported - 1; | 161 station->m_rateIndex = station->m_nSupported - 1; |
160 station->m_power = m_maxPower; | 162 station->m_prevRateIndex = station->m_nSupported - 1; |
161 station->m_rateCrit = 0; | 163 station->m_powerLevel = m_maxPower; |
162 m_powerChange (station->m_power, station->m_state->m_address); | 164 station->m_prevPowerLevel = m_maxPower; |
163 m_rateChange (station->m_rate, station->m_state->m_address); | 165 station->m_critRateIndex = 0; |
| 166 WifiMode mode = GetSupported (station, station->m_rateIndex); |
| 167 uint8_t channelWidth = GetChannelWidth(station); |
| 168 DataRate rate = DataRate (mode.GetDataRate(channelWidth)); |
| 169 double power = GetPhy ()->GetPowerDbm (m_maxPower); |
| 170 m_powerChange (power, power, station->m_state->m_address); |
| 171 m_rateChange (rate, rate, station->m_state->m_address); |
164 station->m_initialized = true; | 172 station->m_initialized = true; |
165 } | 173 } |
166 } | 174 } |
167 | 175 |
168 void AparfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) | 176 void AparfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
169 { | 177 { |
170 NS_LOG_FUNCTION (this << station); | 178 NS_LOG_FUNCTION (this << station); |
171 } | 179 } |
172 | 180 |
173 void AparfWifiManager::DoReportDataFailed (WifiRemoteStation *st) | 181 void AparfWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
174 { | 182 { |
175 NS_LOG_FUNCTION (this << st); | 183 NS_LOG_FUNCTION (this << st); |
176 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 184 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
177 CheckInit (station); | 185 CheckInit (station); |
178 station->m_nFailed++; | 186 station->m_nFailed++; |
179 station->m_nSuccess = 0; | 187 station->m_nSuccess = 0; |
180 NS_LOG_DEBUG ("station=" << station << ", rate=" << station->m_rate | 188 NS_LOG_DEBUG ("station=" << station << ", rate=" << station->m_rateIndex |
181 << ", power=" << (int)station->m_power); | 189 << ", power=" << (int)station->m_powerLevel); |
182 | 190 |
183 if (station->m_aparfState == AparfWifiManager::Low) | 191 if (station->m_aparfState == AparfWifiManager::Low) |
184 { | 192 { |
185 station->m_aparfState = AparfWifiManager::High; | 193 station->m_aparfState = AparfWifiManager::High; |
186 station->m_successThreshold = m_succesMax1; | 194 station->m_successThreshold = m_succesMax1; |
187 } | 195 } |
188 else if (station->m_aparfState == AparfWifiManager::Spread) | 196 else if (station->m_aparfState == AparfWifiManager::Spread) |
189 { | 197 { |
190 station->m_aparfState = AparfWifiManager::Low; | 198 station->m_aparfState = AparfWifiManager::Low; |
191 station->m_successThreshold = m_succesMax2; | 199 station->m_successThreshold = m_succesMax2; |
192 } | 200 } |
193 | 201 |
194 if (station->m_nFailed == station->m_failThreshold) | 202 if (station->m_nFailed == station->m_failThreshold) |
195 { | 203 { |
196 station->m_nFailed = 0; | 204 station->m_nFailed = 0; |
197 station->m_nSuccess = 0; | 205 station->m_nSuccess = 0; |
198 station->m_pCount = 0; | 206 station->m_pCount = 0; |
199 if (station->m_power == m_maxPower) | 207 if (station->m_powerLevel == m_maxPower) |
200 { | 208 { |
201 station->m_rateCrit = station->m_rate; | 209 station->m_critRateIndex = station->m_rateIndex; |
202 if (station->m_rate != 0) | 210 if (station->m_rateIndex != 0) |
203 { | 211 { |
204 NS_LOG_DEBUG ("station=" << station << " dec rate"); | 212 NS_LOG_DEBUG ("station=" << station << " dec rate"); |
205 station->m_rate -= m_rateDec; | 213 station->m_rateIndex -= m_rateDec; |
206 m_rateChange (station->m_rate, station->m_state->m_address); | |
207 } | 214 } |
208 } | 215 } |
209 else | 216 else |
210 { | 217 { |
211 NS_LOG_DEBUG ("station=" << station << " inc power"); | 218 NS_LOG_DEBUG ("station=" << station << " inc power"); |
212 station->m_power += m_powerInc; | 219 station->m_powerLevel += m_powerInc; |
213 m_powerChange (station->m_power, station->m_state->m_address); | |
214 } | 220 } |
215 } | 221 } |
216 } | 222 } |
217 | 223 |
218 void | 224 void |
219 AparfWifiManager::DoReportRxOk (WifiRemoteStation *station, double rxSnr, WifiMo
de txMode) | 225 AparfWifiManager::DoReportRxOk (WifiRemoteStation *station, double rxSnr, WifiMo
de txMode) |
220 { | 226 { |
221 NS_LOG_FUNCTION (this << station << rxSnr << txMode); | 227 NS_LOG_FUNCTION (this << station << rxSnr << txMode); |
222 } | 228 } |
223 | 229 |
224 void | 230 void |
225 AparfWifiManager::DoReportRtsOk (WifiRemoteStation *station, double ctsSnr, | 231 AparfWifiManager::DoReportRtsOk (WifiRemoteStation *station, double ctsSnr, |
226 WifiMode ctsMode, double rtsSnr) | 232 WifiMode ctsMode, double rtsSnr) |
227 { | 233 { |
228 NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr); | 234 NS_LOG_FUNCTION (this << station << ctsSnr << ctsMode << rtsSnr); |
229 NS_LOG_DEBUG ("station=" << station << " rts ok"); | 235 NS_LOG_DEBUG ("station=" << station << " rts ok"); |
230 } | 236 } |
231 | 237 |
232 void | 238 void |
233 AparfWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, | 239 AparfWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, |
234 WifiMode ackMode, double dataSnr) | 240 WifiMode ackMode, double dataSnr) |
235 { | 241 { |
236 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); | 242 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
237 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 243 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
238 CheckInit (station); | 244 CheckInit (station); |
239 station->m_nSuccess++; | 245 station->m_nSuccess++; |
240 station->m_nFailed = 0; | 246 station->m_nFailed = 0; |
241 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_nSucc
ess << ", rate=" << station->m_rate << ", power=" << (int)station->m_power); | 247 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_nSucc
ess << ", rate=" << station->m_rateIndex << ", power=" << (int)station->m_powerL
evel); |
242 | 248 |
243 if ((station->m_aparfState == AparfWifiManager::High) && (station->m_nSuccess
>= station->m_successThreshold)) | 249 if ((station->m_aparfState == AparfWifiManager::High) && (station->m_nSuccess
>= station->m_successThreshold)) |
244 { | 250 { |
245 station->m_aparfState = AparfWifiManager::Spread; | 251 station->m_aparfState = AparfWifiManager::Spread; |
246 } | 252 } |
247 else if ((station->m_aparfState == AparfWifiManager::Low) && (station->m_nSucc
ess >= station->m_successThreshold)) | 253 else if ((station->m_aparfState == AparfWifiManager::Low) && (station->m_nSucc
ess >= station->m_successThreshold)) |
248 { | 254 { |
249 station->m_aparfState = AparfWifiManager::Spread; | 255 station->m_aparfState = AparfWifiManager::Spread; |
250 } | 256 } |
251 else if (station->m_aparfState == AparfWifiManager::Spread) | 257 else if (station->m_aparfState == AparfWifiManager::Spread) |
252 { | 258 { |
253 station->m_aparfState = AparfWifiManager::High; | 259 station->m_aparfState = AparfWifiManager::High; |
254 station->m_successThreshold = m_succesMax1; | 260 station->m_successThreshold = m_succesMax1; |
255 } | 261 } |
256 | 262 |
257 if (station->m_nSuccess == station->m_successThreshold) | 263 if (station->m_nSuccess == station->m_successThreshold) |
258 { | 264 { |
259 station->m_nSuccess = 0; | 265 station->m_nSuccess = 0; |
260 station->m_nFailed = 0; | 266 station->m_nFailed = 0; |
261 if (station->m_rate == (station->m_state->m_operationalRateSet.size () - 1
)) | 267 if (station->m_rateIndex == (station->m_state->m_operationalRateSet.size (
) - 1)) |
262 { | 268 { |
263 if (station->m_power != m_minPower) | 269 if (station->m_powerLevel != m_minPower) |
264 { | 270 { |
265 NS_LOG_DEBUG ("station=" << station << " dec power"); | 271 NS_LOG_DEBUG ("station=" << station << " dec power"); |
266 station->m_power -= m_powerDec; | 272 station->m_powerLevel -= m_powerDec; |
267 m_powerChange (station->m_power, station->m_state->m_address); | |
268 } | 273 } |
269 } | 274 } |
270 else | 275 else |
271 { | 276 { |
272 if (station->m_rateCrit == 0) | 277 if (station->m_critRateIndex == 0) |
273 { | 278 { |
274 if (station->m_rate != (station->m_state->m_operationalRateSet.siz
e () - 1)) | 279 if (station->m_rateIndex != (station->m_state->m_operationalRateSe
t.size () - 1)) |
275 { | 280 { |
276 NS_LOG_DEBUG ("station=" << station << " inc rate"); | 281 NS_LOG_DEBUG ("station=" << station << " inc rate"); |
277 station->m_rate += m_rateInc; | 282 station->m_rateIndex += m_rateInc; |
278 m_rateChange (station->m_rate, station->m_state->m_address); | |
279 } | 283 } |
280 } | 284 } |
281 else | 285 else |
282 { | 286 { |
283 if (station->m_pCount == m_powerMax) | 287 if (station->m_pCount == m_powerMax) |
284 { | 288 { |
285 station->m_power = m_maxPower; | 289 station->m_powerLevel = m_maxPower; |
286 m_powerChange (station->m_power, station->m_state->m_address); | 290 station->m_rateIndex = station->m_critRateIndex; |
287 station->m_rate = station->m_rateCrit; | |
288 m_rateChange (station->m_rate, station->m_state->m_address); | |
289 station->m_pCount = 0; | 291 station->m_pCount = 0; |
290 station->m_rateCrit = 0; | 292 station->m_critRateIndex = 0; |
291 } | 293 } |
292 else | 294 else |
293 { | 295 { |
294 if (station->m_power != m_minPower) | 296 if (station->m_powerLevel != m_minPower) |
295 { | 297 { |
296 station->m_power -= m_powerDec; | 298 station->m_powerLevel -= m_powerDec; |
297 m_powerChange (station->m_power, station->m_state->m_addre
ss); | |
298 station->m_pCount++; | 299 station->m_pCount++; |
299 } | 300 } |
300 } | 301 } |
301 } | 302 } |
302 } | 303 } |
303 } | 304 } |
304 } | 305 } |
305 | 306 |
306 void | 307 void |
307 AparfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) | 308 AparfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
(...skipping 12 matching lines...) Expand all Loading... |
320 { | 321 { |
321 NS_LOG_FUNCTION (this << st); | 322 NS_LOG_FUNCTION (this << st); |
322 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 323 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
323 uint32_t channelWidth = GetChannelWidth (station); | 324 uint32_t channelWidth = GetChannelWidth (station); |
324 if (channelWidth > 20 && channelWidth != 22) | 325 if (channelWidth > 20 && channelWidth != 22) |
325 { | 326 { |
326 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 327 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
327 channelWidth = 20; | 328 channelWidth = 20; |
328 } | 329 } |
329 CheckInit (station); | 330 CheckInit (station); |
330 WifiMode mode = GetSupported (station, station->m_rate); | 331 WifiMode mode = GetSupported (station, station->m_rateIndex); |
331 return WifiTxVector (mode, station->m_power, GetLongRetryCount (station), GetP
reambleForTransmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth, GetA
ggregation (station), false); | 332 DataRate rate = DataRate (mode.GetDataRate(channelWidth)); |
| 333 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate(channelWidth)); |
| 334 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
| 335 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); |
| 336 if (station->m_prevPowerLevel != station->m_powerLevel) |
| 337 { |
| 338 m_powerChange (prevPower, power, station->m_state->m_address); |
| 339 station->m_prevPowerLevel = station->m_powerLevel; |
| 340 } |
| 341 if (station->m_prevRateIndex != station->m_rateIndex) |
| 342 { |
| 343 m_rateChange (prevRate, rate, station->m_state->m_address); |
| 344 station->m_prevRateIndex = station->m_rateIndex; |
| 345 } |
| 346 return WifiTxVector (mode, station->m_powerLevel, GetLongRetryCount (station),
GetPreambleForTransmission (mode, GetAddress (st)), 800, 1, 1, 0, channelWidth,
GetAggregation (station), false); |
332 } | 347 } |
333 | 348 |
334 WifiTxVector | 349 WifiTxVector |
335 AparfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 350 AparfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
336 { | 351 { |
337 NS_LOG_FUNCTION (this << st); | 352 NS_LOG_FUNCTION (this << st); |
338 /// \todo we could/should implement the Arf algorithm for | 353 /// \todo we could/should implement the Arf algorithm for |
339 /// RTS only by picking a single rate within the BasicRateSet. | 354 /// RTS only by picking a single rate within the BasicRateSet. |
340 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 355 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
341 uint32_t channelWidth = GetChannelWidth (station); | 356 uint32_t channelWidth = GetChannelWidth (station); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 AparfWifiManager::SetHeSupported (bool enable) | 404 AparfWifiManager::SetHeSupported (bool enable) |
390 { | 405 { |
391 //HE is not supported by this algorithm. | 406 //HE is not supported by this algorithm. |
392 if (enable) | 407 if (enable) |
393 { | 408 { |
394 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 409 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
395 } | 410 } |
396 } | 411 } |
397 | 412 |
398 } //namespace ns3 | 413 } //namespace ns3 |
LEFT | RIGHT |