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