00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef WIFI_MAC_H 00021 #define WIFI_MAC_H 00022 00023 #include "ns3/packet.h" 00024 #include "ns3/mac48-address.h" 00025 00026 #include "wifi-phy.h" 00027 #include "wifi-remote-station-manager.h" 00028 #include "ssid.h" 00029 00030 namespace ns3 { 00031 00032 /** 00033 * \brief base class for all MAC-level wifi objects. 00034 * 00035 * This class encapsulates all the low-level MAC functionality 00036 * DCA, EDCA, etc) and all the high-level MAC functionality 00037 * (association/disassociation state machines). 00038 * 00039 */ 00040 class WifiMac : public Object 00041 { 00042 public: 00043 static TypeId GetTypeId (void); 00044 00045 /** 00046 * \param slotTime the slot duration 00047 */ 00048 virtual void SetSlot (Time slotTime) = 0; 00049 /** 00050 * \param sifs the sifs duration 00051 */ 00052 virtual void SetSifs (Time sifs) = 0; 00053 /** 00054 * \param eifsNoDifs the duration of an EIFS minus DIFS. 00055 * 00056 * This value is used to calculate the EIFS depending 00057 * on AIFSN. 00058 */ 00059 virtual void SetEifsNoDifs (Time eifsNoDifs) = 0; 00060 /** 00061 * \param pifs the pifs duration. 00062 */ 00063 virtual void SetPifs (Time pifs) = 0; 00064 /** 00065 * \param ctsTimeout the duration of a CTS timeout. 00066 */ 00067 virtual void SetCtsTimeout (Time ctsTimeout) = 0; 00068 /** 00069 * \param ackTimeout the duration of an ACK timeout. 00070 */ 00071 virtual void SetAckTimeout (Time ackTimeout) = 0; 00072 /** 00073 * \param delay the max propagation delay. 00074 * 00075 * Unused for now. 00076 */ 00077 void SetMaxPropagationDelay (Time delay); 00078 00079 /** 00080 * \returns the current PIFS duration. 00081 */ 00082 virtual Time GetPifs (void) const = 0; 00083 /** 00084 * \returns the current SIFS duration. 00085 */ 00086 virtual Time GetSifs (void) const = 0; 00087 /** 00088 * \returns the current slot duration. 00089 */ 00090 virtual Time GetSlot (void) const = 0; 00091 /** 00092 * \returns the current EIFS minus DIFS duration 00093 */ 00094 virtual Time GetEifsNoDifs (void) const = 0; 00095 /** 00096 * \returns the current CTS timeout duration. 00097 */ 00098 virtual Time GetCtsTimeout (void) const = 0; 00099 /** 00100 * \returns the current ACK timeout duration. 00101 */ 00102 virtual Time GetAckTimeout (void) const = 0; 00103 /** 00104 * Unused for now. 00105 */ 00106 Time GetMsduLifetime (void) const; 00107 /** 00108 * Unused for now. 00109 */ 00110 Time GetMaxPropagationDelay (void) const; 00111 /** 00112 * \returns the maximum size of a MAC-level data payload. 00113 */ 00114 uint32_t GetMaxMsduSize (void) const; 00115 00116 /** 00117 * \returns the MAC address associated to this MAC layer. 00118 */ 00119 virtual Mac48Address GetAddress (void) const = 0; 00120 /** 00121 * \returns the ssid which this MAC layer is going to try to stay in. 00122 */ 00123 virtual Ssid GetSsid (void) const = 0; 00124 /** 00125 * \param address the current address of this MAC layer. 00126 */ 00127 virtual void SetAddress (Mac48Address address) = 0; 00128 /** 00129 * \param ssid the current ssid of this MAC layer. 00130 */ 00131 virtual void SetSsid (Ssid ssid) = 0; 00132 /** 00133 * \returns the bssid of the network this device belongs to. 00134 */ 00135 virtual Mac48Address GetBssid (void) const = 0; 00136 00137 /** 00138 * \param packet the packet to send. 00139 * \param to the address to which the packet should be sent. 00140 * \param from the address from which the packet should be sent. 00141 * 00142 * The packet should be enqueued in a tx queue, and should be 00143 * dequeued as soon as the DCF function determines that 00144 * access it granted to this MAC. The extra parameter "from" allows 00145 * this device to operate in a bridged mode, forwarding received 00146 * frames without altering the source addresss. 00147 */ 00148 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from) = 0; 00149 /** 00150 * \param packet the packet to send. 00151 * \param to the address to which the packet should be sent. 00152 * 00153 * The packet should be enqueued in a tx queue, and should be 00154 * dequeued as soon as the DCF function determines that 00155 * access it granted to this MAC. 00156 */ 00157 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0; 00158 virtual bool SupportsSendFrom (void) const = 0; 00159 /** 00160 * \param phy the physical layer attached to this MAC. 00161 */ 00162 virtual void SetWifiPhy (Ptr<WifiPhy> phy) = 0; 00163 /** 00164 * \param stationManager the station manager attached to this MAC. 00165 */ 00166 virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager) = 0; 00167 /** 00168 * \param upCallback the callback to invoke when a packet must be forwarded up the stack. 00169 */ 00170 virtual void SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback) = 0; 00171 /** 00172 * \param linkUp the callback to invoke when the link becomes up. 00173 */ 00174 virtual void SetLinkUpCallback (Callback<void> linkUp) = 0; 00175 /** 00176 * \param linkDown the callback to invoke when the link becomes down. 00177 */ 00178 virtual void SetLinkDownCallback (Callback<void> linkDown) = 0; 00179 private: 00180 00181 00182 00183 static Time GetDefaultMaxPropagationDelay (void); 00184 static Time GetDefaultSlot (void); 00185 static Time GetDefaultSifs (void); 00186 static Time GetDefaultEifsNoDifs (void); 00187 static Time GetDefaultCtsAckDelay (void); 00188 static Time GetDefaultCtsAckTimeout (void); 00189 00190 Time m_maxPropagationDelay; 00191 uint32_t m_maxMsduSize; 00192 }; 00193 00194 } // namespace ns3 00195 00196 #endif /* WIFI_MAC_H */