A Discrete-Event Network Simulator
API
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
34class SupportedRates;
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;
51
53using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
54 std::reference_wrapper<MgtReassocRequestHeader>>;
55
63class ApWifiMac : public WifiMac
64{
65 public:
70 static TypeId GetTypeId();
71
72 ApWifiMac();
73 ~ApWifiMac() override;
74
75 void SetLinkUpCallback(Callback<void> linkUp) override;
76 bool CanForwardPacketsTo(Mac48Address to) const override;
77 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
78 void Enqueue(Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
79 bool SupportsSendFrom() const override;
80 Ptr<WifiMacQueue> GetTxopQueue(AcIndex ac) const override;
81 void ConfigureStandard(WifiStandard standard) override;
82
86 void SetBeaconInterval(Time interval);
90 Time GetBeaconInterval() const;
91
101 int64_t AssignStreams(int64_t stream);
102
111 const std::map<uint16_t, Mac48Address>& GetStaList(uint8_t linkId) const;
117 uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const;
118
127 std::optional<uint8_t> IsAssociated(const Mac48Address& address) const;
128
134 std::optional<Mac48Address> GetMldOrLinkAddressByAid(uint16_t aid) const;
135
152 uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const;
162 void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size);
172
173 protected:
180 {
182 ~ApLinkEntity() override;
183
185 std::map<uint16_t, Mac48Address> staList;
187 uint16_t numNonHtStations{0};
189 0};
191 false};
193 };
194
201 ApLinkEntity& GetLink(uint8_t linkId) const;
202
203 std::map<uint16_t, Mac48Address>
206
207 private:
208 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
209 Mac48Address DoGetLocalAddress(const Mac48Address& remoteAddr) const override;
210 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
211
223 bool ReceiveAssocRequest(const AssocReqRefVariant& assoc,
224 const Mac48Address& from,
225 uint8_t linkId);
226
238 void ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address from, uint8_t linkId);
239
248 void TxOk(Ptr<const WifiMpdu> mpdu);
258 void TxFailed(WifiMacDropReason timeoutReason, Ptr<const WifiMpdu> mpdu);
259
277 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to);
286 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
294 void SendProbeResp(Mac48Address to, uint8_t linkId);
305 using LinkIdStaAddrMap = std::map<uint8_t, Mac48Address>;
317 void SetAid(MgtAssocResponseHeader& assoc, const LinkIdStaAddrMap& linkIdStaAddrMap);
329 const Mac48Address& to,
330 uint8_t linkId);
340 void ConfigQueueScheduler(const LinkIdStaAddrMap& linkIdStaAddrMap,
341 const Mac48Address& to,
342 uint8_t linkId);
350 void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId);
357 void SendOneBeacon(uint8_t linkId);
358
365 CapabilityInformation GetCapabilities(uint8_t linkId) const;
372 ErpInformation GetErpInformation(uint8_t linkId) const;
379 EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const;
385 std::optional<MuEdcaParameterSet> GetMuEdcaParameterSet() const;
393 std::optional<ReducedNeighborReport> GetReducedNeighborReport(uint8_t linkId) const;
404 WifiMacType frameType,
412 HtOperation GetHtOperation(uint8_t linkId) const;
419 VhtOperation GetVhtOperation(uint8_t linkId) const;
426 HeOperation GetHeOperation(uint8_t linkId) const;
433 EhtOperation GetEhtOperation(uint8_t linkId) const;
441 SupportedRates GetSupportedRates(uint8_t linkId) const;
448 DsssParameterSet GetDsssParameterSet(uint8_t linkId) const;
454 void SetBeaconGeneration(bool enable);
455
465 void UpdateShortSlotTimeEnabled(uint8_t linkId);
474 void UpdateShortPreambleEnabled(uint8_t linkId);
475
484 bool GetUseNonErpProtection(uint8_t linkId) const;
485
486 void DoDispose() override;
487 void DoInitialize() override;
488
493 uint16_t GetNextAssociationId(std::list<uint8_t> linkIds);
494
504
506 struct BsrType
507 {
508 uint8_t value;
510 };
511
513 std::unordered_map<WifiAddressTidPair, BsrType, WifiAddressTidHash> m_bufferStatus;
514
521 typedef void (*AssociationCallback)(uint16_t aid, Mac48Address address);
522
525};
526
527} // namespace ns3
528
529#endif /* AP_WIFI_MAC_H */
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:64
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:142
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:495
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:179
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:242
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:126
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:217
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:305
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:482
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:499
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
Definition: ap-wifi-mac.h:521
SupportedRates 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:427
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:390
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:501
EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const
Return the EDCA Parameter Set of the current AP for the given link.
Definition: ap-wifi-mac.cc:514
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:660
HtOperation GetHtOperation(uint8_t linkId) const
Return the HT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:709
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:265
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:204
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:524
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:496
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:497
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:500
std::unordered_map< WifiAddressTidPair, BsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:513
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:910
DsssParameterSet GetDsssParameterSet(uint8_t linkId) const
Return the DSSS Parameter Set that we support on the given link.
Definition: ap-wifi-mac.cc:472
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:523
Time GetBeaconInterval() const
Definition: ap-wifi-mac.cc:198
static TypeId GetTypeId()
Get the type ID.
Definition: ap-wifi-mac.cc:56
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:629
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:410
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:503
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:234
ApLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: ap-wifi-mac.cc:148
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:886
void ConfigureStandard(WifiStandard standard) override
Definition: ap-wifi-mac.cc:154
ErpInformation GetErpInformation(uint8_t linkId) const
Return the ERP information of the current AP for the given link.
Definition: ap-wifi-mac.cc:493
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:205
VhtOperation GetVhtOperation(uint8_t linkId) const
Return the VHT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:807
~ApWifiMac() override
Definition: ap-wifi-mac.cc:120
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:856
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:561
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:420
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:289
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:169
void ConfigQueueScheduler(const LinkIdStaAddrMap &linkIdStaAddrMap, const Mac48Address &to, uint8_t linkId)
Configure the queue scheduler so that frames stored in the container queues associated with the stati...
bool GetUseNonErpProtection(uint8_t linkId) const
Return whether protection for non-ERP stations is used in the BSS corresponding to the given link.
The DSSS Parameter Set.
The EDCA Parameter Set.
EHT Operation Information Element.
Definition: eht-operation.h:67
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:447
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
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
address
Definition: first.py:40
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:54
WifiMacType
Combination of valid MAC header type/subtype.
store value and timestamp for each Buffer Status Report
Definition: ap-wifi-mac.h:507
Time timestamp
timestamp of BSR
Definition: ap-wifi-mac.h:509
uint8_t value
value of BSR
Definition: ap-wifi-mac.h:508