A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
23 #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"
31 #include <map>
33 namespace ns3 {
35 class Dcf;
36 class MacLow;
37 class MacRxMiddle;
38 class MacTxMiddle;
39 class DcfManager;
50 class RegularWifiMac : public WifiMac
51 {
52 public:
53  static TypeId GetTypeId (void);
55  RegularWifiMac ();
56  virtual ~RegularWifiMac ();
61  void SetSlot (Time slotTime);
65  void SetSifs (Time sifs);
72  void SetEifsNoDifs (Time eifsNoDifs);
76  void SetPifs (Time pifs);
78  void SetRifs (Time rifs);
82  void SetCtsTimeout (Time ctsTimeout);
86  void SetAckTimeout (Time ackTimeout);
88  Time GetRifs (void) const;
92  Time GetPifs (void) const;
96  Time GetSifs (void) const;
100  Time GetSlot (void) const;
104  Time GetEifsNoDifs (void) const;
108  Time GetCtsTimeout (void) const;
112  Time GetAckTimeout (void) const;
120  void SetCtsToSelfSupported (bool enable);
128  bool GetCtsToSelfSupported () const;
132  virtual Mac48Address GetAddress (void) const;
136  virtual Ssid GetSsid (void) const;
140  virtual void SetAddress (Mac48Address address);
144  virtual void SetSsid (Ssid ssid);
148  virtual void SetBssid (Mac48Address bssid);
152  virtual Mac48Address GetBssid (void) const;
160  virtual void SetPromisc (void);
173  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
174  virtual bool SupportsSendFrom (void) const;
184  virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0;
188  virtual void SetWifiPhy (Ptr<WifiPhy> phy);
192  virtual Ptr<WifiPhy> GetWifiPhy () const;
196  virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager);
216  virtual void SetForwardUpCallback (ForwardUpCallback upCallback);
220  virtual void SetLinkUpCallback (Callback<void> linkUp);
224  virtual void SetLinkDownCallback (Callback<void> linkDown);
225  /* Next functions are not pure virtual so non Qos WifiMacs are not
226  * forced to implement them.
227  */
228  virtual void SetBasicBlockAckTimeout (Time blockAckTimeout);
229  virtual Time GetBasicBlockAckTimeout (void) const;
230  virtual void SetCompressedBlockAckTimeout (Time blockAckTimeout);
231  virtual Time GetCompressedBlockAckTimeout (void) const;
233 protected:
234  virtual void DoInitialize ();
235  virtual void DoDispose ();
257  typedef std::map<AcIndex, Ptr<EdcaTxopN> > EdcaQueues;
267  Ptr<DcaTxop> GetDcaTxop (void) const;
274  Ptr<EdcaTxopN> GetVOQueue (void) const;
280  Ptr<EdcaTxopN> GetVIQueue (void) const;
286  Ptr<EdcaTxopN> GetBEQueue (void) const;
292  Ptr<EdcaTxopN> GetBKQueue (void) const;
306  virtual void FinishConfigureStandard (enum WifiPhyStandard standard);
316  void SetTypeOfStation (TypeOfStation type);
332  virtual void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
339  virtual void TxOk (const WifiMacHeader &hdr);
346  virtual void TxFailed (const WifiMacHeader &hdr);
355  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
364  virtual void DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket,
365  const WifiMacHeader *hdr);
374  virtual void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr,
375  Mac48Address originator);
396  void SetQosSupported (bool enable);
402  bool GetQosSupported () const;
423  void SetHtSupported (bool enable);
429  bool GetHtSupported () const;
431 private:
432  RegularWifiMac (const RegularWifiMac &);
441  void SetupEdcaQueue (enum AcIndex ac);
445 };
447 } // namespace ns3
449 #endif /* REGULAR_WIFI_MAC_H */
void SetQosSupported(bool enable)
Enable or disable QoS support for the device.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
void SetSifs(Time sifs)
Callback template class.
Definition: callback.h:924
RegularWifiMac & operator=(const RegularWifiMac &)
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 CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
Implement the header for management frames of type add block ack request.
Definition: mgt-headers.h:454
void SetPifs(Time pifs)
virtual void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Callback< void > m_linkUp
Callback when a link is up.
MacTxMiddle * m_txMiddle
TX middle (aggregation etc.)
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.
void SetRifs(Time rifs)
virtual Ssid GetSsid(void) const
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...
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
virtual Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
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...
Identifies the PHY specification that a Wifi device is configured to use.
Time GetCtsTimeout(void) const
virtual void SetForwardUpCallback(ForwardUpCallback upCallback)
base class for all MAC-level wifi objects.
void SetEifsNoDifs(Time eifsNoDifs)
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
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.
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
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:229
virtual void SetAddress(Mac48Address address)
Time GetPifs(void) const
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
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()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
DcfManager * m_dcfManager
DCF manager (access to channel)
an EUI-48 address
Definition: mac48-address.h:41
void SetCtsTimeout(Time ctsTimeout)
virtual bool SupportsSendFrom(void) const
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
virtual Ptr< WifiPhy > GetWifiPhy() const
Time GetRifs(void) const
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.
virtual Time GetBasicBlockAckTimeout(void) const
virtual Mac48Address GetAddress(void) const
virtual void DoInitialize()
This method is called only once by Object::Initialize.
bool GetHtSupported() const
Return whether the device supports QoS.
virtual void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
tuple address
Definition: first.py:37
Enumeration for type of station.
Definition: edca-txop-n.h:59
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.
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
virtual void SetPromisc(void)
Sets the interface in promiscuous mode.
a unique identifier for an interface.
Definition: type-id.h:49
void SetAckTimeout(Time ackTimeout)
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:35
Implements the IEEE 802.11 MAC header.
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...