A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef WIFI_MAC_H
21#define WIFI_MAC_H
22
23#include "qos-utils.h"
24#include "ssid.h"
27#include "wifi-standards.h"
28
29#include "ns3/uniform-random-bit-generator.h"
30
31#include <functional>
32#include <list>
33#include <map>
34#include <memory>
35#include <optional>
36#include <set>
37#include <unordered_map>
38#include <vector>
39
40namespace ns3
41{
42
43class Txop;
44class WifiNetDevice;
45class QosTxop;
46class WifiPsdu;
47class MacRxMiddle;
48class MacTxMiddle;
49class WifiMacQueue;
50class WifiMpdu;
51class HtConfiguration;
52class VhtConfiguration;
53class HeConfiguration;
54class EhtConfiguration;
55class FrameExchangeManager;
56class ChannelAccessManager;
57class ExtendedCapabilities;
58class OriginatorBlockAckAgreement;
59class RecipientBlockAckAgreement;
60class UniformRandomVariable;
61
62/**
63 * \ingroup wifi
64 * Enumeration for type of WiFi station
65 */
67{
72 OCB
73};
74
75/**
76 * \ingroup wifi
77 * \brief The reason why an MPDU was dropped
78 */
79enum WifiMacDropReason : uint8_t
80{
85};
86
87typedef std::unordered_map<uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */> WifiPsduMap;
88
89/**
90 * \brief base class for all MAC-level wifi objects.
91 * \ingroup wifi
92 *
93 * This class encapsulates all the low-level MAC functionality
94 * DCA, EDCA, etc) and all the high-level MAC functionality
95 * (association/disassociation state machines).
96 *
97 */
98class WifiMac : public Object
99{
100 public:
101 /**
102 * \brief Get the type ID.
103 * \return the object TypeId
104 */
105 static TypeId GetTypeId();
106
107 WifiMac();
108 ~WifiMac() override;
109
110 // Delete copy constructor and assignment operator to avoid misuse
111 WifiMac(const WifiMac&) = delete;
112 WifiMac& operator=(const WifiMac&) = delete;
113
114 /**
115 * Assign a fixed random variable stream number to the random variables
116 * used by this model. Return the number of streams (possibly zero) that
117 * have been assigned.
118 *
119 * \param stream first stream index to use
120 *
121 * \return the number of stream indices assigned by this model
122 */
123 virtual int64_t AssignStreams(int64_t stream);
124
125 /**
126 * Sets the device this PHY is associated with.
127 *
128 * \param device the device this PHY is associated with
129 */
130 void SetDevice(const Ptr<WifiNetDevice> device);
131 /**
132 * Return the device this PHY is associated with
133 *
134 * \return the device this PHY is associated with
135 */
137
138 /**
139 * Get the Frame Exchange Manager associated with the given link
140 *
141 * \param linkId the ID of the given link
142 * \return the Frame Exchange Manager
143 */
145
146 /**
147 * \param feManagers the frame exchange managers attached to this MAC.
148 */
149 void SetFrameExchangeManagers(const std::vector<Ptr<FrameExchangeManager>>& feManagers);
150
151 /**
152 * Get the Channel Access Manager associated with the given link
153 *
154 * \param linkId the ID of the given link
155 * \return the Channel Access Manager
156 */
158
159 /**
160 * \param caManagers the channel access managers attached to this MAC.
161 */
162 void SetChannelAccessManagers(const std::vector<Ptr<ChannelAccessManager>>& caManagers);
163
164 /**
165 * Get the number of links (can be greater than 1 for 11be devices only).
166 *
167 * \return the number of links used by this MAC
168 */
169 uint8_t GetNLinks() const;
170
171 /**
172 * \return the set of link IDs in use by this device
173 */
174 const std::set<uint8_t>& GetLinkIds() const;
175
176 /**
177 * Get the ID of the link having the given MAC address, if any.
178 *
179 * \param address the given MAC address
180 * \return the ID of the link having the given MAC address, if any
181 */
182 virtual std::optional<uint8_t> GetLinkIdByAddress(const Mac48Address& address) const;
183
184 /**
185 * Get the ID of the link (if any) on which the given PHY is operating.
186 *
187 * \param phy the given PHY
188 * \return the ID of the link (if any) on which the given PHY is operating
189 */
190 std::optional<uint8_t> GetLinkForPhy(Ptr<const WifiPhy> phy) const;
191
192 /**
193 * Get the ID of the link (if any) on which the given PHY is operating.
194 *
195 * \param phyId the index of the given PHY in the vector of PHYs held by WifiNetDevice
196 * \return the ID of the link (if any) on which the given PHY is operating
197 */
198 std::optional<uint8_t> GetLinkForPhy(std::size_t phyId) const;
199
200 /**
201 * Indicate if a given link is on the 6 GHz band.
202 *
203 * \param linkId the ID of the given link
204 * \return whether the given link is on the 6 GHz band
205 */
206 bool Is6GhzBand(uint8_t linkId) const;
207
208 /**
209 * \param remoteAddr the (MLD or link) address of a remote device
210 * \return the MLD address of the remote device having the given (MLD or link) address, if
211 * the remote device is an MLD.
212 */
213 std::optional<Mac48Address> GetMldAddress(const Mac48Address& remoteAddr) const;
214
215 /**
216 * Get the local MAC address used to communicate with a remote STA. Specifically:
217 * - If the given remote address is the address of a STA affiliated with a remote MLD
218 * and operating on a setup link, the address of the local STA operating on such a link
219 * is returned.
220 * - If the given remote address is the MLD address of a remote MLD (with which some link
221 * has been setup), the MLD address of this device is returned.
222 * - If this is a single link device, the unique MAC address of this device is returned.
223 * - Otherwise, return the MAC address of the affiliated STA (which must exists) that
224 * can be used to communicate with the remote device.
225 *
226 * \param remoteAddr the MAC address of the remote device
227 * \return the local MAC address used to communicate with the remote device
228 */
229 Mac48Address GetLocalAddress(const Mac48Address& remoteAddr) const;
230
231 /**
232 * Accessor for the Txop object
233 *
234 * \return a smart pointer to Txop
235 */
236 Ptr<Txop> GetTxop() const;
237 /**
238 * Accessor for a specified EDCA object
239 *
240 * \param ac the Access Category
241 * \return a smart pointer to a QosTxop
242 */
244 /**
245 * Accessor for a specified EDCA object
246 *
247 * \param tid the Traffic ID
248 * \return a smart pointer to a QosTxop
249 */
250 Ptr<QosTxop> GetQosTxop(uint8_t tid) const;
251 /**
252 * Get the wifi MAC queue of the (Qos)Txop associated with the given AC,
253 * if such (Qos)Txop is installed, or a null pointer, otherwise.
254 *
255 * \param ac the given Access Category
256 * \return the wifi MAC queue of the (Qos)Txop associated with the given AC,
257 * if such (Qos)Txop is installed, or a null pointer, otherwise
258 */
259 virtual Ptr<WifiMacQueue> GetTxopQueue(AcIndex ac) const;
260
261 /**
262 * Check if the MAC has frames to transmit over the given link
263 * \param linkId the ID of the given link.
264 * \return whether the MAC has frames to transmit.
265 */
266 virtual bool HasFramesToTransmit(uint8_t linkId);
267
268 /**
269 * Set the wifi MAC queue scheduler
270 *
271 * \param scheduler the wifi MAC queue scheduler
272 */
273 virtual void SetMacQueueScheduler(Ptr<WifiMacQueueScheduler> scheduler);
274 /**
275 * Get the wifi MAC queue scheduler
276 *
277 * \return the wifi MAC queue scheduler
278 */
280
281 /**
282 * This method is invoked by a subclass to specify what type of
283 * station it is implementing. This is something that the channel
284 * access functions need to know.
285 *
286 * \param type the type of station.
287 */
289 /**
290 * Return the type of station.
291 *
292 * \return the type of station.
293 */
295
296 /**
297 * \param ssid the current SSID of this MAC layer.
298 */
299 void SetSsid(Ssid ssid);
300 /**
301 * \brief Sets the interface in promiscuous mode.
302 *
303 * Enables promiscuous mode on the interface. Note that any further
304 * filtering on the incoming frame path may affect the overall
305 * behavior.
306 */
307 void SetPromisc();
308 /**
309 * Enable or disable CTS-to-self feature.
310 *
311 * \param enable true if CTS-to-self is to be supported,
312 * false otherwise
313 */
314 void SetCtsToSelfSupported(bool enable);
315
316 /**
317 * \return the MAC address associated to this MAC layer.
318 */
319 Mac48Address GetAddress() const;
320 /**
321 * \return the SSID which this MAC layer is going to try to stay in.
322 */
323 Ssid GetSsid() const;
324 /**
325 * \param address the current address of this MAC layer.
326 */
327 virtual void SetAddress(Mac48Address address);
328 /**
329 * \return the BSSID of the network the given link belongs to.
330 * \param linkId the ID of the given link
331 */
332 Mac48Address GetBssid(uint8_t linkId) const;
333 /**
334 * \param bssid the BSSID of the network that the given link belongs to.
335 * \param linkId the ID of the given link
336 */
337 void SetBssid(Mac48Address bssid, uint8_t linkId);
338
339 /**
340 * Block the transmission on the given links of all unicast frames addressed to
341 * the station with the given address for the given reason. The given MAC address
342 * must be the MLD address in case the addressed device is multi-link.
343 *
344 * \param reason the reason for blocking transmissions
345 * \param address the MAC address of the given device
346 * \param linkIds the IDs of the links to block
347 */
349 const Mac48Address& address,
350 const std::set<uint8_t>& linkIds);
351
352 /**
353 * Unblock the transmission on the given links of all unicast frames addressed to
354 * the station with the given address for the given reason. The given MAC address
355 * must be the MLD address in case the addressed device is multi-link.
356 *
357 * \param reason the reason for unblocking transmissions
358 * \param address the MAC address of the given device
359 * \param linkIds the IDs of the links to unblock
360 */
362 const Mac48Address& address,
363 const std::set<uint8_t>& linkIds);
364
365 /**
366 * Return true if packets can be forwarded to the given destination,
367 * false otherwise.
368 *
369 * \param to the address to which the packet should be sent
370 * \return whether packets can be forwarded to the given destination
371 */
372 virtual bool CanForwardPacketsTo(Mac48Address to) const = 0;
373 /**
374 * \param packet the packet to send.
375 * \param to the address to which the packet should be sent.
376 * \param from the address from which the packet should be sent.
377 *
378 * The packet should be enqueued in a TX queue, and should be
379 * dequeued as soon as the DCF function determines that
380 * access it granted to this MAC. The extra parameter "from" allows
381 * this device to operate in a bridged mode, forwarding received
382 * frames without altering the source address.
383 */
384 virtual void Enqueue(Ptr<Packet> packet, Mac48Address to, Mac48Address from);
385 /**
386 * \param packet the packet to send.
387 * \param to the address to which the packet should be sent.
388 *
389 * The packet should be enqueued in a TX queue, and should be
390 * dequeued as soon as the DCF function determines that
391 * access it granted to this MAC.
392 */
393 virtual void Enqueue(Ptr<Packet> packet, Mac48Address to) = 0;
394 /**
395 * \return if this MAC supports sending from arbitrary address.
396 *
397 * The interface may or may not support sending from arbitrary address.
398 * This function returns true if sending from arbitrary address is supported,
399 * false otherwise.
400 */
401 virtual bool SupportsSendFrom() const;
402
403 /**
404 * \param phys the physical layers attached to this MAC.
405 */
406 virtual void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys);
407 /**
408 * \param linkId the index (starting at 0) of the PHY object to retrieve
409 * \return the physical layer attached to this MAC
410 */
411 Ptr<WifiPhy> GetWifiPhy(uint8_t linkId = SINGLE_LINK_OP_ID) const;
412 /**
413 * Remove currently attached WifiPhy objects from this MAC.
414 */
415 void ResetWifiPhys();
416
417 /**
418 * \param stationManager the station manager attached to this MAC.
419 */
421 /**
422 * \param stationManagers the station managers attached to this MAC.
423 */
425 const std::vector<Ptr<WifiRemoteStationManager>>& stationManagers);
426 /**
427 * \param linkId the ID (starting at 0) of the link of the RemoteStationManager object
428 * to retrieve
429 * \return the remote station manager operating on the given link
430 */
432
433 /**
434 * This type defines the callback of a higher layer that a
435 * WifiMac(-derived) object invokes to pass a packet up the stack.
436 *
437 * \param packet the packet that has been received.
438 * \param from the MAC address of the device that sent the packet.
439 * \param to the MAC address of the device that the packet is destined for.
440 */
442
443 /**
444 * \param upCallback the callback to invoke when a packet must be
445 * forwarded up the stack.
446 */
448 /**
449 * \param linkUp the callback to invoke when the link becomes up.
450 */
451 virtual void SetLinkUpCallback(Callback<void> linkUp);
452 /**
453 * \param linkDown the callback to invoke when the link becomes down.
454 */
455 void SetLinkDownCallback(Callback<void> linkDown);
456 /* Next functions are not pure virtual so non QoS WifiMacs are not
457 * forced to implement them.
458 */
459
460 /**
461 * Notify that channel on the given link has been switched.
462 *
463 * \param linkId the ID of the given link
464 */
465 virtual void NotifyChannelSwitching(uint8_t linkId);
466
467 /**
468 * \param packet the packet being enqueued
469 *
470 * Public method used to fire a MacTx trace. Implemented for encapsulation purposes.
471 * Note this trace indicates that the packet was accepted by the device only.
472 * The packet may be dropped later (e.g. if the queue is full).
473 */
474 void NotifyTx(Ptr<const Packet> packet);
475 /**
476 * \param packet the packet being dropped
477 *
478 * Public method used to fire a MacTxDrop trace.
479 * This trace indicates that the packet was dropped before it was queued for
480 * transmission (e.g. when a STA is not associated with an AP).
481 */
482 void NotifyTxDrop(Ptr<const Packet> packet);
483 /**
484 * \param packet the packet we received
485 *
486 * Public method used to fire a MacRx trace. Implemented for encapsulation purposes.
487 */
488 void NotifyRx(Ptr<const Packet> packet);
489 /**
490 * \param packet the packet we received promiscuously
491 *
492 * Public method used to fire a MacPromiscRx trace. Implemented for encapsulation purposes.
493 */
495 /**
496 * \param packet the packet we received but is not destined for us
497 *
498 * Public method used to fire a MacRxDrop trace. Implemented for encapsulation purposes.
499 */
500 void NotifyRxDrop(Ptr<const Packet> packet);
501
502 /**
503 * \return pointer to HtConfiguration if it exists
504 */
506 /**
507 * \return pointer to VhtConfiguration if it exists
508 */
510 /**
511 * \return pointer to HeConfiguration if it exists
512 */
514 /**
515 * \return pointer to EhtConfiguration if it exists
516 */
518
519 /**
520 * Return the extended capabilities of the device.
521 *
522 * \return the extended capabilities that we support
523 */
525 /**
526 * Return the HT capabilities of the device for the given link.
527 *
528 * \param linkId the ID of the given link
529 * \return the HT capabilities that we support
530 */
531 HtCapabilities GetHtCapabilities(uint8_t linkId) const;
532 /**
533 * Return the VHT capabilities of the device for the given link.
534 *
535 * \param linkId the ID of the given link
536 * \return the VHT capabilities that we support
537 */
538 VhtCapabilities GetVhtCapabilities(uint8_t linkId) const;
539 /**
540 * Return the HE capabilities of the device for the given link.
541 *
542 * \param linkId the ID of the given link
543 * \return the HE capabilities that we support
544 */
545 HeCapabilities GetHeCapabilities(uint8_t linkId) const;
546 /**
547 * Return the HE 6GHz band capabilities of the device for the given 6 GHz link.
548 *
549 * \param linkId the ID of the given 6 GHz link
550 * \return the HE 6GHz band capabilities that we support
551 */
553 /**
554 * Return the EHT capabilities of the device for the given link.
555 *
556 * \param linkId the ID of the given link
557 * \return the EHT capabilities that we support
558 */
559 EhtCapabilities GetEhtCapabilities(uint8_t linkId) const;
560
561 /**
562 * Return whether the device supports QoS.
563 *
564 * \return true if QoS is supported, false otherwise
565 */
566 bool GetQosSupported() const;
567 /**
568 * Return whether the device supports ERP on the given link.
569 *
570 * \param linkId the ID of the given link
571 * \return true if ERP is supported, false otherwise
572 */
573 bool GetErpSupported(uint8_t linkId) const;
574 /**
575 * Return whether the device supports DSSS on the given link.
576 *
577 * \param linkId the ID of the given link
578 * \return true if DSSS is supported, false otherwise
579 */
580 bool GetDsssSupported(uint8_t linkId) const;
581 /**
582 * Return whether the device supports HT on the given link.
583 *
584 * \param linkId the ID of the given link.
585 * \return true if HT is supported, false otherwise
586 */
587 bool GetHtSupported(uint8_t linkId) const;
588 /**
589 * Return whether the device supports VHT on the given link.
590 *
591 * \param linkId the ID of the given link.
592 * \return true if VHT is supported, false otherwise
593 */
594 bool GetVhtSupported(uint8_t linkId) const;
595 /**
596 * Return whether the device supports HE.
597 *
598 * \return true if HE is supported, false otherwise
599 */
600 bool GetHeSupported() const;
601 /**
602 * Return whether the device supports EHT.
603 *
604 * \return true if EHT is supported, false otherwise
605 */
606 bool GetEhtSupported() const;
607
608 /**
609 * \param address the (link or MLD) address of a remote station
610 * \return true if the remote station with the given address supports HT
611 */
612 bool GetHtSupported(const Mac48Address& address) const;
613 /**
614 * \param address the (link or MLD) address of a remote station
615 * \return true if the remote station with the given address supports VHT
616 */
617 bool GetVhtSupported(const Mac48Address& address) const;
618 /**
619 * \param address the (link or MLD) address of a remote station
620 * \return true if the remote station with the given address supports HE
621 */
622 bool GetHeSupported(const Mac48Address& address) const;
623 /**
624 * \param address the (link or MLD) address of a remote station
625 * \return true if the remote station with the given address supports EHT
626 */
627 bool GetEhtSupported(const Mac48Address& address) const;
628
629 /**
630 * Return the maximum A-MPDU size of the given Access Category.
631 *
632 * \param ac Access Category index
633 * \return the maximum A-MPDU size
634 */
636 /**
637 * Return the maximum A-MSDU size of the given Access Category.
638 *
639 * \param ac Access Category index
640 * \return the maximum A-MSDU size
641 */
642 uint16_t GetMaxAmsduSize(AcIndex ac) const;
643
644 /// optional const reference to OriginatorBlockAckAgreement
646 std::optional<std::reference_wrapper<const OriginatorBlockAckAgreement>>;
647 /// optional const reference to RecipientBlockAckAgreement
649 std::optional<std::reference_wrapper<const RecipientBlockAckAgreement>>;
650
651 /**
652 * \param recipient (link or device) MAC address of the recipient
653 * \param tid traffic ID.
654 *
655 * \return the originator block ack agreement, if one has been established
656 *
657 * Checks if an originator block ack agreement is established with station addressed by
658 * <i>recipient</i> for TID <i>tid</i>.
659 */
661 uint8_t tid) const;
662 /**
663 * \param originator (link or device) MAC address of the originator
664 * \param tid traffic ID.
665 *
666 * \return the recipient block ack agreement, if one has been established
667 *
668 * Checks if a recipient block ack agreement is established with station addressed by
669 * <i>originator</i> for TID <i>tid</i>.
670 */
672 uint8_t tid) const;
673
674 /**
675 * \param recipient MAC address
676 * \param tid traffic ID
677 *
678 * \return the type of Block Acks sent by the recipient
679 *
680 * This function returns the type of Block Acks sent by the recipient.
681 */
682 BlockAckType GetBaTypeAsOriginator(const Mac48Address& recipient, uint8_t tid) const;
683 /**
684 * \param recipient MAC address of recipient
685 * \param tid traffic ID
686 *
687 * \return the type of Block Ack Requests sent to the recipient
688 *
689 * This function returns the type of Block Ack Requests sent to the recipient.
690 */
691 BlockAckReqType GetBarTypeAsOriginator(const Mac48Address& recipient, uint8_t tid) const;
692 /**
693 * \param originator MAC address of originator
694 * \param tid traffic ID
695 *
696 * \return the type of Block Acks sent to the originator
697 *
698 * This function returns the type of Block Acks sent to the originator.
699 */
700 BlockAckType GetBaTypeAsRecipient(Mac48Address originator, uint8_t tid) const;
701 /**
702 * \param originator MAC address of originator
703 * \param tid traffic ID
704 *
705 * \return the type of Block Ack Requests sent by the originator
706 *
707 * This function returns the type of Block Ack Requests sent by the originator.
708 */
709 BlockAckReqType GetBarTypeAsRecipient(Mac48Address originator, uint8_t tid) const;
710
711 /**
712 * Get the maximum Block Ack buffer size (in number of MPDUs) supported by the given device,
713 * if any, or by this device, otherwise, based on the supported standard.
714 *
715 * \param address the (MLD or link) address of the given device
716 * \return the maximum supported Block Ack buffer size (in number of MPDUs)
717 */
718 uint16_t GetMaxBaBufferSize(std::optional<Mac48Address> address = std::nullopt) const;
719
720 /**
721 * \param size the size (in number of MPDUs) of the buffer used for each BlockAck
722 * agreement in which this node is a recipient
723 */
724 void SetMpduBufferSize(uint16_t size);
725
726 /**
727 * \return the size (in number of MPDUs) of the buffer used for each BlockAck
728 * agreement in which this node is a recipient
729 */
730 uint16_t GetMpduBufferSize() const;
731
732 /**
733 * Get the TID-to-Link Mapping negotiated with the given MLD (if any) for the given direction.
734 * An empty mapping indicates the default mapping.
735 *
736 * \param mldAddr the MLD address of the given MLD
737 * \param dir the given direction (DL or UL)
738 * \return the negotiated TID-to-Link Mapping
739 */
740 std::optional<std::reference_wrapper<const WifiTidLinkMapping>> GetTidToLinkMapping(
741 Mac48Address mldAddr,
742 WifiDirection dir) const;
743
744 /**
745 * Check whether the given TID is mapped on the given link in the given direction for the
746 * given MLD.
747 *
748 * \param mldAddr the MLD address of the given MLD
749 * \param dir the given direction (DL or UL)
750 * \param tid the given TID
751 * \param linkId the ID of the given link
752 * \return whether the given TID is mapped on the given link in the given direction for the
753 * given MLD
754 */
755 bool TidMappedOnLink(Mac48Address mldAddr,
757 uint8_t tid,
758 uint8_t linkId) const;
759
760 protected:
761 void DoInitialize() override;
762 void DoDispose() override;
763 void NotifyConstructionCompleted() override;
764
765 /**
766 * \param cwMin the minimum contention window size
767 * \param cwMax the maximum contention window size
768 *
769 * This method is called to set the minimum and the maximum
770 * contention window size.
771 */
772 virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax);
773
774 /**
775 * Enable or disable short slot time feature.
776 *
777 * \param enable true if short slot time is to be supported,
778 * false otherwise
779 */
780 void SetShortSlotTimeSupported(bool enable);
781 /**
782 * \return whether the device supports short slot time capability.
783 */
784 bool GetShortSlotTimeSupported() const;
785
786 /**
787 * Accessor for the AC_VO channel access function
788 *
789 * \return a smart pointer to QosTxop
790 */
791 Ptr<QosTxop> GetVOQueue() const;
792 /**
793 * Accessor for the AC_VI channel access function
794 *
795 * \return a smart pointer to QosTxop
796 */
797 Ptr<QosTxop> GetVIQueue() const;
798 /**
799 * Accessor for the AC_BE channel access function
800 *
801 * \return a smart pointer to QosTxop
802 */
803 Ptr<QosTxop> GetBEQueue() const;
804 /**
805 * Accessor for the AC_BK channel access function
806 *
807 * \return a smart pointer to QosTxop
808 */
809 Ptr<QosTxop> GetBKQueue() const;
810
811 /**
812 * This method acts as the MacRxMiddle receive callback and is
813 * invoked to notify us that a frame has been received on the given link.
814 * The implementation is intended to capture logic that is going to be
815 * common to all (or most) derived classes. Specifically, handling
816 * of Block Ack management frames is dealt with here.
817 *
818 * This method will need, however, to be overridden by derived
819 * classes so that they can perform their data handling before
820 * invoking the base version.
821 *
822 * The given link may be undefined in some cases (e.g., in case of
823 * QoS Data frames received in the context of a Block Ack agreement --
824 * because the BlockAckManager does not have to record the link each
825 * buffered MPDU has been received on); in such a cases, the value
826 * of <i>linkId</i> should be WIFI_LINKID_UNDEFINED.
827 *
828 * \param mpdu the MPDU that has been received.
829 * \param linkId the ID of the given link
830 */
831 virtual void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
832 /**
833 * Forward the packet up to the device.
834 *
835 * \param packet the packet that we are forwarding up to the device
836 * \param from the address of the source
837 * \param to the address of the destination
838 */
840
841 /**
842 * This method can be called to de-aggregate an A-MSDU and forward
843 * the constituent packets up the stack.
844 *
845 * \param mpdu the MPDU containing the A-MSDU.
846 */
848
849 /**
850 * Apply the TID-to-Link Mapping negotiated with the given MLD for the given direction
851 * by properly configuring the queue scheduler.
852 *
853 * \param mldAddr the MLD MAC address of the given MLD
854 * \param dir the given direction (DL or UL)
855 */
857
858 /**
859 * Swap the links based on the information included in the given map. This method
860 * is normally called by a non-AP MLD upon completing ML setup to have its link IDs
861 * match AP MLD's link IDs.
862 *
863 * \param links a set of pairs (from, to) each mapping a current link ID to the
864 * link ID it has to become (i.e., link 'from' becomes link 'to')
865 */
866 void SwapLinks(std::map<uint8_t, uint8_t> links);
867
868 /**
869 * Structure holding information specific to a single link. Here, the meaning of
870 * "link" is that of the 11be amendment which introduced multi-link devices. For
871 * previous amendments, only one link can be created. Therefore, "link" has not
872 * to be confused with the general concept of link for a NetDevice (used by the
873 * m_linkUp and m_linkDown callbacks).
874 */
876 {
877 /// Destructor (a virtual method is needed to make this struct polymorphic)
878 virtual ~LinkEntity();
879
880 Ptr<WifiPhy> phy; //!< Wifi PHY object
881 Ptr<ChannelAccessManager> channelAccessManager; //!< channel access manager object
882 Ptr<FrameExchangeManager> feManager; //!< Frame Exchange Manager object
883 Ptr<WifiRemoteStationManager> stationManager; //!< Remote station manager (rate control,
884 //!< RTS/CTS/fragmentation thresholds etc.)
885 bool erpSupported{false}; //!< set to \c true iff this WifiMac is to model 802.11g
886 bool dsssSupported{false}; //!< set to \c true iff this WifiMac is to model 802.11b
887 };
888
889 /**
890 * \return a const reference to the map of link entities
891 */
892 const std::map<uint8_t, std::unique_ptr<LinkEntity>>& GetLinks() const;
893
894 /**
895 * Get a reference to the link associated with the given ID.
896 *
897 * \param linkId the given link ID
898 * \return a reference to the link associated with the given ID
899 */
900 LinkEntity& GetLink(uint8_t linkId) const;
901
902 /**
903 * Update the TID-to-Link Mappings for the given MLD in the given direction based on the
904 * given negotiated mappings. An empty mapping indicates the default mapping.
905 *
906 * \param mldAddr the MLD address of the given MLD
907 * \param dir the given direction (DL or UL)
908 * \param mapping the negotiated TID-to-Link Mapping
909 */
910 void UpdateTidToLinkMapping(const Mac48Address& mldAddr,
912 const WifiTidLinkMapping& mapping);
913
914 Ptr<MacRxMiddle> m_rxMiddle; //!< RX middle (defragmentation etc.)
915 Ptr<MacTxMiddle> m_txMiddle; //!< TX middle (aggregation etc.)
916 Ptr<Txop> m_txop; //!< TXOP used for transmission of frames to non-QoS peers.
917 Ptr<WifiMacQueueScheduler> m_scheduler; //!< wifi MAC queue scheduler
918
919 Callback<void> m_linkUp; //!< Callback when a link is up
920 Callback<void> m_linkDown; //!< Callback when a link is down
921
922 private:
923 /**
924 * Complete the configuration of the MAC layer components.
925 */
926 void CompleteConfig();
927
928 /**
929 * Allow subclasses to complete the configuration of the MAC layer components.
930 */
931 virtual void DoCompleteConfig() = 0;
932
933 /**
934 * \param dcf the DCF to be configured
935 * \param cwmin the minimum contention window for the DCF
936 * \param cwmax the maximum contention window for the DCF
937 * \param isDsss vector of flags to indicate whether PHY is DSSS or HR/DSSS for every link
938 * \param ac the access category for the DCF
939 *
940 * Configure the DCF with appropriate values depending on the given access category.
941 */
942 void ConfigureDcf(Ptr<Txop> dcf,
943 uint32_t cwmin,
944 uint32_t cwmax,
945 std::list<bool> isDsss,
946 AcIndex ac);
947
948 /**
949 * Configure PHY dependent parameters such as CWmin and CWmax on the given link.
950 *
951 * \param linkId the ID of the given link
952 */
953 void ConfigurePhyDependentParameters(uint8_t linkId);
954
955 /**
956 * Enable or disable QoS support for the device. Construct a Txop object or QosTxop objects
957 * accordingly. This method is private so that it is only used while constructing this object.
958 *
959 * \param enable whether QoS is supported
960 */
961 void SetQosSupported(bool enable);
962
963 /**
964 * Set the Txop object.
965 * This method is private so that it is only used while constructing this object.
966 *
967 * \param dcf the Txop object
968 */
969 void SetTxop(Ptr<Txop> dcf);
970
971 /**
972 * Set the AC_VO channel access function
973 * This method is private so that it is only used while constructing this object.
974 *
975 * \param edca the QosTxop object for AC_VO
976 */
977 void SetVoQueue(Ptr<QosTxop> edca);
978
979 /**
980 * Set the AC_VI channel access function
981 * This method is private so that it is only used while constructing this object.
982 *
983 * \param edca the QosTxop object for AC_VI
984 */
985 void SetViQueue(Ptr<QosTxop> edca);
986
987 /**
988 * Set the AC_BE channel access function
989 * This method is private so that it is only used while constructing this object.
990 *
991 * \param edca the QosTxop object for AC_BE
992 */
993 void SetBeQueue(Ptr<QosTxop> edca);
994
995 /**
996 * Set the AC_BK channel access function
997 * This method is private so that it is only used while constructing this object.
998 *
999 * \param edca the QosTxop object for AC_BK
1000 */
1001 void SetBkQueue(Ptr<QosTxop> edca);
1002
1003 /**
1004 * This method is a private utility invoked to configure the channel
1005 * access function for devices that do not support QoS.
1006 */
1007 void SetupDcfQueue();
1008
1009 /**
1010 * This method is a private utility invoked to configure the channel
1011 * access function for the specified Access Category.
1012 *
1013 * \param ac the Access Category of the queue to initialise.
1014 */
1015 void SetupEdcaQueue(AcIndex ac);
1016
1017 /**
1018 * If no link has been already created, create the given number links; otherwise, do nothing.
1019 *
1020 * \param nLinks the given number of links
1021 * \return whether the given number of links have been created
1022 */
1023 bool CreateLinksIfNeeded(std::size_t nLinks);
1024
1025 /**
1026 * Create a LinkEntity object.
1027 *
1028 * \return a unique pointer to the created LinkEntity object
1029 */
1030 virtual std::unique_ptr<LinkEntity> CreateLinkEntity() const;
1031
1032 /**
1033 * This method is intended to be called when a link changes ID in order to update the
1034 * link ID stored by the Frame Exchange Manager and the Channel Access Manager operating
1035 * on that link.
1036 *
1037 * \param id the (new) ID of the link that has changed ID
1038 */
1039 void UpdateLinkId(uint8_t id);
1040
1041 /**
1042 * This method is called if this device is an MLD to determine the MAC address of
1043 * the affiliated STA used to communicate with the single link device having the
1044 * given MAC address. This method is overridden because its implementation depends
1045 * on the type of station.
1046 *
1047 * \param remoteAddr the MAC address of the remote single link device
1048 * \return the MAC address of the affiliated STA used to communicate with the remote device
1049 */
1050 virtual Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const;
1051
1052 /**
1053 * Enable or disable ERP support for the given link.
1054 *
1055 * \param enable whether ERP is supported
1056 * \param linkId the ID of the given link
1057 */
1058 void SetErpSupported(bool enable, uint8_t linkId);
1059 /**
1060 * Enable or disable DSSS support for the given link.
1061 *
1062 * \param enable whether DSSS is supported
1063 * \param linkId the ID of the given link
1064 */
1065 void SetDsssSupported(bool enable, uint8_t linkId);
1066
1067 /**
1068 * Set the block ack threshold for AC_VO.
1069 *
1070 * \param threshold the block ack threshold for AC_VO.
1071 */
1072 void SetVoBlockAckThreshold(uint8_t threshold);
1073 /**
1074 * Set the block ack threshold for AC_VI.
1075 *
1076 * \param threshold the block ack threshold for AC_VI.
1077 */
1078 void SetViBlockAckThreshold(uint8_t threshold);
1079 /**
1080 * Set the block ack threshold for AC_BE.
1081 *
1082 * \param threshold the block ack threshold for AC_BE.
1083 */
1084 void SetBeBlockAckThreshold(uint8_t threshold);
1085 /**
1086 * Set the block ack threshold for AC_BK.
1087 *
1088 * \param threshold the block ack threshold for AC_BK.
1089 */
1090 void SetBkBlockAckThreshold(uint8_t threshold);
1091
1092 /**
1093 * Set VO block ack inactivity timeout.
1094 *
1095 * \param timeout the VO block ack inactivity timeout.
1096 */
1098 /**
1099 * Set VI block ack inactivity timeout.
1100 *
1101 * \param timeout the VI block ack inactivity timeout.
1102 */
1104 /**
1105 * Set BE block ack inactivity timeout.
1106 *
1107 * \param timeout the BE block ack inactivity timeout.
1108 */
1110 /**
1111 * Set BK block ack inactivity timeout.
1112 *
1113 * \param timeout the BK block ack inactivity timeout.
1114 */
1116
1117 /**
1118 * This Boolean is set \c true iff this WifiMac is to model
1119 * 802.11e/WMM style Quality of Service. It is exposed through the
1120 * attribute system.
1121 *
1122 * At the moment, this flag is the sole selection between QoS and
1123 * non-QoS operation for the STA (whether IBSS, AP, or
1124 * non-AP). Ultimately, we will want a QoS-enabled STA to be able to
1125 * fall back to non-QoS operation with a non-QoS peer. This'll
1126 * require further intelligence - i.e., per-association QoS
1127 * state. Having a big switch seems like a good intermediate stage,
1128 * however.
1129 */
1131
1132 bool m_shortSlotTimeSupported; ///< flag whether short slot time is supported
1133 bool m_ctsToSelfSupported; ///< flag indicating whether CTS-To-Self is supported
1134
1135 TypeOfStation m_typeOfStation; //!< the type of station
1136
1137 Ptr<WifiNetDevice> m_device; //!< Pointer to the device
1138 std::map<uint8_t, std::unique_ptr<LinkEntity>> m_links; //!< ID-indexed map of Link objects
1139 std::set<uint8_t> m_linkIds; //!< IDs of the links in use
1140
1141 Mac48Address m_address; //!< MAC address of this station
1142 Ssid m_ssid; //!< Service Set ID (SSID)
1143
1144 /** This type defines a mapping between an Access Category index,
1145 and a pointer to the corresponding channel access function.
1146 Access Categories are sorted in decreasing order of priority. */
1147 typedef std::map<AcIndex, Ptr<QosTxop>, std::greater<>> EdcaQueues;
1148
1149 /** This is a map from Access Category index to the corresponding
1150 channel access function */
1152
1153 uint16_t m_voMaxAmsduSize; ///< maximum A-MSDU size for AC_VO (in bytes)
1154 uint16_t m_viMaxAmsduSize; ///< maximum A-MSDU size for AC_VI (in bytes)
1155 uint16_t m_beMaxAmsduSize; ///< maximum A-MSDU size for AC_BE (in bytes)
1156 uint16_t m_bkMaxAmsduSize; ///< maximum A-MSDU size for AC_BK (in bytes)
1157
1158 uint32_t m_voMaxAmpduSize; ///< maximum A-MPDU size for AC_VO (in bytes)
1159 uint32_t m_viMaxAmpduSize; ///< maximum A-MPDU size for AC_VI (in bytes)
1160 uint32_t m_beMaxAmpduSize; ///< maximum A-MPDU size for AC_BE (in bytes)
1161 uint32_t m_bkMaxAmpduSize; ///< maximum A-MPDU size for AC_BK (in bytes)
1162
1163 uint16_t m_mpduBufferSize; //!< BlockAck buffer size (in number of MPDUs)
1164
1165 UniformRandomBitGenerator m_shuffleLinkIdsGen; //!< random number generator to shuffle link IDs
1166
1167 /// @brief DL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)
1168 std::unordered_map<Mac48Address, WifiTidLinkMapping, WifiAddressHash> m_dlTidLinkMappings;
1169 /// @brief UL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)
1170 std::unordered_map<Mac48Address, WifiTidLinkMapping, WifiAddressHash> m_ulTidLinkMappings;
1171
1172 ForwardUpCallback m_forwardUp; //!< Callback to forward packet up the stack
1173
1174 /**
1175 * The trace source fired when packets come into the "top" of the device
1176 * at the L3/L2 transition, before being queued for transmission.
1177 *
1178 * \see class CallBackTraceSource
1179 */
1181 /**
1182 * The trace source fired when packets coming into the "top" of the device
1183 * are dropped at the MAC layer before being queued for transmission.
1184 *
1185 * \see class CallBackTraceSource
1186 */
1188 /**
1189 * The trace source fired for packets successfully received by the device
1190 * immediately before being forwarded up to higher layers (at the L2/L3
1191 * transition). This is a promiscuous trace.
1192 *
1193 * \see class CallBackTraceSource
1194 */
1196 /**
1197 * The trace source fired for packets successfully received by the device
1198 * immediately before being forwarded up to higher layers (at the L2/L3
1199 * transition). This is a non- promiscuous trace.
1200 *
1201 * \see class CallBackTraceSource
1202 */
1204 /**
1205 * The trace source fired when packets coming into the "top" of the device
1206 * are dropped at the MAC layer during reception.
1207 *
1208 * \see class CallBackTraceSource
1209 */
1211
1212 /**
1213 * TracedCallback signature for MPDU drop events.
1214 *
1215 * \param reason the reason why the MPDU was dropped (\see WifiMacDropReason)
1216 * \param mpdu the dropped MPDU
1217 */
1219
1220 /// TracedCallback for MPDU drop events typedef
1222
1223 /**
1224 * This trace indicates that an MPDU was dropped for the given reason.
1225 */
1227
1228 /// TracedCallback for acked/nacked MPDUs typedef
1230
1231 MpduTracedCallback m_ackedMpduCallback; ///< ack'ed MPDU callback
1232 MpduTracedCallback m_nackedMpduCallback; ///< nack'ed MPDU callback
1233
1234 /**
1235 * TracedCallback signature for MPDU response timeout events.
1236 *
1237 * \param reason the reason why the timer was started
1238 * \param mpdu the MPDU whose response was not received before the timeout
1239 * \param txVector the TXVECTOR used to transmit the MPDU
1240 */
1241 typedef void (*MpduResponseTimeoutCallback)(uint8_t reason,
1243 const WifiTxVector& txVector);
1244
1245 /// TracedCallback for MPDU response timeout events typedef
1248
1249 /**
1250 * MPDU response timeout traced callback.
1251 * This trace source is fed by a WifiTxTimer object.
1252 */
1254
1255 /**
1256 * TracedCallback signature for PSDU response timeout events.
1257 *
1258 * \param reason the reason why the timer was started
1259 * \param psdu the PSDU whose response was not received before the timeout
1260 * \param txVector the TXVECTOR used to transmit the PSDU
1261 */
1262 typedef void (*PsduResponseTimeoutCallback)(uint8_t reason,
1264 const WifiTxVector& txVector);
1265
1266 /// TracedCallback for PSDU response timeout events typedef
1269
1270 /**
1271 * PSDU response timeout traced callback.
1272 * This trace source is fed by a WifiTxTimer object.
1273 */
1275
1276 /**
1277 * TracedCallback signature for PSDU map response timeout events.
1278 *
1279 * \param reason the reason why the timer was started
1280 * \param psduMap the PSDU map for which not all responses were received before the timeout
1281 * \param missingStations the MAC addresses of the stations that did not respond
1282 * \param nTotalStations the total number of stations that had to respond
1283 */
1284 typedef void (*PsduMapResponseTimeoutCallback)(uint8_t reason,
1285 WifiPsduMap* psduMap,
1286 const std::set<Mac48Address>* missingStations,
1287 std::size_t nTotalStations);
1288
1289 /// TracedCallback for PSDU map response timeout events typedef
1292
1293 /**
1294 * PSDU map response timeout traced callback.
1295 * This trace source is fed by a WifiTxTimer object.
1296 */
1298};
1299
1300} // namespace ns3
1301
1302#endif /* WIFI_MAC_H */
Callback template class.
Definition: callback.h:438
The IEEE 802.11be EHT Capabilities.
The Extended Capabilities Information Element.
The HE 6 GHz Band Capabilities (IEEE 802.11ax-2021 9.4.2.263)
The IEEE 802.11ax HE Capabilities.
The HT Capabilities Information Element.
an EUI-48 address
Definition: mac48-address.h:46
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Wraps a UniformRandomVariable into a class that meets the requirements of a UniformRandomBitGenerator...
The IEEE 802.11ac VHT Capabilities.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:99
virtual void DoCompleteConfig()=0
Allow subclasses to complete the configuration of the MAC layer components.
uint16_t GetMaxAmsduSize(AcIndex ac) const
Return the maximum A-MSDU size of the given Access Category.
Definition: wifi-mac.cc:2455
Ptr< FrameExchangeManager > GetFrameExchangeManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Frame Exchange Manager associated with the given link.
Definition: wifi-mac.cc:981
Ptr< QosTxop > GetBEQueue() const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:627
virtual void NotifyChannelSwitching(uint8_t linkId)
Notify that channel on the given link has been switched.
Definition: wifi-mac.cc:676
std::optional< Mac48Address > GetMldAddress(const Mac48Address &remoteAddr) const
Definition: wifi-mac.cc:1774
virtual void SetMacQueueScheduler(Ptr< WifiMacQueueScheduler > scheduler)
Set the wifi MAC queue scheduler.
Definition: wifi-mac.cc:663
Mac48Address GetBssid(uint8_t linkId) const
Definition: wifi-mac.cc:522
void(* PsduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
TracedCallback signature for PSDU response timeout events.
Definition: wifi-mac.h:1262
uint16_t m_viMaxAmsduSize
maximum A-MSDU size for AC_VI (in bytes)
Definition: wifi-mac.h:1154
bool m_shortSlotTimeSupported
flag whether short slot time is supported
Definition: wifi-mac.h:1132
void ConfigurePhyDependentParameters(uint8_t linkId)
Configure PHY dependent parameters such as CWmin and CWmax on the given link.
Definition: wifi-mac.cc:910
Ptr< HeConfiguration > GetHeConfiguration() const
Definition: wifi-mac.cc:1891
DroppedMpduTracedCallback m_droppedMpduCallback
This trace indicates that an MPDU was dropped for the given reason.
Definition: wifi-mac.h:1226
TracedCallback< WifiMacDropReason, Ptr< const WifiMpdu > > DroppedMpduTracedCallback
TracedCallback for MPDU drop events typedef.
Definition: wifi-mac.h:1221
TypeOfStation GetTypeOfStation() const
Return the type of station.
Definition: wifi-mac.cc:466
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service.
Definition: wifi-mac.h:1130
void SetBkQueue(Ptr< QosTxop > edca)
Set the AC_BK channel access function This method is private so that it is only used while constructi...
Definition: wifi-mac.cc:583
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition: wifi-mac.cc:1057
Ptr< Txop > GetTxop() const
Accessor for the Txop object.
Definition: wifi-mac.cc:547
VhtCapabilities GetVhtCapabilities(uint8_t linkId) const
Return the VHT capabilities of the device for the given link.
Definition: wifi-mac.cc:2162
Callback< void > m_linkDown
Callback when a link is down.
Definition: wifi-mac.h:920
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:1347
std::optional< std::reference_wrapper< const RecipientBlockAckAgreement > > RecipientAgreementOptConstRef
optional const reference to RecipientBlockAckAgreement
Definition: wifi-mac.h:649
virtual void SetAddress(Mac48Address address)
Definition: wifi-mac.cc:489
void SetFrameExchangeManagers(const std::vector< Ptr< FrameExchangeManager > > &feManagers)
Definition: wifi-mac.cc:944
bool CreateLinksIfNeeded(std::size_t nLinks)
If no link has been already created, create the given number links; otherwise, do nothing.
Definition: wifi-mac.cc:928
Ptr< Txop > m_txop
TXOP used for transmission of frames to non-QoS peers.
Definition: wifi-mac.h:916
void SetQosSupported(bool enable)
Enable or disable QoS support for the device.
Definition: wifi-mac.cc:1339
Mac48Address m_address
MAC address of this station.
Definition: wifi-mac.h:1141
std::set< uint8_t > m_linkIds
IDs of the links in use.
Definition: wifi-mac.h:1139
Ptr< WifiMacQueueScheduler > GetMacQueueScheduler() const
Get the wifi MAC queue scheduler.
Definition: wifi-mac.cc:670
uint16_t GetMpduBufferSize() const
Definition: wifi-mac.cc:2006
uint8_t GetNLinks() const
Get the number of links (can be greater than 1 for 11be devices only).
Definition: wifi-mac.cc:1072
BlockAckType GetBaTypeAsRecipient(Mac48Address originator, uint8_t tid) const
Definition: wifi-mac.cc:1861
void SwapLinks(std::map< uint8_t, uint8_t > links)
Swap the links based on the information included in the given map.
Definition: wifi-mac.cc:1134
uint16_t m_voMaxAmsduSize
maximum A-MSDU size for AC_VO (in bytes)
Definition: wifi-mac.h:1153
Ptr< MacRxMiddle > m_rxMiddle
RX middle (defragmentation etc.)
Definition: wifi-mac.h:914
Ptr< WifiMacQueueScheduler > m_scheduler
wifi MAC queue scheduler
Definition: wifi-mac.h:917
void DoInitialize() override
Initialize() implementation.
Definition: wifi-mac.cc:393
TypeOfStation m_typeOfStation
the type of station
Definition: wifi-mac.h:1135
uint16_t m_mpduBufferSize
BlockAck buffer size (in number of MPDUs)
Definition: wifi-mac.h:1163
uint32_t m_beMaxAmpduSize
maximum A-MPDU size for AC_BE (in bytes)
Definition: wifi-mac.h:1160
void SetChannelAccessManagers(const std::vector< Ptr< ChannelAccessManager > > &caManagers)
Definition: wifi-mac.cc:987
bool TidMappedOnLink(Mac48Address mldAddr, WifiDirection dir, uint8_t tid, uint8_t linkId) const
Check whether the given TID is mapped on the given link in the given direction for the given MLD.
Definition: wifi-mac.cc:1263
void UnblockUnicastTxOnLinks(WifiQueueBlockedReason reason, const Mac48Address &address, const std::set< uint8_t > &linkIds)
Unblock the transmission on the given links of all unicast frames addressed to the station with the g...
Definition: wifi-mac.cc:1558
Ssid GetSsid() const
Definition: wifi-mac.cc:509
void SetWifiRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager > > &stationManagers)
Definition: wifi-mac.cc:1022
void SetBeBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BE.
Definition: wifi-mac.cc:2032
bool GetErpSupported(uint8_t linkId) const
Return whether the device supports ERP on the given link.
Definition: wifi-mac.cc:1353
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to)=0
void ResetWifiPhys()
Remove currently attached WifiPhy objects from this MAC.
Definition: wifi-mac.cc:1321
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
Definition: wifi-mac.h:1180
void SetErpSupported(bool enable, uint8_t linkId)
Enable or disable ERP support for the given link.
Definition: wifi-mac.cc:1359
uint32_t m_voMaxAmpduSize
maximum A-MPDU size for AC_VO (in bytes)
Definition: wifi-mac.h:1158
void(* MpduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector)
TracedCallback signature for MPDU response timeout events.
Definition: wifi-mac.h:1241
void ConfigureDcf(Ptr< Txop > dcf, uint32_t cwmin, uint32_t cwmax, std::list< bool > isDsss, AcIndex ac)
Definition: wifi-mac.cc:770
WifiMac(const WifiMac &)=delete
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition: wifi-mac.h:1137
void SetSsid(Ssid ssid)
Definition: wifi-mac.cc:502
void UpdateLinkId(uint8_t id)
This method is intended to be called when a link changes ID in order to update the link ID stored by ...
Definition: wifi-mac.cc:1084
Ptr< QosTxop > GetVOQueue() const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:615
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:459
MpduTracedCallback m_ackedMpduCallback
ack'ed MPDU callback
Definition: wifi-mac.h:1231
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:1315
void SetMpduBufferSize(uint16_t size)
Definition: wifi-mac.cc:1997
void BlockUnicastTxOnLinks(WifiQueueBlockedReason reason, const Mac48Address &address, const std::set< uint8_t > &linkIds)
Block the transmission on the given links of all unicast frames addressed to the station with the giv...
Definition: wifi-mac.cc:1512
MpduTracedCallback m_nackedMpduCallback
nack'ed MPDU callback
Definition: wifi-mac.h:1232
bool GetEhtSupported() const
Return whether the device supports EHT.
Definition: wifi-mac.cc:1924
void SetTxop(Ptr< Txop > dcf)
Set the Txop object.
Definition: wifi-mac.cc:537
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1918
HtCapabilities GetHtCapabilities(uint8_t linkId) const
Return the HT capabilities of the device for the given link.
Definition: wifi-mac.cc:2103
void SetBkBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BK.
Definition: wifi-mac.cc:2042
void SetVoBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VO.
Definition: wifi-mac.cc:2012
virtual std::optional< uint8_t > GetLinkIdByAddress(const Mac48Address &address) const
Get the ID of the link having the given MAC address, if any.
Definition: wifi-mac.cc:1100
void NotifyPromiscRx(Ptr< const Packet > packet)
Definition: wifi-mac.cc:707
std::unordered_map< Mac48Address, WifiTidLinkMapping, WifiAddressHash > m_dlTidLinkMappings
DL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)
Definition: wifi-mac.h:1168
void SetVoQueue(Ptr< QosTxop > edca)
Set the AC_VO channel access function This method is private so that it is only used while constructi...
Definition: wifi-mac.cc:553
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the MAC has frames to transmit over the given link.
Definition: wifi-mac.cc:646
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
Definition: wifi-mac.cc:1015
UniformRandomBitGenerator m_shuffleLinkIdsGen
random number generator to shuffle link IDs
Definition: wifi-mac.h:1165
void ApplyTidLinkMapping(const Mac48Address &mldAddr, WifiDirection dir)
Apply the TID-to-Link Mapping negotiated with the given MLD for the given direction by properly confi...
Definition: wifi-mac.cc:1430
void CompleteConfig()
Complete the configuration of the MAC layer components.
Definition: wifi-mac.cc:859
RecipientAgreementOptConstRef GetBaAgreementEstablishedAsRecipient(Mac48Address originator, uint8_t tid) const
Definition: wifi-mac.cc:1835
void SetBeBlockAckInactivityTimeout(uint16_t timeout)
Set BE block ack inactivity timeout.
Definition: wifi-mac.cc:2072
Ptr< EhtConfiguration > GetEhtConfiguration() const
Definition: wifi-mac.cc:1897
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Definition: wifi-mac.h:1203
bool GetVhtSupported(uint8_t linkId) const
Return whether the device supports VHT on the given link.
Definition: wifi-mac.cc:1910
void SetDsssSupported(bool enable, uint8_t linkId)
Enable or disable DSSS support for the given link.
Definition: wifi-mac.cc:1370
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets coming into the "top" of the device are dropped at the MAC layer ...
Definition: wifi-mac.h:1187
TracedCallback< Ptr< const WifiMpdu > > MpduTracedCallback
TracedCallback for acked/nacked MPDUs typedef.
Definition: wifi-mac.h:1229
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:915
void NotifyTx(Ptr< const Packet > packet)
Definition: wifi-mac.cc:689
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: wifi-mac.cc:364
static TypeId GetTypeId()
Get the type ID.
Definition: wifi-mac.cc:72
Ptr< HtConfiguration > GetHtConfiguration() const
Definition: wifi-mac.cc:1879
std::optional< std::reference_wrapper< const WifiTidLinkMapping > > GetTidToLinkMapping(Mac48Address mldAddr, WifiDirection dir) const
Get the TID-to-Link Mapping negotiated with the given MLD (if any) for the given direction.
Definition: wifi-mac.cc:1247
uint32_t GetMaxAmpduSize(AcIndex ac) const
Return the maximum A-MPDU size of the given Access Category.
Definition: wifi-mac.cc:2430
BlockAckReqType GetBarTypeAsRecipient(Mac48Address originator, uint8_t tid) const
Definition: wifi-mac.cc:1870
Ssid m_ssid
Service Set ID (SSID)
Definition: wifi-mac.h:1142
std::map< uint8_t, std::unique_ptr< LinkEntity > > m_links
ID-indexed map of Link objects.
Definition: wifi-mac.h:1138
virtual void DeaggregateAmsduAndForward(Ptr< const WifiMpdu > mpdu)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
Definition: wifi-mac.cc:1762
Ptr< QosTxop > GetVIQueue() const
Accessor for the AC_VI channel access function.
Definition: wifi-mac.cc:621
void SetBssid(Mac48Address bssid, uint8_t linkId)
Definition: wifi-mac.cc:515
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-mac.cc:483
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from)
Definition: wifi-mac.cc:1621
void NotifyRx(Ptr< const Packet > packet)
Definition: wifi-mac.cc:701
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired when packets coming into the "top" of the device are dropped at the MAC layer ...
Definition: wifi-mac.h:1210
void UpdateTidToLinkMapping(const Mac48Address &mldAddr, WifiDirection dir, const WifiTidLinkMapping &mapping)
Update the TID-to-Link Mappings for the given MLD in the given direction based on the given negotiate...
Definition: wifi-mac.cc:1213
BlockAckType GetBaTypeAsOriginator(const Mac48Address &recipient, uint8_t tid) const
Definition: wifi-mac.cc:1843
MpduResponseTimeoutTracedCallback m_mpduResponseTimeoutCallback
MPDU response timeout traced callback.
Definition: wifi-mac.h:1253
void SetForwardUpCallback(ForwardUpCallback upCallback)
Definition: wifi-mac.cc:1409
PsduMapResponseTimeoutTracedCallback m_psduMapResponseTimeoutCallback
PSDU map response timeout traced callback.
Definition: wifi-mac.h:1297
ExtendedCapabilities GetExtendedCapabilities() const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:2092
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Definition: wifi-mac.h:1195
std::map< AcIndex, Ptr< QosTxop >, std::greater<> > EdcaQueues
This type defines a mapping between an Access Category index, and a pointer to the corresponding chan...
Definition: wifi-mac.h:1147
uint16_t m_bkMaxAmsduSize
maximum A-MSDU size for AC_BK (in bytes)
Definition: wifi-mac.h:1156
void SetBkBlockAckInactivityTimeout(uint16_t timeout)
Set BK block ack inactivity timeout.
Definition: wifi-mac.cc:2082
std::optional< std::reference_wrapper< const OriginatorBlockAckAgreement > > OriginatorAgreementOptConstRef
optional const reference to OriginatorBlockAckAgreement
Definition: wifi-mac.h:646
std::unordered_map< Mac48Address, WifiTidLinkMapping, WifiAddressHash > m_ulTidLinkMappings
UL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)
Definition: wifi-mac.h:1170
virtual bool SupportsSendFrom() const
Definition: wifi-mac.cc:1403
He6GhzBandCapabilities GetHe6GhzBandCapabilities(uint8_t linkId) const
Return the HE 6GHz band capabilities of the device for the given 6 GHz link.
Definition: wifi-mac.cc:2302
uint16_t GetMaxBaBufferSize(std::optional< Mac48Address > address=std::nullopt) const
Get the maximum Block Ack buffer size (in number of MPDUs) supported by the given device,...
Definition: wifi-mac.cc:1982
virtual Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Definition: wifi-mac.cc:639
std::optional< uint8_t > GetLinkForPhy(Ptr< const WifiPhy > phy) const
Get the ID of the link (if any) on which the given PHY is operating.
Definition: wifi-mac.cc:1113
void SetViBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VI.
Definition: wifi-mac.cc:2022
void SetViBlockAckInactivityTimeout(uint16_t timeout)
Set VI block ack inactivity timeout.
Definition: wifi-mac.cc:2062
bool GetShortSlotTimeSupported() const
Definition: wifi-mac.cc:1397
BlockAckReqType GetBarTypeAsOriginator(const Mac48Address &recipient, uint8_t tid) const
Definition: wifi-mac.cc:1852
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
Definition: wifi-mac.cc:376
void SetupEdcaQueue(AcIndex ac)
This method is a private utility invoked to configure the channel access function for the specified A...
Definition: wifi-mac.cc:730
void SetLinkDownCallback(Callback< void > linkDown)
Definition: wifi-mac.cc:1423
Ptr< QosTxop > GetBKQueue() const
Accessor for the AC_BK channel access function.
Definition: wifi-mac.cc:633
~WifiMac() override
Definition: wifi-mac.cc:66
void SetPromisc()
Sets the interface in promiscuous mode.
Definition: wifi-mac.cc:528
Ptr< VhtConfiguration > GetVhtConfiguration() const
Definition: wifi-mac.cc:1885
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:713
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:1416
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Definition: wifi-mac.cc:1045
const std::set< uint8_t > & GetLinkIds() const
Definition: wifi-mac.cc:1078
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:472
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self feature.
Definition: wifi-mac.cc:1383
Mac48Address GetLocalAddress(const Mac48Address &remoteAddr) const
Get the local MAC address used to communicate with a remote STA.
Definition: wifi-mac.cc:1787
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
Definition: wifi-mac.h:1151
uint32_t m_bkMaxAmpduSize
maximum A-MPDU size for AC_BK (in bytes)
Definition: wifi-mac.h:1161
bool GetHtSupported(uint8_t linkId) const
Return whether the device supports HT on the given link.
Definition: wifi-mac.cc:1903
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:1632
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Definition: wifi-mac.cc:747
bool Is6GhzBand(uint8_t linkId) const
Indicate if a given link is on the 6 GHz band.
Definition: wifi-mac.cc:1205
TracedCallback< uint8_t, Ptr< const WifiPsdu >, const WifiTxVector & > PsduResponseTimeoutTracedCallback
TracedCallback for PSDU response timeout events typedef.
Definition: wifi-mac.h:1268
TracedCallback< uint8_t, Ptr< const WifiMpdu >, const WifiTxVector & > MpduResponseTimeoutTracedCallback
TracedCallback for MPDU response timeout events typedef.
Definition: wifi-mac.h:1247
OriginatorAgreementOptConstRef GetBaAgreementEstablishedAsOriginator(Mac48Address recipient, uint8_t tid) const
Definition: wifi-mac.cc:1821
virtual void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
Definition: wifi-mac.cc:1639
Mac48Address GetAddress() const
Definition: wifi-mac.cc:496
void(* DroppedMpduCallback)(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
TracedCallback signature for MPDU drop events.
Definition: wifi-mac.h:1218
ForwardUpCallback m_forwardUp
Callback to forward packet up the stack.
Definition: wifi-mac.h:1172
EhtCapabilities GetEhtCapabilities(uint8_t linkId) const
Return the EHT capabilities of the device for the given link.
Definition: wifi-mac.cc:2337
TracedCallback< uint8_t, WifiPsduMap *, const std::set< Mac48Address > *, std::size_t > PsduMapResponseTimeoutTracedCallback
TracedCallback for PSDU map response timeout events typedef.
Definition: wifi-mac.h:1291
Callback< void > m_linkUp
Callback when a link is up.
Definition: wifi-mac.h:919
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: wifi-mac.cc:1063
void SetupDcfQueue()
This method is a private utility invoked to configure the channel access function for devices that do...
Definition: wifi-mac.cc:719
void SetBeQueue(Ptr< QosTxop > edca)
Set the AC_BE channel access function This method is private so that it is only used while constructi...
Definition: wifi-mac.cc:573
HeCapabilities GetHeCapabilities(uint8_t linkId) const
Return the HE capabilities of the device for the given link.
Definition: wifi-mac.cc:2244
WifiMac & operator=(const WifiMac &)=delete
virtual bool CanForwardPacketsTo(Mac48Address to) const =0
Return true if packets can be forwarded to the given destination, false otherwise.
virtual void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys)
Definition: wifi-mac.cc:1293
Callback< void, Ptr< const Packet >, Mac48Address, Mac48Address > ForwardUpCallback
This type defines the callback of a higher layer that a WifiMac(-derived) object invokes to pass a pa...
Definition: wifi-mac.h:441
PsduResponseTimeoutTracedCallback m_psduResponseTimeoutCallback
PSDU response timeout traced callback.
Definition: wifi-mac.h:1274
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:593
void(* PsduMapResponseTimeoutCallback)(uint8_t reason, WifiPsduMap *psduMap, const std::set< Mac48Address > *missingStations, std::size_t nTotalStations)
TracedCallback signature for PSDU map response timeout events.
Definition: wifi-mac.h:1284
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:695
void DoDispose() override
Destructor implementation.
Definition: wifi-mac.cc:417
bool GetDsssSupported(uint8_t linkId) const
Return whether the device supports DSSS on the given link.
Definition: wifi-mac.cc:1377
Ptr< ChannelAccessManager > GetChannelAccessManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Channel Access Manager associated with the given link.
Definition: wifi-mac.cc:1009
void SetVoBlockAckInactivityTimeout(uint16_t timeout)
Set VO block ack inactivity timeout.
Definition: wifi-mac.cc:2052
virtual std::unique_ptr< LinkEntity > CreateLinkEntity() const
Create a LinkEntity object.
Definition: wifi-mac.cc:1051
void SetViQueue(Ptr< QosTxop > edca)
Set the AC_VI channel access function This method is private so that it is only used while constructi...
Definition: wifi-mac.cc:563
void SetShortSlotTimeSupported(bool enable)
Enable or disable short slot time feature.
Definition: wifi-mac.cc:1390
bool m_ctsToSelfSupported
flag indicating whether CTS-To-Self is supported
Definition: wifi-mac.h:1133
uint16_t m_beMaxAmsduSize
maximum A-MSDU size for AC_BE (in bytes)
Definition: wifi-mac.h:1155
virtual Mac48Address DoGetLocalAddress(const Mac48Address &remoteAddr) const
This method is called if this device is an MLD to determine the MAC address of the affiliated STA use...
Definition: wifi-mac.cc:1815
uint32_t m_viMaxAmpduSize
maximum A-MPDU size for AC_VI (in bytes)
Definition: wifi-mac.h:1159
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
TypeOfStation
Enumeration for type of WiFi station.
Definition: wifi-mac.h:67
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:80
WifiQueueBlockedReason
Enumeration of the reasons to block container queues.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
@ ADHOC_STA
Definition: wifi-mac.h:70
@ MESH
Definition: wifi-mac.h:71
@ STA
Definition: wifi-mac.h:68
@ AP
Definition: wifi-mac.h:69
@ OCB
Definition: wifi-mac.h:72
@ WIFI_MAC_DROP_QOS_OLD_PACKET
Definition: wifi-mac.h:84
@ WIFI_MAC_DROP_FAILED_ENQUEUE
Definition: wifi-mac.h:81
@ WIFI_MAC_DROP_EXPIRED_LIFETIME
Definition: wifi-mac.h:82
@ WIFI_MAC_DROP_REACHED_RETRY_LIMIT
Definition: wifi-mac.h:83
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition: wifi-utils.h:193
WifiDirection
Wifi direction.
Definition: wifi-utils.h:44
std::map< uint8_t, std::set< uint8_t > > WifiTidLinkMapping
TID-indexed map of the link set to which the TID is mapped.
Definition: wifi-utils.h:75
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
ns3::Time timeout
The different BlockAckRequest variants.
The different BlockAck variants.
std::string dir