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 <unordered_map>
28 
29 namespace ns3 {
30 
31 class SupportedRates;
32 class CapabilityInformation;
33 class DsssParameterSet;
34 class ErpInformation;
35 class EdcaParameterSet;
36 class MuEdcaParameterSet;
37 class HtOperation;
38 class VhtOperation;
39 class HeOperation;
40 class CfParameterSet;
41 class UniformRandomVariable;
42 
50 class ApWifiMac : public WifiMac
51 {
52 public:
57  static TypeId GetTypeId (void);
58 
59  ApWifiMac ();
60  virtual ~ApWifiMac ();
61 
62  void SetLinkUpCallback (Callback<void> linkUp) override;
63  bool CanForwardPacketsTo (Mac48Address to) const override;
64  void Enqueue (Ptr<Packet> packet, Mac48Address to) override;
65  void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
66  bool SupportsSendFrom (void) const override;
67  void SetAddress (Mac48Address address) override;
68  Ptr<WifiMacQueue> GetTxopQueue (AcIndex ac) const override;
69 
73  void SetBeaconInterval (Time interval);
77  Time GetBeaconInterval (void) const;
78 
88  int64_t AssignStreams (int64_t stream);
89 
97  const std::map<uint16_t, Mac48Address>& GetStaList (void) const;
102  uint16_t GetAssociationId (Mac48Address addr) const;
103 
120  uint8_t GetBufferStatus (uint8_t tid, Mac48Address address) const;
130  void SetBufferStatus (uint8_t tid, Mac48Address address, uint8_t size);
139  uint8_t GetMaxBufferStatus (Mac48Address address) const;
140 
141 private:
142  void Receive (Ptr<WifiMacQueueItem> mpdu) override;
151  void TxOk (Ptr<const WifiMacQueueItem> mpdu);
161  void TxFailed (WifiMacDropReason timeoutReason, Ptr<const WifiMacQueueItem> mpdu);
162 
180  void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
189  void ForwardDown (Ptr<Packet> packet, Mac48Address from, Mac48Address to, uint8_t tid);
196  void SendProbeResp (Mac48Address to);
206  void SendAssocResp (Mac48Address to, bool success, bool isReassoc);
210  void SendOneBeacon (void);
211 
223  ErpInformation GetErpInformation (void) const;
241  HtOperation GetHtOperation (void) const;
247  VhtOperation GetVhtOperation (void) const;
253  HeOperation GetHeOperation (void) const;
260  SupportedRates GetSupportedRates (void) const;
272  void SetBeaconGeneration (bool enable);
273 
280  void UpdateShortSlotTimeEnabled (void);
286  void UpdateShortPreambleEnabled (void);
287 
294  bool GetUseNonErpProtection (void) const;
295 
296  void DoDispose (void) override;
297  void DoInitialize (void) override;
298 
302  uint16_t GetNextAssociationId (void);
303 
310  std::map<uint16_t, Mac48Address> m_staList;
318  typedef struct
319  {
320  uint8_t value;
322  } bsrType;
324  std::unordered_map<WifiAddressTidPair, bsrType, WifiAddressTidHash> m_bufferStatus;
325 
332  typedef void (* AssociationCallback)(uint16_t aid, Mac48Address address);
333 
336 };
337 
338 } //namespace ns3
339 
340 #endif /* AP_WIFI_MAC_H */
Wi-Fi AP state machine.
Definition: ap-wifi-mac.h:51
void UpdateShortPreambleEnabled(void)
Update whether short preamble should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:237
bool m_shortPreambleEnabled
Flag whether short preamble is enabled in the BSS.
Definition: ap-wifi-mac.h:314
Ptr< Txop > m_beaconTxop
Dedicated Txop for beacons.
Definition: ap-wifi-mac.h:304
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
Definition: ap-wifi-mac.cc:158
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
Definition: ap-wifi-mac.cc:726
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
Definition: ap-wifi-mac.cc:373
void SetBeaconInterval(Time interval)
Definition: ap-wifi-mac.cc:192
HeOperation GetHeOperation(void) const
Return the HE operation of the current AP.
Definition: ap-wifi-mac.cc:698
uint16_t GetAssociationId(Mac48Address addr) const
void SetAddress(Mac48Address address) override
Definition: ap-wifi-mac.cc:138
uint16_t m_numNonHtStations
Number of non-HT stations currently associated to the AP.
Definition: ap-wifi-mac.h:312
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
Definition: ap-wifi-mac.h:308
void TxOk(Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:974
void(* AssociationCallback)(uint16_t aid, Mac48Address address)
TracedCallback signature for association/deassociation events.
Definition: ap-wifi-mac.h:332
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
Definition: ap-wifi-mac.cc:336
virtual ~ApWifiMac()
Definition: ap-wifi-mac.cc:120
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:315
bool m_shortSlotTimeEnabled
Flag whether short slot time is enabled within the BSS.
Definition: ap-wifi-mac.h:313
void Receive(Ptr< WifiMacQueueItem > mpdu) override
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
Definition: ap-wifi-mac.cc:440
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Definition: ap-wifi-mac.cc:564
bool SupportsSendFrom(void) const override
Definition: ap-wifi-mac.cc:366
std::map< uint16_t, Mac48Address > m_staList
Map of all stations currently associated to the AP with their association ID.
Definition: ap-wifi-mac.h:310
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Definition: ap-wifi-mac.cc:416
void UpdateShortSlotTimeEnabled(void)
Update whether short slot time should be enabled or not in the BSS.
Definition: ap-wifi-mac.cc:215
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Definition: ap-wifi-mac.cc:429
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
Definition: ap-wifi-mac.cc:902
TracedCallback< uint16_t, Mac48Address > m_deAssocLogger
deassociation logger
Definition: ap-wifi-mac.h:335
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
Definition: ap-wifi-mac.h:305
Time m_beaconInterval
Beacon interval.
Definition: ap-wifi-mac.h:306
void TxFailed(WifiMacDropReason timeoutReason, Ptr< const WifiMacQueueItem > mpdu)
The packet we sent was successfully received by the receiver (i.e.
Definition: ap-wifi-mac.cc:987
void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu) override
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
Definition: ap-wifi-mac.h:309
void DoInitialize(void) override
Initialize() implementation.
MuEdcaParameterSet GetMuEdcaParameterSet(void) const
Return the MU EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:510
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
Definition: ap-wifi-mac.cc:462
TracedCallback< uint16_t, Mac48Address > m_assocLogger
association logger
Definition: ap-wifi-mac.h:334
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the BSS.
EventId m_beaconEvent
Event to generate one beacon.
Definition: ap-wifi-mac.h:307
const std::map< uint16_t, Mac48Address > & GetStaList(void) const
Get a const reference to the map of associated stations.
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: ap-wifi-mac.cc:356
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:50
Time m_bsrLifetime
Lifetime of Buffer Status Reports.
Definition: ap-wifi-mac.h:316
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:207
uint16_t GetNextAssociationId(void)
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 SetLinkUpCallback(Callback< void > linkUp) override
Definition: ap-wifi-mac.cc:180
uint16_t m_numNonErpStations
Number of non-ERP stations currently associated to the AP.
Definition: ap-wifi-mac.h:311
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
Definition: ap-wifi-mac.cc:653
void DoDispose(void) override
Destructor implementation.
Definition: ap-wifi-mac.cc:127
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 SendAssocResp(Mac48Address to, bool success, bool isReassoc)
Forward an association or a reassociation response packet to the DCF.
Definition: ap-wifi-mac.cc:797
std::unordered_map< WifiAddressTidPair, bsrType, WifiAddressTidHash > m_bufferStatus
Per (MAC address, TID) buffer status reports.
Definition: ap-wifi-mac.h:324
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
Definition: ap-wifi-mac.cc:260
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:148
Time GetBeaconInterval(void) const
Definition: ap-wifi-mac.cc:173
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
The MU EDCA Parameter Set.
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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:85
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:66
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
store value and timestamp for each Buffer Status Report
Definition: ap-wifi-mac.h:319
uint8_t value
value of BSR
Definition: ap-wifi-mac.h:320
Time timestamp
timestamp of BSR
Definition: ap-wifi-mac.h:321