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 "wifi-mac-header.h"
15#include "wifi-mac.h"
16
17#include "ns3/attribute-container.h"
18#include "ns3/enum.h"
19#include "ns3/pair.h"
20
21#include <unordered_map>
22#include <variant>
23
24namespace ns3
25{
26
27struct AllSupportedRates;
28class CapabilityInformation;
29class DsssParameterSet;
30class ErpInformation;
31class EdcaParameterSet;
32class MuEdcaParameterSet;
33class ReducedNeighborReport;
34class HtOperation;
35class VhtOperation;
36class HeOperation;
37class EhtOperation;
38class CfParameterSet;
39class UniformRandomVariable;
40class MgtEmlOmn;
41class ApEmlsrManager;
42class GcrManager;
43
44/// variant holding a reference to a (Re)Association Request
45using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
46 std::reference_wrapper<MgtReassocRequestHeader>>;
47
48/**
49 * @brief Wi-Fi AP state machine
50 * @ingroup wifi
51 *
52 * Handle association, dis-association and authentication,
53 * of STAs within an infrastructure BSS. By default, beacons are
54 * sent with PIFS access, zero backoff, and are generated roughly
55 * every 102.4 ms by default (configurable by an attribute) and
56 * with some jitter to de-synchronize beacon transmissions in
57 * multi-BSS scenarios.
58 */
59class ApWifiMac : public WifiMac
60{
61 public:
62 /**
63 * @brief Get the type ID.
64 * @return the object TypeId
65 */
66 static TypeId GetTypeId();
67
68 ApWifiMac();
69 ~ApWifiMac() override;
70
71 void SetLinkUpCallback(Callback<void> linkUp) override;
72 bool CanForwardPacketsTo(Mac48Address to) const override;
73 bool SupportsSendFrom() const override;
74 Ptr<WifiMacQueue> GetTxopQueue(AcIndex ac) const override;
75 int64_t AssignStreams(int64_t stream) override;
76
77 /**
78 * Set the AP EMLSR Manager.
79 *
80 * @param apEmlsrManager the AP EMLSR Manager
81 */
82 void SetApEmlsrManager(Ptr<ApEmlsrManager> apEmlsrManager);
83
84 /**
85 * @return the AP EMLSR Manager
86 */
88
89 /**
90 * Set the GCR Manager.
91 *
92 * @param gcrManager the GCR Manager
93 */
94 void SetGcrManager(Ptr<GcrManager> gcrManager);
95
96 /**
97 * @return the GCR Manager
98 */
100
101 /**
102 * @param interval the interval between two beacon transmissions.
103 */
104 void SetBeaconInterval(Time interval);
105 /**
106 * @return the interval between two beacon transmissions.
107 */
108 Time GetBeaconInterval() const;
109
110 /**
111 * Get a const reference to the map of associated stations on the given link.
112 * Each station is specified by an (association ID, MAC address) pair. Make sure
113 * not to use the returned reference after that this object has been deallocated.
114 *
115 * @param linkId the ID of the given link
116 * @return a const reference to the map of associated stations
117 */
118 const std::map<uint16_t, Mac48Address>& GetStaList(uint8_t linkId) const;
119 /**
120 * @param addr the address of the associated station
121 * @param linkId the ID of the link on which the station is associated
122 * @return the Association ID allocated by the AP to the station, SU_STA_ID if unallocated
123 */
124 uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const;
125
126 /**
127 * Get the ID of a link (if any) that has been setup with the station having the given MAC
128 * address. The address can be either a link address or an MLD address. In the former case,
129 * the returned ID is the ID of the link connecting the AP to the STA with the given address.
130 *
131 * @param address the given MAC address
132 * @return the ID of a link (if any) that has been setup with the given station
133 */
134 std::optional<uint8_t> IsAssociated(const Mac48Address& address) const;
135
136 /**
137 * @param aid the given AID
138 * @return the MLD address (in case of MLD) or link address (in case of single link device)
139 * of the STA having the given AID, if any
140 */
141 std::optional<Mac48Address> GetMldOrLinkAddressByAid(uint16_t aid) const;
142
143 /**
144 * Return the value of the Queue Size subfield of the last QoS Data or QoS Null
145 * frame received from the station with the given MAC address and belonging to
146 * the given TID.
147 *
148 * The Queue Size value is the total size, rounded up to the nearest multiple
149 * of 256 octets and expressed in units of 256 octets, of all MSDUs and A-MSDUs
150 * buffered at the STA (excluding the MSDU or A-MSDU of the present QoS Data frame).
151 * A queue size value of 254 is used for all sizes greater than 64 768 octets.
152 * A queue size value of 255 is used to indicate an unspecified or unknown size.
153 * See Section 9.2.4.5.6 of 802.11-2016
154 *
155 * @param tid the given TID
156 * @param address the given MAC address
157 * @return the value of the Queue Size subfield
158 */
159 uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const;
160 /**
161 * Store the value of the Queue Size subfield of the last QoS Data or QoS Null
162 * frame received from the station with the given MAC address and belonging to
163 * the given TID.
164 *
165 * @param tid the given TID
166 * @param address the given MAC address
167 * @param size the value of the Queue Size subfield
168 */
169 void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size);
170 /**
171 * Return the maximum among the values of the Queue Size subfield of the last
172 * QoS Data or QoS Null frames received from the station with the given MAC address
173 * and belonging to any TID.
174 *
175 * @param address the given MAC address
176 * @return the maximum among the values of the Queue Size subfields
177 */
178 uint8_t GetMaxBufferStatus(Mac48Address address) const;
179
180 /**
181 * Return whether GCR is used to transmit a packet.
182 *
183 * @param hdr the header of the packet to transmit
184 * @return true if a GCR manager is set and the packet is a groupcast QoS data, false otherwise
185 */
186 bool UseGcr(const WifiMacHeader& hdr) const;
187
188 /**
189 * Check if a GCR Block Ack agreement has been successfully established with all members of
190 * its group.
191 *
192 * @param groupAddress the GCR group address.
193 * @param tid the traffic ID.
194 * @return true if a GCR Block Ack agreement has been successfully established with all members
195 * of its group, false otherwise.
196 */
198 uint8_t tid) const;
199
200 /// ACI-indexed map of access parameters of type unsigned integer (CWmin, CWmax and AIFSN)
201 using UintAccessParamsMap = std::map<AcIndex, std::vector<uint64_t>>;
202
203 /// ACI-indexed map of access parameters of type Time (TxopLimit)
204 using TimeAccessParamsMap = std::map<AcIndex, std::vector<Time>>;
205
206 /// AttributeValue type of a pair (ACI, access parameters of type unsigned integer)
209
210 /// AttributeValue type of a pair (ACI, access parameters of type Time)
213
214 /// AttributeValue type of an ACI-indexed map of access parameters of type unsigned integer
216
217 /// AttributeValue type of ACI-indexed map of access parameters of type Time
219
220 /**
221 * Get a checker for the CwMinsForSta, CwMaxsForSta and AifsnsForSta attributes, which can
222 * be used to deserialize an ACI-indexed map of access parameters of type unsigned integer
223 * (CWmin, CWmax and AIFSN) from a string:
224 *
225 * @code
226 * ApWifiMac::UintAccessParamsMapValue value;
227 * value.DeserializeFromString("BE 31,31; VO 15,15",
228 * ApWifiMac::GetUintAccessParamsChecker<uint32_t>());
229 * auto map = value.Get();
230 * @endcode
231 *
232 * The type of \p map is ApWifiMac::UintAccessParamsMapValue::result_type, which is
233 * std::list<std::pair<AcIndex, std::vector<uint64_t>>>.
234 *
235 * @tparam T \explicit the type of the unsigned integer access parameter
236 * @return a checker for the CwMinsForSta, CwMaxsForSta and AifsnsForSta attributes
237 */
238 template <class T>
240
241 /**
242 * Get a checker for the TxopLimitsForSta attribute, which can be used to deserialize an
243 * ACI-indexed map of access parameters of type Time (TxopLimit) from a string:
244 *
245 * @code
246 * ApWifiMac::TimeAccessParamsMapValue value;
247 * value.DeserializeFromString("BE 3200us; VO 3232us",
248 * ApWifiMac::GetTimeAccessParamsChecker());
249 * auto map = value.Get();
250 * @endcode
251 *
252 * The type of \p map is ApWifiMac::TimeAccessParamsMapValue::result_type, which is
253 * std::list<std::pair<AcIndex, std::vector<Time>>>.
254 *
255 * @return a checker for the TxopLimitsForSta attribute
256 */
258
259 protected:
260 /**
261 * Structure holding information specific to a single link. Here, the meaning of
262 * "link" is that of the 11be amendment which introduced multi-link devices. For
263 * previous amendments, only one link can be created.
264 */
266 {
267 /// Destructor (a virtual method is needed to make this struct polymorphic)
268 ~ApLinkEntity() override;
269
270 EventId beaconEvent; //!< Event to generate one beacon
271 std::map<uint16_t, Mac48Address> staList; //!< Map of all stations currently associated
272 //!< to the AP with their association ID
273 uint16_t numNonHtStations{0}; //!< Number of non-HT stations currently associated to the AP
275 0}; //!< Number of non-ERP stations currently associated to the AP
277 false}; //!< Flag whether short slot time is enabled within the BSS
278 bool shortPreambleEnabled{false}; //!< Flag whether short preamble is enabled in the BSS
279 };
280
281 /**
282 * Get a reference to the link associated with the given ID.
283 *
284 * @param linkId the given link ID
285 * @return a reference to the link associated with the given ID
286 */
287 ApLinkEntity& GetLink(uint8_t linkId) const;
288
289 std::map<uint16_t, Mac48Address>
290 m_aidToMldOrLinkAddress; //!< Maps AIDs to MLD addresses (for MLDs) or link addresses (in
291 //!< case of single link devices)
292
293 private:
294 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
295 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
296 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
297 void DoCompleteConfig() override;
298 void Enqueue(Ptr<WifiMpdu> mpdu, Mac48Address to, Mac48Address from) override;
299
300 /**
301 * Check whether the supported rate set included in the received (Re)Association
302 * Request frame is compatible with our Basic Rate Set. If so, record all the station's
303 * supported modes in its associated WifiRemoteStation and return true.
304 * Otherwise, return false.
305 *
306 * @param assoc the frame body of the received (Re)Association Request
307 * @param from the Transmitter Address field of the frame
308 * @param linkId the ID of the link on which the frame was received
309 * @return true if the (Re)Association request can be accepted, false otherwise
310 */
311 bool ReceiveAssocRequest(const AssocReqRefVariant& assoc,
312 const Mac48Address& from,
313 uint8_t linkId);
314
315 /**
316 * Given a (Re)Association Request frame body containing a Multi-Link Element,
317 * check if a link can be setup with each of the reported stations (STA MAC address
318 * and a (Re)Association Request frame body must be present, the Link ID identifies
319 * a valid link other than the one the frame was received on and the supported
320 * rates are compatible with our basic rate set).
321 *
322 * @param assoc the frame body of the received (Re)Association Request
323 * @param from the Transmitter Address field of the frame
324 * @param linkId the ID of the link on which the frame was received
325 */
326 void ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address from, uint8_t linkId);
327
328 /**
329 * Take necessary actions upon receiving the given EML Operating Mode Notification frame
330 * from the given station on the given link.
331 *
332 * @param frame the received EML Operating Mode Notification frame
333 * @param sender the MAC address of the sender of the frame
334 * @param linkId the ID of the link over which the frame was received
335 */
336 void ReceiveEmlOmn(MgtEmlOmn& frame, const Mac48Address& sender, uint8_t linkId);
337
338 /**
339 * The packet we sent was successfully received by the receiver
340 * (i.e. we received an Ack from the receiver). If the packet
341 * was an association response to the receiver, we record that
342 * the receiver is now associated with us.
343 *
344 * @param mpdu the MPDU that we successfully sent
345 */
346 void TxOk(Ptr<const WifiMpdu> mpdu);
347 /**
348 * The packet we sent was successfully received by the receiver
349 * (i.e. we did not receive an Ack from the receiver). If the packet
350 * was an association response to the receiver, we record that
351 * the receiver is not associated with us yet.
352 *
353 * @param timeoutReason the reason why the TX timer was started (\see WifiTxTimer::Reason)
354 * @param mpdu the MPDU that we failed to sent
355 */
356 void TxFailed(WifiMacDropReason timeoutReason, Ptr<const WifiMpdu> mpdu);
357
358 /**
359 * This method is called to de-aggregate an A-MSDU and forward the
360 * constituent packets up the stack. We override the WifiMac version
361 * here because, as an AP, we also need to think about redistributing
362 * to other associated STAs.
363 *
364 * @param mpdu the MPDU containing the A-MSDU.
365 */
367
368 /**
369 * Get Probe Response Per-STA Profile for the given link.
370 *
371 * @param linkId the ID of the given link
372 * @return the Probe Response header
373 */
374 MgtProbeResponseHeader GetProbeRespProfile(uint8_t linkId) const;
375
376 /**
377 * Get Probe Response based on the given Probe Request Multi-link Element (if any)
378 *
379 * @param linkId the ID of link the Probe Response is to be sent
380 * @param reqMle Probe Request Multi-link Element
381 * @return Probe Response header
382 */
384 const std::optional<MultiLinkElement>& reqMle);
385
386 /**
387 * Send a packet prepared using the given Probe Response to the given receiver on the given
388 * link.
389 *
390 * @param probeResp the Probe Response header
391 * @param to the address of the STA we are sending a probe response to
392 * @param linkId the ID of the given link
393 */
394 void EnqueueProbeResp(const MgtProbeResponseHeader& probeResp, Mac48Address to, uint8_t linkId);
395
396 /**
397 * Get the Association Response frame to send on a given link. The returned frame
398 * never includes a Multi-Link Element.
399 *
400 * @param to the address of the STA we are sending an association response to
401 * @param linkId the ID of the given link
402 * @return the Association Response frame
403 */
405 /// Map of (link ID, remote STA address) of the links to setup
406 using LinkIdStaAddrMap = std::map<uint8_t, Mac48Address>;
407 /**
408 * Set the AID field of the given Association Response frame. In case of
409 * multi-link setup, the selected AID value must be assigned to all the STAs
410 * corresponding to the setup links. The AID value is selected among the AID
411 * values that are possibly already assigned to the STAs affiliated with the
412 * non-AP MLD we are associating with. If no STA has an assigned AID value,
413 * a new AID value is selected.
414 *
415 * @param assoc the given Association Response frame
416 * @param linkIdStaAddrMap a map of (link ID, remote STA address) of the links to setup
417 */
418 void SetAid(MgtAssocResponseHeader& assoc, const LinkIdStaAddrMap& linkIdStaAddrMap);
419 /**
420 * Get a map of (link ID, remote STA address) of the links to setup. Information
421 * is taken from the given Association Response that is sent over the given link
422 * to the given station.
423 *
424 * @param assoc the given Association Response frame
425 * @param to the Receiver Address (RA) of the Association Response frame
426 * @param linkId the ID of the link on which the Association Response frame is sent
427 * @return a map of (link ID, remote STA address) of the links to setup
428 */
430 const Mac48Address& to,
431 uint8_t linkId);
432 /**
433 * Forward an association or a reassociation response packet to the DCF/EDCA.
434 *
435 * @param to the address of the STA we are sending an association response to
436 * @param isReassoc indicates whether it is a reassociation response
437 * @param linkId the ID of the link on which the association response must be sent
438 */
439 void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId);
440 /**
441 * Forward a beacon packet to the beacon special DCF for transmission
442 * on the given link.
443 *
444 * @param linkId the ID of the given link
445 */
446 void SendOneBeacon(uint8_t linkId);
447
448 /**
449 * Get the FILS Discovery frame to send on the given link.
450 *
451 * @param linkId the ID of the given link
452 * @return the FILS Discovery frame to send on the given link
453 */
454 Ptr<WifiMpdu> GetFilsDiscovery(uint8_t linkId) const;
455
456 /**
457 * Schedule the transmission of FILS Discovery frames or unsolicited Probe Response frames
458 * on the given link
459 *
460 * @param linkId the ID of the given link
461 */
462 void ScheduleFilsDiscOrUnsolProbeRespFrames(uint8_t linkId);
463
464 /**
465 * Process the Power Management bit in the Frame Control field of an MPDU
466 * successfully received on the given link.
467 *
468 * @param mpdu the successfully received MPDU
469 * @param linkId the ID of the given link
470 */
471 void ProcessPowerManagementFlag(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
472 /**
473 * Perform the necessary actions when a given station switches from active mode
474 * to powersave mode.
475 *
476 * @param staAddr the MAC address of the given station
477 * @param linkId the ID of the link on which the given station is operating
478 */
479 void StaSwitchingToPsMode(const Mac48Address& staAddr, uint8_t linkId);
480 /**
481 * Perform the necessary actions when a given station deassociates or switches
482 * from powersave mode to active mode.
483 *
484 * @param staAddr the MAC address of the given station
485 * @param linkId the ID of the link on which the given station is operating
486 */
487 void StaSwitchingToActiveModeOrDeassociated(const Mac48Address& staAddr, uint8_t linkId);
488
489 /**
490 * Return the Capability information of the current AP for the given link.
491 *
492 * @param linkId the ID of the given link
493 * @return the Capability information that we support
494 */
495 CapabilityInformation GetCapabilities(uint8_t linkId) const;
496 /**
497 * Return the ERP information of the current AP for the given link.
498 *
499 * @param linkId the ID of the given link
500 * @return the ERP information that we support for the given link
501 */
502 ErpInformation GetErpInformation(uint8_t linkId) const;
503 /**
504 * Return the EDCA Parameter Set of the current AP for the given link.
505 *
506 * @param linkId the ID of the given link
507 * @return the EDCA Parameter Set that we support for the given link
508 */
509 EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const;
510 /**
511 * Return the MU EDCA Parameter Set of the current AP, if one needs to be advertised
512 *
513 * @return the MU EDCA Parameter Set that needs to be advertised (if any)
514 */
515 std::optional<MuEdcaParameterSet> GetMuEdcaParameterSet() const;
516 /**
517 * Return the Reduced Neighbor Report (RNR) element that the current AP sends
518 * on the given link, if one needs to be advertised.
519 *
520 * @param linkId the ID of the link to send the RNR element onto
521 * @return the Reduced Neighbor Report element
522 */
523 std::optional<ReducedNeighborReport> GetReducedNeighborReport(uint8_t linkId) const;
524
525 /**
526 * Return the Multi-Link Element that the current AP includes in the management
527 * frames of the given type it transmits on the given link.
528 *
529 * @param linkId the ID of the link to send the Multi-Link Element onto
530 * @param frameType the type of the frame containing the Multi-Link Element
531 * @param to the Receiver Address of the frame containing the Multi-Link Element
532 * @param mlProbeReqMle the Multi-Link Element included in the multi-link probe request, in
533 * case the Multi-Link Element is requested for the response to such a
534 * frame
535 * @return the Multi-Link Element
536 */
538 uint8_t linkId,
539 WifiMacType frameType,
541 const std::optional<MultiLinkElement>& mlProbeReqMle = std::nullopt);
542
543 /**
544 * Return the HT operation of the current AP for the given link.
545 *
546 * @param linkId the ID of the given link
547 * @return the HT operation that we support
548 */
549 HtOperation GetHtOperation(uint8_t linkId) const;
550 /**
551 * Return the VHT operation of the current AP for the given link.
552 *
553 * @param linkId the ID of the given link
554 * @return the VHT operation that we support
555 */
556 VhtOperation GetVhtOperation(uint8_t linkId) const;
557 /**
558 * Return the HE operation of the current AP for the given link.
559 *
560 * @param linkId the ID of the given link
561 * @return the HE operation that we support
562 */
563 HeOperation GetHeOperation(uint8_t linkId) const;
564 /**
565 * Return the EHT operation of the current AP for the given link.
566 *
567 * @param linkId the ID of the given link
568 * @return the EHT operation that we support
569 */
570 EhtOperation GetEhtOperation(uint8_t linkId) const;
571 /**
572 * Return an instance of SupportedRates that contains all rates that we support
573 * for the given link (including HT rates).
574 *
575 * @param linkId the ID of the given link
576 * @return all rates that we support
577 */
578 AllSupportedRates GetSupportedRates(uint8_t linkId) const;
579 /**
580 * Return the DSSS Parameter Set that we support on the given link
581 *
582 * @param linkId the ID of the given link
583 * @return the DSSS Parameter Set that we support on the given link
584 */
585 DsssParameterSet GetDsssParameterSet(uint8_t linkId) const;
586 /**
587 * Enable or disable beacon generation of the AP.
588 *
589 * @param enable enable or disable beacon generation
590 */
591 void SetBeaconGeneration(bool enable);
592
593 /**
594 * Update whether short slot time should be enabled or not in the BSS
595 * corresponding to the given link.
596 * Typically, short slot time is enabled only when there is no non-ERP station
597 * associated to the AP, and that short slot time is supported by the AP and by all
598 * other ERP stations that are associated to the AP. Otherwise, it is disabled.
599 *
600 * @param linkId the ID of the given link
601 */
602 void UpdateShortSlotTimeEnabled(uint8_t linkId);
603 /**
604 * Update whether short preamble should be enabled or not in the BSS
605 * corresponding to the given link.
606 * Typically, short preamble is enabled only when the AP and all associated
607 * stations support short PHY preamble. Otherwise, it is disabled.
608 *
609 * @param linkId the ID of the given link
610 */
611 void UpdateShortPreambleEnabled(uint8_t linkId);
612
613 /**
614 * Return whether protection for non-ERP stations is used in the BSS
615 * corresponding to the given link.
616 *
617 * @param linkId the ID of the given link
618 * @return true if protection for non-ERP stations is used in the BSS,
619 * false otherwise
620 */
621 bool GetUseNonErpProtection(uint8_t linkId) const;
622
623 void DoDispose() override;
624 void DoInitialize() override;
625
626 /**
627 * @return the next Association ID to be allocated by the AP
628 */
629 uint16_t GetNextAssociationId() const;
630
631 Ptr<Txop> m_beaconTxop; //!< Dedicated Txop for beacons
632 bool m_enableBeaconGeneration; //!< Flag whether beacons are being generated
633 Time m_beaconInterval; //!< Beacon interval
635 m_beaconJitter; //!< UniformRandomVariable used to randomize the time of the first beacon
636 bool m_enableBeaconJitter; //!< Flag whether the first beacon should be generated at random time
637 bool m_enableNonErpProtection; //!< Flag whether protection mechanism is used or not when
638 //!< non-ERP STAs are present within the BSS
639 Time m_bsrLifetime; //!< Lifetime of Buffer Status Reports
640 /// transition timeout events running for EMLSR clients
641 std::map<Mac48Address, EventId> m_transitionTimeoutEvents;
644
645 UintAccessParamsMap m_cwMinsForSta; //!< Per-AC CW min values to advertise to stations
646 UintAccessParamsMap m_cwMaxsForSta; //!< Per-AC CW max values to advertise to stations
647 UintAccessParamsMap m_aifsnsForSta; //!< Per-AC AIFS values to advertise to stations
648 TimeAccessParamsMap m_txopLimitsForSta; //!< Per-AC TXOP limits values to advertise to stations
649
650 Time m_fdBeaconInterval6GHz; //!< Time elapsing between a beacon and FILS Discovery (FD)
651 //!< frame or between two FD frames on 6GHz links
652 Time m_fdBeaconIntervalNon6GHz; //!< Time elapsing between a beacon and FILS Discovery (FD)
653 //!< frame or between two FD frames on 2.4GHz and 5GHz links
654 bool m_sendUnsolProbeResp; //!< send unsolicited Probe Response instead of FILS Discovery
655
656 /// store value and timestamp for each Buffer Status Report
657 struct BsrType
658 {
659 uint8_t value; //!< value of BSR
660 Time timestamp; //!< timestamp of BSR
661 };
662
663 /// Per (MAC address, TID) buffer status reports
664 std::unordered_map<WifiAddressTidPair, BsrType, WifiAddressTidHash> m_bufferStatus;
665
666 /**
667 * TracedCallback signature for association/deassociation events.
668 *
669 * @param aid the AID of the station
670 * @param address the MAC address of the station
671 */
672 typedef void (*AssociationCallback)(uint16_t aid, Mac48Address address);
673
674 TracedCallback<uint16_t /* AID */, Mac48Address> m_assocLogger; ///< association logger
675 TracedCallback<uint16_t /* AID */, Mac48Address> m_deAssocLogger; ///< deassociation logger
676};
677
678} // namespace ns3
679
680#endif /* AP_WIFI_MAC_H */
Wi-Fi AP state machine.
Definition ap-wifi-mac.h:60
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
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
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...
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.
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.
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
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.
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.
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 deassociates or switches from powersave mode to ac...
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....
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.
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.
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
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,...
void ReceiveEmlOmn(MgtEmlOmn &frame, const Mac48Address &sender, uint8_t linkId)
Take necessary actions upon receiving the given EML Operating Mode Notification frame from the given ...
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.
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...
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
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)
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.
Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const override
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
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 switches from active mode 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:422
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
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.
AttributeValue implementation for Pair.
Definition pair.h:54
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
AttributeValue implementation for Time.
Definition nstime.h:1431
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
Hold an unsigned integer type.
Definition uinteger.h:34
The VHT Operation Information Element.
Implements the IEEE 802.11 MAC header.
base class for all MAC-level wifi objects.
Definition wifi-mac.h:90
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:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiMacType
Combination of valid MAC header type/subtype.
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:45
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