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 "ns3/wifi-mac.h"
25 #include "dca-txop.h"
26 #include "edca-txop-n.h"
28 #include "ssid.h"
29 #include "qos-utils.h"
30 #include <map>
31 
32 namespace ns3 {
33 
34 class Dcf;
35 class MacLow;
36 class MacRxMiddle;
37 class MacTxMiddle;
38 class DcfManager;
39 
49 class RegularWifiMac : public WifiMac
50 {
51 public:
52  static TypeId GetTypeId (void);
53 
54  RegularWifiMac ();
55  virtual ~RegularWifiMac ();
56 
60  void SetSlot (Time slotTime);
64  void SetSifs (Time sifs);
71  void SetEifsNoDifs (Time eifsNoDifs);
75  void SetPifs (Time pifs);
79  void SetRifs (Time rifs);
83  void SetCtsTimeout (Time ctsTimeout);
87  void SetAckTimeout (Time ackTimeout);
88 
89  Time GetRifs (void) const;
93  Time GetPifs (void) const;
97  Time GetSifs (void) const;
101  Time GetSlot (void) const;
105  Time GetEifsNoDifs (void) const;
109  Time GetCtsTimeout (void) const;
113  Time GetAckTimeout (void) const;
114 
121  void SetCtsToSelfSupported (bool enable);
129  bool GetCtsToSelfSupported () const;
130 
137  virtual void SetShortSlotTimeSupported (bool enable);
144  virtual bool GetShortSlotTimeSupported (void) const;
145 
149  virtual Mac48Address GetAddress (void) const;
153  virtual Ssid GetSsid (void) const;
157  virtual void SetAddress (Mac48Address address);
161  virtual void SetSsid (Ssid ssid);
165  virtual void SetBssid (Mac48Address bssid);
169  virtual Mac48Address GetBssid (void) const;
177  virtual void SetPromisc (void);
178 
190  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
191 
192  virtual bool SupportsSendFrom (void) const;
193 
202  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0;
206  virtual void SetWifiPhy (Ptr<WifiPhy> phy);
210  virtual Ptr<WifiPhy> GetWifiPhy (void) const;
214  virtual void ResetWifiPhy (void);
218  virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager);
228  HtCapabilities GetHtCapabilities (void) const;
234  VhtCapabilities GetVhtCapabilities (void) const;
235 
249  virtual void SetForwardUpCallback (ForwardUpCallback upCallback);
253  virtual void SetLinkUpCallback (Callback<void> linkUp);
257  virtual void SetLinkDownCallback (Callback<void> linkDown);
258 
259  /* Next functions are not pure virtual so non Qos WifiMacs are not
260  * forced to implement them.
261  */
262  virtual void SetBasicBlockAckTimeout (Time blockAckTimeout);
263  virtual Time GetBasicBlockAckTimeout (void) const;
264  virtual void SetCompressedBlockAckTimeout (Time blockAckTimeout);
265  virtual Time GetCompressedBlockAckTimeout (void) const;
266 
267 
268 protected:
269  virtual void DoInitialize ();
270  virtual void DoDispose ();
271 
277 
279 
280  ForwardUpCallback m_forwardUp;
283 
285 
289 
292  typedef std::map<AcIndex, Ptr<EdcaTxopN> > EdcaQueues;
293 
296  EdcaQueues m_edca;
297 
303  Ptr<DcaTxop> GetDcaTxop (void) const;
304 
310  Ptr<EdcaTxopN> GetVOQueue (void) const;
316  Ptr<EdcaTxopN> GetVIQueue (void) const;
322  Ptr<EdcaTxopN> GetBEQueue (void) const;
328  Ptr<EdcaTxopN> GetBKQueue (void) const;
329 
342  virtual void FinishConfigureStandard (enum WifiPhyStandard standard);
343 
351  void ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax);
352 
361  void SetTypeOfStation (TypeOfStation type);
362 
377  virtual void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
384  virtual void TxOk (const WifiMacHeader &hdr);
391  virtual void TxFailed (const WifiMacHeader &hdr);
392 
400  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
401 
409  virtual void DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket,
410  const WifiMacHeader *hdr);
411 
419  virtual void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr,
420  Mac48Address originator);
421 
436 
442  void SetQosSupported (bool enable);
448  bool GetQosSupported () const;
449 
463 
469  void SetHtSupported (bool enable);
475  bool GetHtSupported () const;
476 
487  void SetVhtSupported (bool enable);
493  bool GetVhtSupported () const;
494 
505  void SetErpSupported (bool enable);
511  bool GetErpSupported () const;
512 
523  void SetDsssSupported (bool enable);
529  bool GetDsssSupported () const;
530 
531 
532 private:
533  RegularWifiMac (const RegularWifiMac &);
535 
542  void SetupEdcaQueue (enum AcIndex ac);
543 
544  void SetVoMaxAmsduSize (uint32_t size);
545  void SetViMaxAmsduSize (uint32_t size);
546  void SetBeMaxAmsduSize (uint32_t size);
547  void SetBkMaxAmsduSize (uint32_t size);
548 
549  void SetVoMaxAmpduSize (uint32_t size);
550  void SetViMaxAmpduSize (uint32_t size);
551  void SetBeMaxAmpduSize (uint32_t size);
552  void SetBkMaxAmpduSize (uint32_t size);
553 
554  void SetVoBlockAckThreshold (uint8_t threshold);
555  void SetViBlockAckThreshold (uint8_t threshold);
556  void SetBeBlockAckThreshold (uint8_t threshold);
557  void SetBkBlockAckThreshold (uint8_t threshold);
558 
559  void SetVoBlockAckInactivityTimeout (uint16_t timeout);
560  void SetViBlockAckInactivityTimeout (uint16_t timeout);
561  void SetBeBlockAckInactivityTimeout (uint16_t timeout);
562  void SetBkBlockAckInactivityTimeout (uint16_t timeout);
563 
564  void ConfigureAggregation (void);
565  void EnableAggregation (void);
566  void DisableAggregation (void);
567 
572 
577 
580 
582 };
583 
584 } //namespace ns3
585 
586 #endif /* REGULAR_WIFI_MAC_H */
void SetQosSupported(bool enable)
Enable or disable QoS support for the device.
void SetVoBlockAckInactivityTimeout(uint16_t timeout)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetSifs(Time sifs)
Callback template class.
Definition: callback.h:1176
RegularWifiMac & operator=(const RegularWifiMac &)
bool GetDsssSupported() const
Return whether the device supports DSSS.
bool GetVhtSupported() const
Return whether the device supports VHT.
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
ForwardUpCallback m_forwardUp
Callback to forward packet up the stack.
bool GetCtsToSelfSupported() const
Return whether the device supports CTS-to-self capability.
static TypeId GetTypeId(void)
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
Forward calls to a chain of Callback.
void SetErpSupported(bool enable)
Enable or disable ERP support for the device.
Implement the header for management frames of type add block ack request.
Definition: mgt-headers.h:667
void SetPifs(Time pifs)
virtual void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Callback< void > m_linkUp
Callback when a link is up.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
MacTxMiddle * m_txMiddle
TX middle (aggregation etc.)
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
virtual void SetSsid(Ssid ssid)
void SetSlot(Time slotTime)
virtual Time GetCompressedBlockAckTimeout(void) const
bool GetQosSupported() const
Return whether the device supports QoS.
virtual void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
This method can be called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
virtual void SetLinkDownCallback(Callback< void > linkDown)
void SetHtSupported(bool enable)
Enable or disable HT support for the device.
Ptr< WifiPhy > m_phy
Wifi PHY.
ns3::Time timeout
void SetRifs(Time rifs)
virtual Ssid GetSsid(void) const
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capability of the device.
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to, Mac48Address from)
MacRxMiddle * m_rxMiddle
RX middle (de-fragmentation etc.)
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void SetViMaxAmpduSize(uint32_t size)
This class handles duplicate detection and recomposition of fragments.
Definition: mac-rx-middle.h:40
TracedCallback< const WifiMacHeader & > m_txErrCallback
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
void SetBkMaxAmsduSize(uint32_t size)
void SetVoMaxAmpduSize(uint32_t size)
void SetVoBlockAckThreshold(uint8_t threshold)
void SetBeMaxAmpduSize(uint32_t size)
virtual void SetBssid(Mac48Address bssid)
Ptr< EdcaTxopN > GetVOQueue(void) const
Accessor for the AC_VO channel access function.
Time GetSifs(void) const
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
std::map< AcIndex, Ptr< EdcaTxopN > > EdcaQueues
This type defines a mapping between an Access Category index, and a pointer to the corresponding chan...
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
Time GetCtsTimeout(void) const
virtual void SetForwardUpCallback(ForwardUpCallback upCallback)
void SetBeMaxAmsduSize(uint32_t size)
base class for all MAC-level wifi objects.
void SetEifsNoDifs(Time eifsNoDifs)
void SetBkBlockAckThreshold(uint8_t threshold)
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
tuple phy
Definition: third.py:86
virtual void SetBasicBlockAckTimeout(Time blockAckTimeout)
virtual void SetWifiPhy(Ptr< WifiPhy > phy)
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Ptr< DcaTxop > m_dca
This holds a pointer to the DCF instance for this WifiMac - used for transmission of frames to non-Qo...
Ptr< EdcaTxopN > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
void SetVoMaxAmsduSize(uint32_t size)
The IEEE 802.11ac VHT Capabilities.
Ssid m_ssid
Service Set ID (SSID)
Ptr< DcaTxop > GetDcaTxop(void) const
Accessor for the DCF object.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:44
Time GetAckTimeout(void) const
void SetViMaxAmsduSize(uint32_t size)
Time GetSlot(void) const
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:279
bool m_vhtSupported
This Boolean is set true iff this WifiMac is to model 802.11ac.
virtual void SetAddress(Mac48Address address)
virtual void ResetWifiPhy(void)
removes attached WifiPhy device from this MAC.
Time GetPifs(void) const
bool GetErpSupported() const
Return whether the device supports ERP.
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
void SetBeBlockAckThreshold(uint8_t threshold)
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the device.
virtual void SendAddBaResponse(const MgtAddBaRequestHeader *reqHdr, Mac48Address originator)
This method can be called to accept a received ADDBA Request.
Callback< void > m_linkDown
Callback when a link is down.
TracedCallback< const WifiMacHeader & > m_txOkCallback
Ptr< EdcaTxopN > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
virtual void SetLinkUpCallback(Callback< void > linkUp)
virtual void DoDispose()
Destructor implementation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetVhtSupported(bool enable)
Enable or disable VHT support for the device.
DcfManager * m_dcfManager
DCF manager (access to channel)
virtual Ptr< WifiPhy > GetWifiPhy(void) const
an EUI-48 address
Definition: mac48-address.h:43
tuple ssid
Definition: third.py:93
void SetCtsTimeout(Time ctsTimeout)
virtual bool SupportsSendFrom(void) const
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:38
Time GetRifs(void) const
void SetViBlockAckInactivityTimeout(uint16_t timeout)
bool m_htSupported
This Boolean is set true iff this WifiMac is to model 802.11n.
virtual Mac48Address GetBssid(void) const
Ptr< EdcaTxopN > GetBKQueue(void) const
Accessor for the AC_BK channel access function.
void SetViBlockAckThreshold(uint8_t threshold)
virtual Time GetBasicBlockAckTimeout(void) const
virtual Mac48Address GetAddress(void) const
virtual void DoInitialize()
Initialize() implementation.
void SetBkBlockAckInactivityTimeout(uint16_t timeout)
bool GetHtSupported() const
Return whether the device supports HT.
virtual Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
virtual bool GetShortSlotTimeSupported(void) const
virtual void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
tuple address
Definition: first.py:37
bool m_erpSupported
This Boolean is set true iff this WifiMac is to model 802.11g.
TypeOfStation
Enumeration for type of station.
Definition: edca-txop-n.h:61
Callback< void, Ptr< Packet >, Mac48Address, Mac48Address > ForwardUpCallback
This type defines the callback of a higher layer that a WifiMac(-derived) object invokes to pass a pa...
void SetCtsToSelfSupported(bool enable)
Enable or disable CTS-to-self feature.
virtual void SetShortSlotTimeSupported(bool enable)
Enable or disable short slot time feature.
void SetDsssSupported(bool enable)
Enable or disable DSSS support for the device.
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
virtual void SetPromisc(void)
Sets the interface in promiscuous mode.
void SetBeBlockAckInactivityTimeout(uint16_t 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.
void SetAckTimeout(Time ackTimeout)
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:36
Implements the IEEE 802.11 MAC header.
void SetBkMaxAmpduSize(uint32_t size)
virtual void FinishConfigureStandard(enum WifiPhyStandard standard)
virtual void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
Time GetEifsNoDifs(void) const
void SetupEdcaQueue(enum AcIndex ac)
This method is a private utility invoked to configure the channel access function for the specified A...