A Discrete-Event Network Simulator
API
regular-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) 2008 INRIA
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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef REGULAR_WIFI_MAC_H
22 #define REGULAR_WIFI_MAC_H
23 
24 #include "wifi-mac.h"
25 #include "qos-txop.h"
26 #include "ssid.h"
27 #include <set>
28 #include <unordered_map>
29 
30 namespace ns3 {
31 
32 class MacRxMiddle;
33 class MacTxMiddle;
34 class ChannelAccessManager;
35 class ExtendedCapabilities;
36 class FrameExchangeManager;
37 class WifiPsdu;
38 enum WifiTxTimerReason : uint8_t;
39 
40 typedef std::unordered_map <uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */> WifiPsduMap;
41 
50 class RegularWifiMac : public WifiMac
51 {
52 public:
57  static TypeId GetTypeId (void);
58 
59  RegularWifiMac ();
60  virtual ~RegularWifiMac ();
61 
62  // Implementations of pure virtual methods.
63  void SetShortSlotTimeSupported (bool enable) override;
64  void SetSsid (Ssid ssid) override;
65  void SetAddress (Mac48Address address) override;
66  void SetPromisc (void) override;
67  bool GetShortSlotTimeSupported (void) const override;
68  Ssid GetSsid (void) const override;
69  Mac48Address GetAddress (void) const override;
70  Mac48Address GetBssid (void) const override;
71  void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from) override;
72  bool SupportsSendFrom (void) const override;
73  void SetWifiPhy (const Ptr<WifiPhy> phy) override;
74  Ptr<WifiPhy> GetWifiPhy (void) const override;
75  void ResetWifiPhy (void) override;
76  void SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> stationManager) override;
77  void ConfigureStandard (WifiStandard standard) override;
78  TypeOfStation GetTypeOfStation (void) const override;
79  void SetForwardUpCallback (ForwardUpCallback upCallback) override;
80  void SetLinkUpCallback (Callback<void> linkUp) override;
81  void SetLinkDownCallback (Callback<void> linkDown) override;
83 
84  // Should be implemented by child classes
85  void Enqueue (Ptr<Packet> packet, Mac48Address to) override = 0;
86 
93 
100  void SetCtsToSelfSupported (bool enable);
104  void SetBssid (Mac48Address bssid);
105 
111  Ptr<Txop> GetTxop (void) const;
118  Ptr<QosTxop> GetQosTxop (AcIndex ac) const;
125  Ptr<QosTxop> GetQosTxop (uint8_t tid) const;
126 
138  HtCapabilities GetHtCapabilities (void) const;
144  VhtCapabilities GetVhtCapabilities (void) const;
150  HeCapabilities GetHeCapabilities (void) const;
151 
152 protected:
153  void DoInitialize () override;
154  void DoDispose () override;
155  void SetTypeOfStation (TypeOfStation type) override;
156 
162 
164 
168 
170 
174 
177  typedef std::map<AcIndex, Ptr<QosTxop> > EdcaQueues;
178 
182 
188  Ptr<QosTxop> GetVOQueue (void) const;
194  Ptr<QosTxop> GetVIQueue (void) const;
200  Ptr<QosTxop> GetBEQueue (void) const;
206  Ptr<QosTxop> GetBKQueue (void) const;
207 
215  void ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax);
216 
230  virtual void Receive (Ptr<WifiMacQueueItem> mpdu);
231 
239  void ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
240 
248 
254  virtual void SetQosSupported (bool enable);
260  bool GetQosSupported () const;
261 
266  void SetupFrameExchangeManager (void);
267 
273  bool GetHtSupported () const;
274 
280  bool GetVhtSupported () const;
281 
287  void SetErpSupported (bool enable);
293  bool GetErpSupported () const;
294 
300  void SetDsssSupported (bool enable);
306  bool GetDsssSupported () const;
307 
313  bool GetHeSupported () const;
314 
315 private:
325 
332  void SetupEdcaQueue (AcIndex ac);
333 
339  void SetVoBlockAckThreshold (uint8_t threshold);
345  void SetViBlockAckThreshold (uint8_t threshold);
351  void SetBeBlockAckThreshold (uint8_t threshold);
357  void SetBkBlockAckThreshold (uint8_t threshold);
358 
364  void SetVoBlockAckInactivityTimeout (uint16_t timeout);
370  void SetViBlockAckInactivityTimeout (uint16_t timeout);
376  void SetBeBlockAckInactivityTimeout (uint16_t timeout);
382  void SetBkBlockAckInactivityTimeout (uint16_t timeout);
383 
385 
410 
413 
414  uint16_t m_voMaxAmsduSize;
415  uint16_t m_viMaxAmsduSize;
416  uint16_t m_beMaxAmsduSize;
417  uint16_t m_bkMaxAmsduSize;
418 
419  uint32_t m_voMaxAmpduSize;
420  uint32_t m_viMaxAmpduSize;
421  uint32_t m_beMaxAmpduSize;
422  uint32_t m_bkMaxAmpduSize;
423 
426 
429 
432 
440 
443 
448 
456  typedef void (* MpduResponseTimeoutCallback)(uint8_t reason, Ptr<const WifiMacQueueItem> mpdu,
457  const WifiTxVector& txVector);
458 
461 
467 
475  typedef void (* PsduResponseTimeoutCallback)(uint8_t reason, Ptr<const WifiPsdu> psdu,
476  const WifiTxVector& txVector);
477 
480 
486 
495  typedef void (* PsduMapResponseTimeoutCallback)(uint8_t reason, WifiPsduMap* psduMap,
496  const std::set<Mac48Address>* missingStations,
497  std::size_t nTotalStations);
498 
501 
507 
510 };
511 
512 } //namespace ns3
513 
514 #endif /* REGULAR_WIFI_MAC_H */
Callback template class.
Definition: callback.h:1279
The Extended Capabilities Information Element.
The IEEE 802.11ax HE Capabilities.
The HT Capabilities Information Element.
an EUI-48 address
Definition: mac48-address.h:44
base class for all MAC-level wifi objects.
void SetViBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VI.
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
void(* MpduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
TracedCallback signature for MPDU response timeout events.
virtual void SetQosSupported(bool enable)
Enable or disable QoS support for the device.
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self feature.
uint16_t m_voMaxAmsduSize
maximum A-MSDU size for AC_VO (in bytes)
Mac48Address m_address
MAC address of this station.
Mac48Address m_bssid
the BSSID
uint32_t m_beMaxAmpduSize
maximum A-MPDU size for AC_BE (in bytes)
MpduTracedCallback m_ackedMpduCallback
ack'ed MPDU callback
uint32_t m_bkMaxAmpduSize
maximum A-MPDU size for AC_BK (in bytes)
Ptr< WifiPhy > m_phy
Wifi PHY.
PsduMapResponseTimeoutTracedCallback m_psduMapResponseTimeoutCallback
PSDU map response timeout traced callback.
Ptr< FrameExchangeManager > m_feManager
Frame Exchange Manager.
bool GetQosSupported() const
Return whether the device supports QoS.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
void SetBssid(Mac48Address bssid)
void ConfigureStandard(WifiStandard standard) override
void SetLinkUpCallback(Callback< void > linkUp) override
MpduResponseTimeoutTracedCallback m_mpduResponseTimeoutCallback
MPDU response timeout traced callback.
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
void(* PsduMapResponseTimeoutCallback)(uint8_t reason, WifiPsduMap *psduMap, const std::set< Mac48Address > *missingStations, std::size_t nTotalStations)
TracedCallback signature for PSDU map response timeout events.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const override
void SetForwardUpCallback(ForwardUpCallback upCallback) override
void SetTypeOfStation(TypeOfStation type) override
This method is invoked by a subclass to specify what type of station it is implementing.
Ptr< WifiPhy > GetWifiPhy(void) const override
uint16_t m_beMaxAmsduSize
maximum A-MSDU size for AC_BE (in bytes)
void SetBeBlockAckInactivityTimeout(uint16_t timeout)
Set BE block ack inactivity timeout.
void SetViBlockAckInactivityTimeout(uint16_t timeout)
Set VI block ack inactivity timeout.
Callback< void > m_linkDown
Callback when a link is down.
void SetBkBlockAckInactivityTimeout(uint16_t timeout)
Set BK block ack inactivity timeout.
Mac48Address GetBssid(void) const override
void SetBkBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BK.
void SetupEdcaQueue(AcIndex ac)
This method is a private utility invoked to configure the channel access function for the specified A...
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager) override
Ptr< Txop > GetTxop(void) const
Accessor for the DCF object.
TracedCallback< uint8_t, Ptr< const WifiPsdu >, const WifiTxVector & > PsduResponseTimeoutTracedCallback
TracedCallback for PSDU response timeout events typedef.
Ptr< QosTxop > GetBKQueue(void) const
Accessor for the AC_BK channel access function.
uint16_t m_viMaxAmsduSize
maximum A-MSDU size for AC_VI (in bytes)
void SetVoBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VO.
TypeOfStation GetTypeOfStation(void) const override
Return the type of station.
void SetErpSupported(bool enable)
Enable or disable ERP support for the device.
bool m_ctsToSelfSupported
flag indicating whether CTS-To-Self is supported
bool GetErpSupported() const
Return whether the device supports ERP.
void SetShortSlotTimeSupported(bool enable) override
Enable or disable short slot time feature.
PsduResponseTimeoutTracedCallback m_psduResponseTimeoutCallback
PSDU response timeout traced callback.
TracedCallback< uint8_t, Ptr< const WifiMacQueueItem >, const WifiTxVector & > MpduResponseTimeoutTracedCallback
TracedCallback for MPDU response timeout events typedef.
bool GetHeSupported() const
Return whether the device supports HE.
void(* DroppedMpduCallback)(WifiMacDropReason reason, Ptr< const WifiMacQueueItem > mpdu)
TracedCallback signature for MPDU drop events.
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
Ptr< MacRxMiddle > m_rxMiddle
RX middle (defragmentation etc.)
RegularWifiMac & operator=(const RegularWifiMac &mac)
assignment operator
Mac48Address GetAddress(void) const override
void SetupFrameExchangeManager(void)
Create a Frame Exchange Manager depending on the supported version of the standard.
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
ForwardUpCallback m_forwardUp
Callback to forward packet up the stack.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< FrameExchangeManager > GetFrameExchangeManager(void) const
Get the Frame Exchange Manager.
Ssid GetSsid(void) const override
void Enqueue(Ptr< Packet > packet, Mac48Address to) override=0
TypeOfStation m_typeOfStation
the type of station
bool GetHtSupported() const
Return whether the device supports HT.
virtual void Receive(Ptr< WifiMacQueueItem > mpdu)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
bool SupportsSendFrom(void) const override
void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from) override
TracedCallback< const WifiMacHeader & > m_txOkCallback
transmit OK callback
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
void SetSsid(Ssid ssid) override
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
void SetBeBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BE.
TracedCallback< const WifiMacHeader & > m_txErrCallback
transmit error callback
TracedCallback< WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpduTracedCallback
TracedCallback for MPDU drop events typedef.
uint32_t m_voMaxAmpduSize
maximum A-MPDU size for AC_VO (in bytes)
bool GetDsssSupported() const
Return whether the device supports DSSS.
std::map< AcIndex, Ptr< QosTxop > > EdcaQueues
This type defines a mapping between an Access Category index, and a pointer to the corresponding chan...
bool m_dsssSupported
This Boolean is set true iff this WifiMac is to model 802.11b.
virtual void DeaggregateAmsduAndForward(Ptr< WifiMacQueueItem > mpdu)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack.
bool m_erpSupported
This Boolean is set true iff this WifiMac is to model 802.11g.
void SetAddress(Mac48Address address) override
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
void SetDsssSupported(bool enable)
Enable or disable DSSS support for the device.
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
void ResetWifiPhy(void) override
Remove currently attached WifiPhy device from this MAC.
DroppedMpduTracedCallback m_droppedMpduCallback
This trace indicates that an MPDU was dropped for the given reason.
RegularWifiMac(const RegularWifiMac &)
type conversion operator
bool m_shortSlotTimeSupported
flag whether short slot time is supported
void DoInitialize() override
Initialize() implementation.
void DoDispose() override
Destructor implementation.
Ptr< QosTxop > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.
Ssid m_ssid
Service Set ID (SSID)
void SetLinkDownCallback(Callback< void > linkDown) override
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
TracedCallback< Ptr< const WifiMacQueueItem > > MpduTracedCallback
TracedCallback for acked/nacked MPDUs typedef.
void(* PsduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
TracedCallback signature for PSDU response timeout events.
MpduTracedCallback m_nackedMpduCallback
nack'ed MPDU callback
uint16_t m_bkMaxAmsduSize
maximum A-MSDU size for AC_BK (in bytes)
bool GetVhtSupported() const
Return whether the device supports VHT.
TracedCallback< uint8_t, WifiPsduMap *, const std::set< Mac48Address > *, std::size_t > PsduMapResponseTimeoutTracedCallback
TracedCallback for PSDU map response timeout events typedef.
Callback< void > m_linkUp
Callback when a link is up.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
void SetVoBlockAckInactivityTimeout(uint16_t timeout)
Set VO block ack inactivity timeout.
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service.
bool GetShortSlotTimeSupported(void) const override
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
void SetPromisc(void) override
Sets the interface in promiscuous mode.
uint32_t m_viMaxAmpduSize
maximum A-MPDU size for AC_VI (in bytes)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
The IEEE 802.11ac VHT Capabilities.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:71
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiStandard
Identifies the allowed configurations that a Wifi device is configured to use.
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:55
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.
TypeOfStation
Enumeration for type of station.
Definition: wifi-mac.h:41
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
ssid
Definition: third.py:100
mac
Definition: third.py:99
phy
Definition: third.py:93
ns3::Time timeout