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/log.h" |
|
23 |
#include "ns3/simulator.h" |
|
24 |
#include "ns3/string.h" |
|
25 |
#include "ns3/pointer.h" |
|
26 |
||
27 |
#include "qos-tag.h" |
|
28 |
#include "edca-txop-n.h" |
|
29 |
#include "qsta-wifi-mac.h" |
|
30 |
#include "mac-low.h" |
|
31 |
#include "dcf-manager.h" |
|
32 |
#include "mac-rx-middle.h" |
|
33 |
#include "mac-tx-middle.h" |
|
34 |
#include "wifi-mac-header.h" |
|
35 |
#include "msdu-aggregator.h" |
|
36 |
#include "amsdu-subframe-header.h" |
|
37 |
#include "mgt-headers.h" |
|
38 |
||
39 |
NS_LOG_COMPONENT_DEFINE ("QstaWifiMac"); |
|
40 |
||
41 |
namespace ns3 { |
|
42 |
||
43 |
NS_OBJECT_ENSURE_REGISTERED (QstaWifiMac); |
|
44 |
||
45 |
TypeId |
|
46 |
QstaWifiMac::GetTypeId (void) |
|
47 |
{ |
|
48 |
static TypeId tid = TypeId ("ns3::QstaWifiMac") |
|
49 |
.SetParent<WifiMac> () |
|
50 |
.AddConstructor<QstaWifiMac> () |
|
51 |
.AddAttribute ("ProbeRequestTimeout", "The interval between two consecutive probe request attempts.", |
|
52 |
TimeValue (Seconds (0.05)), |
|
53 |
MakeTimeAccessor (&QstaWifiMac::m_probeRequestTimeout), |
|
54 |
MakeTimeChecker ()) |
|
55 |
.AddAttribute ("AssocRequestTimeout", "The interval between two consecutive assoc request attempts.", |
|
56 |
TimeValue (Seconds (0.5)), |
|
57 |
MakeTimeAccessor (&QstaWifiMac::m_assocRequestTimeout), |
|
58 |
MakeTimeChecker ()) |
|
59 |
.AddAttribute ("MaxMissedBeacons", |
|
60 |
"Number of beacons which much be consecutively missed before " |
|
61 |
"we attempt to restart association.", |
|
62 |
UintegerValue (10), |
|
63 |
MakeUintegerAccessor (&QstaWifiMac::m_maxMissedBeacons), |
|
64 |
MakeUintegerChecker<uint32_t> ()) |
|
65 |
.AddAttribute ("ActiveProbing", "If true, we send probe requests. If false, we don't.", |
|
66 |
BooleanValue (false), |
|
67 |
MakeBooleanAccessor (&QstaWifiMac::SetActiveProbing), |
|
68 |
MakeBooleanChecker ()) |
|
69 |
.AddAttribute ("VO_EdcaTxopN", |
|
70 |
"Queue that manages packets belonging to AC_VO access class", |
|
71 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
72 |
MakePointerAccessor(&QstaWifiMac::GetVOQueue), |
4408 | 73 |
MakePointerChecker<EdcaTxopN> ()) |
74 |
.AddAttribute ("VI_EdcaTxopN", |
|
75 |
"Queue that manages packets belonging to AC_VI access class", |
|
76 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
77 |
MakePointerAccessor(&QstaWifiMac::GetVIQueue), |
4408 | 78 |
MakePointerChecker<EdcaTxopN> ()) |
79 |
.AddAttribute ("BE_EdcaTxopN", |
|
80 |
"Queue that manages packets belonging to AC_BE access class", |
|
81 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
82 |
MakePointerAccessor(&QstaWifiMac::GetBEQueue), |
4408 | 83 |
MakePointerChecker<EdcaTxopN> ()) |
84 |
.AddAttribute ("BK_EdcaTxopN", |
|
85 |
"Queue that manages packets belonging to AC_BK access class", |
|
86 |
PointerValue (), |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
87 |
MakePointerAccessor(&QstaWifiMac::GetBKQueue), |
4408 | 88 |
MakePointerChecker<EdcaTxopN> ()) |
89 |
; |
|
90 |
return tid; |
|
91 |
} |
|
92 |
||
93 |
QstaWifiMac::QstaWifiMac () |
|
94 |
: m_state (BEACON_MISSED), |
|
95 |
m_probeRequestEvent (), |
|
96 |
m_assocRequestEvent (), |
|
97 |
m_beaconWatchdogEnd (Seconds (0.0)) |
|
98 |
{ |
|
99 |
NS_LOG_FUNCTION (this); |
|
100 |
m_rxMiddle = new MacRxMiddle (); |
|
101 |
m_rxMiddle->SetForwardCallback (MakeCallback (&QstaWifiMac::Receive, this)); |
|
102 |
/*TxMiddle can be shared between all queues */ |
|
103 |
m_txMiddle= new MacTxMiddle (); |
|
104 |
||
105 |
m_low = CreateObject<MacLow> (); |
|
106 |
m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); |
|
107 |
||
108 |
m_dcfManager = new DcfManager (); |
|
109 |
m_dcfManager->SetupLowListener (m_low); |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
110 |
|
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
111 |
SetQueue (AC_VO); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
112 |
SetQueue (AC_VI); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
113 |
SetQueue (AC_BE); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
114 |
SetQueue (AC_BK); |
4408 | 115 |
} |
116 |
||
117 |
QstaWifiMac::~QstaWifiMac () |
|
118 |
{ |
|
119 |
NS_LOG_FUNCTION (this); |
|
120 |
} |
|
121 |
||
122 |
void |
|
123 |
QstaWifiMac::DoDispose () |
|
124 |
{ |
|
125 |
NS_LOG_FUNCTION (this); |
|
126 |
delete m_rxMiddle; |
|
127 |
delete m_txMiddle; |
|
128 |
delete m_dcfManager; |
|
4687
02bf728f7e39
bug 381: Wifi crashes on shutdown
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4609
diff
changeset
|
129 |
m_low->Dispose (); |
4408 | 130 |
m_rxMiddle = 0; |
131 |
m_txMiddle = 0; |
|
132 |
m_low = 0; |
|
133 |
m_phy = 0; |
|
134 |
m_dcfManager = 0; |
|
135 |
m_stationManager = 0; |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
136 |
for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i) |
4408 | 137 |
{ |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
138 |
(*i).second = 0; |
4408 | 139 |
} |
140 |
WifiMac::DoDispose (); |
|
141 |
} |
|
142 |
||
143 |
void |
|
144 |
QstaWifiMac::SetSlot (Time slotTime) |
|
145 |
{ |
|
146 |
NS_LOG_FUNCTION (this << slotTime); |
|
147 |
m_dcfManager->SetSlot (slotTime); |
|
148 |
m_low->SetSlotTime (slotTime); |
|
149 |
} |
|
150 |
||
151 |
void |
|
152 |
QstaWifiMac::SetSifs (Time sifs) |
|
153 |
{ |
|
154 |
NS_LOG_FUNCTION (this << sifs); |
|
155 |
m_dcfManager->SetSifs (sifs); |
|
156 |
m_low->SetSifs (sifs); |
|
157 |
} |
|
158 |
||
159 |
void |
|
160 |
QstaWifiMac::SetEifsNoDifs (Time eifsNoDifs) |
|
161 |
{ |
|
162 |
NS_LOG_FUNCTION (this << eifsNoDifs); |
|
163 |
m_dcfManager->SetEifsNoDifs (eifsNoDifs); |
|
164 |
} |
|
165 |
||
166 |
void |
|
167 |
QstaWifiMac::SetAckTimeout (Time ackTimeout) |
|
168 |
{ |
|
169 |
m_low->SetAckTimeout (ackTimeout); |
|
170 |
} |
|
171 |
||
172 |
void |
|
173 |
QstaWifiMac::SetCtsTimeout (Time ctsTimeout) |
|
174 |
{ |
|
175 |
m_low->SetCtsTimeout (ctsTimeout); |
|
176 |
} |
|
177 |
||
178 |
void |
|
179 |
QstaWifiMac::SetPifs (Time pifs) |
|
180 |
{ |
|
181 |
m_low->SetPifs (pifs); |
|
182 |
} |
|
183 |
||
184 |
Time |
|
185 |
QstaWifiMac::GetSlot (void) const |
|
186 |
{ |
|
187 |
return m_low->GetSlotTime (); |
|
188 |
} |
|
189 |
||
190 |
Time |
|
191 |
QstaWifiMac::GetSifs (void) const |
|
192 |
{ |
|
193 |
return m_low->GetSifs (); |
|
194 |
} |
|
195 |
||
196 |
Time |
|
197 |
QstaWifiMac::GetEifsNoDifs (void) const |
|
198 |
{ |
|
4461
ab9b58d664d7
move GetEifsNoDifs to DcfManager
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
199 |
return m_dcfManager->GetEifsNoDifs (); |
4408 | 200 |
} |
201 |
||
202 |
Time |
|
203 |
QstaWifiMac::GetAckTimeout (void) const |
|
204 |
{ |
|
205 |
return m_low->GetAckTimeout (); |
|
206 |
} |
|
207 |
||
208 |
Time |
|
209 |
QstaWifiMac::GetCtsTimeout (void) const |
|
210 |
{ |
|
211 |
return m_low->GetCtsTimeout (); |
|
212 |
} |
|
213 |
||
214 |
Time |
|
215 |
QstaWifiMac::GetPifs (void) const |
|
216 |
{ |
|
217 |
return m_low->GetPifs (); |
|
218 |
} |
|
219 |
||
220 |
void |
|
221 |
QstaWifiMac::SetWifiPhy (Ptr<WifiPhy> phy) |
|
222 |
{ |
|
223 |
m_phy = phy; |
|
224 |
m_dcfManager->SetupPhyListener (phy); |
|
225 |
m_low->SetPhy (phy); |
|
226 |
} |
|
227 |
||
228 |
void |
|
229 |
QstaWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager) |
|
230 |
{ |
|
231 |
m_stationManager = stationManager; |
|
232 |
m_queues[AC_VO]->SetWifiRemoteStationManager (stationManager); |
|
233 |
m_queues[AC_VI]->SetWifiRemoteStationManager (stationManager); |
|
234 |
m_queues[AC_BE]->SetWifiRemoteStationManager (stationManager); |
|
235 |
m_queues[AC_BK]->SetWifiRemoteStationManager (stationManager); |
|
236 |
m_low->SetWifiRemoteStationManager (stationManager); |
|
237 |
} |
|
238 |
||
239 |
void |
|
240 |
QstaWifiMac::SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback) |
|
241 |
{ |
|
242 |
m_forwardUp = upCallback; |
|
243 |
} |
|
244 |
||
245 |
void |
|
246 |
QstaWifiMac::SetLinkUpCallback (Callback<void> linkUp) |
|
247 |
{ |
|
248 |
m_linkUp = linkUp; |
|
249 |
} |
|
250 |
||
251 |
void |
|
252 |
QstaWifiMac::SetLinkDownCallback (Callback<void> linkDown) |
|
253 |
{ |
|
254 |
m_linkDown = linkDown; |
|
255 |
} |
|
256 |
||
257 |
Mac48Address |
|
258 |
QstaWifiMac::GetAddress (void) const |
|
259 |
{ |
|
260 |
return m_low->GetAddress (); |
|
261 |
} |
|
262 |
||
263 |
Ssid |
|
264 |
QstaWifiMac::GetSsid (void) const |
|
265 |
{ |
|
266 |
return m_ssid; |
|
267 |
} |
|
268 |
||
269 |
Mac48Address |
|
270 |
QstaWifiMac::GetBssid () const |
|
271 |
{ |
|
272 |
return m_low->GetBssid (); |
|
273 |
} |
|
274 |
||
275 |
void |
|
276 |
QstaWifiMac::SetAddress (Mac48Address address) |
|
277 |
{ |
|
278 |
NS_LOG_FUNCTION (this << address); |
|
279 |
m_low->SetAddress (address); |
|
280 |
} |
|
281 |
||
282 |
void |
|
283 |
QstaWifiMac::SetSsid (Ssid ssid) |
|
284 |
{ |
|
285 |
NS_LOG_FUNCTION (this << ssid); |
|
286 |
m_ssid = ssid; |
|
287 |
} |
|
288 |
||
289 |
void |
|
290 |
QstaWifiMac::SetMaxMissedBeacons (uint32_t missed) |
|
291 |
{ |
|
292 |
NS_LOG_FUNCTION (this << missed); |
|
293 |
m_maxMissedBeacons = missed; |
|
294 |
} |
|
295 |
||
296 |
void |
|
297 |
QstaWifiMac::SetProbeRequestTimeout (Time timeout) |
|
298 |
{ |
|
299 |
NS_LOG_FUNCTION (this << timeout); |
|
300 |
m_probeRequestTimeout = timeout; |
|
301 |
} |
|
302 |
||
303 |
void |
|
304 |
QstaWifiMac::SetAssocRequestTimeout (Time timeout) |
|
305 |
{ |
|
306 |
NS_LOG_FUNCTION (this << timeout); |
|
307 |
m_assocRequestTimeout = timeout; |
|
308 |
} |
|
309 |
||
310 |
void |
|
311 |
QstaWifiMac::StartActiveAssociation (void) |
|
312 |
{ |
|
313 |
NS_LOG_FUNCTION (this); |
|
314 |
TryToEnsureAssociated (); |
|
315 |
} |
|
316 |
||
317 |
Mac48Address |
|
318 |
QstaWifiMac::GetBroadcastBssid (void) |
|
319 |
{ |
|
320 |
return Mac48Address::GetBroadcast (); |
|
321 |
} |
|
322 |
||
323 |
void |
|
324 |
QstaWifiMac::SetBssid (Mac48Address bssid) |
|
325 |
{ |
|
326 |
NS_LOG_FUNCTION (this << bssid); |
|
327 |
m_low->SetBssid (bssid); |
|
328 |
} |
|
329 |
||
330 |
void |
|
331 |
QstaWifiMac::SetActiveProbing (bool enable) |
|
332 |
{ |
|
333 |
NS_LOG_FUNCTION (this << enable); |
|
334 |
if (enable) |
|
335 |
{ |
|
336 |
TryToEnsureAssociated (); |
|
337 |
} |
|
338 |
else |
|
339 |
{ |
|
340 |
m_probeRequestEvent.Cancel (); |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
void |
|
345 |
QstaWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to) |
|
346 |
{ |
|
347 |
NS_LOG_FUNCTION (this << packet << from << to); |
|
348 |
m_forwardUp (packet, from, to); |
|
349 |
} |
|
350 |
||
351 |
void |
|
352 |
QstaWifiMac::SendProbeRequest (void) |
|
353 |
{ |
|
354 |
NS_LOG_FUNCTION (this); |
|
355 |
WifiMacHeader hdr; |
|
356 |
hdr.SetProbeReq (); |
|
357 |
hdr.SetAddr1 (GetBroadcastBssid ()); |
|
358 |
hdr.SetAddr2 (GetAddress ()); |
|
359 |
hdr.SetAddr3 (GetBroadcastBssid ()); |
|
360 |
hdr.SetDsNotFrom (); |
|
361 |
hdr.SetDsNotTo (); |
|
362 |
Ptr<Packet> packet = Create<Packet> (); |
|
363 |
MgtProbeRequestHeader probe; |
|
364 |
probe.SetSsid (GetSsid ()); |
|
365 |
probe.SetSupportedRates (GetSupportedRates ()); |
|
366 |
packet->AddHeader (probe); |
|
367 |
||
368 |
/* Which is correct queue for management frames ? */ |
|
369 |
m_queues[AC_VO]->Queue (packet, hdr); |
|
370 |
||
371 |
m_probeRequestEvent = Simulator::Schedule (m_probeRequestTimeout, |
|
372 |
&QstaWifiMac::ProbeRequestTimeout, this); |
|
373 |
} |
|
374 |
||
375 |
void |
|
376 |
QstaWifiMac::SendAssociationRequest (void) |
|
377 |
{ |
|
378 |
NS_LOG_FUNCTION (this << GetBssid ()); |
|
379 |
WifiMacHeader hdr; |
|
380 |
hdr.SetAssocReq (); |
|
381 |
hdr.SetAddr1 (GetBssid ()); |
|
382 |
hdr.SetAddr2 (GetAddress ()); |
|
383 |
hdr.SetAddr3 (GetBssid ()); |
|
384 |
hdr.SetDsNotFrom (); |
|
385 |
hdr.SetDsNotTo (); |
|
386 |
Ptr<Packet> packet = Create<Packet> (); |
|
387 |
MgtAssocRequestHeader assoc; |
|
388 |
assoc.SetSsid (GetSsid ()); |
|
389 |
assoc.SetSupportedRates (GetSupportedRates ()); |
|
390 |
packet->AddHeader (assoc); |
|
391 |
||
392 |
/* Which is correct queue for management frames ? */ |
|
393 |
m_queues[AC_VO]->Queue (packet, hdr); |
|
394 |
||
395 |
m_assocRequestEvent = Simulator::Schedule (m_assocRequestTimeout, |
|
396 |
&QstaWifiMac::AssocRequestTimeout, this); |
|
397 |
} |
|
398 |
||
399 |
void |
|
400 |
QstaWifiMac::TryToEnsureAssociated (void) |
|
401 |
{ |
|
402 |
NS_LOG_FUNCTION (this); |
|
403 |
switch (m_state) { |
|
404 |
case ASSOCIATED: |
|
405 |
return; |
|
406 |
break; |
|
407 |
case WAIT_PROBE_RESP: |
|
408 |
/* we have sent a probe request earlier so we |
|
409 |
do not need to re-send a probe request immediately. |
|
410 |
We just need to wait until probe-request-timeout |
|
411 |
or until we get a probe response |
|
412 |
*/ |
|
413 |
break; |
|
414 |
case BEACON_MISSED: |
|
415 |
/* we were associated but we missed a bunch of beacons |
|
416 |
* so we should assume we are not associated anymore. |
|
417 |
* We try to initiate a probe request now. |
|
418 |
*/ |
|
419 |
m_linkDown (); |
|
420 |
m_state = WAIT_PROBE_RESP; |
|
421 |
SendProbeRequest (); |
|
422 |
break; |
|
423 |
case WAIT_ASSOC_RESP: |
|
424 |
/* we have sent an assoc request so we do not need to |
|
425 |
re-send an assoc request right now. We just need to |
|
426 |
wait until either assoc-request-timeout or until |
|
427 |
we get an assoc response. |
|
428 |
*/ |
|
429 |
break; |
|
430 |
case REFUSED: |
|
431 |
/* we have sent an assoc request and received a negative |
|
432 |
assoc resp. We wait until someone restarts an |
|
433 |
association with a given ssid. |
|
434 |
*/ |
|
435 |
break; |
|
436 |
} |
|
437 |
} |
|
438 |
||
439 |
void |
|
440 |
QstaWifiMac::AssocRequestTimeout (void) |
|
441 |
{ |
|
442 |
NS_LOG_FUNCTION (this); |
|
443 |
m_state = WAIT_ASSOC_RESP; |
|
444 |
SendAssociationRequest (); |
|
445 |
} |
|
446 |
||
447 |
void |
|
448 |
QstaWifiMac::ProbeRequestTimeout (void) |
|
449 |
{ |
|
450 |
NS_LOG_FUNCTION (this); |
|
451 |
m_state = WAIT_PROBE_RESP; |
|
452 |
SendProbeRequest (); |
|
453 |
} |
|
454 |
||
455 |
void |
|
456 |
QstaWifiMac::MissedBeacons (void) |
|
457 |
{ |
|
458 |
NS_LOG_FUNCTION (this); |
|
459 |
if (m_beaconWatchdogEnd > Simulator::Now ()) |
|
460 |
{ |
|
461 |
m_beaconWatchdog = Simulator::Schedule (m_beaconWatchdogEnd - Simulator::Now (), |
|
462 |
&QstaWifiMac::MissedBeacons, this); |
|
463 |
return; |
|
464 |
} |
|
465 |
NS_LOG_DEBUG ("beacon missed"); |
|
466 |
m_state = BEACON_MISSED; |
|
467 |
TryToEnsureAssociated (); |
|
468 |
} |
|
469 |
||
470 |
void |
|
471 |
QstaWifiMac::RestartBeaconWatchdog (Time delay) |
|
472 |
{ |
|
473 |
NS_LOG_FUNCTION (this << delay); |
|
474 |
m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd); |
|
475 |
if (Simulator::GetDelayLeft (m_beaconWatchdog) < delay && |
|
476 |
m_beaconWatchdog.IsExpired ()) |
|
477 |
{ |
|
478 |
NS_LOG_DEBUG ("really restart watchdog."); |
|
479 |
m_beaconWatchdog = Simulator::Schedule (delay, &QstaWifiMac::MissedBeacons, this); |
|
480 |
} |
|
481 |
} |
|
482 |
||
483 |
bool |
|
4609
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
484 |
QstaWifiMac::IsAssociated (void) const |
4408 | 485 |
{ |
4609
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
486 |
return m_state == ASSOCIATED; |
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
487 |
} |
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
488 |
|
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
489 |
bool |
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
490 |
QstaWifiMac::IsWaitAssocResp (void) const |
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
491 |
{ |
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
492 |
return m_state == WAIT_ASSOC_RESP; |
4408 | 493 |
} |
494 |
||
495 |
void |
|
496 |
QstaWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to) |
|
497 |
{ |
|
498 |
NS_LOG_FUNCTION (this << packet << to); |
|
499 |
if (!IsAssociated ()) |
|
500 |
{ |
|
501 |
TryToEnsureAssociated (); |
|
502 |
return; |
|
503 |
} |
|
504 |
WifiMacHeader hdr; |
|
505 |
||
506 |
hdr.SetType (WIFI_MAC_QOSDATA); |
|
507 |
hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); |
|
508 |
hdr.SetQosNoAmsdu (); |
|
509 |
hdr.SetQosNoEosp (); |
|
510 |
/* Transmission of multiple frames in the same |
|
511 |
Txop is not supported for now */ |
|
512 |
hdr.SetQosTxopLimit (0); |
|
513 |
||
514 |
hdr.SetAddr1 (GetBssid ()); |
|
515 |
hdr.SetAddr2 (m_low->GetAddress ()); |
|
516 |
hdr.SetAddr3 (to); |
|
517 |
hdr.SetDsNotFrom (); |
|
518 |
hdr.SetDsTo (); |
|
519 |
||
520 |
uint8_t tid = QosUtilsGetTidForPacket (packet); |
|
521 |
if (tid < 8) |
|
522 |
{ |
|
523 |
hdr.SetQosTid (tid); |
|
524 |
AccessClass ac = QosUtilsMapTidToAc (tid); |
|
525 |
m_queues[ac]->Queue (packet, hdr); |
|
526 |
} |
|
527 |
else |
|
528 |
{ |
|
529 |
//packet is considerated belonging to BestEffort Access Class (AC_BE) |
|
530 |
hdr.SetQosTid (0); |
|
531 |
m_queues[AC_BE]->Queue (packet, hdr); |
|
532 |
} |
|
533 |
} |
|
534 |
||
535 |
bool |
|
536 |
QstaWifiMac::SupportsSendFrom (void) const |
|
537 |
{ |
|
538 |
return true; |
|
539 |
} |
|
540 |
||
541 |
void |
|
542 |
QstaWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) |
|
543 |
{ |
|
544 |
NS_LOG_FUNCTION (this); |
|
545 |
NS_ASSERT (!hdr->IsCtl ()); |
|
546 |
if (hdr->GetAddr1 () != GetAddress () && |
|
547 |
!hdr->GetAddr1 ().IsBroadcast ()) |
|
548 |
{ |
|
549 |
NS_LOG_LOGIC ("packet is not for us"); |
|
550 |
} |
|
551 |
else if (hdr->IsData ()) |
|
552 |
{ |
|
553 |
if (!IsAssociated ()) |
|
554 |
{ |
|
555 |
NS_LOG_LOGIC ("Received data frame while not associated: ignore"); |
|
556 |
return; |
|
557 |
} |
|
558 |
if (!(hdr->IsFromDs () && !hdr->IsToDs ())) |
|
559 |
{ |
|
560 |
NS_LOG_LOGIC ("Received data frame not from the DS: ignore"); |
|
561 |
return; |
|
562 |
} |
|
563 |
if (hdr->GetAddr2 () != GetBssid ()) |
|
564 |
{ |
|
565 |
NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore"); |
|
566 |
return; |
|
567 |
} |
|
568 |
if (hdr->GetAddr3 () != GetAddress ()) |
|
569 |
{ |
|
570 |
if (hdr->IsQosData ()) |
|
571 |
{ |
|
572 |
if (hdr->IsQosAmsdu ()) |
|
573 |
{ |
|
574 |
NS_ASSERT (hdr->GetAddr3 () == GetBssid ()); |
|
575 |
DeaggregateAmsduAndForward (packet, hdr); |
|
576 |
packet = 0; |
|
577 |
} |
|
578 |
else |
|
579 |
{ |
|
580 |
ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ()); |
|
581 |
} |
|
582 |
} |
|
583 |
else |
|
584 |
{ |
|
585 |
ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ()); |
|
586 |
} |
|
587 |
} |
|
588 |
} |
|
589 |
else if (hdr->IsBeacon ()) |
|
590 |
{ |
|
591 |
MgtBeaconHeader beacon; |
|
592 |
packet->RemoveHeader (beacon); |
|
593 |
bool goodBeacon = false; |
|
594 |
if (GetSsid ().IsBroadcast () || |
|
595 |
beacon.GetSsid ().IsEqual (GetSsid ())) |
|
596 |
{ |
|
597 |
goodBeacon = true; |
|
598 |
} |
|
4609
6ec902d6af68
bug 605: Nqsta MAC should ignore beacons SSIDs while waiting for association response
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4461
diff
changeset
|
599 |
if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ()) |
4408 | 600 |
{ |
601 |
goodBeacon = false; |
|
602 |
} |
|
603 |
if (goodBeacon) |
|
604 |
{ |
|
605 |
Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
|
606 |
RestartBeaconWatchdog (delay); |
|
607 |
SetBssid (hdr->GetAddr3 ()); |
|
608 |
} |
|
609 |
if (goodBeacon && m_state == BEACON_MISSED) |
|
610 |
{ |
|
611 |
m_state = WAIT_ASSOC_RESP; |
|
612 |
SendAssociationRequest (); |
|
613 |
} |
|
614 |
} |
|
615 |
else if (hdr->IsProbeResp ()) |
|
616 |
{ |
|
617 |
if (m_state == WAIT_PROBE_RESP) |
|
618 |
{ |
|
619 |
MgtProbeResponseHeader probeResp; |
|
620 |
packet->RemoveHeader (probeResp); |
|
621 |
if (!probeResp.GetSsid ().IsEqual (GetSsid ())) |
|
622 |
{ |
|
623 |
//not a probe resp for our ssid. |
|
624 |
return; |
|
625 |
} |
|
626 |
SetBssid (hdr->GetAddr3 ()); |
|
627 |
Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons); |
|
628 |
RestartBeaconWatchdog (delay); |
|
629 |
if (m_probeRequestEvent.IsRunning ()) |
|
630 |
{ |
|
631 |
m_probeRequestEvent.Cancel (); |
|
632 |
} |
|
633 |
m_state = WAIT_ASSOC_RESP; |
|
634 |
SendAssociationRequest (); |
|
635 |
} |
|
636 |
} |
|
637 |
else if (hdr->IsAssocResp ()) |
|
638 |
{ |
|
639 |
if (m_state == WAIT_ASSOC_RESP) |
|
640 |
{ |
|
641 |
MgtAssocResponseHeader assocResp; |
|
642 |
packet->RemoveHeader (assocResp); |
|
643 |
if (m_assocRequestEvent.IsRunning ()) |
|
644 |
{ |
|
645 |
m_assocRequestEvent.Cancel (); |
|
646 |
} |
|
647 |
if (assocResp.GetStatusCode ().IsSuccess ()) |
|
648 |
{ |
|
649 |
m_state = ASSOCIATED; |
|
650 |
NS_LOG_DEBUG ("assoc completed"); |
|
651 |
SupportedRates rates = assocResp.GetSupportedRates (); |
|
652 |
WifiRemoteStation *ap = m_stationManager->Lookup (hdr->GetAddr2 ()); |
|
653 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
|
654 |
{ |
|
655 |
WifiMode mode = m_phy->GetMode (i); |
|
656 |
if (rates.IsSupportedRate (mode.GetDataRate ())) |
|
657 |
{ |
|
658 |
ap->AddSupportedMode (mode); |
|
659 |
if (rates.IsBasicRate (mode.GetDataRate ())) |
|
660 |
{ |
|
661 |
m_stationManager->AddBasicMode (mode); |
|
662 |
} |
|
663 |
} |
|
664 |
} |
|
665 |
if (!m_linkUp.IsNull ()) |
|
666 |
{ |
|
667 |
m_linkUp (); |
|
668 |
} |
|
669 |
} |
|
670 |
else |
|
671 |
{ |
|
672 |
NS_LOG_DEBUG ("assoc refused"); |
|
673 |
m_state = REFUSED; |
|
674 |
} |
|
675 |
} |
|
676 |
} |
|
5953
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 |
} |
711 |
||
712 |
SupportedRates |
|
713 |
QstaWifiMac::GetSupportedRates (void) const |
|
714 |
{ |
|
715 |
SupportedRates rates; |
|
716 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
|
717 |
{ |
|
718 |
WifiMode mode = m_phy->GetMode (i); |
|
719 |
rates.AddSupportedRate (mode.GetDataRate ()); |
|
720 |
} |
|
721 |
return rates; |
|
722 |
} |
|
723 |
||
724 |
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
|
725 |
QstaWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, const WifiMacHeader *hdr) |
4408 | 726 |
{ |
727 |
DeaggregatedMsdus packets = MsduAggregator::Deaggregate (aggregatedPacket); |
|
728 |
for (DeaggregatedMsdusCI i = packets.begin (); i != packets.end (); ++i) |
|
729 |
{ |
|
730 |
ForwardUp ((*i).first, (*i).second.GetSourceAddr (), |
|
731 |
(*i).second.GetDestinationAddr ()); |
|
732 |
} |
|
733 |
} |
|
734 |
||
735 |
Ptr<EdcaTxopN> |
|
736 |
QstaWifiMac::GetVOQueue (void) const |
|
737 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
738 |
return m_queues.find (AC_VO)->second; |
4408 | 739 |
} |
740 |
||
741 |
Ptr<EdcaTxopN> |
|
742 |
QstaWifiMac::GetVIQueue (void) const |
|
743 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
744 |
return m_queues.find (AC_VI)->second; |
4408 | 745 |
} |
746 |
||
747 |
Ptr<EdcaTxopN> |
|
748 |
QstaWifiMac::GetBEQueue (void) const |
|
749 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
750 |
return m_queues.find (AC_BE)->second; |
4408 | 751 |
} |
752 |
||
753 |
Ptr<EdcaTxopN> |
|
754 |
QstaWifiMac::GetBKQueue (void) const |
|
755 |
{ |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
756 |
return m_queues.find (AC_BK)->second; |
4408 | 757 |
} |
758 |
||
759 |
void |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
760 |
QstaWifiMac::SetQueue (enum AccessClass ac) |
4408 | 761 |
{ |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
762 |
Ptr<EdcaTxopN> edca = CreateObject<EdcaTxopN> (); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
763 |
edca->SetLow (m_low); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
764 |
edca->SetManager (m_dcfManager); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
765 |
edca->SetTypeOfStation (STA); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
766 |
edca->SetTxMiddle (m_txMiddle); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
767 |
m_queues.insert (std::make_pair(ac, edca)); |
4408 | 768 |
} |
769 |
||
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
770 |
void |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
771 |
QstaWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) |
4408 | 772 |
{ |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
773 |
switch (standard) |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
774 |
{ |
5747
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
4720
diff
changeset
|
775 |
case WIFI_PHY_STANDARD_80211p_CCH: |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
4720
diff
changeset
|
776 |
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:
4720
diff
changeset
|
777 |
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:
4720
diff
changeset
|
778 |
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:
4720
diff
changeset
|
779 |
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:
4720
diff
changeset
|
780 |
break; |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
4720
diff
changeset
|
781 |
case WIFI_PHY_STANDARD_80211p_SCH: |
a171e73c4dae
add support for 802.11p PHY and MAC parameters
Michael Nowatkowski <nowatkom@gmail.com>
parents:
4720
diff
changeset
|
782 |
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:
4720
diff
changeset
|
783 |
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:
4720
diff
changeset
|
784 |
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:
4720
diff
changeset
|
785 |
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:
4720
diff
changeset
|
786 |
break; |
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
787 |
case WIFI_PHY_STANDARD_holland: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
788 |
// fall through |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
789 |
case WIFI_PHY_STANDARD_80211a: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
790 |
// fall through |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
791 |
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
|
792 |
// fall through |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
793 |
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
|
794 |
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
|
795 |
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
|
796 |
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
|
797 |
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
|
798 |
break; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
799 |
case WIFI_PHY_STANDARD_80211b: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
800 |
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
|
801 |
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
|
802 |
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
|
803 |
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
|
804 |
break; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
805 |
default: |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
806 |
NS_ASSERT (false); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
807 |
break; |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4687
diff
changeset
|
808 |
} |
4408 | 809 |
} |
810 |
||
5953
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
811 |
void |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
812 |
QstaWifiMac::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, Mac48Address originator) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
813 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
814 |
NS_LOG_FUNCTION (this); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
815 |
WifiMacHeader hdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
816 |
hdr.SetAction (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
817 |
hdr.SetAddr1 (originator); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
818 |
hdr.SetAddr2 (m_low->GetAddress ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
819 |
hdr.SetAddr3 (m_low->GetAddress ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
820 |
hdr.SetDsNotFrom (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
821 |
hdr.SetDsNotTo (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
822 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
823 |
MgtAddBaResponseHeader respHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
824 |
StatusCode code; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
825 |
code.SetSuccess (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
826 |
respHdr.SetStatusCode (code); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
827 |
//Here a control about queues type? |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
828 |
respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
829 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
830 |
if (reqHdr->IsImmediateBlockAck ()) |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
831 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
832 |
respHdr.SetImmediateBlockAck (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
833 |
} |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
834 |
else |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
835 |
{ |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
836 |
respHdr.SetDelayedBlockAck (); |
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 |
respHdr.SetTid (reqHdr->GetTid ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
839 |
/* 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
|
840 |
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
|
841 |
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
|
842 |
next equation: |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
843 |
(bufferSize + 1) % 16 = 0 |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
844 |
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
|
845 |
all possible packet's fragments. |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
846 |
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
|
847 |
respHdr.SetBufferSize (1023); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
848 |
respHdr.SetTimeout (reqHdr->GetTimeout ()); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
849 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
850 |
WifiActionHeader actionHdr; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
851 |
WifiActionHeader::ActionValue action; |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
852 |
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
|
853 |
actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
854 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
855 |
Ptr<Packet> packet = Create<Packet> (); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
856 |
packet->AddHeader (respHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
857 |
packet->AddHeader (actionHdr); |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
858 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
859 |
/* 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
|
860 |
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
|
861 |
|
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
862 |
//Better a management queue? |
9e400f6b8a2c
handle wifi action frames in high MACs
Mirko Banchi <mk.banchi@gmail.com>
parents:
5906
diff
changeset
|
863 |
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
|
864 |
} |
5906
509b5089a081
Revert bug 706 fix because it breaks the regression testing
Faker Moatamri <faker.moatamri@sophia.inria.fr>
parents:
5903
diff
changeset
|
865 |
|
4408 | 866 |
} //namespace ns3 |