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 {
167 double m_snr;
170 uint8_t m_linkId;
172 std::list<std::pair<uint8_t, uint8_t>> m_setupLinks;
173 };
174
179 static TypeId GetTypeId();
180
181 StaWifiMac();
182 ~StaWifiMac() override;
183
192 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
193 bool CanForwardPacketsTo(Mac48Address to) const override;
194
198 void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys) override;
199
205 void SetAssocManager(Ptr<WifiAssocManager> assocManager);
206
212 void SetEmlsrManager(Ptr<EmlsrManager> emlsrManager);
213
218
224 void SendProbeRequest(uint8_t linkId);
225
233 void ScanningTimeout(const std::optional<ApInfo>& bestAp);
234
240 bool IsAssociated() const;
241
247 std::set<uint8_t> GetSetupLinkIds() const;
248
253 std::optional<uint8_t> GetApLinkId(uint8_t linkId) const;
254
260 uint16_t GetAssociationId() const;
261
268 void SetPowerSaveMode(const std::pair<bool, uint8_t>& enableLinkIdPair);
269
274 WifiPowerManagementMode GetPmMode(uint8_t linkId) const;
275
281 void SetPmModeAfterAssociation(uint8_t linkId);
282
289 void TxOk(Ptr<const WifiMpdu> mpdu);
290
291 void NotifyChannelSwitching(uint8_t linkId) override;
292
302 int64_t AssignStreams(int64_t stream);
303
304 protected:
311 {
313 ~StaLinkEntity() override;
314
317 std::optional<uint8_t> apLinkId;
319 std::optional<Mac48Address> bssid;
325 };
326
333 StaLinkEntity& GetLink(uint8_t linkId) const;
334
335 private:
340 {
345 REFUSED
346 };
347
353 void SetActiveProbing(bool enable);
359 bool GetActiveProbing() const;
360
370 bool CheckSupportedRates(std::variant<MgtBeaconHeader, MgtProbeResponseHeader> frame,
371 uint8_t linkId);
372
373 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
374 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
375 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
376
383 void ReceiveBeacon(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
384
391 void ReceiveProbeResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
392
399 void ReceiveAssocResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
400
411 void UpdateApInfo(const MgtFrameType& frame,
412 const Mac48Address& apAddr,
413 const Mac48Address& bssid,
414 uint8_t linkId);
415
424 std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader> GetAssociationRequest(
425 bool isReassoc,
426 uint8_t linkId) const;
427
436 void SendAssociationRequest(bool isReassoc);
446 void AssocRequestTimeout();
451 void StartScanning();
457 bool IsWaitAssocResp() const;
464 void MissedBeacons(uint8_t linkId);
471 void RestartBeaconWatchdog(Time delay, uint8_t linkId);
479 void Disassociated(uint8_t linkId);
487 AllSupportedRates GetSupportedRates(uint8_t linkId) const;
496 MultiLinkElement GetMultiLinkElement(bool isReassoc, uint8_t linkId) const;
502 void SetState(MacState value);
503
508 {
512 uint8_t aifsn;
514 };
515
522 void SetEdcaParameters(const EdcaParams& params, uint8_t linkId);
523
528 {
532 uint8_t aifsn;
534 };
535
542 void SetMuEdcaParameters(const MuEdcaParams& params, uint8_t linkId);
543
550 CapabilityInformation GetCapabilities(uint8_t linkId) const;
551
556
564 WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const;
565
566 void DoInitialize() override;
567 void DoDispose() override;
568
570 uint16_t m_aid;
582
589
591 using LinkSetupCallback = void (*)(uint8_t /* link ID */, Mac48Address /* AP address */);
592};
593
601std::ostream& operator<<(std::ostream& os, const StaWifiMac::ApInfo& apInfo);
602
603} // namespace ns3
604
605#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:573
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:571
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:578
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.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
Definition: sta-wifi-mac.h:585
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:340
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.
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:56
void(*)(uint8_t, Mac48Address) LinkSetupCallback
TracedCallback signature for link setup completed/canceled events.
Definition: sta-wifi-mac.h:591
void DoDispose() override
Destructor implementation.
void SendProbeRequest(uint8_t linkId)
Enqueue a probe request packet for transmission on the given link.
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:577
TracedCallback< uint8_t, Mac48Address > m_setupCompleted
link setup completed logger
Definition: sta-wifi-mac.h:584
std::optional< uint8_t > GetApLinkId(uint8_t linkId) const
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:583
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:586
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:581
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...
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:579
TracedCallback< ApInfo > m_beaconInfo
beacon info logger
Definition: sta-wifi-mac.h:588
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:570
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:569
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:587
void AssocRequestTimeout()
This method is called after the association timeout occurred.
Ptr< EmlsrManager > m_emlsrManager
EMLSR Manager.
Definition: sta-wifi-mac.h:572
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:575
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:574
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.
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:576
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
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:94
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
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:129
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:168
std::list< std::pair< uint8_t, uint8_t > > m_setupLinks
list of (local link ID, AP link ID) pairs identifying the links to setup between MLDs
Definition: sta-wifi-mac.h:172
WifiScanParams::Channel m_channel
The channel the management frame was received on.
Definition: sta-wifi-mac.h:169
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:166
uint8_t m_linkId
ID of the link used to communicate with the AP.
Definition: sta-wifi-mac.h:170
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:165
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:167
uint32_t cwMax
the maximum contention window size
Definition: sta-wifi-mac.h:511
AcIndex ac
the access category
Definition: sta-wifi-mac.h:509
uint32_t cwMin
the minimum contention window size
Definition: sta-wifi-mac.h:510
uint8_t aifsn
the number of slots that make up an AIFS
Definition: sta-wifi-mac.h:512
Time txopLimit
the TXOP limit
Definition: sta-wifi-mac.h:513
Time muEdcaTimer
the MU EDCA timer
Definition: sta-wifi-mac.h:533
uint8_t aifsn
the number of slots that make up an AIFS
Definition: sta-wifi-mac.h:532
uint32_t cwMin
the minimum contention window size
Definition: sta-wifi-mac.h:530
AcIndex ac
the access category
Definition: sta-wifi-mac.h:529
uint32_t cwMax
the maximum contention window size
Definition: sta-wifi-mac.h:531
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