A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sta-wifi-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006, 2009 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * Mirko Banchi <mk.banchi@gmail.com>
20 */
21
22#ifndef STA_WIFI_MAC_H
23#define STA_WIFI_MAC_H
24
25#include "mgt-headers.h"
26#include "wifi-mac.h"
27
28#include <set>
29#include <variant>
30
35
36namespace ns3
37{
38
39class SupportedRates;
40class CapabilityInformation;
41class RandomVariableStream;
42class WifiAssocManager;
43class EmlsrManager;
44
50enum class WifiScanType : uint8_t
51{
52 ACTIVE = 0,
54};
55
62{
69 struct Channel
70 {
71 uint16_t number{0};
73 };
74
76 using ChannelList = std::list<Channel>;
77
80 std::vector<ChannelList> channelList;
84};
85
92{
97};
98
143class StaWifiMac : public WifiMac
144{
145 public:
147 friend class ::TwoLevelAggregationTest;
149 friend class ::AmpduAggregationTest;
151 friend class ::HeAggregationTest;
153 friend class ::MultiLinkOperationsTestBase;
154
157 std::variant<MgtBeaconHeader, MgtProbeResponseHeader, MgtAssocResponseHeader>;
158
163 struct ApInfo
164 {
169 {
170 uint8_t localLinkId;
171 uint8_t apLinkId;
173 };
174
177 double m_snr;
180 uint8_t m_linkId;
181 std::list<SetupLinksInfo>
183 };
184
189 static TypeId GetTypeId();
190
191 StaWifiMac();
192 ~StaWifiMac() override;
193
202 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
203 bool CanForwardPacketsTo(Mac48Address to) const override;
204
208 void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys) override;
209
215 void SetAssocManager(Ptr<WifiAssocManager> assocManager);
216
222 void SetEmlsrManager(Ptr<EmlsrManager> emlsrManager);
223
228
234 void SendProbeRequest(uint8_t linkId);
235
243 void ScanningTimeout(const std::optional<ApInfo>& bestAp);
244
250 bool IsAssociated() const;
251
257 std::set<uint8_t> GetSetupLinkIds() const;
258
264 uint16_t GetAssociationId() const;
265
272 void SetPowerSaveMode(const std::pair<bool, uint8_t>& enableLinkIdPair);
273
278 WifiPowerManagementMode GetPmMode(uint8_t linkId) const;
279
285 void SetPmModeAfterAssociation(uint8_t linkId);
286
293 void TxOk(Ptr<const WifiMpdu> mpdu);
294
295 void NotifyChannelSwitching(uint8_t linkId) override;
296
303 void NotifyEmlsrModeChanged(const std::set<uint8_t>& linkIds);
304
309 bool IsEmlsrLink(uint8_t linkId) const;
310
317 void NotifySwitchingEmlsrLink(Ptr<WifiPhy> phy, uint8_t linkId);
318
325 void BlockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason);
326
333 void UnblockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason);
334
344 int64_t AssignStreams(int64_t stream);
345
346 protected:
353 {
355 ~StaLinkEntity() override;
356
359 std::optional<Mac48Address> bssid;
365 bool emlsrEnabled{false};
366 };
367
374 StaLinkEntity& GetLink(uint8_t linkId) const;
375
382 StaLinkEntity& GetStaLink(const std::unique_ptr<WifiMac::LinkEntity>& link) const;
383
384 public:
389 {
394 REFUSED
395 };
396
397 private:
403 void SetActiveProbing(bool enable);
409 bool GetActiveProbing() const;
410
420 bool CheckSupportedRates(std::variant<MgtBeaconHeader, MgtProbeResponseHeader> frame,
421 uint8_t linkId);
422
423 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
424 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
425 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
426
433 void ReceiveBeacon(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
434
441 void ReceiveProbeResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
442
449 void ReceiveAssocResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
450
461 void UpdateApInfo(const MgtFrameType& frame,
462 const Mac48Address& apAddr,
463 const Mac48Address& bssid,
464 uint8_t linkId);
465
474 std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader> GetAssociationRequest(
475 bool isReassoc,
476 uint8_t linkId) const;
477
486 void SendAssociationRequest(bool isReassoc);
496 void AssocRequestTimeout();
501 void StartScanning();
507 bool IsWaitAssocResp() const;
514 void MissedBeacons(uint8_t linkId);
521 void RestartBeaconWatchdog(Time delay, uint8_t linkId);
529 void Disassociated(uint8_t linkId);
537 AllSupportedRates GetSupportedRates(uint8_t linkId) const;
546 MultiLinkElement GetMultiLinkElement(bool isReassoc, uint8_t linkId) const;
547
552 std::vector<TidToLinkMapping> GetTidToLinkMappingElements(uint8_t apNegSupport);
553
559 void SetState(MacState value);
560
565 {
569 uint8_t aifsn;
571 };
572
579 void SetEdcaParameters(const EdcaParams& params, uint8_t linkId);
580
585 {
589 uint8_t aifsn;
591 };
592
599 void SetMuEdcaParameters(const MuEdcaParams& params, uint8_t linkId);
600
607 CapabilityInformation GetCapabilities(uint8_t linkId) const;
608
613
621 WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const;
622
623 void DoInitialize() override;
624 void DoDispose() override;
625
627 uint16_t m_aid;
639
644
651
653 using LinkSetupCallback = void (*)(uint8_t /* link ID */, Mac48Address /* AP address */);
654};
655
663std::ostream& operator<<(std::ostream& os, const StaWifiMac::ApInfo& apInfo);
664
665} // namespace ns3
666
667#endif /* STA_WIFI_MAC_H */
Ampdu Aggregation Test.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negotiated buffer ...
Two Level Aggregation Test.
An identifier for simulation events.
Definition: event-id.h:55
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:144
std::set< uint8_t > GetSetupLinkIds() const
Get the IDs of the setup links (if any).
void ScanningTimeout(const std::optional< ApInfo > &bestAp)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
Time m_waitBeaconTimeout
wait beacon timeout
Definition: sta-wifi-mac.h:630
void SetPowerSaveMode(const std::pair< bool, uint8_t > &enableLinkIdPair)
Enable or disable Power Save mode on the given link.
Ptr< WifiAssocManager > m_assocManager
Association Manager.
Definition: sta-wifi-mac.h:628
void MissedBeacons(uint8_t linkId)
This method is called after we have not received a beacon from the AP on the given link.
bool m_activeProbing
active probing
Definition: sta-wifi-mac.h:635
void DoInitialize() override
Initialize() implementation.
void SetAssocManager(Ptr< WifiAssocManager > assocManager)
Set the Association Manager.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
void SetState(MacState value)
Set the current MAC state.
AllSupportedRates GetSupportedRates(uint8_t linkId) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
void SetEdcaParameters(const EdcaParams &params, uint8_t linkId)
Set the EDCA parameters for the given link.
void UnblockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason)
Unblock transmissions on the given link for the given reason.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
Definition: sta-wifi-mac.h:647
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:389
void NotifyChannelSwitching(uint8_t linkId) override
Notify that channel on the given link has been switched.
bool GetActiveProbing() const
Return whether active probing is enabled.
void PhyCapabilitiesChanged()
Indicate that PHY capabilities have changed.
StaLinkEntity & GetStaLink(const std::unique_ptr< WifiMac::LinkEntity > &link) const
Cast the given LinkEntity object to StaLinkEntity.
void ReceiveProbeResp(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Probe Response frame received on the given link.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetPmModeAfterAssociation(uint8_t linkId)
Set the Power Management mode of the setup links after association.
WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const
Get the current primary20 channel used on the given link as a (channel number, PHY band) pair.
uint16_t GetAssociationId() const
Return the association ID.
void TryToEnsureAssociated()
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
void ReceiveAssocResp(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the (Re)Association Response frame received on the given link.
void RestartBeaconWatchdog(Time delay, uint8_t linkId)
Restarts the beacon timer for the given link.
std::variant< MgtAssocRequestHeader, MgtReassocRequestHeader > GetAssociationRequest(bool isReassoc, uint8_t linkId) const
Get the (Re)Association Request frame to send on a given link.
static TypeId GetTypeId()
Get the type ID.
Definition: sta-wifi-mac.cc:57
void(*)(uint8_t, Mac48Address) LinkSetupCallback
TracedCallback signature for link setup completed/canceled events.
Definition: sta-wifi-mac.h:653
void DoDispose() override
Destructor implementation.
void SendProbeRequest(uint8_t linkId)
Enqueue a probe request packet for transmission on the given link.
void BlockTxOnLink(uint8_t linkId, WifiQueueBlockedReason reason)
Block transmissions on the given link for the given reason.
StaLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:634
TracedCallback< uint8_t, Mac48Address > m_setupCompleted
link setup completed logger
Definition: sta-wifi-mac.h:646
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:645
void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys) override
void SetMuEdcaParameters(const MuEdcaParams &params, uint8_t linkId)
Set the MU EDCA parameters for the given link.
void Disassociated(uint8_t linkId)
Check if any enabled link remains after the given link is disabled (because, e.g.,...
TracedCallback< uint8_t, Mac48Address > m_setupCanceled
link setup canceled logger
Definition: sta-wifi-mac.h:648
void NotifyEmlsrModeChanged(const std::set< uint8_t > &linkIds)
Notify the MAC that EMLSR mode has changed on the given set of links.
bool CheckSupportedRates(std::variant< MgtBeaconHeader, MgtProbeResponseHeader > frame, uint8_t linkId)
Determine whether the supported rates indicated in a given Beacon frame or Probe Response frame fit w...
Mac48Address DoGetLocalAddress(const Mac48Address &remoteAddr) const override
This method is called if this device is an MLD to determine the MAC address of the affiliated STA use...
void SetEmlsrManager(Ptr< EmlsrManager > emlsrManager)
Set the EMLSR Manager.
Time m_pmModeSwitchTimeout
PM mode switch timeout.
Definition: sta-wifi-mac.h:638
Ptr< EmlsrManager > GetEmlsrManager() const
void TxOk(Ptr< const WifiMpdu > mpdu)
Notify that the MPDU we sent was successfully received by the receiver (i.e.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
WifiTidLinkMapping m_ulTidLinkMappingInAssocReq
store the UL TID-to-Link Mapping included in the Association Request frame
Definition: sta-wifi-mac.h:643
WifiPowerManagementMode GetPmMode(uint8_t linkId) const
Ptr< RandomVariableStream > m_probeDelay
RandomVariable used to randomize the time of the first Probe Response on each channel.
Definition: sta-wifi-mac.h:636
TracedCallback< ApInfo > m_beaconInfo
beacon info logger
Definition: sta-wifi-mac.h:650
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:627
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:626
bool IsEmlsrLink(uint8_t linkId) const
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void StartScanning()
Start the scanning process which trigger active or passive scanning based on the active probing flag.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Definition: sta-wifi-mac.h:649
void AssocRequestTimeout()
This method is called after the association timeout occurred.
void NotifySwitchingEmlsrLink(Ptr< WifiPhy > phy, uint8_t linkId)
Notify that the given PHY switched channel to operate on another EMLSR link.
Ptr< EmlsrManager > m_emlsrManager
EMLSR Manager.
Definition: sta-wifi-mac.h:629
void UpdateApInfo(const MgtFrameType &frame, const Mac48Address &apAddr, const Mac48Address &bssid, uint8_t linkId)
Update associated AP's information from the given management frame (Beacon, Probe Response or Associa...
Time m_assocRequestTimeout
association request timeout
Definition: sta-wifi-mac.h:632
void ReceiveBeacon(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Beacon frame received on the given link.
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:631
void SetActiveProbing(bool enable)
Enable or disable active probing.
CapabilityInformation GetCapabilities(uint8_t linkId) const
Return the Capability information for the given link.
bool IsAssociated() const
Return whether we are associated with an AP.
~StaWifiMac() override
std::variant< MgtBeaconHeader, MgtProbeResponseHeader, MgtAssocResponseHeader > MgtFrameType
type of the management frames used to get info about APs
Definition: sta-wifi-mac.h:157
bool IsWaitAssocResp() const
Return whether we are waiting for an association response from an AP.
std::vector< TidToLinkMapping > GetTidToLinkMappingElements(uint8_t apNegSupport)
MultiLinkElement GetMultiLinkElement(bool isReassoc, uint8_t linkId) const
Return the Multi-Link Element to include in the management frames transmitted on the given link.
EventId m_assocRequestEvent
association request event
Definition: sta-wifi-mac.h:633
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
WifiTidLinkMapping m_dlTidLinkMappingInAssocReq
store the DL TID-to-Link Mapping included in the Association Request frame
Definition: sta-wifi-mac.h:641
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:96
WifiScanType
Scan type (active or passive)
Definition: sta-wifi-mac.h:51
WifiPowerManagementMode
Enumeration for power management modes.
Definition: sta-wifi-mac.h:92
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
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:72
@ WIFI_PM_SWITCHING_TO_ACTIVE
Definition: sta-wifi-mac.h:96
@ WIFI_PM_POWERSAVE
Definition: sta-wifi-mac.h:95
@ WIFI_PM_SWITCHING_TO_PS
Definition: sta-wifi-mac.h:94
@ WIFI_PM_ACTIVE
Definition: sta-wifi-mac.h:93
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
Definition: wifi-phy-band.h:43
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
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
Struct containing all supported rates.
Struct to hold information regarding observed AP through active/passive scanning.
Definition: sta-wifi-mac.h:164
MgtFrameType m_frame
The body of the management frame used to update AP info.
Definition: sta-wifi-mac.h:178
WifiScanParams::Channel m_channel
The channel the management frame was received on.
Definition: sta-wifi-mac.h:179
std::list< SetupLinksInfo > m_setupLinks
information about the links to setup between MLDs
Definition: sta-wifi-mac.h:182
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:176
uint8_t m_linkId
ID of the link used to communicate with the AP.
Definition: sta-wifi-mac.h:180
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:175
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:177
uint32_t cwMax
the maximum contention window size
Definition: sta-wifi-mac.h:568
AcIndex ac
the access category
Definition: sta-wifi-mac.h:566
uint32_t cwMin
the minimum contention window size
Definition: sta-wifi-mac.h:567
uint8_t aifsn
the number of slots that make up an AIFS
Definition: sta-wifi-mac.h:569
Time txopLimit
the TXOP limit
Definition: sta-wifi-mac.h:570
Time muEdcaTimer
the MU EDCA timer
Definition: sta-wifi-mac.h:590
uint8_t aifsn
the number of slots that make up an AIFS
Definition: sta-wifi-mac.h:589
uint32_t cwMin
the minimum contention window size
Definition: sta-wifi-mac.h:587
AcIndex ac
the access category
Definition: sta-wifi-mac.h:586
uint32_t cwMax
the maximum contention window size
Definition: sta-wifi-mac.h:588
Struct identifying a channel to scan.
Definition: sta-wifi-mac.h:70
WifiPhyBand band
PHY band.
Definition: sta-wifi-mac.h:72
uint16_t number
channel number
Definition: sta-wifi-mac.h:71
Structure holding scan parameters.
Definition: sta-wifi-mac.h:62
std::list< Channel > ChannelList
typedef for a list of channels
Definition: sta-wifi-mac.h:76
std::vector< ChannelList > channelList
list of channels to scan, for each link
Definition: sta-wifi-mac.h:80
Time probeDelay
delay prior to transmitting a Probe Request
Definition: sta-wifi-mac.h:81
WifiScanType type
indicates either active or passive scanning
Definition: sta-wifi-mac.h:78
Time maxChannelTime
maximum time to spend on each channel
Definition: sta-wifi-mac.h:83
Ssid ssid
desired SSID or wildcard SSID
Definition: sta-wifi-mac.h:79
Time minChannelTime
minimum time to spend on each channel
Definition: sta-wifi-mac.h:82