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 * Get the Channel Access Manager associated with the given link
148 *
149 * \param linkId the ID of the given link
150 * \return the Channel Access Manager
151 */
153
154 /**
155 * Get the number of links (can be greater than 1 for 11be devices only).
156 *
157 * \return the number of links used by this MAC
158 */
159 uint8_t GetNLinks() const;
160
161 /**
162 * \return the set of link IDs in use by this device
163 */
164 const std::set<uint8_t>& GetLinkIds() const;
165
166 /**
167 * Get the ID of the link having the given MAC address, if any.
168 *
169 * \param address the given MAC address
170 * \return the ID of the link having the given MAC address, if any
171 */
172 virtual std::optional<uint8_t> GetLinkIdByAddress(const Mac48Address& address) const;
173
174 /**
175 * Get the ID of the link (if any) on which the given PHY is operating.
176 *
177 * \param phy the given PHY
178 * \return the ID of the link (if any) on which the given PHY is operating
179 */
180 std::optional<uint8_t> GetLinkForPhy(Ptr<const WifiPhy> phy) const;
181
182 /**
183 * Get the ID of the link (if any) on which the given PHY is operating.
184 *
185 * \param phyId the index of the given PHY in the vector of PHYs held by WifiNetDevice
186 * \return the ID of the link (if any) on which the given PHY is operating
187 */
188 std::optional<uint8_t> GetLinkForPhy(std::size_t phyId) const;
189
190 /**
191 * \param remoteAddr the (MLD or link) address of a remote device
192 * \return the MLD address of the remote device having the given (MLD or link) address, if
193 * the remote device is an MLD.
194 */
195 std::optional<Mac48Address> GetMldAddress(const Mac48Address& remoteAddr) const;
196
197 /**
198 * Get the local MAC address used to communicate with a remote STA. Specifically:
199 * - If the given remote address is the address of a STA affiliated with a remote MLD
200 * and operating on a setup link, the address of the local STA operating on such a link
201 * is returned.
202 * - If the given remote address is the MLD address of a remote MLD (with which some link
203 * has been setup), the MLD address of this device is returned.
204 * - If this is a single link device, the unique MAC address of this device is returned.
205 * - Otherwise, return the MAC address of the affiliated STA (which must exists) that
206 * can be used to communicate with the remote device.
207 *
208 * \param remoteAddr the MAC address of the remote device
209 * \return the local MAC address used to communicate with the remote device
210 */
211 Mac48Address GetLocalAddress(const Mac48Address& remoteAddr) const;
212
213 /**
214 * Accessor for the Txop object
215 *
216 * \return a smart pointer to Txop
217 */
218 Ptr<Txop> GetTxop() const;
219 /**
220 * Accessor for a specified EDCA object
221 *
222 * \param ac the Access Category
223 * \return a smart pointer to a QosTxop
224 */
226 /**
227 * Accessor for a specified EDCA object
228 *
229 * \param tid the Traffic ID
230 * \return a smart pointer to a QosTxop
231 */
232 Ptr<QosTxop> GetQosTxop(uint8_t tid) const;
233 /**
234 * Get the wifi MAC queue of the (Qos)Txop associated with the given AC,
235 * if such (Qos)Txop is installed, or a null pointer, otherwise.
236 *
237 * \param ac the given Access Category
238 * \return the wifi MAC queue of the (Qos)Txop associated with the given AC,
239 * if such (Qos)Txop is installed, or a null pointer, otherwise
240 */
241 virtual Ptr<WifiMacQueue> GetTxopQueue(AcIndex ac) const;
242
243 /**
244 * Check if the MAC has frames to transmit over the given link
245 * \param linkId the ID of the given link.
246 * \return whether the MAC has frames to transmit.
247 */
248 virtual bool HasFramesToTransmit(uint8_t linkId);
249
250 /**
251 * Set the wifi MAC queue scheduler
252 *
253 * \param scheduler the wifi MAC queue scheduler
254 */
255 virtual void SetMacQueueScheduler(Ptr<WifiMacQueueScheduler> scheduler);
256 /**
257 * Get the wifi MAC queue scheduler
258 *
259 * \return the wifi MAC queue scheduler
260 */
262
263 /**
264 * This method is invoked by a subclass to specify what type of
265 * station it is implementing. This is something that the channel
266 * access functions need to know.
267 *
268 * \param type the type of station.
269 */
271 /**
272 * Return the type of station.
273 *
274 * \return the type of station.
275 */
277
278 /**
279 * \param ssid the current SSID of this MAC layer.
280 */
281 void SetSsid(Ssid ssid);
282 /**
283 * \brief Sets the interface in promiscuous mode.
284 *
285 * Enables promiscuous mode on the interface. Note that any further
286 * filtering on the incoming frame path may affect the overall
287 * behavior.
288 */
289 void SetPromisc();
290 /**
291 * Enable or disable CTS-to-self feature.
292 *
293 * \param enable true if CTS-to-self is to be supported,
294 * false otherwise
295 */
296 void SetCtsToSelfSupported(bool enable);
297
298 /**
299 * \return the MAC address associated to this MAC layer.
300 */
301 Mac48Address GetAddress() const;
302 /**
303 * \return the SSID which this MAC layer is going to try to stay in.
304 */
305 Ssid GetSsid() const;
306 /**
307 * \param address the current address of this MAC layer.
308 */
309 virtual void SetAddress(Mac48Address address);
310 /**
311 * \return the BSSID of the network the given link belongs to.
312 * \param linkId the ID of the given link
313 */
314 Mac48Address GetBssid(uint8_t linkId) const;
315 /**
316 * \param bssid the BSSID of the network that the given link belongs to.
317 * \param linkId the ID of the given link
318 */
319 void SetBssid(Mac48Address bssid, uint8_t linkId);
320
321 /**
322 * Block the transmission on the given links of all unicast frames addressed to
323 * the station with the given address for the given reason. The given MAC address
324 * must be the MLD address in case the addressed device is multi-link.
325 *
326 * \param reason the reason for blocking transmissions
327 * \param address the MAC address of the given device
328 * \param linkIds the IDs of the links to block
329 */
331 const Mac48Address& address,
332 const std::set<uint8_t>& linkIds);
333
334 /**
335 * Unblock the transmission on the given links of all unicast frames addressed to
336 * the station with the given address for the given reason. The given MAC address
337 * must be the MLD address in case the addressed device is multi-link.
338 *
339 * \param reason the reason for unblocking transmissions
340 * \param address the MAC address of the given device
341 * \param linkIds the IDs of the links to unblock
342 */
344 const Mac48Address& address,
345 const std::set<uint8_t>& linkIds);
346
347 /**
348 * Return true if packets can be forwarded to the given destination,
349 * false otherwise.
350 *
351 * \param to the address to which the packet should be sent
352 * \return whether packets can be forwarded to the given destination
353 */
354 virtual bool CanForwardPacketsTo(Mac48Address to) const = 0;
355 /**
356 * \param packet the packet to send.
357 * \param to the address to which the packet should be sent.
358 * \param from the address from which the packet should be sent.
359 *
360 * The packet should be enqueued in a TX queue, and should be
361 * dequeued as soon as the DCF function determines that
362 * access it granted to this MAC. The extra parameter "from" allows
363 * this device to operate in a bridged mode, forwarding received
364 * frames without altering the source address.
365 */
366 virtual void Enqueue(Ptr<Packet> packet, Mac48Address to, Mac48Address from);
367 /**
368 * \param packet the packet to send.
369 * \param to the address to which the packet should be sent.
370 *
371 * The packet should be enqueued in a TX queue, and should be
372 * dequeued as soon as the DCF function determines that
373 * access it granted to this MAC.
374 */
375 virtual void Enqueue(Ptr<Packet> packet, Mac48Address to) = 0;
376 /**
377 * \return if this MAC supports sending from arbitrary address.
378 *
379 * The interface may or may not support sending from arbitrary address.
380 * This function returns true if sending from arbitrary address is supported,
381 * false otherwise.
382 */
383 virtual bool SupportsSendFrom() const;
384
385 /**
386 * \param phys the physical layers attached to this MAC.
387 */
388 virtual void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys);
389 /**
390 * \param linkId the index (starting at 0) of the PHY object to retrieve
391 * \return the physical layer attached to this MAC
392 */
393 Ptr<WifiPhy> GetWifiPhy(uint8_t linkId = SINGLE_LINK_OP_ID) const;
394 /**
395 * Remove currently attached WifiPhy objects from this MAC.
396 */
397 void ResetWifiPhys();
398
399 /**
400 * \param stationManager the station manager attached to this MAC.
401 */
403 /**
404 * \param stationManagers the station managers attached to this MAC.
405 */
407 const std::vector<Ptr<WifiRemoteStationManager>>& stationManagers);
408 /**
409 * \param linkId the ID (starting at 0) of the link of the RemoteStationManager object
410 * to retrieve
411 * \return the remote station manager operating on the given link
412 */
414
415 /**
416 * This type defines the callback of a higher layer that a
417 * WifiMac(-derived) object invokes to pass a packet up the stack.
418 *
419 * \param packet the packet that has been received.
420 * \param from the MAC address of the device that sent the packet.
421 * \param to the MAC address of the device that the packet is destined for.
422 */
424
425 /**
426 * \param upCallback the callback to invoke when a packet must be
427 * forwarded up the stack.
428 */
430 /**
431 * \param linkUp the callback to invoke when the link becomes up.
432 */
433 virtual void SetLinkUpCallback(Callback<void> linkUp);
434 /**
435 * \param linkDown the callback to invoke when the link becomes down.
436 */
437 void SetLinkDownCallback(Callback<void> linkDown);
438 /* Next functions are not pure virtual so non QoS WifiMacs are not
439 * forced to implement them.
440 */
441
442 /**
443 * Notify that channel on the given link has been switched.
444 *
445 * \param linkId the ID of the given link
446 */
447 virtual void NotifyChannelSwitching(uint8_t linkId);
448
449 /**
450 * \param packet the packet being enqueued
451 *
452 * Public method used to fire a MacTx trace. Implemented for encapsulation purposes.
453 * Note this trace indicates that the packet was accepted by the device only.
454 * The packet may be dropped later (e.g. if the queue is full).
455 */
456 void NotifyTx(Ptr<const Packet> packet);
457 /**
458 * \param packet the packet being dropped
459 *
460 * Public method used to fire a MacTxDrop trace.
461 * This trace indicates that the packet was dropped before it was queued for
462 * transmission (e.g. when a STA is not associated with an AP).
463 */
464 void NotifyTxDrop(Ptr<const Packet> packet);
465 /**
466 * \param packet the packet we received
467 *
468 * Public method used to fire a MacRx trace. Implemented for encapsulation purposes.
469 */
470 void NotifyRx(Ptr<const Packet> packet);
471 /**
472 * \param packet the packet we received promiscuously
473 *
474 * Public method used to fire a MacPromiscRx trace. Implemented for encapsulation purposes.
475 */
477 /**
478 * \param packet the packet we received but is not destined for us
479 *
480 * Public method used to fire a MacRxDrop trace. Implemented for encapsulation purposes.
481 */
482 void NotifyRxDrop(Ptr<const Packet> packet);
483
484 /**
485 * \param standard the wifi standard to be configured
486 *
487 * This method completes the configuration process for a requested PHY standard
488 * by creating the Frame Exchange Manager and the Channel Access Manager and
489 * configuring the PHY dependent parameters.
490 * This method can only be called after a configured PHY has been set.
491 */
492 virtual void ConfigureStandard(WifiStandard standard);
493
494 /**
495 * \return pointer to HtConfiguration if it exists
496 */
498 /**
499 * \return pointer to VhtConfiguration if it exists
500 */
502 /**
503 * \return pointer to HeConfiguration if it exists
504 */
506 /**
507 * \return pointer to EhtConfiguration if it exists
508 */
510
511 /**
512 * Return the extended capabilities of the device.
513 *
514 * \return the extended capabilities that we support
515 */
517 /**
518 * Return the HT capabilities of the device for the given link.
519 *
520 * \param linkId the ID of the given link
521 * \return the HT capabilities that we support
522 */
523 HtCapabilities GetHtCapabilities(uint8_t linkId) const;
524 /**
525 * Return the VHT capabilities of the device for the given link.
526 *
527 * \param linkId the ID of the given link
528 * \return the VHT capabilities that we support
529 */
530 VhtCapabilities GetVhtCapabilities(uint8_t linkId) const;
531 /**
532 * Return the HE capabilities of the device for the given link.
533 *
534 * \param linkId the ID of the given link
535 * \return the HE capabilities that we support
536 */
537 HeCapabilities GetHeCapabilities(uint8_t linkId) const;
538 /**
539 * Return the EHT capabilities of the device for the given link.
540 *
541 * \param linkId the ID of the given link
542 * \return the EHT capabilities that we support
543 */
544 EhtCapabilities GetEhtCapabilities(uint8_t linkId) const;
545
546 /**
547 * Return whether the device supports QoS.
548 *
549 * \return true if QoS is supported, false otherwise
550 */
551 bool GetQosSupported() const;
552 /**
553 * Return whether the device supports ERP on the given link.
554 *
555 * \param linkId the ID of the given link
556 * \return true if ERP is supported, false otherwise
557 */
558 bool GetErpSupported(uint8_t linkId) const;
559 /**
560 * Return whether the device supports DSSS on the given link.
561 *
562 * \param linkId the ID of the given link
563 * \return true if DSSS is supported, false otherwise
564 */
565 bool GetDsssSupported(uint8_t linkId) const;
566 /**
567 * Return whether the device supports HT.
568 *
569 * \return true if HT is supported, false otherwise
570 */
571 bool GetHtSupported() const;
572 /**
573 * Return whether the device supports VHT on the given link.
574 *
575 * \param linkId the ID of the given link.
576 * \return true if VHT is supported, false otherwise
577 */
578 bool GetVhtSupported(uint8_t linkId) const;
579 /**
580 * Return whether the device supports HE.
581 *
582 * \return true if HE is supported, false otherwise
583 */
584 bool GetHeSupported() const;
585 /**
586 * Return whether the device supports EHT.
587 *
588 * \return true if EHT is supported, false otherwise
589 */
590 bool GetEhtSupported() const;
591
592 /**
593 * \param address the (link or MLD) address of a remote station
594 * \return true if the remote station with the given address supports HT
595 */
596 bool GetHtSupported(const Mac48Address& address) const;
597 /**
598 * \param address the (link or MLD) address of a remote station
599 * \return true if the remote station with the given address supports VHT
600 */
601 bool GetVhtSupported(const Mac48Address& address) const;
602 /**
603 * \param address the (link or MLD) address of a remote station
604 * \return true if the remote station with the given address supports HE
605 */
606 bool GetHeSupported(const Mac48Address& address) const;
607 /**
608 * \param address the (link or MLD) address of a remote station
609 * \return true if the remote station with the given address supports EHT
610 */
611 bool GetEhtSupported(const Mac48Address& address) const;
612
613 /**
614 * Return the maximum A-MPDU size of the given Access Category.
615 *
616 * \param ac Access Category index
617 * \return the maximum A-MPDU size
618 */
620 /**
621 * Return the maximum A-MSDU size of the given Access Category.
622 *
623 * \param ac Access Category index
624 * \return the maximum A-MSDU size
625 */
626 uint16_t GetMaxAmsduSize(AcIndex ac) const;
627
628 /// optional const reference to OriginatorBlockAckAgreement
630 std::optional<std::reference_wrapper<const OriginatorBlockAckAgreement>>;
631 /// optional const reference to RecipientBlockAckAgreement
633 std::optional<std::reference_wrapper<const RecipientBlockAckAgreement>>;
634
635 /**
636 * \param recipient (link or device) MAC address of the recipient
637 * \param tid traffic ID.
638 *
639 * \return the originator block ack agreement, if one has been established
640 *
641 * Checks if an originator block ack agreement is established with station addressed by
642 * <i>recipient</i> for TID <i>tid</i>.
643 */
645 uint8_t tid) const;
646 /**
647 * \param originator (link or device) MAC address of the originator
648 * \param tid traffic ID.
649 *
650 * \return the recipient block ack agreement, if one has been established
651 *
652 * Checks if a recipient block ack agreement is established with station addressed by
653 * <i>originator</i> for TID <i>tid</i>.
654 */
656 uint8_t tid) const;
657
658 /**
659 * \param recipient MAC address
660 * \param tid traffic ID
661 *
662 * \return the type of Block Acks sent by the recipient
663 *
664 * This function returns the type of Block Acks sent by the recipient.
665 */
666 BlockAckType GetBaTypeAsOriginator(const Mac48Address& recipient, uint8_t tid) const;
667 /**
668 * \param recipient MAC address of recipient
669 * \param tid traffic ID
670 *
671 * \return the type of Block Ack Requests sent to the recipient
672 *
673 * This function returns the type of Block Ack Requests sent to the recipient.
674 */
675 BlockAckReqType GetBarTypeAsOriginator(const Mac48Address& recipient, uint8_t tid) const;
676 /**
677 * \param originator MAC address of originator
678 * \param tid traffic ID
679 *
680 * \return the type of Block Acks sent to the originator
681 *
682 * This function returns the type of Block Acks sent to the originator.
683 */
684 BlockAckType GetBaTypeAsRecipient(Mac48Address originator, uint8_t tid) const;
685 /**
686 * \param originator MAC address of originator
687 * \param tid traffic ID
688 *
689 * \return the type of Block Ack Requests sent by the originator
690 *
691 * This function returns the type of Block Ack Requests sent by the originator.
692 */
693 BlockAckReqType GetBarTypeAsRecipient(Mac48Address originator, uint8_t tid) const;
694
695 /**
696 * Get the maximum Block Ack buffer size (in number of MPDUs) supported by the given device,
697 * if any, or by this device, otherwise, based on the supported standard.
698 *
699 * \param address the (MLD or link) address of the given device
700 * \return the maximum supported Block Ack buffer size (in number of MPDUs)
701 */
702 uint16_t GetMaxBaBufferSize(std::optional<Mac48Address> address = std::nullopt) const;
703
704 /**
705 * \param size the size (in number of MPDUs) of the buffer used for each BlockAck
706 * agreement in which this node is a recipient
707 */
708 void SetMpduBufferSize(uint16_t size);
709
710 /**
711 * \return the size (in number of MPDUs) of the buffer used for each BlockAck
712 * agreement in which this node is a recipient
713 */
714 uint16_t GetMpduBufferSize() const;
715
716 /**
717 * Get the TID-to-Link Mapping negotiated with the given MLD (if any) for the given direction.
718 * An empty mapping indicates the default mapping.
719 *
720 * \param mldAddr the MLD address of the given MLD
721 * \param dir the given direction (DL or UL)
722 * \return the negotiated TID-to-Link Mapping
723 */
724 std::optional<std::reference_wrapper<const WifiTidLinkMapping>> GetTidToLinkMapping(
725 Mac48Address mldAddr,
726 WifiDirection dir) const;
727
728 /**
729 * Check whether the given TID is mapped on the given link in the given direction for the
730 * given MLD.
731 *
732 * \param mldAddr the MLD address of the given MLD
733 * \param dir the given direction (DL or UL)
734 * \param tid the given TID
735 * \param linkId the ID of the given link
736 * \return whether the given TID is mapped on the given link in the given direction for the
737 * given MLD
738 */
739 bool TidMappedOnLink(Mac48Address mldAddr,
741 uint8_t tid,
742 uint8_t linkId) const;
743
744 protected:
745 void DoInitialize() override;
746 void DoDispose() override;
747
748 /**
749 * \param cwMin the minimum contention window size
750 * \param cwMax the maximum contention window size
751 *
752 * This method is called to set the minimum and the maximum
753 * contention window size.
754 */
755 virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax);
756
757 /**
758 * Enable or disable QoS support for the device. Construct a Txop object
759 * or QosTxop objects accordingly. This method can only be called before
760 * initialization.
761 *
762 * \param enable whether QoS is supported
763 */
764 void SetQosSupported(bool enable);
765
766 /**
767 * Enable or disable short slot time feature.
768 *
769 * \param enable true if short slot time is to be supported,
770 * false otherwise
771 */
772 void SetShortSlotTimeSupported(bool enable);
773 /**
774 * \return whether the device supports short slot time capability.
775 */
776 bool GetShortSlotTimeSupported() const;
777
778 /**
779 * Accessor for the AC_VO channel access function
780 *
781 * \return a smart pointer to QosTxop
782 */
783 Ptr<QosTxop> GetVOQueue() const;
784 /**
785 * Accessor for the AC_VI channel access function
786 *
787 * \return a smart pointer to QosTxop
788 */
789 Ptr<QosTxop> GetVIQueue() const;
790 /**
791 * Accessor for the AC_BE channel access function
792 *
793 * \return a smart pointer to QosTxop
794 */
795 Ptr<QosTxop> GetBEQueue() const;
796 /**
797 * Accessor for the AC_BK channel access function
798 *
799 * \return a smart pointer to QosTxop
800 */
801 Ptr<QosTxop> GetBKQueue() const;
802
803 /**
804 * This method acts as the MacRxMiddle receive callback and is
805 * invoked to notify us that a frame has been received on the given link.
806 * The implementation is intended to capture logic that is going to be
807 * common to all (or most) derived classes. Specifically, handling
808 * of Block Ack management frames is dealt with here.
809 *
810 * This method will need, however, to be overridden by derived
811 * classes so that they can perform their data handling before
812 * invoking the base version.
813 *
814 * The given link may be undefined in some cases (e.g., in case of
815 * QoS Data frames received in the context of a Block Ack agreement --
816 * because the BlockAckManager does not have to record the link each
817 * buffered MPDU has been received on); in such a cases, the value
818 * of <i>linkId</i> should be WIFI_LINKID_UNDEFINED.
819 *
820 * \param mpdu the MPDU that has been received.
821 * \param linkId the ID of the given link
822 */
823 virtual void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
824 /**
825 * Forward the packet up to the device.
826 *
827 * \param packet the packet that we are forwarding up to the device
828 * \param from the address of the source
829 * \param to the address of the destination
830 */
832
833 /**
834 * This method can be called to de-aggregate an A-MSDU and forward
835 * the constituent packets up the stack.
836 *
837 * \param mpdu the MPDU containing the A-MSDU.
838 */
840
841 /**
842 * Apply the TID-to-Link Mapping negotiated with the given MLD for the given direction
843 * by properly configuring the queue scheduler.
844 *
845 * \param mldAddr the MLD MAC address of the given MLD
846 * \param dir the given direction (DL or UL)
847 */
849
850 /**
851 * Swap the links based on the information included in the given map. This method
852 * is normally called by a non-AP MLD upon completing ML setup to have its link IDs
853 * match AP MLD's link IDs.
854 *
855 * \param links a set of pairs (from, to) each mapping a current link ID to the
856 * link ID it has to become (i.e., link 'from' becomes link 'to')
857 */
858 void SwapLinks(std::map<uint8_t, uint8_t> links);
859
860 /**
861 * Structure holding information specific to a single link. Here, the meaning of
862 * "link" is that of the 11be amendment which introduced multi-link devices. For
863 * previous amendments, only one link can be created. Therefore, "link" has not
864 * to be confused with the general concept of link for a NetDevice (used by the
865 * m_linkUp and m_linkDown callbacks).
866 */
868 {
869 /// Destructor (a virtual method is needed to make this struct polymorphic)
870 virtual ~LinkEntity();
871
872 Ptr<WifiPhy> phy; //!< Wifi PHY object
873 Ptr<ChannelAccessManager> channelAccessManager; //!< channel access manager object
874 Ptr<FrameExchangeManager> feManager; //!< Frame Exchange Manager object
875 Ptr<WifiRemoteStationManager> stationManager; //!< Remote station manager (rate control,
876 //!< RTS/CTS/fragmentation thresholds etc.)
877 bool erpSupported{false}; //!< set to \c true iff this WifiMac is to model 802.11g
878 bool dsssSupported{false}; //!< set to \c true iff this WifiMac is to model 802.11b
879 };
880
881 /**
882 * \return a const reference to the map of link entities
883 */
884 const std::map<uint8_t, std::unique_ptr<LinkEntity>>& GetLinks() const;
885
886 /**
887 * Get a reference to the link associated with the given ID.
888 *
889 * \param linkId the given link ID
890 * \return a reference to the link associated with the given ID
891 */
892 LinkEntity& GetLink(uint8_t linkId) const;
893
894 /**
895 * Update the TID-to-Link Mappings for the given MLD in the given direction based on the
896 * given negotiated mappings. An empty mapping indicates the default mapping.
897 *
898 * \param mldAddr the MLD address of the given MLD
899 * \param dir the given direction (DL or UL)
900 * \param mapping the negotiated TID-to-Link Mapping
901 */
902 void UpdateTidToLinkMapping(const Mac48Address& mldAddr,
904 const WifiTidLinkMapping& mapping);
905
906 Ptr<MacRxMiddle> m_rxMiddle; //!< RX middle (defragmentation etc.)
907 Ptr<MacTxMiddle> m_txMiddle; //!< TX middle (aggregation etc.)
908 Ptr<Txop> m_txop; //!< TXOP used for transmission of frames to non-QoS peers.
909 Ptr<WifiMacQueueScheduler> m_scheduler; //!< wifi MAC queue scheduler
910
911 Callback<void> m_linkUp; //!< Callback when a link is up
912 Callback<void> m_linkDown; //!< Callback when a link is down
913
914 private:
915 /**
916 * \param dcf the DCF to be configured
917 * \param cwmin the minimum contention window for the DCF
918 * \param cwmax the maximum contention window for the DCF
919 * \param isDsss vector of flags to indicate whether PHY is DSSS or HR/DSSS for every link
920 * \param ac the access category for the DCF
921 *
922 * Configure the DCF with appropriate values depending on the given access category.
923 */
924 void ConfigureDcf(Ptr<Txop> dcf,
925 uint32_t cwmin,
926 uint32_t cwmax,
927 std::list<bool> isDsss,
928 AcIndex ac);
929
930 /**
931 * Configure PHY dependent parameters such as CWmin and CWmax on the given link.
932 *
933 * \param linkId the ID of the given link
934 */
935 void ConfigurePhyDependentParameters(uint8_t linkId);
936
937 /**
938 * This method is a private utility invoked to configure the channel
939 * access function for the specified Access Category.
940 *
941 * \param ac the Access Category of the queue to initialise.
942 */
943 void SetupEdcaQueue(AcIndex ac);
944
945 /**
946 * Create a Frame Exchange Manager depending on the supported version
947 * of the standard.
948 *
949 * \param standard the supported version of the standard
950 * \return the created Frame Exchange Manager
951 */
953
954 /**
955 * Create a LinkEntity object.
956 *
957 * \return a unique pointer to the created LinkEntity object
958 */
959 virtual std::unique_ptr<LinkEntity> CreateLinkEntity() const;
960
961 /**
962 * This method is intended to be called when a link changes ID in order to update the
963 * link ID stored by the Frame Exchange Manager and the Channel Access Manager operating
964 * on that link.
965 *
966 * \param id the (new) ID of the link that has changed ID
967 */
968 void UpdateLinkId(uint8_t id);
969
970 /**
971 * This method is called if this device is an MLD to determine the MAC address of
972 * the affiliated STA used to communicate with the single link device having the
973 * given MAC address. This method is overridden because its implementation depends
974 * on the type of station.
975 *
976 * \param remoteAddr the MAC address of the remote single link device
977 * \return the MAC address of the affiliated STA used to communicate with the remote device
978 */
979 virtual Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const;
980
981 /**
982 * Enable or disable ERP support for the given link.
983 *
984 * \param enable whether ERP is supported
985 * \param linkId the ID of the given link
986 */
987 void SetErpSupported(bool enable, uint8_t linkId);
988 /**
989 * Enable or disable DSSS support for the given link.
990 *
991 * \param enable whether DSSS is supported
992 * \param linkId the ID of the given link
993 */
994 void SetDsssSupported(bool enable, uint8_t linkId);
995
996 /**
997 * Set the block ack threshold for AC_VO.
998 *
999 * \param threshold the block ack threshold for AC_VO.
1000 */
1001 void SetVoBlockAckThreshold(uint8_t threshold);
1002 /**
1003 * Set the block ack threshold for AC_VI.
1004 *
1005 * \param threshold the block ack threshold for AC_VI.
1006 */
1007 void SetViBlockAckThreshold(uint8_t threshold);
1008 /**
1009 * Set the block ack threshold for AC_BE.
1010 *
1011 * \param threshold the block ack threshold for AC_BE.
1012 */
1013 void SetBeBlockAckThreshold(uint8_t threshold);
1014 /**
1015 * Set the block ack threshold for AC_BK.
1016 *
1017 * \param threshold the block ack threshold for AC_BK.
1018 */
1019 void SetBkBlockAckThreshold(uint8_t threshold);
1020
1021 /**
1022 * Set VO block ack inactivity timeout.
1023 *
1024 * \param timeout the VO block ack inactivity timeout.
1025 */
1027 /**
1028 * Set VI block ack inactivity timeout.
1029 *
1030 * \param timeout the VI block ack inactivity timeout.
1031 */
1033 /**
1034 * Set BE block ack inactivity timeout.
1035 *
1036 * \param timeout the BE block ack inactivity timeout.
1037 */
1039 /**
1040 * Set BK block ack inactivity timeout.
1041 *
1042 * \param timeout the BK block ack inactivity timeout.
1043 */
1045
1046 /**
1047 * This Boolean is set \c true iff this WifiMac is to model
1048 * 802.11e/WMM style Quality of Service. It is exposed through the
1049 * attribute system.
1050 *
1051 * At the moment, this flag is the sole selection between QoS and
1052 * non-QoS operation for the STA (whether IBSS, AP, or
1053 * non-AP). Ultimately, we will want a QoS-enabled STA to be able to
1054 * fall back to non-QoS operation with a non-QoS peer. This'll
1055 * require further intelligence - i.e., per-association QoS
1056 * state. Having a big switch seems like a good intermediate stage,
1057 * however.
1058 */
1060
1061 bool m_shortSlotTimeSupported; ///< flag whether short slot time is supported
1062 bool m_ctsToSelfSupported; ///< flag indicating whether CTS-To-Self is supported
1063
1064 TypeOfStation m_typeOfStation; //!< the type of station
1065
1066 Ptr<WifiNetDevice> m_device; //!< Pointer to the device
1067 std::map<uint8_t, std::unique_ptr<LinkEntity>> m_links; //!< ID-indexed map of Link objects
1068 std::set<uint8_t> m_linkIds; //!< IDs of the links in use
1069
1070 Mac48Address m_address; //!< MAC address of this station
1071 Ssid m_ssid; //!< Service Set ID (SSID)
1072
1073 /** This type defines a mapping between an Access Category index,
1074 and a pointer to the corresponding channel access function.
1075 Access Categories are sorted in decreasing order of priority. */
1076 typedef std::map<AcIndex, Ptr<QosTxop>, std::greater<>> EdcaQueues;
1077
1078 /** This is a map from Access Category index to the corresponding
1079 channel access function */
1081
1082 uint16_t m_voMaxAmsduSize; ///< maximum A-MSDU size for AC_VO (in bytes)
1083 uint16_t m_viMaxAmsduSize; ///< maximum A-MSDU size for AC_VI (in bytes)
1084 uint16_t m_beMaxAmsduSize; ///< maximum A-MSDU size for AC_BE (in bytes)
1085 uint16_t m_bkMaxAmsduSize; ///< maximum A-MSDU size for AC_BK (in bytes)
1086
1087 uint32_t m_voMaxAmpduSize; ///< maximum A-MPDU size for AC_VO (in bytes)
1088 uint32_t m_viMaxAmpduSize; ///< maximum A-MPDU size for AC_VI (in bytes)
1089 uint32_t m_beMaxAmpduSize; ///< maximum A-MPDU size for AC_BE (in bytes)
1090 uint32_t m_bkMaxAmpduSize; ///< maximum A-MPDU size for AC_BK (in bytes)
1091
1092 uint16_t m_mpduBufferSize; //!< BlockAck buffer size (in number of MPDUs)
1093
1094 UniformRandomBitGenerator m_shuffleLinkIdsGen; //!< random number generator to shuffle link IDs
1095
1096 /// @brief DL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)
1097 std::unordered_map<Mac48Address, WifiTidLinkMapping, WifiAddressHash> m_dlTidLinkMappings;
1098 /// @brief UL TID-to-Link Mapping negotiated with an MLD (identified by its MLD address)
1099 std::unordered_map<Mac48Address, WifiTidLinkMapping, WifiAddressHash> m_ulTidLinkMappings;
1100
1101 ForwardUpCallback m_forwardUp; //!< Callback to forward packet up the stack
1102
1103 /**
1104 * The trace source fired when packets come into the "top" of the device
1105 * at the L3/L2 transition, before being queued for transmission.
1106 *
1107 * \see class CallBackTraceSource
1108 */
1110 /**
1111 * The trace source fired when packets coming into the "top" of the device
1112 * are dropped at the MAC layer before being queued for transmission.
1113 *
1114 * \see class CallBackTraceSource
1115 */
1117 /**
1118 * The trace source fired for packets successfully received by the device
1119 * immediately before being forwarded up to higher layers (at the L2/L3
1120 * transition). This is a promiscuous trace.
1121 *
1122 * \see class CallBackTraceSource
1123 */
1125 /**
1126 * The trace source fired for packets successfully received by the device
1127 * immediately before being forwarded up to higher layers (at the L2/L3
1128 * transition). This is a non- promiscuous trace.
1129 *
1130 * \see class CallBackTraceSource
1131 */
1133 /**
1134 * The trace source fired when packets coming into the "top" of the device
1135 * are dropped at the MAC layer during reception.
1136 *
1137 * \see class CallBackTraceSource
1138 */
1140
1141 /**
1142 * TracedCallback signature for MPDU drop events.
1143 *
1144 * \param reason the reason why the MPDU was dropped (\see WifiMacDropReason)
1145 * \param mpdu the dropped MPDU
1146 */
1148
1149 /// TracedCallback for MPDU drop events typedef
1151
1152 /**
1153 * This trace indicates that an MPDU was dropped for the given reason.
1154 */
1156
1157 /// TracedCallback for acked/nacked MPDUs typedef
1159
1160 MpduTracedCallback m_ackedMpduCallback; ///< ack'ed MPDU callback
1161 MpduTracedCallback m_nackedMpduCallback; ///< nack'ed MPDU callback
1162
1163 /**
1164 * TracedCallback signature for MPDU response timeout events.
1165 *
1166 * \param reason the reason why the timer was started
1167 * \param mpdu the MPDU whose response was not received before the timeout
1168 * \param txVector the TXVECTOR used to transmit the MPDU
1169 */
1170 typedef void (*MpduResponseTimeoutCallback)(uint8_t reason,
1172 const WifiTxVector& txVector);
1173
1174 /// TracedCallback for MPDU response timeout events typedef
1177
1178 /**
1179 * MPDU response timeout traced callback.
1180 * This trace source is fed by a WifiTxTimer object.
1181 */
1183
1184 /**
1185 * TracedCallback signature for PSDU response timeout events.
1186 *
1187 * \param reason the reason why the timer was started
1188 * \param psdu the PSDU whose response was not received before the timeout
1189 * \param txVector the TXVECTOR used to transmit the PSDU
1190 */
1191 typedef void (*PsduResponseTimeoutCallback)(uint8_t reason,
1193 const WifiTxVector& txVector);
1194
1195 /// TracedCallback for PSDU response timeout events typedef
1198
1199 /**
1200 * PSDU response timeout traced callback.
1201 * This trace source is fed by a WifiTxTimer object.
1202 */
1204
1205 /**
1206 * TracedCallback signature for PSDU map response timeout events.
1207 *
1208 * \param reason the reason why the timer was started
1209 * \param psduMap the PSDU map for which not all responses were received before the timeout
1210 * \param missingStations the MAC addresses of the stations that did not respond
1211 * \param nTotalStations the total number of stations that had to respond
1212 */
1213 typedef void (*PsduMapResponseTimeoutCallback)(uint8_t reason,
1214 WifiPsduMap* psduMap,
1215 const std::set<Mac48Address>* missingStations,
1216 std::size_t nTotalStations);
1217
1218 /// TracedCallback for PSDU map response timeout events typedef
1221
1222 /**
1223 * PSDU map response timeout traced callback.
1224 * This trace source is fed by a WifiTxTimer object.
1225 */
1227};
1228
1229} // namespace ns3
1230
1231#endif /* WIFI_MAC_H */
Callback template class.
Definition: callback.h:438
The IEEE 802.11be EHT Capabilities.
The Extended Capabilities Information Element.
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
uint16_t GetMaxAmsduSize(AcIndex ac) const
Return the maximum A-MSDU size of the given Access Category.
Definition: wifi-mac.cc:2307
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:878
Ptr< QosTxop > GetBEQueue() const
Accessor for the AC_BE channel access function.
Definition: wifi-mac.cc:547
virtual void NotifyChannelSwitching(uint8_t linkId)
Notify that channel on the given link has been switched.
Definition: wifi-mac.cc:596
std::optional< Mac48Address > GetMldAddress(const Mac48Address &remoteAddr) const
Definition: wifi-mac.cc:1663
virtual void SetMacQueueScheduler(Ptr< WifiMacQueueScheduler > scheduler)
Set the wifi MAC queue scheduler.
Definition: wifi-mac.cc:583
Mac48Address GetBssid(uint8_t linkId) const
Definition: wifi-mac.cc:492
void(* PsduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
TracedCallback signature for PSDU response timeout events.
Definition: wifi-mac.h:1191
uint16_t m_viMaxAmsduSize
maximum A-MSDU size for AC_VI (in bytes)
Definition: wifi-mac.h:1083
bool m_shortSlotTimeSupported
flag whether short slot time is supported
Definition: wifi-mac.h:1061
void ConfigurePhyDependentParameters(uint8_t linkId)
Configure PHY dependent parameters such as CWmin and CWmax on the given link.
Definition: wifi-mac.cc:809
Ptr< HeConfiguration > GetHeConfiguration() const
Definition: wifi-mac.cc:1780
DroppedMpduTracedCallback m_droppedMpduCallback
This trace indicates that an MPDU was dropped for the given reason.
Definition: wifi-mac.h:1155
TracedCallback< WifiMacDropReason, Ptr< const WifiMpdu > > DroppedMpduTracedCallback
TracedCallback for MPDU drop events typedef.
Definition: wifi-mac.h:1150
TypeOfStation GetTypeOfStation() const
Return the type of station.
Definition: wifi-mac.cc:436
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:1059
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition: wifi-mac.cc:932
Ptr< Txop > GetTxop() const
Accessor for the Txop object.
Definition: wifi-mac.cc:507
VhtCapabilities GetVhtCapabilities(uint8_t linkId) const
Return the VHT capabilities of the device for the given link.
Definition: wifi-mac.cc:2049
Callback< void > m_linkDown
Callback when a link is down.
Definition: wifi-mac.h:912
bool GetQosSupported() const
Return whether the device supports QoS.
Definition: wifi-mac.cc:1236
std::optional< std::reference_wrapper< const RecipientBlockAckAgreement > > RecipientAgreementOptConstRef
optional const reference to RecipientBlockAckAgreement
Definition: wifi-mac.h:633
virtual void SetAddress(Mac48Address address)
Definition: wifi-mac.cc:459
Ptr< Txop > m_txop
TXOP used for transmission of frames to non-QoS peers.
Definition: wifi-mac.h:908
void SetQosSupported(bool enable)
Enable or disable QoS support for the device.
Definition: wifi-mac.cc:1209
Mac48Address m_address
MAC address of this station.
Definition: wifi-mac.h:1070
std::set< uint8_t > m_linkIds
IDs of the links in use.
Definition: wifi-mac.h:1068
Ptr< WifiMacQueueScheduler > GetMacQueueScheduler() const
Get the wifi MAC queue scheduler.
Definition: wifi-mac.cc:590
uint16_t GetMpduBufferSize() const
Definition: wifi-mac.cc:1893
uint8_t GetNLinks() const
Get the number of links (can be greater than 1 for 11be devices only).
Definition: wifi-mac.cc:947
BlockAckType GetBaTypeAsRecipient(Mac48Address originator, uint8_t tid) const
Definition: wifi-mac.cc:1750
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:1009
uint16_t m_voMaxAmsduSize
maximum A-MSDU size for AC_VO (in bytes)
Definition: wifi-mac.h:1082
Ptr< MacRxMiddle > m_rxMiddle
RX middle (defragmentation etc.)
Definition: wifi-mac.h:906
Ptr< WifiMacQueueScheduler > m_scheduler
wifi MAC queue scheduler
Definition: wifi-mac.h:909
void DoInitialize() override
Initialize() implementation.
Definition: wifi-mac.cc:363
TypeOfStation m_typeOfStation
the type of station
Definition: wifi-mac.h:1064
uint16_t m_mpduBufferSize
BlockAck buffer size (in number of MPDUs)
Definition: wifi-mac.h:1092
uint32_t m_beMaxAmpduSize
maximum A-MPDU size for AC_BE (in bytes)
Definition: wifi-mac.h:1089
virtual void ConfigureStandard(WifiStandard standard)
Definition: wifi-mac.cc:762
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:1130
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:1447
Ssid GetSsid() const
Definition: wifi-mac.cc:479
void SetWifiRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager > > &stationManagers)
Definition: wifi-mac.cc:897
void SetBeBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BE.
Definition: wifi-mac.cc:1919
bool GetErpSupported(uint8_t linkId) const
Return whether the device supports ERP on the given link.
Definition: wifi-mac.cc:1242
bool GetHtSupported() const
Return whether the device supports HT.
Definition: wifi-mac.cc:1792
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to)=0
void ResetWifiPhys()
Remove currently attached WifiPhy objects from this MAC.
Definition: wifi-mac.cc:1191
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:1109
void SetErpSupported(bool enable, uint8_t linkId)
Enable or disable ERP support for the given link.
Definition: wifi-mac.cc:1248
uint32_t m_voMaxAmpduSize
maximum A-MPDU size for AC_VO (in bytes)
Definition: wifi-mac.h:1087
void(* MpduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector)
TracedCallback signature for MPDU response timeout events.
Definition: wifi-mac.h:1170
void ConfigureDcf(Ptr< Txop > dcf, uint32_t cwmin, uint32_t cwmax, std::list< bool > isDsss, AcIndex ac)
Definition: wifi-mac.cc:683
WifiMac(const WifiMac &)=delete
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition: wifi-mac.h:1066
void SetSsid(Ssid ssid)
Definition: wifi-mac.cc:472
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:959
Ptr< QosTxop > GetVOQueue() const
Accessor for the AC_VO channel access function.
Definition: wifi-mac.cc:535
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Definition: wifi-mac.cc:429
MpduTracedCallback m_ackedMpduCallback
ack'ed MPDU callback
Definition: wifi-mac.h:1160
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Definition: wifi-mac.cc:1185
void SetMpduBufferSize(uint16_t size)
Definition: wifi-mac.cc:1884
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:1401
MpduTracedCallback m_nackedMpduCallback
nack'ed MPDU callback
Definition: wifi-mac.h:1161
bool GetEhtSupported() const
Return whether the device supports EHT.
Definition: wifi-mac.cc:1811
bool GetHeSupported() const
Return whether the device supports HE.
Definition: wifi-mac.cc:1805
HtCapabilities GetHtCapabilities(uint8_t linkId) const
Return the HT capabilities of the device for the given link.
Definition: wifi-mac.cc:1990
void SetBkBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BK.
Definition: wifi-mac.cc:1929
void SetVoBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VO.
Definition: wifi-mac.cc:1899
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:975
void NotifyPromiscRx(Ptr< const Packet > packet)
Definition: wifi-mac.cc:627
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:1097
virtual bool HasFramesToTransmit(uint8_t linkId)
Check if the MAC has frames to transmit over the given link.
Definition: wifi-mac.cc:566
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
Definition: wifi-mac.cc:890
UniformRandomBitGenerator m_shuffleLinkIdsGen
random number generator to shuffle link IDs
Definition: wifi-mac.h:1094
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:1319
RecipientAgreementOptConstRef GetBaAgreementEstablishedAsRecipient(Mac48Address originator, uint8_t tid) const
Definition: wifi-mac.cc:1724
void SetBeBlockAckInactivityTimeout(uint16_t timeout)
Set BE block ack inactivity timeout.
Definition: wifi-mac.cc:1959
Ptr< EhtConfiguration > GetEhtConfiguration() const
Definition: wifi-mac.cc:1786
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:1132
bool GetVhtSupported(uint8_t linkId) const
Return whether the device supports VHT on the given link.
Definition: wifi-mac.cc:1798
void SetDsssSupported(bool enable, uint8_t linkId)
Enable or disable DSSS support for the given link.
Definition: wifi-mac.cc:1259
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:1116
TracedCallback< Ptr< const WifiMpdu > > MpduTracedCallback
TracedCallback for acked/nacked MPDUs typedef.
Definition: wifi-mac.h:1158
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Definition: wifi-mac.h:907
void NotifyTx(Ptr< const Packet > packet)
Definition: wifi-mac.cc:609
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:351
static TypeId GetTypeId()
Get the type ID.
Definition: wifi-mac.cc:69
Ptr< HtConfiguration > GetHtConfiguration() const
Definition: wifi-mac.cc:1768
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:1114
uint32_t GetMaxAmpduSize(AcIndex ac) const
Return the maximum A-MPDU size of the given Access Category.
Definition: wifi-mac.cc:2282
BlockAckReqType GetBarTypeAsRecipient(Mac48Address originator, uint8_t tid) const
Definition: wifi-mac.cc:1759
Ssid m_ssid
Service Set ID (SSID)
Definition: wifi-mac.h:1071
std::map< uint8_t, std::unique_ptr< LinkEntity > > m_links
ID-indexed map of Link objects.
Definition: wifi-mac.h:1067
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:1651
Ptr< QosTxop > GetVIQueue() const
Accessor for the AC_VI channel access function.
Definition: wifi-mac.cc:541
void SetBssid(Mac48Address bssid, uint8_t linkId)
Definition: wifi-mac.cc:485
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-mac.cc:453
Ptr< FrameExchangeManager > SetupFrameExchangeManager(WifiStandard standard)
Create a Frame Exchange Manager depending on the supported version of the standard.
Definition: wifi-mac.cc:827
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from)
Definition: wifi-mac.cc:1510
void NotifyRx(Ptr< const Packet > packet)
Definition: wifi-mac.cc:621
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:1139
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:1080
BlockAckType GetBaTypeAsOriginator(const Mac48Address &recipient, uint8_t tid) const
Definition: wifi-mac.cc:1732
MpduResponseTimeoutTracedCallback m_mpduResponseTimeoutCallback
MPDU response timeout traced callback.
Definition: wifi-mac.h:1182
void SetForwardUpCallback(ForwardUpCallback upCallback)
Definition: wifi-mac.cc:1298
PsduMapResponseTimeoutTracedCallback m_psduMapResponseTimeoutCallback
PSDU map response timeout traced callback.
Definition: wifi-mac.h:1226
ExtendedCapabilities GetExtendedCapabilities() const
Return the extended capabilities of the device.
Definition: wifi-mac.cc:1979
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:1124
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:1076
uint16_t m_bkMaxAmsduSize
maximum A-MSDU size for AC_BK (in bytes)
Definition: wifi-mac.h:1085
void SetBkBlockAckInactivityTimeout(uint16_t timeout)
Set BK block ack inactivity timeout.
Definition: wifi-mac.cc:1969
std::optional< std::reference_wrapper< const OriginatorBlockAckAgreement > > OriginatorAgreementOptConstRef
optional const reference to OriginatorBlockAckAgreement
Definition: wifi-mac.h:630
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:1099
virtual bool SupportsSendFrom() const
Definition: wifi-mac.cc:1292
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:1869
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:559
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:988
void SetViBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VI.
Definition: wifi-mac.cc:1909
void SetViBlockAckInactivityTimeout(uint16_t timeout)
Set VI block ack inactivity timeout.
Definition: wifi-mac.cc:1949
bool GetShortSlotTimeSupported() const
Definition: wifi-mac.cc:1286
BlockAckReqType GetBarTypeAsOriginator(const Mac48Address &recipient, uint8_t tid) const
Definition: wifi-mac.cc:1741
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:639
void SetLinkDownCallback(Callback< void > linkDown)
Definition: wifi-mac.cc:1312
Ptr< QosTxop > GetBKQueue() const
Accessor for the AC_BK channel access function.
Definition: wifi-mac.cc:553
~WifiMac() override
Definition: wifi-mac.cc:63
void SetPromisc()
Sets the interface in promiscuous mode.
Definition: wifi-mac.cc:498
Ptr< VhtConfiguration > GetVhtConfiguration() const
Definition: wifi-mac.cc:1774
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:633
virtual void SetLinkUpCallback(Callback< void > linkUp)
Definition: wifi-mac.cc:1305
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Definition: wifi-mac.cc:920
const std::set< uint8_t > & GetLinkIds() const
Definition: wifi-mac.cc:953
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:442
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self feature.
Definition: wifi-mac.cc:1272
Mac48Address GetLocalAddress(const Mac48Address &remoteAddr) const
Get the local MAC address used to communicate with a remote STA.
Definition: wifi-mac.cc:1676
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
Definition: wifi-mac.h:1080
uint32_t m_bkMaxAmpduSize
maximum A-MPDU size for AC_BK (in bytes)
Definition: wifi-mac.h:1090
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
Definition: wifi-mac.cc:1521
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Definition: wifi-mac.cc:660
TracedCallback< uint8_t, Ptr< const WifiPsdu >, const WifiTxVector & > PsduResponseTimeoutTracedCallback
TracedCallback for PSDU response timeout events typedef.
Definition: wifi-mac.h:1197
TracedCallback< uint8_t, Ptr< const WifiMpdu >, const WifiTxVector & > MpduResponseTimeoutTracedCallback
TracedCallback for MPDU response timeout events typedef.
Definition: wifi-mac.h:1176
OriginatorAgreementOptConstRef GetBaAgreementEstablishedAsOriginator(Mac48Address recipient, uint8_t tid) const
Definition: wifi-mac.cc:1710
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:1528
Mac48Address GetAddress() const
Definition: wifi-mac.cc:466
void(* DroppedMpduCallback)(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
TracedCallback signature for MPDU drop events.
Definition: wifi-mac.h:1147
ForwardUpCallback m_forwardUp
Callback to forward packet up the stack.
Definition: wifi-mac.h:1101
EhtCapabilities GetEhtCapabilities(uint8_t linkId) const
Return the EHT capabilities of the device for the given link.
Definition: wifi-mac.cc:2189
TracedCallback< uint8_t, WifiPsduMap *, const std::set< Mac48Address > *, std::size_t > PsduMapResponseTimeoutTracedCallback
TracedCallback for PSDU map response timeout events typedef.
Definition: wifi-mac.h:1220
Callback< void > m_linkUp
Callback when a link is up.
Definition: wifi-mac.h:911
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: wifi-mac.cc:938
HeCapabilities GetHeCapabilities(uint8_t linkId) const
Return the HE capabilities of the device for the given link.
Definition: wifi-mac.cc:2131
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:1160
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:423
PsduResponseTimeoutTracedCallback m_psduResponseTimeoutCallback
PSDU response timeout traced callback.
Definition: wifi-mac.h:1203
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
Definition: wifi-mac.cc:513
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:1213
void NotifyTxDrop(Ptr< const Packet > packet)
Definition: wifi-mac.cc:615
void DoDispose() override
Destructor implementation.
Definition: wifi-mac.cc:387
bool GetDsssSupported(uint8_t linkId) const
Return whether the device supports DSSS on the given link.
Definition: wifi-mac.cc:1266
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:884
void SetVoBlockAckInactivityTimeout(uint16_t timeout)
Set VO block ack inactivity timeout.
Definition: wifi-mac.cc:1939
virtual std::unique_ptr< LinkEntity > CreateLinkEntity() const
Create a LinkEntity object.
Definition: wifi-mac.cc:926
void SetShortSlotTimeSupported(bool enable)
Enable or disable short slot time feature.
Definition: wifi-mac.cc:1279
bool m_ctsToSelfSupported
flag indicating whether CTS-To-Self is supported
Definition: wifi-mac.h:1062
uint16_t m_beMaxAmsduSize
maximum A-MSDU size for AC_BE (in bytes)
Definition: wifi-mac.h:1084
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:1704
uint32_t m_viMaxAmpduSize
maximum A-MPDU size for AC_VI (in bytes)
Definition: wifi-mac.h:1088
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
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
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:192
WifiDirection
Wifi direction.
Definition: wifi-utils.h:43
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:74
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