A Discrete-Event Network Simulator
API
ap-wifi-mac.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2006, 2009 INRIA
4 * Copyright (c) 2009 MIRKO BANCHI
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20 * Mirko Banchi <mk.banchi@gmail.com>
21 */
22
23#ifndef AP_WIFI_MAC_H
24#define AP_WIFI_MAC_H
25
26#include "wifi-mac.h"
27#include "wifi-mac-header.h"
28#include <unordered_map>
29#include <variant>
30
31namespace ns3 {
32
33class SupportedRates;
34class CapabilityInformation;
35class DsssParameterSet;
36class ErpInformation;
37class EdcaParameterSet;
38class MuEdcaParameterSet;
39class ReducedNeighborReport;
40class MultiLinkElement;
41class HtOperation;
42class VhtOperation;
43class HeOperation;
44class CfParameterSet;
45class UniformRandomVariable;
46class MgtAssocRequestHeader;
47class MgtReassocRequestHeader;
48class MgtAssocResponseHeader;
49
51using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
52 std::reference_wrapper<MgtReassocRequestHeader>>;
53
61class ApWifiMac : public WifiMac
62{
63public:
68 static TypeId GetTypeId (void);
69
70 ApWifiMac ();
71 virtual ~ApWifiMac ();
72
73 void SetLinkUpCallback (Callback<void> linkUp) override;
74 bool CanForwardPacketsTo (Mac48Address to) const override;
75 void Enqueue (Ptr<Packet> packet, Mac48Address to) override;
76 void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
77 bool SupportsSendFrom (void) const override;
78 Ptr<WifiMacQueue> GetTxopQueue (AcIndex ac) const override;
79 void ConfigureStandard (WifiStandard standard) override;
80
84 void SetBeaconInterval (Time interval);
88 Time GetBeaconInterval (void) const;
89
99 int64_t AssignStreams (int64_t stream);
100
109 const std::map<uint16_t, Mac48Address>& GetStaList (uint8_t linkId = SINGLE_LINK_OP_ID) const;
115 uint16_t GetAssociationId (Mac48Address addr, uint8_t linkId) const;
116
133 uint8_t GetBufferStatus (uint8_t tid, Mac48Address address) const;
143 void SetBufferStatus (uint8_t tid, Mac48Address address, uint8_t size);
153
154protected:
161 {
163 virtual ~ApLinkEntity ();
164
166 std::map<uint16_t, Mac48Address> staList;
168 uint16_t numNonHtStations {0};
169 uint16_t numNonErpStations {0};
170 bool shortSlotTimeEnabled {false};
171 bool shortPreambleEnabled {false};
172 };
173
180 ApLinkEntity& GetLink (uint8_t linkId) const;
181
182private:
183 std::unique_ptr<LinkEntity> CreateLinkEntity (void) const override;
184
185 void Receive (Ptr<const WifiMpdu> mpdu, uint8_t linkId) override;
197 bool ReceiveAssocRequest (const AssocReqRefVariant& assoc, const Mac48Address& from,
198 uint8_t linkId);
199
211 void ParseReportedStaInfo (const AssocReqRefVariant& assoc, Mac48Address from, uint8_t linkId);
212
221 void TxOk (Ptr<const WifiMpdu> mpdu);
231 void TxFailed (WifiMacDropReason timeoutReason, Ptr<const WifiMpdu> mpdu);
232
250 void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
259 void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
267 void SendProbeResp (Mac48Address to, uint8_t linkId);
290 void SetAid (MgtAssocResponseHeader& assoc, const Mac48Address& to, uint8_t linkId);
298 void SendAssocResp (Mac48Address to, bool isReassoc, uint8_t linkId);
305 void SendOneBeacon (uint8_t linkId);
306
313 CapabilityInformation GetCapabilities (uint8_t linkId) const;
320 ErpInformation GetErpInformation (uint8_t linkId) const;
327 EdcaParameterSet GetEdcaParameterSet (uint8_t linkId) const;
333 std::optional<MuEdcaParameterSet> GetMuEdcaParameterSet (void) const;
341 std::optional<ReducedNeighborReport> GetReducedNeighborReport (uint8_t linkId) const;
351 MultiLinkElement GetMultiLinkElement (uint8_t linkId, WifiMacType frameType,
359 HtOperation GetHtOperation (uint8_t linkId) const;
366 VhtOperation GetVhtOperation (uint8_t linkId) const;
373 HeOperation GetHeOperation (uint8_t linkId) const;
381 SupportedRates GetSupportedRates (uint8_t linkId) const;
388 DsssParameterSet GetDsssParameterSet (uint8_t linkId) const;
394 void SetBeaconGeneration (bool enable);
395
405 void UpdateShortSlotTimeEnabled (uint8_t linkId);
414 void UpdateShortPreambleEnabled (uint8_t linkId);
415
424 bool GetUseNonErpProtection (uint8_t linkId) const;
425
426 void DoDispose (void) override;
427 void DoInitialize (void) override;
428
433 uint16_t GetNextAssociationId (std::list<uint8_t> linkIds);
434
443 typedef struct
444 {
445 uint8_t value;
447 } bsrType;
449 std::unordered_map<WifiAddressTidPair, bsrType, WifiAddressTidHash> m_bufferStatus;
450
457 typedef void (* AssociationCallback)(uint16_t aid, Mac48Address address);
458
461};
462
463} //namespace ns3
464
465#endif /* AP_WIFI_MAC_H */
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:62
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
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:435
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:173
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 ...
Definition: ap-wifi-mac.cc:995
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:234
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:211
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:447
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:438
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
Definition: ap-wifi-mac.h:457
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:394
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:357
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:114
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:440
EdcaParameterSet GetEdcaParameterSet(uint8_t linkId) const
Return the EDCA Parameter Set of the current AP for the given link.
Definition: ap-wifi-mac.cc:479
bool SupportsSendFrom(void) const override
Definition: ap-wifi-mac.cc:387
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:624
HtOperation GetHtOperation(uint8_t linkId) const
Return the HT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:674
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:257
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:460
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:436
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:437
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:439
void DoInitialize(void) override
Initialize() implementation.
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:838
DsssParameterSet GetDsssParameterSet(uint8_t linkId) const
Return the DSSS Parameter Set that we support on the given link.
Definition: ap-wifi-mac.cc:437
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:459
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:593
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:377
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...
static TypeId GetTypeId(void)
Get the type ID.
Definition: ap-wifi-mac.cc:53
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:441
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:226
ApLinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Definition: ap-wifi-mac.cc:142
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:148
ErpInformation GetErpInformation(uint8_t linkId) const
Return the ERP information of the current AP for the given link.
Definition: ap-wifi-mac.cc:458
void SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:199
VhtOperation GetVhtOperation(uint8_t linkId) const
Return the VHT operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:764
void DoDispose(void) override
Destructor implementation.
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.
std::optional< MuEdcaParameterSet > GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set of the current AP, if one needs to be advertised.
Definition: ap-wifi-mac.cc:526
HeOperation GetHeOperation(uint8_t linkId) const
Return the HE operation of the current AP for the given link.
Definition: ap-wifi-mac.cc:810
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...
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.
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:449
MgtAssocResponseHeader GetAssocResp(Mac48Address to, uint8_t linkId)
Get the Association Response frame to send on a given link.
Definition: ap-wifi-mac.cc:940
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:281
std::unique_ptr< LinkEntity > CreateLinkEntity(void) const override
Create a LinkEntity object.
Definition: ap-wifi-mac.cc:136
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:163
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.
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:192
The DSSS Parameter Set.
The EDCA Parameter Set.
The ErpInformation Information Element.
An identifier for simulation events.
Definition: event-id.h:54
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:44
static Mac48Address GetBroadcast(void)
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:449
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
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:91
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:72
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:73
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:52
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:138
WifiMacType
Combination of valid MAC header type/subtype.
store value and timestamp for each Buffer Status Report
Definition: ap-wifi-mac.h:444
uint8_t value
value of BSR
Definition: ap-wifi-mac.h:445
Time timestamp
timestamp of BSR
Definition: ap-wifi-mac.h:446