A Discrete-Event Network Simulator
API
sta-wifi-mac.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2006, 2009 INRIA
4 * Copyright (c) 2009 MIRKO BANCHICONFLICT (content): Merge conflict in src/wifi/model/sta-wifi-mac.cc
5
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation;
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21 * Mirko Banchi <mk.banchi@gmail.com>
22 */
23
24#include "ns3/log.h"
25#include "ns3/packet.h"
26#include "ns3/simulator.h"
27#include "qos-txop.h"
28#include "sta-wifi-mac.h"
29#include "wifi-phy.h"
30#include "mgt-headers.h"
31#include "snr-tag.h"
32#include "wifi-net-device.h"
33#include "ns3/ht-configuration.h"
34#include "ns3/he-configuration.h"
35
36namespace ns3 {
37
38NS_LOG_COMPONENT_DEFINE ("StaWifiMac");
39
41
42TypeId
44{
45 static TypeId tid = TypeId ("ns3::StaWifiMac")
47 .SetGroupName ("Wifi")
48 .AddConstructor<StaWifiMac> ()
49 .AddAttribute ("ProbeRequestTimeout", "The duration to actively probe the channel.",
50 TimeValue (Seconds (0.05)),
53 .AddAttribute ("WaitBeaconTimeout", "The duration to dwell on a channel while passively scanning for beacon",
54 TimeValue (MilliSeconds (120)),
57 .AddAttribute ("AssocRequestTimeout", "The interval between two consecutive association request attempts.",
58 TimeValue (Seconds (0.5)),
61 .AddAttribute ("MaxMissedBeacons",
62 "Number of beacons which much be consecutively missed before "
63 "we attempt to restart association.",
64 UintegerValue (10),
66 MakeUintegerChecker<uint32_t> ())
67 .AddAttribute ("ActiveProbing",
68 "If true, we send probe requests. If false, we don't."
69 "NOTE: if more than one STA in your simulation is using active probing, "
70 "you should enable it at a different simulation time for each STA, "
71 "otherwise all the STAs will start sending probes at the same time resulting in collisions. "
72 "See bug 1060 for more info.",
73 BooleanValue (false),
76 .AddTraceSource ("Assoc", "Associated with an access point.",
78 "ns3::Mac48Address::TracedCallback")
79 .AddTraceSource ("DeAssoc", "Association with an access point lost.",
81 "ns3::Mac48Address::TracedCallback")
82 .AddTraceSource ("BeaconArrival",
83 "Time of beacons arrival from associated AP",
85 "ns3::Time::TracedCallback")
86 ;
87 return tid;
88}
89
91 : m_state (UNASSOCIATED),
92 m_aid (0),
93 m_waitBeaconEvent (),
94 m_probeRequestEvent (),
95 m_assocRequestEvent (),
96 m_beaconWatchdogEnd (Seconds (0))
97{
98 NS_LOG_FUNCTION (this);
99
100 //Let the lower layers know that we are acting as a non-AP STA in
101 //an infrastructure BSS.
103}
104
105void
107{
108 NS_LOG_FUNCTION (this);
109 StartScanning ();
110}
111
113{
114 NS_LOG_FUNCTION (this);
115}
116
117uint16_t
119{
120 NS_ASSERT_MSG (IsAssociated (), "This station is not associated to any AP");
121 return m_aid;
122}
123
124void
126{
127 NS_LOG_FUNCTION (this << enable);
128 m_activeProbing = enable;
130 {
131 NS_LOG_DEBUG ("STA is still scanning, reset scanning process");
132 StartScanning ();
133 }
134}
135
136bool
138{
139 return m_activeProbing;
140}
141
142void
144{
145 NS_LOG_FUNCTION (this << phy);
148}
149
150void
152{
153 NS_LOG_FUNCTION (this);
154 WifiMacHeader hdr;
157 hdr.SetAddr2 (GetAddress ());
159 hdr.SetDsNotFrom ();
160 hdr.SetDsNotTo ();
161 Ptr<Packet> packet = Create<Packet> ();
163 probe.SetSsid (GetSsid ());
165 if (GetHtSupported ())
166 {
169 }
170 if (GetVhtSupported ())
171 {
173 }
174 if (GetHeSupported ())
175 {
177 }
178 if (GetEhtSupported ())
179 {
181 }
182 packet->AddHeader (probe);
183
184 if (!GetQosSupported ())
185 {
186 GetTxop ()->Queue (packet, hdr);
187 }
188 // "A QoS STA that transmits a Management frame determines access category used
189 // for medium access in transmission of the Management frame as follows
190 // (If dot11QMFActivated is false or not present)
191 // — If the Management frame is individually addressed to a non-QoS STA, category
192 // AC_BE should be selected.
193 // — If category AC_BE was not selected by the previous step, category AC_VO
194 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
195 else
196 {
197 GetVOQueue ()->Queue (packet, hdr);
198 }
199}
200
201void
203{
204 NS_LOG_FUNCTION (this << GetBssid () << isReassoc);
205 WifiMacHeader hdr;
207 hdr.SetAddr1 (GetBssid ());
208 hdr.SetAddr2 (GetAddress ());
209 hdr.SetAddr3 (GetBssid ());
210 hdr.SetDsNotFrom ();
211 hdr.SetDsNotTo ();
212 Ptr<Packet> packet = Create<Packet> ();
213 if (!isReassoc)
214 {
216 assoc.SetSsid (GetSsid ());
219 assoc.SetListenInterval (0);
220 if (GetHtSupported ())
221 {
224 }
225 if (GetVhtSupported ())
226 {
228 }
229 if (GetHeSupported ())
230 {
232 }
233 if (GetEhtSupported ())
234 {
236 }
237 packet->AddHeader (assoc);
238 }
239 else
240 {
242 reassoc.SetCurrentApAddress (GetBssid ());
243 reassoc.SetSsid (GetSsid ());
245 reassoc.SetCapabilities (GetCapabilities ());
246 reassoc.SetListenInterval (0);
247 if (GetHtSupported ())
248 {
251 }
252 if (GetVhtSupported ())
253 {
255 }
256 if (GetHeSupported ())
257 {
259 }
260 if (GetEhtSupported ())
261 {
263 }
264 packet->AddHeader (reassoc);
265 }
266
267 if (!GetQosSupported ())
268 {
269 GetTxop ()->Queue (packet, hdr);
270 }
271 // "A QoS STA that transmits a Management frame determines access category used
272 // for medium access in transmission of the Management frame as follows
273 // (If dot11QMFActivated is false or not present)
274 // — If the Management frame is individually addressed to a non-QoS STA, category
275 // AC_BE should be selected.
276 // — If category AC_BE was not selected by the previous step, category AC_VO
277 // shall be selected." (Sec. 10.2.3.2 of 802.11-2020)
279 {
280 GetBEQueue ()->Queue (packet, hdr);
281 }
282 else
283 {
284 GetVOQueue ()->Queue (packet, hdr);
285 }
286
288 {
290 }
293}
294
295void
297{
298 NS_LOG_FUNCTION (this);
299 switch (m_state)
300 {
301 case ASSOCIATED:
302 return;
303 break;
304 case WAIT_PROBE_RESP:
305 /* we have sent a probe request earlier so we
306 do not need to re-send a probe request immediately.
307 We just need to wait until probe-request-timeout
308 or until we get a probe response
309 */
310 break;
311 case WAIT_BEACON:
312 /* we have initiated passive scanning, continue to wait
313 and gather beacons
314 */
315 break;
316 case UNASSOCIATED:
317 /* we were associated but we missed a bunch of beacons
318 * so we should assume we are not associated anymore.
319 * We try to initiate a scan now.
320 */
321 m_linkDown ();
322 StartScanning ();
323 break;
324 case WAIT_ASSOC_RESP:
325 /* we have sent an association request so we do not need to
326 re-send an association request right now. We just need to
327 wait until either assoc-request-timeout or until
328 we get an association response.
329 */
330 break;
331 case REFUSED:
332 /* we have sent an association request and received a negative
333 association response. We wait until someone restarts an
334 association with a given SSID.
335 */
336 break;
337 }
338}
339
340void
342{
343 NS_LOG_FUNCTION (this);
344 m_candidateAps.clear ();
346 {
348 }
350 {
352 }
353 if (GetActiveProbing ())
354 {
359 this);
360 }
361 else
362 {
366 this);
367 }
368}
369
370void
372{
373 NS_LOG_FUNCTION (this);
374 if (!m_candidateAps.empty ())
375 {
376 ApInfo bestAp = m_candidateAps.front();
377 m_candidateAps.erase(m_candidateAps.begin ());
378 NS_LOG_DEBUG ("Attempting to associate with BSSID " << bestAp.m_bssid);
379 Time beaconInterval;
380 if (bestAp.m_activeProbing)
381 {
382 UpdateApInfoFromProbeResp (bestAp.m_probeResp, bestAp.m_apAddr, bestAp.m_bssid);
383 beaconInterval = MicroSeconds (bestAp.m_probeResp.GetBeaconIntervalUs ());
384 }
385 else
386 {
387 UpdateApInfoFromBeacon (bestAp.m_beacon, bestAp.m_apAddr, bestAp.m_bssid);
388 beaconInterval = MicroSeconds (bestAp.m_beacon.GetBeaconIntervalUs ());
389 }
390
391 Time delay = beaconInterval * m_maxMissedBeacons;
392 RestartBeaconWatchdog (delay);
395 }
396 else
397 {
398 NS_LOG_DEBUG ("Exhausted list of candidate AP; restart scanning");
399 StartScanning ();
400 }
401}
402
403void
405{
406 NS_LOG_FUNCTION (this);
409}
410
411void
413{
414 NS_LOG_FUNCTION (this);
416 {
418 {
420 }
423 return;
424 }
425 NS_LOG_DEBUG ("beacon missed");
426 // We need to switch to the UNASSOCIATED state. However, if we are receiving
427 // a frame, wait until the RX is completed (otherwise, crashes may occur if
428 // we are receiving a MU frame because its reception requires the STA-ID)
429 Time delay = Seconds (0);
430 if (GetWifiPhy ()->IsStateRx ())
431 {
432 delay = GetWifiPhy ()->GetDelayUntilIdle ();
433 }
435}
436
437void
439{
440 NS_LOG_FUNCTION (this);
441 NS_LOG_DEBUG ("Set state to UNASSOCIATED and start scanning");
444}
445
446void
448{
449 NS_LOG_FUNCTION (this << delay);
453 {
454 NS_LOG_DEBUG ("really restart watchdog.");
456 }
457}
458
459bool
461{
462 return m_state == ASSOCIATED;
463}
464
465bool
467{
468 return m_state == WAIT_ASSOC_RESP;
469}
470
471bool
473{
474 return (IsAssociated ());
475}
476
477void
479{
480 NS_LOG_FUNCTION (this << packet << to);
481 if (!CanForwardPacketsTo (to))
482 {
483 NotifyTxDrop (packet);
485 return;
486 }
487 WifiMacHeader hdr;
488
489 //If we are not a QoS AP then we definitely want to use AC_BE to
490 //transmit the packet. A TID of zero will map to AC_BE (through \c
491 //QosUtilsMapTidToAc()), so we use that as our default here.
492 uint8_t tid = 0;
493
494 //For now, an AP that supports QoS does not support non-QoS
495 //associations, and vice versa. In future the AP model should
496 //support simultaneously associated QoS and non-QoS STAs, at which
497 //point there will need to be per-association QoS state maintained
498 //by the association state machine, and consulted here.
499 if (GetQosSupported ())
500 {
503 hdr.SetQosNoEosp ();
504 hdr.SetQosNoAmsdu ();
505 //Transmission of multiple frames in the same TXOP is not
506 //supported for now
507 hdr.SetQosTxopLimit (0);
508
509 //Fill in the QoS control field in the MAC header
510 tid = QosUtilsGetTidForPacket (packet);
511 //Any value greater than 7 is invalid and likely indicates that
512 //the packet had no QoS tag, so we revert to zero, which'll
513 //mean that AC_BE is used.
514 if (tid > 7)
515 {
516 tid = 0;
517 }
518 hdr.SetQosTid (tid);
519 }
520 else
521 {
523 }
524 if (GetQosSupported ())
525 {
526 hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented)
527 }
528
529 hdr.SetAddr1 (GetBssid ());
530 hdr.SetAddr2 (GetAddress ());
531 hdr.SetAddr3 (to);
532 hdr.SetDsNotFrom ();
533 hdr.SetDsTo ();
534
535 if (GetQosSupported ())
536 {
537 //Sanity check that the TID is valid
538 NS_ASSERT (tid < 8);
539 GetQosTxop (tid)->Queue (packet, hdr);
540 }
541 else
542 {
543 GetTxop ()->Queue (packet, hdr);
544 }
545}
546
547void
549{
550 NS_LOG_FUNCTION (this << *mpdu);
551 const WifiMacHeader* hdr = &mpdu->GetHeader ();
552 Ptr<const Packet> packet = mpdu->GetPacket ();
553 NS_ASSERT (!hdr->IsCtl ());
554 if (hdr->GetAddr3 () == GetAddress ())
555 {
556 NS_LOG_LOGIC ("packet sent by us.");
557 return;
558 }
559 else if (hdr->GetAddr1 () != GetAddress ()
560 && !hdr->GetAddr1 ().IsGroup ())
561 {
562 NS_LOG_LOGIC ("packet is not for us");
563 NotifyRxDrop (packet);
564 return;
565 }
566 if (hdr->IsData ())
567 {
568 if (!IsAssociated ())
569 {
570 NS_LOG_LOGIC ("Received data frame while not associated: ignore");
571 NotifyRxDrop (packet);
572 return;
573 }
574 if (!(hdr->IsFromDs () && !hdr->IsToDs ()))
575 {
576 NS_LOG_LOGIC ("Received data frame not from the DS: ignore");
577 NotifyRxDrop (packet);
578 return;
579 }
580 if (hdr->GetAddr2 () != GetBssid ())
581 {
582 NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore");
583 NotifyRxDrop (packet);
584 return;
585 }
586 if (hdr->IsQosData ())
587 {
588 if (hdr->IsQosAmsdu ())
589 {
590 NS_ASSERT (hdr->GetAddr3 () == GetBssid ());
592 packet = 0;
593 }
594 else
595 {
596 ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
597 }
598 }
599 else if (hdr->HasData ())
600 {
601 ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ());
602 }
603 return;
604 }
605 else if (hdr->IsProbeReq ()
606 || hdr->IsAssocReq ()
607 || hdr->IsReassocReq ())
608 {
609 //This is a frame aimed at an AP, so we can safely ignore it.
610 NotifyRxDrop (packet);
611 return;
612 }
613 else if (hdr->IsBeacon ())
614 {
615 NS_LOG_DEBUG ("Beacon received");
616 MgtBeaconHeader beacon;
617 Ptr<Packet> copy = packet->Copy ();
618 copy->RemoveHeader (beacon);
619 CapabilityInformation capabilities = beacon.GetCapabilities ();
620 NS_ASSERT (capabilities.IsEss ());
621 bool goodBeacon = false;
622 if (GetSsid ().IsBroadcast ()
623 || beacon.GetSsid ().IsEqual (GetSsid ()))
624 {
625 NS_LOG_LOGIC ("Beacon is for our SSID");
626 goodBeacon = true;
627 }
628 SupportedRates rates = beacon.GetSupportedRates ();
629 bool bssMembershipSelectorMatch = false;
630 auto selectorList = GetWifiPhy ()->GetBssMembershipSelectorList ();
631 for (const auto & selector : selectorList)
632 {
633 if (rates.IsBssMembershipSelectorRate (selector))
634 {
635 NS_LOG_LOGIC ("Beacon is matched to our BSS membership selector");
636 bssMembershipSelectorMatch = true;
637 }
638 }
639 if (selectorList.size () > 0 && bssMembershipSelectorMatch == false)
640 {
641 NS_LOG_LOGIC ("No match for BSS membership selector");
642 goodBeacon = false;
643 }
644 if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ())
645 {
646 NS_LOG_LOGIC ("Beacon is not for us");
647 goodBeacon = false;
648 }
649 if (goodBeacon && m_state == ASSOCIATED)
650 {
653 RestartBeaconWatchdog (delay);
654 UpdateApInfoFromBeacon (beacon, hdr->GetAddr2 (), hdr->GetAddr3 ());
655 }
656 if (goodBeacon && m_state == WAIT_BEACON)
657 {
658 NS_LOG_DEBUG ("Beacon received while scanning from " << hdr->GetAddr2 ());
659 SnrTag snrTag;
660 bool removed = copy->RemovePacketTag (snrTag);
661 NS_ASSERT (removed);
662 ApInfo apInfo;
663 apInfo.m_apAddr = hdr->GetAddr2 ();
664 apInfo.m_bssid = hdr->GetAddr3 ();
665 apInfo.m_activeProbing = false;
666 apInfo.m_snr = snrTag.Get ();
667 apInfo.m_beacon = beacon;
668 UpdateCandidateApList (apInfo);
669 }
670 return;
671 }
672 else if (hdr->IsProbeResp ())
673 {
675 {
676 NS_LOG_DEBUG ("Probe response received while scanning from " << hdr->GetAddr2 ());
677 MgtProbeResponseHeader probeResp;
678 Ptr<Packet> copy = packet->Copy ();
679 copy->RemoveHeader (probeResp);
680 if (!probeResp.GetSsid ().IsEqual (GetSsid ()))
681 {
682 NS_LOG_DEBUG ("Probe response is not for our SSID");
683 return;
684 }
685 SnrTag snrTag;
686 bool removed = copy->RemovePacketTag (snrTag);
687 NS_ASSERT (removed);
688 ApInfo apInfo;
689 apInfo.m_apAddr = hdr->GetAddr2 ();
690 apInfo.m_bssid = hdr->GetAddr3 ();
691 apInfo.m_activeProbing = true;
692 apInfo.m_snr = snrTag.Get ();
693 apInfo.m_probeResp = probeResp;
694 UpdateCandidateApList (apInfo);
695 }
696 return;
697 }
698 else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
699 {
701 {
702 MgtAssocResponseHeader assocResp;
703 packet->PeekHeader (assocResp);
705 {
707 }
708 if (assocResp.GetStatusCode ().IsSuccess ())
709 {
711 m_aid = assocResp.GetAssociationId ();
712 if (hdr->IsReassocResp ())
713 {
714 NS_LOG_DEBUG ("reassociation done");
715 }
716 else
717 {
718 NS_LOG_DEBUG ("association completed");
719 }
720 UpdateApInfoFromAssocResp (assocResp, hdr->GetAddr2 ());
721 if (!m_linkUp.IsNull ())
722 {
723 m_linkUp ();
724 }
725 }
726 else
727 {
728 NS_LOG_DEBUG ("association refused");
729 if (m_candidateAps.empty ())
730 {
732 }
733 else
734 {
736 }
737 }
738 }
739 return;
740 }
741
742 //Invoke the receive handler of our parent class to deal with any
743 //other frames. Specifically, this will handle Block Ack-related
744 //Management Action frames.
745 WifiMac::Receive (Create<WifiMacQueueItem> (packet, *hdr));
746}
747
748void
750{
751 NS_LOG_FUNCTION (this << newApInfo.m_bssid << newApInfo.m_apAddr << newApInfo.m_snr << newApInfo.m_activeProbing << newApInfo.m_beacon << newApInfo.m_probeResp);
752 // Remove duplicate ApInfo entry
753 for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
754 {
755 if (newApInfo.m_bssid == (*i).m_bssid)
756 {
757 m_candidateAps.erase(i);
758 break;
759 }
760 }
761 // Insert before the entry with lower SNR
762 for (std::vector<ApInfo>::iterator i = m_candidateAps.begin(); i != m_candidateAps.end(); ++i)
763 {
764 if (newApInfo.m_snr > (*i).m_snr)
765 {
766 m_candidateAps.insert (i, newApInfo);
767 return;
768 }
769 }
770 // If new ApInfo is the lowest, insert at back
771 m_candidateAps.push_back(newApInfo);
772}
773
774void
776{
777 NS_LOG_FUNCTION (this << beacon << apAddr << bssid);
778 SetBssid (bssid);
779 CapabilityInformation capabilities = beacon.GetCapabilities ();
780 SupportedRates rates = beacon.GetSupportedRates ();
781 for (const auto & mode : GetWifiPhy ()->GetModeList ())
782 {
783 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
784 {
786 }
787 }
788 bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
789 if (GetErpSupported ())
790 {
791 ErpInformation erpInformation = beacon.GetErpInformation ();
792 isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
793 if (erpInformation.GetUseProtection () != 0)
794 {
796 }
797 else
798 {
800 }
801 if (capabilities.IsShortSlotTime () == true)
802 {
803 //enable short slot time
805 }
806 else
807 {
808 //disable short slot time
810 }
811 }
812 if (GetQosSupported ())
813 {
814 bool qosSupported = false;
815 EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet ();
816 if (edcaParameters.IsQosSupported ())
817 {
818 qosSupported = true;
819 //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs.
820 SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
821 SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
822 SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
823 SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
824 }
825 GetWifiRemoteStationManager ()->SetQosSupport (apAddr, qosSupported);
826 }
827 if (GetHtSupported ())
828 {
829 HtCapabilities htCapabilities = beacon.GetHtCapabilities ();
830 if (!htCapabilities.IsSupportedMcs (0))
831 {
833 }
834 else
835 {
836 GetWifiRemoteStationManager ()->AddStationHtCapabilities (apAddr, htCapabilities);
837 }
838 }
839 if (GetVhtSupported ())
840 {
841 VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities ();
842 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
843 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
844 {
845 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (apAddr, vhtCapabilities);
846 VhtOperation vhtOperation = beacon.GetVhtOperation ();
847 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
848 {
849 if (vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
850 {
852 }
853 }
854 }
855 }
856 if (GetHtSupported ())
857 {
858 ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities ();
859 //TODO: to be completed
860 }
861 if (GetHeSupported ())
862 {
863 HeCapabilities heCapabilities = beacon.GetHeCapabilities ();
864 if (heCapabilities.GetSupportedMcsAndNss () != 0)
865 {
866 GetWifiRemoteStationManager ()->AddStationHeCapabilities (apAddr, heCapabilities);
867 HeOperation heOperation = beacon.GetHeOperation ();
868 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
869 {
870 if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
871 {
873 }
874 }
875 }
876
877 MuEdcaParameterSet muEdcaParameters = beacon.GetMuEdcaParameterSet ();
878 if (muEdcaParameters.IsPresent ())
879 {
880 SetMuEdcaParameters (AC_BE, muEdcaParameters.GetMuCwMin (AC_BE), muEdcaParameters.GetMuCwMax (AC_BE),
881 muEdcaParameters.GetMuAifsn (AC_BE), muEdcaParameters.GetMuEdcaTimer (AC_BE));
882 SetMuEdcaParameters (AC_BK, muEdcaParameters.GetMuCwMin (AC_BK), muEdcaParameters.GetMuCwMax (AC_BK),
883 muEdcaParameters.GetMuAifsn (AC_BK), muEdcaParameters.GetMuEdcaTimer (AC_BK));
884 SetMuEdcaParameters (AC_VI, muEdcaParameters.GetMuCwMin (AC_VI), muEdcaParameters.GetMuCwMax (AC_VI),
885 muEdcaParameters.GetMuAifsn (AC_VI), muEdcaParameters.GetMuEdcaTimer (AC_VI));
886 SetMuEdcaParameters (AC_VO, muEdcaParameters.GetMuCwMin (AC_VO), muEdcaParameters.GetMuCwMax (AC_VO),
887 muEdcaParameters.GetMuAifsn (AC_VO), muEdcaParameters.GetMuEdcaTimer (AC_VO));
888 }
889 }
890 if (GetEhtSupported ())
891 {
892 EhtCapabilities ehtCapabilities = beacon.GetEhtCapabilities ();
893 //TODO: once we support non constant rate managers, we should add checks here whether EHT is supported by the peer
894 GetWifiRemoteStationManager ()->AddStationEhtCapabilities (apAddr, ehtCapabilities);
895 }
896 GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled);
898}
899
900void
902{
903 NS_LOG_FUNCTION (this << probeResp << apAddr << bssid);
904 CapabilityInformation capabilities = probeResp.GetCapabilities ();
905 SupportedRates rates = probeResp.GetSupportedRates ();
906 for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
907 {
908 if (!rates.IsBssMembershipSelectorRate (selector))
909 {
910 NS_LOG_DEBUG ("Supported rates do not fit with the BSS membership selector");
911 return;
912 }
913 }
914 for (const auto & mode : GetWifiPhy ()->GetModeList ())
915 {
916 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
917 {
919 if (rates.IsBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
920 {
922 }
923 }
924 }
925
926 bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
927 if (GetErpSupported ())
928 {
929 bool isErpAllowed = false;
930 for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
931 {
932 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
933 {
934 isErpAllowed = true;
935 break;
936 }
937 }
938 if (!isErpAllowed)
939 {
940 //disable short slot time and set cwMin to 31
942 ConfigureContentionWindow (31, 1023);
943 }
944 else
945 {
946 ErpInformation erpInformation = probeResp.GetErpInformation ();
947 isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
948 if (GetWifiRemoteStationManager ()->GetShortSlotTimeEnabled ())
949 {
950 //enable short slot time
952 }
953 else
954 {
955 //disable short slot time
957 }
958 ConfigureContentionWindow (15, 1023);
959 }
960 }
961 GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled);
963 SetBssid (bssid);
964}
965
966void
968{
969 NS_LOG_FUNCTION (this << assocResp << apAddr);
970 CapabilityInformation capabilities = assocResp.GetCapabilities ();
971 SupportedRates rates = assocResp.GetSupportedRates ();
972 bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
973 if (GetErpSupported ())
974 {
975 bool isErpAllowed = false;
976 for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
977 {
978 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
979 {
980 isErpAllowed = true;
981 break;
982 }
983 }
984 if (!isErpAllowed)
985 {
986 //disable short slot time and set cwMin to 31
988 ConfigureContentionWindow (31, 1023);
989 }
990 else
991 {
992 ErpInformation erpInformation = assocResp.GetErpInformation ();
993 isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
994 if (GetWifiRemoteStationManager ()->GetShortSlotTimeEnabled ())
995 {
996 //enable short slot time
998 }
999 else
1000 {
1001 //disable short slot time
1002 GetWifiPhy ()->SetSlot (MicroSeconds (20));
1003 }
1004 ConfigureContentionWindow (15, 1023);
1005 }
1006 }
1007 GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled);
1009 if (GetQosSupported ())
1010 {
1011 bool qosSupported = false;
1012 EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet ();
1013 if (edcaParameters.IsQosSupported ())
1014 {
1015 qosSupported = true;
1016 //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs.
1017 SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTxopLimit ()));
1018 SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTxopLimit ()));
1019 SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ()));
1020 SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ()));
1021 }
1022 GetWifiRemoteStationManager ()->SetQosSupport (apAddr, qosSupported);
1023 }
1024 if (GetHtSupported ())
1025 {
1026 HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1027 if (!htCapabilities.IsSupportedMcs (0))
1028 {
1030 }
1031 else
1032 {
1033 GetWifiRemoteStationManager ()->AddStationHtCapabilities (apAddr, htCapabilities);
1034 }
1035 }
1036 if (GetVhtSupported ())
1037 {
1038 VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities ();
1039 //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1040 if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1041 {
1042 GetWifiRemoteStationManager ()->AddStationVhtCapabilities (apAddr, vhtCapabilities);
1043 VhtOperation vhtOperation = assocResp.GetVhtOperation ();
1044 }
1045 }
1046 if (GetHeSupported ())
1047 {
1048 HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1049 if (heCapabilities.GetSupportedMcsAndNss () != 0)
1050 {
1051 GetWifiRemoteStationManager ()->AddStationHeCapabilities (apAddr, heCapabilities);
1052 HeOperation heOperation = assocResp.GetHeOperation ();
1053 GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ()));
1054 }
1055
1056 MuEdcaParameterSet muEdcaParameters = assocResp.GetMuEdcaParameterSet ();
1057 if (muEdcaParameters.IsPresent ())
1058 {
1059 SetMuEdcaParameters (AC_BE, muEdcaParameters.GetMuCwMin (AC_BE), muEdcaParameters.GetMuCwMax (AC_BE),
1060 muEdcaParameters.GetMuAifsn (AC_BE), muEdcaParameters.GetMuEdcaTimer (AC_BE));
1061 SetMuEdcaParameters (AC_BK, muEdcaParameters.GetMuCwMin (AC_BK), muEdcaParameters.GetMuCwMax (AC_BK),
1062 muEdcaParameters.GetMuAifsn (AC_BK), muEdcaParameters.GetMuEdcaTimer (AC_BK));
1063 SetMuEdcaParameters (AC_VI, muEdcaParameters.GetMuCwMin (AC_VI), muEdcaParameters.GetMuCwMax (AC_VI),
1064 muEdcaParameters.GetMuAifsn (AC_VI), muEdcaParameters.GetMuEdcaTimer (AC_VI));
1065 SetMuEdcaParameters (AC_VO, muEdcaParameters.GetMuCwMin (AC_VO), muEdcaParameters.GetMuCwMax (AC_VO),
1066 muEdcaParameters.GetMuAifsn (AC_VO), muEdcaParameters.GetMuEdcaTimer (AC_VO));
1067 }
1068 }
1069 if (GetEhtSupported ())
1070 {
1071 EhtCapabilities ehtCapabilities = assocResp.GetEhtCapabilities ();
1072 //TODO: once we support non constant rate managers, we should add checks here whether EHT is supported by the peer
1073 GetWifiRemoteStationManager ()->AddStationEhtCapabilities (apAddr, ehtCapabilities);
1074 }
1075 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1076 {
1077 if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1078 {
1080 if (rates.IsBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ())))
1081 {
1083 }
1084 }
1085 }
1086 if (GetHtSupported ())
1087 {
1088 HtCapabilities htCapabilities = assocResp.GetHtCapabilities ();
1089 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT))
1090 {
1091 if (htCapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1092 {
1094 //here should add a control to add basic MCS when it is implemented
1095 }
1096 }
1097 }
1098 if (GetVhtSupported ())
1099 {
1100 VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities ();
1101 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT))
1102 {
1103 if (vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1104 {
1106 //here should add a control to add basic MCS when it is implemented
1107 }
1108 }
1109 }
1110 if (GetHtSupported ())
1111 {
1112 ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities ();
1113 //TODO: to be completed
1114 }
1115 if (GetHeSupported ())
1116 {
1117 HeCapabilities heCapabilities = assocResp.GetHeCapabilities ();
1118 for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE))
1119 {
1120 if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ()))
1121 {
1123 //here should add a control to add basic MCS when it is implemented
1124 }
1125 }
1126 }
1127 if (GetEhtSupported ())
1128 {
1129 EhtCapabilities ehtCapabilities = assocResp.GetEhtCapabilities ();
1130 //TODO: to be completed
1131 }
1132}
1133
1136{
1137 SupportedRates rates;
1138 for (const auto & mode : GetWifiPhy ()->GetModeList ())
1139 {
1140 uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ());
1141 NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate);
1142 rates.AddSupportedRate (modeDataRate);
1143 }
1144 if (GetHtSupported ())
1145 {
1146 for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ())
1147 {
1148 rates.AddBssMembershipSelectorRate (selector);
1149 }
1150 }
1151 return rates;
1152}
1153
1156{
1157 CapabilityInformation capabilities;
1158 capabilities.SetShortPreamble (GetWifiPhy ()->GetShortPhyPreambleSupported () || GetErpSupported ());
1160 return capabilities;
1161}
1162
1163void
1165{
1166 if (value == ASSOCIATED
1167 && m_state != ASSOCIATED)
1168 {
1170 }
1171 else if (value != ASSOCIATED
1172 && m_state == ASSOCIATED)
1173 {
1175 }
1176 m_state = value;
1177}
1178
1179void
1180StaWifiMac::SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
1181{
1182 Ptr<QosTxop> edca = GetQosTxop (ac);
1183 edca->SetMinCw (cwMin);
1184 edca->SetMaxCw (cwMax);
1185 edca->SetAifsn (aifsn);
1186 edca->SetTxopLimit (txopLimit);
1187}
1188
1189void
1190StaWifiMac::SetMuEdcaParameters (AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
1191{
1192 Ptr<QosTxop> edca = GetQosTxop (ac);
1193 edca->SetMuCwMin (cwMin);
1194 edca->SetMuCwMax (cwMax);
1195 edca->SetMuAifsn (aifsn);
1196 edca->SetMuEdcaTimer (muEdcaTimer);
1197}
1198
1199void
1201{
1202 NS_LOG_FUNCTION (this);
1203 if (IsAssociated ())
1204 {
1205 NS_LOG_DEBUG ("PHY capabilities changed: send reassociation request");
1208 }
1209}
1210
1211void
1213{
1214 NS_LOG_FUNCTION (this);
1215
1217
1218 if (IsInitialized ())
1219 {
1220 Disassociated ();
1221 }
1222}
1223
1224} //namespace ns3
#define max(a, b)
Definition: 80211b.c:43
AttributeValue implementation for Boolean.
Definition: boolean.h:37
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.
bool IsShortSlotTime(void) const
Check if the short slot time in the capability information field is set to 1.
void SetShortSlotTime(bool shortSlotTime)
Set the short slot time bit in the capability information field.
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
bool IsEss(void) const
Check if the Extended Service Set (ESS) bit in the capability information field is set to 1.
The EDCA Parameter Set.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t IsQosSupported(void) const
Is QOS supported function.
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
The IEEE 802.11be EHT Capabilities.
The ErpInformation Information Element.
uint8_t GetBarkerPreambleMode(void) const
Return the Barker_Preamble_Mode field in the ErpInformation information element.
uint8_t GetUseProtection(void) const
Return the Use_Protection field in the ErpInformation information element.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
The Extended Capabilities Information Element.
The IEEE 802.11ax HE Capabilities.
bool IsSupportedRxMcs(uint8_t mcs) const
Is RX MCS supported.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
The HE Operation Information Element.
Definition: he-operation.h:36
uint8_t GetBssColor(void) const
Get the BSS color.
The HT Capabilities Information Element.
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetBroadcast(void)
bool IsGroup(void) const
Implement the header for management frames of type association request.
Definition: mgt-headers.h:51
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:619
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:559
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:595
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:583
void SetEhtCapabilities(EhtCapabilities ehtCapabilities)
Set the EHT capabilities.
Definition: mgt-headers.cc:631
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:553
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:565
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:571
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:607
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:347
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
SupportedRates GetSupportedRates(void)
Return the supported rates.
Definition: mgt-headers.cc:975
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
EhtCapabilities GetEhtCapabilities(void) const
Return the EHT capabilities.
StatusCode GetStatusCode(void)
Return the status code.
Definition: mgt-headers.cc:969
HeOperation GetHeOperation(void) const
Return the HE operation.
ErpInformation GetErpInformation(void) const
Return the ERP information.
uint16_t GetAssociationId(void) const
Return the association ID.
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:999
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:928
Implement the header for management frames of type probe request.
Definition: mgt-headers.h:569
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:94
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:40
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:52
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:82
void SetEhtCapabilities(EhtCapabilities ehtCapabilities)
Set the EHT capabilities.
Definition: mgt-headers.cc:106
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:70
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the extended capabilities.
Definition: mgt-headers.cc:58
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:686
VhtOperation GetVhtOperation(void) const
Return the VHT operation.
Definition: mgt-headers.cc:302
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities.
Definition: mgt-headers.cc:314
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities.
Definition: mgt-headers.cc:290
HeOperation GetHeOperation(void) const
Return the HE operation.
Definition: mgt-headers.cc:326
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set.
Definition: mgt-headers.cc:404
CapabilityInformation GetCapabilities(void) const
Return the Capability information.
Definition: mgt-headers.cc:242
EhtCapabilities GetEhtCapabilities(void) const
Return the EHT capabilities.
Definition: mgt-headers.cc:338
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set.
Definition: mgt-headers.cc:398
Ssid GetSsid(void) const
Return the Service Set Identifier (SSID).
Definition: mgt-headers.cc:218
SupportedRates GetSupportedRates(void) const
Return the supported rates.
Definition: mgt-headers.cc:230
ErpInformation GetErpInformation(void) const
Return the ERP information.
Definition: mgt-headers.cc:380
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities.
Definition: mgt-headers.cc:266
uint64_t GetBeaconIntervalUs(void) const
Return the beacon interval in microseconds unit.
Definition: mgt-headers.cc:224
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities.
Definition: mgt-headers.cc:254
Implement the header for management frames of type reassociation request.
Definition: mgt-headers.h:196
void SetSupportedRates(SupportedRates rates)
Set the supported rates.
Definition: mgt-headers.cc:762
void SetHtCapabilities(HtCapabilities htCapabilities)
Set the HT capabilities.
Definition: mgt-headers.cc:798
void SetCapabilities(CapabilityInformation capabilities)
Set the Capability information.
Definition: mgt-headers.cc:774
void SetEhtCapabilities(EhtCapabilities ehtCapabilities)
Set the EHT capabilities.
Definition: mgt-headers.cc:834
void SetSsid(Ssid ssid)
Set the Service Set Identifier (SSID).
Definition: mgt-headers.cc:756
void SetExtendedCapabilities(ExtendedCapabilities extendedCapabilities)
Set the Extended Capabilities.
Definition: mgt-headers.cc:786
void SetListenInterval(uint16_t interval)
Set the listen interval.
Definition: mgt-headers.cc:768
void SetHeCapabilities(HeCapabilities heCapabilities)
Set the HE capabilities.
Definition: mgt-headers.cc:822
void SetVhtCapabilities(VhtCapabilities vhtCapabilities)
Set the VHT capabilities.
Definition: mgt-headers.cc:810
void SetCurrentApAddress(Mac48Address currentApAddr)
Set the address of the current access point.
Definition: mgt-headers.cc:864
The MU EDCA Parameter Set.
uint16_t GetMuCwMin(uint8_t aci) const
Get the CWmin value encoded by the ECWmin subfield of the ECWmin/ECWmax field in the MU AC Parameter ...
uint8_t GetMuAifsn(uint8_t aci) const
Get the AIFSN subfield of the ACI/AIFSN field in the MU AC Parameter Record field corresponding to th...
bool IsPresent(void) const
Return true if a valid MU EDCA Parameter Set is present in this object.
uint16_t GetMuCwMax(uint8_t aci) const
Get the CWmax value encoded by the ECWmax subfield of the ECWmin/ECWmax field in the MU AC Parameter ...
Time GetMuEdcaTimer(uint8_t aci) const
Get the MU EDCA Timer value encoded in the MU AC Parameter Record field corresponding to the given AC...
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:963
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
void SetMuCwMax(uint16_t cwMax)
Set the maximum contention window size to use while the MU EDCA Timer is running.
Definition: qos-txop.cc:165
void SetMuEdcaTimer(Time timer)
Set the MU EDCA Timer.
Definition: qos-txop.cc:179
void SetMuAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS while the MU EDCA Timer is running.
Definition: qos-txop.cc:172
void SetMuCwMin(uint16_t cwMin)
Set the minimum contention window size to use while the MU EDCA Timer is running.
Definition: qos-txop.cc:158
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:204
Introspection did not find any typical Config paths.
Definition: snr-tag.h:35
double Get(void) const
Return the SNR value.
Definition: snr-tag.cc:89
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition: ssid.cc:55
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:107
Time m_waitBeaconTimeout
wait beacon timeout
Definition: sta-wifi-mac.h:326
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
bool m_activeProbing
active probing
Definition: sta-wifi-mac.h:335
virtual ~StaWifiMac()
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
void SetState(MacState value)
Set the current MAC state.
Time m_beaconWatchdogEnd
beacon watchdog end
Definition: sta-wifi-mac.h:333
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP's information from probe response.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
Definition: sta-wifi-mac.h:343
void NotifyChannelSwitching(void) override
Notify that channel has been switched.
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP's information from beacon.
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:161
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:332
uint16_t GetAssociationId(void) const
Return the association ID.
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP's information from association response.
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
bool IsAssociated(void) const
Return whether we are associated with an AP.
void Disassociated(void)
Take actions after disassociation.
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:334
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:329
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:342
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
void Receive(Ptr< WifiMacQueueItem > mpdu) override
Handle a received packet.
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
EventId m_probeRequestEvent
probe request event
Definition: sta-wifi-mac.h:330
static TypeId GetTypeId(void)
Get the type ID.
Definition: sta-wifi-mac.cc:43
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag.
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:325
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:324
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void SetMuEdcaParameters(AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
Set the MU EDCA parameters.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Definition: sta-wifi-mac.h:344
Time m_assocRequestTimeout
association request timeout
Definition: sta-wifi-mac.h:328
void DoInitialize(void) override
Initialize() implementation.
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:327
void SetActiveProbing(bool enable)
Enable or disable active probing.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate to
Definition: sta-wifi-mac.h:336
EventId m_assocRequestEvent
association request event
Definition: sta-wifi-mac.h:331
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
bool IsSuccess(void) const
Return whether the status code is success.
Definition: status-code.cc:42
The Supported Rates Information Element.
void AddBssMembershipSelectorRate(uint64_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
bool IsBssMembershipSelectorRate(uint64_t bs) const
Check if the given rate is a BSS membership selector value.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
AttributeValue implementation for Time.
Definition: nstime.h:1308
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:173
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:254
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:247
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:161
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:294
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
The IEEE 802.11ac VHT Capabilities.
bool IsSupportedRxMcs(uint8_t mcs) const
Returns true if receive MCS is supported.
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
The VHT Operation Information Element.
Definition: vht-operation.h:36
Implements the IEEE 802.11 MAC header.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
bool IsCtl(void) const
Return true if the Type is Control.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
bool IsFromDs(void) const
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetNoOrder(void)
Unset order bit in the frame control field.
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
bool IsData(void) const
Return true if the Type is DATA.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool IsToDs(void) const
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:86
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1196
bool GetShortSlotTimeSupported(void) const
Definition: wifi-mac.cc:877
Ptr< HeConfiguration > GetHeConfiguration(void) const
Definition: wifi-mac.cc:1064
Callback< void > m_linkDown
Callback when a link is down.
Definition: wifi-mac.h:543
bool GetVhtSupported() const
Return whether the device supports VHT.
Definition: wifi-mac.cc:1086
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:827
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
Definition: wifi-mac.cc:1341
Ssid GetSsid(void) const
Definition: wifi-mac.cc:421
Mac48Address GetAddress(void) const
Definition: wifi-mac.cc:408
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:490
bool GetHtSupported() const
Return whether the device supports HT.
Definition: wifi-mac.cc:1076
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:376
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Definition: wifi-mac.cc:762
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:478
bool GetEhtSupported() const
Return whether the device supports EHT.
Definition: wifi-mac.cc:1106
Mac48Address GetBssid(void) const
Definition: wifi-mac.cc:438
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1096
virtual void Receive(Ptr< WifiMacQueueItem > mpdu)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
Definition: wifi-mac.cc:928
virtual void NotifyChannelSwitching(void)
Notify that channel has been switched.
Definition: wifi-mac.cc:509
Ptr< WifiPhy > GetWifiPhy(void) const
Definition: wifi-mac.cc:781
virtual void SetWifiPhy(Ptr< WifiPhy > phy)
Definition: wifi-mac.cc:768
virtual void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
Definition: wifi-mac.cc:1041
EhtCapabilities GetEhtCapabilities(void) const
Return the EHT capabilities of the device.
Definition: wifi-mac.cc:1395
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:548
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:921
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Definition: wifi-mac.cc:577
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
Definition: wifi-mac.cc:1263
bool GetErpSupported() const
Return whether the device supports ERP.
Definition: wifi-mac.cc:833
Callback< void > m_linkUp
Callback when a link is up.
Definition: wifi-mac.h:542
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Definition: wifi-mac.cc:1207
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:457
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:530
void SetBssid(Mac48Address bssid)
Definition: wifi-mac.cc:427
Ptr< Txop > GetTxop(void) const
Accessor for the Txop object.
Definition: wifi-mac.cc:451
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1173
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:683
Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:1859
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:415
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
void RemoveAllSupportedMcs(Mac48Address address)
Invoked in a STA or AP to delete all of the supported MCS by a destination.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtCapabilities)
Records VHT capabilities of the remote station.
void SetShortPreambleEnabled(bool enable)
Enable or disable short PHY preambles.
void SetQosSupport(Mac48Address from, bool qosSupported)
Records QoS support of the remote station.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
void AddStationEhtCapabilities(Mac48Address from, EhtCapabilities ehtCapabilities)
Records EHT capabilities of the remote station.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1309
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a QoS tag is attached to the packet, returns a value < 8.
Definition: qos-utils.cc:152
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ AC_BE
Best Effort.
Definition: qos-utils.h:73
@ AC_VO
Voice.
Definition: qos-utils.h:79
@ AC_VI
Video.
Definition: qos-utils.h:77
@ AC_BK
Background.
Definition: qos-utils.h:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ STA
Definition: wifi-mac.h:54
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:522
@ WIFI_MAC_MGT_PROBE_REQUEST
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
@ WIFI_MAC_DATA
@ WIFI_MAC_QOSDATA
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
phy
Definition: third.py:93
Struct to hold information regarding observed AP through active/passive scanning.
Definition: sta-wifi-mac.h:45
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:48
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:46
MgtProbeResponseHeader m_probeResp
Probe Response header.
Definition: sta-wifi-mac.h:51
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:47
MgtBeaconHeader m_beacon
Beacon header.
Definition: sta-wifi-mac.h:50
bool m_activeProbing
Flag whether active probing is used or not.
Definition: sta-wifi-mac.h:49