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);
64  void SetSsid (Ssid ssid);
66  void SetPromisc (void);
67  bool GetShortSlotTimeSupported (void) const;
68  Ssid GetSsid (void) const;
69  Mac48Address GetAddress (void) const;
70  Mac48Address GetBssid (void) const;
71  virtual void Enqueue (Ptr<Packet> packet, Mac48Address to, Mac48Address from);
72  virtual bool SupportsSendFrom (void) const;
73  virtual void SetWifiPhy (const Ptr<WifiPhy> phy);
74  Ptr<WifiPhy> GetWifiPhy (void) const;
75  void ResetWifiPhy (void);
76  virtual void SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager> stationManager);
77  void ConfigureStandard (WifiStandard standard);
78  TypeOfStation GetTypeOfStation (void) const;
79 
89 
90  void SetForwardUpCallback (ForwardUpCallback upCallback);
91  void SetLinkUpCallback (Callback<void> linkUp);
92  void SetLinkDownCallback (Callback<void> linkDown);
93 
94  // Should be implemented by child classes
95  virtual void Enqueue (Ptr<Packet> packet, Mac48Address to) = 0;
96 
103 
110  void SetCtsToSelfSupported (bool enable);
114  void SetBssid (Mac48Address bssid);
115 
120 
126  Ptr<Txop> GetTxop (void) const;
133  Ptr<QosTxop> GetQosTxop (AcIndex ac) const;
140  Ptr<QosTxop> GetQosTxop (uint8_t tid) const;
141 
153  HtCapabilities GetHtCapabilities (void) const;
159  VhtCapabilities GetVhtCapabilities (void) const;
165  HeCapabilities GetHeCapabilities (void) const;
166 
167 protected:
168  virtual void DoInitialize ();
169  virtual void DoDispose ();
170  void SetTypeOfStation (TypeOfStation type);
171 
177 
179 
183 
185 
189 
192  typedef std::map<AcIndex, Ptr<QosTxop> > EdcaQueues;
193 
197 
203  Ptr<QosTxop> GetVOQueue (void) const;
209  Ptr<QosTxop> GetVIQueue (void) const;
215  Ptr<QosTxop> GetBEQueue (void) const;
221  Ptr<QosTxop> GetBKQueue (void) const;
222 
230  void ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax);
231 
245  virtual void Receive (Ptr<WifiMacQueueItem> mpdu);
246 
254  void ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
255 
263 
269  virtual void SetQosSupported (bool enable);
275  bool GetQosSupported () const;
276 
281  void SetupFrameExchangeManager (void);
282 
288  bool GetHtSupported () const;
289 
295  bool GetVhtSupported () const;
296 
302  void SetErpSupported (bool enable);
308  bool GetErpSupported () const;
309 
315  void SetDsssSupported (bool enable);
321  bool GetDsssSupported () const;
322 
328  bool GetHeSupported () const;
329 
330 private:
332  RegularWifiMac (const RegularWifiMac &);
340 
347  void SetupEdcaQueue (AcIndex ac);
348 
354  void SetVoBlockAckThreshold (uint8_t threshold);
360  void SetViBlockAckThreshold (uint8_t threshold);
366  void SetBeBlockAckThreshold (uint8_t threshold);
372  void SetBkBlockAckThreshold (uint8_t threshold);
373 
379  void SetVoBlockAckInactivityTimeout (uint16_t timeout);
385  void SetViBlockAckInactivityTimeout (uint16_t timeout);
391  void SetBeBlockAckInactivityTimeout (uint16_t timeout);
397  void SetBkBlockAckInactivityTimeout (uint16_t timeout);
398 
400 
425 
428 
429  uint16_t m_voMaxAmsduSize;
430  uint16_t m_viMaxAmsduSize;
431  uint16_t m_beMaxAmsduSize;
432  uint16_t m_bkMaxAmsduSize;
433 
434  uint32_t m_voMaxAmpduSize;
435  uint32_t m_viMaxAmpduSize;
436  uint32_t m_beMaxAmpduSize;
437  uint32_t m_bkMaxAmpduSize;
438 
441 
444 
447 
455 
458 
463 
471  typedef void (* MpduResponseTimeoutCallback)(uint8_t reason, Ptr<const WifiMacQueueItem> mpdu,
472  const WifiTxVector& txVector);
473 
476 
482 
490  typedef void (* PsduResponseTimeoutCallback)(uint8_t reason, Ptr<const WifiPsdu> psdu,
491  const WifiTxVector& txVector);
492 
495 
501 
510  typedef void (* PsduMapResponseTimeoutCallback)(uint8_t reason, WifiPsduMap* psduMap,
511  const std::set<Mac48Address>* missingStations,
512  std::size_t nTotalStations);
513 
516 
522 
525 };
526 
527 } //namespace ns3
528 
529 #endif /* REGULAR_WIFI_MAC_H */
virtual void SetQosSupported(bool enable)
Enable or disable QoS support for the device.
uint16_t m_voMaxAmsduSize
maximum A-MSDU size for AC_VO (in bytes)
Mac48Address m_bssid
the BSSID
void SetVoBlockAckInactivityTimeout(uint16_t timeout)
Set VO block ack inactivity timeout.
void SetupEdcaQueue(AcIndex ac)
This method is a private utility invoked to configure the channel access function for the specified A...
TracedCallback< uint8_t, WifiPsduMap *, const std::set< Mac48Address > *, std::size_t > PsduMapResponseTimeoutTracedCallback
TracedCallback for PSDU map response timeout events typedef.
MpduResponseTimeoutTracedCallback m_mpduResponseTimeoutCallback
MPDU response timeout traced callback.
bool GetHeSupported() const
Return whether the device supports HE.
Callback template class.
Definition: callback.h:1278
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Ptr< Txop > m_txop
This holds a pointer to the TXOP instance for this WifiMac - used for transmission of frames to non-Q...
uint32_t m_bkMaxAmpduSize
maximum A-MPDU size for AC_BK (in bytes)
ForwardUpCallback m_forwardUp
Callback to forward packet up the stack.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:57
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 GetQosSupported() const
Return whether the device supports QoS.
static TypeId GetTypeId(void)
Get the type ID.
uint16_t m_bkMaxAmsduSize
maximum A-MSDU size for AC_BK (in bytes)
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
Forward calls to a chain of Callback.
uint32_t m_beMaxAmpduSize
maximum A-MPDU size for AC_BE (in bytes)
void SetErpSupported(bool enable)
Enable or disable ERP support for the device.
ExtendedCapabilities GetExtendedCapabilities(void) const
Return the extended capabilities of the device.
The Extended Capabilities Information ElementThis class knows how to serialise and deserialise the Ex...
Callback< void > m_linkUp
Callback when a link is up.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void(* PsduMapResponseTimeoutCallback)(uint8_t reason, WifiPsduMap *psduMap, const std::set< Mac48Address > *missingStations, std::size_t nTotalStations)
TracedCallback signature for PSDU map response timeout events.
void SetSsid(Ssid ssid)
TracedCallback< uint8_t, Ptr< const WifiPsdu >, const WifiTxVector & > PsduResponseTimeoutTracedCallback
TracedCallback for PSDU response timeout events typedef.
void SetLinkDownCallback(Callback< void > linkDown)
Ptr< WifiPhy > m_phy
Wifi PHY.
uint32_t m_voMaxAmpduSize
maximum A-MPDU size for AC_VO (in bytes)
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
ns3::Time timeout
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 GetShortSlotTimeSupported(void) const
bool GetDsssSupported() const
Return whether the device supports DSSS.
TracedCallback< const WifiMacHeader & > m_txErrCallback
transmit error callback
phy
Definition: third.py:93
void SetVoBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VO.
void SetBssid(Mac48Address bssid)
virtual bool SupportsSendFrom(void) const
void SetForwardUpCallback(ForwardUpCallback upCallback)
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from)
base class for all MAC-level wifi objects.
void SetBkBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BK.
bool GetErpSupported() const
Return whether the device supports ERP.
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
bool GetVhtSupported() const
Return whether the device supports VHT.
The IEEE 802.11ac VHT Capabilities.
Ssid m_ssid
Service Set ID (SSID)
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:70
ssid
Definition: third.py:100
mac
Definition: third.py:99
void SetAddress(Mac48Address address)
TracedCallback< WifiMacDropReason, Ptr< const WifiMacQueueItem > > DroppedMpduTracedCallback
TracedCallback for MPDU drop events typedef.
Ptr< MacRxMiddle > m_rxMiddle
RX middle (defragmentation etc.)
Ptr< QosTxop > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
TypeOfStation GetTypeOfStation(void) const
Return the type of station.
uint16_t m_viMaxAmsduSize
maximum A-MSDU size for AC_VI (in bytes)
Mac48Address GetBssid(void) const
uint16_t m_beMaxAmsduSize
maximum A-MSDU size for AC_BE (in bytes)
HeCapabilities GetHeCapabilities(void) const
Return the HE capabilities of the device.
void ResetWifiPhy(void)
Remove currently attached WifiPhy device from this MAC.
void SetupFrameExchangeManager(void)
Create a Frame Exchange Manager depending on the supported version of the standard.
PsduResponseTimeoutTracedCallback m_psduResponseTimeoutCallback
PSDU response timeout traced callback.
TypeOfStation m_typeOfStation
the type of station
void SetBeBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_BE.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Callback< void > m_linkDown
Callback when a link is down.
TracedCallback< const WifiMacHeader & > m_txOkCallback
transmit OK callback
Ptr< FrameExchangeManager > GetFrameExchangeManager(void) const
Get the Frame Exchange Manager.
Ptr< FrameExchangeManager > m_feManager
Frame Exchange Manager.
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void SetLinkUpCallback(Callback< void > linkUp)
virtual void DoDispose()
Destructor implementation.
DroppedMpduTracedCallback m_droppedMpduCallback
This trace indicates that an MPDU was dropped for the given reason.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiStandard
Identifies the allowed configurations that a Wifi device is configured to use.
address
Definition: first.py:44
void(* PsduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
TracedCallback signature for PSDU response timeout events.
an EUI-48 address
Definition: mac48-address.h:43
Ssid GetSsid(void) const
Ptr< QosTxop > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
void SetViBlockAckInactivityTimeout(uint16_t timeout)
Set VI block ack inactivity timeout.
std::map< AcIndex, Ptr< QosTxop > > EdcaQueues
This type defines a mapping between an Access Category index, and a pointer to the corresponding chan...
MpduTracedCallback m_nackedMpduCallback
nack&#39;ed MPDU callback
Mac48Address GetAddress(void) const
void(* DroppedMpduCallback)(WifiMacDropReason reason, Ptr< const WifiMacQueueItem > mpdu)
TracedCallback signature for MPDU drop events.
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Ptr< Txop > GetTxop(void) const
Accessor for the DCF object.
void SetViBlockAckThreshold(uint8_t threshold)
Set the block ack threshold for AC_VI.
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
bool GetHtSupported() const
Return whether the device supports HT.
MpduTracedCallback m_ackedMpduCallback
ack&#39;ed MPDU callback
void(* MpduResponseTimeoutCallback)(uint8_t reason, Ptr< const WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
TracedCallback signature for MPDU response timeout events.
bool m_ctsToSelfSupported
flag indicating whether CTS-To-Self is supported
TracedCallback< Ptr< const WifiMacQueueItem > > MpduTracedCallback
TracedCallback for acked/nacked MPDUs typedef.
PsduMapResponseTimeoutTracedCallback m_psduMapResponseTimeoutCallback
PSDU map response timeout traced callback.
virtual void DoInitialize()
Initialize() implementation.
void SetBkBlockAckInactivityTimeout(uint16_t timeout)
Set BK block ack inactivity timeout.
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
bool m_shortSlotTimeSupported
flag whether short slot time is supported
uint32_t m_viMaxAmpduSize
maximum A-MPDU size for AC_VI (in bytes)
bool m_erpSupported
This Boolean is set true iff this WifiMac is to model 802.11g.
Ptr< QosTxop > GetBKQueue(void) const
Accessor for the AC_BK channel access function.
TypeOfStation
Enumeration for type of station.
Definition: wifi-mac.h:40
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self feature.
RegularWifiMac & operator=(const RegularWifiMac &mac)
assignment operator
void SetShortSlotTimeSupported(bool enable)
Enable or disable short slot time feature.
void SetDsssSupported(bool enable)
Enable or disable DSSS support for the device.
void ConfigureStandard(WifiStandard standard)
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
Mac48Address m_address
MAC address of this station.
void SetPromisc(void)
Sets the interface in promiscuous mode.
Ptr< WifiPhy > GetWifiPhy(void) const
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capabilities of the device.
The IEEE 802.11ax HE Capabilities.
void SetBeBlockAckInactivityTimeout(uint16_t timeout)
Set BE block ack inactivity timeout.
a unique identifier for an interface.
Definition: type-id.h:58
bool m_dsssSupported
This Boolean is set true iff this WifiMac is to model 802.11b.
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
virtual void SetWifiPhy(const Ptr< WifiPhy > phy)
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:54
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Callback< void, Ptr< const Packet >, Mac48Address, Mac48Address > ForwardUpCallback
This type defines the callback of a higher layer that a WifiMac(-derived) object invokes to pass a pa...
TracedCallback< uint8_t, Ptr< const WifiMacQueueItem >, const WifiTxVector & > MpduResponseTimeoutTracedCallback
TracedCallback for MPDU response timeout events typedef.
HtCapabilities GetHtCapabilities(void) const
Return the HT capabilities of the device.