LEFT | RIGHT |
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) 2017 Universidad de la República - Uruguay | 3 * Copyright (c) 2017 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Matías Richart <mrichart@fing.edu.uy> | 18 * Author: Matías Richart <mrichart@fing.edu.uy> |
19 */ | 19 */ |
20 | 20 |
21 #include "rrpaa-wifi-manager.h" | 21 #include "ns3/packet.h" |
22 #include "yans-wifi-phy.h" | |
23 #include "wifi-phy.h" | |
24 #include "wifi-mac.h" | |
25 #include "ns3/assert.h" | |
26 #include "ns3/log.h" | 22 #include "ns3/log.h" |
27 #include "ns3/boolean.h" | 23 #include "ns3/boolean.h" |
28 #include "ns3/double.h" | 24 #include "ns3/double.h" |
29 #include "ns3/uinteger.h" | 25 #include "ns3/uinteger.h" |
30 #include "ns3/simulator.h" | 26 #include "ns3/simulator.h" |
31 #include <cmath> | 27 #include "ns3/data-rate.h" |
| 28 #include "rrpaa-wifi-manager.h" |
| 29 #include "wifi-phy.h" |
| 30 #include "wifi-mac.h" |
32 | 31 |
33 NS_LOG_COMPONENT_DEFINE ("RrpaaWifiManager"); | 32 NS_LOG_COMPONENT_DEFINE ("RrpaaWifiManager"); |
34 | 33 |
35 namespace ns3 { | 34 namespace ns3 { |
36 | 35 |
37 /** | 36 /** |
38 * Hold per-remote-station state for RRPAA Wifi manager. | 37 * Hold per-remote-station state for RRPAA Wifi manager. |
39 * | 38 * |
40 * This struct extends from WifiRemoteStation struct to hold additional | 39 * This struct extends from WifiRemoteStation struct to hold additional |
41 * information required by the APARF Wifi manager | 40 * information required by the APARF Wifi manager |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 //Note: we appear to be doing late initialization of the table | 236 //Note: we appear to be doing late initialization of the table |
238 //to make sure that the set of supported rates has been initialized | 237 //to make sure that the set of supported rates has been initialized |
239 //before we perform our own initialization. | 238 //before we perform our own initialization. |
240 station->m_nRate = GetNSupported (station); | 239 station->m_nRate = GetNSupported (station); |
241 //Initialize at minimal rate and maximal power. | 240 //Initialize at minimal rate and maximal power. |
242 station->m_prevRateIndex = 0; | 241 station->m_prevRateIndex = 0; |
243 station->m_rateIndex = 0; | 242 station->m_rateIndex = 0; |
244 station->m_prevPowerLevel = m_maxPowerLevel; | 243 station->m_prevPowerLevel = m_maxPowerLevel; |
245 station->m_powerLevel = m_maxPowerLevel; | 244 station->m_powerLevel = m_maxPowerLevel; |
246 WifiMode mode = GetSupported (station, 0); | 245 WifiMode mode = GetSupported (station, 0); |
247 uint8_t channelWidth = GetChannelWidth (station); | 246 uint16_t channelWidth = GetChannelWidth (station); |
248 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); | 247 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); |
249 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); | 248 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
250 m_rateChange (rate, rate, station->m_state->m_address); | 249 m_rateChange (rate, rate, station->m_state->m_address); |
251 m_powerChange (power, power, station->m_state->m_address); | 250 m_powerChange (power, power, station->m_state->m_address); |
252 | 251 |
253 station->m_pdTable = RrpaaProbabilitiesTable (station->m_nRate, std::vecto
r<double> (m_nPowerLevels)); | 252 station->m_pdTable = RrpaaProbabilitiesTable (station->m_nRate, std::vecto
r<double> (m_nPowerLevels)); |
254 NS_LOG_DEBUG ("Initializing pdTable"); | 253 NS_LOG_DEBUG ("Initializing pdTable"); |
255 for (uint8_t i = 0; i < station->m_nRate; i++) | 254 for (uint8_t i = 0; i < station->m_nRate; i++) |
256 { | 255 { |
257 for (uint8_t j = 0; j < m_nPowerLevels; j++) | 256 for (uint8_t j = 0; j < m_nPowerLevels; j++) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 RrpaaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) | 368 RrpaaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
370 { | 369 { |
371 NS_LOG_FUNCTION (this << st); | 370 NS_LOG_FUNCTION (this << st); |
372 } | 371 } |
373 | 372 |
374 WifiTxVector | 373 WifiTxVector |
375 RrpaaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 374 RrpaaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
376 { | 375 { |
377 NS_LOG_FUNCTION (this << st); | 376 NS_LOG_FUNCTION (this << st); |
378 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; | 377 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; |
379 uint8_t channelWidth = GetChannelWidth (station); | 378 uint16_t channelWidth = GetChannelWidth (station); |
380 if (channelWidth > 20 && channelWidth != 22) | 379 if (channelWidth > 20 && channelWidth != 22) |
381 { | 380 { |
382 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 381 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
383 channelWidth = 20; | 382 channelWidth = 20; |
384 } | 383 } |
385 CheckInit (station); | 384 CheckInit (station); |
386 WifiMode mode = GetSupported (station, station->m_rateIndex); | 385 WifiMode mode = GetSupported (station, station->m_rateIndex); |
387 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); | 386 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); |
388 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (channelWidth)); | 387 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (channelWidth)); |
389 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); | 388 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
390 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); | 389 double prevPower = GetPhy ()->GetPowerDbm (station->m_prevPowerLevel); |
391 if (station->m_prevRateIndex != station->m_rateIndex) | 390 if (station->m_prevRateIndex != station->m_rateIndex) |
392 { | 391 { |
393 m_rateChange (prevRate, rate, station->m_state->m_address); | 392 m_rateChange (prevRate, rate, station->m_state->m_address); |
394 station->m_prevRateIndex = station->m_rateIndex; | 393 station->m_prevRateIndex = station->m_rateIndex; |
395 } | 394 } |
396 if (station->m_prevPowerLevel != station->m_powerLevel) | 395 if (station->m_prevPowerLevel != station->m_powerLevel) |
397 { | 396 { |
398 m_powerChange (prevPower, power, station->m_state->m_address); | 397 m_powerChange (prevPower, power, station->m_state->m_address); |
399 station->m_prevPowerLevel = station->m_powerLevel; | 398 station->m_prevPowerLevel = station->m_powerLevel; |
400 } | 399 } |
401 return WifiTxVector (mode, station->m_powerLevel, GetPreambleForTransmission (
mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station
), false); | 400 return WifiTxVector (mode, station->m_powerLevel, GetPreambleForTransmission (
mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (station
), false); |
402 } | 401 } |
403 WifiTxVector | 402 WifiTxVector |
404 RrpaaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 403 RrpaaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
405 { | 404 { |
406 NS_LOG_FUNCTION (this << st); | 405 NS_LOG_FUNCTION (this << st); |
407 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; | 406 RrpaaWifiRemoteStation *station = (RrpaaWifiRemoteStation *) st; |
408 uint8_t channelWidth = GetChannelWidth (station); | 407 uint16_t channelWidth = GetChannelWidth (station); |
409 if (channelWidth > 20 && channelWidth != 22) | 408 if (channelWidth > 20 && channelWidth != 22) |
410 { | 409 { |
411 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 410 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
412 channelWidth = 20; | 411 channelWidth = 20; |
413 } | 412 } |
414 WifiTxVector rtsTxVector; | 413 WifiTxVector rtsTxVector; |
415 WifiMode mode; | 414 WifiMode mode; |
416 if (GetUseNonErpProtection () == false) | 415 if (GetUseNonErpProtection () == false) |
417 { | 416 { |
418 mode = GetSupported (station, 0); | 417 mode = GetSupported (station, 0); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 RrpaaWifiManager::SetHeSupported (bool enable) | 624 RrpaaWifiManager::SetHeSupported (bool enable) |
626 { | 625 { |
627 //HE is not supported by this algorithm. | 626 //HE is not supported by this algorithm. |
628 if (enable) | 627 if (enable) |
629 { | 628 { |
630 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 629 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
631 } | 630 } |
632 } | 631 } |
633 | 632 |
634 } // namespace ns3 | 633 } // namespace ns3 |
LEFT | RIGHT |