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) 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_prevRateIndex; //!< Rate index of the previous transmis
sion. | 46 uint8_t m_prevRateIndex; //!< Rate index of the previous transmis
sion. |
47 uint32_t m_rateIndex; //!< Current rate index. | 47 uint8_t m_rateIndex; //!< Current rate index. |
48 uint32_t m_critRateIndex; //!< Critical rate. | 48 uint8_t m_critRateIndex; //!< Critical rate. |
49 uint8_t m_prevPowerLevel; //!< Power level of the previous transmi
ssion. | 49 uint8_t m_prevPowerLevel; //!< Power level of the previous transmi
ssion. |
50 uint8_t m_powerLevel; //!< Current power level. | 50 uint8_t m_powerLevel; //!< Current power level. |
51 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. |
52 bool m_initialized; //!< For initializing variables. | 52 bool m_initialized; //!< For initializing variables. |
53 AparfWifiManager::State m_aparfState; //!< The estimated state of the channel. | 53 AparfWifiManager::State m_aparfState; //!< The estimated state of the channel. |
54 }; | 54 }; |
55 | 55 |
56 NS_OBJECT_ENSURE_REGISTERED (AparfWifiManager); | 56 NS_OBJECT_ENSURE_REGISTERED (AparfWifiManager); |
57 | 57 |
58 TypeId | 58 TypeId |
(...skipping 20 matching lines...) Expand all Loading... |
79 MakeUintegerChecker<uint32_t> ()) | 79 MakeUintegerChecker<uint32_t> ()) |
80 .AddAttribute ("PowerThreshold", | 80 .AddAttribute ("PowerThreshold", |
81 "The maximum number of power changes.", | 81 "The maximum number of power changes.", |
82 UintegerValue (10), | 82 UintegerValue (10), |
83 MakeUintegerAccessor (&AparfWifiManager::m_powerMax), | 83 MakeUintegerAccessor (&AparfWifiManager::m_powerMax), |
84 MakeUintegerChecker<uint32_t> ()) | 84 MakeUintegerChecker<uint32_t> ()) |
85 .AddAttribute ("PowerDecrementStep", | 85 .AddAttribute ("PowerDecrementStep", |
86 "Step size for decrement the power.", | 86 "Step size for decrement the power.", |
87 UintegerValue (1), | 87 UintegerValue (1), |
88 MakeUintegerAccessor (&AparfWifiManager::m_powerDec), | 88 MakeUintegerAccessor (&AparfWifiManager::m_powerDec), |
89 MakeUintegerChecker<uint32_t> ()) | 89 MakeUintegerChecker<uint8_t> ()) |
90 .AddAttribute ("PowerIncrementStep", | 90 .AddAttribute ("PowerIncrementStep", |
91 "Step size for increment the power.", | 91 "Step size for increment the power.", |
92 UintegerValue (1), | 92 UintegerValue (1), |
93 MakeUintegerAccessor (&AparfWifiManager::m_powerInc), | 93 MakeUintegerAccessor (&AparfWifiManager::m_powerInc), |
94 MakeUintegerChecker<uint32_t> ()) | 94 MakeUintegerChecker<uint8_t> ()) |
95 .AddAttribute ("RateDecrementStep", | 95 .AddAttribute ("RateDecrementStep", |
96 "Step size for decrement the rate.", | 96 "Step size for decrement the rate.", |
97 UintegerValue (1), | 97 UintegerValue (1), |
98 MakeUintegerAccessor (&AparfWifiManager::m_rateDec), | 98 MakeUintegerAccessor (&AparfWifiManager::m_rateDec), |
99 MakeUintegerChecker<uint32_t> ()) | 99 MakeUintegerChecker<uint8_t> ()) |
100 .AddAttribute ("RateIncrementStep", | 100 .AddAttribute ("RateIncrementStep", |
101 "Step size for increment the rate.", | 101 "Step size for increment the rate.", |
102 UintegerValue (1), | 102 UintegerValue (1), |
103 MakeUintegerAccessor (&AparfWifiManager::m_rateInc), | 103 MakeUintegerAccessor (&AparfWifiManager::m_rateInc), |
104 MakeUintegerChecker<uint32_t> ()) | 104 MakeUintegerChecker<uint8_t> ()) |
105 .AddTraceSource ("PowerChange", | 105 .AddTraceSource ("PowerChange", |
106 "The transmission power has change", | 106 "The transmission power has change", |
107 MakeTraceSourceAccessor (&AparfWifiManager::m_powerChange), | 107 MakeTraceSourceAccessor (&AparfWifiManager::m_powerChange), |
108 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback") | 108 "ns3::WifiRemoteStationManager::PowerChangeTracedCallback") |
109 .AddTraceSource ("RateChange", | 109 .AddTraceSource ("RateChange", |
110 "The transmission rate has change", | 110 "The transmission rate has change", |
111 MakeTraceSourceAccessor (&AparfWifiManager::m_rateChange), | 111 MakeTraceSourceAccessor (&AparfWifiManager::m_rateChange), |
112 "ns3::WifiRemoteStationManager::RateChangeTracedCallback") | 112 "ns3::WifiRemoteStationManager::RateChangeTracedCallback") |
113 ; | 113 ; |
114 return tid; | 114 return tid; |
115 } | 115 } |
116 | 116 |
117 AparfWifiManager::AparfWifiManager () | 117 AparfWifiManager::AparfWifiManager () |
118 { | 118 { |
119 NS_LOG_FUNCTION (this); | 119 NS_LOG_FUNCTION (this); |
120 } | 120 } |
121 | 121 |
122 AparfWifiManager::~AparfWifiManager () | 122 AparfWifiManager::~AparfWifiManager () |
123 { | 123 { |
124 NS_LOG_FUNCTION (this); | 124 NS_LOG_FUNCTION (this); |
125 } | 125 } |
126 | 126 |
127 void | 127 void |
128 AparfWifiManager::SetupPhy (const Ptr<WifiPhy> phy) | 128 AparfWifiManager::SetupPhy (const Ptr<WifiPhy> phy) |
129 { | 129 { |
130 m_minPower = static_cast<uint32_t>(phy->GetTxPowerStart ()); | 130 m_minPower = static_cast<uint8_t>(phy->GetTxPowerStart ()); |
131 m_maxPower = static_cast<uint32_t>(phy->GetTxPowerEnd ()); | 131 m_maxPower = static_cast<uint8_t>(phy->GetTxPowerEnd ()); |
132 WifiRemoteStationManager::SetupPhy (phy); | 132 WifiRemoteStationManager::SetupPhy (phy); |
133 } | 133 } |
134 | 134 |
135 WifiRemoteStation * | 135 WifiRemoteStation * |
136 AparfWifiManager::DoCreateStation (void) const | 136 AparfWifiManager::DoCreateStation (void) const |
137 { | 137 { |
138 NS_LOG_FUNCTION (this); | 138 NS_LOG_FUNCTION (this); |
139 AparfWifiRemoteStation *station = new AparfWifiRemoteStation (); | 139 AparfWifiRemoteStation *station = new AparfWifiRemoteStation (); |
140 | 140 |
141 station->m_successThreshold = m_succesMax1; | 141 station->m_successThreshold = m_succesMax1; |
142 station->m_failThreshold = m_failMax; | 142 station->m_failThreshold = m_failMax; |
143 station->m_nSuccess = 0; | 143 station->m_nSuccess = 0; |
144 station->m_nFailed = 0; | 144 station->m_nFailed = 0; |
145 station->m_pCount = 0; | 145 station->m_pCount = 0; |
146 station->m_aparfState = AparfWifiManager::High; | 146 station->m_aparfState = AparfWifiManager::High; |
147 station->m_initialized = false; | 147 station->m_initialized = false; |
148 | 148 |
149 NS_LOG_DEBUG ("create station=" << station << ", rate=" << station->m_rateInde
x | 149 NS_LOG_DEBUG ("create station=" << station << ", rate=" << station->m_rateInde
x |
150 << ", power=" << (int)station->m_powerLevel); | 150 << ", power=" << station->m_powerLevel); |
151 | 151 |
152 return station; | 152 return station; |
153 } | 153 } |
154 | 154 |
155 void | 155 void |
156 AparfWifiManager::CheckInit (AparfWifiRemoteStation *station) | 156 AparfWifiManager::CheckInit (AparfWifiRemoteStation *station) |
157 { | 157 { |
158 if (!station->m_initialized) | 158 if (!station->m_initialized) |
159 { | 159 { |
160 station->m_nSupported = GetNSupported (station); | 160 station->m_nSupported = GetNSupported (station); |
161 station->m_rateIndex = station->m_nSupported - 1; | 161 station->m_rateIndex = static_cast<uint8_t> (station->m_nSupported - 1); |
162 station->m_prevRateIndex = station->m_nSupported - 1; | 162 station->m_prevRateIndex = station->m_rateIndex; |
163 station->m_powerLevel = static_cast<uint8_t>(m_maxPower); | 163 station->m_powerLevel = static_cast<uint8_t>(m_maxPower); |
164 station->m_prevPowerLevel = static_cast<uint8_t>(m_maxPower); | 164 station->m_prevPowerLevel = station->m_powerLevel; |
165 station->m_critRateIndex = 0; | 165 station->m_critRateIndex = 0; |
166 WifiMode mode = GetSupported (station, station->m_rateIndex); | 166 WifiMode mode = GetSupported (station, station->m_rateIndex); |
167 uint8_t channelWidth = GetChannelWidth (station); | 167 uint8_t channelWidth = GetChannelWidth (station); |
168 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); | 168 DataRate rate = DataRate (mode.GetDataRate (channelWidth)); |
169 double power = GetPhy ()->GetPowerDbm (static_cast<uint8_t>(m_maxPower)); | 169 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
170 m_powerChange (power, power, station->m_state->m_address); | 170 m_powerChange (power, power, station->m_state->m_address); |
171 m_rateChange (rate, rate, station->m_state->m_address); | 171 m_rateChange (rate, rate, station->m_state->m_address); |
172 station->m_initialized = true; | 172 station->m_initialized = true; |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 void AparfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) | 176 void AparfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
177 { | 177 { |
178 NS_LOG_FUNCTION (this << station); | 178 NS_LOG_FUNCTION (this << station); |
179 } | 179 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 void | 238 void |
239 AparfWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, | 239 AparfWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, |
240 WifiMode ackMode, double dataSnr) | 240 WifiMode ackMode, double dataSnr) |
241 { | 241 { |
242 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); | 242 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
243 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 243 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
244 CheckInit (station); | 244 CheckInit (station); |
245 station->m_nSuccess++; | 245 station->m_nSuccess++; |
246 station->m_nFailed = 0; | 246 station->m_nFailed = 0; |
247 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_nSucc
ess << ", rate=" << station->m_rateIndex << ", power=" << (int)station->m_powerL
evel); | 247 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_nSucc
ess << ", rate=" << static_cast<uint16_t>(station->m_rateIndex) << ", power=" <<
static_cast<uint16_t>(station->m_powerLevel)); |
248 | 248 |
249 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)) |
250 { | 250 { |
251 station->m_aparfState = AparfWifiManager::Spread; | 251 station->m_aparfState = AparfWifiManager::Spread; |
252 } | 252 } |
253 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)) |
254 { | 254 { |
255 station->m_aparfState = AparfWifiManager::Spread; | 255 station->m_aparfState = AparfWifiManager::Spread; |
256 } | 256 } |
257 else if (station->m_aparfState == AparfWifiManager::Spread) | 257 else if (station->m_aparfState == AparfWifiManager::Spread) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 AparfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) | 314 AparfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
315 { | 315 { |
316 NS_LOG_FUNCTION (this << station); | 316 NS_LOG_FUNCTION (this << station); |
317 } | 317 } |
318 | 318 |
319 WifiTxVector | 319 WifiTxVector |
320 AparfWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 320 AparfWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
321 { | 321 { |
322 NS_LOG_FUNCTION (this << st); | 322 NS_LOG_FUNCTION (this << st); |
323 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 323 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
324 uint32_t channelWidth = GetChannelWidth (station); | 324 uint8_t channelWidth = GetChannelWidth (station); |
325 if (channelWidth > 20 && channelWidth != 22) | 325 if (channelWidth > 20 && channelWidth != 22) |
326 { | 326 { |
327 //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 |
328 channelWidth = 20; | 328 channelWidth = 20; |
329 } | 329 } |
330 CheckInit (station); | 330 CheckInit (station); |
331 WifiMode mode = GetSupported (station, station->m_rateIndex); | 331 WifiMode mode = GetSupported (station, station->m_rateIndex); |
332 DataRate rate = DataRate (mode.GetDataRate (static_cast<uint8_t>(channelWidth)
)); | 332 DataRate rate = DataRate (mode.GetDataRate (static_cast<uint8_t>(channelWidth)
)); |
333 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (static_cast<uint8_t>(channelWidth))); | 333 DataRate prevRate = DataRate (GetSupported (station, station->m_prevRateIndex)
.GetDataRate (static_cast<uint8_t>(channelWidth))); |
334 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); | 334 double power = GetPhy ()->GetPowerDbm (station->m_powerLevel); |
(...skipping 11 matching lines...) Expand all Loading... |
346 return WifiTxVector (mode, station->m_powerLevel, static_cast<uint8_t>(GetLong
RetryCount (station)), GetPreambleForTransmission (mode, GetAddress (st)), 800,
1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 346 return WifiTxVector (mode, station->m_powerLevel, static_cast<uint8_t>(GetLong
RetryCount (station)), GetPreambleForTransmission (mode, GetAddress (st)), 800,
1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); |
347 } | 347 } |
348 | 348 |
349 WifiTxVector | 349 WifiTxVector |
350 AparfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 350 AparfWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
351 { | 351 { |
352 NS_LOG_FUNCTION (this << st); | 352 NS_LOG_FUNCTION (this << st); |
353 /// \todo we could/should implement the Arf algorithm for | 353 /// \todo we could/should implement the Arf algorithm for |
354 /// RTS only by picking a single rate within the BasicRateSet. | 354 /// RTS only by picking a single rate within the BasicRateSet. |
355 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; | 355 AparfWifiRemoteStation *station = (AparfWifiRemoteStation *) st; |
356 uint32_t channelWidth = GetChannelWidth (station); | 356 uint8_t channelWidth = GetChannelWidth (station); |
357 if (channelWidth > 20 && channelWidth != 22) | 357 if (channelWidth > 20 && channelWidth != 22) |
358 { | 358 { |
359 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 359 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
360 channelWidth = 20; | 360 channelWidth = 20; |
361 } | 361 } |
362 WifiTxVector rtsTxVector; | 362 WifiTxVector rtsTxVector; |
363 WifiMode mode; | 363 WifiMode mode; |
364 if (GetUseNonErpProtection () == false) | 364 if (GetUseNonErpProtection () == false) |
365 { | 365 { |
366 mode = GetSupported (station, 0); | 366 mode = GetSupported (station, 0); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 AparfWifiManager::SetHeSupported (bool enable) | 404 AparfWifiManager::SetHeSupported (bool enable) |
405 { | 405 { |
406 //HE is not supported by this algorithm. | 406 //HE is not supported by this algorithm. |
407 if (enable) | 407 if (enable) |
408 { | 408 { |
409 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 409 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 } //namespace ns3 | 413 } //namespace ns3 |
LEFT | RIGHT |