src/devices/wifi/qap-wifi-mac.h
changeset 4408 76a169b3db3d
child 4421 0608881b163f
equal deleted inserted replaced
4407:ef566eeff84f 4408:76a169b3db3d
       
     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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    20  * Author: Mirko Banchi <mk.banchi@gmail.com>
       
    21  */
       
    22 #ifndef QAP_WIFI_MAC_H
       
    23 #define QAP_WIFI_MAC_H
       
    24 
       
    25 #include "ns3/mac48-address.h"
       
    26 #include "ns3/callback.h"
       
    27 #include "ns3/packet.h"
       
    28 #include "ns3/nstime.h"
       
    29 #include "ns3/event-id.h"
       
    30 
       
    31 #include "supported-rates.h"
       
    32 #include "wifi-remote-station-manager.h"
       
    33 #include "wifi-mac.h"
       
    34 #include "qos-utils.h"
       
    35 
       
    36 #include <map>
       
    37 
       
    38 namespace ns3 {
       
    39 
       
    40 class DcaTxop;
       
    41 class EdcaTxopN;
       
    42 class WifiMacHeader;
       
    43 class WifiPhy;
       
    44 class MacLow;
       
    45 class MacRxMiddle;
       
    46 class MacTxMiddle;
       
    47 class DcfManager;
       
    48 class AmsduSubframeHeader;
       
    49 class MsduAggregator;
       
    50 
       
    51 class QapWifiMac : public WifiMac
       
    52 {
       
    53 public:
       
    54   static TypeId GetTypeId (void);
       
    55   QapWifiMac ();
       
    56   virtual ~QapWifiMac ();
       
    57   
       
    58   // inherited from WifiMac.
       
    59   virtual void SetSlot (Time slotTime);
       
    60   virtual void SetSifs (Time sifs);
       
    61   virtual void SetEifsNoDifs (Time eifsNoDifs);
       
    62   virtual void SetAckTimeout (Time ackTimeout);
       
    63   virtual void SetCtsTimeout (Time ctsTimeout);
       
    64   virtual void SetPifs (Time pifs);
       
    65   virtual Time GetSlot (void) const;
       
    66   virtual Time GetSifs (void) const;
       
    67   virtual Time GetEifsNoDifs (void) const;
       
    68   virtual Time GetAckTimeout (void) const;
       
    69   virtual Time GetCtsTimeout (void) const;
       
    70   virtual Time GetPifs (void) const;
       
    71   virtual void SetWifiPhy (Ptr<WifiPhy> phy);
       
    72   virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager);
       
    73   virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from);
       
    74   virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to);
       
    75   virtual bool SupportsSendFrom (void) const;
       
    76   virtual void SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback);
       
    77   virtual void SetLinkUpCallback (Callback<void> linkUp);
       
    78   virtual void SetLinkDownCallback (Callback<void> linkDown);
       
    79   virtual Mac48Address GetAddress (void) const;
       
    80   virtual Ssid GetSsid (void) const;
       
    81   virtual void SetAddress (Mac48Address address);
       
    82   virtual void SetSsid (Ssid ssid);
       
    83   virtual Mac48Address GetBssid (void) const;
       
    84 
       
    85   void SetBeaconInterval (Time interval);
       
    86   Time GetBeaconInterval (void) const;
       
    87   void StartBeaconing (void);
       
    88 
       
    89 private:
       
    90   virtual void DoDispose (void);
       
    91   void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);
       
    92   void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
       
    93   void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
       
    94   /* Next function is invoked only when ap relies a frame. */
       
    95   void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to,
       
    96                     WifiMacHeader const *oldHdr);
       
    97   void TxOk (WifiMacHeader const &hdr);
       
    98   void TxFailed (WifiMacHeader const &hdr);
       
    99   void SendProbeResp (Mac48Address to);
       
   100   void SendAssocResp (Mac48Address to, bool success);
       
   101   void SendOneBeacon (void);
       
   102   SupportedRates GetSupportedRates (void) const;
       
   103   void SetBeaconGeneration (bool enable);
       
   104   bool GetBeaconGeneration (void) const;
       
   105   
       
   106   void DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, WifiMacHeader const *hdr);
       
   107 
       
   108   typedef std::map<AccessClass, Ptr<EdcaTxopN> > Queues;
       
   109   typedef std::list<std::pair<Ptr<Packet>, AmsduSubframeHeader> > DeaggregatedMsdus;
       
   110   typedef std::list<std::pair<Ptr<Packet>, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI;
       
   111 
       
   112   Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> m_forwardUp;
       
   113   
       
   114   Ptr<EdcaTxopN> GetVOQueue (void) const;
       
   115   Ptr<EdcaTxopN> GetVIQueue (void) const;
       
   116   Ptr<EdcaTxopN> GetBEQueue (void) const;
       
   117   Ptr<EdcaTxopN> GetBKQueue (void) const;
       
   118 
       
   119   void SetVOQueue (Ptr<EdcaTxopN> voQueue);
       
   120   void SetVIQueue (Ptr<EdcaTxopN> viQueue);
       
   121   void SetBEQueue (Ptr<EdcaTxopN> beQueue);
       
   122   void SetBKQueue (Ptr<EdcaTxopN> bkQueue);
       
   123 
       
   124   /*Next map is used only for an esay access to a specific queue*/
       
   125   Queues m_queues;
       
   126   Ptr<EdcaTxopN> m_voEdca;
       
   127   Ptr<EdcaTxopN> m_viEdca;
       
   128   Ptr<EdcaTxopN> m_beEdca;
       
   129   Ptr<EdcaTxopN> m_bkEdca;
       
   130   Ptr<DcaTxop> m_beaconDca;
       
   131   Ptr<MacLow> m_low;
       
   132   Ptr<WifiPhy> m_phy;
       
   133   Ptr<WifiRemoteStationManager> m_stationManager;
       
   134   MacRxMiddle *m_rxMiddle;
       
   135   MacTxMiddle *m_txMiddle;
       
   136   DcfManager *m_dcfManager;
       
   137   Ssid m_ssid;
       
   138   EventId m_beaconEvent;
       
   139   Time m_beaconInterval;
       
   140   Time m_eifsNoDifs;
       
   141 };
       
   142 
       
   143 }  //namespace ns3
       
   144 
       
   145 #endif /* QAP_WIFI_MAC_H */