Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
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 #ifndef REGULAR_WIFI_MAC_H | |
21 #define REGULAR_WIFI_MAC_H | |
22 | |
23 #include "ns3/wifi-mac.h" | |
24 | |
25 #include "dca-txop.h" | |
26 #include "edca-txop-n.h" | |
27 #include "wifi-remote-station-manager.h" | |
28 #include "ssid.h" | |
29 #include "qos-utils.h" | |
30 | |
31 #include <map> | |
32 | |
33 namespace ns3 { | |
34 | |
35 class Dcf; | |
36 class MacLow; | |
37 class MacRxMiddle; | |
38 class MacTxMiddle; | |
39 class DcfManager; | |
40 | |
41 /** | |
42 * \brief base class for all MAC-level wifi objects. | |
43 * | |
44 * This class encapsulates all the low-level MAC functionality | |
45 * DCA, EDCA, etc) and all the high-level MAC functionality | |
46 * (association/disassociation state machines). | |
47 * | |
48 */ | |
49 class RegularWifiMac : public WifiMac | |
50 { | |
51 public: | |
52 static TypeId GetTypeId (void); | |
53 | |
54 RegularWifiMac (); | |
55 virtual ~RegularWifiMac (); | |
56 | |
57 /** | |
58 * \param slotTime the slot duration | |
59 */ | |
60 void SetSlot (Time slotTime); | |
61 /** | |
62 * \param sifs the sifs duration | |
63 */ | |
64 void SetSifs (Time sifs); | |
65 /** | |
66 * \param eifsNoDifs the duration of an EIFS minus DIFS. | |
67 * | |
68 * This value is used to calculate the EIFS depending | |
69 * on AIFSN. | |
70 */ | |
71 void SetEifsNoDifs (Time eifsNoDifs); | |
72 /** | |
73 * \param pifs the pifs duration. | |
74 */ | |
75 void SetPifs (Time pifs); | |
76 /** | |
77 * \param ctsTimeout the duration of a CTS timeout. | |
78 */ | |
79 void SetCtsTimeout (Time ctsTimeout); | |
80 /** | |
81 * \param ackTimeout the duration of an ACK timeout. | |
82 */ | |
83 void SetAckTimeout (Time ackTimeout); | |
84 /** | |
85 * \returns the current PIFS duration. | |
86 */ | |
87 Time GetPifs (void) const; | |
88 /** | |
89 * \returns the current SIFS duration. | |
90 */ | |
91 Time GetSifs (void) const; | |
92 /** | |
93 * \returns the current slot duration. | |
94 */ | |
95 Time GetSlot (void) const; | |
96 /** | |
97 * \returns the current EIFS minus DIFS duration | |
98 */ | |
99 Time GetEifsNoDifs (void) const; | |
100 /** | |
101 * \returns the current CTS timeout duration. | |
102 */ | |
103 Time GetCtsTimeout (void) const; | |
104 /** | |
105 * \returns the current ACK timeout duration. | |
106 */ | |
107 Time GetAckTimeout (void) const; | |
108 /** | |
109 * \returns the MAC address associated to this MAC layer. | |
110 */ | |
111 virtual Mac48Address GetAddress (void) const; | |
112 /** | |
113 * \returns the ssid which this MAC layer is going to try to stay in. | |
114 */ | |
115 virtual Ssid GetSsid (void) const; | |
116 /** | |
117 * \param address the current address of this MAC layer. | |
118 */ | |
119 virtual void SetAddress (Mac48Address address); | |
120 /** | |
121 * \param ssid the current ssid of this MAC layer. | |
122 */ | |
123 virtual void SetSsid (Ssid ssid); | |
124 /** | |
125 * \param bssid the BSSID of the network that this device belongs to. | |
126 */ | |
127 virtual void SetBssid (Mac48Address bssid); | |
128 /** | |
129 * \returns the bssid of the network this device belongs to. | |
130 */ | |
131 virtual Mac48Address GetBssid (void) const; | |
132 | |
133 /** | |
134 * \param packet the packet to send. | |
135 * \param to the address to which the packet should be sent. | |
136 * \param from the address from which the packet should be sent. | |
137 * | |
138 * The packet should be enqueued in a tx queue, and should be | |
139 * dequeued as soon as the channel access function determines that | |
140 * access is granted to this MAC. The extra parameter "from" allows | |
141 * this device to operate in a bridged mode, forwarding received | |
142 * frames without altering the source address. | |
143 */ | |
144 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from); | |
145 virtual bool SupportsSendFrom (void) const; | |
146 | |
147 /** | |
148 * \param packet the packet to send. | |
149 * \param to the address to which the packet should be sent. | |
150 * | |
151 * The packet should be enqueued in a tx queue, and should be | |
152 * dequeued as soon as the channel access function determines that | |
153 * access is granted to this MAC. | |
154 */ | |
155 virtual void Enqueue (Ptr<const Packet> packet, Mac48Address to) = 0; | |
156 /** | |
157 * \param phy the physical layer attached to this MAC. | |
158 */ | |
159 virtual void SetWifiPhy (Ptr<WifiPhy> phy); | |
160 /** | |
161 * \returns the physical layer attached to this MAC. | |
162 */ | |
163 virtual Ptr<WifiPhy> GetWifiPhy () const; | |
164 /** | |
165 * \param stationManager the station manager attached to this MAC. | |
166 */ | |
167 virtual void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> statio nManager); | |
168 /** | |
169 * \returns the station manager attached to this MAC. | |
170 */ | |
171 virtual Ptr<WifiRemoteStationManager> GetWifiRemoteStationManager () const; | |
172 | |
173 /** | |
174 * This type defines the callback of a higher layer that a | |
175 * WifiMac(-derived) object invokes to pass a packet up the stack. | |
176 * | |
177 * \param packet the packet that has been received. | |
178 * \param from the MAC address of the device that sent the packet. | |
179 * \param to the MAC address ot the device that the packet is | |
180 * destined for. | |
181 */ | |
182 typedef Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> ForwardUpCallb ack; | |
183 /** | |
184 * \param upCallback the callback to invoke when a packet must be | |
185 * forwarded up the stack. | |
186 */ | |
187 virtual void SetForwardUpCallback (ForwardUpCallback upCallback); | |
188 /** | |
189 * \param linkUp the callback to invoke when the link becomes up. | |
190 */ | |
191 virtual void SetLinkUpCallback (Callback<void> linkUp); | |
192 /** | |
193 * \param linkDown the callback to invoke when the link becomes down. | |
194 */ | |
195 virtual void SetLinkDownCallback (Callback<void> linkDown); | |
196 /* Next functions are not pure virtual so non Qos WifiMacs are not | |
197 * forced to implement them. | |
198 */ | |
199 virtual void SetBasicBlockAckTimeout (Time blockAckTimeout); | |
200 virtual Time GetBasicBlockAckTimeout (void) const; | |
201 virtual void SetCompressedBlockAckTimeout (Time blockAckTimeout); | |
202 virtual Time GetCompressedBlockAckTimeout (void) const; | |
203 | |
204 protected: | |
205 virtual void DoStart (); | |
206 virtual void DoDispose (); | |
207 | |
208 MacRxMiddle *m_rxMiddle; | |
209 MacTxMiddle *m_txMiddle; | |
210 Ptr<MacLow> m_low; | |
211 DcfManager *m_dcfManager; | |
212 Ptr<WifiPhy> m_phy; | |
213 | |
214 Ptr<WifiRemoteStationManager> m_stationManager; | |
215 | |
216 ForwardUpCallback m_forwardUp; | |
217 Callback<void> m_linkUp; | |
218 Callback<void> m_linkDown; | |
219 | |
220 Ssid m_ssid; | |
221 | |
222 /** This holds a pointer to the DCF instance for this WifiMac - used | |
223 for transmission of frames to non-QoS peers. */ | |
224 Ptr<DcaTxop> m_dca; | |
225 | |
226 /** This type defines a mapping between an Access Category index, | |
227 and a pointer to the corresponding channel access function */ | |
228 typedef std::map<AcIndex, Ptr<EdcaTxopN> > EdcaQueues; | |
229 /** This is a map from Access Category index to the corresponding | |
230 channel access function */ | |
231 EdcaQueues m_edca; | |
232 | |
233 /** | |
234 * \param standard the phy standard to be used | |
235 * | |
236 * This method is called by ns3::WifiMac::ConfigureStandard to | |
237 * complete the configuration process for a requested phy standard. | |
238 * | |
239 * This method may be overriden by a derived class (e.g., in order | |
240 * to apply DCF or EDCA parameters specific to the usage model it is | |
241 * dealing with), in which case the reimplementation may choose to | |
242 * deal with certain values in the WifiPhyStandard enumeration, and | |
243 * chain up to this implementation to deal with the remainder. | |
244 */ | |
245 virtual void FinishConfigureStandard (enum WifiPhyStandard standard); | |
246 | |
247 /** | |
248 * This method is invoked by a subclass to specify what type of | |
249 * station it is implementing. This is something that the channel | |
250 * access functions (instantiated within this class as EdcaTxopN's) | |
251 * need to know. | |
252 * | |
253 * \param type the type of station. | |
254 */ | |
255 void SetTypeOfStation (TypeOfStation type); | |
256 | |
257 /** | |
258 * This method acts as the MacRxMiddle receive callback and is | |
259 * invoked to notify us that a frame has been received. The | |
260 * implementation is intended to capture logic that is going to be | |
261 * common to all (or most) derived classes. Specifically, handling | |
262 * of Block Ack managment frames is dealt with here. | |
263 * | |
264 * This method will need, however, to be overriden by derived | |
265 * classes so that they can perform their data handling before | |
266 * invoking the base version. | |
267 * | |
268 * \param packet the packet that has been received. | |
269 * \param hdr a pointer to the MAC header of the received frame. | |
270 */ | |
271 virtual void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr); | |
272 virtual void TxOk (const WifiMacHeader &hdr); | |
273 virtual void TxFailed (const WifiMacHeader &hdr); | |
274 | |
275 void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to); | |
276 | |
277 /** | |
278 * This method can be called to de-aggregate an A-MSDU and forward | |
279 * the constituent packets up the stack. | |
280 * | |
281 * \param aggregatedPacket the Packet containing the A-MSDU. | |
282 * \param hdr a pointer to the MAC header for \c aggregatedPacket. | |
283 */ | |
284 virtual void DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, | |
285 const WifiMacHeader *hdr); | |
286 | |
287 /** | |
288 * This method can be called to accept a received ADDBA Request. An | |
289 * ADDBA Response will be constructed and queued for transmission. | |
290 * | |
291 * \param reqHdr a pointer to the received ADDBA Request header. | |
292 * \param originator the MAC address of the originator. | |
293 */ | |
294 virtual void SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, | |
295 Mac48Address originator); | |
296 | |
297 /** | |
298 * This Boolean is set \c true iff this WifiMac is to model | |
299 * 802.11e/WMM style Quality of Service. It is exposed through the | |
300 * attribute system. | |
301 * | |
302 * At the moment, this flag is the sole selection between QoS and | |
303 * non-QoS operation for the STA (whether IBSS, AP, or | |
304 * non-AP). Ultimately, we will want a QoS-enabled STA to be able to | |
305 * fall back to non-QoS operation with a non-QoS peer. This'll | |
306 * require further intelligence - i.e., per-association QoS | |
307 * state. Having a big switch seems like a good intermediate stage, | |
308 * however. | |
309 */ | |
310 bool m_qosSupported; | |
311 /** Set accessor for the \c m_qosSupported member */ | |
312 void SetQosSupported (bool enable); | |
313 /** Get accessor for the \c m_qosSupported member */ | |
314 bool GetQosSupported () const; | |
315 private: | |
316 /** | |
317 * This method is a private utility invoked to configure the channel | |
318 * access function for the specified Access Category. | |
319 * | |
320 * \param ac the Access Category index of the queue to initialise. | |
321 */ | |
322 void SetupEdcaQueue (enum AcIndex ac); | |
Gary Pei
2010/09/17 23:05:42
Can you move this to "protected" rather than privt
Dean
2010/09/30 20:13:46
Done.
| |
323 | |
324 /** Accessor for the DCF object */ | |
325 Ptr<DcaTxop> GetDcaTxop (void) const; | |
326 | |
327 /** Accessor for the AC_VO channel access function */ | |
328 Ptr<EdcaTxopN> GetVOQueue (void) const; | |
329 /** Accessor for the AC_VI channel access function */ | |
330 Ptr<EdcaTxopN> GetVIQueue (void) const; | |
331 /** Accessor for the AC_BE channel access function */ | |
332 Ptr<EdcaTxopN> GetBEQueue (void) const; | |
333 /** Accessor for the AC_BK channel access function */ | |
334 Ptr<EdcaTxopN> GetBKQueue (void) const; | |
335 | |
336 TracedCallback<const WifiMacHeader &> m_txOkCallback; | |
337 TracedCallback<const WifiMacHeader &> m_txErrCallback; | |
338 }; | |
339 | |
340 } // namespace ns3 | |
341 | |
342 #endif /* REGULAR_WIFI_MAC_H */ | |
OLD | NEW |