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