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) 2006, 2009 INRIA | 3 * Copyright (c) 2006, 2009 INRIA |
4 * Copyright (c) 2009 MIRKO BANCHI | 4 * Copyright (c) 2009 MIRKO BANCHI |
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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | 16 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 * | 18 * |
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
20 * Mirko Banchi <mk.banchi@gmail.com> | 20 * Mirko Banchi <mk.banchi@gmail.com> |
21 */ | 21 */ |
22 | 22 |
23 #include "ns3/log.h" | |
24 #include "ns3/packet.h" | |
25 #include "ns3/simulator.h" | |
26 #include "ns3/pointer.h" | |
27 #include "ns3/string.h" | |
28 #include "ns3/random-variable-stream.h" | |
23 #include "ap-wifi-mac.h" | 29 #include "ap-wifi-mac.h" |
24 #include "ns3/log.h" | |
25 #include "ns3/simulator.h" | |
26 #include "ns3/string.h" | |
27 #include "ns3/pointer.h" | |
28 #include "mac-low.h" | 30 #include "mac-low.h" |
29 #include "mac-tx-middle.h" | 31 #include "mac-tx-middle.h" |
32 #include "mgt-headers.h" | |
33 #include "msdu-aggregator.h" | |
34 #include "amsdu-subframe-header.h" | |
35 #include "wifi-phy.h" | |
30 | 36 |
31 namespace ns3 { | 37 namespace ns3 { |
32 | 38 |
33 NS_LOG_COMPONENT_DEFINE ("ApWifiMac"); | 39 NS_LOG_COMPONENT_DEFINE ("ApWifiMac"); |
34 | 40 |
35 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac); | 41 NS_OBJECT_ENSURE_REGISTERED (ApWifiMac); |
36 | 42 |
37 TypeId | 43 TypeId |
38 ApWifiMac::GetTypeId (void) | 44 ApWifiMac::GetTypeId (void) |
39 { | 45 { |
(...skipping 14 matching lines...) Expand all Loading... | |
54 MakePointerAccessor (&ApWifiMac::m_beaconJitter), | 60 MakePointerAccessor (&ApWifiMac::m_beaconJitter), |
55 MakePointerChecker<UniformRandomVariable> ()) | 61 MakePointerChecker<UniformRandomVariable> ()) |
56 .AddAttribute ("EnableBeaconJitter", | 62 .AddAttribute ("EnableBeaconJitter", |
57 "If beacons are enabled, whether to jitter the initial send e vent.", | 63 "If beacons are enabled, whether to jitter the initial send e vent.", |
58 BooleanValue (true), | 64 BooleanValue (true), |
59 MakeBooleanAccessor (&ApWifiMac::m_enableBeaconJitter), | 65 MakeBooleanAccessor (&ApWifiMac::m_enableBeaconJitter), |
60 MakeBooleanChecker ()) | 66 MakeBooleanChecker ()) |
61 .AddAttribute ("BeaconGeneration", | 67 .AddAttribute ("BeaconGeneration", |
62 "Whether or not beacons are generated.", | 68 "Whether or not beacons are generated.", |
63 BooleanValue (true), | 69 BooleanValue (true), |
64 MakeBooleanAccessor (&ApWifiMac::SetBeaconGeneration, | 70 MakeBooleanAccessor (&ApWifiMac::SetBeaconGeneration), |
65 &ApWifiMac::GetBeaconGeneration), | |
66 MakeBooleanChecker ()) | 71 MakeBooleanChecker ()) |
67 .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanis m should be used when non-ERP STAs are present within the BSS." | 72 .AddAttribute ("EnableNonErpProtection", "Whether or not protection mechanis m should be used when non-ERP STAs are present within the BSS." |
68 "This parameter is only used when ERP is supported by the AP. ", | 73 "This parameter is only used when ERP is supported by the AP. ", |
69 BooleanValue (true), | 74 BooleanValue (true), |
70 MakeBooleanAccessor (&ApWifiMac::m_enableNonErpProtection), | 75 MakeBooleanAccessor (&ApWifiMac::m_enableNonErpProtection), |
71 MakeBooleanChecker ()) | 76 MakeBooleanChecker ()) |
72 .AddAttribute ("RifsMode", "If non-HT STAs are detected, whether to force RI FS to be disabled within the BSS." | 77 .AddAttribute ("RifsMode", "If non-HT STAs are detected, whether to force RI FS to be disabled within the BSS." |
73 "This parameter is only used when HT is supported by the AP." , | 78 "This parameter is only used when HT is supported by the AP." , |
74 BooleanValue (true), | 79 BooleanValue (true), |
75 MakeBooleanAccessor (&ApWifiMac::m_disableRifs), | 80 MakeBooleanAccessor (&ApWifiMac::m_disableRifs), |
76 MakeBooleanChecker ()) | 81 MakeBooleanChecker ()) |
77 ; | 82 ; |
78 return tid; | 83 return tid; |
79 } | 84 } |
80 | 85 |
81 ApWifiMac::ApWifiMac () | 86 ApWifiMac::ApWifiMac () |
82 : m_enableBeaconGeneration (false) | 87 : m_enableBeaconGeneration (false) |
83 { | 88 { |
84 NS_LOG_FUNCTION (this); | 89 NS_LOG_FUNCTION (this); |
85 m_beaconDca = CreateObject<DcaTxop> (); | 90 m_beaconDca = CreateObject<DcaTxop> (); |
86 m_beaconDca->SetAifsn (1); | 91 m_beaconDca->SetAifsn (1); |
87 m_beaconDca->SetMinCw (0); | 92 m_beaconDca->SetMinCw (0); |
88 m_beaconDca->SetMaxCw (0); | 93 m_beaconDca->SetMaxCw (0); |
89 m_beaconDca->SetLow (m_low); | 94 m_beaconDca->SetMacLow (m_low); |
90 m_beaconDca->SetManager (m_dcfManager); | 95 m_beaconDca->SetDcfManager (m_dcfManager); |
91 m_beaconDca->SetTxMiddle (m_txMiddle); | 96 m_beaconDca->SetTxMiddle (m_txMiddle); |
92 | 97 |
93 //Let the lower layers know that we are acting as an AP. | 98 //Let the lower layers know that we are acting as an AP. |
94 SetTypeOfStation (AP); | 99 SetTypeOfStation (AP); |
95 } | 100 } |
96 | 101 |
97 ApWifiMac::~ApWifiMac () | 102 ApWifiMac::~ApWifiMac () |
98 { | 103 { |
99 NS_LOG_FUNCTION (this); | 104 NS_LOG_FUNCTION (this); |
100 m_staList.clear (); | 105 m_staList.clear (); |
(...skipping 30 matching lines...) Expand all Loading... | |
131 { | 136 { |
132 m_beaconEvent.Cancel (); | 137 m_beaconEvent.Cancel (); |
133 } | 138 } |
134 else if (enable && !m_enableBeaconGeneration) | 139 else if (enable && !m_enableBeaconGeneration) |
135 { | 140 { |
136 m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, this); | 141 m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, this); |
137 } | 142 } |
138 m_enableBeaconGeneration = enable; | 143 m_enableBeaconGeneration = enable; |
139 } | 144 } |
140 | 145 |
141 bool | |
142 ApWifiMac::GetBeaconGeneration (void) const | |
143 { | |
144 NS_LOG_FUNCTION (this); | |
145 return m_enableBeaconGeneration; | |
146 } | |
147 | |
148 Time | 146 Time |
149 ApWifiMac::GetBeaconInterval (void) const | 147 ApWifiMac::GetBeaconInterval (void) const |
150 { | 148 { |
151 NS_LOG_FUNCTION (this); | 149 NS_LOG_FUNCTION (this); |
152 return m_beaconInterval; | 150 return m_beaconInterval; |
153 } | 151 } |
154 | 152 |
155 void | 153 void |
156 ApWifiMac::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> stat ionManager) | 154 ApWifiMac::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> stat ionManager) |
157 { | 155 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 191 |
194 bool | 192 bool |
195 ApWifiMac::GetShortSlotTimeEnabled (void) const | 193 ApWifiMac::GetShortSlotTimeEnabled (void) const |
196 { | 194 { |
197 if (m_nonErpStations.size () != 0) | 195 if (m_nonErpStations.size () != 0) |
198 { | 196 { |
199 return false; | 197 return false; |
200 } | 198 } |
201 if (m_erpSupported == true && GetShortSlotTimeSupported () == true) | 199 if (m_erpSupported == true && GetShortSlotTimeSupported () == true) |
202 { | 200 { |
203 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++) | 201 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++) |
204 { | 202 { |
205 if (m_stationManager->GetShortSlotTimeSupported (*i) == false) | 203 if (m_stationManager->GetShortSlotTimeSupported (i->second) == false) |
206 { | 204 { |
207 return false; | 205 return false; |
208 } | 206 } |
209 } | 207 } |
210 return true; | 208 return true; |
211 } | 209 } |
212 return false; | 210 return false; |
213 } | 211 } |
214 | 212 |
215 bool | 213 bool |
(...skipping 10 matching lines...) Expand all Loading... | |
226 } | 224 } |
227 return true; | 225 return true; |
228 } | 226 } |
229 return false; | 227 return false; |
230 } | 228 } |
231 | 229 |
232 bool | 230 bool |
233 ApWifiMac::IsNonGfHtStasPresent (void) const | 231 ApWifiMac::IsNonGfHtStasPresent (void) const |
234 { | 232 { |
235 bool isNonGfHtStasPresent = false; | 233 bool isNonGfHtStasPresent = false; |
236 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_st aList.end (); i++) | 234 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++) |
237 { | 235 { |
238 if (m_stationManager->GetGreenfieldSupported (*i) == false) | 236 if (m_stationManager->GetGreenfieldSupported (i->second) == false) |
239 { | 237 { |
240 isNonGfHtStasPresent = true; | 238 isNonGfHtStasPresent = true; |
241 break; | 239 break; |
242 } | 240 } |
243 } | 241 } |
244 m_stationManager->SetUseGreenfieldProtection (isNonGfHtStasPresent); | 242 m_stationManager->SetUseGreenfieldProtection (isNonGfHtStasPresent); |
245 return isNonGfHtStasPresent; | 243 return isNonGfHtStasPresent; |
246 } | 244 } |
247 | 245 |
248 uint8_t | 246 uint16_t |
249 ApWifiMac::GetVhtOperationalChannelWidth (void) const | 247 ApWifiMac::GetVhtOperationalChannelWidth (void) const |
250 { | 248 { |
251 uint8_t channelWidth = m_phy->GetChannelWidth (); | 249 uint16_t channelWidth = m_phy->GetChannelWidth (); |
252 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_st aList.end (); i++) | 250 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++) |
253 { | 251 { |
254 if (m_stationManager->GetVhtSupported (*i)) | 252 if (m_stationManager->GetVhtSupported (i->second)) |
255 { | 253 { |
256 if (m_stationManager->GetChannelWidthSupported (*i) < channelWidth) | 254 if (m_stationManager->GetChannelWidthSupported (i->second) < channelWi dth) |
257 { | 255 { |
258 channelWidth = m_stationManager->GetChannelWidthSupported (*i); | 256 channelWidth = m_stationManager->GetChannelWidthSupported (i->seco nd); |
259 } | 257 } |
260 } | 258 } |
261 } | 259 } |
262 return channelWidth; | 260 return channelWidth; |
263 } | 261 } |
264 | 262 |
265 void | 263 void |
266 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, | 264 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, |
267 Mac48Address to) | 265 Mac48Address to) |
268 { | 266 { |
(...skipping 16 matching lines...) Expand all Loading... | |
285 } | 283 } |
286 } | 284 } |
287 | 285 |
288 ForwardDown (packet, from, to, tid); | 286 ForwardDown (packet, from, to, tid); |
289 } | 287 } |
290 | 288 |
291 void | 289 void |
292 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, | 290 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, |
293 Mac48Address to, uint8_t tid) | 291 Mac48Address to, uint8_t tid) |
294 { | 292 { |
295 NS_LOG_FUNCTION (this << packet << from << to << static_cast<uint32_t> (tid)); | 293 NS_LOG_FUNCTION (this << packet << from << to << +tid); |
296 WifiMacHeader hdr; | 294 WifiMacHeader hdr; |
297 | 295 |
298 //For now, an AP that supports QoS does not support non-QoS | 296 //For now, an AP that supports QoS does not support non-QoS |
299 //associations, and vice versa. In future the AP model should | 297 //associations, and vice versa. In future the AP model should |
300 //support simultaneously associated QoS and non-QoS STAs, at which | 298 //support simultaneously associated QoS and non-QoS STAs, at which |
301 //point there will need to be per-association QoS state maintained | 299 //point there will need to be per-association QoS state maintained |
302 //by the association state machine, and consulted here. | 300 //by the association state machine, and consulted here. |
303 if (m_qosSupported) | 301 if (m_qosSupported) |
304 { | 302 { |
305 hdr.SetType (WIFI_MAC_QOSDATA); | 303 hdr.SetType (WIFI_MAC_QOSDATA); |
306 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); | 304 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); |
307 hdr.SetQosNoEosp (); | 305 hdr.SetQosNoEosp (); |
308 hdr.SetQosNoAmsdu (); | 306 hdr.SetQosNoAmsdu (); |
309 //Transmission of multiple frames in the same Polled TXOP is not supported for now | 307 //Transmission of multiple frames in the same Polled TXOP is not supported for now |
310 hdr.SetQosTxopLimit (0); | 308 hdr.SetQosTxopLimit (0); |
311 //Fill in the QoS control field in the MAC header | 309 //Fill in the QoS control field in the MAC header |
312 hdr.SetQosTid (tid); | 310 hdr.SetQosTid (tid); |
313 } | 311 } |
314 else | 312 else |
315 { | 313 { |
316 hdr.SetType (WIFI_MAC_DATA); | 314 hdr.SetType (WIFI_MAC_DATA); |
317 } | 315 } |
318 | 316 |
319 if (m_htSupported || m_vhtSupported || m_heSupported) | 317 if (m_qosSupported || m_htSupported || m_vhtSupported || m_heSupported) |
320 { | 318 { |
321 hdr.SetNoOrder (); | 319 hdr.SetNoOrder (); |
322 } | 320 } |
323 hdr.SetAddr1 (to); | 321 hdr.SetAddr1 (to); |
324 hdr.SetAddr2 (GetAddress ()); | 322 hdr.SetAddr2 (GetAddress ()); |
325 hdr.SetAddr3 (from); | 323 hdr.SetAddr3 (from); |
326 hdr.SetDsFrom (); | 324 hdr.SetDsFrom (); |
327 hdr.SetDsNotTo (); | 325 hdr.SetDsNotTo (); |
328 | 326 |
329 if (m_qosSupported) | 327 if (m_qosSupported) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 ApWifiMac::GetSupportedRates (void) const | 371 ApWifiMac::GetSupportedRates (void) const |
374 { | 372 { |
375 NS_LOG_FUNCTION (this); | 373 NS_LOG_FUNCTION (this); |
376 SupportedRates rates; | 374 SupportedRates rates; |
377 //If it is an HT-AP or VHT-AP or HE-AP, then add the BSSMembershipSelectorSet | 375 //If it is an HT-AP or VHT-AP or HE-AP, then add the BSSMembershipSelectorSet |
378 //The standard says that the BSSMembershipSelectorSet | 376 //The standard says that the BSSMembershipSelectorSet |
379 //must have its MSB set to 1 (must be treated as a Basic Rate) | 377 //must have its MSB set to 1 (must be treated as a Basic Rate) |
380 //Also the standard mentioned that at least 1 element should be included in th e SupportedRates the rest can be in the ExtendedSupportedRates | 378 //Also the standard mentioned that at least 1 element should be included in th e SupportedRates the rest can be in the ExtendedSupportedRates |
381 if (m_htSupported || m_vhtSupported || m_heSupported) | 379 if (m_htSupported || m_vhtSupported || m_heSupported) |
382 { | 380 { |
383 for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++) | 381 for (uint8_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++) |
384 { | 382 { |
385 rates.AddBssMembershipSelectorRate (m_phy->GetBssMembershipSelector (i )); | 383 rates.AddBssMembershipSelectorRate (m_phy->GetBssMembershipSelector (i )); |
386 } | 384 } |
387 } | 385 } |
388 // | 386 // |
389 //Send the set of supported rates and make sure that we indicate | 387 //Send the set of supported rates and make sure that we indicate |
390 //the Basic Rate set in this set of supported rates. | 388 //the Basic Rate set in this set of supported rates. |
391 for (uint32_t i = 0; i < m_phy->GetNModes (); i++) | 389 for (uint8_t i = 0; i < m_phy->GetNModes (); i++) |
392 { | 390 { |
393 WifiMode mode = m_phy->GetMode (i); | 391 WifiMode mode = m_phy->GetMode (i); |
394 uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); | 392 uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); |
395 NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate); | 393 NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate); |
396 rates.AddSupportedRate (static_cast<uint32_t>(modeDataRate)); | 394 rates.AddSupportedRate (modeDataRate); |
S. Deronne
2017/12/17 15:39:14
32 or 64 bits?
ammo6818-vandals.uidaho.edu
2017/12/20 04:16:32
The parameter to AddSupportedRate takes a uint32_t
S. Deronne
2017/12/22 22:28:21
maybe AddSupportedRate should take uint64_t as inp
ammo6818-vandals.uidaho.edu
2017/12/23 15:14:32
implemented this change. also modified the other
| |
397 //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!) | 395 //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!) |
398 //here we choose to add the mandatory rates to the BSSBasicRateSet, | 396 //here we choose to add the mandatory rates to the BSSBasicRateSet, |
399 //except for 802.11b where we assume that only the non HR-DSSS rates are p art of the BSSBasicRateSet | 397 //except for 802.11b where we assume that only the non HR-DSSS rates are p art of the BSSBasicRateSet |
400 if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_H R_DSSS)) | 398 if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_H R_DSSS)) |
401 { | 399 { |
402 NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ()); | 400 NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ()); |
403 m_stationManager->AddBasicMode (mode); | 401 m_stationManager->AddBasicMode (mode); |
404 } | 402 } |
405 } | 403 } |
406 //set the basic rates | 404 //set the basic rates |
407 for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++) | 405 for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++) |
408 { | 406 { |
409 WifiMode mode = m_stationManager->GetBasicMode (j); | 407 WifiMode mode = m_stationManager->GetBasicMode (j); |
410 uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); | 408 uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); |
411 NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ()); | 409 NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ()); |
412 rates.SetBasicRate (static_cast<uint32_t>(modeDataRate)); | 410 rates.SetBasicRate (modeDataRate); |
S. Deronne
2017/12/17 15:39:14
same comment
ammo6818-vandals.uidaho.edu
2017/12/20 04:16:32
The parameter to AddSupportedRate takes a uint32_t
| |
413 } | 411 } |
414 | 412 |
415 return rates; | 413 return rates; |
416 } | 414 } |
417 | 415 |
418 DsssParameterSet | 416 DsssParameterSet |
419 ApWifiMac::GetDsssParameterSet (void) const | 417 ApWifiMac::GetDsssParameterSet (void) const |
420 { | 418 { |
421 NS_LOG_FUNCTION (this); | 419 NS_LOG_FUNCTION (this); |
422 DsssParameterSet dsssParameters; | 420 DsssParameterSet dsssParameters; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 EdcaParameterSet edcaParameters; | 466 EdcaParameterSet edcaParameters; |
469 if (m_qosSupported) | 467 if (m_qosSupported) |
470 { | 468 { |
471 edcaParameters.SetQosSupported (1); | 469 edcaParameters.SetQosSupported (1); |
472 Ptr<EdcaTxopN> edca; | 470 Ptr<EdcaTxopN> edca; |
473 Time txopLimit; | 471 Time txopLimit; |
474 | 472 |
475 edca = m_edca.find (AC_BE)->second; | 473 edca = m_edca.find (AC_BE)->second; |
476 txopLimit = edca->GetTxopLimit (); | 474 txopLimit = edca->GetTxopLimit (); |
477 edcaParameters.SetBeAci (0); | 475 edcaParameters.SetBeAci (0); |
478 edcaParameters.SetBeCWmin (static_cast<uint8_t>(edca->GetMinCw ())); | 476 edcaParameters.SetBeCWmin (edca->GetMinCw ()); |
479 edcaParameters.SetBeCWmax (static_cast<uint8_t>(edca->GetMaxCw ())); | 477 edcaParameters.SetBeCWmax (edca->GetMaxCw ()); |
480 edcaParameters.SetBeAifsn (static_cast<uint8_t>(edca->GetAifsn ())); | 478 edcaParameters.SetBeAifsn (static_cast<uint8_t> (edca->GetAifsn ())); |
S. Deronne
2018/05/11 14:46:04
maybe worth to check in the standard whether we ca
| |
481 edcaParameters.SetBeTXOPLimit (static_cast<uint16_t>(txopLimit.GetMicroSec onds () / 32)); | 479 edcaParameters.SetBeTXOPLimit (static_cast<uint16_t> (txopLimit.GetMicroSe conds () / 32)); |
482 edcaParameters.SetBeAcm (0); | |
483 | 480 |
484 edca = m_edca.find (AC_BK)->second; | 481 edca = m_edca.find (AC_BK)->second; |
485 txopLimit = edca->GetTxopLimit (); | 482 txopLimit = edca->GetTxopLimit (); |
486 edcaParameters.SetBkAci (1); | 483 edcaParameters.SetBkAci (1); |
487 edcaParameters.SetBkCWmin (static_cast<uint8_t>(edca->GetMinCw ())); | 484 edcaParameters.SetBkCWmin (edca->GetMinCw ()); |
488 edcaParameters.SetBkCWmax (static_cast<uint8_t>(edca->GetMaxCw ())); | 485 edcaParameters.SetBkCWmax (edca->GetMaxCw ()); |
489 edcaParameters.SetBkAifsn (static_cast<uint8_t>(edca->GetAifsn ())); | 486 edcaParameters.SetBkAifsn (static_cast<uint8_t> (edca->GetAifsn ())); |
490 edcaParameters.SetBkTXOPLimit (static_cast<uint16_t>(txopLimit.GetMicroSec onds () / 32)); | 487 edcaParameters.SetBkTXOPLimit (static_cast<uint16_t> (txopLimit.GetMicroSe conds () / 32)); |
491 edcaParameters.SetBkAcm (0); | |
492 | 488 |
493 edca = m_edca.find (AC_VI)->second; | 489 edca = m_edca.find (AC_VI)->second; |
494 txopLimit = edca->GetTxopLimit (); | 490 txopLimit = edca->GetTxopLimit (); |
495 edcaParameters.SetViAci (2); | 491 edcaParameters.SetViAci (2); |
496 edcaParameters.SetViCWmin (static_cast<uint8_t>(edca->GetMinCw ())); | 492 edcaParameters.SetViCWmin (edca->GetMinCw ()); |
497 edcaParameters.SetViCWmax (static_cast<uint8_t>(edca->GetMaxCw ())); | 493 edcaParameters.SetViCWmax (edca->GetMaxCw ()); |
498 edcaParameters.SetViAifsn (static_cast<uint8_t>(edca->GetAifsn ())); | 494 edcaParameters.SetViAifsn (static_cast<uint8_t> (edca->GetAifsn ())); |
499 edcaParameters.SetViTXOPLimit (static_cast<uint16_t>(txopLimit.GetMicroSec onds () / 32)); | 495 edcaParameters.SetViTXOPLimit (static_cast<uint16_t> (txopLimit.GetMicroSe conds () / 32)); |
500 edcaParameters.SetViAcm (0); | |
501 | 496 |
502 edca = m_edca.find (AC_VO)->second; | 497 edca = m_edca.find (AC_VO)->second; |
503 txopLimit = edca->GetTxopLimit (); | 498 txopLimit = edca->GetTxopLimit (); |
504 edcaParameters.SetVoAci (3); | 499 edcaParameters.SetVoAci (3); |
505 edcaParameters.SetVoCWmin (static_cast<uint8_t>(edca->GetMinCw ())); | 500 edcaParameters.SetVoCWmin (edca->GetMinCw ()); |
506 edcaParameters.SetVoCWmax (static_cast<uint8_t>(edca->GetMaxCw ())); | 501 edcaParameters.SetVoCWmax (edca->GetMaxCw ()); |
507 edcaParameters.SetVoAifsn (static_cast<uint8_t>(edca->GetAifsn ())); | 502 edcaParameters.SetVoAifsn (static_cast<uint8_t> (edca->GetAifsn ())); |
508 edcaParameters.SetVoTXOPLimit (static_cast<uint16_t>(txopLimit.GetMicroSec onds () / 32)); | 503 edcaParameters.SetVoTXOPLimit (static_cast<uint16_t> (txopLimit.GetMicroSe conds () / 32)); |
509 edcaParameters.SetVoAcm (0); | |
510 | 504 |
511 edcaParameters.SetQosInfo (0); | 505 edcaParameters.SetQosInfo (0); |
512 } | 506 } |
513 return edcaParameters; | 507 return edcaParameters; |
514 } | 508 } |
515 | 509 |
516 HtOperation | 510 HtOperation |
517 ApWifiMac::GetHtOperation (void) const | 511 ApWifiMac::GetHtOperation (void) const |
518 { | 512 { |
519 NS_LOG_FUNCTION (this); | 513 NS_LOG_FUNCTION (this); |
(...skipping 28 matching lines...) Expand all Loading... | |
548 NS_ASSERT (nss > 0 && nss < 5); | 542 NS_ASSERT (nss > 0 && nss < 5); |
549 uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy- >GetShortGuardInterval () ? 400 : 800, nss); | 543 uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy- >GetShortGuardInterval () ? 400 : 800, nss); |
550 if (dataRate > maxSupportedRate) | 544 if (dataRate > maxSupportedRate) |
551 { | 545 { |
552 maxSupportedRate = dataRate; | 546 maxSupportedRate = dataRate; |
553 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate) ; | 547 NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate) ; |
554 } | 548 } |
555 } | 549 } |
556 uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams (); | 550 uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams (); |
557 uint8_t nMcs = m_phy->GetNMcs (); | 551 uint8_t nMcs = m_phy->GetNMcs (); |
558 for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++) | 552 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++) |
559 { | 553 { |
560 if (m_stationManager->GetHtSupported (*i)) | 554 if (m_stationManager->GetHtSupported (i->second)) |
561 { | 555 { |
562 uint64_t maxSupportedRateByHtSta = 0; //in bit/s | 556 uint64_t maxSupportedRateByHtSta = 0; //in bit/s |
563 for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcs Supported (*i))); j++) | 557 for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcs Supported (i->second))); j++) |
564 { | 558 { |
565 WifiMode mcs = m_phy->GetMcs (j); | 559 WifiMode mcs = m_phy->GetMcs (j); |
566 if (mcs.GetModulationClass () != WIFI_MOD_CLASS_HT) | 560 if (mcs.GetModulationClass () != WIFI_MOD_CLASS_HT) |
567 { | 561 { |
568 continue; | 562 continue; |
569 } | 563 } |
570 uint8_t nss = (mcs.GetMcsValue () / 8) + 1; | 564 uint8_t nss = (mcs.GetMcsValue () / 8) + 1; |
571 NS_ASSERT (nss > 0 && nss < 5); | 565 NS_ASSERT (nss > 0 && nss < 5); |
572 uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChan nelWidthSupported (*i), m_stationManager->GetShortGuardInterval (*i) ? 400 : 800 , nss); | 566 uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChan nelWidthSupported (i->second), m_stationManager->GetShortGuardInterval (i->secon d) ? 400 : 800, nss); |
573 if (dataRate > maxSupportedRateByHtSta) | 567 if (dataRate > maxSupportedRateByHtSta) |
574 { | 568 { |
575 maxSupportedRateByHtSta = dataRate; | 569 maxSupportedRateByHtSta = dataRate; |
576 } | 570 } |
577 } | 571 } |
578 if (maxSupportedRateByHtSta < maxSupportedRate) | 572 if (maxSupportedRateByHtSta < maxSupportedRate) |
579 { | 573 { |
580 maxSupportedRate = maxSupportedRateByHtSta; | 574 maxSupportedRate = maxSupportedRateByHtSta; |
581 } | 575 } |
582 if (m_stationManager->GetNMcsSupported (*i) < nMcs) | 576 if (m_stationManager->GetNMcsSupported (i->second) < nMcs) |
583 { | 577 { |
584 nMcs = m_stationManager->GetNMcsSupported (*i); | 578 nMcs = m_stationManager->GetNMcsSupported (i->second); |
585 } | 579 } |
586 if (m_stationManager->GetNumberOfSupportedStreams (*i) < maxSpatia lStream) | 580 if (m_stationManager->GetNumberOfSupportedStreams (i->second) < ma xSpatialStream) |
587 { | 581 { |
588 maxSpatialStream = m_stationManager->GetNumberOfSupportedStrea ms (*i); | 582 maxSpatialStream = m_stationManager->GetNumberOfSupportedStrea ms (i->second); |
589 } | 583 } |
590 } | 584 } |
591 } | 585 } |
592 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t>(maxSupporte dRate / 1e6)); //in Mbit/s | 586 operation.SetRxHighestSupportedDataRate (static_cast<uint16_t> (maxSupport edRate / 1e6)); //in Mbit/s |
593 operation.SetTxMcsSetDefined (nMcs > 0); | 587 operation.SetTxMcsSetDefined (nMcs > 0); |
594 operation.SetTxMaxNSpatialStreams (maxSpatialStream); | 588 operation.SetTxMaxNSpatialStreams (maxSpatialStream); |
595 //To be filled in once supported | 589 //To be filled in once supported |
596 operation.SetObssNonHtStasPresent (0); | 590 operation.SetObssNonHtStasPresent (0); |
597 operation.SetDualBeacon (0); | 591 operation.SetDualBeacon (0); |
598 operation.SetDualCtsProtection (0); | 592 operation.SetDualCtsProtection (0); |
599 operation.SetStbcBeacon (0); | 593 operation.SetStbcBeacon (0); |
600 operation.SetLSigTxopProtectionFullSupport (0); | 594 operation.SetLSigTxopProtectionFullSupport (0); |
601 operation.SetPcoActive (0); | 595 operation.SetPcoActive (0); |
602 operation.SetPhase (0); | 596 operation.SetPhase (0); |
603 operation.SetRxMcsBitmask (0); | 597 operation.SetRxMcsBitmask (0); |
604 operation.SetTxRxMcsSetUnequal (0); | 598 operation.SetTxRxMcsSetUnequal (0); |
605 operation.SetTxUnequalModulation (0); | 599 operation.SetTxUnequalModulation (0); |
606 } | 600 } |
607 return operation; | 601 return operation; |
608 } | 602 } |
609 | 603 |
610 VhtOperation | 604 VhtOperation |
611 ApWifiMac::GetVhtOperation (void) const | 605 ApWifiMac::GetVhtOperation (void) const |
612 { | 606 { |
613 NS_LOG_FUNCTION (this); | 607 NS_LOG_FUNCTION (this); |
614 VhtOperation operation; | 608 VhtOperation operation; |
615 if (m_vhtSupported) | 609 if (m_vhtSupported) |
616 { | 610 { |
617 operation.SetVhtSupported (1); | 611 operation.SetVhtSupported (1); |
618 uint8_t channelWidth = GetVhtOperationalChannelWidth (); | 612 uint16_t channelWidth = GetVhtOperationalChannelWidth (); |
619 if (channelWidth == 160) | 613 if (channelWidth == 160) |
620 { | 614 { |
621 operation.SetChannelWidth (2); | 615 operation.SetChannelWidth (2); |
622 } | 616 } |
623 else if (channelWidth == 80) | 617 else if (channelWidth == 80) |
624 { | 618 { |
625 operation.SetChannelWidth (1); | 619 operation.SetChannelWidth (1); |
626 } | 620 } |
627 else | 621 else |
628 { | 622 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 if (m_erpSupported) | 682 if (m_erpSupported) |
689 { | 683 { |
690 probe.SetErpInformation (GetErpInformation ()); | 684 probe.SetErpInformation (GetErpInformation ()); |
691 } | 685 } |
692 if (m_qosSupported) | 686 if (m_qosSupported) |
693 { | 687 { |
694 probe.SetEdcaParameterSet (GetEdcaParameterSet ()); | 688 probe.SetEdcaParameterSet (GetEdcaParameterSet ()); |
695 } | 689 } |
696 if (m_htSupported || m_vhtSupported || m_heSupported) | 690 if (m_htSupported || m_vhtSupported || m_heSupported) |
697 { | 691 { |
692 probe.SetExtendedCapabilities (GetExtendedCapabilities ()); | |
698 probe.SetHtCapabilities (GetHtCapabilities ()); | 693 probe.SetHtCapabilities (GetHtCapabilities ()); |
699 probe.SetHtOperation (GetHtOperation ()); | 694 probe.SetHtOperation (GetHtOperation ()); |
700 } | 695 } |
701 if (m_vhtSupported || m_heSupported) | 696 if (m_vhtSupported || m_heSupported) |
702 { | 697 { |
703 probe.SetVhtCapabilities (GetVhtCapabilities ()); | 698 probe.SetVhtCapabilities (GetVhtCapabilities ()); |
704 probe.SetVhtOperation (GetVhtOperation ()); | 699 probe.SetVhtOperation (GetVhtOperation ()); |
705 } | 700 } |
706 if (m_heSupported) | 701 if (m_heSupported) |
707 { | 702 { |
708 probe.SetHeCapabilities (GetHeCapabilities ()); | 703 probe.SetHeCapabilities (GetHeCapabilities ()); |
709 probe.SetHeOperation (GetHeOperation ()); | 704 probe.SetHeOperation (GetHeOperation ()); |
710 } | 705 } |
711 packet->AddHeader (probe); | 706 packet->AddHeader (probe); |
712 | 707 |
713 //The standard is not clear on the correct queue for management | 708 //The standard is not clear on the correct queue for management |
714 //frames if we are a QoS AP. The approach taken here is to always | 709 //frames if we are a QoS AP. The approach taken here is to always |
715 //use the DCF for these regardless of whether we have a QoS | 710 //use the DCF for these regardless of whether we have a QoS |
716 //association or not. | 711 //association or not. |
717 m_dca->Queue (packet, hdr); | 712 m_dca->Queue (packet, hdr); |
718 } | 713 } |
719 | 714 |
720 void | 715 void |
721 ApWifiMac::SendAssocResp (Mac48Address to, bool success) | 716 ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc) |
722 { | 717 { |
723 NS_LOG_FUNCTION (this << to << success); | 718 NS_LOG_FUNCTION (this << to << success << isReassoc); |
724 WifiMacHeader hdr; | 719 WifiMacHeader hdr; |
725 hdr.SetType (WIFI_MAC_MGT_ASSOCIATION_RESPONSE); | 720 hdr.SetType (isReassoc ? WIFI_MAC_MGT_REASSOCIATION_RESPONSE : WIFI_MAC_MGT_AS SOCIATION_RESPONSE); |
726 hdr.SetAddr1 (to); | 721 hdr.SetAddr1 (to); |
727 hdr.SetAddr2 (GetAddress ()); | 722 hdr.SetAddr2 (GetAddress ()); |
728 hdr.SetAddr3 (GetAddress ()); | 723 hdr.SetAddr3 (GetAddress ()); |
729 hdr.SetDsNotFrom (); | 724 hdr.SetDsNotFrom (); |
730 hdr.SetDsNotTo (); | 725 hdr.SetDsNotTo (); |
731 hdr.SetNoOrder (); | 726 hdr.SetNoOrder (); |
732 Ptr<Packet> packet = Create<Packet> (); | 727 Ptr<Packet> packet = Create<Packet> (); |
733 MgtAssocResponseHeader assoc; | 728 MgtAssocResponseHeader assoc; |
734 StatusCode code; | 729 StatusCode code; |
735 if (success) | 730 if (success) |
736 { | 731 { |
737 code.SetSuccess (); | 732 code.SetSuccess (); |
738 m_staList.push_back (to); | 733 uint16_t aid = 0; |
734 bool found = false; | |
735 if (isReassoc) | |
736 { | |
737 for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.be gin (); i != m_staList.end (); ++i) | |
738 { | |
739 if (i->second == to) | |
740 { | |
741 aid = i->first; | |
742 found = true; | |
743 break; | |
744 } | |
745 } | |
746 } | |
747 if (!found) | |
748 { | |
749 aid = GetNextAssociationId (); | |
750 m_staList.insert (std::make_pair (aid, to)); | |
751 } | |
752 assoc.SetAssociationId (aid); | |
739 } | 753 } |
740 else | 754 else |
741 { | 755 { |
742 code.SetFailure (); | 756 code.SetFailure (); |
743 } | 757 } |
744 assoc.SetSupportedRates (GetSupportedRates ()); | 758 assoc.SetSupportedRates (GetSupportedRates ()); |
745 assoc.SetStatusCode (code); | 759 assoc.SetStatusCode (code); |
746 assoc.SetCapabilities (GetCapabilities ()); | 760 assoc.SetCapabilities (GetCapabilities ()); |
747 if (m_erpSupported) | 761 if (m_erpSupported) |
748 { | 762 { |
749 assoc.SetErpInformation (GetErpInformation ()); | 763 assoc.SetErpInformation (GetErpInformation ()); |
750 } | 764 } |
751 if (m_qosSupported) | 765 if (m_qosSupported) |
752 { | 766 { |
753 assoc.SetEdcaParameterSet (GetEdcaParameterSet ()); | 767 assoc.SetEdcaParameterSet (GetEdcaParameterSet ()); |
754 } | 768 } |
755 if (m_htSupported || m_vhtSupported || m_heSupported) | 769 if (m_htSupported || m_vhtSupported || m_heSupported) |
756 { | 770 { |
771 assoc.SetExtendedCapabilities (GetExtendedCapabilities ()); | |
757 assoc.SetHtCapabilities (GetHtCapabilities ()); | 772 assoc.SetHtCapabilities (GetHtCapabilities ()); |
758 assoc.SetHtOperation (GetHtOperation ()); | 773 assoc.SetHtOperation (GetHtOperation ()); |
759 } | 774 } |
760 if (m_vhtSupported || m_heSupported) | 775 if (m_vhtSupported || m_heSupported) |
761 { | 776 { |
762 assoc.SetVhtCapabilities (GetVhtCapabilities ()); | 777 assoc.SetVhtCapabilities (GetVhtCapabilities ()); |
763 assoc.SetVhtOperation (GetVhtOperation ()); | 778 assoc.SetVhtOperation (GetVhtOperation ()); |
764 } | 779 } |
765 if (m_heSupported) | 780 if (m_heSupported) |
766 { | 781 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 if (m_erpSupported) | 818 if (m_erpSupported) |
804 { | 819 { |
805 beacon.SetErpInformation (GetErpInformation ()); | 820 beacon.SetErpInformation (GetErpInformation ()); |
806 } | 821 } |
807 if (m_qosSupported) | 822 if (m_qosSupported) |
808 { | 823 { |
809 beacon.SetEdcaParameterSet (GetEdcaParameterSet ()); | 824 beacon.SetEdcaParameterSet (GetEdcaParameterSet ()); |
810 } | 825 } |
811 if (m_htSupported || m_vhtSupported) | 826 if (m_htSupported || m_vhtSupported) |
812 { | 827 { |
828 beacon.SetExtendedCapabilities (GetExtendedCapabilities ()); | |
813 beacon.SetHtCapabilities (GetHtCapabilities ()); | 829 beacon.SetHtCapabilities (GetHtCapabilities ()); |
814 beacon.SetHtOperation (GetHtOperation ()); | 830 beacon.SetHtOperation (GetHtOperation ()); |
815 } | 831 } |
816 if (m_vhtSupported || m_heSupported) | 832 if (m_vhtSupported || m_heSupported) |
817 { | 833 { |
818 beacon.SetVhtCapabilities (GetVhtCapabilities ()); | 834 beacon.SetVhtCapabilities (GetVhtCapabilities ()); |
819 beacon.SetVhtOperation (GetVhtOperation ()); | 835 beacon.SetVhtOperation (GetVhtOperation ()); |
820 } | 836 } |
821 if (m_heSupported) | 837 if (m_heSupported) |
822 { | 838 { |
(...skipping 22 matching lines...) Expand all Loading... | |
845 SetSlot (MicroSeconds (20)); | 861 SetSlot (MicroSeconds (20)); |
846 } | 862 } |
847 } | 863 } |
848 } | 864 } |
849 | 865 |
850 void | 866 void |
851 ApWifiMac::TxOk (const WifiMacHeader &hdr) | 867 ApWifiMac::TxOk (const WifiMacHeader &hdr) |
852 { | 868 { |
853 NS_LOG_FUNCTION (this); | 869 NS_LOG_FUNCTION (this); |
854 RegularWifiMac::TxOk (hdr); | 870 RegularWifiMac::TxOk (hdr); |
855 | 871 if ((hdr.IsAssocResp () || hdr.IsReassocResp ()) |
856 if (hdr.IsAssocResp () | |
857 && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ())) | 872 && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ())) |
858 { | 873 { |
859 NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ()); | 874 NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ()); |
860 m_stationManager->RecordGotAssocTxOk (hdr.GetAddr1 ()); | 875 m_stationManager->RecordGotAssocTxOk (hdr.GetAddr1 ()); |
861 } | 876 } |
862 } | 877 } |
863 | 878 |
864 void | 879 void |
865 ApWifiMac::TxFailed (const WifiMacHeader &hdr) | 880 ApWifiMac::TxFailed (const WifiMacHeader &hdr) |
866 { | 881 { |
867 NS_LOG_FUNCTION (this); | 882 NS_LOG_FUNCTION (this); |
868 RegularWifiMac::TxFailed (hdr); | 883 RegularWifiMac::TxFailed (hdr); |
869 | 884 |
870 if (hdr.IsAssocResp () | 885 if ((hdr.IsAssocResp () || hdr.IsReassocResp ()) |
871 && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ())) | 886 && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ())) |
872 { | 887 { |
873 NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ()); | 888 NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ()); |
874 m_stationManager->RecordGotAssocTxFailed (hdr.GetAddr1 ()); | 889 m_stationManager->RecordGotAssocTxFailed (hdr.GetAddr1 ()); |
875 } | 890 } |
876 } | 891 } |
877 | 892 |
878 void | 893 void |
879 ApWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) | 894 ApWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) |
880 { | 895 { |
881 NS_LOG_FUNCTION (this << packet << hdr); | 896 NS_LOG_FUNCTION (this << packet << hdr); |
882 | |
883 Mac48Address from = hdr->GetAddr2 (); | 897 Mac48Address from = hdr->GetAddr2 (); |
884 | |
885 if (hdr->IsData ()) | 898 if (hdr->IsData ()) |
886 { | 899 { |
887 Mac48Address bssid = hdr->GetAddr1 (); | 900 Mac48Address bssid = hdr->GetAddr1 (); |
888 if (!hdr->IsFromDs () | 901 if (!hdr->IsFromDs () |
889 && hdr->IsToDs () | 902 && hdr->IsToDs () |
890 && bssid == GetAddress () | 903 && bssid == GetAddress () |
891 && m_stationManager->IsAssociated (from)) | 904 && m_stationManager->IsAssociated (from)) |
892 { | 905 { |
893 Mac48Address to = hdr->GetAddr3 (); | 906 Mac48Address to = hdr->GetAddr3 (); |
894 if (to == GetAddress ()) | 907 if (to == GetAddress ()) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 //they are not targeted at the AP | 962 //they are not targeted at the AP |
950 NotifyRxDrop (packet); | 963 NotifyRxDrop (packet); |
951 } | 964 } |
952 return; | 965 return; |
953 } | 966 } |
954 else if (hdr->IsMgt ()) | 967 else if (hdr->IsMgt ()) |
955 { | 968 { |
956 if (hdr->IsProbeReq ()) | 969 if (hdr->IsProbeReq ()) |
957 { | 970 { |
958 NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ()); | 971 NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ()); |
972 NS_LOG_DEBUG ("Probe request received from " << from << ": send probe response"); | |
959 SendProbeResp (from); | 973 SendProbeResp (from); |
960 return; | 974 return; |
961 } | 975 } |
962 else if (hdr->GetAddr1 () == GetAddress ()) | 976 else if (hdr->GetAddr1 () == GetAddress ()) |
963 { | 977 { |
964 if (hdr->IsAssocReq ()) | 978 if (hdr->IsAssocReq ()) |
965 { | 979 { |
980 NS_LOG_DEBUG ("Association request received from " << from); | |
966 //first, verify that the the station's supported | 981 //first, verify that the the station's supported |
967 //rate set is compatible with our Basic Rate set | 982 //rate set is compatible with our Basic Rate set |
968 MgtAssocRequestHeader assocReq; | 983 MgtAssocRequestHeader assocReq; |
969 packet->RemoveHeader (assocReq); | 984 packet->RemoveHeader (assocReq); |
970 CapabilityInformation capabilities = assocReq.GetCapabilities (); | 985 CapabilityInformation capabilities = assocReq.GetCapabilities (); |
971 m_stationManager->AddSupportedPlcpPreamble (from, capabilities.IsS hortPreamble ()); | 986 m_stationManager->AddSupportedPlcpPreamble (from, capabilities.IsS hortPreamble ()); |
972 SupportedRates rates = assocReq.GetSupportedRates (); | 987 SupportedRates rates = assocReq.GetSupportedRates (); |
973 bool problem = false; | 988 bool problem = false; |
974 bool isHtStation = false; | 989 bool isHtStation = false; |
975 bool isOfdmStation = false; | 990 bool isOfdmStation = false; |
976 bool isErpStation = false; | 991 bool isErpStation = false; |
977 bool isDsssStation = false; | 992 bool isDsssStation = false; |
978 for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++) | 993 for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++) |
979 { | 994 { |
980 WifiMode mode = m_stationManager->GetBasicMode (i); | 995 WifiMode mode = m_stationManager->GetBasicMode (i); |
981 if (!rates.IsSupportedRate (static_cast<uint32_t>(mode.GetData Rate (m_phy->GetChannelWidth ())))) | 996 if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChanne lWidth ()))) |
982 { | 997 { |
983 if ((mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS)) | 998 if ((mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS)) |
984 { | 999 { |
985 isDsssStation = false; | 1000 isDsssStation = false; |
986 } | 1001 } |
987 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_ OFDM) | 1002 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_ OFDM) |
988 { | 1003 { |
989 isErpStation = false; | 1004 isErpStation = false; |
990 } | 1005 } |
991 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM ) | 1006 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM ) |
(...skipping 23 matching lines...) Expand all Loading... | |
1015 } | 1030 } |
1016 } | 1031 } |
1017 m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsSh ortSlotTime () && isErpStation); | 1032 m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsSh ortSlotTime () && isErpStation); |
1018 if (m_htSupported) | 1033 if (m_htSupported) |
1019 { | 1034 { |
1020 //check whether the HT STA supports all MCSs in Basic MCS Set | 1035 //check whether the HT STA supports all MCSs in Basic MCS Set |
1021 HtCapabilities htcapabilities = assocReq.GetHtCapabilities (); | 1036 HtCapabilities htcapabilities = assocReq.GetHtCapabilities (); |
1022 if (htcapabilities.IsSupportedMcs (0)) | 1037 if (htcapabilities.IsSupportedMcs (0)) |
1023 { | 1038 { |
1024 isHtStation = true; | 1039 isHtStation = true; |
1025 for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs () ; i++) | 1040 for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) |
1026 { | 1041 { |
1027 WifiMode mcs = m_stationManager->GetBasicMcs (i); | 1042 WifiMode mcs = m_stationManager->GetBasicMcs (i); |
1028 if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue () )) | 1043 if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue () )) |
1029 { | 1044 { |
1030 problem = true; | 1045 problem = true; |
1031 break; | 1046 break; |
1032 } | 1047 } |
1033 } | 1048 } |
1034 } | 1049 } |
1035 } | 1050 } |
1036 if (m_vhtSupported) | 1051 if (m_vhtSupported) |
1037 { | 1052 { |
1038 //check whether the VHT STA supports all MCSs in Basic MCS Set | 1053 //check whether the VHT STA supports all MCSs in Basic MCS Set |
1039 VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities (); | 1054 VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities (); |
1040 if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) | 1055 if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) |
1041 { | 1056 { |
1042 for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs () ; i++) | 1057 for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) |
1043 { | 1058 { |
1044 WifiMode mcs = m_stationManager->GetBasicMcs (i); | 1059 WifiMode mcs = m_stationManager->GetBasicMcs (i); |
1045 if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | 1060 if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) |
1046 { | 1061 { |
1047 problem = true; | 1062 problem = true; |
1048 break; | 1063 break; |
1049 } | 1064 } |
1050 } | 1065 } |
1051 } | 1066 } |
1052 } | 1067 } |
1053 if (m_heSupported) | 1068 if (m_heSupported) |
1054 { | 1069 { |
1055 //check whether the HE STA supports all MCSs in Basic MCS Set | 1070 //check whether the HE STA supports all MCSs in Basic MCS Set |
1056 HeCapabilities hecapabilities = assocReq.GetHeCapabilities (); | 1071 HeCapabilities hecapabilities = assocReq.GetHeCapabilities (); |
1057 if (hecapabilities.GetSupportedMcsAndNss () != 0) | 1072 if (hecapabilities.GetSupportedMcsAndNss () != 0) |
1058 { | 1073 { |
1059 for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs () ; i++) | 1074 for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) |
1060 { | 1075 { |
1061 WifiMode mcs = m_stationManager->GetBasicMcs (i); | 1076 WifiMode mcs = m_stationManager->GetBasicMcs (i); |
1062 if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | 1077 if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) |
1063 { | 1078 { |
1064 problem = true; | 1079 problem = true; |
1065 break; | 1080 break; |
1066 } | 1081 } |
1067 } | 1082 } |
1068 } | 1083 } |
1069 } | 1084 } |
1070 if (problem) | 1085 if (problem) |
1071 { | 1086 { |
1072 //One of the Basic Rate set mode is not | 1087 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send association response with an error status"); |
1073 //supported by the station. So, we return an assoc | 1088 SendAssocResp (hdr->GetAddr2 (), false, false); |
1074 //response with an error status. | |
1075 SendAssocResp (hdr->GetAddr2 (), false); | |
1076 } | 1089 } |
1077 else | 1090 else |
1078 { | 1091 { |
1079 //station supports all rates in Basic Rate Set. | 1092 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the s tation"); |
1080 //record all its supported modes in its associated WifiRemoteS tation | 1093 //record all its supported modes in its associated WifiRemoteS tation |
1081 for (uint32_t j = 0; j < m_phy->GetNModes (); j++) | 1094 for (uint8_t j = 0; j < m_phy->GetNModes (); j++) |
1082 { | 1095 { |
1083 WifiMode mode = m_phy->GetMode (j); | 1096 WifiMode mode = m_phy->GetMode (j); |
1084 if (rates.IsSupportedRate (static_cast<uint32_t>(mode.GetD ataRate (m_phy->GetChannelWidth ())))) | 1097 if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetCha nnelWidth ()))) |
1085 { | 1098 { |
1086 m_stationManager->AddSupportedMode (from, mode); | 1099 m_stationManager->AddSupportedMode (from, mode); |
1087 } | 1100 } |
1088 } | 1101 } |
1089 if (m_htSupported) | 1102 if (m_htSupported) |
1090 { | 1103 { |
1091 HtCapabilities htCapabilities = assocReq.GetHtCapabilities (); | 1104 HtCapabilities htCapabilities = assocReq.GetHtCapabilities (); |
1092 if (htCapabilities.IsSupportedMcs (0)) | 1105 if (htCapabilities.IsSupportedMcs (0)) |
1093 { | 1106 { |
1094 m_stationManager->AddStationHtCapabilities (from, htCa pabilities); | 1107 m_stationManager->AddStationHtCapabilities (from, htCa pabilities); |
1095 } | 1108 } |
1096 } | 1109 } |
1097 if (m_vhtSupported) | 1110 if (m_vhtSupported) |
1098 { | 1111 { |
1099 VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilit ies (); | 1112 VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilit ies (); |
1100 //we will always fill in RxHighestSupportedLgiDataRate fie ld at TX, so this can be used to check whether it supports VHT | 1113 //we will always fill in RxHighestSupportedLgiDataRate fie ld at TX, so this can be used to check whether it supports VHT |
1101 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) | 1114 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) |
1102 { | 1115 { |
1103 m_stationManager->AddStationVhtCapabilities (from, vht Capabilities); | 1116 m_stationManager->AddStationVhtCapabilities (from, vht Capabilities); |
1104 for (uint32_t i = 0; i < m_phy->GetNMcs (); i++) | 1117 for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) |
1105 { | 1118 { |
1106 WifiMode mcs = m_phy->GetMcs (static_cast<uint8_t> (i)); | 1119 WifiMode mcs = m_phy->GetMcs (i); |
1107 if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VH T && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | 1120 if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VH T && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) |
1108 { | 1121 { |
1109 m_stationManager->AddSupportedMcs (hdr->GetAdd r2 (), mcs); | 1122 m_stationManager->AddSupportedMcs (hdr->GetAdd r2 (), mcs); |
1110 //here should add a control to add basic MCS w hen it is implemented | 1123 //here should add a control to add basic MCS w hen it is implemented |
1111 } | 1124 } |
1112 } | 1125 } |
1113 } | 1126 } |
1114 } | 1127 } |
1128 if (m_htSupported || m_vhtSupported) | |
1129 { | |
1130 ExtendedCapabilities extendedCapabilities = assocReq.GetEx tendedCapabilities (); | |
1131 //TODO: to be completed | |
1132 } | |
1115 if (m_heSupported) | 1133 if (m_heSupported) |
1116 { | 1134 { |
1117 HeCapabilities heCapabilities = assocReq.GetHeCapabilities (); | 1135 HeCapabilities heCapabilities = assocReq.GetHeCapabilities (); |
1118 //todo: once we support non constant rate managers, we sho uld add checks here whether HE is supported by the peer | 1136 //todo: once we support non constant rate managers, we sho uld add checks here whether HE is supported by the peer |
1119 m_stationManager->AddStationHeCapabilities (from, heCapabi lities); | 1137 m_stationManager->AddStationHeCapabilities (from, heCapabi lities); |
1120 for (uint32_t i = 0; i < m_phy->GetNMcs (); i++) | 1138 for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) |
1121 { | 1139 { |
1122 WifiMode mcs = m_phy->GetMcs (static_cast<uint8_t>(i)) ; | 1140 WifiMode mcs = m_phy->GetMcs (i); |
1123 if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | 1141 if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) |
1124 { | 1142 { |
1125 m_stationManager->AddSupportedMcs (hdr->GetAddr2 ( ), mcs); | 1143 m_stationManager->AddSupportedMcs (hdr->GetAddr2 ( ), mcs); |
1126 //here should add a control to add basic MCS when it is implemented | 1144 //here should add a control to add basic MCS when it is implemented |
1127 } | 1145 } |
1128 } | 1146 } |
1129 } | 1147 } |
1130 m_stationManager->RecordWaitAssocTxOk (from); | 1148 m_stationManager->RecordWaitAssocTxOk (from); |
1131 if (!isHtStation) | 1149 if (!isHtStation) |
1132 { | 1150 { |
1133 m_nonHtStations.push_back (hdr->GetAddr2 ()); | 1151 m_nonHtStations.push_back (hdr->GetAddr2 ()); |
1152 m_nonHtStations.unique (); | |
1134 } | 1153 } |
1135 if (!isErpStation && isDsssStation) | 1154 if (!isErpStation && isDsssStation) |
1136 { | 1155 { |
1137 m_nonErpStations.push_back (hdr->GetAddr2 ()); | 1156 m_nonErpStations.push_back (hdr->GetAddr2 ()); |
1138 } | 1157 m_nonErpStations.unique (); |
1139 // send assoc response with success status. | 1158 } |
1140 SendAssocResp (hdr->GetAddr2 (), true); | 1159 NS_LOG_DEBUG ("Send association response with success status") ; |
1160 SendAssocResp (hdr->GetAddr2 (), true, false); | |
1161 } | |
1162 return; | |
1163 } | |
1164 else if (hdr->IsReassocReq ()) | |
1165 { | |
1166 NS_LOG_DEBUG ("Reassociation request received from " << from); | |
1167 //first, verify that the the station's supported | |
1168 //rate set is compatible with our Basic Rate set | |
1169 MgtReassocRequestHeader reassocReq; | |
1170 packet->RemoveHeader (reassocReq); | |
1171 CapabilityInformation capabilities = reassocReq.GetCapabilities () ; | |
1172 m_stationManager->AddSupportedPlcpPreamble (from, capabilities.IsS hortPreamble ()); | |
1173 SupportedRates rates = reassocReq.GetSupportedRates (); | |
1174 bool problem = false; | |
1175 bool isHtStation = false; | |
1176 bool isOfdmStation = false; | |
1177 bool isErpStation = false; | |
1178 bool isDsssStation = false; | |
1179 for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++) | |
1180 { | |
1181 WifiMode mode = m_stationManager->GetBasicMode (i); | |
1182 if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChanne lWidth ()))) | |
1183 { | |
1184 if ((mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS)) | |
1185 { | |
1186 isDsssStation = false; | |
1187 } | |
1188 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_ OFDM) | |
1189 { | |
1190 isErpStation = false; | |
1191 } | |
1192 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM ) | |
1193 { | |
1194 isOfdmStation = false; | |
1195 } | |
1196 if (isDsssStation == false && isErpStation == false && isO fdmStation == false) | |
1197 { | |
1198 problem = true; | |
1199 break; | |
1200 } | |
1201 } | |
1202 else | |
1203 { | |
1204 if ((mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS)) | |
1205 { | |
1206 isDsssStation = true; | |
1207 } | |
1208 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_ OFDM) | |
1209 { | |
1210 isErpStation = true; | |
1211 } | |
1212 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM ) | |
1213 { | |
1214 isOfdmStation = true; | |
1215 } | |
1216 } | |
1217 } | |
1218 m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsSh ortSlotTime () && isErpStation); | |
1219 if (m_htSupported) | |
1220 { | |
1221 //check whether the HT STA supports all MCSs in Basic MCS Set | |
1222 HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ( ); | |
1223 if (htcapabilities.IsSupportedMcs (0)) | |
1224 { | |
1225 isHtStation = true; | |
1226 for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) | |
1227 { | |
1228 WifiMode mcs = m_stationManager->GetBasicMcs (i); | |
1229 if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue () )) | |
1230 { | |
1231 problem = true; | |
1232 break; | |
1233 } | |
1234 } | |
1235 } | |
1236 } | |
1237 if (m_vhtSupported) | |
1238 { | |
1239 //check whether the VHT STA supports all MCSs in Basic MCS Set | |
1240 VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilitie s (); | |
1241 if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) | |
1242 { | |
1243 for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) | |
1244 { | |
1245 WifiMode mcs = m_stationManager->GetBasicMcs (i); | |
1246 if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | |
1247 { | |
1248 problem = true; | |
1249 break; | |
1250 } | |
1251 } | |
1252 } | |
1253 } | |
1254 if (m_heSupported) | |
1255 { | |
1256 //check whether the HE STA supports all MCSs in Basic MCS Set | |
1257 HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ( ); | |
1258 if (hecapabilities.GetSupportedMcsAndNss () != 0) | |
1259 { | |
1260 for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) | |
1261 { | |
1262 WifiMode mcs = m_stationManager->GetBasicMcs (i); | |
1263 if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | |
1264 { | |
1265 problem = true; | |
1266 break; | |
1267 } | |
1268 } | |
1269 } | |
1270 } | |
1271 if (problem) | |
1272 { | |
1273 NS_LOG_DEBUG ("One of the Basic Rate set mode is not supported by the station: send reassociation response with an error status"); | |
1274 SendAssocResp (hdr->GetAddr2 (), false, true); | |
1275 } | |
1276 else | |
1277 { | |
1278 NS_LOG_DEBUG ("The Basic Rate set modes are supported by the s tation"); | |
1279 //update all its supported modes in its associated WifiRemoteS tation | |
1280 for (uint8_t j = 0; j < m_phy->GetNModes (); j++) | |
1281 { | |
1282 WifiMode mode = m_phy->GetMode (j); | |
1283 if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetCha nnelWidth ()))) | |
1284 { | |
1285 m_stationManager->AddSupportedMode (from, mode); | |
1286 } | |
1287 } | |
1288 if (m_htSupported) | |
1289 { | |
1290 HtCapabilities htCapabilities = reassocReq.GetHtCapabiliti es (); | |
1291 if (htCapabilities.IsSupportedMcs (0)) | |
1292 { | |
1293 m_stationManager->AddStationHtCapabilities (from, htCa pabilities); | |
1294 } | |
1295 } | |
1296 if (m_vhtSupported) | |
1297 { | |
1298 VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabil ities (); | |
1299 //we will always fill in RxHighestSupportedLgiDataRate fie ld at TX, so this can be used to check whether it supports VHT | |
1300 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) | |
1301 { | |
1302 m_stationManager->AddStationVhtCapabilities (from, vht Capabilities); | |
1303 for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) | |
1304 { | |
1305 WifiMode mcs = m_phy->GetMcs (i); | |
1306 if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VH T && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | |
1307 { | |
1308 m_stationManager->AddSupportedMcs (hdr->GetAdd r2 (), mcs); | |
1309 //here should add a control to add basic MCS w hen it is implemented | |
1310 } | |
1311 } | |
1312 } | |
1313 } | |
1314 if (m_htSupported || m_vhtSupported) | |
1315 { | |
1316 ExtendedCapabilities extendedCapabilities = reassocReq.Get ExtendedCapabilities (); | |
1317 //TODO: to be completed | |
1318 } | |
1319 if (m_heSupported) | |
1320 { | |
1321 HeCapabilities heCapabilities = reassocReq.GetHeCapabiliti es (); | |
1322 //todo: once we support non constant rate managers, we sho uld add checks here whether HE is supported by the peer | |
1323 m_stationManager->AddStationHeCapabilities (from, heCapabi lities); | |
1324 for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) | |
1325 { | |
1326 WifiMode mcs = m_phy->GetMcs (i); | |
1327 if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) | |
1328 { | |
1329 m_stationManager->AddSupportedMcs (hdr->GetAddr2 ( ), mcs); | |
1330 //here should add a control to add basic MCS when it is implemented | |
1331 } | |
1332 } | |
1333 } | |
1334 m_stationManager->RecordWaitAssocTxOk (from); | |
1335 if (!isHtStation) | |
1336 { | |
1337 m_nonHtStations.push_back (hdr->GetAddr2 ()); | |
1338 m_nonHtStations.unique (); | |
1339 } | |
1340 if (!isErpStation && isDsssStation) | |
1341 { | |
1342 m_nonErpStations.push_back (hdr->GetAddr2 ()); | |
1343 m_nonErpStations.unique (); | |
1344 } | |
1345 NS_LOG_DEBUG ("Send reassociation response with success status "); | |
1346 SendAssocResp (hdr->GetAddr2 (), true, true); | |
1141 } | 1347 } |
1142 return; | 1348 return; |
1143 } | 1349 } |
1144 else if (hdr->IsDisassociation ()) | 1350 else if (hdr->IsDisassociation ()) |
1145 { | 1351 { |
1352 NS_LOG_DEBUG ("Disassociation received from " << from); | |
1146 m_stationManager->RecordDisassociated (from); | 1353 m_stationManager->RecordDisassociated (from); |
1147 for (std::list<Mac48Address>::const_iterator i = m_staList.begin ( ); i != m_staList.end (); i++) | 1354 for (std::map<uint16_t, Mac48Address>::const_iterator j = m_staLis t.begin (); j != m_staList.end (); j++) |
1148 { | 1355 { |
1149 if ((*i) == from) | 1356 if (j->second == from) |
1150 { | 1357 { |
1151 m_staList.erase (i); | 1358 m_staList.erase (j); |
1152 break; | 1359 break; |
1153 } | 1360 } |
1154 } | 1361 } |
1155 for (std::list<Mac48Address>::const_iterator j = m_nonErpStations. begin (); j != m_nonErpStations.end (); j++) | 1362 for (std::list<Mac48Address>::const_iterator j = m_nonErpStations. begin (); j != m_nonErpStations.end (); j++) |
1156 { | 1363 { |
1157 if ((*j) == from) | 1364 if ((*j) == from) |
1158 { | 1365 { |
1159 m_nonErpStations.erase (j); | 1366 m_nonErpStations.erase (j); |
1160 break; | 1367 break; |
1161 } | 1368 } |
(...skipping 11 matching lines...) Expand all Loading... | |
1173 } | 1380 } |
1174 } | 1381 } |
1175 | 1382 |
1176 //Invoke the receive handler of our parent class to deal with any | 1383 //Invoke the receive handler of our parent class to deal with any |
1177 //other frames. Specifically, this will handle Block Ack-related | 1384 //other frames. Specifically, this will handle Block Ack-related |
1178 //Management Action frames. | 1385 //Management Action frames. |
1179 RegularWifiMac::Receive (packet, hdr); | 1386 RegularWifiMac::Receive (packet, hdr); |
1180 } | 1387 } |
1181 | 1388 |
1182 void | 1389 void |
1183 ApWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, | 1390 ApWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, const WifiM acHeader *hdr) |
1184 const WifiMacHeader *hdr) | |
1185 { | 1391 { |
1186 NS_LOG_FUNCTION (this << aggregatedPacket << hdr); | 1392 NS_LOG_FUNCTION (this << aggregatedPacket << hdr); |
1187 MsduAggregator::DeaggregatedMsdus packets = | 1393 MsduAggregator::DeaggregatedMsdus packets = MsduAggregator::Deaggregate (aggre gatedPacket); |
1188 MsduAggregator::Deaggregate (aggregatedPacket); | |
1189 | |
1190 for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin (); | 1394 for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin (); |
1191 i != packets.end (); ++i) | 1395 i != packets.end (); ++i) |
1192 { | 1396 { |
1193 if ((*i).second.GetDestinationAddr () == GetAddress ()) | 1397 if ((*i).second.GetDestinationAddr () == GetAddress ()) |
1194 { | 1398 { |
1195 ForwardUp ((*i).first, (*i).second.GetSourceAddr (), | 1399 ForwardUp ((*i).first, (*i).second.GetSourceAddr (), |
1196 (*i).second.GetDestinationAddr ()); | 1400 (*i).second.GetDestinationAddr ()); |
1197 } | 1401 } |
1198 else | 1402 else |
1199 { | 1403 { |
1200 Mac48Address from = (*i).second.GetSourceAddr (); | 1404 Mac48Address from = (*i).second.GetSourceAddr (); |
1201 Mac48Address to = (*i).second.GetDestinationAddr (); | 1405 Mac48Address to = (*i).second.GetDestinationAddr (); |
1202 NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to); | 1406 NS_LOG_DEBUG ("forwarding QoS frame from=" << from << ", to=" << to); |
1203 ForwardDown ((*i).first, from, to, hdr->GetQosTid ()); | 1407 ForwardDown ((*i).first, from, to, hdr->GetQosTid ()); |
1204 } | 1408 } |
1205 } | 1409 } |
1206 } | 1410 } |
1207 | 1411 |
1208 void | 1412 void |
1209 ApWifiMac::DoInitialize (void) | 1413 ApWifiMac::DoInitialize (void) |
1210 { | 1414 { |
1211 NS_LOG_FUNCTION (this); | 1415 NS_LOG_FUNCTION (this); |
1212 m_beaconDca->Initialize (); | 1416 m_beaconDca->Initialize (); |
1213 m_beaconEvent.Cancel (); | 1417 m_beaconEvent.Cancel (); |
1214 if (m_enableBeaconGeneration) | 1418 if (m_enableBeaconGeneration) |
1215 { | 1419 { |
1216 if (m_enableBeaconJitter) | 1420 if (m_enableBeaconJitter) |
1217 { | 1421 { |
1218 int64_t jitter = static_cast<int64_t>(m_beaconJitter->GetValue (0, sta tic_cast<double>(m_beaconInterval.GetMicroSeconds ()))); | 1422 int64_t jitter = static_cast<int64_t> (m_beaconJitter->GetValue (0, st atic_cast<double> (m_beaconInterval.GetMicroSeconds ()))); |
1219 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddr ess () << " at time " << jitter << " microseconds"); | 1423 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddr ess () << " at time " << jitter << " microseconds"); |
1220 m_beaconEvent = Simulator::Schedule (MicroSeconds (jitter), &ApWifiMac ::SendOneBeacon, this); | 1424 m_beaconEvent = Simulator::Schedule (MicroSeconds (jitter), &ApWifiMac ::SendOneBeacon, this); |
1221 } | 1425 } |
1222 else | 1426 else |
1223 { | 1427 { |
1224 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddr ess () << " at time 0"); | 1428 NS_LOG_DEBUG ("Scheduling initial beacon for access point " << GetAddr ess () << " at time 0"); |
1225 m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, thi s); | 1429 m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, thi s); |
1226 } | 1430 } |
1227 } | 1431 } |
1228 RegularWifiMac::DoInitialize (); | 1432 RegularWifiMac::DoInitialize (); |
(...skipping 22 matching lines...) Expand all Loading... | |
1251 { | 1455 { |
1252 m_stationManager->SetRifsPermitted (true); | 1456 m_stationManager->SetRifsPermitted (true); |
1253 } | 1457 } |
1254 else | 1458 else |
1255 { | 1459 { |
1256 m_stationManager->SetRifsPermitted (false); | 1460 m_stationManager->SetRifsPermitted (false); |
1257 } | 1461 } |
1258 return rifsMode; | 1462 return rifsMode; |
1259 } | 1463 } |
1260 | 1464 |
1465 uint16_t | |
1466 ApWifiMac::GetNextAssociationId (void) | |
1467 { | |
1468 //Return the first free AID value between 1 and 2007 | |
1469 for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++) | |
1470 { | |
1471 if (m_staList.find (nextAid) == m_staList.end ()) | |
1472 { | |
1473 return nextAid; | |
1474 } | |
1475 } | |
1476 NS_ASSERT_MSG (false, "No free association ID available!"); | |
1477 return 0; | |
1478 } | |
1479 | |
1261 } //namespace ns3 | 1480 } //namespace ns3 |
LEFT | RIGHT |