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 CfParameterSet;
46class UniformRandomVariable;
47class MgtAssocRequestHeader;
48class MgtReassocRequestHeader;
49class MgtAssocResponseHeader;
50
52using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
53 std::reference_wrapper<MgtReassocRequestHeader>>;
54
62class ApWifiMac : public WifiMac
63{
64 public:
69 static TypeId GetTypeId();
70
71 ApWifiMac();
72 ~ApWifiMac() override;
73
74 void SetLinkUpCallback(Callback<void> linkUp) override;
75 bool CanForwardPacketsTo(Mac48Address to) const override;
76 void Enqueue(Ptr<Packet> packet, Mac48Address to) override;
77 void Enqueue(Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
78 bool SupportsSendFrom() const override;
79 Ptr<WifiMacQueue> GetTxopQueue(AcIndex ac) const override;
80 void ConfigureStandard(WifiStandard standard) override;
81
85 void SetBeaconInterval(Time interval);
89 Time GetBeaconInterval() const;
90
100 int64_t AssignStreams(int64_t stream);
101
110 const std::map<uint16_t, Mac48Address>& GetStaList(uint8_t linkId = SINGLE_LINK_OP_ID) const;
116 uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const;
117
134 uint8_t GetBufferStatus(uint8_t tid, Mac48Address address) const;
144 void SetBufferStatus(uint8_t tid, Mac48Address address, uint8_t size);
154
155 protected:
162 {
164 ~ApLinkEntity() override;
165
167 std::map<uint16_t, Mac48Address> staList;
169 uint16_t numNonHtStations{0};
171 0};
173 false};
175 };
176
183 ApLinkEntity& GetLink(uint8_t linkId) const;
184
185 private:
186 std::unique_ptr<LinkEntity> CreateLinkEntity() const override;
187
188 void Receive(Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
200 bool ReceiveAssocRequest(const AssocReqRefVariant& assoc,
201 const Mac48Address& from,
202 uint8_t linkId);
203
215 void ParseReportedStaInfo(const AssocReqRefVariant& assoc, Mac48Address from, uint8_t linkId);
216
225 void TxOk(Ptr<const WifiMpdu> mpdu);
235 void TxFailed(WifiMacDropReason timeoutReason, Ptr<const WifiMpdu> mpdu);
236
254 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to);
263 void ForwardDown(Ptr<Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
271 void SendProbeResp(Mac48Address to, uint8_t linkId);
294 void SetAid(MgtAssocResponseHeader& assoc, const Mac48Address& to, uint8_t linkId);
302 void SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId);
309 void SendOneBeacon(uint8_t linkId);
310
317 CapabilityInformation GetCapabilities(uint8_t linkId) const;
324 ErpInformation GetErpInformation(uint8_t linkId) const;
331 EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const;
337 std::optional<MuEdcaParameterSet> GetMuEdcaParameterSet() const;
345 std::optional<ReducedNeighborReport> GetReducedNeighborReport(uint8_t linkId) const;
356 WifiMacType frameType,
364 HtOperation GetHtOperation(uint8_t linkId) const;
371 VhtOperation GetVhtOperation(uint8_t linkId) const;
378 HeOperation GetHeOperation(uint8_t linkId) const;
386 SupportedRates GetSupportedRates(uint8_t linkId) const;
393 DsssParameterSet GetDsssParameterSet(uint8_t linkId) const;
399 void SetBeaconGeneration(bool enable);
400
410 void UpdateShortSlotTimeEnabled(uint8_t linkId);
419 void UpdateShortPreambleEnabled(uint8_t linkId);
420
429 bool GetUseNonErpProtection(uint8_t linkId) const;
430
431 void DoDispose() override;
432 void DoInitialize() override;
433
438 uint16_t GetNextAssociationId(std::list<uint8_t> linkIds);
439
449
451 typedef struct
452 {
453 uint8_t value;
455 } bsrType;
456
458 std::unordered_map<WifiAddressTidPair, bsrType, WifiAddressTidHash> m_bufferStatus;
459
466 typedef void (*AssociationCallback)(uint16_t aid, Mac48Address address);
467
470};
471
472} // namespace ns3
473
474#endif /* AP_WIFI_MAC_H */
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:63
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:141
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:440
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:178
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 SetAid(MgtAssocResponseHeader &assoc, const Mac48Address &to, uint8_t linkId)
Set the AID field of the given Association Response frame, which is going to be sent to the STA with ...
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:241
void DoDispose() override
Destructor implementation.
Definition: ap-wifi-mac.cc:125
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:216
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...
CapabilityInformation GetCapabilities(uint8_t linkId) const
Return the Capability information of the current AP for the given link.
Definition: ap-wifi-mac.cc:455
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:444
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
Definition: ap-wifi-mac.h:466
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:400
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:363
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:446
EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const
Return the EDCA Parameter Set of the current AP for the given link.
Definition: ap-wifi-mac.cc:487
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:633
HtOperation GetHtOperation(uint8_t linkId) const
Return the HT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:682
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:264
void TxOk(Ptr< const WifiMpdu > mpdu)
The packet we sent was successfully received by the receiver (i.e.
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:469
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:441
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:442
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:445
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:859
DsssParameterSet GetDsssParameterSet(uint8_t linkId) const
Return the DSSS Parameter Set that we support on the given link.
Definition: ap-wifi-mac.cc:445
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:468
Time GetBeaconInterval() const
Definition: ap-wifi-mac.cc:197
static TypeId GetTypeId()
Get the type ID.
Definition: ap-wifi-mac.cc:55
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:602
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:383
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:448
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:233
ApLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: ap-wifi-mac.cc:147
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 ...
void ConfigureStandard(WifiStandard standard) override
Definition: ap-wifi-mac.cc:153
ErpInformation GetErpInformation(uint8_t linkId) const
Return the ERP information of the current AP for the given link.
Definition: ap-wifi-mac.cc:466
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:204
VhtOperation GetVhtOperation(uint8_t linkId) const
Return the VHT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:780
~ApWifiMac() override
Definition: ap-wifi-mac.cc:119
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:829
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:534
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:393
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:458
MgtAssocResponseHeader GetAssocResp(Mac48Address to, uint8_t linkId)
Get the Association Response frame to send on a given link.
Definition: ap-wifi-mac.cc:963
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:288
void DoInitialize() override
Initialize() implementation.
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:168
const std::map< uint16_t, Mac48Address > & GetStaList(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get a const reference to the map of associated stations on the given link.
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.
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:446
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
The VHT Operation Information Element.
Definition: vht-operation.h:36
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:92
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:73
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:74
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:53
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Definition: wifi-utils.h:140
WifiMacType
Combination of valid MAC header type/subtype.
store value and timestamp for each Buffer Status Report
Definition: ap-wifi-mac.h:452
uint8_t value
value of BSR
Definition: ap-wifi-mac.h:453
Time timestamp
timestamp of BSR
Definition: ap-wifi-mac.h:454