A Discrete-Event Network Simulator
API
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;
43
50{
57 struct Channel
58 {
59 uint16_t number{0};
61 };
62
64 using ChannelList = std::list<Channel>;
65
66 enum : uint8_t
67 {
68 ACTIVE = 0,
70 } type;
71
73 std::vector<ChannelList> channelList;
77};
78
123class StaWifiMac : public WifiMac
124{
125 public:
127 friend class ::TwoLevelAggregationTest;
129 friend class ::AmpduAggregationTest;
131 friend class ::HeAggregationTest;
133 friend class ::MultiLinkOperationsTestBase;
134
137 std::variant<MgtBeaconHeader, MgtProbeResponseHeader, MgtAssocResponseHeader>;
138
143 struct ApInfo
144 {
147 double m_snr;
150 uint8_t m_linkId;
152 std::list<std::pair<std::uint8_t, uint8_t>> m_setupLinks;
153 };
154
159 static TypeId GetTypeId();
160
161 StaWifiMac();
162 ~StaWifiMac() override;
163
172 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
173 bool CanForwardPacketsTo(Mac48Address to) const override;
174
178 void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys) override;
179
185 void SetAssocManager(Ptr<WifiAssocManager> assocManager);
186
191 void SendProbeRequest();
192
200 void ScanningTimeout(const std::optional<ApInfo>& bestAp);
201
207 bool IsAssociated() const;
208
214 std::set<uint8_t> GetSetupLinkIds() const;
215
221 uint16_t GetAssociationId() const;
222
223 void NotifyChannelSwitching(uint8_t linkId) override;
224
234 int64_t AssignStreams(int64_t stream);
235
236 protected:
243 {
245 ~StaLinkEntity() override;
246
249 std::optional<uint8_t> apLinkId;
251 std::optional<Mac48Address> bssid;
254 };
255
262 StaLinkEntity& GetLink(uint8_t linkId) const;
263
264 private:
269 {
274 REFUSED
275 };
276
282 void SetActiveProbing(bool enable);
288 bool GetActiveProbing() const;
289
299 bool CheckSupportedRates(std::variant<MgtBeaconHeader, MgtProbeResponseHeader> frame,
300 uint8_t linkId);
301
302 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
303 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
304 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
305
312 void ReceiveBeacon(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
313
320 void ReceiveProbeResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
321
328 void ReceiveAssocResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
329
340 void UpdateApInfo(const MgtFrameType& frame,
341 const Mac48Address& apAddr,
342 const Mac48Address& bssid,
343 uint8_t linkId);
344
353 std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader> GetAssociationRequest(
354 bool isReassoc,
355 uint8_t linkId) const;
356
365 void SendAssociationRequest(bool isReassoc);
375 void AssocRequestTimeout();
380 void StartScanning();
386 bool IsWaitAssocResp() const;
393 void MissedBeacons(uint8_t linkId);
400 void RestartBeaconWatchdog(Time delay, uint8_t linkId);
408 void Disassociated(uint8_t linkId);
416 SupportedRates GetSupportedRates(uint8_t linkId) const;
425 MultiLinkElement GetMultiLinkElement(bool isReassoc, uint8_t linkId) const;
431 void SetState(MacState value);
442 uint32_t cwMin,
443 uint32_t cwMax,
444 uint8_t aifsn,
445 Time txopLimit);
456 uint16_t cwMin,
457 uint16_t cwMax,
458 uint8_t aifsn,
459 Time muEdcaTimer);
466 CapabilityInformation GetCapabilities(uint8_t linkId) const;
467
472
480 WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const;
481
482 void DoInitialize() override;
483 void DoDispose() override;
484
486 uint16_t m_aid;
496
503
505 using LinkSetupCallback = void (*)(uint8_t /* link ID */, Mac48Address /* AP address */);
506};
507
515std::ostream& operator<<(std::ostream& os, const StaWifiMac::ApInfo& apInfo);
516
517} // namespace ns3
518
519#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
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:124
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:488
Ptr< WifiAssocManager > m_assocManager
Association Manager.
Definition: sta-wifi-mac.h:487
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:493
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 SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
void SetState(MacState value)
Set the current MAC state.
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
Definition: sta-wifi-mac.h:499
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:269
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.
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:52
void(*)(uint8_t, Mac48Address) LinkSetupCallback
TracedCallback signature for link setup completed/canceled events.
Definition: sta-wifi-mac.h:505
void DoDispose() override
Destructor implementation.
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:492
TracedCallback< uint8_t, Mac48Address > m_setupCompleted
link setup completed logger
Definition: sta-wifi-mac.h:498
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:497
void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys) override
void Disassociated(uint8_t linkId)
Check if any enabled link remains after the given link is disabled (because, e.g.,...
SupportedRates GetSupportedRates(uint8_t linkId) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
TracedCallback< uint8_t, Mac48Address > m_setupCanceled
link setup canceled logger
Definition: sta-wifi-mac.h:500
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 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...
Ptr< RandomVariableStream > m_probeDelay
RandomVariable used to randomize the time of the first Probe Response on each channel.
Definition: sta-wifi-mac.h:494
TracedCallback< ApInfo > m_beaconInfo
beacon info logger
Definition: sta-wifi-mac.h:502
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:486
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:485
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
void SetMuEdcaParameters(AcIndex ac, uint16_t cwMin, uint16_t cwMax, uint8_t aifsn, Time muEdcaTimer)
Set the MU EDCA parameters.
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:501
void AssocRequestTimeout()
This method is called after the association timeout occurred.
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...
void SendProbeRequest()
Forward a probe request packet to the DCF.
Time m_assocRequestTimeout
association request timeout
Definition: sta-wifi-mac.h:490
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:489
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:137
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:491
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
The Supported Rates Information Element.
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
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_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
value
Definition: second.py:41
Struct to hold information regarding observed AP through active/passive scanning.
Definition: sta-wifi-mac.h:144
std::list< std::pair< std::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:152
MgtFrameType m_frame
The body of the management frame used to update AP info.
Definition: sta-wifi-mac.h:148
WifiScanParams::Channel m_channel
The channel the management frame was received on.
Definition: sta-wifi-mac.h:149
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:146
uint8_t m_linkId
ID of the link used to communicate with the AP.
Definition: sta-wifi-mac.h:150
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:145
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:147
Struct identifying a channel to scan.
Definition: sta-wifi-mac.h:58
WifiPhyBand band
PHY band.
Definition: sta-wifi-mac.h:60
uint16_t number
channel number
Definition: sta-wifi-mac.h:59
Structure holding scan parameters.
Definition: sta-wifi-mac.h:50
std::list< Channel > ChannelList
typedef for a list of channels
Definition: sta-wifi-mac.h:64
std::vector< ChannelList > channelList
list of channels to scan, for each link
Definition: sta-wifi-mac.h:73
Time probeDelay
delay prior to transmitting a Probe Request
Definition: sta-wifi-mac.h:74
Time maxChannelTime
maximum time to spend on each channel
Definition: sta-wifi-mac.h:76
Ssid ssid
desired SSID or wildcard SSID
Definition: sta-wifi-mac.h:72
enum ns3::WifiScanParams::@75 type
indicates either active or passive scanning
Time minChannelTime
minimum time to spend on each channel
Definition: sta-wifi-mac.h:75