A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ap-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 AP_WIFI_MAC_H
12#define AP_WIFI_MAC_H
13
14#include "tim.h"
15#include "wifi-mac-header.h"
16#include "wifi-mac.h"
17#include "wifi-psdu.h"
18
19#include "ns3/attribute-container.h"
20#include "ns3/enum.h"
21#include "ns3/pair.h"
22
23#include <unordered_map>
24#include <variant>
25
26namespace ns3
27{
28
32class ErpInformation;
36class HtOperation;
37class VhtOperation;
38class HeOperation;
39class EhtOperation;
40class CfParameterSet;
42class MgtEmlOmn;
43class ApEmlsrManager;
44class GcrManager;
45
46/// variant holding a reference to a (Re)Association Request
47using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
48 std::reference_wrapper<MgtReassocRequestHeader>>;
49
50/**
51 * @brief Wi-Fi AP state machine
52 * @ingroup wifi
53 *
54 * Handle association, dis-association and authentication,
55 * of STAs within an infrastructure BSS. By default, beacons are
56 * sent with PIFS access, zero backoff, and are generated roughly
57 * every 102.4 ms by default (configurable by an attribute) and
58 * with some jitter to de-synchronize beacon transmissions in
59 * multi-BSS scenarios.
60 */
61class ApWifiMac : public WifiMac
62{
63 public:
65
66 /**
67 * @brief Get the type ID.
68 * @return the object TypeId
69 */
70 static TypeId GetTypeId();
71
72 ApWifiMac();
73 ~ApWifiMac() override;
74
75 void SetLinkUpCallback(Callback<void> linkUp) override;
76 bool CanForwardPacketsTo(Mac48Address to) const override;
77 bool SupportsSendFrom() const override;
78 Ptr<Txop> GetTxopFor(AcIndex ac) const override;
79 int64_t AssignStreams(int64_t stream) override;
80
81 /**
82 * Set the AP EMLSR Manager.
83 *
84 * @param apEmlsrManager the AP EMLSR Manager
85 */
86 void SetApEmlsrManager(Ptr<ApEmlsrManager> apEmlsrManager);
87
88 /**
89 * @return the AP EMLSR Manager
90 */
92
93 /**
94 * Set the GCR Manager.
95 *
96 * @param gcrManager the GCR Manager
97 */
98 void SetGcrManager(Ptr<GcrManager> gcrManager);
99
100 /**
101 * @return the GCR Manager
102 */
104
105 /**
106 * @param interval the interval between two beacon transmissions.
107 */
108 void SetBeaconInterval(Time interval);
109 /**
110 * @return the interval between two beacon transmissions.
111 */
112 Time GetBeaconInterval() const;
113
114 /**
115 * Get a const reference to the map of associated stations on the given link.
116 * Each station is specified by an (association ID, MAC address) pair. Make sure
117 * not to use the returned reference after that this object has been deallocated.
118 *
119 * @param linkId the ID of the given link
120 * @return a const reference to the map of associated stations
121 */
122 const std::map<uint16_t, Mac48Address>& GetStaList(uint8_t linkId) const;
123 /**
124 * @param addr the address of the associated station
125 * @param linkId the ID of the link on which the station is associated
126 * @return the Association ID allocated by the AP to the station, SU_STA_ID if unallocated
127 */
128 uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const;
129
130 /// @return the next Association ID to be allocated by the AP
131 uint16_t GetNextAssociationId() const;
132
133 /**
134 * Get the ID of a link (if any) that has been setup with the station having the given MAC
135 * address. The address can be either a link address or an MLD address. In the former case,
136 * the returned ID is the ID of the link connecting the AP to the STA with the given address.
137 *
138 * @param address the given MAC address
139 * @return the ID of a link (if any) that has been setup with the given station
140 */
141 std::optional<uint8_t> IsAssociated(const Mac48Address& address) const;
142
143 /**
144 * @param aid the given AID
145 * @return the MLD address (in case of MLD) or link address (in case of single link device)
146 * of the STA having the given AID, if any
147 */
148 std::optional<Mac48Address> GetMldOrLinkAddressByAid(uint16_t aid) const;
149
150 /**
151 * Get the number of STAs associated on the given link that are in PowerSave mode.
152 *
153 * @param linkId the ID of the given link
154 * @return the number of STAs associated on the given link that are in PowerSave mode
155 */
156 std::size_t GetNStationsInPsMode(linkId_t linkId) const;
157
158 /**
159 * Check whether the AP MLD has buffered (QoS) data frame(s) for the given destination
160 * because non-AP STAs operating on links where those (QoS) data frames could be transmitted
161 * are in powersave mode. If a link ID is defined, it must be possible for the returned buffered
162 * (QoS) data frame to be transmitted on that link (e.g., the TID of the data frame is mapped to
163 * that link).
164 *
165 * @param address the MLD address, if the destination is an MLD, or the MAC address, otherwise
166 * @param linkId the ID of the link for which we check buffered (QoS) data frames
167 * @return a buffered (QoS) data frame for the given destination
168 */
170 uint8_t linkId = WIFI_LINKID_UNDEFINED) const;
171
172 /**
173 * Check whether the AP MLD has buffered MMPDUs for the given destination because non-AP STAs
174 * operating on links where those MMPDUs could be transmitted are in powersave mode. If a link
175 * ID is defined, it must be possible for the returned buffered MMPDU to be transmitted on that
176 * link.
177 *
178 * @param address the MLD address, if the destination is an MLD, or the MAC address, otherwise
179 * @param linkId the ID of the link for which we check buffered (QoS) data frames
180 * @return a buffered MMPDUs for the given destination
181 */
183 uint8_t linkId = WIFI_LINKID_UNDEFINED) const;
184
185 /**
186 * Check whether the AP MLD has buffered frames with a destination groupcast address to be sent
187 * on the given link.
188 *
189 * @param linkId the ID of the given link
190 * @return whether the AP MLD has buffered frames with a destination groupcast address
191 */
192 bool HasBufferedGroupcast(uint8_t linkId) const;
193
194 /**
195 * Return the value of the Queue Size subfield of the last QoS Data or QoS Null
196 * frame received from the station with the given MAC address and belonging to
197 * the given TID.
198 *
199 * The Queue Size value is the total size, rounded up to the nearest multiple
200 * of 256 octets and expressed in units of 256 octets, of all MSDUs and A-MSDUs
201 * buffered at the STA (excluding the MSDU or A-MSDU of the present QoS Data frame).
202 * A queue size value of 254 is used for all sizes greater than 64 768 octets.
203 * A queue size value of 255 is used to indicate an unspecified or unknown size.
204 * See Section 9.2.4.5.6 of 802.11-2016
205 *
206 * @param tid the given TID
207 * @param address the given MAC address
208 * @return the value of the Queue Size subfield
209 */
210 uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const;
211 /**
212 * Store the value of the Queue Size subfield of the last QoS Data or QoS Null
213 * frame received from the station with the given MAC address and belonging to
214 * the given TID.
215 *
216 * @param tid the given TID
217 * @param address the given MAC address
218 * @param size the value of the Queue Size subfield
219 */
220 void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size);
221 /**
222 * Return the maximum among the values of the Queue Size subfield of the last
223 * QoS Data or QoS Null frames received from the station with the given MAC address
224 * and belonging to any TID.
225 *
226 * @param address the given MAC address
227 * @return the maximum among the values of the Queue Size subfields
228 */
229 uint8_t GetMaxBufferStatus(Mac48Address address) const;
230
231 /**
232 * Return whether at least one additional buffered unit is present for the same STA after
233 * transmitting the given MPDU, if the given MPDU is a unicast frame, or whether one additional
234 * group addressed buffered unit is present after transmitting the given MPDU, if the given
235 * MPDU is a group addressed frame.
236 *
237 * @param mpdu an individually addressed Data or Management frame transmitted to a STA in
238 * PS mode or a group addressed frame transmitted after a DTIM (i.e., while
239 * transmission of unicast frames is blocked)
240 * @param linkId the ID of the link on which the MPDU is transmitted
241 * @return whether at least one additional buffered unit is present after transmitting the
242 * given MPDU
243 */
244 bool HasMoreDataAfter(Ptr<const WifiMpdu> mpdu, uint8_t linkId) const;
245
246 /**
247 * Return whether GCR is used to transmit a packet.
248 *
249 * @param hdr the header of the packet to transmit
250 * @return true if a GCR manager is set and the packet is a groupcast QoS data, false otherwise
251 */
252 bool UseGcr(const WifiMacHeader& hdr) const;
253
254 /**
255 * Check if a GCR Block Ack agreement has been successfully established with all members of
256 * its group.
257 *
258 * @param groupAddress the GCR group address.
259 * @param tid the traffic ID.
260 * @return true if a GCR Block Ack agreement has been successfully established with all members
261 * of its group, false otherwise.
262 */
264 uint8_t tid) const;
265
266 /// ACI-indexed map of access parameters of type unsigned integer (CWmin, CWmax and AIFSN)
267 using UintAccessParamsMap = std::map<AcIndex, std::vector<uint64_t>>;
268
269 /// ACI-indexed map of access parameters of type Time (TxopLimit)
270 using TimeAccessParamsMap = std::map<AcIndex, std::vector<Time>>;
271
272 /// AttributeValue type of a pair (ACI, access parameters of type unsigned integer)
275
276 /// AttributeValue type of a pair (ACI, access parameters of type Time)
279
280 /// AttributeValue type of an ACI-indexed map of access parameters of type unsigned integer
282
283 /// AttributeValue type of ACI-indexed map of access parameters of type Time
285
286 /**
287 * Get a checker for the CwMinsForSta, CwMaxsForSta and AifsnsForSta attributes, which can
288 * be used to deserialize an ACI-indexed map of access parameters of type unsigned integer
289 * (CWmin, CWmax and AIFSN) from a string:
290 *
291 * @code
292 * ApWifiMac::UintAccessParamsMapValue value;
293 * value.DeserializeFromString("BE 31,31; VO 15,15",
294 * ApWifiMac::GetUintAccessParamsChecker<uint32_t>());
295 * auto map = value.Get();
296 * @endcode
297 *
298 * The type of \p map is ApWifiMac::UintAccessParamsMapValue::result_type, which is
299 * std::list<std::pair<AcIndex, std::vector<uint64_t>>>.
300 *
301 * @tparam T \explicit the type of the unsigned integer access parameter
302 * @return a checker for the CwMinsForSta, CwMaxsForSta and AifsnsForSta attributes
303 */
304 template <class T>
306
307 /**
308 * Get a checker for the TxopLimitsForSta attribute, which can be used to deserialize an
309 * ACI-indexed map of access parameters of type Time (TxopLimit) from a string:
310 *
311 * @code
312 * ApWifiMac::TimeAccessParamsMapValue value;
313 * value.DeserializeFromString("BE 3200us; VO 3232us",
314 * ApWifiMac::GetTimeAccessParamsChecker());
315 * auto map = value.Get();
316 * @endcode
317 *
318 * The type of \p map is ApWifiMac::TimeAccessParamsMapValue::result_type, which is
319 * std::list<std::pair<AcIndex, std::vector<Time>>>.
320 *
321 * @return a checker for the TxopLimitsForSta attribute
322 */
324
325 protected:
326 /**
327 * Structure holding information specific to a single link. Here, the meaning of
328 * "link" is that of the 11be amendment which introduced multi-link devices. For
329 * previous amendments, only one link can be created.
330 */
332 {
333 /// Destructor (a virtual method is needed to make this struct polymorphic)
334 ~ApLinkEntity() override;
335
336 EventId beaconEvent; //!< Event to generate one beacon
337 std::map<uint16_t, Mac48Address> staList; //!< Map of all stations currently associated
338 //!< to the AP with their association ID
339 uint16_t numNonHtStations{0}; //!< Number of non-HT stations currently associated to the AP
341 0}; //!< Number of non-ERP stations currently associated to the AP
343 false}; //!< Flag whether short slot time is enabled within the BSS
344 bool shortPreambleEnabled{false}; //!< Flag whether short preamble is enabled in the BSS
345 uint8_t beaconDtimCount{0}; ///< Number of beacons to DTIM
346 std::size_t nStationsInPsMode{0}; //!< Number of associated stations in PS mode
347 };
348
349 /**
350 * Get a reference to the link associated with the given ID.
351 *
352 * @param linkId the given link ID
353 * @return a reference to the link associated with the given ID
354 */
355 ApLinkEntity& GetLink(uint8_t linkId) const;
356
357 std::map<uint16_t, Mac48Address>
358 m_aidToMldOrLinkAddress; //!< Maps AIDs to MLD addresses (for MLDs) or link addresses (in
359 //!< case of single link devices)
360
361 private:
362 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
363 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
364 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
365 void DoCompleteConfig() override;
366 void Enqueue(Ptr<WifiMpdu> mpdu, Mac48Address to, Mac48Address from) override;
367
368 /**
369 * Check whether the supported rate set included in the received (Re)Association
370 * Request frame is compatible with our Basic Rate Set. If so, record all the station's
371 * supported modes in its associated WifiRemoteStation and return true.
372 * Otherwise, return false.
373 *
374 * @param assoc the frame body of the received (Re)Association Request
375 * @param from the Transmitter Address field of the frame
376 * @param linkId the ID of the link on which the frame was received
377 * @return true if the (Re)Association request can be accepted, false otherwise
378 */
379 bool ReceiveAssocRequest(const AssocReqRefVariant& assoc,
380 const Mac48Address& from,
381 uint8_t linkId);
382
383 /**
384 * Given a (Re)Association Request frame body containing a Multi-Link Element,
385 * check if a link can be setup with each of the reported stations (STA MAC address
386 * and a (Re)Association Request frame body must be present, the Link ID identifies
387 * a valid link other than the one the frame was received on and the supported
388 * rates are compatible with our basic rate set).
389 *
390 * @param assoc the frame body of the received (Re)Association Request
391 * @param from the Transmitter Address field of the frame
392 * @param linkId the ID of the link on which the frame was received
393 */
394 void ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address from, uint8_t linkId);
395
396 /**
397 * Process the EML Operating Mode Notification frame received from the given station on the
398 * given link.
399 *
400 * @param frame the received EML Operating Mode Notification frame
401 * @param sender the MAC address of the sender of the frame
402 * @param linkId the ID of the link over which the frame was received
403 */
404 void ReceiveEmlOmn(const MgtEmlOmn& frame, const Mac48Address& sender, uint8_t linkId);
405
406 /**
407 * Respond to the EML Operating Mode Notification frame received from the given station on the
408 * given link.
409 *
410 * @param frame the received EML Operating Mode Notification frame
411 * @param sender the MAC address of the sender of the frame
412 * @param linkId the ID of the link over which the frame was received
413 */
414 void RespondToEmlOmn(MgtEmlOmn frame, const Mac48Address& sender, uint8_t linkId);
415
416 /**
417 * Take necessary actions upon completion of an exchange of EML Operating Mode Notification
418 * frames.
419 *
420 * @param frame the received EML Operating Mode Notification frame
421 * @param sender the MAC address of the sender of the frame
422 * @param linkId the ID of the link over which the frame was received
423 */
424 void EmlOmnExchangeCompleted(const MgtEmlOmn& frame,
425 const Mac48Address& sender,
426 uint8_t linkId);
427
428 /**
429 * The packet we sent was successfully received by the receiver
430 * (i.e. we received an Ack from the receiver). If the packet
431 * was an association response to the receiver, we record that
432 * the receiver is now associated with us.
433 *
434 * @param mpdu the MPDU that we successfully sent
435 */
436 void TxOk(Ptr<const WifiMpdu> mpdu);
437 /**
438 * The packet we sent was successfully received by the receiver
439 * (i.e. we did not receive an Ack from the receiver). If the packet
440 * was an association response to the receiver, we record that
441 * the receiver is not associated with us yet.
442 *
443 * @param timeoutReason the reason why the TX timer was started (\see WifiTxTimer::Reason)
444 * @param mpdu the MPDU that we failed to sent
445 */
446 void TxFailed(WifiMacDropReason timeoutReason, Ptr<const WifiMpdu> mpdu);
447
448 /**
449 * This method is called to de-aggregate an A-MSDU and forward the
450 * constituent packets up the stack. We override the WifiMac version
451 * here because, as an AP, we also need to think about redistributing
452 * to other associated STAs.
453 *
454 * @param mpdu the MPDU containing the A-MSDU.
455 */
457
458 /**
459 * Get Probe Response Per-STA Profile for the given link.
460 *
461 * @param linkId the ID of the given link
462 * @return the Probe Response header
463 */
464 MgtProbeResponseHeader GetProbeRespProfile(uint8_t linkId) const;
465
466 /**
467 * Get Probe Response based on the given Probe Request Multi-link Element (if any)
468 *
469 * @param linkId the ID of link the Probe Response is to be sent
470 * @param reqMle Probe Request Multi-link Element
471 * @return Probe Response header
472 */
474 const std::optional<MultiLinkElement>& reqMle);
475
476 /**
477 * Send a packet prepared using the given Probe Response to the given receiver on the given
478 * link.
479 *
480 * @param probeResp the Probe Response header
481 * @param to the address of the STA we are sending a probe response to
482 * @param linkId the ID of the given link
483 */
484 void EnqueueProbeResp(const MgtProbeResponseHeader& probeResp, Mac48Address to, uint8_t linkId);
485
486 /**
487 * Get the Association Response frame to send on a given link. The returned frame
488 * never includes a Multi-Link Element.
489 *
490 * @param to the address of the STA we are sending an association response to
491 * @param linkId the ID of the given link
492 * @return the Association Response frame
493 */
495 /// Map of (link ID, remote STA address) of the links to setup
496 using LinkIdStaAddrMap = std::map<uint8_t, Mac48Address>;
497 /**
498 * Set the AID field of the given Association Response frame. In case of
499 * multi-link setup, the selected AID value must be assigned to all the STAs
500 * corresponding to the setup links. The AID value is selected among the AID
501 * values that are possibly already assigned to the STAs affiliated with the
502 * non-AP MLD we are associating with. If no STA has an assigned AID value,
503 * a new AID value is selected.
504 *
505 * @param assoc the given Association Response frame
506 * @param linkIdStaAddrMap a map of (link ID, remote STA address) of the links to setup
507 */
508 void SetAid(MgtAssocResponseHeader& assoc, const LinkIdStaAddrMap& linkIdStaAddrMap);
509 /**
510 * Get a map of (link ID, remote STA address) of the links to setup. Information
511 * is taken from the given Association Response that is sent over the given link
512 * to the given station.
513 *
514 * @param assoc the given Association Response frame
515 * @param to the Receiver Address (RA) of the Association Response frame
516 * @param linkId the ID of the link on which the Association Response frame is sent
517 * @return a map of (link ID, remote STA address) of the links to setup
518 */
520 const Mac48Address& to,
521 uint8_t linkId);
522 /**
523 * Forward an association or a reassociation response packet to the DCF/EDCA.
524 *
525 * @param to the address of the STA we are sending an association response to
526 * @param isReassoc indicates whether it is a reassociation response
527 * @param linkId the ID of the link on which the association response must be sent
528 */
529 void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId);
530 /**
531 * Forward a beacon packet to the beacon special DCF for transmission
532 * on the given link.
533 *
534 * @param linkId the ID of the given link
535 */
536 void SendOneBeacon(uint8_t linkId);
537
538 /**
539 * This function is connected to the PhyTxPsduBegin PHY trace source when enqueuing a Beacon
540 * frame containing a DTIM that indicates that group addressed frames are queued. This function
541 * intercepts the Beacon frame, unblock the transmission of group addressed frames on the given
542 * link and block the transmission of unicast frames on the given link (so that group addressed
543 * frames are transmitted first).
544 *
545 * @param linkId the ID of the link on which the frame is transmitted
546 * @param psduMap the transmitted PSDU map
547 */
548 void TxGroupAddrFramesAfterDtim(uint8_t linkId,
549 WifiConstPsduMap psduMap,
550 WifiTxVector /* txVector */,
551 Watt_u /* txPower */);
552
553 /**
554 * Check whether the AP is done with the transmission of group addressed frames after a DTIM
555 * transmitted on the given link. If so, transmission of group addressed frames on the given
556 * link is blocked and transmission of unicast frames on the given link is unblocked.
557 *
558 * @param linkId the ID of the given link
559 * @param mpdu the MPDU (if any) that triggered a call to this function after being removed
560 * from a MAC queue
561 */
562 void CheckGroupAddrFramesAfterDtimDone(uint8_t linkId,
563 Ptr<const WifiMpdu> mpdu = nullptr) const;
564
565 /**
566 * Get the FILS Discovery frame to send on the given link.
567 *
568 * @param linkId the ID of the given link
569 * @return the FILS Discovery frame to send on the given link
570 */
571 Ptr<WifiMpdu> GetFilsDiscovery(uint8_t linkId) const;
572
573 /**
574 * Schedule the transmission of FILS Discovery frames or unsolicited Probe Response frames
575 * on the given link
576 *
577 * @param linkId the ID of the given link
578 */
579 void ScheduleFilsDiscOrUnsolProbeRespFrames(uint8_t linkId);
580
581 /**
582 * Process the Power Management bit in the Frame Control field of an MPDU
583 * successfully received on the given link.
584 *
585 * @param mpdu the successfully received MPDU
586 * @param linkId the ID of the given link
587 */
588 void ProcessPowerManagementFlag(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
589 /**
590 * Perform the necessary actions when a given station that is in active mode switches
591 * to powersave mode.
592 *
593 * @param staAddr the MAC address of the given station
594 * @param linkId the ID of the link on which the given station is operating
595 */
596 void StaSwitchingToPsMode(const Mac48Address& staAddr, uint8_t linkId);
597 /**
598 * Perform the necessary actions when a given station that is in powersave mode deassociates
599 * or switches to active mode.
600 *
601 * @param staAddr the MAC address of the given station
602 * @param linkId the ID of the link on which the given station is operating
603 */
604 void StaSwitchingToActiveModeOrDeassociated(const Mac48Address& staAddr, uint8_t linkId);
605
606 /**
607 * Return the Capability information of the current AP for the given link.
608 *
609 * @param linkId the ID of the given link
610 * @return the Capability information that we support
611 */
612 CapabilityInformation GetCapabilities(uint8_t linkId) const;
613
614 /**
615 * Return the TIM for the current AP to transmit on the given link.
616 *
617 * @param linkId the ID of the given link
618 * @return the TIM based on the current status of the queues
619 */
620 Tim GetTim(uint8_t linkId) const;
621
622 /**
623 * Return the ERP information of the current AP for the given link.
624 *
625 * @param linkId the ID of the given link
626 * @return the ERP information that we support for the given link
627 */
628 ErpInformation GetErpInformation(uint8_t linkId) const;
629 /**
630 * Return the EDCA Parameter Set of the current AP for the given link.
631 *
632 * @param linkId the ID of the given link
633 * @return the EDCA Parameter Set that we support for the given link
634 */
635 EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const;
636 /**
637 * Return the MU EDCA Parameter Set of the current AP, if one needs to be advertised
638 *
639 * @return the MU EDCA Parameter Set that needs to be advertised (if any)
640 */
641 std::optional<MuEdcaParameterSet> GetMuEdcaParameterSet() const;
642 /**
643 * Return the Reduced Neighbor Report (RNR) element that the current AP sends
644 * on the given link, if one needs to be advertised.
645 *
646 * @param linkId the ID of the link to send the RNR element onto
647 * @return the Reduced Neighbor Report element
648 */
649 std::optional<ReducedNeighborReport> GetReducedNeighborReport(uint8_t linkId) const;
650
651 /**
652 * Return the Multi-Link Element that the current AP includes in the management
653 * frames of the given type it transmits on the given link.
654 *
655 * @param linkId the ID of the link to send the Multi-Link Element onto
656 * @param frameType the type of the frame containing the Multi-Link Element
657 * @param to the Receiver Address of the frame containing the Multi-Link Element
658 * @param mlProbeReqMle the Multi-Link Element included in the multi-link probe request, in
659 * case the Multi-Link Element is requested for the response to such a
660 * frame
661 * @return the Multi-Link Element
662 */
664 uint8_t linkId,
665 WifiMacType frameType,
667 const std::optional<MultiLinkElement>& mlProbeReqMle = std::nullopt);
668
669 /**
670 * Return the HT operation of the current AP for the given link.
671 *
672 * @param linkId the ID of the given link
673 * @return the HT operation that we support
674 */
675 HtOperation GetHtOperation(uint8_t linkId) const;
676 /**
677 * Return the VHT operation of the current AP for the given link.
678 *
679 * @param linkId the ID of the given link
680 * @return the VHT operation that we support
681 */
682 VhtOperation GetVhtOperation(uint8_t linkId) const;
683 /**
684 * Return the HE operation of the current AP for the given link.
685 *
686 * @param linkId the ID of the given link
687 * @return the HE operation that we support
688 */
689 HeOperation GetHeOperation(uint8_t linkId) const;
690 /**
691 * Return the EHT operation of the current AP for the given link.
692 *
693 * @param linkId the ID of the given link
694 * @return the EHT operation that we support
695 */
696 EhtOperation GetEhtOperation(uint8_t linkId) const;
697 /**
698 * Return an instance of SupportedRates that contains all rates that we support
699 * for the given link (including HT rates).
700 *
701 * @param linkId the ID of the given link
702 * @return all rates that we support
703 */
704 AllSupportedRates GetSupportedRates(uint8_t linkId) const;
705 /**
706 * Return the DSSS Parameter Set that we support on the given link
707 *
708 * @param linkId the ID of the given link
709 * @return the DSSS Parameter Set that we support on the given link
710 */
711 DsssParameterSet GetDsssParameterSet(uint8_t linkId) const;
712 /**
713 * Enable or disable beacon generation of the AP.
714 *
715 * @param enable enable or disable beacon generation
716 */
717 void SetBeaconGeneration(bool enable);
718
719 /**
720 * Update whether short slot time should be enabled or not in the BSS
721 * corresponding to the given link.
722 * Typically, short slot time is enabled only when there is no non-ERP station
723 * associated to the AP, and that short slot time is supported by the AP and by all
724 * other ERP stations that are associated to the AP. Otherwise, it is disabled.
725 *
726 * @param linkId the ID of the given link
727 */
728 void UpdateShortSlotTimeEnabled(uint8_t linkId);
729 /**
730 * Update whether short preamble should be enabled or not in the BSS
731 * corresponding to the given link.
732 * Typically, short preamble is enabled only when the AP and all associated
733 * stations support short PHY preamble. Otherwise, it is disabled.
734 *
735 * @param linkId the ID of the given link
736 */
737 void UpdateShortPreambleEnabled(uint8_t linkId);
738
739 /**
740 * Return whether protection for non-ERP stations is used in the BSS
741 * corresponding to the given link.
742 *
743 * @param linkId the ID of the given link
744 * @return true if protection for non-ERP stations is used in the BSS,
745 * false otherwise
746 */
747 bool GetUseNonErpProtection(uint8_t linkId) const;
748
749 void DoDispose() override;
750 void DoInitialize() override;
751
752 Ptr<Txop> m_beaconTxop; //!< Dedicated Txop for beacons
753 bool m_enableBeaconGeneration; //!< Flag whether beacons are being generated
754 Time m_beaconInterval; //!< Beacon interval
756 m_beaconJitter; //!< UniformRandomVariable used to randomize the time of the first beacon
757 bool m_enableBeaconJitter; //!< Flag whether the first beacon should be generated at random time
758 uint8_t m_dtimPeriod; //!< DTIM Period
759 bool m_enableNonErpProtection; //!< Flag whether protection mechanism is used or not when
760 //!< non-ERP STAs are present within the BSS
761 Time m_bsrLifetime; //!< Lifetime of Buffer Status Reports
762 /// transition timeout events running for EMLSR clients
763 std::map<Mac48Address, EventId> m_transitionTimeoutEvents;
764 uint8_t m_grpAddrBuIndicExp; //!< Group Addressed BU Indication Exponent of EHT Operation IE
767
768 UintAccessParamsMap m_cwMinsForSta; //!< Per-AC CW min values to advertise to stations
769 UintAccessParamsMap m_cwMaxsForSta; //!< Per-AC CW max values to advertise to stations
770 UintAccessParamsMap m_aifsnsForSta; //!< Per-AC AIFS values to advertise to stations
771 TimeAccessParamsMap m_txopLimitsForSta; //!< Per-AC TXOP limits values to advertise to stations
772
773 Time m_fdBeaconInterval6GHz; //!< Time elapsing between a beacon and FILS Discovery (FD)
774 //!< frame or between two FD frames on 6GHz links
775 Time m_fdBeaconIntervalNon6GHz; //!< Time elapsing between a beacon and FILS Discovery (FD)
776 //!< frame or between two FD frames on 2.4GHz and 5GHz links
777 bool m_sendUnsolProbeResp; //!< send unsolicited Probe Response instead of FILS Discovery
778
779 /// store value and timestamp for each Buffer Status Report
780 struct BsrType
781 {
782 uint8_t value; //!< value of BSR
783 Time timestamp; //!< timestamp of BSR
784 };
785
786 /// Per (MAC address, TID) buffer status reports
787 std::unordered_map<WifiAddressTidPair, BsrType, WifiAddressTidHash> m_bufferStatus;
788
789 /**
790 * TracedCallback signature for association/deassociation events.
791 *
792 * @param aid the AID of the station
793 * @param address the MAC address of the station
794 */
795 typedef void (*AssociationCallback)(uint16_t aid, Mac48Address address);
796
797 TracedCallback<uint16_t /* AID */, Mac48Address> m_assocLogger; ///< association logger
798 TracedCallback<uint16_t /* AID */, Mac48Address> m_deAssocLogger; ///< deassociation logger
799};
800
801} // namespace ns3
802
803#endif /* AP_WIFI_MAC_H */
ApEmlsrManager is an abstract base class defining the API that EHT AP MLDs with EMLSR activated can u...
void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId)
Forward an association or a reassociation response packet to the DCF/EDCA.
uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const
AttributeContainerValue< UintAccessParamsPairValue, ';'> UintAccessParamsMapValue
AttributeValue type of an ACI-indexed map of access parameters of type unsigned integer.
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
void RespondToEmlOmn(MgtEmlOmn frame, const Mac48Address &sender, uint8_t linkId)
Respond to the EML Operating Mode Notification frame received from the given station on the given lin...
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
void ParseReportedStaInfo(const AssocReqRefVariant &assoc, Mac48Address from, uint8_t linkId)
Given a (Re)Association Request frame body containing a Multi-Link Element, check if a link can be se...
AttributeContainerValue< TimeAccessParamsPairValue, ';'> TimeAccessParamsMapValue
AttributeValue type of ACI-indexed map of access parameters of type Time.
void UpdateShortSlotTimeEnabled(uint8_t linkId)
Update whether short slot time should be enabled or not in the BSS corresponding to the given link.
void DoCompleteConfig() override
Allow subclasses to complete the configuration of the MAC layer components.
const std::map< uint16_t, Mac48Address > & GetStaList(uint8_t linkId) const
Get a const reference to the map of associated stations on the given link.
void DoDispose() override
Destructor implementation.
void SetBeaconInterval(Time interval)
bool ReceiveAssocRequest(const AssocReqRefVariant &assoc, const Mac48Address &from, uint8_t linkId)
Check whether the supported rate set included in the received (Re)Association Request frame is compat...
std::map< uint8_t, Mac48Address > LinkIdStaAddrMap
Map of (link ID, remote STA address) of the links to setup.
Ptr< RandomVariableStream > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
std::map< Mac48Address, EventId > m_transitionTimeoutEvents
transition timeout events running for EMLSR clients
UintAccessParamsMap m_cwMaxsForSta
Per-AC CW max values to advertise to stations.
void ScheduleFilsDiscOrUnsolProbeRespFrames(uint8_t linkId)
Schedule the transmission of FILS Discovery frames or unsolicited Probe Response frames on the given ...
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...
CapabilityInformation GetCapabilities(uint8_t linkId) const
Return the Capability information of the current AP for the given link.
Ptr< ApEmlsrManager > m_apEmlsrManager
AP EMLSR Manager.
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
Ptr< WifiMpdu > GetBufferedMmpduFor(Mac48Address address, uint8_t linkId=WIFI_LINKID_UNDEFINED) const
Check whether the AP MLD has buffered MMPDUs for the given destination because non-AP STAs operating ...
void EnqueueProbeResp(const MgtProbeResponseHeader &probeResp, Mac48Address to, uint8_t linkId)
Send a packet prepared using the given Probe Response to the given receiver on the given link.
void TxGroupAddrFramesAfterDtim(uint8_t linkId, WifiConstPsduMap psduMap, WifiTxVector, Watt_u)
This function is connected to the PhyTxPsduBegin PHY trace source when enqueuing a Beacon frame conta...
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
bool m_enableNonErpProtection
Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS.
bool HasMoreDataAfter(Ptr< const WifiMpdu > mpdu, uint8_t linkId) const
Return whether at least one additional buffered unit is present for the same STA after transmitting t...
uint8_t m_dtimPeriod
DTIM Period.
EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const
Return the EDCA Parameter Set of the current AP for the given link.
void StaSwitchingToActiveModeOrDeassociated(const Mac48Address &staAddr, uint8_t linkId)
Perform the necessary actions when a given station that is in powersave mode deassociates or switches...
HtOperation GetHtOperation(uint8_t linkId) const
Return the HT operation of the current AP for the given link.
std::optional< Mac48Address > GetMldOrLinkAddressByAid(uint16_t aid) const
Ptr< GcrManager > m_gcrManager
GCR Manager.
void UpdateShortPreambleEnabled(uint8_t linkId)
Update whether short preamble should be enabled or not in the BSS corresponding to the given link.
uint16_t GetNextAssociationId() const
void TxOk(Ptr< const WifiMpdu > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Time m_fdBeaconIntervalNon6GHz
Time elapsing between a beacon and FILS Discovery (FD) frame or between two FD frames on 2....
Tim GetTim(uint8_t linkId) const
Return the TIM for the current AP to transmit on the given link.
std::map< uint16_t, Mac48Address > m_aidToMldOrLinkAddress
Maps AIDs to MLD addresses (for MLDs) or link addresses (in case of single link devices).
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
void Enqueue(Ptr< WifiMpdu > mpdu, Mac48Address to, Mac48Address from) override
LinkIdStaAddrMap GetLinkIdStaAddrMap(MgtAssocResponseHeader &assoc, const Mac48Address &to, uint8_t linkId)
Get a map of (link ID, remote STA address) of the links to setup.
void SetAid(MgtAssocResponseHeader &assoc, const LinkIdStaAddrMap &linkIdStaAddrMap)
Set the AID field of the given Association Response frame.
void EmlOmnExchangeCompleted(const MgtEmlOmn &frame, const Mac48Address &sender, uint8_t linkId)
Take necessary actions upon completion of an exchange of EML Operating Mode Notification frames.
static Ptr< const AttributeChecker > GetTimeAccessParamsChecker()
Get a checker for the TxopLimitsForSta attribute, which can be used to deserialize an ACI-indexed map...
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Time m_beaconInterval
Beacon interval.
Ptr< GcrManager > GetGcrManager() const
MultiLinkElement GetMultiLinkElement(uint8_t linkId, WifiMacType frameType, const Mac48Address &to=Mac48Address::GetBroadcast(), const std::optional< MultiLinkElement > &mlProbeReqMle=std::nullopt)
Return the Multi-Link Element that the current AP includes in the management frames of the given type...
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
std::unordered_map< WifiAddressTidPair, BsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
PairValue< EnumValue< AcIndex >, AttributeContainerValue< TimeValue, ',', std::vector > > TimeAccessParamsPairValue
AttributeValue type of a pair (ACI, access parameters of type Time).
std::map< AcIndex, std::vector< Time > > TimeAccessParamsMap
ACI-indexed map of access parameters of type Time (TxopLimit).
DsssParameterSet GetDsssParameterSet(uint8_t linkId) const
Return the DSSS Parameter Set that we support on the given link.
friend class WifiStaticSetupHelper
Definition ap-wifi-mac.h:64
void ReceiveEmlOmn(const MgtEmlOmn &frame, const Mac48Address &sender, uint8_t linkId)
Process the EML Operating Mode Notification frame received from the given station on the given link.
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
uint8_t m_grpAddrBuIndicExp
Group Addressed BU Indication Exponent of EHT Operation IE.
Time GetBeaconInterval() const
static TypeId GetTypeId()
Get the type ID.
std::optional< ReducedNeighborReport > GetReducedNeighborReport(uint8_t linkId) const
Return the Reduced Neighbor Report (RNR) element that the current AP sends on the given link,...
Ptr< ApEmlsrManager > GetApEmlsrManager() const
Time m_fdBeaconInterval6GHz
Time elapsing between a beacon and FILS Discovery (FD) frame or between two FD frames on 6GHz links.
uint8_t GetMaxBufferStatus(Mac48Address address) const
Return the maximum among the values of the Queue Size subfield of the last QoS Data or QoS Null frame...
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
bool HasBufferedGroupcast(uint8_t linkId) const
Check whether the AP MLD has buffered frames with a destination groupcast address to be sent on the g...
ApLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
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...
std::size_t GetNStationsInPsMode(linkId_t linkId) const
Get the number of STAs associated on the given link that are in PowerSave mode.
void CheckGroupAddrFramesAfterDtimDone(uint8_t linkId, Ptr< const WifiMpdu > mpdu=nullptr) const
Check whether the AP is done with the transmission of group addressed frames after a DTIM transmitted...
uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const
Return the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the ...
EhtOperation GetEhtOperation(uint8_t linkId) const
Return the EHT operation of the current AP for the given link.
bool UseGcr(const WifiMacHeader &hdr) const
Return whether GCR is used to transmit a packet.
bool m_sendUnsolProbeResp
send unsolicited Probe Response instead of FILS Discovery
ErpInformation GetErpInformation(uint8_t linkId) const
Return the ERP information of the current AP for the given link.
void SetLinkUpCallback(Callback< void > linkUp) override
VhtOperation GetVhtOperation(uint8_t linkId) const
Return the VHT operation of the current AP for the given link.
~ApWifiMac() override
Ptr< WifiMpdu > GetBufferedDataFor(Mac48Address address, uint8_t linkId=WIFI_LINKID_UNDEFINED) const
Check whether the AP MLD has buffered (QoS) data frame(s) for the given destination because non-AP ST...
void TxFailed(WifiMacDropReason timeoutReason, Ptr< const WifiMpdu > mpdu)
The packet we sent was successfully received by the receiver (i.e.
HeOperation GetHeOperation(uint8_t linkId) const
Return the HE operation of the current AP for the given link.
bool IsGcrBaAgreementEstablishedWithAllMembers(const Mac48Address &groupAddress, uint8_t tid) const
Check if a GCR Block Ack agreement has been successfully established with all members of its group.
void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size)
Store the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the s...
TimeAccessParamsMap m_txopLimitsForSta
Per-AC TXOP limits values to advertise to stations.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
PairValue< EnumValue< AcIndex >, AttributeContainerValue< UintegerValue, ',', std::vector > > UintAccessParamsPairValue
AttributeValue type of a pair (ACI, access parameters of type unsigned integer).
Ptr< Txop > GetTxopFor(AcIndex ac) const override
Get the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed, or a null pointer,...
std::optional< MuEdcaParameterSet > GetMuEdcaParameterSet() const
Return the MU EDCA Parameter Set of the current AP, if one needs to be advertised.
void ProcessPowerManagementFlag(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Power Management bit in the Frame Control field of an MPDU successfully received on the g...
void DeaggregateAmsduAndForward(Ptr< const WifiMpdu > mpdu) override
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
bool SupportsSendFrom() const override
std::map< AcIndex, std::vector< uint64_t > > UintAccessParamsMap
ACI-indexed map of access parameters of type unsigned integer (CWmin, CWmax and AIFSN).
MgtAssocResponseHeader GetAssocResp(Mac48Address to, uint8_t linkId)
Get the Association Response frame to send on a given link.
void SetGcrManager(Ptr< GcrManager > gcrManager)
Set the GCR Manager.
Ptr< WifiMpdu > GetFilsDiscovery(uint8_t linkId) const
Get the FILS Discovery frame to send on the given link.
static Ptr< const AttributeChecker > GetUintAccessParamsChecker()
Get a checker for the CwMinsForSta, CwMaxsForSta and AifsnsForSta attributes, which can be used to de...
void DoInitialize() override
Initialize() implementation.
std::optional< uint8_t > IsAssociated(const Mac48Address &address) const
Get the ID of a link (if any) that has been setup with the station having the given MAC address.
void SendOneBeacon(uint8_t linkId)
Forward a beacon packet to the beacon special DCF for transmission on the given link.
void SetApEmlsrManager(Ptr< ApEmlsrManager > apEmlsrManager)
Set the AP EMLSR Manager.
bool GetUseNonErpProtection(uint8_t linkId) const
Return whether protection for non-ERP stations is used in the BSS corresponding to the given link.
MgtProbeResponseHeader GetProbeRespProfile(uint8_t linkId) const
Get Probe Response Per-STA Profile for the given link.
UintAccessParamsMap m_cwMinsForSta
Per-AC CW min values to advertise to stations.
UintAccessParamsMap m_aifsnsForSta
Per-AC AIFS values to advertise to stations.
MgtProbeResponseHeader GetProbeResp(uint8_t linkId, const std::optional< MultiLinkElement > &reqMle)
Get Probe Response based on the given Probe Request Multi-link Element (if any).
void StaSwitchingToPsMode(const Mac48Address &staAddr, uint8_t linkId)
Perform the necessary actions when a given station that is in active mode switches to powersave mode.
AllSupportedRates GetSupportedRates(uint8_t linkId) const
Return an instance of SupportedRates that contains all rates that we support for the given link (incl...
A container for one type of attribute.
Callback template class.
Definition callback.h:428
The DSSS Parameter Set.
The EDCA Parameter Set.
EHT Operation Information Element.
The ErpInformation Information Element.
An identifier for simulation events.
Definition event-id.h:45
GcrManager is a base class defining the API to handle 802.11aa GCR.
Definition gcr-manager.h:49
The HE Operation Information Element.
The HT Operation Information Element.
an EUI-48 address
static Mac48Address GetBroadcast()
Implement the header for management frames of type association and reassociation response.
Implement the header for Action frames of type EML Operating Mode Notification.
Implement the header for management frames of type probe response.
The MU EDCA Parameter Set.
AttributeValue implementation for Pair.
Definition pair.h:54
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
The Reduced Neighbor Report element.
The Traffic Indication Map Information Element.
Definition tim.h:29
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
AttributeValue implementation for Time.
Definition nstime.h:1375
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:50
Hold an unsigned integer type.
Definition uinteger.h:34
The uniform distribution Random Number Generator (RNG).
The VHT Operation Information Element.
Implements the IEEE 802.11 MAC header.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMacDropReason
The reason why an MPDU was dropped.
Definition wifi-mac.h:71
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:64
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiMacType
Combination of valid MAC header type/subtype.
static constexpr uint8_t WIFI_LINKID_UNDEFINED
Invalid link identifier.
Definition wifi-utils.h:298
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
uint8_t linkId_t
IEEE 802.11be D7.0 Figure 9-207e—Link ID Info field format.
Definition wifi-utils.h:74
std::variant< std::reference_wrapper< MgtAssocRequestHeader >, std::reference_wrapper< MgtReassocRequestHeader > > AssocReqRefVariant
variant holding a reference to a (Re)Association Request
Definition ap-wifi-mac.h:47
double Watt_u
Watt weak type.
Definition wifi-units.h:25
Struct containing all supported rates.
store value and timestamp for each Buffer Status Report
Time timestamp
timestamp of BSR
uint8_t value
value of BSR