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 <variant>
29
33
34namespace ns3
35{
36
37class SupportedRates;
38class CapabilityInformation;
39class RandomVariableStream;
40class WifiAssocManager;
41
48{
55 struct Channel
56 {
57 uint16_t number{0};
59 };
60
62 using ChannelList = std::list<Channel>;
63
64 enum : uint8_t
65 {
66 ACTIVE = 0,
68 } type;
69
71 std::vector<ChannelList> channelList;
75};
76
121class StaWifiMac : public WifiMac
122{
123 public:
125 friend class ::TwoLevelAggregationTest;
127 friend class ::AmpduAggregationTest;
129 friend class ::HeAggregationTest;
130
133 std::variant<MgtBeaconHeader, MgtProbeResponseHeader, MgtAssocResponseHeader>;
134
139 struct ApInfo
140 {
143 double m_snr;
146 uint8_t m_linkId;
148 std::list<std::pair<std::uint8_t, uint8_t>> m_setupLinks;
149 };
150
155 static TypeId GetTypeId();
156
157 StaWifiMac();
158 ~StaWifiMac() override;
159
168 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
169 bool CanForwardPacketsTo(Mac48Address to) const override;
170
174 void SetWifiPhys(const std::vector<Ptr<WifiPhy>>& phys) override;
175
181 void SetAssocManager(Ptr<WifiAssocManager> assocManager);
182
187 void SendProbeRequest();
188
196 void ScanningTimeout(const std::optional<ApInfo>& bestAp);
197
203 bool IsAssociated() const;
204
210 uint16_t GetAssociationId() const;
211
212 void NotifyChannelSwitching(uint8_t linkId) override;
213
223 int64_t AssignStreams(int64_t stream);
224
225 protected:
232 {
234 ~StaLinkEntity() override;
235
238 std::optional<uint8_t> apLinkId;
240 std::optional<Mac48Address> bssid;
243 };
244
251 StaLinkEntity& GetLink(uint8_t linkId) const;
252
253 private:
258 {
263 REFUSED
264 };
265
271 void SetActiveProbing(bool enable);
277 bool GetActiveProbing() const;
278
288 bool CheckSupportedRates(std::variant<MgtBeaconHeader, MgtProbeResponseHeader> frame,
289 uint8_t linkId);
290
291 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
292 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
293
300 void ReceiveBeacon(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
301
308 void ReceiveProbeResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
309
316 void ReceiveAssocResp(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
317
328 void UpdateApInfo(const MgtFrameType& frame,
329 const Mac48Address& apAddr,
330 const Mac48Address& bssid,
331 uint8_t linkId);
332
341 std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader> GetAssociationRequest(
342 bool isReassoc,
343 uint8_t linkId) const;
344
353 void SendAssociationRequest(bool isReassoc);
363 void AssocRequestTimeout();
368 void StartScanning();
374 bool IsWaitAssocResp() const;
381 void MissedBeacons(uint8_t linkId);
388 void RestartBeaconWatchdog(Time delay, uint8_t linkId);
396 void Disassociated(uint8_t linkId);
404 SupportedRates GetSupportedRates(uint8_t linkId) const;
413 MultiLinkElement GetMultiLinkElement(bool isReassoc, uint8_t linkId) const;
419 void SetState(MacState value);
430 uint32_t cwMin,
431 uint32_t cwMax,
432 uint8_t aifsn,
433 Time txopLimit);
444 uint16_t cwMin,
445 uint16_t cwMax,
446 uint8_t aifsn,
447 Time muEdcaTimer);
454 CapabilityInformation GetCapabilities(uint8_t linkId) const;
455
460
468 WifiScanParams::Channel GetCurrentChannel(uint8_t linkId) const;
469
470 void DoInitialize() override;
471 void DoDispose() override;
472
474 uint16_t m_aid;
484
491
493 using LinkSetupCallback = void (*)(uint8_t /* link ID */, Mac48Address /* AP address */);
494};
495
503std::ostream& operator<<(std::ostream& os, const StaWifiMac::ApInfo& apInfo);
504
505} // namespace ns3
506
507#endif /* STA_WIFI_MAC_H */
Ampdu Aggregation Test.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated 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:122
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:476
Ptr< WifiAssocManager > m_assocManager
Association Manager.
Definition: sta-wifi-mac.h:475
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:481
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:487
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:258
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:493
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:480
TracedCallback< uint8_t, Mac48Address > m_setupCompleted
link setup completed logger
Definition: sta-wifi-mac.h:486
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:485
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:488
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...
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:482
TracedCallback< ApInfo > m_beaconInfo
beacon info logger
Definition: sta-wifi-mac.h:490
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:474
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:473
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:489
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:478
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:477
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:133
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:479
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:60
base class for all MAC-level wifi objects.
Definition: 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:74
@ 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:140
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:148
MgtFrameType m_frame
The body of the management frame used to update AP info.
Definition: sta-wifi-mac.h:144
WifiScanParams::Channel m_channel
The channel the management frame was received on.
Definition: sta-wifi-mac.h:145
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:142
uint8_t m_linkId
ID of the link used to communicate with the AP.
Definition: sta-wifi-mac.h:146
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:141
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:143
Struct identifying a channel to scan.
Definition: sta-wifi-mac.h:56
WifiPhyBand band
PHY band.
Definition: sta-wifi-mac.h:58
uint16_t number
channel number
Definition: sta-wifi-mac.h:57
Structure holding scan parameters.
Definition: sta-wifi-mac.h:48
std::list< Channel > ChannelList
typedef for a list of channels
Definition: sta-wifi-mac.h:62
std::vector< ChannelList > channelList
list of channels to scan, for each link
Definition: sta-wifi-mac.h:71
Time probeDelay
delay prior to transmitting a Probe Request
Definition: sta-wifi-mac.h:72
Time maxChannelTime
maximum time to spend on each channel
Definition: sta-wifi-mac.h:74
Ssid ssid
desired SSID or wildcard SSID
Definition: sta-wifi-mac.h:70
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:73