Left: | ||
Right: |
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) 2009 Duy Nguyen | 3 * Copyright (c) 2009 Duy Nguyen |
4 * Copyright (c) 2015 Ghada Badawy | 4 * Copyright (c) 2015 Ghada Badawy |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * | 27 * |
28 * 2) Sampling is done differently from legacy Minstrel. Minstrel-HT tries | 28 * 2) Sampling is done differently from legacy Minstrel. Minstrel-HT tries |
29 * to sample all rates in all groups at least once and to avoid many | 29 * to sample all rates in all groups at least once and to avoid many |
30 * consecutive samplings. | 30 * consecutive samplings. |
31 * | 31 * |
32 * 3) Sample rate is tried only once, at first place of the MRR chain. | 32 * 3) Sample rate is tried only once, at first place of the MRR chain. |
33 * | 33 * |
34 * reference: http://lwn.net/Articles/376765/ | 34 * reference: http://lwn.net/Articles/376765/ |
35 */ | 35 */ |
36 | 36 |
37 #include "minstrel-ht-wifi-manager.h" | 37 #include <iomanip> |
38 #include "ns3/packet.h" | |
38 #include "ns3/simulator.h" | 39 #include "ns3/simulator.h" |
39 #include "ns3/log.h" | 40 #include "ns3/log.h" |
40 #include "ns3/double.h" | 41 #include "ns3/random-variable-stream.h" |
41 #include "ns3/boolean.h" | 42 #include "minstrel-ht-wifi-manager.h" |
42 #include "wifi-mac.h" | 43 #include "wifi-mac.h" |
43 #include "wifi-phy.h" | 44 #include "wifi-phy.h" |
44 #include <iomanip> | |
45 | 45 |
46 #define Min(a,b) ((a < b) ? a : b) | 46 #define Min(a,b) ((a < b) ? a : b) |
47 #define Max(a,b) ((a > b) ? a : b) | 47 #define Max(a,b) ((a > b) ? a : b) |
48 | 48 |
49 NS_LOG_COMPONENT_DEFINE ("MinstrelHtWifiManager"); | 49 NS_LOG_COMPONENT_DEFINE ("MinstrelHtWifiManager"); |
50 | 50 |
51 namespace ns3 { | 51 namespace ns3 { |
52 | 52 |
53 ///MinstrelHtWifiRemoteStation structure | 53 ///MinstrelHtWifiRemoteStation structure |
54 struct MinstrelHtWifiRemoteStation : MinstrelWifiRemoteStation | 54 struct MinstrelHtWifiRemoteStation : MinstrelWifiRemoteStation |
55 { | 55 { |
56 /// Dispose station function | |
57 void DisposeStation (); | |
58 | |
59 uint32_t m_sampleGroup; //!< The group that the sample rate belongs to. | 56 uint32_t m_sampleGroup; //!< The group that the sample rate belongs to. |
60 | 57 |
61 uint32_t m_sampleWait; //!< How many transmission attempts to wait until a new sample. | 58 uint32_t m_sampleWait; //!< How many transmission attempts to wait until a new sample. |
62 uint32_t m_sampleTries; //!< Number of sample tries after waiting sampleWa it. | 59 uint32_t m_sampleTries; //!< Number of sample tries after waiting sampleWa it. |
63 uint32_t m_sampleCount; //!< Max number of samples per update interval. | 60 uint32_t m_sampleCount; //!< Max number of samples per update interval. |
64 uint32_t m_numSamplesSlow; //!< Number of times a slow rate was sampled. | 61 uint32_t m_numSamplesSlow; //!< Number of times a slow rate was sampled. |
65 | 62 |
66 double m_avgAmpduLen; //!< Average number of MPDUs in an A-MPDU. | 63 double m_avgAmpduLen; //!< Average number of MPDUs in an A-MPDU. |
67 double m_ampduLen; //!< Number of MPDUs in an A-MPDU. | 64 double m_ampduLen; //!< Number of MPDUs in an A-MPDU. |
68 uint32_t m_ampduPacketCount; //!< Number of A-MPDUs transmitted. | 65 uint32_t m_ampduPacketCount; //!< Number of A-MPDUs transmitted. |
69 | 66 |
70 McsGroupData m_groupsTable; //!< Table of groups with stats. | 67 McsGroupData m_groupsTable; //!< Table of groups with stats. |
71 bool m_isHt; //!< If the station is HT capable. | 68 bool m_isHt; //!< If the station is HT capable. |
72 | 69 |
73 std::ofstream m_statsFile; //!< File where statistics table is written. | 70 std::ofstream m_statsFile; //!< File where statistics table is written. |
74 }; | 71 }; |
75 | |
76 void | |
77 MinstrelHtWifiRemoteStation::DisposeStation () | |
78 { | |
79 if (m_isHt) | |
80 { | |
81 std::vector<std::vector<uint32_t> > ().swap (m_sampleTable); | |
82 for (uint8_t j = 0; j < m_groupsTable.size (); j++) | |
83 { | |
84 std::vector<HtRateInfo> ().swap (m_groupsTable[j].m_ratesTable); | |
85 } | |
86 std::vector<GroupInfo> ().swap (m_groupsTable); | |
87 m_statsFile.close (); | |
88 } | |
89 } | |
90 | 72 |
91 NS_OBJECT_ENSURE_REGISTERED (MinstrelHtWifiManager); | 73 NS_OBJECT_ENSURE_REGISTERED (MinstrelHtWifiManager); |
92 | 74 |
93 TypeId | 75 TypeId |
94 MinstrelHtWifiManager::GetTypeId (void) | 76 MinstrelHtWifiManager::GetTypeId (void) |
95 { | 77 { |
96 static TypeId tid = TypeId ("ns3::MinstrelHtWifiManager") | 78 static TypeId tid = TypeId ("ns3::MinstrelHtWifiManager") |
97 .SetParent<WifiRemoteStationManager> () | 79 .SetParent<WifiRemoteStationManager> () |
98 .AddConstructor<MinstrelHtWifiManager> () | 80 .AddConstructor<MinstrelHtWifiManager> () |
99 .SetGroupName ("Wifi") | 81 .SetGroupName ("Wifi") |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 * or non-HT stations want to associate. | 133 * or non-HT stations want to associate. |
152 */ | 134 */ |
153 m_legacyManager = CreateObject<MinstrelWifiManager> (); | 135 m_legacyManager = CreateObject<MinstrelWifiManager> (); |
154 } | 136 } |
155 | 137 |
156 MinstrelHtWifiManager::~MinstrelHtWifiManager () | 138 MinstrelHtWifiManager::~MinstrelHtWifiManager () |
157 { | 139 { |
158 NS_LOG_FUNCTION (this); | 140 NS_LOG_FUNCTION (this); |
159 if (HasHtSupported ()) | 141 if (HasHtSupported ()) |
160 { | 142 { |
161 for (uint32_t i = 0; i < m_numGroups; i++) | 143 for (uint8_t i = 0; i < m_numGroups; i++) |
162 { | 144 { |
163 m_minstrelGroups[i].ratesFirstMpduTxTimeTable.clear (); | 145 m_minstrelGroups[i].ratesFirstMpduTxTimeTable.clear (); |
164 m_minstrelGroups[i].ratesTxTimeTable.clear (); | 146 m_minstrelGroups[i].ratesTxTimeTable.clear (); |
165 } | 147 } |
166 } | 148 } |
167 } | 149 } |
168 | 150 |
169 int64_t | 151 int64_t |
170 MinstrelHtWifiManager::AssignStreams (int64_t stream) | 152 MinstrelHtWifiManager::AssignStreams (int64_t stream) |
171 { | 153 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 * - A global continuous index, which identifies all rates within all gro ups, in [0, m_numGroups * m_numRates] | 198 * - A global continuous index, which identifies all rates within all gro ups, in [0, m_numGroups * m_numRates] |
217 * - A groupId, which indexes a group in the array, in [0, m_numGroups] | 199 * - A groupId, which indexes a group in the array, in [0, m_numGroups] |
218 * - A rateId, which identifies a rate within a group, in [0, m_numRates] | 200 * - A rateId, which identifies a rate within a group, in [0, m_numRates] |
219 * - A deviceIndex, which indexes a MCS in the phy MCS array. | 201 * - A deviceIndex, which indexes a MCS in the phy MCS array. |
220 * - A mcsIndex, which indexes a MCS in the wifi-remote-station-manager s upported MCSs array. | 202 * - A mcsIndex, which indexes a MCS in the wifi-remote-station-manager s upported MCSs array. |
221 */ | 203 */ |
222 NS_LOG_DEBUG ("Initialize MCS Groups:"); | 204 NS_LOG_DEBUG ("Initialize MCS Groups:"); |
223 m_minstrelGroups = MinstrelMcsGroups (m_numGroups); | 205 m_minstrelGroups = MinstrelMcsGroups (m_numGroups); |
224 | 206 |
225 // Initialize all HT groups | 207 // Initialize all HT groups |
226 for (uint8_t chWidth = 20; chWidth <= MAX_HT_WIDTH; chWidth *= 2) | 208 for (uint16_t chWidth = 20; chWidth <= MAX_HT_WIDTH; chWidth *= 2) |
227 { | 209 { |
228 for (uint8_t sgi = 0; sgi <= 1; sgi++) | 210 for (uint8_t sgi = 0; sgi <= 1; sgi++) |
229 { | 211 { |
230 for (uint8_t streams = 1; streams <= MAX_SUPPORTED_STREAMS; stream s++) | 212 for (uint8_t streams = 1; streams <= MAX_SUPPORTED_STREAMS; stream s++) |
231 { | 213 { |
232 uint32_t groupId = GetHtGroupId (streams, sgi, chWidth); | 214 uint32_t groupId = GetHtGroupId (streams, sgi, chWidth); |
233 | 215 |
234 m_minstrelGroups[groupId].streams = streams; | 216 m_minstrelGroups[groupId].streams = streams; |
235 m_minstrelGroups[groupId].sgi = sgi; | 217 m_minstrelGroups[groupId].sgi = sgi; |
236 m_minstrelGroups[groupId].chWidth = chWidth; | 218 m_minstrelGroups[groupId].chWidth = chWidth; |
237 m_minstrelGroups[groupId].isVht = false; | 219 m_minstrelGroups[groupId].isVht = false; |
238 m_minstrelGroups[groupId].isSupported = false; | 220 m_minstrelGroups[groupId].isSupported = false; |
239 | 221 |
240 // Check capabilities of the device | 222 // Check capabilities of the device |
241 if (!(!GetPhy ()->GetShortGuardInterval () && m_minstrelGroups [groupId].sgi) ///Is SGI supported by the transmitter? | 223 if (!(!GetPhy ()->GetShortGuardInterval () && m_minstrelGroups [groupId].sgi) ///Is SGI supported by the transmitter? |
242 && (GetPhy ()->GetChannelWidth () >= m_minstrelGroups[grou pId].chWidth) ///Is channel width supported by the transmitter? | 224 && (GetPhy ()->GetChannelWidth () >= m_minstrelGroups[grou pId].chWidth) ///Is channel width supported by the transmitter? |
243 && (GetPhy ()->GetMaxSupportedTxSpatialStreams () >= m_min strelGroups[groupId].streams)) ///Are streams supported by the transmitter? | 225 && (GetPhy ()->GetMaxSupportedTxSpatialStreams () >= m_min strelGroups[groupId].streams)) ///Are streams supported by the transmitter? |
244 { | 226 { |
245 m_minstrelGroups[groupId].isSupported = true; | 227 m_minstrelGroups[groupId].isSupported = true; |
246 | 228 |
247 // Calculate tx time for all rates of the group | 229 // Calculate tx time for all rates of the group |
248 WifiModeList htMcsList = GetHtDeviceMcsList (); | 230 WifiModeList htMcsList = GetHtDeviceMcsList (); |
249 for (uint8_t i = 0; i < MAX_HT_GROUP_RATES; i++) | 231 for (uint8_t i = 0; i < MAX_HT_GROUP_RATES; i++) |
250 { | 232 { |
251 uint32_t deviceIndex = i + (m_minstrelGroups[groupId]. streams - 1) * 8; | 233 uint32_t deviceIndex = i + (m_minstrelGroups[groupId]. streams - 1) * 8; |
252 WifiMode mode = htMcsList[deviceIndex]; | 234 WifiMode mode = htMcsList[deviceIndex]; |
253 AddFirstMpduTxTime (groupId, mode, CalculateFirstMpduT xDuration (GetPhy (), streams, sgi, chWidth, mode)); | 235 AddFirstMpduTxTime (groupId, mode, CalculateFirstMpduT xDuration (GetPhy (), streams, sgi, chWidth, mode)); |
254 AddMpduTxTime (groupId, mode, CalculateMpduTxDuration (GetPhy (), streams, sgi, chWidth, mode)); | 236 AddMpduTxTime (groupId, mode, CalculateMpduTxDuration (GetPhy (), streams, sgi, chWidth, mode)); |
255 } | 237 } |
256 NS_LOG_DEBUG ("Initialized group " << groupId << ": (" << (uint16_t)streams << "," << (uint16_t)sgi << "," << (uint16_t)chWidth << ")"); | 238 NS_LOG_DEBUG ("Initialized group " << groupId << ": (" << +streams << "," << +sgi << "," << chWidth << ")"); |
257 } | 239 } |
258 } | 240 } |
259 } | 241 } |
260 } | 242 } |
261 | 243 |
262 if (HasVhtSupported ()) | 244 if (HasVhtSupported ()) |
263 { | 245 { |
264 // Initialize all VHT groups | 246 // Initialize all VHT groups |
265 for (uint16_t chWidth = 20; chWidth <= MAX_VHT_WIDTH; chWidth *= 2) | 247 for (uint16_t chWidth = 20; chWidth <= MAX_VHT_WIDTH; chWidth *= 2) |
266 { | 248 { |
267 for (uint8_t sgi = 0; sgi <= 1; sgi++) | 249 for (uint8_t sgi = 0; sgi <= 1; sgi++) |
268 { | 250 { |
269 for (uint8_t streams = 1; streams <= MAX_SUPPORTED_STREAMS; st reams++) | 251 for (uint8_t streams = 1; streams <= MAX_SUPPORTED_STREAMS; st reams++) |
270 { | 252 { |
271 uint32_t groupId = GetVhtGroupId (streams, sgi, static_cas t<uint8_t>(chWidth)); | 253 uint32_t groupId = GetVhtGroupId (streams, sgi, chWidth); |
272 | 254 |
273 m_minstrelGroups[groupId].streams = streams; | 255 m_minstrelGroups[groupId].streams = streams; |
274 m_minstrelGroups[groupId].sgi = sgi; | 256 m_minstrelGroups[groupId].sgi = sgi; |
275 m_minstrelGroups[groupId].chWidth = static_cast<uint8_t>(c hWidth); | 257 m_minstrelGroups[groupId].chWidth = chWidth; |
276 m_minstrelGroups[groupId].isVht = true; | 258 m_minstrelGroups[groupId].isVht = true; |
277 m_minstrelGroups[groupId].isSupported = false; | 259 m_minstrelGroups[groupId].isSupported = false; |
278 | 260 |
279 // Check capabilities of the device | 261 // Check capabilities of the device |
280 if (!(!GetPhy ()->GetShortGuardInterval () && m_minstrelGr oups[groupId].sgi) ///Is SGI supported by the transmitter? | 262 if (!(!GetPhy ()->GetShortGuardInterval () && m_minstrelGr oups[groupId].sgi) ///Is SGI supported by the transmitter? |
281 && (GetPhy ()->GetChannelWidth () >= m_minstrelGroups[ groupId].chWidth) ///Is channel width supported by the transmitter ? | 263 && (GetPhy ()->GetChannelWidth () >= m_minstrelGroups[ groupId].chWidth) ///Is channel width supported by the transmitter ? |
282 && (GetPhy ()->GetMaxSupportedTxSpatialStreams () >= m _minstrelGroups[groupId].streams)) ///Are streams supported by the transmitter? | 264 && (GetPhy ()->GetMaxSupportedTxSpatialStreams () >= m _minstrelGroups[groupId].streams)) ///Are streams supported by the transmitter? |
283 { | 265 { |
284 m_minstrelGroups[groupId].isSupported = true; | 266 m_minstrelGroups[groupId].isSupported = true; |
285 | 267 |
286 // Calculate tx time for all rates of the group | 268 // Calculate tx time for all rates of the group |
287 WifiModeList vhtMcsList = GetVhtDeviceMcsList (); | 269 WifiModeList vhtMcsList = GetVhtDeviceMcsList (); |
288 for (uint8_t i = 0; i < MAX_VHT_GROUP_RATES; i++) | 270 for (uint8_t i = 0; i < MAX_VHT_GROUP_RATES; i++) |
289 { | 271 { |
290 WifiMode mode = vhtMcsList[i]; | 272 WifiMode mode = vhtMcsList[i]; |
291 // Check for invalid VHT MCSs and do not add time to array. | 273 // Check for invalid VHT MCSs and do not add time to array. |
292 if (IsValidMcs (GetPhy (), streams, static_cast<ui nt8_t>(chWidth), mode)) | 274 if (IsValidMcs (GetPhy (), streams, chWidth, mode) ) |
293 { | 275 { |
294 AddFirstMpduTxTime (groupId, mode, CalculateFi rstMpduTxDuration (GetPhy (), streams, sgi, static_cast<uint8_t>(chWidth), mode) ); | 276 AddFirstMpduTxTime (groupId, mode, CalculateFi rstMpduTxDuration (GetPhy (), streams, sgi, chWidth, mode)); |
295 AddMpduTxTime (groupId, mode, CalculateMpduTxD uration (GetPhy (), streams, sgi, static_cast<uint8_t>(chWidth), mode)); | 277 AddMpduTxTime (groupId, mode, CalculateMpduTxD uration (GetPhy (), streams, sgi, chWidth, mode)); |
296 } | 278 } |
297 } | 279 } |
298 NS_LOG_DEBUG ("Initialized group " << groupId << ": (" << (uint16_t)streams << "," << (uint16_t)sgi << "," << (uint16_t)chWidth << ")" ); | 280 NS_LOG_DEBUG ("Initialized group " << groupId << ": (" << +streams << "," << +sgi << "," << chWidth << ")"); |
299 } | 281 } |
300 } | 282 } |
301 } | 283 } |
302 } | 284 } |
303 } | 285 } |
304 } | 286 } |
305 } | 287 } |
306 | 288 |
307 void | 289 void |
308 MinstrelHtWifiManager::SetupMac (const Ptr<WifiMac> mac) | 290 MinstrelHtWifiManager::SetupMac (const Ptr<WifiMac> mac) |
309 { | 291 { |
310 NS_LOG_FUNCTION (this << mac); | 292 NS_LOG_FUNCTION (this << mac); |
311 m_legacyManager->SetupMac (mac); | 293 m_legacyManager->SetupMac (mac); |
312 WifiRemoteStationManager::SetupMac (mac); | 294 WifiRemoteStationManager::SetupMac (mac); |
313 } | 295 } |
314 | 296 |
315 bool | 297 bool |
316 MinstrelHtWifiManager::IsValidMcs (Ptr<WifiPhy> phy, uint8_t streams, uint8_t ch Width, WifiMode mode) | 298 MinstrelHtWifiManager::IsValidMcs (Ptr<WifiPhy> phy, uint8_t streams, uint16_t c hWidth, WifiMode mode) |
317 { | 299 { |
318 NS_LOG_FUNCTION (this << phy << (uint16_t)streams << (uint16_t)chWidth << mode ); | 300 NS_LOG_FUNCTION (this << phy << +streams << chWidth << mode); |
319 | |
320 WifiTxVector txvector; | 301 WifiTxVector txvector; |
321 txvector.SetNss (streams); | 302 txvector.SetNss (streams); |
322 txvector.SetChannelWidth (chWidth); | 303 txvector.SetChannelWidth (chWidth); |
323 txvector.SetMode (mode); | 304 txvector.SetMode (mode); |
324 return phy->IsValidTxVector (txvector); | 305 return txvector.IsValid (); |
325 } | 306 } |
326 | 307 |
327 Time | 308 Time |
328 MinstrelHtWifiManager::CalculateFirstMpduTxDuration (Ptr<WifiPhy> phy, uint8_t s treams, uint8_t sgi, uint8_t chWidth, WifiMode mode) | 309 MinstrelHtWifiManager::CalculateFirstMpduTxDuration (Ptr<WifiPhy> phy, uint8_t s treams, uint8_t sgi, uint16_t chWidth, WifiMode mode) |
329 { | 310 { |
330 NS_LOG_FUNCTION (this << phy << (uint16_t)streams << (uint16_t)sgi << (uint16_ t)chWidth << mode); | 311 NS_LOG_FUNCTION (this << phy << +streams << +sgi << chWidth << mode); |
331 | |
332 WifiTxVector txvector; | 312 WifiTxVector txvector; |
333 txvector.SetNss (streams); | 313 txvector.SetNss (streams); |
334 txvector.SetGuardInterval (sgi ? 400 : 800); | 314 txvector.SetGuardInterval (sgi ? 400 : 800); |
335 txvector.SetChannelWidth (chWidth); | 315 txvector.SetChannelWidth (chWidth); |
336 txvector.SetNess (0); | 316 txvector.SetNess (0); |
337 txvector.SetStbc (phy->GetStbc ()); | 317 txvector.SetStbc (phy->GetStbc ()); |
338 txvector.SetMode (mode); | 318 txvector.SetMode (mode); |
339 txvector.SetPreambleType (WIFI_PREAMBLE_HT_MF); | 319 txvector.SetPreambleType (WIFI_PREAMBLE_HT_MF); |
340 return phy->CalculateTxDuration (m_frameLength, txvector, phy->GetFrequency () , MPDU_IN_AGGREGATE, 0); | 320 return phy->CalculateTxDuration (m_frameLength, txvector, phy->GetFrequency () , MPDU_IN_AGGREGATE, 0); |
341 } | 321 } |
342 | 322 |
343 Time | 323 Time |
344 MinstrelHtWifiManager::CalculateMpduTxDuration (Ptr<WifiPhy> phy, uint8_t stream s, uint8_t sgi, uint8_t chWidth, WifiMode mode) | 324 MinstrelHtWifiManager::CalculateMpduTxDuration (Ptr<WifiPhy> phy, uint8_t stream s, uint8_t sgi, uint16_t chWidth, WifiMode mode) |
345 { | 325 { |
346 NS_LOG_FUNCTION (this << phy << (uint16_t)streams << (uint16_t)sgi << (uint16_ t)chWidth << mode); | 326 NS_LOG_FUNCTION (this << phy << +streams << +sgi << chWidth << mode); |
347 | |
348 WifiTxVector txvector; | 327 WifiTxVector txvector; |
349 txvector.SetNss (streams); | 328 txvector.SetNss (streams); |
350 txvector.SetGuardInterval (sgi ? 400 : 800); | 329 txvector.SetGuardInterval (sgi ? 400 : 800); |
351 txvector.SetChannelWidth (chWidth); | 330 txvector.SetChannelWidth (chWidth); |
352 txvector.SetNess (0); | 331 txvector.SetNess (0); |
353 txvector.SetStbc (phy->GetStbc ()); | 332 txvector.SetStbc (phy->GetStbc ()); |
354 txvector.SetMode (mode); | 333 txvector.SetMode (mode); |
355 txvector.SetPreambleType (WIFI_PREAMBLE_NONE); | 334 txvector.SetPreambleType (WIFI_PREAMBLE_NONE); |
356 return phy->CalculateTxDuration (m_frameLength, txvector, phy->GetFrequency () , MPDU_IN_AGGREGATE, 0); | 335 return phy->CalculateTxDuration (m_frameLength, txvector, phy->GetFrequency () , MPDU_IN_AGGREGATE, 0); |
357 } | 336 } |
358 | 337 |
359 Time | 338 Time |
360 MinstrelHtWifiManager::GetFirstMpduTxTime (uint32_t groupId, WifiMode mode) cons t | 339 MinstrelHtWifiManager::GetFirstMpduTxTime (uint32_t groupId, WifiMode mode) cons t |
361 { | 340 { |
362 NS_LOG_FUNCTION (this << groupId << mode); | 341 NS_LOG_FUNCTION (this << groupId << mode); |
363 | 342 auto it = m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.find (mode); |
364 for (TxTime::const_iterator i = m_minstrelGroups[groupId].ratesFirstMpduTxTime Table.begin (); i != m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.end (); i++) | 343 NS_ASSERT (it != m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.end ()); |
365 { | 344 return it->second; |
366 if (mode == i->second) | |
367 { | |
368 return i->first; | |
369 } | |
370 } | |
371 NS_ASSERT (false); | |
372 return Seconds (0); | |
373 } | 345 } |
374 | 346 |
375 void | 347 void |
376 MinstrelHtWifiManager::AddFirstMpduTxTime (uint32_t groupId, WifiMode mode, Time t) | 348 MinstrelHtWifiManager::AddFirstMpduTxTime (uint32_t groupId, WifiMode mode, Time t) |
377 { | 349 { |
378 NS_LOG_FUNCTION (this << groupId << mode << t); | 350 NS_LOG_FUNCTION (this << groupId << mode << t); |
379 | 351 m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.insert (std::make_pair (mo de, t)); |
380 m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.push_back (std::make_pair (t, mode)); | |
381 } | 352 } |
382 | 353 |
383 Time | 354 Time |
384 MinstrelHtWifiManager::GetMpduTxTime (uint32_t groupId, WifiMode mode) const | 355 MinstrelHtWifiManager::GetMpduTxTime (uint32_t groupId, WifiMode mode) const |
385 { | 356 { |
386 NS_LOG_FUNCTION (this << groupId << mode); | 357 NS_LOG_FUNCTION (this << groupId << mode); |
387 | 358 auto it = m_minstrelGroups[groupId].ratesTxTimeTable.find (mode); |
388 for (TxTime::const_iterator i = m_minstrelGroups[groupId].ratesTxTimeTable.beg in (); i != m_minstrelGroups[groupId].ratesTxTimeTable.end (); i++) | 359 NS_ASSERT (it != m_minstrelGroups[groupId].ratesTxTimeTable.end ()); |
389 { | 360 return it->second; |
390 if (mode == i->second) | |
391 { | |
392 return i->first; | |
393 } | |
394 } | |
395 NS_ASSERT (false); | |
396 return Seconds (0); | |
397 } | 361 } |
398 | 362 |
399 void | 363 void |
400 MinstrelHtWifiManager::AddMpduTxTime (uint32_t groupId, WifiMode mode, Time t) | 364 MinstrelHtWifiManager::AddMpduTxTime (uint32_t groupId, WifiMode mode, Time t) |
401 { | 365 { |
402 NS_LOG_FUNCTION (this << groupId << mode << t); | 366 NS_LOG_FUNCTION (this << groupId << mode << t); |
403 | 367 m_minstrelGroups[groupId].ratesTxTimeTable.insert (std::make_pair (mode, t)); |
404 m_minstrelGroups[groupId].ratesTxTimeTable.push_back (std::make_pair (t, mode) ); | |
405 } | 368 } |
406 | 369 |
407 WifiRemoteStation * | 370 WifiRemoteStation * |
408 MinstrelHtWifiManager::DoCreateStation (void) const | 371 MinstrelHtWifiManager::DoCreateStation (void) const |
409 { | 372 { |
410 NS_LOG_FUNCTION (this); | 373 NS_LOG_FUNCTION (this); |
411 | |
412 MinstrelHtWifiRemoteStation *station = new MinstrelHtWifiRemoteStation (); | 374 MinstrelHtWifiRemoteStation *station = new MinstrelHtWifiRemoteStation (); |
413 | 375 |
414 // Initialize variables common to both stations. | 376 // Initialize variables common to both stations. |
415 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; | 377 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; |
416 station->m_col = 0; | 378 station->m_col = 0; |
417 station->m_index = 0; | 379 station->m_index = 0; |
418 station->m_maxTpRate = 0; | 380 station->m_maxTpRate = 0; |
419 station->m_maxTpRate2 = 0; | 381 station->m_maxTpRate2 = 0; |
420 station->m_maxProbRate = 0; | 382 station->m_maxProbRate = 0; |
421 station->m_nModes = 0; | 383 station->m_nModes = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 station->m_isHt = false; | 417 station->m_isHt = false; |
456 } | 418 } |
457 | 419 |
458 return station; | 420 return station; |
459 } | 421 } |
460 | 422 |
461 void | 423 void |
462 MinstrelHtWifiManager::CheckInit (MinstrelHtWifiRemoteStation *station) | 424 MinstrelHtWifiManager::CheckInit (MinstrelHtWifiRemoteStation *station) |
463 { | 425 { |
464 NS_LOG_FUNCTION (this << station); | 426 NS_LOG_FUNCTION (this << station); |
465 | |
466 // Note: we appear to be doing late initialization of the table | 427 // Note: we appear to be doing late initialization of the table |
467 // to make sure that the set of supported rates has been initialized | 428 // to make sure that the set of supported rates has been initialized |
468 // before we perform our own initialization. | 429 // before we perform our own initialization. |
469 if (!station->m_initialized) | 430 if (!station->m_initialized) |
470 { | 431 { |
471 /** | 432 /** |
472 * Check if the station supports HT. | 433 * Check if the station supports HT. |
473 * Assume that if the device do not supports HT then | 434 * Assume that if the device do not supports HT then |
474 * the station will not support HT either. | 435 * the station will not support HT either. |
475 * We save from using another check and variable. | 436 * We save from using another check and variable. |
476 */ | 437 */ |
477 if (!GetHtSupported (station) && !GetVhtSupported (station)) | 438 if (!GetHtSupported (station) && !GetVhtSupported (station)) |
478 { | 439 { |
479 NS_LOG_DEBUG ("Non-HT station " << station); | 440 NS_LOG_INFO ("Non-HT station " << station); |
480 station->m_isHt = false; | 441 station->m_isHt = false; |
481 // We will use non-HT minstrel for this station. Initialize the manage r. | 442 // We will use non-HT minstrel for this station. Initialize the manage r. |
482 m_legacyManager->SetAttribute ("UpdateStatistics", TimeValue (m_update Stats)); | 443 m_legacyManager->SetAttribute ("UpdateStatistics", TimeValue (m_update Stats)); |
483 m_legacyManager->SetAttribute ("LookAroundRate", DoubleValue (m_lookAr oundRate)); | 444 m_legacyManager->SetAttribute ("LookAroundRate", DoubleValue (m_lookAr oundRate)); |
484 m_legacyManager->SetAttribute ("EWMA", DoubleValue (m_ewmaLevel)); | 445 m_legacyManager->SetAttribute ("EWMA", DoubleValue (m_ewmaLevel)); |
485 m_legacyManager->SetAttribute ("SampleColumn", UintegerValue (m_nSampl eCol)); | 446 m_legacyManager->SetAttribute ("SampleColumn", UintegerValue (m_nSampl eCol)); |
486 m_legacyManager->SetAttribute ("PacketLength", UintegerValue (m_frameL ength)); | 447 m_legacyManager->SetAttribute ("PacketLength", UintegerValue (m_frameL ength)); |
487 m_legacyManager->SetAttribute ("PrintStats", BooleanValue (m_printStat s)); | 448 m_legacyManager->SetAttribute ("PrintStats", BooleanValue (m_printStat s)); |
488 m_legacyManager->CheckInit (station); | 449 m_legacyManager->CheckInit (station); |
489 } | 450 } |
490 else | 451 else |
491 { | 452 { |
492 NS_LOG_DEBUG ("HT station " << station); | 453 NS_LOG_DEBUG ("HT station " << station); |
493 station->m_isHt = true; | 454 station->m_isHt = true; |
494 station->m_nModes = GetNMcsSupported (station); | 455 station->m_nModes = GetNMcsSupported (station); |
495 station->m_sampleTable = SampleRate (m_numRates, std::vector<uint32_t> (m_nSampleCol)); | 456 station->m_sampleTable = SampleRate (m_numRates, std::vector<uint32_t> (m_nSampleCol)); |
496 InitSampleTable (station); | 457 InitSampleTable (station); |
497 RateInit (station); | 458 RateInit (station); |
498 std::ostringstream tmp; | 459 std::ostringstream tmp; |
499 tmp << "minstrel-ht-stats-" << station->m_state->m_address << ".txt"; | 460 tmp << "minstrel-ht-stats-" << station->m_state->m_address << ".txt"; |
500 station->m_statsFile.open (tmp.str ().c_str (), std::ios::out); | 461 station->m_statsFile.open (tmp.str ().c_str (), std::ios::out); |
501 station->m_initialized = true; | 462 station->m_initialized = true; |
502 } | 463 } |
503 } | 464 } |
504 } | 465 } |
505 | 466 |
506 void | 467 void |
507 MinstrelHtWifiManager::DoReportRxOk (WifiRemoteStation *st, | 468 MinstrelHtWifiManager::DoReportRxOk (WifiRemoteStation *st, double rxSnr, WifiMo de txMode) |
508 double rxSnr, WifiMode txMode) | 469 { |
509 { | |
510 NS_UNUSED(rxSnr); | |
511 NS_UNUSED(txMode); | |
512 NS_LOG_FUNCTION (this << st); | 470 NS_LOG_FUNCTION (this << st); |
513 | |
514 NS_LOG_DEBUG ("DoReportRxOk m_txrate=" << ((MinstrelHtWifiRemoteStation *)st)- >m_txrate); | 471 NS_LOG_DEBUG ("DoReportRxOk m_txrate=" << ((MinstrelHtWifiRemoteStation *)st)- >m_txrate); |
515 } | 472 } |
516 | 473 |
517 void | 474 void |
518 MinstrelHtWifiManager::DoReportRtsFailed (WifiRemoteStation *st) | 475 MinstrelHtWifiManager::DoReportRtsFailed (WifiRemoteStation *st) |
519 { | 476 { |
520 NS_LOG_FUNCTION (this << st); | 477 NS_LOG_FUNCTION (this << st); |
521 | |
522 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; | 478 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; |
523 | |
524 CheckInit (station); | 479 CheckInit (station); |
525 if (!station->m_initialized) | 480 if (!station->m_initialized) |
526 { | 481 { |
527 return; | 482 return; |
528 } | 483 } |
529 | |
530 NS_LOG_DEBUG ("DoReportRtsFailed m_txrate=" << station->m_txrate); | 484 NS_LOG_DEBUG ("DoReportRtsFailed m_txrate=" << station->m_txrate); |
531 station->m_shortRetry++; | 485 station->m_shortRetry++; |
532 } | 486 } |
533 | 487 |
534 void | 488 void |
535 MinstrelHtWifiManager::DoReportRtsOk (WifiRemoteStation *st, double ctsSnr, Wifi Mode ctsMode, double rtsSnr) | 489 MinstrelHtWifiManager::DoReportRtsOk (WifiRemoteStation *st, double ctsSnr, Wifi Mode ctsMode, double rtsSnr) |
536 { | 490 { |
537 NS_UNUSED(ctsSnr); | |
538 NS_UNUSED(ctsMode); | |
539 NS_UNUSED(rtsSnr); | |
540 NS_LOG_FUNCTION (this << st); | 491 NS_LOG_FUNCTION (this << st); |
541 | |
542 NS_LOG_DEBUG ("self=" << st << " rts ok"); | |
543 } | 492 } |
544 | 493 |
545 void | 494 void |
546 MinstrelHtWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) | 495 MinstrelHtWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) |
547 { | 496 { |
548 NS_LOG_FUNCTION (this << st); | 497 NS_LOG_FUNCTION (this << st); |
549 | |
550 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; | 498 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; |
551 NS_LOG_DEBUG ("Final RTS failed"); | 499 NS_LOG_DEBUG ("Final RTS failed"); |
552 | |
553 CheckInit (station); | 500 CheckInit (station); |
554 if (!station->m_initialized) | 501 if (!station->m_initialized) |
555 { | 502 { |
556 return; | 503 return; |
557 } | 504 } |
558 | |
559 UpdateRetry (station); | 505 UpdateRetry (station); |
560 } | 506 } |
561 | 507 |
562 void | 508 void |
563 MinstrelHtWifiManager::DoReportDataFailed (WifiRemoteStation *st) | 509 MinstrelHtWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
564 { | 510 { |
565 NS_LOG_FUNCTION (this << st); | 511 NS_LOG_FUNCTION (this << st); |
566 | |
567 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; | 512 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; |
568 | 513 |
569 CheckInit (station); | 514 CheckInit (station); |
570 if (!station->m_initialized) | 515 if (!station->m_initialized) |
571 { | 516 { |
572 return; | 517 return; |
573 } | 518 } |
574 | 519 |
520 NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m_txr ate << "\tlongRetry \t" << station->m_longRetry); | |
521 | |
575 if (!station->m_isHt) | 522 if (!station->m_isHt) |
576 { | 523 { |
577 m_legacyManager->UpdateRate (station); | 524 m_legacyManager->UpdateRate (station); |
578 } | 525 } |
579 else | 526 else |
580 { | 527 { |
581 NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m _txrate << "\tlongRetry \t" << station->m_longRetry); | |
582 | |
583 uint32_t rateId = GetRateId (station->m_txrate); | 528 uint32_t rateId = GetRateId (station->m_txrate); |
584 uint32_t groupId = GetGroupId (station->m_txrate); | 529 uint32_t groupId = GetGroupId (station->m_txrate); |
585 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++; // Increment the attempts counter for the rate used. | 530 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++; // Increment the attempts counter for the rate used. |
586 | |
587 UpdateRate (station); | 531 UpdateRate (station); |
588 } | 532 } |
589 } | 533 } |
590 | 534 |
591 void | 535 void |
592 MinstrelHtWifiManager::DoReportDataOk (WifiRemoteStation *st, | 536 MinstrelHtWifiManager::DoReportDataOk (WifiRemoteStation *st, double ackSnr, Wif iMode ackMode, double dataSnr) |
593 double ackSnr, WifiMode ackMode, double d ataSnr) | |
594 { | 537 { |
595 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); | 538 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
596 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; | 539 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; |
597 | 540 |
598 CheckInit (station); | 541 CheckInit (station); |
599 if (!station->m_initialized) | 542 if (!station->m_initialized) |
600 { | 543 { |
601 return; | 544 return; |
602 } | 545 } |
603 | 546 |
604 NS_LOG_DEBUG ("Data OK - Txrate = " << station->m_txrate ); | 547 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", attempt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", success = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (before u pdate)."); |
605 | 548 |
606 if (!station->m_isHt) | 549 if (!station->m_isHt) |
607 { | 550 { |
608 station->m_minstrelTable[station->m_txrate].numRateSuccess++; | 551 station->m_minstrelTable[station->m_txrate].numRateSuccess++; |
609 station->m_minstrelTable[station->m_txrate].numRateAttempt++; | 552 station->m_minstrelTable[station->m_txrate].numRateAttempt++; |
610 | 553 |
611 m_legacyManager->UpdatePacketCounters (station); | 554 m_legacyManager->UpdatePacketCounters (station); |
555 | |
556 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", atte mpt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", succ ess = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (afte r update)."); | |
612 | 557 |
613 UpdateRetry (station); | 558 UpdateRetry (station); |
614 m_legacyManager->UpdateStats (station); | 559 m_legacyManager->UpdateStats (station); |
615 | 560 |
616 if (station->m_nModes >= 1) | 561 if (station->m_nModes >= 1) |
617 { | 562 { |
618 station->m_txrate = m_legacyManager->FindRate (station); | 563 station->m_txrate = m_legacyManager->FindRate (station); |
619 } | 564 } |
620 } | 565 } |
621 else | 566 else |
622 { | 567 { |
623 uint32_t rateId = GetRateId (station->m_txrate); | 568 uint32_t rateId = GetRateId (station->m_txrate); |
624 uint32_t groupId = GetGroupId (station->m_txrate); | 569 uint32_t groupId = GetGroupId (station->m_txrate); |
625 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess++; | 570 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess++; |
626 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++; | 571 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++; |
627 | 572 |
628 UpdatePacketCounters (station, 1, 0); | 573 UpdatePacketCounters (station, 1, 0); |
629 | 574 |
575 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", atte mpt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", succ ess = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (afte r update)."); | |
576 | |
630 station->m_isSampling = false; | 577 station->m_isSampling = false; |
631 station->m_sampleDeferred = false; | 578 station->m_sampleDeferred = false; |
632 | 579 |
633 UpdateRetry (station); | 580 UpdateRetry (station); |
634 if (Simulator::Now () >= station->m_nextStatsUpdate) | 581 if (Simulator::Now () >= station->m_nextStatsUpdate) |
635 { | 582 { |
636 UpdateStats (station); | 583 UpdateStats (station); |
637 } | 584 } |
638 | 585 |
639 if (station->m_nModes >= 1) | 586 if (station->m_nModes >= 1) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 { | 635 { |
689 station->m_txrate = FindRate (station); | 636 station->m_txrate = FindRate (station); |
690 } | 637 } |
691 } | 638 } |
692 NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate ); | 639 NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate ); |
693 } | 640 } |
694 | 641 |
695 void | 642 void |
696 MinstrelHtWifiManager::DoReportAmpduTxStatus (WifiRemoteStation *st, uint8_t nSu ccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr) | 643 MinstrelHtWifiManager::DoReportAmpduTxStatus (WifiRemoteStation *st, uint8_t nSu ccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr) |
697 { | 644 { |
698 NS_LOG_FUNCTION (this << st << (uint16_t)nSuccessfulMpdus << (uint16_t)nFailed Mpdus << rxSnr << dataSnr); | 645 NS_LOG_FUNCTION (this << st << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr); |
699 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; | 646 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; |
700 | 647 |
701 CheckInit (station); | 648 CheckInit (station); |
702 if (!station->m_initialized) | 649 if (!station->m_initialized) |
703 { | 650 { |
704 return; | 651 return; |
705 } | 652 } |
706 | 653 |
707 if (!station->m_isHt) | 654 if (!station->m_isHt) |
708 { | 655 { |
709 NS_ASSERT_MSG (false,"A-MPDU Tx Status called but no HT or VHT supported." ); | 656 NS_ASSERT_MSG (false,"A-MPDU Tx Status called but no HT or VHT supported." ); |
710 } | 657 } |
711 | 658 |
712 NS_LOG_DEBUG ("DoReportAmpduTxStatus. TxRate=" << station->m_txrate << " SuccM pdus= " << | 659 NS_LOG_DEBUG ("DoReportAmpduTxStatus. TxRate=" << station->m_txrate << " SuccM pdus= " << |
713 (uint16_t)nSuccessfulMpdus << " FailedMpdus= " << (uint16_t)nFai ledMpdus); | 660 +nSuccessfulMpdus << " FailedMpdus= " << +nFailedMpdus); |
714 | 661 |
715 station->m_ampduPacketCount++; | 662 station->m_ampduPacketCount++; |
716 station->m_ampduLen += nSuccessfulMpdus + nFailedMpdus; | 663 station->m_ampduLen += nSuccessfulMpdus + nFailedMpdus; |
717 | 664 |
718 UpdatePacketCounters (station, nSuccessfulMpdus, nFailedMpdus); | 665 UpdatePacketCounters (station, nSuccessfulMpdus, nFailedMpdus); |
719 | 666 |
720 uint32_t rateId = GetRateId (station->m_txrate); | 667 uint32_t rateId = GetRateId (station->m_txrate); |
721 uint32_t groupId = GetGroupId (station->m_txrate); | 668 uint32_t groupId = GetGroupId (station->m_txrate); |
722 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess += nSucces sfulMpdus; | 669 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess += nSucces sfulMpdus; |
723 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt += nSucces sfulMpdus + nFailedMpdus; | 670 station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt += nSucces sfulMpdus + nFailedMpdus; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
846 } | 793 } |
847 NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate); | 794 NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate); |
848 } | 795 } |
849 | 796 |
850 void | 797 void |
851 MinstrelHtWifiManager::UpdateRetry (MinstrelHtWifiRemoteStation *station) | 798 MinstrelHtWifiManager::UpdateRetry (MinstrelHtWifiRemoteStation *station) |
852 { | 799 { |
853 NS_LOG_FUNCTION (this << station); | 800 NS_LOG_FUNCTION (this << station); |
854 station->m_shortRetry = 0; | 801 station->m_shortRetry = 0; |
855 station->m_longRetry = 0; | 802 station->m_longRetry = 0; |
856 | |
857 } | 803 } |
858 | 804 |
859 void | 805 void |
860 MinstrelHtWifiManager::UpdatePacketCounters (MinstrelHtWifiRemoteStation *statio n, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus) | 806 MinstrelHtWifiManager::UpdatePacketCounters (MinstrelHtWifiRemoteStation *statio n, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus) |
861 { | 807 { |
862 NS_LOG_FUNCTION (this << station << (uint16_t)nSuccessfulMpdus << (uint16_t)nF ailedMpdus); | 808 NS_LOG_FUNCTION (this << station << +nSuccessfulMpdus << +nFailedMpdus); |
863 | 809 |
864 station->m_totalPacketsCount += nSuccessfulMpdus + nFailedMpdus; | 810 station->m_totalPacketsCount += nSuccessfulMpdus + nFailedMpdus; |
865 if (station->m_isSampling) | 811 if (station->m_isSampling) |
866 { | 812 { |
867 station->m_samplePacketsCount += nSuccessfulMpdus + nFailedMpdus; | 813 station->m_samplePacketsCount += nSuccessfulMpdus + nFailedMpdus; |
868 } | 814 } |
869 if (station->m_totalPacketsCount == ~0) | 815 if (station->m_totalPacketsCount == ~0) |
870 { | 816 { |
871 station->m_samplePacketsCount = 0; | 817 station->m_samplePacketsCount = 0; |
872 station->m_totalPacketsCount = 0; | 818 station->m_totalPacketsCount = 0; |
873 } | 819 } |
874 | 820 |
875 if (!station->m_sampleWait && !station->m_sampleTries && station->m_sampleCoun t > 0) | 821 if (!station->m_sampleWait && !station->m_sampleTries && station->m_sampleCoun t > 0) |
876 { | 822 { |
877 station->m_sampleWait = static_cast<uint32_t>(16 + 2 * station->m_avgAmpdu Len); | 823 station->m_sampleWait = static_cast<uint32_t> (16 + 2 * station->m_avgAmpd uLen); |
878 station->m_sampleTries = 1; | 824 station->m_sampleTries = 1; |
879 station->m_sampleCount--; | 825 station->m_sampleCount--; |
880 } | 826 } |
881 | 827 } |
882 } | 828 |
883 void | 829 WifiTxVector |
884 MinstrelHtWifiManager::DoDisposeStation (WifiRemoteStation *st) | 830 MinstrelHtWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
885 { | 831 { |
886 NS_LOG_FUNCTION (this << st); | 832 NS_LOG_FUNCTION (this << st); |
887 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; | 833 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; |
888 station->DisposeStation (); | |
889 } | |
890 | |
891 WifiTxVector | |
892 MinstrelHtWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | |
893 { | |
894 NS_LOG_FUNCTION (this << st); | |
895 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; | |
896 | 834 |
897 if (!station->m_initialized) | 835 if (!station->m_initialized) |
898 { | 836 { |
899 CheckInit (station); | 837 CheckInit (station); |
900 } | 838 } |
901 | 839 |
902 if (!station->m_isHt) | 840 if (!station->m_isHt) |
903 { | 841 { |
904 WifiTxVector vector = m_legacyManager->GetDataTxVector (station); | 842 WifiTxVector vector = m_legacyManager->GetDataTxVector (station); |
905 | 843 |
906 uint64_t dataRate = vector.GetMode ().GetDataRate (vector); | 844 uint64_t dataRate = vector.GetMode ().GetDataRate (vector); |
907 if (!station->m_isSampling) | 845 if (!station->m_isSampling) |
908 { | 846 { |
909 m_rateChange (dataRate, station->m_state->m_address); | 847 m_rateChange (dataRate, station->m_state->m_address); |
910 } | 848 } |
911 | 849 |
912 return vector; | 850 return vector; |
913 } | 851 } |
914 else | 852 else |
915 { | 853 { |
916 NS_LOG_DEBUG ("DoGetDataMode m_txrate= " << station->m_txrate); | 854 NS_LOG_DEBUG ("DoGetDataMode m_txrate= " << station->m_txrate); |
917 | 855 |
918 uint32_t rateId = GetRateId (station->m_txrate); | 856 uint32_t rateId = GetRateId (station->m_txrate); |
919 uint32_t groupId = GetGroupId (station->m_txrate); | 857 uint32_t groupId = GetGroupId (station->m_txrate); |
920 uint32_t mcsIndex = station->m_groupsTable[groupId].m_ratesTable[rateId].m csIndex; | 858 uint8_t mcsIndex = static_cast<uint8_t> (station->m_groupsTable[groupId].m _ratesTable[rateId].mcsIndex); |
921 | 859 |
922 NS_LOG_DEBUG ("DoGetDataMode rateId= " << rateId << " groupId= " << groupI d << " mode= " << GetMcsSupported (station, mcsIndex)); | 860 NS_LOG_DEBUG ("DoGetDataMode rateId= " << rateId << " groupId= " << groupI d << " mode= " << GetMcsSupported (station, mcsIndex)); |
923 | 861 |
924 McsGroup group = m_minstrelGroups[groupId]; | 862 McsGroup group = m_minstrelGroups[groupId]; |
925 | 863 |
926 // Check consistency of rate selected. | 864 // Check consistency of rate selected. |
927 if ((group.sgi && !GetShortGuardInterval (station)) || group.chWidth > Get ChannelWidth (station) || group.streams > GetNumberOfSupportedStreams (station )) | 865 if ((group.sgi && !GetShortGuardInterval (station)) || group.chWidth > Get ChannelWidth (station) || group.streams > GetNumberOfSupportedStreams (station )) |
928 { | 866 { |
929 NS_ASSERT_MSG (false,"Inconsistent group selected. Group: (" << (uint1 6_t)group.streams << "," << (uint16_t)group.sgi << "," << (uint16_t)group.chWidt h << ")" << | 867 NS_ASSERT_MSG (false, "Inconsistent group selected. Group: (" << +grou p.streams << |
930 " Station capabilities: (" << GetNumberOfSupportedStrea ms (station) << "," << GetShortGuardInterval (station) << "," << GetChannelWidth (station) << ")"); | 868 "," << +group.sgi << "," << group.chWidth << ")" << |
869 " Station capabilities: (" << GetNumberOfSupportedStrea ms (station) << | |
870 "," << GetShortGuardInterval (station) << "," << GetCha nnelWidth (station) << ")"); | |
931 } | 871 } |
932 | 872 |
933 uint64_t dataRate = GetMcsSupported (station, mcsIndex).GetDataRate (group .chWidth, group.sgi ? 400 : 800, group.streams); | 873 uint64_t dataRate = GetMcsSupported (station, mcsIndex).GetDataRate (group .chWidth, group.sgi ? 400 : 800, group.streams); |
934 if (!station->m_isSampling) | 874 if (!station->m_isSampling) |
935 { | 875 { |
936 m_rateChange (dataRate, station->m_state->m_address); | 876 m_rateChange (dataRate, station->m_state->m_address); |
937 } | 877 } |
938 WifiMode mode = GetMcsSupported (station, mcsIndex); | 878 WifiMode mode = GetMcsSupported (station, mcsIndex); |
939 return WifiTxVector (mode, GetDefaultTxPowerLevel (), static_cast<uint8_t> (GetLongRetryCount (station)), | 879 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransm ission (mode, GetAddress (station)), group.sgi ? 400 : 800, GetNumberOfAntennas (), group.streams, static_cast<uint8_t> (GetNess (station)), GetChannelWidthForT ransmission (mode, group.chWidth), GetAggregation (station) && !station->m_isSam pling, false); |
940 GetPreambleForTransmission (mode, GetAddress (station )), group.sgi ? 400 : 800, GetNumberOfAntennas (), group.streams, (uint8_t)GetNe ss (station), group.chWidth, GetAggregation (station) && !station->m_isSampling, false); | |
941 } | 880 } |
942 } | 881 } |
943 | 882 |
944 WifiTxVector | 883 WifiTxVector |
945 MinstrelHtWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 884 MinstrelHtWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
946 { | 885 { |
947 NS_LOG_FUNCTION (this << st); | 886 NS_LOG_FUNCTION (this << st); |
948 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; | 887 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *) st; |
949 | 888 |
950 if (!station->m_initialized) | 889 if (!station->m_initialized) |
(...skipping 18 matching lines...) Expand all Loading... | |
969 * directed to the same receiving STA. If no rate in the BSSBasicRateSet p arameter meets | 908 * directed to the same receiving STA. If no rate in the BSSBasicRateSet p arameter meets |
970 * these conditions, the control frame shall be transmitted at a rate no h igher than the | 909 * these conditions, the control frame shall be transmitted at a rate no h igher than the |
971 * highest mandatory rate of the attached PHY that is less than or equal t o the rate | 910 * highest mandatory rate of the attached PHY that is less than or equal t o the rate |
972 * or non-HT reference rate (see 9.7.9) of the previously transmitted fram e that was | 911 * or non-HT reference rate (see 9.7.9) of the previously transmitted fram e that was |
973 * directed to the same receiving STA." | 912 * directed to the same receiving STA." |
974 */ | 913 */ |
975 | 914 |
976 // As we are in Minstrel HT, assume the last rate was an HT rate. | 915 // As we are in Minstrel HT, assume the last rate was an HT rate. |
977 uint32_t rateId = GetRateId (station->m_txrate); | 916 uint32_t rateId = GetRateId (station->m_txrate); |
978 uint32_t groupId = GetGroupId (station->m_txrate); | 917 uint32_t groupId = GetGroupId (station->m_txrate); |
979 uint32_t mcsIndex = station->m_groupsTable[groupId].m_ratesTable[rateId].m csIndex; | 918 uint8_t mcsIndex = static_cast<uint8_t> (station->m_groupsTable[groupId].m _ratesTable[rateId].mcsIndex); |
980 | 919 |
981 WifiMode lastRate = GetMcsSupported (station, mcsIndex); | 920 WifiMode lastRate = GetMcsSupported (station, mcsIndex); |
982 uint64_t lastDataRate = lastRate.GetNonHtReferenceRate (); | 921 uint64_t lastDataRate = lastRate.GetNonHtReferenceRate (); |
983 uint32_t nBasicRates = GetNBasicModes (); | 922 uint8_t nBasicRates = GetNBasicModes (); |
984 | 923 |
985 WifiMode rtsRate; | 924 WifiMode rtsRate; |
986 bool rateFound = false; | 925 bool rateFound = false; |
987 | 926 |
988 for (uint32_t i = 0; i < nBasicRates; i++) | 927 for (uint8_t i = 0; i < nBasicRates; i++) |
989 { | 928 { |
990 uint64_t rate = GetBasicMode (i).GetDataRate (20); | 929 uint64_t rate = GetBasicMode (i).GetDataRate (20); |
991 if (rate <= lastDataRate) | 930 if (rate <= lastDataRate) |
992 { | 931 { |
993 rtsRate = GetBasicMode (i); | 932 rtsRate = GetBasicMode (i); |
994 rateFound = true; | 933 rateFound = true; |
995 } | 934 } |
996 } | 935 } |
997 | 936 |
998 if (!rateFound) | 937 if (!rateFound) |
999 { | 938 { |
1000 Ptr<WifiPhy> phy = GetPhy (); | 939 Ptr<WifiPhy> phy = GetPhy (); |
1001 uint32_t nSupportRates = phy->GetNModes (); | 940 uint8_t nSupportRates = phy->GetNModes (); |
1002 for (uint32_t i = 0; i < nSupportRates; i++) | 941 for (uint8_t i = 0; i < nSupportRates; i++) |
1003 { | 942 { |
1004 uint64_t rate = phy->GetMode (i).GetDataRate (20); | 943 uint64_t rate = phy->GetMode (i).GetDataRate (20); |
1005 if (rate <= lastDataRate) | 944 if (rate <= lastDataRate) |
1006 { | 945 { |
1007 rtsRate = phy->GetMode (i); | 946 rtsRate = phy->GetMode (i); |
1008 rateFound = true; | 947 rateFound = true; |
1009 } | 948 } |
1010 } | 949 } |
1011 } | 950 } |
1012 | 951 |
1013 NS_ASSERT (rateFound); | 952 NS_ASSERT (rateFound); |
1014 | 953 |
1015 return WifiTxVector (rtsRate, GetDefaultTxPowerLevel (), static_cast<uint8 _t>(GetShortRetryCount (station)), GetPreambleForTransmission (rtsRate, GetAddre ss (station)), | 954 return WifiTxVector (rtsRate, GetDefaultTxPowerLevel (), GetPreambleForTra nsmission (rtsRate, GetAddress (station)), |
1016 800, 1, 1, 0, GetChannelWidth (station), GetAggregati on (station), false); | 955 800, 1, 1, 0, GetChannelWidthForTransmission (rtsRate , GetChannelWidth (station)), GetAggregation (station), false); |
1017 } | 956 } |
1018 } | 957 } |
1019 | 958 |
1020 bool | 959 bool |
1021 MinstrelHtWifiManager::DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<cons t Packet> packet, bool normally) | 960 MinstrelHtWifiManager::DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<cons t Packet> packet, bool normally) |
1022 { | 961 { |
1023 NS_LOG_FUNCTION (this << st << packet << normally); | 962 NS_LOG_FUNCTION (this << st << packet << normally); |
1024 | 963 |
1025 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; | 964 MinstrelHtWifiRemoteStation *station = (MinstrelHtWifiRemoteStation *)st; |
1026 | 965 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 else | 1011 else |
1073 { | 1012 { |
1074 return 1 + station->m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId] .retryCount + | 1013 return 1 + station->m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId] .retryCount + |
1075 station->m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId]. retryCount; | 1014 station->m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId]. retryCount; |
1076 } | 1015 } |
1077 } | 1016 } |
1078 | 1017 |
1079 bool | 1018 bool |
1080 MinstrelHtWifiManager::IsLowLatency (void) const | 1019 MinstrelHtWifiManager::IsLowLatency (void) const |
1081 { | 1020 { |
1082 NS_LOG_FUNCTION (this); | |
1083 return true; | 1021 return true; |
1084 } | 1022 } |
1085 | 1023 |
1086 uint32_t | 1024 uint32_t |
1087 MinstrelHtWifiManager::GetNextSample (MinstrelHtWifiRemoteStation *station) | 1025 MinstrelHtWifiManager::GetNextSample (MinstrelHtWifiRemoteStation *station) |
1088 { | 1026 { |
1089 NS_LOG_FUNCTION (this << station); | 1027 NS_LOG_FUNCTION (this << station); |
1090 | 1028 |
1091 uint32_t sampleGroup = station->m_sampleGroup; | 1029 uint32_t sampleGroup = station->m_sampleGroup; |
1092 | 1030 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1131 index = station->m_groupsTable[station->m_sampleGroup].m_index; | 1069 index = station->m_groupsTable[station->m_sampleGroup].m_index; |
1132 col = station->m_groupsTable[sampleGroup].m_col; | 1070 col = station->m_groupsTable[sampleGroup].m_col; |
1133 } | 1071 } |
1134 NS_LOG_DEBUG ("New sample set: group= " << sampleGroup << " index= " << statio n->m_sampleTable[index][col]); | 1072 NS_LOG_DEBUG ("New sample set: group= " << sampleGroup << " index= " << statio n->m_sampleTable[index][col]); |
1135 } | 1073 } |
1136 | 1074 |
1137 uint32_t | 1075 uint32_t |
1138 MinstrelHtWifiManager::FindRate (MinstrelHtWifiRemoteStation *station) | 1076 MinstrelHtWifiManager::FindRate (MinstrelHtWifiRemoteStation *station) |
1139 { | 1077 { |
1140 NS_LOG_FUNCTION (this << station); | 1078 NS_LOG_FUNCTION (this << station); |
1141 NS_LOG_DEBUG ("FindRate " << "packet=" << station->m_totalPacketsCount ); | 1079 NS_LOG_DEBUG ("FindRate packet=" << station->m_totalPacketsCount ); |
1142 | 1080 |
1143 if ((station->m_samplePacketsCount + station->m_totalPacketsCount) == 0) | 1081 if ((station->m_samplePacketsCount + station->m_totalPacketsCount) == 0) |
1144 { | 1082 { |
1145 return station->m_maxTpRate; | 1083 return station->m_maxTpRate; |
1146 } | 1084 } |
1147 | 1085 |
1148 // If we have waited enough, then sample. | 1086 // If we have waited enough, then sample. |
1149 if (station->m_sampleWait == 0 && station->m_sampleTries != 0) | 1087 if (station->m_sampleWait == 0 && station->m_sampleTries != 0) |
1150 { | 1088 { |
1151 //SAMPLING | 1089 //SAMPLING |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1189 uint32_t maxProbRateId = GetRateId (station->m_maxProbRate); | 1127 uint32_t maxProbRateId = GetRateId (station->m_maxProbRate); |
1190 | 1128 |
1191 uint8_t maxTpStreams = m_minstrelGroups[maxTpGroupId].streams; | 1129 uint8_t maxTpStreams = m_minstrelGroups[maxTpGroupId].streams; |
1192 uint8_t sampleStreams = m_minstrelGroups[sampleGroupId].streams; | 1130 uint8_t sampleStreams = m_minstrelGroups[sampleGroupId].streams; |
1193 | 1131 |
1194 Time sampleDuration = sampleRateInfo.perfectTxTime; | 1132 Time sampleDuration = sampleRateInfo.perfectTxTime; |
1195 Time maxTp2Duration = station->m_groupsTable[maxTp2GroupId].m_rate sTable[maxTp2RateId].perfectTxTime; | 1133 Time maxTp2Duration = station->m_groupsTable[maxTp2GroupId].m_rate sTable[maxTp2RateId].perfectTxTime; |
1196 Time maxProbDuration = station->m_groupsTable[maxProbGroupId].m_ra tesTable[maxProbRateId].perfectTxTime; | 1134 Time maxProbDuration = station->m_groupsTable[maxProbGroupId].m_ra tesTable[maxProbRateId].perfectTxTime; |
1197 | 1135 |
1198 NS_LOG_DEBUG ("Use sample rate? SampleDuration= " << sampleDuratio n << " maxTp2Duration= " << maxTp2Duration << | 1136 NS_LOG_DEBUG ("Use sample rate? SampleDuration= " << sampleDuratio n << " maxTp2Duration= " << maxTp2Duration << |
1199 " maxProbDuration= " << maxProbDuration << " sampleS treams= " << (uint16_t)sampleStreams << | 1137 " maxProbDuration= " << maxProbDuration << " sampleS treams= " << +sampleStreams << |
1200 " maxTpStreams= " << (uint16_t)maxTpStreams); | 1138 " maxTpStreams= " << +maxTpStreams); |
1201 if (sampleDuration < maxTp2Duration || (sampleStreams < maxTpStrea ms && sampleDuration < maxProbDuration)) | 1139 if (sampleDuration < maxTp2Duration || (sampleStreams < maxTpStrea ms && sampleDuration < maxProbDuration)) |
1202 { | 1140 { |
1203 /// Set flag that we are currently sampling. | 1141 /// Set flag that we are currently sampling. |
1204 station->m_isSampling = true; | 1142 station->m_isSampling = true; |
1205 | 1143 |
1206 /// set the rate that we're currently sampling | 1144 /// set the rate that we're currently sampling |
1207 station->m_sampleRate = sampleIdx; | 1145 station->m_sampleRate = sampleIdx; |
1208 | 1146 |
1209 NS_LOG_DEBUG ("FindRate " << "sampleRate=" << sampleIdx); | 1147 NS_LOG_DEBUG ("FindRate " << "sampleRate=" << sampleIdx); |
1210 station->m_sampleTries--; | 1148 station->m_sampleTries--; |
(...skipping 26 matching lines...) Expand all Loading... | |
1237 /// Continue using the best rate. | 1175 /// Continue using the best rate. |
1238 | 1176 |
1239 NS_LOG_DEBUG ("FindRate " << "maxTpRrate=" << station->m_maxTpRate); | 1177 NS_LOG_DEBUG ("FindRate " << "maxTpRrate=" << station->m_maxTpRate); |
1240 return station->m_maxTpRate; | 1178 return station->m_maxTpRate; |
1241 } | 1179 } |
1242 void | 1180 void |
1243 MinstrelHtWifiManager::UpdateStats (MinstrelHtWifiRemoteStation *station) | 1181 MinstrelHtWifiManager::UpdateStats (MinstrelHtWifiRemoteStation *station) |
1244 { | 1182 { |
1245 NS_LOG_FUNCTION (this << station); | 1183 NS_LOG_FUNCTION (this << station); |
1246 | 1184 |
1247 NS_LOG_DEBUG ("Updating stats=" << this); | |
1248 | |
1249 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; | 1185 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; |
1250 | 1186 |
1251 station->m_numSamplesSlow = 0; | 1187 station->m_numSamplesSlow = 0; |
1252 station->m_sampleCount = 0; | 1188 station->m_sampleCount = 0; |
1253 | 1189 |
1254 double tempProb; | 1190 double tempProb; |
1255 | 1191 |
1256 if (station->m_ampduPacketCount > 0) | 1192 if (station->m_ampduPacketCount > 0) |
1257 { | 1193 { |
1258 double newLen = station->m_ampduLen / station->m_ampduPacketCount; | 1194 double newLen = station->m_ampduLen / station->m_ampduPacketCount; |
1259 station->m_avgAmpduLen = ( newLen * (100 - m_ewmaLevel) + (station->m_avgA mpduLen * m_ewmaLevel) ) / 100; | 1195 station->m_avgAmpduLen = ( newLen * (100 - m_ewmaLevel) + (station->m_avgA mpduLen * m_ewmaLevel) ) / 100; |
1260 station->m_ampduLen = 0; | 1196 station->m_ampduLen = 0; |
1261 station->m_ampduPacketCount = 0; | 1197 station->m_ampduPacketCount = 0; |
1262 } | 1198 } |
1263 | 1199 |
1264 /* Initialize global rate indexes */ | 1200 /* Initialize global rate indexes */ |
1265 station->m_maxTpRate = GetLowestIndex (station); | 1201 station->m_maxTpRate = GetLowestIndex (station); |
1266 station->m_maxTpRate2 = GetLowestIndex (station); | 1202 station->m_maxTpRate2 = GetLowestIndex (station); |
1267 station->m_maxProbRate = GetLowestIndex (station); | 1203 station->m_maxProbRate = GetLowestIndex (station); |
1268 | 1204 |
1269 /// Update throughput and EWMA for each rate inside each group. | 1205 /// Update throughput and EWMA for each rate inside each group. |
1270 for (uint32_t j = 0; j < m_numGroups; j++) | 1206 for (uint8_t j = 0; j < m_numGroups; j++) |
1271 { | 1207 { |
1272 if (station->m_groupsTable[j].m_supported) | 1208 if (station->m_groupsTable[j].m_supported) |
1273 { | 1209 { |
1274 station->m_sampleCount++; | 1210 station->m_sampleCount++; |
1275 | 1211 |
1276 /* (re)Initialize group rate indexes */ | 1212 /* (re)Initialize group rate indexes */ |
1277 station->m_groupsTable[j].m_maxTpRate = GetLowestIndex (station, j); | 1213 station->m_groupsTable[j].m_maxTpRate = GetLowestIndex (station, j); |
1278 station->m_groupsTable[j].m_maxTpRate2 = GetLowestIndex (station, j); | 1214 station->m_groupsTable[j].m_maxTpRate2 = GetLowestIndex (station, j); |
1279 station->m_groupsTable[j].m_maxProbRate = GetLowestIndex (station, j); | 1215 station->m_groupsTable[j].m_maxProbRate = GetLowestIndex (station, j); |
1280 | 1216 |
1281 for (uint32_t i = 0; i < m_numRates; i++) | 1217 for (uint8_t i = 0; i < m_numRates; i++) |
1282 { | 1218 { |
1283 if (station->m_groupsTable[j].m_ratesTable[i].supported) | 1219 if (station->m_groupsTable[j].m_ratesTable[i].supported) |
1284 { | 1220 { |
1285 station->m_groupsTable[j].m_ratesTable[i].retryUpdated = false ; | 1221 station->m_groupsTable[j].m_ratesTable[i].retryUpdated = false ; |
1286 | 1222 |
1287 NS_LOG_DEBUG (i << " " << GetMcsSupported (station, station-> m_groupsTable[j].m_ratesTable[i].mcsIndex) << | 1223 NS_LOG_DEBUG (i << " " << GetMcsSupported (station, static_ca st<uint8_t> (station->m_groupsTable[j].m_ratesTable[i].mcsIndex)) << |
1288 "\t attempt=" << station->m_groupsTable[j].m_rat esTable[i].numRateAttempt << | 1224 "\t attempt=" << station->m_groupsTable[j].m_rat esTable[i].numRateAttempt << |
1289 "\t success=" << station->m_groupsTable[j].m_rat esTable[i].numRateSuccess); | 1225 "\t success=" << station->m_groupsTable[j].m_rat esTable[i].numRateSuccess); |
1290 | 1226 |
1291 /// If we've attempted something. | 1227 /// If we've attempted something. |
1292 if (station->m_groupsTable[j].m_ratesTable[i].numRateAttempt > 0) | 1228 if (station->m_groupsTable[j].m_ratesTable[i].numRateAttempt > 0) |
1293 { | 1229 { |
1294 station->m_groupsTable[j].m_ratesTable[i].numSamplesSkippe d = 0; | 1230 station->m_groupsTable[j].m_ratesTable[i].numSamplesSkippe d = 0; |
1295 /** | 1231 /** |
1296 * Calculate the probability of success. | 1232 * Calculate the probability of success. |
1297 * Assume probability scales from 0 to 100. | 1233 * Assume probability scales from 0 to 100. |
1298 */ | 1234 */ |
1299 tempProb = (100 * station->m_groupsTable[j].m_ratesTable[i ].numRateSuccess) / station->m_groupsTable[j].m_ratesTable[i].numRateAttempt; | 1235 tempProb = (100 * station->m_groupsTable[j].m_ratesTable[i ].numRateSuccess) / station->m_groupsTable[j].m_ratesTable[i].numRateAttempt; |
1300 | 1236 |
1301 /// Bookeeping. | 1237 /// Bookeeping. |
1302 station->m_groupsTable[j].m_ratesTable[i].prob = tempProb; | 1238 station->m_groupsTable[j].m_ratesTable[i].prob = tempProb; |
1303 | 1239 |
1304 if (station->m_groupsTable[j].m_ratesTable[i].successHist == 0) | 1240 if (station->m_groupsTable[j].m_ratesTable[i].successHist == 0) |
1305 { | 1241 { |
1306 station->m_groupsTable[j].m_ratesTable[i].ewmaProb = t empProb; | 1242 station->m_groupsTable[j].m_ratesTable[i].ewmaProb = t empProb; |
1307 } | 1243 } |
1308 else | 1244 else |
1309 { | 1245 { |
1310 station->m_groupsTable[j].m_ratesTable[i].ewmsdProb = CalculateEwmsd (station->m_groupsTable[j].m_ratesTable[i].ewmsdProb, | 1246 station->m_groupsTable[j].m_ratesTable[i].ewmsdProb = CalculateEwmsd (station->m_groupsTable[j].m_ratesTable[i].ewmsdProb, |
1311 tempProb, station->m_groupsTable[j].m_ratesTable[i].ewmaProb, | 1247 tempProb, station->m_groupsTable[j].m_ratesTable[i].ewmaProb, |
1312 static_cast<uint32_t>(m_ewmaLevel)); | 1248 m_ewmaLevel); |
1313 /// EWMA probability | 1249 /// EWMA probability |
1314 tempProb = (tempProb * (100 - m_ewmaLevel) + station-> m_groupsTable[j].m_ratesTable[i].ewmaProb * m_ewmaLevel) / 100; | 1250 tempProb = (tempProb * (100 - m_ewmaLevel) + station-> m_groupsTable[j].m_ratesTable[i].ewmaProb * m_ewmaLevel) / 100; |
1315 station->m_groupsTable[j].m_ratesTable[i].ewmaProb = t empProb; | 1251 station->m_groupsTable[j].m_ratesTable[i].ewmaProb = t empProb; |
1316 } | 1252 } |
1317 | 1253 |
1318 station->m_groupsTable[j].m_ratesTable[i].throughput = Cal culateThroughput (station, j, i, tempProb); | 1254 station->m_groupsTable[j].m_ratesTable[i].throughput = Cal culateThroughput (station, j, i, tempProb); |
1319 | 1255 |
1320 station->m_groupsTable[j].m_ratesTable[i].successHist += s tation->m_groupsTable[j].m_ratesTable[i].numRateSuccess; | 1256 station->m_groupsTable[j].m_ratesTable[i].successHist += s tation->m_groupsTable[j].m_ratesTable[i].numRateSuccess; |
1321 station->m_groupsTable[j].m_ratesTable[i].attemptHist += s tation->m_groupsTable[j].m_ratesTable[i].numRateAttempt; | 1257 station->m_groupsTable[j].m_ratesTable[i].attemptHist += s tation->m_groupsTable[j].m_ratesTable[i].numRateAttempt; |
1322 } | 1258 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1504 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob)) | 1440 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob)) |
1505 { | 1441 { |
1506 group->m_maxTpRate2 = index; | 1442 group->m_maxTpRate2 = index; |
1507 } | 1443 } |
1508 } | 1444 } |
1509 | 1445 |
1510 void | 1446 void |
1511 MinstrelHtWifiManager::RateInit (MinstrelHtWifiRemoteStation *station) | 1447 MinstrelHtWifiManager::RateInit (MinstrelHtWifiRemoteStation *station) |
1512 { | 1448 { |
1513 NS_LOG_FUNCTION (this << station); | 1449 NS_LOG_FUNCTION (this << station); |
1514 NS_LOG_DEBUG ("RateInit=" << station); | |
1515 | 1450 |
1516 station->m_groupsTable = McsGroupData (m_numGroups); | 1451 station->m_groupsTable = McsGroupData (m_numGroups); |
1517 | 1452 |
1518 /** | 1453 /** |
1519 * Initialize groups supported by the receiver. | 1454 * Initialize groups supported by the receiver. |
1520 */ | 1455 */ |
1521 NS_LOG_DEBUG ("Supported groups by station:"); | 1456 NS_LOG_DEBUG ("Supported groups by station:"); |
1522 for (uint32_t groupId = 0; groupId < m_numGroups; groupId++) | 1457 for (uint8_t groupId = 0; groupId < m_numGroups; groupId++) |
1523 { | 1458 { |
1524 if (m_minstrelGroups[groupId].isSupported) | 1459 if (m_minstrelGroups[groupId].isSupported) |
1525 { | 1460 { |
1526 station->m_groupsTable[groupId].m_supported = false; | 1461 station->m_groupsTable[groupId].m_supported = false; |
1527 if (!(!GetVhtSupported (station) && m_minstrelGroups[groupId].isVht) ///Is VHT supported by the receiver? | 1462 if (!(!GetVhtSupported (station) && m_minstrelGroups[groupId].isVht) ///Is VHT supported by the receiver? |
1528 && (m_minstrelGroups[groupId].isVht || !GetVhtSupported (station) || !m_useVhtOnly) ///If it is an HT MCS, check if VHT only is disabled | 1463 && (m_minstrelGroups[groupId].isVht || !GetVhtSupported (station) || !m_useVhtOnly) ///If it is an HT MCS, check if VHT only is disabled |
1529 && !(!GetShortGuardInterval (station) && m_minstrelGroups[groupId] .sgi) ///Is SGI supported by the receiver? | 1464 && !(!GetShortGuardInterval (station) && m_minstrelGroups[groupId] .sgi) ///Is SGI supported by the receiver? |
1530 && (GetChannelWidth (station) >= m_minstrelGroups[groupId].chWidth ) ///Is channel width supported by the receiver? | 1465 && (GetChannelWidth (station) >= m_minstrelGroups[groupId].chWidth ) ///Is channel width supported by the receiver? |
1531 && (GetNumberOfSupportedStreams (station) >= m_minstrelGroups[grou pId].streams)) ///Are streams supported by the receiver? | 1466 && (GetNumberOfSupportedStreams (station) >= m_minstrelGroups[grou pId].streams)) ///Are streams supported by the receiver? |
1532 { | 1467 { |
1533 NS_LOG_DEBUG ("Group " << groupId << ": (" << (uint16_t)m_minstrel Groups[groupId].streams << | 1468 NS_LOG_DEBUG ("Group " << groupId << ": (" << +m_minstrelGroups[gr oupId].streams << |
1534 "," << (uint16_t)m_minstrelGroups[groupId].sgi << ", " << (uint16_t)m_minstrelGroups[groupId].chWidth << ")"); | 1469 "," << +m_minstrelGroups[groupId].sgi << "," << m_mi nstrelGroups[groupId].chWidth << ")"); |
1535 | 1470 |
1536 station->m_groupsTable[groupId].m_supported = true; ///Group supported. | 1471 station->m_groupsTable[groupId].m_supported = true; ///Group supported. |
1537 station->m_groupsTable[groupId].m_col = 0; | 1472 station->m_groupsTable[groupId].m_col = 0; |
1538 station->m_groupsTable[groupId].m_index = 0; | 1473 station->m_groupsTable[groupId].m_index = 0; |
1539 | 1474 |
1540 station->m_groupsTable[groupId].m_ratesTable = HtMinstrelRate (m_n umRates); ///Create the rate list for the group. | 1475 station->m_groupsTable[groupId].m_ratesTable = HtMinstrelRate (m_n umRates); ///Create the rate list for the group. |
1541 for (uint32_t i = 0; i < m_numRates; i++) | 1476 for (uint8_t i = 0; i < m_numRates; i++) |
1542 { | 1477 { |
1543 station->m_groupsTable[groupId].m_ratesTable[i].supported = fa lse; | 1478 station->m_groupsTable[groupId].m_ratesTable[i].supported = fa lse; |
1544 } | 1479 } |
1545 | 1480 |
1546 // Initialize all modes supported by the remote station that belon g to the current group. | 1481 // Initialize all modes supported by the remote station that belon g to the current group. |
1547 for (uint32_t i = 0; i < station->m_nModes; i++) | 1482 for (uint8_t i = 0; i < station->m_nModes; i++) |
1548 { | 1483 { |
1549 WifiMode mode = GetMcsSupported (station, i); | 1484 WifiMode mode = GetMcsSupported (station, i); |
1550 | 1485 |
1551 ///Use the McsValue as the index in the rate table. | 1486 ///Use the McsValue as the index in the rate table. |
1552 ///This way, MCSs not supported are not initialized. | 1487 ///This way, MCSs not supported are not initialized. |
1553 uint32_t rateId = mode.GetMcsValue (); | 1488 uint8_t rateId = mode.GetMcsValue (); |
1554 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) | 1489 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
1555 { | 1490 { |
1556 rateId %= MAX_HT_GROUP_RATES; | 1491 rateId %= MAX_HT_GROUP_RATES; |
1557 } | 1492 } |
1558 | 1493 |
1559 if ((m_minstrelGroups[groupId].isVht && mode.GetModulationClas s () == WIFI_MOD_CLASS_VHT ///If it is a VHT MCS only add to a VHT group. | 1494 if ((m_minstrelGroups[groupId].isVht && mode.GetModulationClas s () == WIFI_MOD_CLASS_VHT ///If it is a VHT MCS only add to a VHT group. |
1560 && IsValidMcs (GetPhy (), m_minstrelGroups[groupId].strea ms, m_minstrelGroups[groupId].chWidth, mode)) ///Check validity of the VHT MCS | 1495 && IsValidMcs (GetPhy (), m_minstrelGroups[groupId].strea ms, m_minstrelGroups[groupId].chWidth, mode)) ///Check validity of the VHT MCS |
1561 || (!m_minstrelGroups[groupId].isVht && mode.GetModulatio nClass () == WIFI_MOD_CLASS_HT ///If it is a HT MCS only add to a HT group. | 1496 || (!m_minstrelGroups[groupId].isVht && mode.GetModulatio nClass () == WIFI_MOD_CLASS_HT ///If it is a HT MCS only add to a HT group. |
1562 && mode.GetMcsValue () < (m_minstrelGroups[groupId].st reams * 8) ///Check if the HT MCS correspon ds to groups number of streams. | 1497 && mode.GetMcsValue () < (m_minstrelGroups[groupId].st reams * 8) ///Check if the HT MCS correspon ds to groups number of streams. |
1563 && mode.GetMcsValue () >= ((m_minstrelGroups[groupId]. streams - 1) * 8))) | 1498 && mode.GetMcsValue () >= ((m_minstrelGroups[groupId]. streams - 1) * 8))) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 if (!station->m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated) | 1534 if (!station->m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated) |
1600 { | 1535 { |
1601 CalculateRetransmits (station, groupId, rateId); | 1536 CalculateRetransmits (station, groupId, rateId); |
1602 } | 1537 } |
1603 } | 1538 } |
1604 | 1539 |
1605 void | 1540 void |
1606 MinstrelHtWifiManager::CalculateRetransmits (MinstrelHtWifiRemoteStation *statio n, uint32_t groupId, uint32_t rateId) | 1541 MinstrelHtWifiManager::CalculateRetransmits (MinstrelHtWifiRemoteStation *statio n, uint32_t groupId, uint32_t rateId) |
1607 { | 1542 { |
1608 NS_LOG_FUNCTION (this << station << groupId << groupId); | 1543 NS_LOG_FUNCTION (this << station << groupId << groupId); |
1609 NS_LOG_DEBUG (" Calculating the number of retries"); | |
1610 | 1544 |
1611 uint32_t cw = 15; // Is an approximation. | 1545 uint32_t cw = 15; // Is an approximation. |
1612 uint32_t cwMax = 1023; | 1546 uint32_t cwMax = 1023; |
1613 Time cwTime, txTime, dataTxTime; | 1547 Time cwTime, txTime, dataTxTime; |
1614 Time slotTime = GetMac ()->GetSlot (); | 1548 Time slotTime = GetMac ()->GetSlot (); |
1615 Time ackTime = GetMac ()->GetBasicBlockAckTimeout (); | 1549 Time ackTime = GetMac ()->GetBasicBlockAckTimeout (); |
1616 | 1550 |
1617 if (station->m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb < 1) | 1551 if (station->m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb < 1) |
1618 { | 1552 { |
1619 station->m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 1; | 1553 station->m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 1; |
1620 } | 1554 } |
1621 else | 1555 else |
1622 { | 1556 { |
1623 station->m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 2; | 1557 station->m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 2; |
1624 station->m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated = true; | 1558 station->m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated = true; |
1625 | 1559 |
1626 dataTxTime = GetFirstMpduTxTime (groupId, GetMcsSupported (station, statio n->m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) + | 1560 uint8_t mcsIndex = static_cast<uint8_t> (station->m_groupsTable[groupId].m _ratesTable[rateId].mcsIndex); |
1627 GetMpduTxTime (groupId, GetMcsSupported (station, station->m_groupsTable [groupId].m_ratesTable[rateId].mcsIndex)) * static_cast<uint32_t>(station->m_avg AmpduLen - 1); | 1561 |
1562 dataTxTime = GetFirstMpduTxTime (groupId, GetMcsSupported (station, mcsInd ex)) + | |
1563 GetMpduTxTime (groupId, GetMcsSupported (station, mcsIndex)) * static_ca st<int64_t> ((station->m_avgAmpduLen - 1)); | |
1628 | 1564 |
1629 /* Contention time for first 2 tries */ | 1565 /* Contention time for first 2 tries */ |
1630 cwTime = (cw / 2) * slotTime; | 1566 cwTime = (cw / 2) * slotTime; |
1631 cw = Min ((cw + 1) * 2, cwMax); | 1567 cw = Min ((cw + 1) * 2, cwMax); |
1632 cwTime += (cw / 2) * slotTime; | 1568 cwTime += (cw / 2) * slotTime; |
1633 cw = Min ((cw + 1) * 2, cwMax); | 1569 cw = Min ((cw + 1) * 2, cwMax); |
1634 | 1570 |
1635 /* Total TX time for data and Contention after first 2 tries */ | 1571 /* Total TX time for data and Contention after first 2 tries */ |
1636 txTime = cwTime + 2 * (dataTxTime + ackTime); | 1572 txTime = cwTime + 2 * (dataTxTime + ackTime); |
1637 | 1573 |
1638 /* See how many more tries we can fit inside segment size */ | 1574 /* See how many more tries we can fit inside segment size */ |
1639 do | 1575 do |
1640 { | 1576 { |
1641 /* Contention time for this try */ | 1577 /* Contention time for this try */ |
1642 cwTime = (cw / 2) * slotTime; | 1578 cwTime = (cw / 2) * slotTime; |
1643 cw = Min ((cw + 1) * 2, cwMax); | 1579 cw = Min ((cw + 1) * 2, cwMax); |
1644 | 1580 |
1645 /* Total TX time after this try */ | 1581 /* Total TX time after this try */ |
1646 txTime += cwTime + ackTime + dataTxTime; | 1582 txTime += cwTime + ackTime + dataTxTime; |
1647 } | 1583 } |
1648 while ((txTime < MilliSeconds (6)) | 1584 while ((txTime < MilliSeconds (6)) |
1649 && (++station->m_groupsTable[groupId].m_ratesTable[rateId].retryCou nt < 7)); | 1585 && (++station->m_groupsTable[groupId].m_ratesTable[rateId].retryCou nt < 7)); |
1650 } | 1586 } |
1651 } | 1587 } |
1652 | 1588 |
1653 double | 1589 double |
1654 MinstrelHtWifiManager::CalculateEwmsd (double oldEwmsd, double currentProb, doub le ewmaProb, uint32_t weight) | 1590 MinstrelHtWifiManager::CalculateEwmsd (double oldEwmsd, double currentProb, doub le ewmaProb, double weight) |
1655 { | 1591 { |
1656 double diff, incr, tmp; | 1592 double diff, incr, tmp; |
1657 | 1593 |
1658 /* calculate exponential weighted moving variance */ | 1594 /* calculate exponential weighted moving variance */ |
1659 diff = currentProb - ewmaProb; | 1595 diff = currentProb - ewmaProb; |
1660 incr = (100 - weight) * diff / 100; | 1596 incr = (100 - weight) * diff / 100; |
1661 tmp = oldEwmsd * oldEwmsd; | 1597 tmp = oldEwmsd * oldEwmsd; |
1662 tmp = weight * (tmp + diff * incr) / 100; | 1598 tmp = weight * (tmp + diff * incr) / 100; |
1663 | 1599 |
1664 /* return standard deviation */ | 1600 /* return standard deviation */ |
1665 return sqrt (tmp); | 1601 return sqrt (tmp); |
1666 } | 1602 } |
1667 | 1603 |
1668 void | 1604 void |
1669 MinstrelHtWifiManager::InitSampleTable (MinstrelHtWifiRemoteStation *station) | 1605 MinstrelHtWifiManager::InitSampleTable (MinstrelHtWifiRemoteStation *station) |
1670 { | 1606 { |
1671 NS_LOG_DEBUG ("InitSampleTable=" << this); | 1607 NS_LOG_FUNCTION (this << station); |
1672 | |
1673 station->m_col = station->m_index = 0; | 1608 station->m_col = station->m_index = 0; |
1674 | 1609 |
1675 //for off-setting to make rates fall between 0 and nModes | 1610 //for off-setting to make rates fall between 0 and nModes |
1676 uint32_t numSampleRates = m_numRates; | 1611 uint8_t numSampleRates = m_numRates; |
1677 | 1612 |
1678 uint32_t newIndex; | 1613 uint32_t newIndex; |
1679 for (uint32_t col = 0; col < m_nSampleCol; col++) | 1614 for (uint32_t col = 0; col < m_nSampleCol; col++) |
1680 { | 1615 { |
1681 for (uint32_t i = 0; i < numSampleRates; i++ ) | 1616 for (uint32_t i = 0; i < numSampleRates; i++ ) |
1682 { | 1617 { |
1683 /** | 1618 /** |
1684 * The next two lines basically tries to generate a random number | 1619 * The next two lines basically tries to generate a random number |
1685 * between 0 and the number of available rates | 1620 * between 0 and the number of available rates |
1686 */ | 1621 */ |
1687 int uv = m_uniformRandomVariable->GetInteger (0, numSampleRates); | 1622 int uv = m_uniformRandomVariable->GetInteger (0, numSampleRates); |
1688 newIndex = (i + uv) % numSampleRates; | 1623 newIndex = (i + uv) % numSampleRates; |
1689 | 1624 |
1690 //this loop is used for filling in other uninitialized places | 1625 //this loop is used for filling in other uninitialized places |
1691 while (station->m_sampleTable[newIndex][col] != 0) | 1626 while (station->m_sampleTable[newIndex][col] != 0) |
1692 { | 1627 { |
1693 newIndex = (newIndex + 1) % m_numRates; | 1628 newIndex = (newIndex + 1) % m_numRates; |
1694 } | 1629 } |
1695 station->m_sampleTable[newIndex][col] = i; | 1630 station->m_sampleTable[newIndex][col] = i; |
1696 } | 1631 } |
1697 } | 1632 } |
1698 } | 1633 } |
1699 | 1634 |
1700 void | 1635 void |
1701 MinstrelHtWifiManager::PrintTable (MinstrelHtWifiRemoteStation *station) | 1636 MinstrelHtWifiManager::PrintTable (MinstrelHtWifiRemoteStation *station) |
1702 { | 1637 { |
1703 NS_LOG_FUNCTION (this << station); | |
1704 NS_LOG_DEBUG ("PrintTable=" << station); | |
1705 | |
1706 station->m_statsFile << " best ____________rate__________ _ _______statistics________ ________last_______ ______sum-of________\n" << | 1638 station->m_statsFile << " best ____________rate__________ _ _______statistics________ ________last_______ ______sum-of________\n" << |
1707 " mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(pr ob)] [prob.|retry|suc|att] [#success | #attempts]\n"; | 1639 " mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(pr ob)] [prob.|retry|suc|att] [#success | #attempts]\n"; |
1708 for (uint32_t i = 0; i < m_numGroups; i++) | 1640 for (uint8_t i = 0; i < m_numGroups; i++) |
1709 { | 1641 { |
1710 StatsDump (station, i, station->m_statsFile); | 1642 StatsDump (station, i, station->m_statsFile); |
1711 } | 1643 } |
1712 | 1644 |
1713 station->m_statsFile << "\nTotal packet count:: ideal " << Max (0, station- >m_totalPacketsCount - station->m_samplePacketsCount) << | 1645 station->m_statsFile << "\nTotal packet count:: ideal " << Max (0, station- >m_totalPacketsCount - station->m_samplePacketsCount) << |
1714 " lookaround " << station->m_samplePacketsCount << "\n"; | 1646 " lookaround " << station->m_samplePacketsCount << "\n"; |
1715 station->m_statsFile << "Average # of aggregated frames per A-MPDU: " << stati on->m_avgAmpduLen << "\n\n"; | 1647 station->m_statsFile << "Average # of aggregated frames per A-MPDU: " << stati on->m_avgAmpduLen << "\n\n"; |
1716 | 1648 |
1717 station->m_statsFile.flush (); | 1649 station->m_statsFile.flush (); |
1718 } | 1650 } |
1719 | 1651 |
1720 void | 1652 void |
1721 MinstrelHtWifiManager::StatsDump (MinstrelHtWifiRemoteStation *station, uint32_t groupId, std::ofstream &of) | 1653 MinstrelHtWifiManager::StatsDump (MinstrelHtWifiRemoteStation *station, uint32_t groupId, std::ofstream &of) |
1722 { | 1654 { |
1723 uint32_t numRates = m_numRates; | 1655 uint8_t numRates = m_numRates; |
1724 McsGroup group = m_minstrelGroups[groupId]; | 1656 McsGroup group = m_minstrelGroups[groupId]; |
1725 Time txTime; | 1657 Time txTime; |
1726 char giMode; | 1658 char giMode; |
1727 if (group.sgi) | 1659 if (group.sgi) |
1728 { | 1660 { |
1729 giMode = 'S'; | 1661 giMode = 'S'; |
1730 } | 1662 } |
1731 else | 1663 else |
1732 { | 1664 { |
1733 giMode = 'L'; | 1665 giMode = 'L'; |
1734 } | 1666 } |
1735 for (uint32_t i = 0; i < numRates; i++) | 1667 for (uint8_t i = 0; i < numRates; i++) |
1736 { | 1668 { |
1737 if (station->m_groupsTable[groupId].m_supported && station->m_groupsTable[ groupId].m_ratesTable[i].supported) | 1669 if (station->m_groupsTable[groupId].m_supported && station->m_groupsTable[ groupId].m_ratesTable[i].supported) |
1738 { | 1670 { |
1739 if (!group.isVht) | 1671 if (!group.isVht) |
1740 { | 1672 { |
1741 of << "HT" << group.chWidth << " " << giMode << "GI " << (int)g roup.streams << " "; | 1673 of << "HT" << group.chWidth << " " << giMode << "GI " << (int)g roup.streams << " "; |
1742 } | 1674 } |
1743 else | 1675 else |
1744 { | 1676 { |
1745 of << "VHT" << group.chWidth << " " << giMode << "GI " << (int) group.streams << " "; | 1677 of << "VHT" << group.chWidth << " " << giMode << "GI " << (int) group.streams << " "; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1809 NS_LOG_FUNCTION (this << groupId << rateId); | 1741 NS_LOG_FUNCTION (this << groupId << rateId); |
1810 uint32_t index; | 1742 uint32_t index; |
1811 index = groupId * m_numRates + rateId; | 1743 index = groupId * m_numRates + rateId; |
1812 return index; | 1744 return index; |
1813 } | 1745 } |
1814 | 1746 |
1815 uint32_t | 1747 uint32_t |
1816 MinstrelHtWifiManager::GetRateId (uint32_t index) | 1748 MinstrelHtWifiManager::GetRateId (uint32_t index) |
1817 { | 1749 { |
1818 NS_LOG_FUNCTION (this << index); | 1750 NS_LOG_FUNCTION (this << index); |
1819 | |
1820 uint32_t id; | 1751 uint32_t id; |
1821 id = index % m_numRates; | 1752 id = index % m_numRates; |
1822 return id; | 1753 return id; |
1823 } | 1754 } |
1824 | 1755 |
1825 uint32_t | 1756 uint32_t |
1826 MinstrelHtWifiManager::GetGroupId (uint32_t index) | 1757 MinstrelHtWifiManager::GetGroupId (uint32_t index) |
1827 { | 1758 { |
1828 NS_LOG_FUNCTION (this << index); | 1759 NS_LOG_FUNCTION (this << index); |
1829 | |
1830 return index / m_numRates; | 1760 return index / m_numRates; |
1831 } | 1761 } |
1832 | 1762 |
1833 uint32_t | 1763 uint32_t |
1834 MinstrelHtWifiManager::GetHtGroupId (uint8_t txstreams, uint8_t sgi, uint8_t chW idth) | 1764 MinstrelHtWifiManager::GetHtGroupId (uint8_t txstreams, uint8_t sgi, uint16_t ch Width) |
1835 { | 1765 { |
1836 NS_LOG_FUNCTION (this << (uint16_t)txstreams << (uint16_t)sgi << (uint16_t)chW idth); | 1766 NS_LOG_FUNCTION (this << +txstreams << +sgi << chWidth); |
1837 | |
1838 return MAX_SUPPORTED_STREAMS * 2 * (chWidth == 40 ? 1 : 0) + MAX_SUPPORTED_STR EAMS * sgi + txstreams - 1; | 1767 return MAX_SUPPORTED_STREAMS * 2 * (chWidth == 40 ? 1 : 0) + MAX_SUPPORTED_STR EAMS * sgi + txstreams - 1; |
1839 } | 1768 } |
1840 | 1769 |
1841 uint32_t | 1770 uint32_t |
1842 MinstrelHtWifiManager::GetVhtGroupId (uint8_t txstreams, uint8_t sgi, uint8_t ch Width) | 1771 MinstrelHtWifiManager::GetVhtGroupId (uint8_t txstreams, uint8_t sgi, uint16_t c hWidth) |
1843 { | 1772 { |
1844 NS_LOG_FUNCTION (this << (uint16_t)txstreams << (uint16_t)sgi << (uint16_t)chW idth); | 1773 NS_LOG_FUNCTION (this << +txstreams << +sgi << chWidth); |
1845 | |
1846 return MAX_HT_STREAM_GROUPS * MAX_SUPPORTED_STREAMS + MAX_SUPPORTED_STREAMS * 2 * (chWidth == 160 ? 3 : chWidth == 80 ? 2 : chWidth == 40 ? 1 : 0) + MAX_SUPPO RTED_STREAMS * sgi + txstreams - 1; | 1774 return MAX_HT_STREAM_GROUPS * MAX_SUPPORTED_STREAMS + MAX_SUPPORTED_STREAMS * 2 * (chWidth == 160 ? 3 : chWidth == 80 ? 2 : chWidth == 40 ? 1 : 0) + MAX_SUPPO RTED_STREAMS * sgi + txstreams - 1; |
1847 } | 1775 } |
1848 | 1776 |
1849 uint32_t | 1777 uint32_t |
1850 MinstrelHtWifiManager::GetLowestIndex (MinstrelHtWifiRemoteStation *station) | 1778 MinstrelHtWifiManager::GetLowestIndex (MinstrelHtWifiRemoteStation *station) |
1851 { | 1779 { |
1852 NS_LOG_FUNCTION (this << station); | 1780 NS_LOG_FUNCTION (this << station); |
1853 | 1781 |
1854 uint32_t groupId = 0; | 1782 uint32_t groupId = 0; |
1855 uint32_t rateId = 0; | 1783 uint32_t rateId = 0; |
(...skipping 16 matching lines...) Expand all Loading... | |
1872 | 1800 |
1873 uint32_t rateId = 0; | 1801 uint32_t rateId = 0; |
1874 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[ra teId].supported) | 1802 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[ra teId].supported) |
1875 { | 1803 { |
1876 rateId++; | 1804 rateId++; |
1877 } | 1805 } |
1878 NS_ASSERT (station->m_groupsTable[groupId].m_supported && station->m_groupsTab le[groupId].m_ratesTable[rateId].supported); | 1806 NS_ASSERT (station->m_groupsTable[groupId].m_supported && station->m_groupsTab le[groupId].m_ratesTable[rateId].supported); |
1879 return GetIndex (groupId, rateId); | 1807 return GetIndex (groupId, rateId); |
1880 } | 1808 } |
1881 | 1809 |
1882 | |
1883 WifiModeList | 1810 WifiModeList |
1884 MinstrelHtWifiManager::GetVhtDeviceMcsList (void) const | 1811 MinstrelHtWifiManager::GetVhtDeviceMcsList (void) const |
1885 { | 1812 { |
1886 WifiModeList vhtMcsList; | 1813 WifiModeList vhtMcsList; |
1887 Ptr<WifiPhy> phy = GetPhy (); | 1814 Ptr<WifiPhy> phy = GetPhy (); |
1888 for (uint32_t i = 0; i < phy->GetNMcs (); i++) | 1815 for (uint8_t i = 0; i < phy->GetNMcs (); i++) |
1889 { | 1816 { |
1890 WifiMode mode = phy->GetMcs (static_cast<uint8_t>(i)); | 1817 WifiMode mode = phy->GetMcs (i); |
S. Deronne
2017/12/17 15:39:15
simply define i as uint8_t
ammo6818-vandals.uidaho.edu
2017/12/20 04:16:34
changed as noted.
| |
1891 if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT) | 1818 if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT) |
1892 { | 1819 { |
1893 vhtMcsList.push_back (mode); | 1820 vhtMcsList.push_back (mode); |
1894 } | 1821 } |
1895 } | 1822 } |
1896 return vhtMcsList; | 1823 return vhtMcsList; |
1897 } | 1824 } |
1898 | 1825 |
1899 WifiModeList | 1826 WifiModeList |
1900 MinstrelHtWifiManager::GetHtDeviceMcsList (void) const | 1827 MinstrelHtWifiManager::GetHtDeviceMcsList (void) const |
1901 { | 1828 { |
1902 WifiModeList htMcsList; | 1829 WifiModeList htMcsList; |
1903 Ptr<WifiPhy> phy = GetPhy (); | 1830 Ptr<WifiPhy> phy = GetPhy (); |
1904 for (uint32_t i = 0; i < phy->GetNMcs (); i++) | 1831 for (uint8_t i = 0; i < phy->GetNMcs (); i++) |
1905 { | 1832 { |
1906 WifiMode mode = phy->GetMcs (static_cast<uint8_t>(i)); | 1833 WifiMode mode = phy->GetMcs (i); |
S. Deronne
2017/12/17 15:39:15
same here
ammo6818-vandals.uidaho.edu
2017/12/20 04:16:33
changed as noted.
| |
1907 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) | 1834 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
1908 { | 1835 { |
1909 htMcsList.push_back (mode); | 1836 htMcsList.push_back (mode); |
1910 } | 1837 } |
1911 } | 1838 } |
1912 return htMcsList; | 1839 return htMcsList; |
1913 } | 1840 } |
1914 | 1841 |
1915 void | 1842 void |
1916 MinstrelHtWifiManager::SetHeSupported (bool enable) | 1843 MinstrelHtWifiManager::SetHeSupported (bool enable) |
1917 { | 1844 { |
1918 //HE is not supported yet by this algorithm. | 1845 //HE is not supported yet by this algorithm. |
1919 if (enable) | 1846 if (enable) |
1920 { | 1847 { |
1921 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat es"); | 1848 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat es"); |
1922 } | 1849 } |
1923 } | 1850 } |
1924 | 1851 |
1925 } // namespace ns3 | 1852 } // namespace ns3 |
1926 | |
1927 | |
1928 | |
1929 | |
1930 | |
LEFT | RIGHT |