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) 2006 INRIA | 3 * Copyright (c) 2006 INRIA |
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
| 21 #include "ns3/log.h" |
21 #include "ideal-wifi-manager.h" | 22 #include "ideal-wifi-manager.h" |
22 #include "wifi-phy.h" | 23 #include "wifi-phy.h" |
23 #include "ns3/log.h" | |
24 | 24 |
25 namespace ns3 { | 25 namespace ns3 { |
26 | 26 |
27 /** | 27 /** |
28 * \brief hold per-remote-station state for Ideal Wifi manager. | 28 * \brief hold per-remote-station state for Ideal Wifi manager. |
29 * | 29 * |
30 * This struct extends from WifiRemoteStation struct to hold additional | 30 * This struct extends from WifiRemoteStation struct to hold additional |
31 * information required by the Ideal Wifi manager | 31 * information required by the Ideal Wifi manager |
32 */ | 32 */ |
33 struct IdealWifiRemoteStation : public WifiRemoteStation | 33 struct IdealWifiRemoteStation : public WifiRemoteStation |
34 { | 34 { |
35 double m_lastSnrObserved; //!< SNR of most recently reported packet sent to t
he remote station | 35 double m_lastSnrObserved; //!< SNR of most recently reported packet sent to t
he remote station |
36 double m_lastSnrCached; //!< SNR most recently used to select a rate | 36 double m_lastSnrCached; //!< SNR most recently used to select a rate |
37 double m_nss; //!< SNR most recently used to select a rate | 37 uint8_t m_nss; //!< Number of spacial streams |
38 WifiMode m_lastMode; //!< Mode most recently used to the remote station | 38 WifiMode m_lastMode; //!< Mode most recently used to the remote station |
39 }; | 39 }; |
40 | 40 |
41 /// To avoid using the cache before a valid value has been cached | 41 /// To avoid using the cache before a valid value has been cached |
42 static const double CACHE_INITIAL_VALUE = -100; | 42 static const double CACHE_INITIAL_VALUE = -100; |
43 | 43 |
44 NS_OBJECT_ENSURE_REGISTERED (IdealWifiManager); | 44 NS_OBJECT_ENSURE_REGISTERED (IdealWifiManager); |
45 | 45 |
46 NS_LOG_COMPONENT_DEFINE ("IdealWifiManager"); | 46 NS_LOG_COMPONENT_DEFINE ("IdealWifiManager"); |
47 | 47 |
(...skipping 13 matching lines...) Expand all Loading... |
61 "Traced value for rate changes (b/s)", | 61 "Traced value for rate changes (b/s)", |
62 MakeTraceSourceAccessor (&IdealWifiManager::m_currentRate), | 62 MakeTraceSourceAccessor (&IdealWifiManager::m_currentRate), |
63 "ns3::TracedValueCallback::Uint64") | 63 "ns3::TracedValueCallback::Uint64") |
64 ; | 64 ; |
65 return tid; | 65 return tid; |
66 } | 66 } |
67 | 67 |
68 IdealWifiManager::IdealWifiManager () | 68 IdealWifiManager::IdealWifiManager () |
69 : m_currentRate (0) | 69 : m_currentRate (0) |
70 { | 70 { |
| 71 NS_LOG_FUNCTION (this); |
71 } | 72 } |
72 | 73 |
73 IdealWifiManager::~IdealWifiManager () | 74 IdealWifiManager::~IdealWifiManager () |
74 { | 75 { |
| 76 NS_LOG_FUNCTION (this); |
75 } | 77 } |
76 | 78 |
77 void | 79 void |
78 IdealWifiManager::SetupPhy (const Ptr<WifiPhy> phy) | 80 IdealWifiManager::SetupPhy (const Ptr<WifiPhy> phy) |
79 { | 81 { |
80 NS_LOG_FUNCTION (this << phy); | 82 NS_LOG_FUNCTION (this << phy); |
81 WifiRemoteStationManager::SetupPhy (phy); | 83 WifiRemoteStationManager::SetupPhy (phy); |
82 } | 84 } |
83 | 85 |
84 uint8_t | 86 uint16_t |
85 IdealWifiManager::GetChannelWidthForMode (WifiMode mode) const | 87 IdealWifiManager::GetChannelWidthForMode (WifiMode mode) const |
86 { | 88 { |
87 NS_ASSERT (mode.GetModulationClass () != WIFI_MOD_CLASS_HT | 89 NS_ASSERT (mode.GetModulationClass () != WIFI_MOD_CLASS_HT |
88 && mode.GetModulationClass () != WIFI_MOD_CLASS_VHT | 90 && mode.GetModulationClass () != WIFI_MOD_CLASS_VHT |
89 && mode.GetModulationClass () != WIFI_MOD_CLASS_HE); | 91 && mode.GetModulationClass () != WIFI_MOD_CLASS_HE); |
90 if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS | 92 if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS |
91 || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) | 93 || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
92 { | 94 { |
93 return 22; | 95 return 22; |
94 } | 96 } |
95 else | 97 else |
96 { | 98 { |
97 return 20; | 99 return 20; |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
101 void | 103 void |
102 IdealWifiManager::DoInitialize () | 104 IdealWifiManager::DoInitialize () |
103 { | 105 { |
104 NS_LOG_FUNCTION (this); | 106 NS_LOG_FUNCTION (this); |
105 WifiMode mode; | 107 WifiMode mode; |
106 WifiTxVector txVector; | 108 WifiTxVector txVector; |
107 uint8_t nss = 1; | 109 uint8_t nss = 1; |
108 uint32_t nModes = GetPhy ()->GetNModes (); | 110 uint8_t nModes = GetPhy ()->GetNModes (); |
109 for (uint32_t i = 0; i < nModes; i++) | 111 for (uint8_t i = 0; i < nModes; i++) |
110 { | 112 { |
111 mode = GetPhy ()->GetMode (i); | 113 mode = GetPhy ()->GetMode (i); |
112 txVector.SetChannelWidth (GetChannelWidthForMode (mode)); | 114 txVector.SetChannelWidth (GetChannelWidthForMode (mode)); |
113 txVector.SetNss (nss); | 115 txVector.SetNss (nss); |
114 txVector.SetMode (mode); | 116 txVector.SetMode (mode); |
115 NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName ()); | 117 NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName ()); |
116 AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber)); | 118 AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber)); |
117 } | 119 } |
118 // Add all Ht and Vht MCSes | 120 // Add all Ht and Vht MCSes |
119 if (HasVhtSupported () == true || HasHtSupported () == true || HasHeSupported
() == true) | 121 if (HasVhtSupported () == true || HasHtSupported () == true || HasHeSupported
() == true) |
120 { | 122 { |
121 nModes = GetPhy ()->GetNMcs (); | 123 nModes = GetPhy ()->GetNMcs (); |
122 for (uint32_t i = 0; i < nModes; i++) | 124 for (uint8_t i = 0; i < nModes; i++) |
123 { | 125 { |
124 for (uint16_t j = 20; j <= GetPhy ()->GetChannelWidth (); j *= 2) | 126 for (uint16_t j = 20; j <= GetPhy ()->GetChannelWidth (); j *= 2) |
125 { | 127 { |
126 txVector.SetChannelWidth (j); | 128 txVector.SetChannelWidth (static_cast<uint8_t> (j)); |
127 mode = GetPhy ()->GetMcs (i); | 129 mode = GetPhy ()->GetMcs (i); |
128 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) | 130 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
129 { | 131 { |
130 uint16_t guardInterval = GetPhy ()->GetShortGuardInterval () ?
400 : 800; | 132 uint16_t guardInterval = GetPhy ()->GetShortGuardInterval () ?
400 : 800; |
131 txVector.SetGuardInterval (guardInterval); | 133 txVector.SetGuardInterval (guardInterval); |
132 //derive NSS from the MCS index | 134 //derive NSS from the MCS index |
133 nss = (mode.GetMcsValue () / 8) + 1; | 135 nss = (mode.GetMcsValue () / 8) + 1; |
134 NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueNa
me () << | 136 NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueNa
me () << |
135 " channel width " << (uint16_t) j << | 137 " channel width " << j << |
136 " nss " << (uint16_t) nss << | 138 " nss " << +nss << |
137 " GI " << guardInterval); | 139 " GI " << guardInterval); |
138 NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueN
ame ()); | 140 NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueN
ame ()); |
139 txVector.SetNss (nss); | 141 txVector.SetNss (nss); |
140 txVector.SetMode (mode); | 142 txVector.SetMode (mode); |
141 AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector,
m_ber)); | 143 AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector,
m_ber)); |
142 } | 144 } |
143 else //VHT or HE | 145 else //VHT or HE |
144 { | 146 { |
145 uint16_t guardInterval; | 147 uint16_t guardInterval; |
146 if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT) | 148 if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT) |
147 { | 149 { |
148 guardInterval = GetPhy ()->GetShortGuardInterval () ? 400
: 800; | 150 guardInterval = GetPhy ()->GetShortGuardInterval () ? 400
: 800; |
149 } | 151 } |
150 else | 152 else |
151 { | 153 { |
152 guardInterval = (uint16_t)GetPhy ()->GetGuardInterval ().G
etNanoSeconds (); | 154 guardInterval = static_cast<uint16_t> (GetPhy ()->GetGuard
Interval ().GetNanoSeconds ()); |
153 } | 155 } |
| 156 txVector.SetGuardInterval (guardInterval); |
154 for (uint8_t k = 1; k <= GetPhy ()->GetMaxSupportedTxSpatialSt
reams (); k++) | 157 for (uint8_t k = 1; k <= GetPhy ()->GetMaxSupportedTxSpatialSt
reams (); k++) |
155 { | 158 { |
156 NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniq
ueName () << | 159 NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniq
ueName () << |
157 " channel width " << (uint16_t)j << | 160 " channel width " << j << |
158 " nss " << (uint16_t)k << | 161 " nss " << +k << |
159 " GI " << guardInterval); | 162 " GI " << guardInterval); |
160 NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUni
queName ()); | 163 NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUni
queName ()); |
161 txVector.SetNss (k); | 164 txVector.SetNss (k); |
162 txVector.SetMode (mode); | 165 txVector.SetMode (mode); |
163 AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVect
or, m_ber)); | 166 AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVect
or, m_ber)); |
164 } | 167 } |
165 } | 168 } |
166 } | 169 } |
167 } | 170 } |
168 } | 171 } |
169 } | 172 } |
170 | 173 |
171 double | 174 double |
172 IdealWifiManager::GetSnrThreshold (WifiTxVector txVector) const | 175 IdealWifiManager::GetSnrThreshold (WifiTxVector txVector) const |
173 { | 176 { |
174 NS_LOG_FUNCTION (this << txVector.GetMode ().GetUniqueName ()); | 177 NS_LOG_FUNCTION (this << txVector.GetMode ().GetUniqueName ()); |
175 for (Thresholds::const_iterator i = m_thresholds.begin (); i != m_thresholds.e
nd (); i++) | 178 for (Thresholds::const_iterator i = m_thresholds.begin (); i != m_thresholds.e
nd (); i++) |
176 { | 179 { |
177 NS_LOG_DEBUG ("Checking " << i->second.GetMode ().GetUniqueName () << | 180 NS_LOG_DEBUG ("Checking " << i->second.GetMode ().GetUniqueName () << |
178 " nss " << (uint16_t) i->second.GetNss () << | 181 " nss " << +i->second.GetNss () << |
179 " GI " << i->second.GetGuardInterval () << | 182 " GI " << i->second.GetGuardInterval () << |
180 " width " << (uint16_t) i->second.GetChannelWidth ()); | 183 " width " << i->second.GetChannelWidth ()); |
181 NS_LOG_DEBUG ("against TxVector " << txVector.GetMode ().GetUniqueName ()
<< | 184 NS_LOG_DEBUG ("against TxVector " << txVector.GetMode ().GetUniqueName ()
<< |
182 " nss " << (uint16_t) txVector.GetNss () << | 185 " nss " << +txVector.GetNss () << |
183 " GI " << txVector.GetGuardInterval () << | 186 " GI " << txVector.GetGuardInterval () << |
184 " width " << (uint16_t) txVector.GetChannelWidth ()); | 187 " width " << txVector.GetChannelWidth ()); |
185 if (txVector.GetMode () == i->second.GetMode () | 188 if (txVector.GetMode () == i->second.GetMode () |
186 && txVector.GetNss () == i->second.GetNss () | 189 && txVector.GetNss () == i->second.GetNss () |
187 && txVector.GetChannelWidth () == i->second.GetChannelWidth ()) | 190 && txVector.GetChannelWidth () == i->second.GetChannelWidth ()) |
188 { | 191 { |
189 return i->first; | 192 return i->first; |
190 } | 193 } |
191 } | 194 } |
192 NS_ASSERT (false); | 195 NS_ASSERT (false); |
193 return 0.0; | 196 return 0.0; |
194 } | 197 } |
(...skipping 12 matching lines...) Expand all Loading... |
207 IdealWifiRemoteStation *station = new IdealWifiRemoteStation (); | 210 IdealWifiRemoteStation *station = new IdealWifiRemoteStation (); |
208 station->m_lastSnrObserved = 0.0; | 211 station->m_lastSnrObserved = 0.0; |
209 station->m_lastSnrCached = CACHE_INITIAL_VALUE; | 212 station->m_lastSnrCached = CACHE_INITIAL_VALUE; |
210 station->m_lastMode = GetDefaultMode (); | 213 station->m_lastMode = GetDefaultMode (); |
211 station->m_nss = 1; | 214 station->m_nss = 1; |
212 return station; | 215 return station; |
213 } | 216 } |
214 | 217 |
215 | 218 |
216 void | 219 void |
217 IdealWifiManager::DoReportRxOk (WifiRemoteStation *station, | 220 IdealWifiManager::DoReportRxOk (WifiRemoteStation *station, double rxSnr, WifiMo
de txMode) |
218 double rxSnr, WifiMode txMode) | 221 { |
219 { | 222 NS_LOG_FUNCTION (this << station << rxSnr << txMode); |
220 NS_UNUSED(station); | |
221 NS_UNUSED(rxSnr); | |
222 NS_UNUSED(txMode); | |
223 } | 223 } |
224 | 224 |
225 void | 225 void |
226 IdealWifiManager::DoReportRtsFailed (WifiRemoteStation *station) | 226 IdealWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
227 { | 227 { |
228 NS_UNUSED(station); | 228 NS_LOG_FUNCTION (this << station); |
229 } | 229 } |
230 | 230 |
231 void | 231 void |
232 IdealWifiManager::DoReportDataFailed (WifiRemoteStation *station) | 232 IdealWifiManager::DoReportDataFailed (WifiRemoteStation *station) |
233 { | 233 { |
234 NS_UNUSED(station); | 234 NS_LOG_FUNCTION (this << station); |
235 } | 235 } |
236 | 236 |
237 void | 237 void |
238 IdealWifiManager::DoReportRtsOk (WifiRemoteStation *st, | 238 IdealWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
239 double ctsSnr, WifiMode ctsMode, double rtsSnr) | 239 double ctsSnr, WifiMode ctsMode, double rtsSnr) |
240 { | 240 { |
241 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode.GetUniqueName () << rtsSnr); | 241 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode.GetUniqueName () << rtsSnr); |
242 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; | 242 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; |
243 station->m_lastSnrObserved = rtsSnr; | 243 station->m_lastSnrObserved = rtsSnr; |
244 } | 244 } |
245 | 245 |
246 void | 246 void |
247 IdealWifiManager::DoReportDataOk (WifiRemoteStation *st, | 247 IdealWifiManager::DoReportDataOk (WifiRemoteStation *st, |
248 double ackSnr, WifiMode ackMode, double dataSn
r) | 248 double ackSnr, WifiMode ackMode, double dataSn
r) |
249 { | 249 { |
250 NS_LOG_FUNCTION (this << st << ackSnr << ackMode.GetUniqueName () << dataSnr); | 250 NS_LOG_FUNCTION (this << st << ackSnr << ackMode.GetUniqueName () << dataSnr); |
251 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; | 251 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; |
252 if (dataSnr == 0) | 252 if (dataSnr == 0) |
253 { | 253 { |
254 NS_LOG_WARN ("DataSnr reported to be zero; not saving this report."); | 254 NS_LOG_WARN ("DataSnr reported to be zero; not saving this report."); |
255 return; | 255 return; |
256 } | 256 } |
257 station->m_lastSnrObserved = dataSnr; | 257 station->m_lastSnrObserved = dataSnr; |
258 } | 258 } |
259 | 259 |
260 void | 260 void |
261 IdealWifiManager::DoReportAmpduTxStatus (WifiRemoteStation *st, uint8_t nSuccess
fulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr) | 261 IdealWifiManager::DoReportAmpduTxStatus (WifiRemoteStation *st, uint8_t nSuccess
fulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr) |
262 { | 262 { |
263 NS_LOG_FUNCTION (this << st << (uint16_t)nSuccessfulMpdus << (uint16_t)nFailed
Mpdus << rxSnr << dataSnr); | 263 NS_LOG_FUNCTION (this << st << +nSuccessfulMpdus << +nFailedMpdus << rxSnr <<
dataSnr); |
264 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; | 264 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; |
265 if (dataSnr == 0) | 265 if (dataSnr == 0) |
266 { | 266 { |
267 NS_LOG_WARN ("DataSnr reported to be zero; not saving this report."); | 267 NS_LOG_WARN ("DataSnr reported to be zero; not saving this report."); |
268 return; | 268 return; |
269 } | 269 } |
270 station->m_lastSnrObserved = dataSnr; | 270 station->m_lastSnrObserved = dataSnr; |
271 } | 271 } |
272 | 272 |
273 | 273 |
274 void | 274 void |
275 IdealWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) | 275 IdealWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
276 { | 276 { |
277 NS_UNUSED(station); | 277 NS_LOG_FUNCTION (this << station); |
278 } | 278 } |
279 | 279 |
280 void | 280 void |
281 IdealWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) | 281 IdealWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
282 { | 282 { |
283 NS_UNUSED(station); | 283 NS_LOG_FUNCTION (this << station); |
284 } | 284 } |
285 | 285 |
286 WifiTxVector | 286 WifiTxVector |
287 IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 287 IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
288 { | 288 { |
289 NS_LOG_FUNCTION (this << st); | 289 NS_LOG_FUNCTION (this << st); |
290 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; | 290 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; |
291 //We search within the Supported rate set the mode with the | 291 //We search within the Supported rate set the mode with the |
292 //highest data rate for which the snr threshold is smaller than m_lastSnr | 292 //highest data rate for which the snr threshold is smaller than m_lastSnr |
293 //to ensure correct packet delivery. | 293 //to ensure correct packet delivery. |
294 WifiMode maxMode = GetDefaultMode (); | 294 WifiMode maxMode = GetDefaultMode (); |
295 WifiTxVector txVector; | 295 WifiTxVector txVector; |
296 WifiMode mode; | 296 WifiMode mode; |
297 uint64_t bestRate = 0; | 297 uint64_t bestRate = 0; |
298 uint8_t selectedNss = 1; | 298 uint8_t selectedNss = 1; |
299 uint16_t guardInterval; | 299 uint16_t guardInterval; |
300 uint8_t channelWidth = std::min (GetChannelWidth (station), GetPhy ()->GetChan
nelWidth ()); | 300 uint16_t channelWidth = std::min (GetChannelWidth (station), GetPhy ()->GetCha
nnelWidth ()); |
301 txVector.SetChannelWidth (channelWidth); | 301 txVector.SetChannelWidth (channelWidth); |
302 if (station->m_lastSnrCached != CACHE_INITIAL_VALUE && station->m_lastSnrObser
ved == station->m_lastSnrCached) | 302 if (station->m_lastSnrCached != CACHE_INITIAL_VALUE && station->m_lastSnrObser
ved == station->m_lastSnrCached) |
303 { | 303 { |
304 // SNR has not changed, so skip the search and use the last | 304 // SNR has not changed, so skip the search and use the last |
305 // mode selected | 305 // mode selected |
306 maxMode = station->m_lastMode; | 306 maxMode = station->m_lastMode; |
307 selectedNss = (uint8_t)station->m_nss; | 307 selectedNss = station->m_nss; |
308 NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () << | 308 NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () << |
309 " last snr observed " << station->m_lastSnrObserved << | 309 " last snr observed " << station->m_lastSnrObserved << |
310 " cached " << station->m_lastSnrCached << | 310 " cached " << station->m_lastSnrCached << |
311 " nss " << (uint16_t) selectedNss); | 311 " nss " << +selectedNss); |
312 } | 312 } |
313 else | 313 else |
314 { | 314 { |
315 if ((HasVhtSupported () == true || HasHtSupported () == true || HasHeSuppo
rted () == true) | 315 if ((HasVhtSupported () == true || HasHtSupported () == true || HasHeSuppo
rted () == true) |
316 && (GetHtSupported (st) == true || GetVhtSupported (st) == true || Get
HeSupported (st) == true)) | 316 && (GetHtSupported (st) == true || GetVhtSupported (st) == true || Get
HeSupported (st) == true)) |
317 { | 317 { |
318 for (uint32_t i = 0; i < GetNMcsSupported (station); i++) | 318 for (uint8_t i = 0; i < GetNMcsSupported (station); i++) |
319 { | 319 { |
320 mode = GetMcsSupported (station, i); | 320 mode = GetMcsSupported (station, i); |
321 txVector.SetMode (mode); | 321 txVector.SetMode (mode); |
322 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) | 322 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
323 { | 323 { |
324 guardInterval = (uint16_t)std::max (GetShortGuardInterval (sta
tion) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800); | 324 guardInterval = static_cast<uint16_t> (std::max (GetShortGuard
Interval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800)
); |
325 txVector.SetGuardInterval (guardInterval); | 325 txVector.SetGuardInterval (guardInterval); |
326 // If the node and peer are both VHT capable, only search VHT
modes | 326 // If the node and peer are both VHT capable, only search VHT
modes |
327 if (HasVhtSupported () && GetVhtSupported (station)) | 327 if (HasVhtSupported () && GetVhtSupported (station)) |
328 { | 328 { |
329 continue; | 329 continue; |
330 } | 330 } |
331 // If the node and peer are both HE capable, only search HE mo
des | 331 // If the node and peer are both HE capable, only search HE mo
des |
332 if (HasHeSupported () && GetHeSupported (station)) | 332 if (HasHeSupported () && GetHeSupported (station)) |
333 { | 333 { |
334 continue; | 334 continue; |
335 } | 335 } |
336 // Derive NSS from the MCS index. There is a different mode fo
r each possible NSS value. | 336 // Derive NSS from the MCS index. There is a different mode fo
r each possible NSS value. |
337 uint8_t nss = (mode.GetMcsValue () / 8) + 1; | 337 uint8_t nss = (mode.GetMcsValue () / 8) + 1; |
338 txVector.SetNss (nss); | 338 txVector.SetNss (nss); |
339 if (WifiPhy::IsValidTxVector (txVector) == false | 339 if (!txVector.IsValid () |
340 || nss > std::min (GetMaxNumberOfTransmitStreams (), GetNu
mberOfSupportedStreams (st))) | 340 || nss > std::min (GetMaxNumberOfTransmitStreams (), GetNu
mberOfSupportedStreams (st))) |
341 { | 341 { |
342 NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () << | 342 NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () << |
343 " nss " << (uint16_t) nss << " width " << | 343 " nss " << +nss << |
344 (uint16_t) txVector.GetChannelWidth ()); | 344 " width " << txVector.GetChannelWidth ()); |
345 continue; | 345 continue; |
346 } | 346 } |
347 double threshold = GetSnrThreshold (txVector); | 347 double threshold = GetSnrThreshold (txVector); |
348 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth
(), txVector.GetGuardInterval (), nss); | 348 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth
(), txVector.GetGuardInterval (), nss); |
349 NS_LOG_DEBUG ("Testing mode " << mode.GetUniqueName () << | 349 NS_LOG_DEBUG ("Testing mode " << mode.GetUniqueName () << |
350 " data rate " << dataRate << | 350 " data rate " << dataRate << |
351 " threshold " << threshold << " last snr observ
ed " << | 351 " threshold " << threshold << " last snr observ
ed " << |
352 station->m_lastSnrObserved << " cached " << | 352 station->m_lastSnrObserved << " cached " << |
353 station->m_lastSnrCached); | 353 station->m_lastSnrCached); |
354 if (dataRate > bestRate && threshold < station->m_lastSnrObser
ved) | 354 if (dataRate > bestRate && threshold < station->m_lastSnrObser
ved) |
355 { | 355 { |
356 NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName ()
<< | 356 NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName ()
<< |
357 " data rate " << dataRate << | 357 " data rate " << dataRate << |
358 " threshold " << threshold << | 358 " threshold " << threshold << |
359 " last snr observed " << | 359 " last snr observed " << |
360 station->m_lastSnrObserved); | 360 station->m_lastSnrObserved); |
361 bestRate = dataRate; | 361 bestRate = dataRate; |
362 maxMode = mode; | 362 maxMode = mode; |
363 selectedNss = nss; | 363 selectedNss = nss; |
364 } | 364 } |
365 } | 365 } |
366 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT) | 366 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT) |
367 { | 367 { |
368 guardInterval = (uint16_t)std::max (GetShortGuardInterval (sta
tion) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800); | 368 guardInterval = static_cast<uint16_t> (std::max (GetShortGuard
Interval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800)
); |
369 txVector.SetGuardInterval (guardInterval); | 369 txVector.SetGuardInterval (guardInterval); |
370 // If the node and peer are both HE capable, only search HE mo
des | 370 // If the node and peer are both HE capable, only search HE mo
des |
371 if (HasHeSupported () && GetHeSupported (station)) | 371 if (HasHeSupported () && GetHeSupported (station)) |
372 { | 372 { |
373 continue; | 373 continue; |
374 } | 374 } |
375 // If the node and peer are not both VHT capable, only search
HT modes | 375 // If the node and peer are not both VHT capable, only search
HT modes |
376 if (!HasVhtSupported () || !GetVhtSupported (station)) | 376 if (!HasVhtSupported () || !GetVhtSupported (station)) |
377 { | 377 { |
378 continue; | 378 continue; |
379 } | 379 } |
380 for (uint8_t nss = 1; nss <= std::min (GetMaxNumberOfTransmitS
treams (), GetNumberOfSupportedStreams (station)); nss++) | 380 for (uint8_t nss = 1; nss <= std::min (GetMaxNumberOfTransmitS
treams (), GetNumberOfSupportedStreams (station)); nss++) |
381 { | 381 { |
382 txVector.SetNss (nss); | 382 txVector.SetNss (nss); |
383 if (WifiPhy::IsValidTxVector (txVector) == false) | 383 if (!txVector.IsValid ()) |
384 { | 384 { |
385 NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName (
) << | 385 NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName (
) << |
386 " nss " << (uint16_t) nss << " width " <
< | 386 " nss " << +nss << |
387 (uint16_t) txVector.GetChannelWidth ()); | 387 " width " << txVector.GetChannelWidth ()
); |
388 continue; | 388 continue; |
389 } | 389 } |
390 double threshold = GetSnrThreshold (txVector); | 390 double threshold = GetSnrThreshold (txVector); |
391 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelW
idth (), txVector.GetGuardInterval (), nss); | 391 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelW
idth (), txVector.GetGuardInterval (), nss); |
392 NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <
< | 392 NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <
< |
393 " data rate " << dataRate << | 393 " data rate " << dataRate << |
394 " threshold " << threshold << " last snr obs
erved " << | 394 " threshold " << threshold << " last snr obs
erved " << |
395 station->m_lastSnrObserved << " cached " << | 395 station->m_lastSnrObserved << " cached " << |
396 station->m_lastSnrCached); | 396 station->m_lastSnrCached); |
397 if (dataRate > bestRate && threshold < station->m_lastSnrO
bserved) | 397 if (dataRate > bestRate && threshold < station->m_lastSnrO
bserved) |
(...skipping 14 matching lines...) Expand all Loading... |
412 guardInterval = std::max (GetGuardInterval (station), static_c
ast<uint16_t> (GetPhy ()->GetGuardInterval ().GetNanoSeconds ())); | 412 guardInterval = std::max (GetGuardInterval (station), static_c
ast<uint16_t> (GetPhy ()->GetGuardInterval ().GetNanoSeconds ())); |
413 txVector.SetGuardInterval (guardInterval); | 413 txVector.SetGuardInterval (guardInterval); |
414 // If the node and peer are not both HE capable, only search (
V)HT modes | 414 // If the node and peer are not both HE capable, only search (
V)HT modes |
415 if (!HasHeSupported () || !GetHeSupported (station)) | 415 if (!HasHeSupported () || !GetHeSupported (station)) |
416 { | 416 { |
417 continue; | 417 continue; |
418 } | 418 } |
419 for (uint8_t nss = 1; nss <= GetNumberOfSupportedStreams (stat
ion); nss++) | 419 for (uint8_t nss = 1; nss <= GetNumberOfSupportedStreams (stat
ion); nss++) |
420 { | 420 { |
421 txVector.SetNss (nss); | 421 txVector.SetNss (nss); |
422 if (WifiPhy::IsValidTxVector (txVector) == false) | 422 if (!txVector.IsValid ()) |
423 { | 423 { |
424 NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName (
) << | 424 NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName (
) << |
425 " nss " << (uint16_t) nss << " width " <
< | 425 " nss " << +nss << |
426 (uint16_t) txVector.GetChannelWidth ()); | 426 " width " << +txVector.GetChannelWidth (
)); |
427 continue; | 427 continue; |
428 } | 428 } |
429 double threshold = GetSnrThreshold (txVector); | 429 double threshold = GetSnrThreshold (txVector); |
430 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelW
idth (), txVector.GetGuardInterval (), nss); | 430 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelW
idth (), txVector.GetGuardInterval (), nss); |
431 NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <
< | 431 NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <
< |
432 " data rate " << dataRate << | 432 " data rate " << dataRate << |
433 " threshold " << threshold << " last snr ob
served " << | 433 " threshold " << threshold << " last snr ob
served " << |
434 station->m_lastSnrObserved << " cached " << | 434 station->m_lastSnrObserved << " cached " << |
435 station->m_lastSnrCached); | 435 station->m_lastSnrCached); |
436 if (dataRate > bestRate && threshold < station->m_lastSnrO
bserved) | 436 if (dataRate > bestRate && threshold < station->m_lastSnrO
bserved) |
437 { | 437 { |
438 NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueNam
e () << | 438 NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueNam
e () << |
439 " data rate " << dataRate << | 439 " data rate " << dataRate << |
440 " threshold " << threshold << | 440 " threshold " << threshold << |
441 " last snr observed " << | 441 " last snr observed " << |
442 station->m_lastSnrObserved); | 442 station->m_lastSnrObserved); |
443 bestRate = dataRate; | 443 bestRate = dataRate; |
444 maxMode = mode; | 444 maxMode = mode; |
445 selectedNss = nss; | 445 selectedNss = nss; |
446 } | 446 } |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 } | 450 } |
451 else | 451 else |
452 { | 452 { |
453 // Non-HT selection | 453 // Non-HT selection |
454 selectedNss = 1; | 454 selectedNss = 1; |
455 for (uint32_t i = 0; i < GetNSupported (station); i++) | 455 for (uint8_t i = 0; i < GetNSupported (station); i++) |
456 { | 456 { |
457 mode = GetSupported (station, i); | 457 mode = GetSupported (station, i); |
458 txVector.SetMode (mode); | 458 txVector.SetMode (mode); |
459 txVector.SetNss (selectedNss); | 459 txVector.SetNss (selectedNss); |
460 txVector.SetChannelWidth (GetChannelWidthForMode (mode)); | 460 txVector.SetChannelWidth (GetChannelWidthForMode (mode)); |
461 double threshold = GetSnrThreshold (txVector); | 461 double threshold = GetSnrThreshold (txVector); |
462 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth (),
txVector.GetGuardInterval (), txVector.GetNss ()); | 462 uint64_t dataRate = mode.GetDataRate (txVector.GetChannelWidth (),
txVector.GetGuardInterval (), txVector.GetNss ()); |
463 NS_LOG_DEBUG ("mode = " << mode.GetUniqueName () << | 463 NS_LOG_DEBUG ("mode = " << mode.GetUniqueName () << |
464 " threshold " << threshold << | 464 " threshold " << threshold << |
465 " last snr observed " << | 465 " last snr observed " << |
466 station->m_lastSnrObserved); | 466 station->m_lastSnrObserved); |
467 if (dataRate > bestRate && threshold < station->m_lastSnrObserved) | 467 if (dataRate > bestRate && threshold < station->m_lastSnrObserved) |
468 { | 468 { |
469 NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () << | 469 NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () << |
470 " data rate " << dataRate << | 470 " data rate " << dataRate << |
471 " threshold " << threshold << | 471 " threshold " << threshold << |
472 " last snr observed " << | 472 " last snr observed " << |
473 station->m_lastSnrObserved); | 473 station->m_lastSnrObserved); |
474 bestRate = dataRate; | 474 bestRate = dataRate; |
475 maxMode = mode; | 475 maxMode = mode; |
476 } | 476 } |
477 } | 477 } |
478 } | 478 } |
479 NS_LOG_DEBUG ("Updating cached values for station to " << maxMode.GetUniq
ueName () << " snr " << station->m_lastSnrObserved); | 479 NS_LOG_DEBUG ("Updating cached values for station to " << maxMode.GetUniq
ueName () << " snr " << station->m_lastSnrObserved); |
480 station->m_lastSnrCached = station->m_lastSnrObserved; | 480 station->m_lastSnrCached = station->m_lastSnrObserved; |
481 station->m_lastMode = maxMode; | 481 station->m_lastMode = maxMode; |
482 station->m_nss = selectedNss; | 482 station->m_nss = selectedNss; |
483 } | 483 } |
484 NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t)
channelWidth); | 484 NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << channelWidt
h); |
485 if (maxMode.GetModulationClass () == WIFI_MOD_CLASS_HE) | 485 if (maxMode.GetModulationClass () == WIFI_MOD_CLASS_HE) |
486 { | 486 { |
487 guardInterval = std::max (GetGuardInterval (station), static_cast<uint16_t
> (GetPhy ()->GetGuardInterval ().GetNanoSeconds ())); | 487 guardInterval = std::max (GetGuardInterval (station), static_cast<uint16_t
> (GetPhy ()->GetGuardInterval ().GetNanoSeconds ())); |
488 } | 488 } |
489 else | 489 else |
490 { | 490 { |
491 guardInterval = (uint16_t)std::max (GetShortGuardInterval (station) ? 400
: 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800); | 491 guardInterval = static_cast<uint16_t> (std::max (GetShortGuardInterval (st
ation) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800)); |
492 } | 492 } |
493 if (m_currentRate != maxMode.GetDataRate (channelWidth, guardInterval, selecte
dNss)) | 493 if (m_currentRate != maxMode.GetDataRate (channelWidth, guardInterval, selecte
dNss)) |
494 { | 494 { |
495 NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, guard
Interval, selectedNss)); | 495 NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, guard
Interval, selectedNss)); |
496 m_currentRate = maxMode.GetDataRate (channelWidth, guardInterval, selected
Nss); | 496 m_currentRate = maxMode.GetDataRate (channelWidth, guardInterval, selected
Nss); |
497 } | 497 } |
498 return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), (uint8_t)GetLongRetry
Count (station), GetPreambleForTransmission (maxMode, GetAddress (station)), gua
rdInterval, GetNumberOfAntennas (), selectedNss, 0, channelWidth, GetAggregation
(station), false); | 498 return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetPreambleForTransmi
ssion (maxMode, GetAddress (station)), guardInterval, GetNumberOfAntennas (), se
lectedNss, 0, GetChannelWidthForTransmission (maxMode, channelWidth), GetAggrega
tion (station), false); |
499 } | 499 } |
500 | 500 |
501 WifiTxVector | 501 WifiTxVector |
502 IdealWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 502 IdealWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
503 { | 503 { |
504 NS_LOG_FUNCTION (this << st); | 504 NS_LOG_FUNCTION (this << st); |
505 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; | 505 IdealWifiRemoteStation *station = (IdealWifiRemoteStation *)st; |
506 //We search within the Basic rate set the mode with the highest | 506 //We search within the Basic rate set the mode with the highest |
507 //snr threshold possible which is smaller than m_lastSnr to | 507 //snr threshold possible which is smaller than m_lastSnr to |
508 //ensure correct packet delivery. | 508 //ensure correct packet delivery. |
509 double maxThreshold = 0.0; | 509 double maxThreshold = 0.0; |
510 WifiTxVector txVector; | 510 WifiTxVector txVector; |
511 WifiMode mode; | 511 WifiMode mode; |
512 uint8_t nss = 1; | 512 uint8_t nss = 1; |
513 WifiMode maxMode = GetDefaultMode (); | 513 WifiMode maxMode = GetDefaultMode (); |
514 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac/ax | 514 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac/ax |
515 //RTS is sent in a legacy frame; RTS with HT/VHT/HE is not yet supported | 515 //RTS is sent in a legacy frame; RTS with HT/VHT/HE is not yet supported |
516 for (uint32_t i = 0; i < GetNBasicModes (); i++) | 516 for (uint8_t i = 0; i < GetNBasicModes (); i++) |
517 { | 517 { |
518 mode = GetBasicMode (i); | 518 mode = GetBasicMode (i); |
519 txVector.SetMode (mode); | 519 txVector.SetMode (mode); |
520 txVector.SetNss (nss); | 520 txVector.SetNss (nss); |
521 txVector.SetChannelWidth (GetChannelWidthForMode (mode)); | 521 txVector.SetChannelWidth (GetChannelWidthForMode (mode)); |
522 double threshold = GetSnrThreshold (txVector); | 522 double threshold = GetSnrThreshold (txVector); |
523 if (threshold > maxThreshold && threshold < station->m_lastSnrObserved) | 523 if (threshold > maxThreshold && threshold < station->m_lastSnrObserved) |
524 { | 524 { |
525 maxThreshold = threshold; | 525 maxThreshold = threshold; |
526 maxMode = mode; | 526 maxMode = mode; |
527 } | 527 } |
528 } | 528 } |
529 return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), (uint8_t)GetShortRetr
yCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), 80
0, GetNumberOfAntennas (), nss, 0, GetChannelWidthForMode (maxMode), GetAggregat
ion (station), false); | 529 return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetPreambleForTransmi
ssion (maxMode, GetAddress (station)), 800, GetNumberOfAntennas (), nss, 0, GetC
hannelWidthForMode (maxMode), GetAggregation (station), false); |
530 } | 530 } |
531 | 531 |
532 bool | 532 bool |
533 IdealWifiManager::IsLowLatency (void) const | 533 IdealWifiManager::IsLowLatency (void) const |
534 { | 534 { |
535 return true; | 535 return true; |
536 } | 536 } |
537 | 537 |
538 } //namespace ns3 | 538 } //namespace ns3 |
LEFT | RIGHT |