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