A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ap-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 AP_WIFI_MAC_H
23#define AP_WIFI_MAC_H
24
25#include "wifi-mac-header.h"
26#include "wifi-mac.h"
27
28#include <unordered_map>
29#include <variant>
30
31namespace ns3
32{
33
34struct AllSupportedRates;
35class CapabilityInformation;
36class DsssParameterSet;
37class ErpInformation;
38class EdcaParameterSet;
39class MuEdcaParameterSet;
40class ReducedNeighborReport;
41class MultiLinkElement;
42class HtOperation;
43class VhtOperation;
44class HeOperation;
45class EhtOperation;
46class CfParameterSet;
47class UniformRandomVariable;
48class MgtAssocRequestHeader;
49class MgtReassocRequestHeader;
50class MgtAssocResponseHeader;
51class MgtEmlOperatingModeNotification;
52
54using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
55 std::reference_wrapper<MgtReassocRequestHeader>>;
56
64class ApWifiMac : public WifiMac
65{
66 public:
71 static TypeId GetTypeId();
72
73 ApWifiMac();
74 ~ApWifiMac() override;
75
76 void SetLinkUpCallback(Callback<void> linkUp) override;
77 bool CanForwardPacketsTo(Mac48Address to) const override;
78 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
79 void Enqueue(Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
80 bool SupportsSendFrom() const override;
81 Ptr<WifiMacQueue> GetTxopQueue(AcIndex ac) const override;
82 void ConfigureStandard(WifiStandard standard) override;
83
87 void SetBeaconInterval(Time interval);
91 Time GetBeaconInterval() const;
92
102 int64_t AssignStreams(int64_t stream);
103
112 const std::map<uint16_t, Mac48Address>& GetStaList(uint8_t linkId) const;
118 uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const;
119
128 std::optional<uint8_t> IsAssociated(const Mac48Address& address) const;
129
135 std::optional<Mac48Address> GetMldOrLinkAddressByAid(uint16_t aid) const;
136
153 uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const;
163 void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size);
172 uint8_t GetMaxBufferStatus(Mac48Address address) const;
173
174 protected:
181 {
183 ~ApLinkEntity() override;
184
186 std::map<uint16_t, Mac48Address> staList;
188 uint16_t numNonHtStations{0};
190 0};
192 false};
194 };
195
202 ApLinkEntity& GetLink(uint8_t linkId) const;
203
204 std::map<uint16_t, Mac48Address>
207
208 private:
209 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
210 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
211 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
212
224 bool ReceiveAssocRequest(const AssocReqRefVariant& assoc,
225 const Mac48Address& from,
226 uint8_t linkId);
227
239 void ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address from, uint8_t linkId);
240
250 const Mac48Address& sender,
251 uint8_t linkId);
252
261 void TxOk(Ptr<const WifiMpdu> mpdu);
271 void TxFailed(WifiMacDropReason timeoutReason, Ptr<const WifiMpdu> mpdu);
272
290 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to);
299 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
307 void SendProbeResp(Mac48Address to, uint8_t linkId);
318 using LinkIdStaAddrMap = std::map<uint8_t, Mac48Address>;
330 void SetAid(MgtAssocResponseHeader& assoc, const LinkIdStaAddrMap& linkIdStaAddrMap);
342 const Mac48Address& to,
343 uint8_t linkId);
351 void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId);
358 void SendOneBeacon(uint8_t linkId);
359
367 void ProcessPowerManagementFlag(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
375 void StaSwitchingToPsMode(const Mac48Address& staAddr, uint8_t linkId);
383 void StaSwitchingToActiveModeOrDeassociated(const Mac48Address& staAddr, uint8_t linkId);
384
391 CapabilityInformation GetCapabilities(uint8_t linkId) const;
398 ErpInformation GetErpInformation(uint8_t linkId) const;
405 EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const;
411 std::optional<MuEdcaParameterSet> GetMuEdcaParameterSet() const;
419 std::optional<ReducedNeighborReport> GetReducedNeighborReport(uint8_t linkId) const;
430 WifiMacType frameType,
438 HtOperation GetHtOperation(uint8_t linkId) const;
445 VhtOperation GetVhtOperation(uint8_t linkId) const;
452 HeOperation GetHeOperation(uint8_t linkId) const;
459 EhtOperation GetEhtOperation(uint8_t linkId) const;
467 AllSupportedRates GetSupportedRates(uint8_t linkId) const;
474 DsssParameterSet GetDsssParameterSet(uint8_t linkId) const;
480 void SetBeaconGeneration(bool enable);
481
491 void UpdateShortSlotTimeEnabled(uint8_t linkId);
500 void UpdateShortPreambleEnabled(uint8_t linkId);
501
510 bool GetUseNonErpProtection(uint8_t linkId) const;
511
512 void DoDispose() override;
513 void DoInitialize() override;
514
519 uint16_t GetNextAssociationId(std::list<uint8_t> linkIds);
520
531 std::map<Mac48Address, EventId> m_transitionTimeoutEvents;
532
534 struct BsrType
535 {
536 uint8_t value;
538 };
539
541 std::unordered_map<WifiAddressTidPair, BsrType, WifiAddressTidHash> m_bufferStatus;
542
549 typedef void (*AssociationCallback)(uint16_t aid, Mac48Address address);
550
553};
554
555} // namespace ns3
556
557#endif /* AP_WIFI_MAC_H */
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:65
void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId)
Forward an association or a reassociation response packet to the DCF/EDCA.
uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const
std::unique_ptr< LinkEntity > CreateLinkEntity() const override
Create a LinkEntity object.
Definition: ap-wifi-mac.cc:143
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:521
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:180
void ParseReportedStaInfo(const AssocReqRefVariant &assoc, Mac48Address from, uint8_t linkId)
Given a (Re)Association Request frame body containing a Multi-Link Element, check if a link can be se...
void UpdateShortSlotTimeEnabled(uint8_t linkId)
Update whether short slot time should be enabled or not in the BSS corresponding to the given link.
Definition: ap-wifi-mac.cc:243
const std::map< uint16_t, Mac48Address > & GetStaList(uint8_t linkId) const
Get a const reference to the map of associated stations on the given link.
void DoDispose() override
Destructor implementation.
Definition: ap-wifi-mac.cc:127
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:218
bool ReceiveAssocRequest(const AssocReqRefVariant &assoc, const Mac48Address &from, uint8_t linkId)
Check whether the supported rate set included in the received (Re)Association Request frame is compat...
std::map< uint8_t, Mac48Address > LinkIdStaAddrMap
Map of (link ID, remote STA address) of the links to setup.
Definition: ap-wifi-mac.h:318
std::map< Mac48Address, EventId > m_transitionTimeoutEvents
transition timeout events running for EMLSR clients
Definition: ap-wifi-mac.h:531
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...
CapabilityInformation GetCapabilities(uint8_t linkId) const
Return the Capability information of the current AP for the given link.
Definition: ap-wifi-mac.cc:483
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:525
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
Definition: ap-wifi-mac.h:549
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:391
bool m_enableNonErpProtection
Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS.
Definition: ap-wifi-mac.h:527
EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const
Return the EDCA Parameter Set of the current AP for the given link.
Definition: ap-wifi-mac.cc:515
void StaSwitchingToActiveModeOrDeassociated(const Mac48Address &staAddr, uint8_t linkId)
Perform the necessary actions when a given station deassociates or switches from powersave mode to ac...
MultiLinkElement GetMultiLinkElement(uint8_t linkId, WifiMacType frameType, const Mac48Address &to=Mac48Address::GetBroadcast())
Return the Multi-Link Element that the current AP includes in the management frames of the given type...
Definition: ap-wifi-mac.cc:661
HtOperation GetHtOperation(uint8_t linkId) const
Return the HT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:728
std::optional< Mac48Address > GetMldOrLinkAddressByAid(uint16_t aid) const
void UpdateShortPreambleEnabled(uint8_t linkId)
Update whether short preamble should be enabled or not in the BSS corresponding to the given link.
Definition: ap-wifi-mac.cc:266
void TxOk(Ptr< const WifiMpdu > mpdu)
The packet we sent was successfully received by the receiver (i.e.
std::map< uint16_t, Mac48Address > m_aidToMldOrLinkAddress
Maps AIDs to MLD addresses (for MLDs) or link addresses (in case of single link devices)
Definition: ap-wifi-mac.h:205
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:552
LinkIdStaAddrMap GetLinkIdStaAddrMap(MgtAssocResponseHeader &assoc, const Mac48Address &to, uint8_t linkId)
Get a map of (link ID, remote STA address) of the links to setup.
void SetAid(MgtAssocResponseHeader &assoc, const LinkIdStaAddrMap &linkIdStaAddrMap)
Set the AID field of the given Association Response frame.
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:522
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:523
uint16_t GetNextAssociationId(std::list< uint8_t > linkIds)
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
Definition: ap-wifi-mac.h:526
std::unordered_map< WifiAddressTidPair, BsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:541
void SendProbeResp(Mac48Address to, uint8_t linkId)
Send a Probe Response in response to a Probe Request received from the STA with the given address on ...
Definition: ap-wifi-mac.cc:929
DsssParameterSet GetDsssParameterSet(uint8_t linkId) const
Return the DSSS Parameter Set that we support on the given link.
Definition: ap-wifi-mac.cc:473
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:551
Time GetBeaconInterval() const
Definition: ap-wifi-mac.cc:199
static TypeId GetTypeId()
Get the type ID.
Definition: ap-wifi-mac.cc:57
std::optional< ReducedNeighborReport > GetReducedNeighborReport(uint8_t linkId) const
Return the Reduced Neighbor Report (RNR) element that the current AP sends on the given link,...
Definition: ap-wifi-mac.cc:630
void ReceiveEmlNotification(MgtEmlOperatingModeNotification &frame, const Mac48Address &sender, uint8_t linkId)
Take necessary actions upon receiving the given EML Operating Mode Notification frame from the given ...
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:411
uint8_t GetMaxBufferStatus(Mac48Address address) const
Return the maximum among the values of the Queue Size subfield of the last QoS Data or QoS Null frame...
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:529
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: ap-wifi-mac.cc:235
ApLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: ap-wifi-mac.cc:149
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...
uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const
Return the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the ...
EhtOperation GetEhtOperation(uint8_t linkId) const
Return the EHT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:905
void ConfigureStandard(WifiStandard standard) override
Definition: ap-wifi-mac.cc:155
ErpInformation GetErpInformation(uint8_t linkId) const
Return the ERP information of the current AP for the given link.
Definition: ap-wifi-mac.cc:494
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:206
VhtOperation GetVhtOperation(uint8_t linkId) const
Return the VHT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:826
~ApWifiMac() override
Definition: ap-wifi-mac.cc:121
void TxFailed(WifiMacDropReason timeoutReason, Ptr< const WifiMpdu > mpdu)
The packet we sent was successfully received by the receiver (i.e.
HeOperation GetHeOperation(uint8_t linkId) const
Return the HE operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:875
void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size)
Store the value of the Queue Size subfield of the last QoS Data or QoS Null frame received from the s...
std::optional< MuEdcaParameterSet > GetMuEdcaParameterSet() const
Return the MU EDCA Parameter Set of the current AP, if one needs to be advertised.
Definition: ap-wifi-mac.cc:562
void ProcessPowerManagementFlag(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Process the Power Management bit in the Frame Control field of an MPDU successfully received on the g...
void DeaggregateAmsduAndForward(Ptr< const WifiMpdu > mpdu) override
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
bool SupportsSendFrom() const override
Definition: ap-wifi-mac.cc:421
MgtAssocResponseHeader GetAssocResp(Mac48Address to, uint8_t linkId)
Get the Association Response frame to send on a given link.
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:290
void DoInitialize() override
Initialize() implementation.
std::optional< uint8_t > IsAssociated(const Mac48Address &address) const
Get the ID of a link (if any) that has been setup with the station having the given MAC address.
void SendOneBeacon(uint8_t linkId)
Forward a beacon packet to the beacon special DCF for transmission on the given link.
Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const override
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Definition: ap-wifi-mac.cc:170
bool GetUseNonErpProtection(uint8_t linkId) const
Return whether protection for non-ERP stations is used in the BSS corresponding to the given link.
void StaSwitchingToPsMode(const Mac48Address &staAddr, uint8_t linkId)
Perform the necessary actions when a given station switches from active mode to powersave mode.
AllSupportedRates GetSupportedRates(uint8_t linkId) const
Return an instance of SupportedRates that contains all rates that we support for the given link (incl...
Definition: ap-wifi-mac.cc:428
Callback template class.
Definition: callback.h:438
The DSSS Parameter Set.
The EDCA Parameter Set.
EHT Operation Information Element.
Definition: eht-operation.h:66
The ErpInformation Information Element.
An identifier for simulation events.
Definition: event-id.h:55
The HE Operation Information Element.
Definition: he-operation.h:36
The HT Operation Information Element.
Definition: ht-operation.h:51
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:338
Implement the header for Action frames of type EML Operating Mode Notification.
Definition: mgt-headers.h:1113
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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
The VHT Operation Information Element.
Definition: vht-operation.h:36
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:94
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:75
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:72
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::variant< std::reference_wrapper< MgtAssocRequestHeader >, std::reference_wrapper< MgtReassocRequestHeader > > AssocReqRefVariant
variant holding a reference to a (Re)Association Request
Definition: ap-wifi-mac.h:55
WifiMacType
Combination of valid MAC header type/subtype.
Struct containing all supported rates.
store value and timestamp for each Buffer Status Report
Definition: ap-wifi-mac.h:535
Time timestamp
timestamp of BSR
Definition: ap-wifi-mac.h:537
uint8_t value
value of BSR
Definition: ap-wifi-mac.h:536