A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sta-wifi-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006, 2009 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8 * Mirko Banchi <mk.banchi@gmail.com>
9 */
10
11#ifndef STA_WIFI_MAC_H
12#define STA_WIFI_MAC_H
13
14#include "wifi-mac.h"
15
16#include "ns3/eht-configuration.h"
17
18#include <set>
19#include <variant>
20
23class ProbeExchTest;
24
25namespace ns3
26{
27
28class SupportedRates;
33class EmlsrManager;
34
35/**
36 * @ingroup wifi
37 *
38 * Type of association performed by this device (provided that it is supported by the standard
39 * configured for this device).
40 */
41enum class WifiAssocType : uint8_t
42{
43 LEGACY = 0,
45};
46
47/**
48 * @ingroup wifi
49 *
50 * Scan type (active or passive)
51 */
52enum class WifiScanType : uint8_t
53{
54 ACTIVE = 0,
56};
57
58/**
59 * @ingroup wifi
60 *
61 * Structure holding scan parameters
62 */
64{
65 /**
66 * Struct identifying a channel to scan.
67 * A channel number equal to zero indicates to scan all the channels;
68 * an unspecified band (WIFI_PHY_BAND_UNSPECIFIED) indicates to scan
69 * all the supported PHY bands.
70 */
71 struct Channel
72 {
73 uint16_t number{0}; ///< channel number
75 };
76
77 /// typedef for a list of channels
78 using ChannelList = std::list<Channel>;
79
80 WifiScanType type; ///< indicates either active or passive scanning
81 Ssid ssid; ///< desired SSID or wildcard SSID
82 std::vector<ChannelList> channelList; ///< list of channels to scan, for each link
83 Time probeDelay; ///< delay prior to transmitting a Probe Request
84 Time minChannelTime; ///< minimum time to spend on each channel
85 Time maxChannelTime; ///< maximum time to spend on each channel
86};
87
88/**
89 * @ingroup wifi
90 *
91 * Enumeration for power management modes
92 */
100
101/**
102 * @ingroup wifi
103 *
104 * The Wifi MAC high model for a non-AP STA in a BSS. The state
105 * machine is as follows:
106 *
107 \verbatim
108 ┌───────────┐ ┌────────────────┐ ┌─────────────┐
109 │ Start │ ┌─────┤ Associated ◄───────────────────┐ ┌──► Refused │
110 └─┬─────────┘ │ └────────────────┘ │ │ └─────────────┘
111 │ │ │ │
112 │ │ ┌─────────────────────────────────────┐ │ │
113 │ │ │ │ │ │
114 │ ┌─────────────▼─▼──┐ ┌──────────────┐ ┌───┴──▼────┴───────────────────┐
115 └──► Unassociated ├───────► Scanning ├───────► Wait Association Response │
116 └──────────────────┘ └──────┬──▲────┘ └───────────────┬──▲────────────┘
117 │ │ │ │
118 │ │ │ │
119 └──┘ └──┘
120 \endverbatim
121 *
122 * Notes:
123 * 1. The state 'Start' is not included in #MacState and only used
124 * for illustration purpose.
125 * 2. The Unassociated state is a transient state before STA starts the
126 * scanning procedure which moves it into the Scanning state.
127 * 3. In Scanning, STA is gathering beacon or probe response frames from APs,
128 * resulted in a list of candidate AP. After the timeout, it then tries to
129 * associate to the best AP, which is indicated by the Association Manager.
130 * STA will restart the scanning procedure if SetActiveProbing() called.
131 * 4. In the case when AP responded to STA's association request with a
132 * refusal, STA will try to associate to the next best AP until the list
133 * of candidate AP is exhausted which sends STA to Refused state.
134 * - Note that this behavior is not currently tested since ns-3 does not
135 * implement association refusal at present.
136 * 5. The transition from Wait Association Response to Unassociated
137 * occurs if an association request fails without explicit
138 * refusal (i.e., the AP fails to respond).
139 * 6. The transition from Associated to Wait Association Response
140 * occurs when STA's PHY capabilities changed. In this state, STA
141 * tries to reassociate with the previously associated AP.
142 * 7. The transition from Associated to Unassociated occurs if the number
143 * of missed beacons exceeds the threshold.
144 */
145class StaWifiMac : public WifiMac
146{
147 public:
148 /// Allow test cases to access private members
149 friend class ::AmpduAggregationTest;
150 friend class ::MultiLinkOperationsTestBase;
151 friend class ::ProbeExchTest;
153
154 /**
155 * Struct to hold information regarding observed AP through
156 * active/passive scanning
157 */
158 struct ApInfo
159 {
160 /**
161 * Information about links to setup
162 */
164 {
165 uint8_t localLinkId; ///< local link ID
166 uint8_t apLinkId; ///< AP link ID
167 Mac48Address bssid; ///< BSSID
168 };
169
171 Mac48Address m_apAddr; ///< AP MAC address
172 double m_snr; ///< SNR in linear scale
173 MgtFrameType m_frame; ///< The body of the management frame used to update AP info
174 WifiScanParams::Channel m_channel; ///< The channel the management frame was received on
175 uint8_t m_linkId; ///< ID of the link used to communicate with the AP
176 std::list<SetupLinksInfo>
177 m_setupLinks; ///< information about the links to setup between MLDs
178 };
179
180 /**
181 * @brief Get the type ID.
182 * @return the object TypeId
183 */
184 static TypeId GetTypeId();
185
186 StaWifiMac();
187 ~StaWifiMac() override;
188
189 bool CanForwardPacketsTo(Mac48Address to) const override;
190 int64_t AssignStreams(int64_t stream) override;
191
192 /**
193 * @param phys the physical layers attached to this MAC.
194 */
195 void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys) override;
196
197 /**
198 * Set the Association Manager.
199 *
200 * @param assocManager the Association Manager
201 */
202 void SetAssocManager(Ptr<WifiAssocManager> assocManager);
203
204 /**
205 * Set the Power Save Manager.
206 *
207 * @param powerSaveManager the Power Save Manager
208 */
209 void SetPowerSaveManager(Ptr<PowerSaveManager> powerSaveManager);
210
211 /**
212 * @return the Power Save Manager
213 */
215
216 /**
217 * Set the EMLSR Manager.
218 *
219 * @param emlsrManager the EMLSR Manager
220 */
221 void SetEmlsrManager(Ptr<EmlsrManager> emlsrManager);
222
223 /**
224 * @return the EMLSR Manager
225 */
227
228 /**
229 * Get the frame body of the Probe Request to transmit on the given link.
230 *
231 * @param linkId the ID of the given link
232 * @return the Probe Request frame body
233 */
234 MgtProbeRequestHeader GetProbeRequest(uint8_t linkId) const;
235
236 /**
237 * Get the frame body of the Multi-Link Probe Request to transmit on the given link.
238 *
239 * @param linkId the ID of the given link
240 * @param apLinkIds ID of the links on which the requested APs, affiliated with the
241 * AP MLD, operate
242 * @param apMldId the AP MLD ID to include in the Common Info field
243 * @return the Multi-Link Probe Request frame body
244 */
246 const std::vector<uint8_t>& apLinkIds,
247 std::optional<uint8_t> apMldId) const;
248
249 /**
250 * Enqueue the given probe request packet for transmission on the given link.
251 *
252 * @param probeReq the given Probe Request frame body
253 * @param linkId the ID of the given link
254 * @param addr1 the MAC address for the Address1 field
255 * @param addr3 the MAC address for the Address3 field
256 */
257 void EnqueueProbeRequest(const MgtProbeRequestHeader& probeReq,
258 uint8_t linkId,
261
262 /**
263 * This method is called after wait beacon timeout or wait probe request timeout has
264 * occurred. This will trigger association process from beacons or probe responses
265 * gathered while scanning.
266 *
267 * @param bestAp the info about the best AP to associate with, if one was found
268 */
269 void ScanningTimeout(const std::optional<ApInfo>& bestAp);
270
271 /**
272 * Return whether we are associated with an AP.
273 *
274 * @return true if we are associated with an AP, false otherwise
275 */
276 bool IsAssociated() const;
277
278 /**
279 * Get the IDs of the setup links (if any).
280 *
281 * @return the IDs of the setup links
282 */
283 std::set<uint8_t> GetSetupLinkIds() const;
284
285 /**
286 * Return the association ID.
287 *
288 * @return the association ID
289 */
290 uint16_t GetAssociationId() const;
291
292 /// @return the type of association procedure performed by this device
294
295 /**
296 * Enable or disable Power Save mode on the given link.
297 *
298 * @param enableLinkIdPair a pair indicating whether to enable or not power save mode on
299 * the link with the given ID
300 */
301 void SetPowerSaveMode(const std::pair<bool, uint8_t>& enableLinkIdPair);
302
303 /**
304 * @param linkId the ID of the given link
305 * @return the current Power Management mode of the STA operating on the given link
306 */
307 WifiPowerManagementMode GetPmMode(uint8_t linkId) const;
308
309 /**
310 * Set the Power Management mode of the setup links after association.
311 *
312 * @param linkId the ID of the link used to establish association
313 */
314 void SetPmModeAfterAssociation(uint8_t linkId);
315
316 /**
317 * Enqueue a PS-Poll frame to be sent on the given link.
318 *
319 * @param linkId the ID of the link on which the PS-Poll frame must be sent
320 */
321 void EnqueuePsPoll(uint8_t linkId);
322
323 /**
324 * Notify the reception of a frame in response to a PS-Poll frame on the given link.
325 *
326 * @param mpdu the received MPDU
327 * @param linkId the ID of the given link
328 */
329 void NotifyReceivedFrameAfterPsPoll(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
330
331 /**
332 * Notify that the MPDU we sent was successfully received by the receiver
333 * (i.e. we received an Ack from the receiver).
334 *
335 * @param mpdu the MPDU that we successfully sent
336 */
337 void TxOk(Ptr<const WifiMpdu> mpdu);
338
339 void NotifyChannelSwitching(uint8_t linkId) override;
340 void NotifyRequestAccess(Ptr<Txop> txop, uint8_t linkId) override;
341 void NotifyChannelReleased(Ptr<Txop> txop, uint8_t linkId) override;
342
343 /**
344 * Notify the MAC that EMLSR mode has changed on the given set of links.
345 *
346 * @param txLinkId the ID of the link on which the EML OMN frame was sent by the EMLSR client
347 * @param linkIds the IDs of the links that are now EMLSR links (EMLSR mode is disabled
348 * on other links)
349 */
350 void NotifyEmlsrModeChanged(uint8_t txLinkId, const std::set<uint8_t>& linkIds);
351
352 /**
353 * @param linkId the ID of the given link
354 * @return whether the EMLSR mode is enabled on the given link
355 */
356 bool IsEmlsrLink(uint8_t linkId) const;
357
358 /**
359 * Notify that the given PHY switched channel to operate on another EMLSR link.
360 *
361 * @param phy the given PHY
362 * @param linkId the ID of the EMLSR link on which the given PHY operates after
363 * the channel switch
364 * @param delay the delay after which the channel switch will be completed
365 */
366 void NotifySwitchingEmlsrLink(Ptr<WifiPhy> phy, uint8_t linkId, Time delay);
367
368 /**
369 * Cancel any scheduled event for connecting the given PHY to an EMLSR link.
370 *
371 * @param phyId the ID of the given PHY
372 */
373 void CancelEmlsrPhyConnectEvent(uint8_t phyId);
374
375 /**
376 * Block transmissions on the given link for the given reason.
377 *
378 * @param linkId the ID of the given link
379 * @param reason the reason for blocking transmissions on the given link
380 */
381 void BlockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason);
382
383 /**
384 * Unblock transmissions on the given links for the given reason.
385 *
386 * @param linkIds the IDs of the given links
387 * @param reason the reason for unblocking transmissions on the given links
388 */
389 void UnblockTxOnLink(std::set<uint8_t> linkIds, WifiQueueBlockedReason reason);
390
391 protected:
392 /**
393 * Structure holding information specific to a single link. Here, the meaning of
394 * "link" is that of the 11be amendment which introduced multi-link devices. For
395 * previous amendments, only one link can be created.
396 */
398 {
399 /// Destructor (a virtual method is needed to make this struct polymorphic)
400 ~StaLinkEntity() override;
401
402 bool sendAssocReq; //!< whether this link is used to send the
403 //!< Association Request frame
404 std::optional<Mac48Address> bssid; //!< BSSID of the AP to associate with over this link
405 WifiPowerManagementMode pmMode{WIFI_PM_ACTIVE}; /**< the current PM mode, if the STA is
406 associated, or the PM mode to switch
407 to upon association, otherwise */
408 bool emlsrEnabled{false}; //!< whether EMLSR mode is enabled on this link
409 };
410
411 /**
412 * Get a reference to the link associated with the given ID.
413 *
414 * @param linkId the given link ID
415 * @return a reference to the link associated with the given ID
416 */
417 StaLinkEntity& GetLink(uint8_t linkId) const;
418
419 /**
420 * Cast the given LinkEntity object to StaLinkEntity.
421 *
422 * @param link the given LinkEntity object
423 * @return a reference to the object casted to StaLinkEntity
424 */
425 StaLinkEntity& GetStaLink(const std::unique_ptr<WifiMac::LinkEntity>& link) const;
426
427 public:
428 /**
429 * The current MAC state of the STA.
430 */
439
440 private:
441 void DoCompleteConfig() override;
442
443 /**
444 * Enable or disable active probing.
445 *
446 * @param enable enable or disable active probing
447 */
448 void SetActiveProbing(bool enable);
449 /**
450 * Return whether active probing is enabled.
451 *
452 * @return true if active probing is enabled, false otherwise
453 */
454 bool GetActiveProbing() const;
455
456 /**
457 * Determine whether the supported rates indicated in a given Beacon frame or
458 * Probe Response frame fit with the configured membership selector.
459 *
460 * @param frame the given Beacon or Probe Response frame
461 * @param linkId ID of the link the mgt frame was received over
462 * @return whether the the supported rates indicated in the given management
463 * frame fit with the configured membership selector
464 */
465 bool CheckSupportedRates(std::variant<MgtBeaconHeader, MgtProbeResponseHeader> frame,
466 uint8_t linkId);
467
468 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
469 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
470 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
471 void Enqueue(Ptr<WifiMpdu> mpdu, Mac48Address to, Mac48Address from) override;
472 void NotifyDropPacketToEnqueue(Ptr<Packet> packet, Mac48Address to) override;
473
474 /**
475 * Process the Beacon frame received on the given link.
476 *
477 * @param mpdu the MPDU containing the Beacon frame
478 * @param linkId the ID of the given link
479 */
480 void ReceiveBeacon(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
481
482 /**
483 * Process the Probe Response frame received on the given link.
484 *
485 * @param mpdu the MPDU containing the Probe Response frame
486 * @param linkId the ID of the given link
487 */
488 void ReceiveProbeResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
489
490 /**
491 * Process the (Re)Association Response frame received on the given link.
492 *
493 * @param mpdu the MPDU containing the (Re)Association Response frame
494 * @param linkId the ID of the given link
495 */
496 void ReceiveAssocResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
497
498 /**
499 * Update operations information from the given management frame.
500 *
501 * @param frame the body of the given management frame
502 * @param addr MAC address of the sender
503 * @param linkId ID of the link the management frame was received over
504 */
505 void RecordOperations(const MgtFrameType& frame, const Mac48Address& addr, uint8_t linkId);
506
507 /**
508 * Update operational settings based on associated AP's information provided by the given
509 * management frame (Beacon, Probe Response or Association Response).
510 *
511 * @param frame the body of the given management frame
512 * @param apAddr MAC address of the AP
513 * @param bssid MAC address of BSSID
514 * @param linkId ID of the link the management frame was received over
515 */
516 void ApplyOperationalSettings(const MgtFrameType& frame,
517 const Mac48Address& apAddr,
518 const Mac48Address& bssid,
519 uint8_t linkId);
520
521 /**
522 * Get the (Re)Association Request frame to send on a given link. The returned frame
523 * never includes a Multi-Link Element.
524 *
525 * @param isReassoc whether a Reassociation Request has to be returned
526 * @param linkId the ID of the given link
527 * @return the (Re)Association Request frame
528 */
529 std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader> GetAssociationRequest(
530 bool isReassoc,
531 uint8_t linkId) const;
532
533 /**
534 * Forward an association or reassociation request packet to the DCF.
535 * The standard is not clear on the correct queue for management frames if QoS is supported.
536 * We always use the DCF.
537 *
538 * @param isReassoc flag whether it is a reassociation request
539 *
540 */
541 void SendAssociationRequest(bool isReassoc);
542 /**
543 * Try to ensure that we are associated with an AP by taking an appropriate action
544 * depending on the current association status.
545 */
547 /**
548 * This method is called after the association timeout occurred. We switch the state to
549 * WAIT_ASSOC_RESP and re-send an association request.
550 */
551 void AssocRequestTimeout();
552 /**
553 * Start the scanning process which trigger active or passive scanning based on the
554 * active probing flag.
555 */
556 void StartScanning();
557 /**
558 * Return whether we are waiting for an association response from an AP.
559 *
560 * @return true if we are waiting for an association response from an AP, false otherwise
561 */
562 bool IsWaitAssocResp() const;
563
564 /**
565 * This method is called after we have not received a beacon from the AP on any link.
566 */
567 void MissedBeacons();
568 /**
569 * Restarts the beacon timer.
570 *
571 * @param delay the delay before the watchdog fires
572 */
573 void RestartBeaconWatchdog(Time delay);
574 /**
575 * Set the state to unassociated and try to associate again.
576 */
577 void Disassociated();
578 /**
579 * Return an instance of SupportedRates that contains all rates that we support
580 * including HT rates.
581 *
582 * @param linkId the ID of the link for which the request is made
583 * @return SupportedRates all rates that we support
584 */
585 AllSupportedRates GetSupportedRates(uint8_t linkId) const;
586 /**
587 * Return the Basic Multi-Link Element to include in the management frames transmitted
588 * on the given link
589 *
590 * @param isReassoc whether the Basic Multi-Link Element is included in a Reassociation Request
591 * @param linkId the ID of the given link
592 * @return the Basic Multi-Link Element
593 */
594 MultiLinkElement GetBasicMultiLinkElement(bool isReassoc, uint8_t linkId) const;
595
596 /**
597 * Return the Probe Request Multi-Link Element to include in the management frames to transmit.
598 *
599 * @param apLinkIds ID of the links on which the requested APs operate
600 * @param apMldId the AP MLD ID to include in the Common Info field
601 * @return the Probe Request Multi-Link Element
602 */
603 MultiLinkElement GetProbeReqMultiLinkElement(const std::vector<uint8_t>& apLinkIds,
604 std::optional<uint8_t> apMldId) const;
605
606 /**
607 * @param apNegSupport the negotiation type supported by the AP MLD
608 * @return the TID-to-Link Mapping element(s) to include in Association Request frame.
609 */
610 std::vector<TidToLinkMapping> GetTidToLinkMappingElements(
611 WifiTidToLinkMappingNegSupport apNegSupport);
612
613 /**
614 * Set the current MAC state.
615 *
616 * @param value the new state
617 */
618 void SetState(MacState value);
619
620 /**
621 * EDCA Parameters
622 */
624 {
625 AcIndex ac; //!< the access category
626 uint32_t cwMin; //!< the minimum contention window size
627 uint32_t cwMax; //!< the maximum contention window size
628 uint8_t aifsn; //!< the number of slots that make up an AIFS
629 Time txopLimit; //!< the TXOP limit
630 };
631
632 /**
633 * Set the EDCA parameters for the given link.
634 *
635 * @param params the EDCA parameters
636 * @param linkId the ID of the given link
637 */
638 void SetEdcaParameters(const EdcaParams& params, uint8_t linkId);
639
640 /**
641 * MU EDCA Parameters
642 */
644 {
645 AcIndex ac; //!< the access category
646 uint32_t cwMin; //!< the minimum contention window size
647 uint32_t cwMax; //!< the maximum contention window size
648 uint8_t aifsn; //!< the number of slots that make up an AIFS
649 Time muEdcaTimer; //!< the MU EDCA timer
650 };
651
652 /**
653 * Set the MU EDCA parameters for the given link.
654 *
655 * @param params the MU EDCA parameters
656 * @param linkId the ID of the given link
657 */
658 void SetMuEdcaParameters(const MuEdcaParams& params, uint8_t linkId);
659
660 /**
661 * Return the Capability information for the given link.
662 *
663 * @param linkId the ID of the given link
664 * @return the Capability information that we support
665 */
666 CapabilityInformation GetCapabilities(uint8_t linkId) const;
667
668 /**
669 * Indicate that PHY capabilities have changed.
670 */
672
673 /**
674 * Get the current primary20 channel used on the given link as a
675 * (channel number, PHY band) pair.
676 *
677 * @param linkId the ID of the given link
678 * @return a (channel number, PHY band) pair
679 */
680 WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const;
681
682 void DoInitialize() override;
683 void DoDispose() override;
684
685 MacState m_state; ///< MAC state
686 uint16_t m_aid; ///< Association AID
687 Ptr<WifiAssocManager> m_assocManager; ///< Association Manager
689 WifiAssocType m_assocType; ///< type of association
691 Time m_waitBeaconTimeout; ///< wait beacon timeout
692 Time m_probeRequestTimeout; ///< probe request timeout
693 Time m_assocRequestTimeout; ///< association request timeout
694 EventId m_assocRequestEvent; ///< association request event
695 uint32_t m_maxMissedBeacons; ///< maximum missed beacons
696 EventId m_beaconWatchdog; //!< beacon watchdog
697 Time m_beaconWatchdogEnd{0}; //!< beacon watchdog end
698 bool m_enableScanning; //!< enable channel scanning
699 bool m_activeProbing; ///< active probing
700 Ptr<RandomVariableStream> m_probeDelay; ///< RandomVariable used to randomize the time
701 ///< of the first Probe Response on each channel
702 Time m_pmModeSwitchTimeout; ///< PM mode switch timeout
703 std::map<uint8_t, EventId> m_emlsrLinkSwitch; ///< maps PHY ID to the event scheduled to switch
704 ///< the corresponding PHY to a new EMLSR link
705
706 /// store the DL TID-to-Link Mapping included in the Association Request frame
708 /// store the UL TID-to-Link Mapping included in the Association Request frame
710
714 TracedCallback<Time> m_beaconArrival; ///< beacon arrival logger
715 TracedCallback<ApInfo> m_beaconInfo; ///< beacon info logger
717 m_emlsrLinkSwitchLogger; ///< EMLSR link switch logger
718
719 /// TracedCallback signature for link setup completed/canceled events
720 using LinkSetupCallback = void (*)(uint8_t /* link ID */, Mac48Address /* AP address */);
721
722 /// TracedCallback signature for EMLSR link switch events
723 using EmlsrLinkSwitchCallback = void (*)(uint8_t /* link ID */, Ptr<WifiPhy> /* PHY */);
724};
725
726/**
727 * @brief Stream insertion operator.
728 *
729 * @param os the output stream
730 * @param apInfo the AP information
731 * @returns a reference to the stream
732 */
733std::ostream& operator<<(std::ostream& os, const StaWifiMac::ApInfo& apInfo);
734
735/**
736 * @brief Stream insertion operator.
737 *
738 * @param os the output stream
739 * @param pmMode the power management mode
740 * @returns a reference to the stream
741 */
742std::ostream& operator<<(std::ostream& os, WifiPowerManagementMode pmMode);
743
744} // namespace ns3
745
746#endif /* STA_WIFI_MAC_H */
Ampdu Aggregation Test.
Probe Request-Probe Response exchange.
EmlsrManager is an abstract base class defining the API that EHT non-AP MLDs with EMLSR activated can...
An identifier for simulation events.
Definition event-id.h:45
an EUI-48 address
static Mac48Address GetBroadcast()
Implement the header for management frames of type probe request.
PowerSaveManager is an abstract base class.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
The basic uniform Random Number Generator (RNG).
The IEEE 802.11 SSID Information Element.
Definition ssid.h:25
std::set< uint8_t > GetSetupLinkIds() const
Get the IDs of the setup links (if any).
void ScanningTimeout(const std::optional< ApInfo > &bestAp)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
Time m_waitBeaconTimeout
wait beacon timeout
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void SetPowerSaveMode(const std::pair< bool, uint8_t > &enableLinkIdPair)
Enable or disable Power Save mode on the given link.
Ptr< WifiAssocManager > m_assocManager
Association Manager.
void DoCompleteConfig() override
Allow subclasses to complete the configuration of the MAC layer components.
bool m_activeProbing
active probing
void DoInitialize() override
Initialize() implementation.
void SetAssocManager(Ptr< WifiAssocManager > assocManager)
Set the Association Manager.
void NotifyEmlsrModeChanged(uint8_t txLinkId, const std::set< uint8_t > &linkIds)
Notify the MAC that EMLSR mode has changed on the given set of links.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
void SetState(MacState value)
Set the current MAC state.
Time m_beaconWatchdogEnd
beacon watchdog end
bool m_enableScanning
enable channel scanning
AllSupportedRates GetSupportedRates(uint8_t linkId) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
void SetEdcaParameters(const EdcaParams &params, uint8_t linkId)
Set the EDCA parameters for the given link.
void SetPowerSaveManager(Ptr< PowerSaveManager > powerSaveManager)
Set the Power Save Manager.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
MacState
The current MAC state of the STA.
void NotifyChannelSwitching(uint8_t linkId) override
Notify that channel on the given link has been switched.
bool GetActiveProbing() const
Return whether active probing is enabled.
EventId m_beaconWatchdog
beacon watchdog
void PhyCapabilitiesChanged()
Indicate that PHY capabilities have changed.
WifiAssocType m_assocType
type of association
StaLinkEntity & GetStaLink(const std::unique_ptr< WifiMac::LinkEntity > &link) const
Cast the given LinkEntity object to StaLinkEntity.
void ReceiveProbeResp(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Probe Response frame received on the given link.
void SetPmModeAfterAssociation(uint8_t linkId)
Set the Power Management mode of the setup links after association.
WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const
Get the current primary20 channel used on the given link as a (channel number, PHY band) pair.
uint16_t GetAssociationId() const
Return the association ID.
void TryToEnsureAssociated()
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
void ReceiveAssocResp(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the (Re)Association Response frame received on the given link.
void NotifySwitchingEmlsrLink(Ptr< WifiPhy > phy, uint8_t linkId, Time delay)
Notify that the given PHY switched channel to operate on another EMLSR link.
std::variant< MgtAssocRequestHeader, MgtReassocRequestHeader > GetAssociationRequest(bool isReassoc, uint8_t linkId) const
Get the (Re)Association Request frame to send on a given link.
static TypeId GetTypeId()
Get the type ID.
MultiLinkElement GetBasicMultiLinkElement(bool isReassoc, uint8_t linkId) const
Return the Basic Multi-Link Element to include in the management frames transmitted on the given link...
void CancelEmlsrPhyConnectEvent(uint8_t phyId)
Cancel any scheduled event for connecting the given PHY to an EMLSR link.
void(*)(uint8_t, Mac48Address) LinkSetupCallback
TracedCallback signature for link setup completed/canceled events.
void DoDispose() override
Destructor implementation.
void BlockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason)
Block transmissions on the given link for the given reason.
std::map< uint8_t, EventId > m_emlsrLinkSwitch
maps PHY ID to the event scheduled to switch the corresponding PHY to a new EMLSR link
void RecordOperations(const MgtFrameType &frame, const Mac48Address &addr, uint8_t linkId)
Update operations information from the given management frame.
StaLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
uint32_t m_maxMissedBeacons
maximum missed beacons
TracedCallback< uint8_t, Mac48Address > m_setupCompleted
link setup completed logger
TracedCallback< Mac48Address > m_assocLogger
association logger
void NotifyChannelReleased(Ptr< Txop > txop, uint8_t linkId) override
Notify that the given TXOP has released the channel on the given link.
void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys) override
void SetMuEdcaParameters(const MuEdcaParams &params, uint8_t linkId)
Set the MU EDCA parameters for the given link.
bool CheckSupportedRates(std::variant< MgtBeaconHeader, MgtProbeResponseHeader > frame, uint8_t linkId)
Determine whether the supported rates indicated in a given Beacon frame or Probe Response frame fit w...
Mac48Address DoGetLocalAddress(const Mac48Address &remoteAddr) const override
This method is called if this device is an MLD to determine the MAC address of the affiliated STA use...
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
friend class WifiStaticSetupHelper
void SetEmlsrManager(Ptr< EmlsrManager > emlsrManager)
Set the EMLSR Manager.
void NotifyDropPacketToEnqueue(Ptr< Packet > packet, Mac48Address to) override
Allow subclasses to take actions when a packet to enqueue has been dropped.
Ptr< PowerSaveManager > GetPowerSaveManager() const
Time m_pmModeSwitchTimeout
PM mode switch timeout.
void Disassociated()
Set the state to unassociated and try to associate again.
Ptr< EmlsrManager > GetEmlsrManager() const
void TxOk(Ptr< const WifiMpdu > mpdu)
Notify that the MPDU we sent was successfully received by the receiver (i.e.
MgtProbeRequestHeader GetProbeRequest(uint8_t linkId) const
Get the frame body of the Probe Request to transmit on the given link.
void EnqueuePsPoll(uint8_t linkId)
Enqueue a PS-Poll frame to be sent on the given link.
MgtProbeRequestHeader GetMultiLinkProbeRequest(uint8_t linkId, const std::vector< uint8_t > &apLinkIds, std::optional< uint8_t > apMldId) const
Get the frame body of the Multi-Link Probe Request to transmit on the given link.
void NotifyReceivedFrameAfterPsPoll(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Notify the reception of a frame in response to a PS-Poll frame on the given link.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
WifiTidLinkMapping m_ulTidLinkMappingInAssocReq
store the UL TID-to-Link Mapping included in the Association Request frame
WifiPowerManagementMode GetPmMode(uint8_t linkId) const
Ptr< RandomVariableStream > m_probeDelay
RandomVariable used to randomize the time of the first Probe Response on each channel.
TracedCallback< ApInfo > m_beaconInfo
beacon info logger
void MissedBeacons()
This method is called after we have not received a beacon from the AP on any link.
uint16_t m_aid
Association AID.
void(*)(uint8_t, Ptr< WifiPhy >) EmlsrLinkSwitchCallback
TracedCallback signature for EMLSR link switch events.
MacState m_state
MAC state.
bool IsEmlsrLink(uint8_t linkId) const
WifiAssocType GetAssocType() const
void NotifyRequestAccess(Ptr< Txop > txop, uint8_t linkId) override
Notify that the given TXOP is requesting channel access on the given link.
void StartScanning()
Start the scanning process which trigger active or passive scanning based on the active probing flag.
std::vector< TidToLinkMapping > GetTidToLinkMappingElements(WifiTidToLinkMappingNegSupport apNegSupport)
TracedCallback< Time > m_beaconArrival
beacon arrival logger
void UnblockTxOnLink(std::set< uint8_t > linkIds, WifiQueueBlockedReason reason)
Unblock transmissions on the given links for the given reason.
void AssocRequestTimeout()
This method is called after the association timeout occurred.
void Enqueue(Ptr< WifiMpdu > mpdu, Mac48Address to, Mac48Address from) override
Ptr< EmlsrManager > m_emlsrManager
EMLSR Manager.
void ApplyOperationalSettings(const MgtFrameType &frame, const Mac48Address &apAddr, const Mac48Address &bssid, uint8_t linkId)
Update operational settings based on associated AP's information provided by the given management fra...
Time m_assocRequestTimeout
association request timeout
void ReceiveBeacon(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Beacon frame received on the given link.
Time m_probeRequestTimeout
probe request timeout
void SetActiveProbing(bool enable)
Enable or disable active probing.
CapabilityInformation GetCapabilities(uint8_t linkId) const
Return the Capability information for the given link.
bool IsAssociated() const
Return whether we are associated with an AP.
~StaWifiMac() override
bool IsWaitAssocResp() const
Return whether we are waiting for an association response from an AP.
Ptr< PowerSaveManager > m_powerSaveManager
Power Save Manager.
MultiLinkElement GetProbeReqMultiLinkElement(const std::vector< uint8_t > &apLinkIds, std::optional< uint8_t > apMldId) const
Return the Probe Request Multi-Link Element to include in the management frames to transmit.
EventId m_assocRequestEvent
association request event
void EnqueueProbeRequest(const MgtProbeRequestHeader &probeReq, uint8_t linkId, const Mac48Address &addr1=Mac48Address::GetBroadcast(), const Mac48Address &addr3=Mac48Address::GetBroadcast())
Enqueue the given probe request packet for transmission on the given link.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
TracedCallback< uint8_t, Ptr< WifiPhy >, bool > m_emlsrLinkSwitchLogger
EMLSR link switch logger.
WifiTidLinkMapping m_dlTidLinkMappingInAssocReq
store the DL TID-to-Link Mapping included in the Association Request frame
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:50
Abstract base class for the Association Manager, which manages scanning and association for single li...
std::variant< MgtBeaconHeader, MgtProbeResponseHeader, MgtAssocResponseHeader > MgtFrameType
type of the management frames
Definition wifi-mac.h:108
WifiScanType
Scan type (active or passive).
WifiPowerManagementMode
Enumeration for power management modes.
WifiPhyBand
Identifies the PHY band.
WifiQueueBlockedReason
Enumeration of the reasons to block container queues.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:64
WifiAssocType
Type of association performed by this device (provided that it is supported by the standard configure...
@ WIFI_PM_SWITCHING_TO_ACTIVE
@ WIFI_PM_POWERSAVE
@ WIFI_PM_SWITCHING_TO_PS
@ WIFI_PM_ACTIVE
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiTidToLinkMappingNegSupport
TID-to-Link Mapping Negotiation Support.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
std::map< tid_t, std::set< linkId_t > > WifiTidLinkMapping
TID-indexed map of the link set to which the TID is mapped.
Definition wifi-utils.h:77
Struct containing all supported rates.
Struct to hold information regarding observed AP through active/passive scanning.
MgtFrameType m_frame
The body of the management frame used to update AP info.
WifiScanParams::Channel m_channel
The channel the management frame was received on.
std::list< SetupLinksInfo > m_setupLinks
information about the links to setup between MLDs
Mac48Address m_apAddr
AP MAC address.
uint8_t m_linkId
ID of the link used to communicate with the AP.
Mac48Address m_bssid
BSSID.
double m_snr
SNR in linear scale.
uint32_t cwMax
the maximum contention window size
AcIndex ac
the access category
uint32_t cwMin
the minimum contention window size
uint8_t aifsn
the number of slots that make up an AIFS
Time txopLimit
the TXOP limit
Time muEdcaTimer
the MU EDCA timer
uint8_t aifsn
the number of slots that make up an AIFS
uint32_t cwMin
the minimum contention window size
AcIndex ac
the access category
uint32_t cwMax
the maximum contention window size
Struct identifying a channel to scan.
WifiPhyBand band
PHY band.
uint16_t number
channel number
Structure holding scan parameters.
std::list< Channel > ChannelList
typedef for a list of channels
std::vector< ChannelList > channelList
list of channels to scan, for each link
Time probeDelay
delay prior to transmitting a Probe Request
WifiScanType type
indicates either active or passive scanning
Time maxChannelTime
maximum time to spend on each channel
Ssid ssid
desired SSID or wildcard SSID
Time minChannelTime
minimum time to spend on each channel