author | Mirko Banchi <mk.banchi@gmail.com> |
Wed, 03 Feb 2010 20:34:51 +0100 | |
changeset 5956 | e9918be47f78 |
parent 5953 | 9e400f6b8a2c |
child 5958 | dd0accd82659 |
permissions | -rw-r--r-- |
4408 | 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 |
#include "ns3/assert.h" |
|
23 |
#include "ns3/log.h" |
|
24 |
#include "ns3/simulator.h" |
|
25 |
#include "ns3/string.h" |
|
26 |
#include "ns3/pointer.h" |
|
27 |
||
28 |
#include "qos-tag.h" |
|
29 |
#include "qap-wifi-mac.h" |
|
30 |
#include "dca-txop.h" |
|
31 |
#include "edca-txop-n.h" |
|
32 |
#include "wifi-phy.h" |
|
33 |
#include "dcf-manager.h" |
|
34 |
#include "mac-rx-middle.h" |
|
35 |
#include "mac-tx-middle.h" |
|
36 |
#include "mgt-headers.h" |
|
37 |
#include "mac-low.h" |
|
38 |
#include "amsdu-subframe-header.h" |
|
39 |
#include "msdu-aggregator.h" |
|
40 |
||
41 |
NS_LOG_COMPONENT_DEFINE ("QapWifiMac"); |
|
42 |
||
43 |
namespace ns3 { |
|
44 |
||
45 |
NS_OBJECT_ENSURE_REGISTERED (QapWifiMac); |
|
46 |
||
47 |
TypeId |
|
48 |
QapWifiMac::GetTypeId (void) |
|
49 |
{ |
|
50 |
static TypeId tid = TypeId ("ns3::QapWifiMac") |
|
51 |
.SetParent<WifiMac> () |
|
52 |
.AddConstructor<QapWifiMac> () |
|
53 |
.AddAttribute ("BeaconInterval", "Delay between two beacons", |
|
54 |
TimeValue (Seconds (0.1)), |
|
55 |
MakeTimeAccessor (&QapWifiMac::GetBeaconInterval, |
|
56 |
&QapWifiMac::SetBeaconInterval), |
|
57 |
MakeTimeChecker ()) |
|
58 |
.AddAttribute ("BeaconGeneration", "Whether or not beacons are generated.", |
|
59 |
BooleanValue (true), |
|
60 |
MakeBooleanAccessor (&QapWifiMac::SetBeaconGeneration, |
|
61 |
&QapWifiMac::GetBeaconGeneration), |
|
62 |
MakeBooleanChecker ()) |
|
63 |
.AddAttribute ("VO_EdcaTxopN", |
|
64 |
"Queue that manages packets belonging to AC_VO access class", |
|
65 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
66 |
MakePointerAccessor(&QapWifiMac::GetVOQueue), |
4408 | 67 |
MakePointerChecker<EdcaTxopN> ()) |
68 |
.AddAttribute ("VI_EdcaTxopN", |
|
69 |
"Queue that manages packets belonging to AC_VI access class", |
|
70 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
71 |
MakePointerAccessor(&QapWifiMac::GetVIQueue), |
4408 | 72 |
MakePointerChecker<EdcaTxopN> ()) |
73 |
.AddAttribute ("BE_EdcaTxopN", |
|
74 |
"Queue that manages packets belonging to AC_BE access class", |
|
75 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
76 |
MakePointerAccessor(&QapWifiMac::GetBEQueue), |
4408 | 77 |
MakePointerChecker<EdcaTxopN> ()) |
78 |
.AddAttribute ("BK_EdcaTxopN", |
|
79 |
"Queue that manages packets belonging to AC_BK access class", |
|
80 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
81 |
MakePointerAccessor(&QapWifiMac::GetBKQueue), |
4408 | 82 |
MakePointerChecker<EdcaTxopN> ()) |
83 |
; |
|
84 |
return tid; |
|
85 |
} |
|
86 |
||
87 |
QapWifiMac::QapWifiMac () |
|
88 |
{ |
|
89 |
NS_LOG_FUNCTION (this); |
|
90 |
m_rxMiddle = new MacRxMiddle (); |
|
91 |
m_rxMiddle->SetForwardCallback (MakeCallback (&QapWifiMac::Receive, this)); |
|
92 |
||
93 |
m_txMiddle = new MacTxMiddle (); |
|
94 |
||
95 |
m_low = CreateObject<MacLow> (); |
|
96 |
m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); |
|
97 |
||
98 |
m_dcfManager = new DcfManager (); |
|
99 |
m_dcfManager->SetupLowListener (m_low); |
|
100 |
||
101 |
m_beaconDca = CreateObject<DcaTxop> (); |
|
102 |
m_beaconDca->SetAifsn(1); |
|
103 |
m_beaconDca->SetMinCw(0); |
|
104 |
m_beaconDca->SetMaxCw(0); |
|
105 |
m_beaconDca->SetLow (m_low); |
|
106 |
m_beaconDca->SetManager (m_dcfManager); |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
107 |
|
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
108 |
SetQueue (AC_VO); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
109 |
SetQueue (AC_VI); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
110 |
SetQueue (AC_BE); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
111 |
SetQueue (AC_BK); |
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
112 |
|
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
113 |
m_enableBeaconGeneration = false; |
4408 | 114 |
} |
115 |
||
116 |
QapWifiMac::~QapWifiMac () |
|
117 |
{ |
|
118 |
NS_LOG_FUNCTION (this); |
|
119 |
} |
|
120 |
||
121 |
void |
|
122 |
QapWifiMac::DoDispose () |
|
123 |
{ |
|
124 |
delete m_rxMiddle; |
|
4687
02bf728f7e39
bug 381: Wifi crashes on shutdown
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4461
diff
changeset
|
125 |
delete m_txMiddle; |
02bf728f7e39
bug 381: Wifi crashes on shutdown
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4461
diff
changeset
|
126 |
delete m_dcfManager; |
02bf728f7e39
bug 381: Wifi crashes on shutdown
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4461
diff
changeset
|
127 |
m_low->Dispose (); |
4408 | 128 |
m_rxMiddle = 0; |
129 |
m_txMiddle = 0; |
|
130 |
m_dcfManager = 0; |
|
131 |
m_low = 0; |
|
132 |
m_phy = 0; |
|
133 |
m_beaconDca = 0; |
|
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
134 |
m_enableBeaconGeneration = false; |
4408 | 135 |
m_beaconEvent.Cancel (); |
136 |
m_stationManager = 0; |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
137 |
for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) |
4408 | 138 |
{ |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
139 |
(*i).second = 0; |
4408 | 140 |
} |
141 |
WifiMac::DoDispose (); |
|
142 |
} |
|
143 |
||
144 |
void |
|
145 |
QapWifiMac::SetBeaconGeneration (bool enable) |
|
146 |
{ |
|
147 |
NS_LOG_FUNCTION (this << enable); |
|
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
148 |
if (!enable) |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
149 |
{ |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
150 |
m_beaconEvent.Cancel (); |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
151 |
} |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
152 |
else if (enable && !m_enableBeaconGeneration) |
4408 | 153 |
{ |
154 |
m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this); |
|
155 |
} |
|
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
156 |
m_enableBeaconGeneration = enable; |
4408 | 157 |
} |
158 |
||
159 |
bool |
|
160 |
QapWifiMac::GetBeaconGeneration (void) const |
|
161 |
{ |
|
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
162 |
return m_enableBeaconGeneration; |
4408 | 163 |
} |
164 |
||
165 |
Time |
|
166 |
QapWifiMac::GetBeaconInterval (void) const |
|
167 |
{ |
|
168 |
return m_beaconInterval; |
|
169 |
} |
|
170 |
||
171 |
void |
|
172 |
QapWifiMac::SetSlot (Time slotTime) |
|
173 |
{ |
|
174 |
NS_LOG_FUNCTION (this << slotTime); |
|
175 |
m_dcfManager->SetSlot (slotTime); |
|
176 |
m_low->SetSlotTime (slotTime); |
|
177 |
} |
|
178 |
||
179 |
void |
|
180 |
QapWifiMac::SetSifs (Time sifs) |
|
181 |
{ |
|
182 |
NS_LOG_FUNCTION (this << sifs); |
|
183 |
m_dcfManager->SetSifs (sifs); |
|
184 |
m_low->SetSifs (sifs); |
|
185 |
} |
|
186 |
||
187 |
void |
|
188 |
QapWifiMac::SetEifsNoDifs (Time eifsNoDifs) |
|
189 |
{ |
|
190 |
NS_LOG_FUNCTION (this << eifsNoDifs); |
|
191 |
m_dcfManager->SetEifsNoDifs (eifsNoDifs); |
|
192 |
} |
|
193 |
||
194 |
void |
|
195 |
QapWifiMac::SetAckTimeout (Time ackTimeout) |
|
196 |
{ |
|
197 |
m_low->SetAckTimeout (ackTimeout); |
|
198 |
} |
|
199 |
||
200 |
void |
|
201 |
QapWifiMac::SetCtsTimeout (Time ctsTimeout) |
|
202 |
{ |
|
203 |
m_low->SetCtsTimeout (ctsTimeout); |
|
204 |
} |
|
205 |
||
206 |
void |
|
207 |
QapWifiMac::SetPifs (Time pifs) |
|
208 |
{ |
|
209 |
m_low->SetPifs (pifs); |
|
210 |
} |
|
211 |
||
212 |
Time |
|
213 |
QapWifiMac::GetSlot (void) const |
|
214 |
{ |
|
215 |
return m_low->GetSlotTime (); |
|
216 |
} |
|
217 |
||
218 |
Time |
|
219 |
QapWifiMac::GetSifs (void) const |
|
220 |
{ |
|
221 |
return m_low->GetSifs (); |
|
222 |
} |
|
223 |
||
224 |
Time |
|
225 |
QapWifiMac::GetEifsNoDifs (void) const |
|
226 |
{ |
|
4461
ab9b58d664d7
move GetEifsNoDifs to DcfManager
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4424
diff
changeset
|
227 |
return m_dcfManager->GetEifsNoDifs (); |
4408 | 228 |
} |
229 |
||
230 |
Time |
|
231 |
QapWifiMac::GetAckTimeout (void) const |
|
232 |
{ |
|
233 |
return m_low->GetAckTimeout (); |
|
234 |
} |
|
235 |
||
236 |
Time |
|
237 |
QapWifiMac::GetCtsTimeout (void) const |
|
238 |
{ |
|
239 |
return m_low->GetCtsTimeout (); |
|
240 |
} |
|
241 |
||
242 |
Time |
|
243 |
QapWifiMac::GetPifs (void) const |
|
244 |
{ |
|
245 |
return m_low->GetPifs (); |
|
246 |
} |
|
247 |
||
248 |
void |
|
249 |
QapWifiMac::SetWifiPhy (Ptr<WifiPhy> phy) |
|
250 |
{ |
|
251 |
NS_LOG_FUNCTION (this << phy); |
|
252 |
m_phy = phy; |
|
253 |
m_dcfManager->SetupPhyListener (phy); |
|
254 |
m_low->SetPhy (phy); |
|
255 |
} |
|
256 |
||
257 |
void |
|
258 |
QapWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager) |
|
259 |
{ |
|
260 |
NS_LOG_FUNCTION (this << stationManager); |
|
261 |
m_stationManager = stationManager; |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
262 |
for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
263 |
{ |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
264 |
(*i).second->SetWifiRemoteStationManager (stationManager); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
265 |
} |
4408 | 266 |
m_beaconDca->SetWifiRemoteStationManager (stationManager); |
267 |
m_low->SetWifiRemoteStationManager (stationManager); |
|
268 |
} |
|
269 |
||
270 |
void |
|
271 |
QapWifiMac::SetForwardUpCallback (Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> upCallback) |
|
272 |
{ |
|
273 |
NS_LOG_FUNCTION (this); |
|
274 |
m_forwardUp = upCallback; |
|
275 |
} |
|
276 |
||
277 |
void |
|
278 |
QapWifiMac::SetLinkUpCallback (Callback<void> linkUp) |
|
279 |
{ |
|
280 |
NS_LOG_FUNCTION (this); |
|
281 |
if (!linkUp.IsNull ()) |
|
282 |
{ |
|
283 |
linkUp (); |
|
284 |
} |
|
285 |
} |
|
286 |
||
287 |
void |
|
288 |
QapWifiMac::SetLinkDownCallback (Callback<void> linkDown) |
|
289 |
{ |
|
290 |
NS_LOG_FUNCTION (this); |
|
291 |
} |
|
292 |
||
293 |
Mac48Address |
|
294 |
QapWifiMac::GetAddress () const |
|
295 |
{ |
|
296 |
return m_low->GetAddress (); |
|
297 |
} |
|
298 |
||
299 |
Ssid |
|
300 |
QapWifiMac::GetSsid (void) const |
|
301 |
{ |
|
302 |
return m_ssid; |
|
303 |
} |
|
304 |
||
305 |
void |
|
306 |
QapWifiMac::SetAddress (Mac48Address address) |
|
307 |
{ |
|
308 |
NS_LOG_FUNCTION (address); |
|
309 |
m_low->SetAddress (address); |
|
310 |
m_low->SetBssid (address); |
|
311 |
} |
|
312 |
||
313 |
void |
|
314 |
QapWifiMac::SetSsid (Ssid ssid) |
|
315 |
{ |
|
316 |
NS_LOG_FUNCTION (this << ssid); |
|
317 |
m_ssid = ssid; |
|
318 |
} |
|
319 |
||
320 |
Mac48Address |
|
321 |
QapWifiMac::GetBssid (void) const |
|
322 |
{ |
|
323 |
return m_low->GetBssid (); |
|
324 |
} |
|
325 |
||
326 |
void |
|
327 |
QapWifiMac::SetBeaconInterval (Time interval) |
|
328 |
{ |
|
329 |
NS_LOG_FUNCTION (this << interval); |
|
330 |
m_beaconInterval = interval; |
|
331 |
} |
|
332 |
||
333 |
void |
|
334 |
QapWifiMac::StartBeaconing (void) |
|
335 |
{ |
|
336 |
NS_LOG_FUNCTION (this); |
|
337 |
SendOneBeacon (); |
|
338 |
} |
|
339 |
||
340 |
void |
|
341 |
QapWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to) |
|
342 |
{ |
|
343 |
NS_LOG_FUNCTION (this << packet << from); |
|
344 |
m_forwardUp (packet, from, to); |
|
345 |
} |
|
346 |
||
347 |
void |
|
348 |
QapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to) |
|
349 |
{ |
|
350 |
/* For now Qos AP sends only Qos frame. In the future it should be able to |
|
351 |
send frames also to Non-Qos Stas. |
|
352 |
*/ |
|
353 |
NS_LOG_FUNCTION (this << packet << from << to); |
|
354 |
WifiMacHeader hdr; |
|
355 |
hdr.SetType (WIFI_MAC_QOSDATA); |
|
356 |
hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); |
|
357 |
hdr.SetQosNoEosp (); |
|
358 |
hdr.SetQosNoAmsdu (); |
|
359 |
/* Transmission of multiple frames in the same |
|
360 |
Txop is not supported for now */ |
|
361 |
hdr.SetQosTxopLimit (0); |
|
362 |
||
363 |
hdr.SetAddr1 (to); |
|
364 |
hdr.SetAddr2 (GetAddress ()); |
|
365 |
hdr.SetAddr3 (from); |
|
366 |
hdr.SetDsFrom (); |
|
367 |
hdr.SetDsNotTo (); |
|
368 |
||
369 |
uint8_t tid = QosUtilsGetTidForPacket (packet); |
|
370 |
if (tid < 8) |
|
371 |
{ |
|
372 |
hdr.SetQosTid (tid); |
|
373 |
AccessClass ac = QosUtilsMapTidToAc (tid); |
|
374 |
m_queues[ac]->Queue (packet, hdr); |
|
375 |
} |
|
376 |
else |
|
377 |
{ |
|
378 |
//packet is considerated belonging to BestEffort AC |
|
379 |
hdr.SetQosTid (0); |
|
380 |
m_queues[AC_BE]->Queue (packet, hdr); |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
void |
|
385 |
QapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to, |
|
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5747
diff
changeset
|
386 |
const WifiMacHeader *oldHdr) |
4408 | 387 |
{ |
388 |
/* For now Qos AP sends only Qos frame. In the future it should be able to |
|
389 |
send frames also to Non-Qos Stas. |
|
390 |
*/ |
|
391 |
NS_LOG_FUNCTION (this << packet << from << to); |
|
392 |
NS_ASSERT (oldHdr->IsQosData ()); |
|
393 |
WifiMacHeader hdr; |
|
394 |
hdr.SetType (WIFI_MAC_QOSDATA); |
|
395 |
hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); |
|
396 |
hdr.SetQosNoEosp (); |
|
397 |
hdr.SetQosNoAmsdu (); |
|
398 |
/* Transmission of multiple frames in the same |
|
399 |
Txop is not supported for now */ |
|
400 |
hdr.SetQosTxopLimit (0); |
|
401 |
hdr.SetQosTid (oldHdr->GetQosTid ()); |
|
402 |
||
403 |
hdr.SetAddr1 (to); |
|
404 |
hdr.SetAddr2 (GetAddress ()); |
|
405 |
hdr.SetAddr3 (from); |
|
406 |
hdr.SetDsFrom (); |
|
407 |
hdr.SetDsNotTo (); |
|
408 |
||
409 |
AccessClass ac = QosUtilsMapTidToAc (oldHdr->GetQosTid ()); |
|
410 |
m_queues[ac]->Queue (packet, hdr); |
|
411 |
} |
|
412 |
||
413 |
void |
|
414 |
QapWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from) |
|
415 |
{ |
|
416 |
NS_LOG_FUNCTION (this << packet << from << to); |
|
417 |
ForwardDown (packet, from, to); |
|
418 |
} |
|
419 |
||
420 |
void |
|
421 |
QapWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to) |
|
422 |
{ |
|
423 |
NS_LOG_FUNCTION (this << packet << to); |
|
424 |
ForwardDown (packet, m_low->GetAddress (), to); |
|
425 |
} |
|
426 |
||
427 |
bool |
|
428 |
QapWifiMac::SupportsSendFrom (void) const |
|
429 |
{ |
|
430 |
return true; |
|
431 |
} |
|
432 |
||
433 |
SupportedRates |
|
434 |
QapWifiMac::GetSupportedRates (void) const |
|
435 |
{ |
|
436 |
// send the set of supported rates and make sure that we indicate |
|
437 |
// the Basic Rate set in this set of supported rates. |
|
438 |
SupportedRates rates; |
|
439 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
|
440 |
{ |
|
441 |
WifiMode mode = m_phy->GetMode (i); |
|
442 |
rates.AddSupportedRate (mode.GetDataRate ()); |
|
443 |
} |
|
444 |
// set the basic rates |
|
445 |
for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++) |
|
446 |
{ |
|
447 |
WifiMode mode = m_stationManager->GetBasicMode (j); |
|
448 |
rates.SetBasicRate (mode.GetDataRate ()); |
|
449 |
} |
|
450 |
return rates; |
|
451 |
} |
|
452 |
||
453 |
void |
|
454 |
QapWifiMac::SendProbeResp (Mac48Address to) |
|
455 |
{ |
|
456 |
NS_LOG_FUNCTION (this << to); |
|
457 |
WifiMacHeader hdr; |
|
458 |
hdr.SetProbeResp (); |
|
459 |
hdr.SetAddr1 (to); |
|
460 |
hdr.SetAddr2 (GetAddress ()); |
|
461 |
hdr.SetAddr3 (GetAddress ()); |
|
462 |
hdr.SetDsNotFrom (); |
|
463 |
hdr.SetDsNotTo (); |
|
464 |
Ptr<Packet> packet = Create<Packet> (); |
|
465 |
MgtProbeResponseHeader probe; |
|
466 |
probe.SetSsid (GetSsid ()); |
|
467 |
probe.SetSupportedRates (GetSupportedRates ()); |
|
468 |
probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ()); |
|
469 |
packet->AddHeader (probe); |
|
470 |
||
471 |
/* Which is correct queue for management frames ? */ |
|
472 |
m_queues[AC_VO]->Queue (packet, hdr); |
|
473 |
} |
|
474 |
||
475 |
void |
|
476 |
QapWifiMac::SendAssocResp (Mac48Address to, bool success) |
|
477 |
{ |
|
478 |
NS_LOG_FUNCTION (this << to << success); |
|
479 |
WifiMacHeader hdr; |
|
480 |
hdr.SetAssocResp (); |
|
481 |
hdr.SetAddr1 (to); |
|
482 |
hdr.SetAddr2 (GetAddress ()); |
|
483 |
hdr.SetAddr3 (GetAddress ()); |
|
484 |
hdr.SetDsNotFrom (); |
|
485 |
hdr.SetDsNotTo (); |
|
486 |
Ptr<Packet> packet = Create<Packet> (); |
|
487 |
MgtAssocResponseHeader assoc; |
|
488 |
StatusCode code; |
|
489 |
if (success) |
|
490 |
{ |
|
491 |
code.SetSuccess (); |
|
492 |
} |
|
493 |
else |
|
494 |
{ |
|
495 |
code.SetFailure (); |
|
496 |
} |
|
497 |
assoc.SetSupportedRates (GetSupportedRates ()); |
|
498 |
assoc.SetStatusCode (code); |
|
499 |
packet->AddHeader (assoc); |
|
500 |
||
501 |
/* Which is correct queue for management frames ? */ |
|
502 |
m_queues[AC_VO]->Queue (packet, hdr); |
|
503 |
} |
|
504 |
||
505 |
void |
|
506 |
QapWifiMac::SendOneBeacon (void) |
|
507 |
{ |
|
508 |
NS_LOG_FUNCTION (this); |
|
509 |
WifiMacHeader hdr; |
|
510 |
hdr.SetBeacon (); |
|
511 |
hdr.SetAddr1 (Mac48Address::GetBroadcast ()); |
|
512 |
hdr.SetAddr2 (GetAddress ()); |
|
513 |
hdr.SetAddr3 (GetAddress ()); |
|
514 |
hdr.SetDsNotFrom (); |
|
515 |
hdr.SetDsNotTo (); |
|
516 |
Ptr<Packet> packet = Create<Packet> (); |
|
517 |
MgtBeaconHeader beacon; |
|
518 |
beacon.SetSsid (GetSsid ()); |
|
519 |
beacon.SetSupportedRates (GetSupportedRates ()); |
|
520 |
beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ()); |
|
521 |
||
522 |
packet->AddHeader (beacon); |
|
523 |
||
524 |
m_beaconDca->Queue (packet, hdr); |
|
525 |
m_beaconEvent = Simulator::Schedule (m_beaconInterval, &QapWifiMac::SendOneBeacon, this); |
|
526 |
} |
|
527 |
||
528 |
void |
|
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5747
diff
changeset
|
529 |
QapWifiMac::TxOk (const WifiMacHeader &hdr) |
4408 | 530 |
{ |
531 |
NS_LOG_FUNCTION (this); |
|
532 |
WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ()); |
|
533 |
if (hdr.IsAssocResp () && |
|
534 |
station->IsWaitAssocTxOk ()) |
|
535 |
{ |
|
536 |
NS_LOG_DEBUG ("associated with sta="<<hdr.GetAddr1 ()); |
|
537 |
station->RecordGotAssocTxOk (); |
|
538 |
} |
|
539 |
} |
|
540 |
||
541 |
void |
|
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5747
diff
changeset
|
542 |
QapWifiMac::TxFailed (const WifiMacHeader &hdr) |
4408 | 543 |
{ |
544 |
NS_LOG_FUNCTION (this); |
|
545 |
WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ()); |
|
546 |
if (hdr.IsAssocResp () && |
|
547 |
station->IsWaitAssocTxOk ()) |
|
548 |
{ |
|
549 |
NS_LOG_DEBUG ("assoc failed with sta="<<hdr.GetAddr1 ()); |
|
550 |
station->RecordGotAssocTxFailed (); |
|
551 |
} |
|
552 |
} |
|
553 |
||
554 |
void |
|
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5747
diff
changeset
|
555 |
QapWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) |
4408 | 556 |
{ |
557 |
NS_LOG_FUNCTION (this << packet << hdr); |
|
558 |
||
559 |
Mac48Address from = hdr->GetAddr2 (); |
|
560 |
WifiRemoteStation *fromStation = m_stationManager->Lookup (from); |
|
561 |
||
562 |
if (hdr->IsData ()) |
|
563 |
{ |
|
564 |
Mac48Address bssid = hdr->GetAddr1 (); |
|
565 |
if (!hdr->IsFromDs () && |
|
566 |
hdr->IsToDs () && |
|
567 |
bssid == GetAddress () && |
|
568 |
fromStation->IsAssociated ()) |
|
569 |
{ |
|
570 |
Mac48Address to = hdr->GetAddr3 (); |
|
571 |
WifiRemoteStation *toStation = m_stationManager->Lookup (to); |
|
572 |
||
573 |
if (to == GetAddress ()) |
|
574 |
{ |
|
575 |
NS_LOG_DEBUG ("frame for me (Qap) from="<<from); |
|
576 |
if (hdr->IsQosData ()) |
|
577 |
{ |
|
578 |
if (hdr->IsQosAmsdu ()) |
|
579 |
{ |
|
580 |
NS_LOG_DEBUG ("Received A-MSDU from="<<from<<", size="<<packet->GetSize ()); |
|
581 |
DeaggregateAmsduAndForward (packet, hdr); |
|
582 |
packet = 0; |
|
583 |
} |
|
584 |
else |
|
585 |
{ |
|
586 |
ForwardUp (packet, from, bssid); |
|
587 |
} |
|
588 |
} |
|
589 |
else |
|
590 |
{ |
|
591 |
ForwardUp (packet, from, bssid); |
|
592 |
} |
|
593 |
} |
|
4424
af26433b13bc
remove Mac48Address::IsMulticast
Fabian Mauchle <f1mauchl@hsr.ch>
parents:
4408
diff
changeset
|
594 |
else if (to.IsGroup () || |
4408 | 595 |
toStation->IsAssociated ()) |
596 |
{ |
|
597 |
NS_LOG_DEBUG ("forwarding frame from="<<from<<", to="<<to); |
|
598 |
Ptr<Packet> copy = packet->Copy (); |
|
599 |
ForwardDown (packet, from, to, hdr); |
|
600 |
ForwardUp (copy, from, to); |
|
601 |
} |
|
602 |
else |
|
603 |
{ |
|
604 |
ForwardUp (packet, from, to); |
|
605 |
} |
|
606 |
} |
|
607 |
else if (hdr->IsFromDs () && |
|
608 |
hdr->IsToDs ()) |
|
609 |
{ |
|
610 |
// this is an AP-to-AP frame |
|
611 |
// we ignore for now. |
|
612 |
} |
|
613 |
else |
|
614 |
{ |
|
615 |
// we can ignore these frames since |
|
616 |
// they are not targeted at the AP |
|
617 |
} |
|
618 |
} |
|
619 |
else if (hdr->IsMgt ()) |
|
620 |
{ |
|
621 |
if (hdr->IsProbeReq ()) |
|
622 |
{ |
|
623 |
NS_ASSERT (hdr->GetAddr1 ().IsBroadcast ()); |
|
624 |
SendProbeResp (hdr->GetAddr2 ()); |
|
625 |
} |
|
626 |
else if (hdr->GetAddr1 () == GetAddress ()) |
|
627 |
{ |
|
628 |
if (hdr->IsAssocReq ()) |
|
629 |
{ |
|
630 |
// first, verify that the the station's supported |
|
631 |
// rate set is compatible with our Basic Rate set |
|
632 |
MgtAssocRequestHeader assocReq; |
|
633 |
packet->RemoveHeader (assocReq); |
|
634 |
SupportedRates rates = assocReq.GetSupportedRates (); |
|
635 |
bool problem = false; |
|
636 |
for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++) |
|
637 |
{ |
|
638 |
WifiMode mode = m_stationManager->GetBasicMode (i); |
|
639 |
if (!rates.IsSupportedRate (mode.GetDataRate ())) |
|
640 |
{ |
|
641 |
problem = true; |
|
642 |
break; |
|
643 |
} |
|
644 |
} |
|
645 |
if (problem) |
|
646 |
{ |
|
647 |
// one of the Basic Rate set mode is not |
|
648 |
// supported by the station. So, we return an assoc |
|
649 |
// response with an error status. |
|
650 |
SendAssocResp (hdr->GetAddr2 (), false); |
|
651 |
} |
|
652 |
else |
|
653 |
{ |
|
654 |
// station supports all rates in Basic Rate Set. |
|
655 |
// record all its supported modes in its associated WifiRemoteStation |
|
656 |
for (uint32_t j = 0; j < m_phy->GetNModes (); j++) |
|
657 |
{ |
|
658 |
WifiMode mode = m_phy->GetMode (j); |
|
659 |
if (rates.IsSupportedRate (mode.GetDataRate ())) |
|
660 |
{ |
|
661 |
fromStation->AddSupportedMode (mode); |
|
662 |
} |
|
663 |
} |
|
664 |
fromStation->RecordWaitAssocTxOk (); |
|
665 |
// send assoc response with success status. |
|
666 |
SendAssocResp (hdr->GetAddr2 (), true); |
|
667 |
} |
|
668 |
} |
|
669 |
else if (hdr->IsDisassociation ()) |
|
670 |
{ |
|
671 |
fromStation->RecordDisassociated (); |
|
672 |
} |
|
673 |
else if (hdr->IsReassocReq ()) |
|
674 |
{ |
|
675 |
/* we don't support reassoc frames for now */ |
|
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
676 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
677 |
else if (hdr->IsAction ()) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
678 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
679 |
WifiActionHeader actionHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
680 |
packet->RemoveHeader (actionHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
681 |
if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK && |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
682 |
actionHdr.GetAction().blockAck == WifiActionHeader::BLOCK_ACK_ADDBA_REQUEST) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
683 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
684 |
MgtAddBaRequestHeader reqHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
685 |
packet->RemoveHeader (reqHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
686 |
SendAddBaResponse (&reqHdr, hdr->GetAddr2 ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
687 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
688 |
else if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK && |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
689 |
actionHdr.GetAction().blockAck == WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
690 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
691 |
MgtAddBaResponseHeader respHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
692 |
packet->RemoveHeader (respHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
693 |
m_queues[QosUtilsMapTidToAc (respHdr.GetTid ())]->GotAddBaResponse (&respHdr, hdr->GetAddr2 ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
694 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
695 |
else if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK && |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
696 |
actionHdr.GetAction().blockAck == WifiActionHeader::BLOCK_ACK_DELBA) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
697 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
698 |
MgtDelBaHeader delBaHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
699 |
packet->RemoveHeader (delBaHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
700 |
if (delBaHdr.IsByOriginator ()) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
701 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
702 |
/* Block ack agreement tear down */ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
703 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
704 |
else |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
705 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
706 |
/* We must notify correct queue tear down of agreement */ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
707 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
708 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
709 |
} |
4408 | 710 |
else if (hdr->IsAuthentication () || |
711 |
hdr->IsDeauthentication ()) |
|
712 |
{ |
|
713 |
/* |
|
714 |
*/ |
|
715 |
} |
|
716 |
else |
|
717 |
{ |
|
718 |
/* unknown mgt frame |
|
719 |
*/ |
|
720 |
} |
|
721 |
} |
|
722 |
} |
|
723 |
} |
|
724 |
||
725 |
void |
|
5819
514ec98954ab
Wifi code cleanup: Correcting various const keyword ordering and removing superfluous (boolean)?true:false.
Timo Bingmann <tbns@idlebox.net>
parents:
5747
diff
changeset
|
726 |
QapWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, const WifiMacHeader *hdr) |
4408 | 727 |
{ |
728 |
DeaggregatedMsdus packets = MsduAggregator::Deaggregate (aggregatedPacket); |
|
729 |
for (DeaggregatedMsdusCI i = packets.begin (); i != packets.end (); ++i) |
|
730 |
{ |
|
731 |
if ((*i).second.GetDestinationAddr () == GetAddress ()) |
|
732 |
{ |
|
733 |
ForwardUp ((*i).first, (*i).second.GetSourceAddr (), |
|
734 |
(*i).second.GetDestinationAddr ()); |
|
735 |
} |
|
736 |
else |
|
737 |
{ |
|
738 |
Mac48Address from = (*i).second.GetSourceAddr (); |
|
739 |
Mac48Address to = (*i).second.GetDestinationAddr (); |
|
740 |
NS_LOG_DEBUG ("forwarding QoS frame from="<<from<<", to="<<to); |
|
741 |
ForwardDown ((*i).first, from, to, hdr); |
|
742 |
} |
|
743 |
} |
|
744 |
} |
|
745 |
||
746 |
Ptr<EdcaTxopN> |
|
747 |
QapWifiMac::GetVOQueue (void) const |
|
748 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
749 |
return m_queues.find (AC_VO)->second; |
4408 | 750 |
} |
751 |
||
752 |
Ptr<EdcaTxopN> |
|
753 |
QapWifiMac::GetVIQueue (void) const |
|
754 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
755 |
return m_queues.find (AC_VI)->second; |
4408 | 756 |
} |
757 |
||
758 |
Ptr<EdcaTxopN> |
|
759 |
QapWifiMac::GetBEQueue (void) const |
|
760 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
761 |
return m_queues.find (AC_BE)->second; |
4408 | 762 |
} |
763 |
||
764 |
Ptr<EdcaTxopN> |
|
765 |
QapWifiMac::GetBKQueue (void) const |
|
766 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
767 |
return m_queues.find (AC_BK)->second; |
4408 | 768 |
} |
769 |
||
770 |
void |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
771 |
QapWifiMac::SetQueue (enum AccessClass ac) |
4408 | 772 |
{ |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
773 |
Ptr<EdcaTxopN> edca = CreateObject<EdcaTxopN> (); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
774 |
edca->SetLow (m_low); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
775 |
edca->SetManager (m_dcfManager); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
776 |
edca->SetTypeOfStation (AP); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
777 |
edca->SetTxMiddle (m_txMiddle); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
778 |
edca->SetTxOkCallback (MakeCallback (&QapWifiMac::TxOk, this)); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
779 |
edca->SetTxFailedCallback (MakeCallback (&QapWifiMac::TxFailed, this)); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
780 |
m_queues.insert (std::make_pair(ac, edca)); |
4408 | 781 |
} |
782 |
||
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
783 |
void |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
784 |
QapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) |
4408 | 785 |
{ |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
786 |
switch (standard) |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
787 |
{ |
5747
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
788 |
case WIFI_PHY_STANDARD_80211p_CCH: |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
789 |
ConfigureCCHDcf (m_queues[AC_BK], 15, 511, AC_BK); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
790 |
ConfigureCCHDcf (m_queues[AC_BE], 15, 511, AC_BE); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
791 |
ConfigureCCHDcf (m_queues[AC_VI], 15, 511, AC_VI); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
792 |
ConfigureCCHDcf (m_queues[AC_VO], 15, 511, AC_VO); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
793 |
break; |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
794 |
case WIFI_PHY_STANDARD_80211p_SCH: |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
795 |
ConfigureDcf (m_queues[AC_BK], 15, 511, AC_BK); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
796 |
ConfigureDcf (m_queues[AC_BE], 15, 511, AC_BE); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
797 |
ConfigureDcf (m_queues[AC_VI], 15, 511, AC_VI); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
798 |
ConfigureDcf (m_queues[AC_VO], 15, 511, AC_VO); |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
5524
diff
changeset
|
799 |
break; |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
800 |
case WIFI_PHY_STANDARD_holland: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
801 |
// fall through |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
802 |
case WIFI_PHY_STANDARD_80211a: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
803 |
// fall through |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
804 |
case WIFI_PHY_STANDARD_80211_10Mhz: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
805 |
// fall through |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
806 |
case WIFI_PHY_STANDARD_80211_5Mhz: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
807 |
ConfigureDcf (m_queues[AC_BK], 15, 1023, AC_BK); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
808 |
ConfigureDcf (m_queues[AC_BE], 15, 1023, AC_BE); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
809 |
ConfigureDcf (m_queues[AC_VI], 15, 1023, AC_VI); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
810 |
ConfigureDcf (m_queues[AC_VO], 15, 1023, AC_VO); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
811 |
break; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
812 |
case WIFI_PHY_STANDARD_80211b: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
813 |
ConfigureDcf (m_queues[AC_BK], 31, 1023, AC_BK); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
814 |
ConfigureDcf (m_queues[AC_BE], 31, 1023, AC_BE); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
815 |
ConfigureDcf (m_queues[AC_VI], 31, 1023, AC_VI); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
816 |
ConfigureDcf (m_queues[AC_VO], 31, 1023, AC_VO); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
817 |
break; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
818 |
default: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
819 |
NS_ASSERT (false); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
820 |
break; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
821 |
} |
4408 | 822 |
} |
823 |
||
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
824 |
void |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
825 |
QapWifiMac::DoStart (void) |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
826 |
{ |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
827 |
m_beaconEvent.Cancel (); |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
828 |
if (m_enableBeaconGeneration) |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
829 |
{ |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
830 |
m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this); |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
831 |
} |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
832 |
WifiMac::DoStart (); |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
833 |
} |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
4720
diff
changeset
|
834 |
|
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
835 |
void |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
836 |
QapWifiMac::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, Mac48Address originator) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
837 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
838 |
NS_LOG_FUNCTION (this); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
839 |
WifiMacHeader hdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
840 |
hdr.SetAction (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
841 |
hdr.SetAddr1 (originator); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
842 |
hdr.SetAddr2 (m_low->GetAddress ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
843 |
hdr.SetAddr3 (m_low->GetAddress ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
844 |
hdr.SetDsNotFrom (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
845 |
hdr.SetDsNotTo (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
846 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
847 |
MgtAddBaResponseHeader respHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
848 |
StatusCode code; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
849 |
code.SetSuccess (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
850 |
respHdr.SetStatusCode (code); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
851 |
//Here a control about queues type? |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
852 |
respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
853 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
854 |
if (reqHdr->IsImmediateBlockAck ()) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
855 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
856 |
respHdr.SetImmediateBlockAck (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
857 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
858 |
else |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
859 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
860 |
respHdr.SetDelayedBlockAck (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
861 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
862 |
respHdr.SetTid (reqHdr->GetTid ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
863 |
/* For now there's not no control about limit of reception. |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
864 |
We assume that receiver has no limit on reception. |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
865 |
However we assume that a receiver sets a bufferSize in order to satisfy |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
866 |
next equation: |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
867 |
(bufferSize + 1) % 16 = 0 |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
868 |
So if a recipient is able to buffer a packet, it should be also able to buffer |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
869 |
all possible packet's fragments. |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
870 |
See section 7.3.1.14 in IEEE802.11e for more details. */ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
871 |
respHdr.SetBufferSize (1023); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
872 |
respHdr.SetTimeout (reqHdr->GetTimeout ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
873 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
874 |
WifiActionHeader actionHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
875 |
WifiActionHeader::ActionValue action; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
876 |
action.blockAck = WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
877 |
actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
878 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
879 |
Ptr<Packet> packet = Create<Packet> (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
880 |
packet->AddHeader (respHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
881 |
packet->AddHeader (actionHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
882 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
883 |
/* ns3::MacLow have to buffer all correctly received packet for this block ack session */ |
5956
e9918be47f78
MacLow now buffers QoS MPDUs under Block Ack
Mirko Banchi <mk.banchi@gmail.com>
parents:
5953
diff
changeset
|
884 |
m_low->CreateBlockAckAgreement (&respHdr, originator, reqHdr->GetStartingSequence ()); |
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
885 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
886 |
//Better a management queue? |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
887 |
m_queues[QosUtilsMapTidToAc (reqHdr->GetTid ())]->PushFront (packet, hdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
888 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
889 |
|
4408 | 890 |
} //namespace ns3 |