equal
deleted
inserted
replaced
35 #include "mac-tx-middle.h" |
35 #include "mac-tx-middle.h" |
36 #include "wifi-mac-header.h" |
36 #include "wifi-mac-header.h" |
37 #include "msdu-aggregator.h" |
37 #include "msdu-aggregator.h" |
38 #include "amsdu-subframe-header.h" |
38 #include "amsdu-subframe-header.h" |
39 #include "mgt-headers.h" |
39 #include "mgt-headers.h" |
|
40 #include "ht-capabilities.h" |
40 |
41 |
41 NS_LOG_COMPONENT_DEFINE ("StaWifiMac"); |
42 NS_LOG_COMPONENT_DEFINE ("StaWifiMac"); |
42 |
43 |
43 |
44 |
44 /* |
45 /* |
166 hdr.SetDsNotTo (); |
167 hdr.SetDsNotTo (); |
167 Ptr<Packet> packet = Create<Packet> (); |
168 Ptr<Packet> packet = Create<Packet> (); |
168 MgtProbeRequestHeader probe; |
169 MgtProbeRequestHeader probe; |
169 probe.SetSsid (GetSsid ()); |
170 probe.SetSsid (GetSsid ()); |
170 probe.SetSupportedRates (GetSupportedRates ()); |
171 probe.SetSupportedRates (GetSupportedRates ()); |
|
172 if (m_htSupported) |
|
173 { |
|
174 probe.SetHtCapabilities (GetHtCapabilities()); |
|
175 hdr.SetNoOrder(); |
|
176 } |
|
177 |
171 packet->AddHeader (probe); |
178 packet->AddHeader (probe); |
172 |
179 |
173 // The standard is not clear on the correct queue for management |
180 // The standard is not clear on the correct queue for management |
174 // frames if we are a QoS AP. The approach taken here is to always |
181 // frames if we are a QoS AP. The approach taken here is to always |
175 // use the DCF for these regardless of whether we have a QoS |
182 // use the DCF for these regardless of whether we have a QoS |
193 hdr.SetDsNotTo (); |
200 hdr.SetDsNotTo (); |
194 Ptr<Packet> packet = Create<Packet> (); |
201 Ptr<Packet> packet = Create<Packet> (); |
195 MgtAssocRequestHeader assoc; |
202 MgtAssocRequestHeader assoc; |
196 assoc.SetSsid (GetSsid ()); |
203 assoc.SetSsid (GetSsid ()); |
197 assoc.SetSupportedRates (GetSupportedRates ()); |
204 assoc.SetSupportedRates (GetSupportedRates ()); |
|
205 if (m_htSupported) |
|
206 { |
|
207 assoc.SetHtCapabilities (GetHtCapabilities()); |
|
208 hdr.SetNoOrder(); |
|
209 } |
|
210 |
198 packet->AddHeader (assoc); |
211 packet->AddHeader (assoc); |
199 |
212 |
200 // The standard is not clear on the correct queue for management |
213 // The standard is not clear on the correct queue for management |
201 // frames if we are a QoS AP. The approach taken here is to always |
214 // frames if we are a QoS AP. The approach taken here is to always |
202 // use the DCF for these regardless of whether we have a QoS |
215 // use the DCF for these regardless of whether we have a QoS |
349 } |
362 } |
350 else |
363 else |
351 { |
364 { |
352 hdr.SetTypeData (); |
365 hdr.SetTypeData (); |
353 } |
366 } |
|
367 if (m_htSupported) |
|
368 { |
|
369 hdr.SetNoOrder(); |
|
370 } |
354 |
371 |
355 hdr.SetAddr1 (GetBssid ()); |
372 hdr.SetAddr1 (GetBssid ()); |
356 hdr.SetAddr2 (m_low->GetAddress ()); |
373 hdr.SetAddr2 (m_low->GetAddress ()); |
357 hdr.SetAddr3 (to); |
374 hdr.SetAddr3 (to); |
358 hdr.SetDsNotFrom (); |
375 hdr.SetDsNotFrom (); |
442 if (GetSsid ().IsBroadcast () |
459 if (GetSsid ().IsBroadcast () |
443 || beacon.GetSsid ().IsEqual (GetSsid ())) |
460 || beacon.GetSsid ().IsEqual (GetSsid ())) |
444 { |
461 { |
445 goodBeacon = true; |
462 goodBeacon = true; |
446 } |
463 } |
|
464 SupportedRates rates = beacon.GetSupportedRates (); |
|
465 for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++) |
|
466 { |
|
467 uint32_t selector = m_phy->GetBssMembershipSelector (i); |
|
468 if (!rates.IsSupportedRate (selector)) |
|
469 { |
|
470 goodBeacon = false; |
|
471 } |
|
472 } |
447 if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ()) |
473 if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ()) |
448 { |
474 { |
449 goodBeacon = false; |
475 goodBeacon = false; |
450 } |
476 } |
451 if (goodBeacon) |
477 if (goodBeacon) |
469 packet->RemoveHeader (probeResp); |
495 packet->RemoveHeader (probeResp); |
470 if (!probeResp.GetSsid ().IsEqual (GetSsid ())) |
496 if (!probeResp.GetSsid ().IsEqual (GetSsid ())) |
471 { |
497 { |
472 //not a probe resp for our ssid. |
498 //not a probe resp for our ssid. |
473 return; |
499 return; |
|
500 } |
|
501 SupportedRates rates = probeResp.GetSupportedRates (); |
|
502 for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors (); i++) |
|
503 { |
|
504 uint32_t selector = m_phy->GetBssMembershipSelector (i); |
|
505 if (!rates.IsSupportedRate (selector)) |
|
506 { |
|
507 return; |
|
508 } |
474 } |
509 } |
475 SetBssid (hdr->GetAddr3 ()); |
510 SetBssid (hdr->GetAddr3 ()); |
476 Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons); |
511 Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons); |
477 RestartBeaconWatchdog (delay); |
512 RestartBeaconWatchdog (delay); |
478 if (m_probeRequestEvent.IsRunning ()) |
513 if (m_probeRequestEvent.IsRunning ()) |
497 if (assocResp.GetStatusCode ().IsSuccess ()) |
532 if (assocResp.GetStatusCode ().IsSuccess ()) |
498 { |
533 { |
499 SetState (ASSOCIATED); |
534 SetState (ASSOCIATED); |
500 NS_LOG_DEBUG ("assoc completed"); |
535 NS_LOG_DEBUG ("assoc completed"); |
501 SupportedRates rates = assocResp.GetSupportedRates (); |
536 SupportedRates rates = assocResp.GetSupportedRates (); |
|
537 if (m_htSupported) |
|
538 { |
|
539 HtCapabilities htcapabilities = assocResp.GetHtCapabilities (); |
|
540 m_stationManager->AddStationHtCapabilities (hdr->GetAddr2 (),htcapabilities); |
|
541 } |
|
542 |
502 for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
543 for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
503 { |
544 { |
504 WifiMode mode = m_phy->GetMode (i); |
545 WifiMode mode = m_phy->GetMode (i); |
505 if (rates.IsSupportedRate (mode.GetDataRate ())) |
546 if (rates.IsSupportedRate (mode.GetDataRate ())) |
506 { |
547 { |
509 { |
550 { |
510 m_stationManager->AddBasicMode (mode); |
551 m_stationManager->AddBasicMode (mode); |
511 } |
552 } |
512 } |
553 } |
513 } |
554 } |
|
555 if(m_htSupported) |
|
556 { |
|
557 HtCapabilities htcapabilities = assocResp.GetHtCapabilities (); |
|
558 for (uint32_t i = 0; i < m_phy->GetNMcs(); i++) |
|
559 { |
|
560 uint8_t mcs=m_phy->GetMcs(i); |
|
561 if (htcapabilities.IsSupportedMcs (mcs)) |
|
562 { |
|
563 m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); |
|
564 //here should add a control to add basic MCS when it is implemented |
|
565 } |
|
566 } |
|
567 } |
514 if (!m_linkUp.IsNull ()) |
568 if (!m_linkUp.IsNull ()) |
515 { |
569 { |
516 m_linkUp (); |
570 m_linkUp (); |
517 } |
571 } |
518 } |
572 } |
533 |
587 |
534 SupportedRates |
588 SupportedRates |
535 StaWifiMac::GetSupportedRates (void) const |
589 StaWifiMac::GetSupportedRates (void) const |
536 { |
590 { |
537 SupportedRates rates; |
591 SupportedRates rates; |
|
592 if(m_htSupported) |
|
593 { |
|
594 for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++) |
|
595 { |
|
596 rates.SetBasicRate(m_phy->GetBssMembershipSelector(i)); |
|
597 } |
|
598 } |
538 for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
599 for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
539 { |
600 { |
540 WifiMode mode = m_phy->GetMode (i); |
601 WifiMode mode = m_phy->GetMode (i); |
541 rates.AddSupportedRate (mode.GetDataRate ()); |
602 rates.AddSupportedRate (mode.GetDataRate ()); |
542 } |
603 } |
543 return rates; |
604 return rates; |
544 } |
605 } |
545 |
606 HtCapabilities |
|
607 StaWifiMac::GetHtCapabilities (void) const |
|
608 { |
|
609 HtCapabilities capabilities; |
|
610 capabilities.SetHtSupported(1); |
|
611 capabilities.SetLdpc (m_phy->GetLdpc()); |
|
612 capabilities.SetShortGuardInterval20 (m_phy->GetGuardInterval()); |
|
613 capabilities.SetGreenfield (m_phy->GetGreenfield()); |
|
614 for (uint8_t i =0 ; i < m_phy->GetNMcs();i++) |
|
615 { |
|
616 capabilities.SetRxMcsBitmask(m_phy->GetMcs(i)); |
|
617 } |
|
618 return capabilities; |
|
619 } |
546 void |
620 void |
547 StaWifiMac::SetState (MacState value) |
621 StaWifiMac::SetState (MacState value) |
548 { |
622 { |
549 if (value == ASSOCIATED |
623 if (value == ASSOCIATED |
550 && m_state != ASSOCIATED) |
624 && m_state != ASSOCIATED) |