LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009, 2010 MIRKO BANCHI | 3 * Copyright (c) 2009, 2010 MIRKO BANCHI |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mirko Banchi <mk.banchi@gmail.com> | 18 * Author: Mirko Banchi <mk.banchi@gmail.com> |
19 */ | 19 */ |
20 | 20 |
21 #include "ns3/log.h" | 21 #include "ns3/log.h" |
22 #include "ns3/simulator.h" | 22 #include "ns3/simulator.h" |
23 #include "block-ack-manager.h" | 23 #include "block-ack-manager.h" |
| 24 #include "wifi-remote-station-manager.h" |
| 25 #include "ctrl-headers.h" |
24 #include "mgt-headers.h" | 26 #include "mgt-headers.h" |
25 #include "wifi-mac-queue.h" | 27 #include "wifi-mac-queue.h" |
26 #include "mac-tx-middle.h" | 28 #include "mac-tx-middle.h" |
| 29 #include "qos-utils.h" |
27 | 30 |
28 namespace ns3 { | 31 namespace ns3 { |
29 | 32 |
30 NS_LOG_COMPONENT_DEFINE ("BlockAckManager"); | 33 NS_LOG_COMPONENT_DEFINE ("BlockAckManager"); |
31 | 34 |
32 BlockAckManager::Item::Item (Ptr<const Packet> packet, const WifiMacHeader &hdr,
Time tStamp) | 35 BlockAckManager::Item::Item (Ptr<const Packet> packet, const WifiMacHeader &hdr,
Time tStamp) |
33 : packet (packet), | 36 : packet (packet), |
34 hdr (hdr), | 37 hdr (hdr), |
35 timestamp (tStamp) | 38 timestamp (tStamp) |
36 { | 39 { |
37 NS_LOG_FUNCTION (this << packet << hdr << tStamp); | 40 NS_LOG_FUNCTION (this << packet << hdr << tStamp); |
38 } | 41 } |
39 | 42 |
40 Bar::Bar () | 43 Bar::Bar () |
41 { | 44 { |
42 NS_LOG_FUNCTION (this); | 45 NS_LOG_FUNCTION (this); |
43 } | 46 } |
44 | 47 |
45 Bar::Bar (Ptr<const Packet> bar, Mac48Address recipient, uint8_t tid, bool immed
iate) | 48 Bar::Bar (Ptr<const Packet> bar, Mac48Address recipient, uint8_t tid, bool immed
iate) |
46 : bar (bar), | 49 : bar (bar), |
47 recipient (recipient), | 50 recipient (recipient), |
48 tid (tid), | 51 tid (tid), |
49 immediate (immediate) | 52 immediate (immediate) |
50 { | 53 { |
51 NS_LOG_FUNCTION (this << bar << recipient << (uint16_t)tid << immediate); | 54 NS_LOG_FUNCTION (this << bar << recipient << +tid << immediate); |
52 } | 55 } |
53 | 56 |
54 NS_OBJECT_ENSURE_REGISTERED (BlockAckManager); | 57 NS_OBJECT_ENSURE_REGISTERED (BlockAckManager); |
55 | 58 |
56 TypeId | 59 TypeId |
57 BlockAckManager::GetTypeId (void) | 60 BlockAckManager::GetTypeId (void) |
58 { | 61 { |
59 static TypeId tid = TypeId ("ns3::BlockAckManager") | 62 static TypeId tid = TypeId ("ns3::BlockAckManager") |
60 .SetParent<Object> () | 63 .SetParent<Object> () |
61 .SetGroupName ("Wifi") | 64 .SetGroupName ("Wifi") |
(...skipping 11 matching lines...) Expand all Loading... |
73 { | 76 { |
74 NS_LOG_FUNCTION (this); | 77 NS_LOG_FUNCTION (this); |
75 m_queue = 0; | 78 m_queue = 0; |
76 m_agreements.clear (); | 79 m_agreements.clear (); |
77 m_retryPackets.clear (); | 80 m_retryPackets.clear (); |
78 } | 81 } |
79 | 82 |
80 bool | 83 bool |
81 BlockAckManager::ExistsAgreement (Mac48Address recipient, uint8_t tid) const | 84 BlockAckManager::ExistsAgreement (Mac48Address recipient, uint8_t tid) const |
82 { | 85 { |
83 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid); | 86 NS_LOG_FUNCTION (this << recipient << +tid); |
84 return (m_agreements.find (std::make_pair (recipient, tid)) != m_agreements.en
d ()); | 87 return (m_agreements.find (std::make_pair (recipient, tid)) != m_agreements.en
d ()); |
85 } | 88 } |
86 | 89 |
87 bool | 90 bool |
88 BlockAckManager::ExistsAgreementInState (Mac48Address recipient, uint8_t tid, | 91 BlockAckManager::ExistsAgreementInState (Mac48Address recipient, uint8_t tid, |
89 OriginatorBlockAckAgreement::State stat
e) const | 92 OriginatorBlockAckAgreement::State stat
e) const |
90 { | 93 { |
91 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid << state); | 94 NS_LOG_FUNCTION (this << recipient << +tid << state); |
92 AgreementsCI it; | 95 AgreementsCI it; |
93 it = m_agreements.find (std::make_pair (recipient, tid)); | 96 it = m_agreements.find (std::make_pair (recipient, tid)); |
94 if (it != m_agreements.end ()) | 97 if (it != m_agreements.end ()) |
95 { | 98 { |
96 switch (state) | 99 switch (state) |
97 { | 100 { |
98 case OriginatorBlockAckAgreement::INACTIVE: | 101 case OriginatorBlockAckAgreement::INACTIVE: |
99 return it->second.first.IsInactive (); | 102 return it->second.first.IsInactive (); |
100 case OriginatorBlockAckAgreement::ESTABLISHED: | 103 case OriginatorBlockAckAgreement::ESTABLISHED: |
101 return it->second.first.IsEstablished (); | 104 return it->second.first.IsEstablished (); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 agreement.SetState (OriginatorBlockAckAgreement::PENDING); | 138 agreement.SetState (OriginatorBlockAckAgreement::PENDING); |
136 PacketQueue queue; | 139 PacketQueue queue; |
137 std::pair<OriginatorBlockAckAgreement, PacketQueue> value (agreement, queue); | 140 std::pair<OriginatorBlockAckAgreement, PacketQueue> value (agreement, queue); |
138 m_agreements.insert (std::make_pair (key, value)); | 141 m_agreements.insert (std::make_pair (key, value)); |
139 m_blockPackets (recipient, reqHdr->GetTid ()); | 142 m_blockPackets (recipient, reqHdr->GetTid ()); |
140 } | 143 } |
141 | 144 |
142 void | 145 void |
143 BlockAckManager::DestroyAgreement (Mac48Address recipient, uint8_t tid) | 146 BlockAckManager::DestroyAgreement (Mac48Address recipient, uint8_t tid) |
144 { | 147 { |
145 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid); | 148 NS_LOG_FUNCTION (this << recipient << +tid); |
146 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 149 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
147 if (it != m_agreements.end ()) | 150 if (it != m_agreements.end ()) |
148 { | 151 { |
149 for (std::list<PacketQueueI>::const_iterator i = m_retryPackets.begin ();
i != m_retryPackets.end (); ) | 152 for (std::list<PacketQueueI>::const_iterator i = m_retryPackets.begin ();
i != m_retryPackets.end (); ) |
150 { | 153 { |
151 if ((*i)->hdr.GetAddr1 () == recipient && (*i)->hdr.GetQosTid () == ti
d) | 154 if ((*i)->hdr.GetAddr1 () == recipient && (*i)->hdr.GetQosTid () == ti
d) |
152 { | 155 { |
153 i = m_retryPackets.erase (i); | 156 i = m_retryPackets.erase (i); |
154 } | 157 } |
155 else | 158 else |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin (); | 402 std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin (); |
400 for (; it != m_retryPackets.end (); it++) | 403 for (; it != m_retryPackets.end (); it++) |
401 { | 404 { |
402 if (!(*it)->hdr.IsQosData ()) | 405 if (!(*it)->hdr.IsQosData ()) |
403 { | 406 { |
404 NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos Dat
a"); | 407 NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos Dat
a"); |
405 } | 408 } |
406 if ((*it)->hdr.GetAddr1 () == recipient && (*it)->hdr.GetQosTid () == tid
&& (*it)->hdr.GetSequenceNumber () == seqnumber) | 409 if ((*it)->hdr.GetAddr1 () == recipient && (*it)->hdr.GetQosTid () == tid
&& (*it)->hdr.GetSequenceNumber () == seqnumber) |
407 { | 410 { |
408 WifiMacHeader hdr = (*it)->hdr; | 411 WifiMacHeader hdr = (*it)->hdr; |
409 uint8_t tid2 = hdr.GetQosTid (); | 412 uint8_t hdrTid = hdr.GetQosTid (); |
410 Mac48Address recipient2 = hdr.GetAddr1 (); | 413 Mac48Address hdrRecipient = hdr.GetAddr1 (); |
411 | 414 |
412 AgreementsI i = m_agreements.find (std::make_pair (recipient2, tid2)); | 415 AgreementsI i = m_agreements.find (std::make_pair (hdrRecipient, hdrTi
d)); |
413 i->second.second.erase ((*it)); | 416 i->second.second.erase ((*it)); |
414 | 417 |
415 m_retryPackets.erase (it); | 418 m_retryPackets.erase (it); |
416 NS_LOG_DEBUG ("Removed Packet from retry queue = " << hdr.GetSequenceN
umber () << " " << (uint16_t)tid2 << " " << recipient2 << " Buffer Size = " << m
_retryPackets.size ()); | 419 NS_LOG_DEBUG ("Removed Packet from retry queue = " << hdr.GetSequenceN
umber () << " " << +tid << " " << recipient << " Buffer Size = " << m_retryPacke
ts.size ()); |
417 return true; | 420 return true; |
418 } | 421 } |
419 } | 422 } |
420 return false; | 423 return false; |
421 } | 424 } |
422 | 425 |
423 bool | 426 bool |
424 BlockAckManager::HasBar (Bar &bar) | 427 BlockAckManager::HasBar (Bar &bar) |
425 { | 428 { |
426 NS_LOG_FUNCTION (this << &bar); | 429 NS_LOG_FUNCTION (this << &bar); |
427 if (m_bars.size () > 0) | 430 if (m_bars.size () > 0) |
428 { | 431 { |
429 bar = m_bars.front (); | 432 bar = m_bars.front (); |
430 m_bars.pop_front (); | 433 m_bars.pop_front (); |
431 return true; | 434 return true; |
432 } | 435 } |
433 return false; | 436 return false; |
434 } | 437 } |
435 | 438 |
436 bool | 439 bool |
437 BlockAckManager::HasPackets (void) const | 440 BlockAckManager::HasPackets (void) const |
438 { | 441 { |
439 NS_LOG_FUNCTION (this); | 442 NS_LOG_FUNCTION (this); |
440 return (m_retryPackets.size () > 0 || m_bars.size () > 0); | 443 return (m_retryPackets.size () > 0 || m_bars.size () > 0); |
441 } | 444 } |
442 | 445 |
443 uint32_t | 446 uint32_t |
444 BlockAckManager::GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const | 447 BlockAckManager::GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const |
445 { | 448 { |
446 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid); | 449 NS_LOG_FUNCTION (this << recipient << +tid); |
447 uint32_t nPackets = 0; | 450 uint32_t nPackets = 0; |
448 if (ExistsAgreement (recipient, tid)) | 451 if (ExistsAgreement (recipient, tid)) |
449 { | 452 { |
450 AgreementsCI it = m_agreements.find (std::make_pair (recipient, tid)); | 453 AgreementsCI it = m_agreements.find (std::make_pair (recipient, tid)); |
451 PacketQueueCI queueIt = (*it).second.second.begin (); | 454 PacketQueueCI queueIt = (*it).second.second.begin (); |
452 uint16_t currentSeq = 0; | 455 uint16_t currentSeq = 0; |
453 while (queueIt != (*it).second.second.end ()) | 456 while (queueIt != (*it).second.second.end ()) |
454 { | 457 { |
455 currentSeq = (*queueIt).hdr.GetSequenceNumber (); | 458 currentSeq = (*queueIt).hdr.GetSequenceNumber (); |
456 nPackets++; | 459 nPackets++; |
457 /* a fragmented packet must be counted as one packet */ | 460 /* a fragmented packet must be counted as one packet */ |
458 while (queueIt != (*it).second.second.end () && (*queueIt).hdr.GetSequ
enceNumber () == currentSeq) | 461 while (queueIt != (*it).second.second.end () && (*queueIt).hdr.GetSequ
enceNumber () == currentSeq) |
459 { | 462 { |
460 queueIt++; | 463 queueIt++; |
461 } | 464 } |
462 } | 465 } |
463 return nPackets; | 466 return nPackets; |
464 } | 467 } |
465 return 0; | 468 return 0; |
466 } | 469 } |
467 | 470 |
468 uint32_t | 471 uint32_t |
469 BlockAckManager::GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) co
nst | 472 BlockAckManager::GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) co
nst |
470 { | 473 { |
471 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid); | 474 NS_LOG_FUNCTION (this << recipient << +tid); |
472 uint32_t nPackets = 0; | 475 uint32_t nPackets = 0; |
473 uint16_t currentSeq = 0; | 476 uint16_t currentSeq = 0; |
474 if (ExistsAgreement (recipient, tid)) | 477 if (ExistsAgreement (recipient, tid)) |
475 { | 478 { |
476 std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin (); | 479 std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin (); |
477 while (it != m_retryPackets.end ()) | 480 while (it != m_retryPackets.end ()) |
478 { | 481 { |
479 if (!(*it)->hdr.IsQosData ()) | 482 if (!(*it)->hdr.IsQosData ()) |
480 { | 483 { |
481 NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos
Data"); | 484 NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos
Data"); |
(...skipping 14 matching lines...) Expand all Loading... |
496 it++; | 499 it++; |
497 } | 500 } |
498 } | 501 } |
499 } | 502 } |
500 return nPackets; | 503 return nPackets; |
501 } | 504 } |
502 | 505 |
503 void | 506 void |
504 BlockAckManager::SetBlockAckThreshold (uint8_t nPackets) | 507 BlockAckManager::SetBlockAckThreshold (uint8_t nPackets) |
505 { | 508 { |
506 NS_LOG_FUNCTION (this << (uint16_t)nPackets); | 509 NS_LOG_FUNCTION (this << +nPackets); |
507 m_blockAckThreshold = nPackets; | 510 m_blockAckThreshold = nPackets; |
508 } | 511 } |
509 | 512 |
510 void | 513 void |
511 BlockAckManager::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager
> manager) | 514 BlockAckManager::SetWifiRemoteStationManager (const Ptr<WifiRemoteStationManager
> manager) |
512 { | 515 { |
513 NS_LOG_FUNCTION (this << manager); | 516 NS_LOG_FUNCTION (this << manager); |
514 m_stationManager = manager; | 517 m_stationManager = manager; |
515 } | 518 } |
516 | 519 |
(...skipping 21 matching lines...) Expand all Loading... |
538 BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac4
8Address recipient, double rxSnr, WifiMode txMode, double dataSnr) | 541 BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac4
8Address recipient, double rxSnr, WifiMode txMode, double dataSnr) |
539 { | 542 { |
540 NS_LOG_FUNCTION (this << blockAck << recipient << rxSnr << txMode.GetUniqueNam
e () << dataSnr); | 543 NS_LOG_FUNCTION (this << blockAck << recipient << rxSnr << txMode.GetUniqueNam
e () << dataSnr); |
541 uint16_t sequenceFirstLost = 0; | 544 uint16_t sequenceFirstLost = 0; |
542 if (!blockAck->IsMultiTid ()) | 545 if (!blockAck->IsMultiTid ()) |
543 { | 546 { |
544 uint8_t tid = blockAck->GetTidInfo (); | 547 uint8_t tid = blockAck->GetTidInfo (); |
545 if (ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::E
STABLISHED)) | 548 if (ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::E
STABLISHED)) |
546 { | 549 { |
547 bool foundFirstLost = false; | 550 bool foundFirstLost = false; |
548 uint32_t nSuccessfulMpdus = 0; | 551 uint8_t nSuccessfulMpdus = 0; |
549 uint32_t nFailedMpdus = 0; | 552 uint8_t nFailedMpdus = 0; |
550 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 553 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
551 PacketQueueI queueEnd = it->second.second.end (); | 554 PacketQueueI queueEnd = it->second.second.end (); |
552 | 555 |
553 if (it->second.first.m_inactivityEvent.IsRunning ()) | 556 if (it->second.first.m_inactivityEvent.IsRunning ()) |
554 { | 557 { |
555 /* Upon reception of a block ack frame, the inactivity timer at th
e | 558 /* Upon reception of a block ack frame, the inactivity timer at th
e |
556 originator must be reset. | 559 originator must be reset. |
557 For more details see section 11.5.3 in IEEE802.11e standard */ | 560 For more details see section 11.5.3 in IEEE802.11e standard */ |
558 it->second.first.m_inactivityEvent.Cancel (); | 561 it->second.first.m_inactivityEvent.Cancel (); |
559 Time timeout = MicroSeconds (1024 * it->second.first.GetTimeout ()
); | 562 Time timeout = MicroSeconds (1024 * it->second.first.GetTimeout ()
); |
560 it->second.first.m_inactivityEvent = Simulator::Schedule (timeout, | 563 it->second.first.m_inactivityEvent = Simulator::Schedule (timeout, |
561 &BlockAc
kManager::InactivityTimeout, | 564 &BlockAc
kManager::InactivityTimeout, |
562 this, | 565 this, |
563 recipien
t, tid); | 566 recipien
t, tid); |
564 } | 567 } |
565 if (blockAck->IsBasic ()) | 568 if (blockAck->IsBasic ()) |
566 { | 569 { |
567 for (PacketQueueI queueIt = it->second.second.begin (); queueIt !=
queueEnd; ) | 570 for (PacketQueueI queueIt = it->second.second.begin (); queueIt !=
queueEnd; ) |
568 { | 571 { |
569 if (blockAck->IsFragmentReceived ((*queueIt).hdr.GetSequenceNu
mber (), | 572 if (blockAck->IsFragmentReceived ((*queueIt).hdr.GetSequenceNu
mber (), |
570 (uint8_t)(*queueIt).hdr.GetF
ragmentNumber ())) | 573 (*queueIt).hdr.GetFragmentNu
mber ())) |
571 { | 574 { |
572 nSuccessfulMpdus++; | 575 nSuccessfulMpdus++; |
573 RemoveFromRetryQueue (recipient, tid, (*queueIt).hdr.GetSe
quenceNumber ()); | 576 RemoveFromRetryQueue (recipient, tid, (*queueIt).hdr.GetSe
quenceNumber ()); |
574 queueIt = it->second.second.erase (queueIt); | 577 queueIt = it->second.second.erase (queueIt); |
575 } | 578 } |
576 else | 579 else |
577 { | 580 { |
578 if (!foundFirstLost) | 581 if (!foundFirstLost) |
579 { | 582 { |
580 foundFirstLost = true; | 583 foundFirstLost = true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 m_txFailedCallback ((*queueIt).hdr); | 626 m_txFailedCallback ((*queueIt).hdr); |
624 } | 627 } |
625 if (!AlreadyExists ((*queueIt).hdr.GetSequenceNumber (),re
cipient,tid)) | 628 if (!AlreadyExists ((*queueIt).hdr.GetSequenceNumber (),re
cipient,tid)) |
626 { | 629 { |
627 InsertInRetryQueue (queueIt); | 630 InsertInRetryQueue (queueIt); |
628 } | 631 } |
629 queueIt++; | 632 queueIt++; |
630 } | 633 } |
631 } | 634 } |
632 } | 635 } |
633 m_stationManager->ReportAmpduTxStatus (recipient, tid, (uint8_t)nSucce
ssfulMpdus, (uint8_t)nFailedMpdus, rxSnr, dataSnr); | 636 m_stationManager->ReportAmpduTxStatus (recipient, tid, nSuccessfulMpdu
s, nFailedMpdus, rxSnr, dataSnr); |
634 uint16_t newSeq = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, re
cipient); | 637 uint16_t newSeq = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, re
cipient); |
635 if ((foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid, sequ
enceFirstLost)) | 638 if ((foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid, sequ
enceFirstLost)) |
636 || (!foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid,
newSeq))) | 639 || (!foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid,
newSeq))) |
637 { | 640 { |
638 it->second.first.CompleteExchange (); | 641 it->second.first.CompleteExchange (); |
639 } | 642 } |
640 } | 643 } |
641 } | 644 } |
642 else | 645 else |
643 { | 646 { |
(...skipping 10 matching lines...) Expand all Loading... |
654 } | 657 } |
655 | 658 |
656 Ptr<Packet> | 659 Ptr<Packet> |
657 BlockAckManager::ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t ti
d) | 660 BlockAckManager::ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t ti
d) |
658 { | 661 { |
659 /* This method checks if a BlockAckRequest frame should be send to the recipie
nt station. | 662 /* This method checks if a BlockAckRequest frame should be send to the recipie
nt station. |
660 Number of packets under block ack is specified in OriginatorBlockAckAgreeme
nt object but sometimes | 663 Number of packets under block ack is specified in OriginatorBlockAckAgreeme
nt object but sometimes |
661 this number could be incorrect. In fact is possible that a block ack agreem
ent exists for n | 664 this number could be incorrect. In fact is possible that a block ack agreem
ent exists for n |
662 packets but some of these packets are dropped due to MSDU lifetime expirati
on. | 665 packets but some of these packets are dropped due to MSDU lifetime expirati
on. |
663 */ | 666 */ |
664 NS_LOG_FUNCTION (this << recipient << static_cast<uint32_t> (tid)); | 667 NS_LOG_FUNCTION (this << recipient << +tid); |
665 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 668 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
666 NS_ASSERT (it != m_agreements.end ()); | 669 NS_ASSERT (it != m_agreements.end ()); |
667 | 670 |
668 if ((*it).second.first.IsBlockAckRequestNeeded () | 671 if ((*it).second.first.IsBlockAckRequestNeeded () |
669 || (GetNRetryNeededPackets (recipient, tid) == 0 | 672 || (GetNRetryNeededPackets (recipient, tid) == 0 |
670 && m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, rec
ipient) == 0)) | 673 && m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, rec
ipient) == 0)) |
671 { | 674 { |
672 OriginatorBlockAckAgreement &agreement = (*it).second.first; | 675 OriginatorBlockAckAgreement &agreement = (*it).second.first; |
673 agreement.CompleteExchange (); | 676 agreement.CompleteExchange (); |
674 | 677 |
(...skipping 15 matching lines...) Expand all Loading... |
690 Ptr<Packet> bar = Create<Packet> (); | 693 Ptr<Packet> bar = Create<Packet> (); |
691 bar->AddHeader (reqHdr); | 694 bar->AddHeader (reqHdr); |
692 return bar; | 695 return bar; |
693 } | 696 } |
694 return 0; | 697 return 0; |
695 } | 698 } |
696 | 699 |
697 void | 700 void |
698 BlockAckManager::InactivityTimeout (Mac48Address recipient, uint8_t tid) | 701 BlockAckManager::InactivityTimeout (Mac48Address recipient, uint8_t tid) |
699 { | 702 { |
700 NS_LOG_FUNCTION (this << recipient << static_cast<uint32_t> (tid)); | 703 NS_LOG_FUNCTION (this << recipient << +tid); |
701 m_blockAckInactivityTimeout (recipient, tid, true); | 704 m_blockAckInactivityTimeout (recipient, tid, true); |
702 } | 705 } |
703 | 706 |
704 void | 707 void |
705 BlockAckManager::NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid
, uint16_t startingSeq) | 708 BlockAckManager::NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid
, uint16_t startingSeq) |
706 { | 709 { |
707 NS_LOG_FUNCTION (this << recipient << static_cast<uint32_t> (tid) << startingS
eq); | 710 NS_LOG_FUNCTION (this << recipient << +tid << startingSeq); |
708 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 711 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
709 NS_ASSERT (it != m_agreements.end ()); | 712 NS_ASSERT (it != m_agreements.end ()); |
710 it->second.first.SetState (OriginatorBlockAckAgreement::ESTABLISHED); | 713 it->second.first.SetState (OriginatorBlockAckAgreement::ESTABLISHED); |
711 it->second.first.SetStartingSequence (startingSeq); | 714 it->second.first.SetStartingSequence (startingSeq); |
712 } | 715 } |
713 | 716 |
714 void | 717 void |
715 BlockAckManager::NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t ti
d) | 718 BlockAckManager::NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t ti
d) |
716 { | 719 { |
717 NS_LOG_FUNCTION (this << recipient << static_cast<uint32_t> (tid)); | 720 NS_LOG_FUNCTION (this << recipient << +tid); |
718 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 721 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
719 NS_ASSERT (it != m_agreements.end ()); | 722 NS_ASSERT (it != m_agreements.end ()); |
720 if (it != m_agreements.end ()) | 723 if (it != m_agreements.end ()) |
721 { | 724 { |
722 it->second.first.SetState (OriginatorBlockAckAgreement::UNSUCCESSFUL); | 725 it->second.first.SetState (OriginatorBlockAckAgreement::UNSUCCESSFUL); |
723 } | 726 } |
724 } | 727 } |
725 | 728 |
726 void | 729 void |
727 BlockAckManager::NotifyMpduTransmission (Mac48Address recipient, uint8_t tid, ui
nt16_t nextSeqNumber, WifiMacHeader::QosAckPolicy policy) | 730 BlockAckManager::NotifyMpduTransmission (Mac48Address recipient, uint8_t tid, ui
nt16_t nextSeqNumber, WifiMacHeader::QosAckPolicy policy) |
728 { | 731 { |
729 NS_LOG_FUNCTION (this << recipient << static_cast<uint32_t> (tid) << nextSeqNu
mber); | 732 NS_LOG_FUNCTION (this << recipient << +tid << nextSeqNumber); |
730 Ptr<Packet> bar = 0; | 733 Ptr<Packet> bar = 0; |
731 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 734 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
732 NS_ASSERT (it != m_agreements.end ()); | 735 NS_ASSERT (it != m_agreements.end ()); |
733 uint16_t nextSeq; | 736 uint16_t nextSeq; |
734 if (GetNRetryNeededPackets (recipient, tid) > 0) | 737 if (GetNRetryNeededPackets (recipient, tid) > 0) |
735 { | 738 { |
736 nextSeq = GetSeqNumOfNextRetryPacket (recipient, tid); | 739 nextSeq = GetSeqNumOfNextRetryPacket (recipient, tid); |
737 } | 740 } |
738 else | 741 else |
739 { | 742 { |
(...skipping 14 matching lines...) Expand all Loading... |
754 void | 757 void |
755 BlockAckManager::SetQueue (const Ptr<WifiMacQueue> queue) | 758 BlockAckManager::SetQueue (const Ptr<WifiMacQueue> queue) |
756 { | 759 { |
757 NS_LOG_FUNCTION (this << queue); | 760 NS_LOG_FUNCTION (this << queue); |
758 m_queue = queue; | 761 m_queue = queue; |
759 } | 762 } |
760 | 763 |
761 bool | 764 bool |
762 BlockAckManager::SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid,
uint16_t startingSeq) | 765 BlockAckManager::SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid,
uint16_t startingSeq) |
763 { | 766 { |
764 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid << startingSeq); | 767 NS_LOG_FUNCTION (this << recipient << +tid << startingSeq); |
765 NS_ASSERT (!ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreemen
t::PENDING)); | 768 NS_ASSERT (!ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreemen
t::PENDING)); |
766 if (!ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::UNSU
CCESSFUL) && ExistsAgreement (recipient, tid)) | 769 if (!ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::UNSU
CCESSFUL) && ExistsAgreement (recipient, tid)) |
767 { | 770 { |
768 uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader
::ADDR1, recipient) + | 771 uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader
::ADDR1, recipient) + |
769 GetNBufferedPackets (recipient, tid); | 772 GetNBufferedPackets (recipient, tid); |
770 if (packets >= m_blockAckThreshold) | 773 if (packets >= m_blockAckThreshold) |
771 { | 774 { |
772 NotifyAgreementEstablished (recipient, tid, startingSeq); | 775 NotifyAgreementEstablished (recipient, tid, startingSeq); |
773 return true; | 776 return true; |
774 } | 777 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 void | 877 void |
875 BlockAckManager::SetTxMiddle (const Ptr<MacTxMiddle> txMiddle) | 878 BlockAckManager::SetTxMiddle (const Ptr<MacTxMiddle> txMiddle) |
876 { | 879 { |
877 NS_LOG_FUNCTION (this << txMiddle); | 880 NS_LOG_FUNCTION (this << txMiddle); |
878 m_txMiddle = txMiddle; | 881 m_txMiddle = txMiddle; |
879 } | 882 } |
880 | 883 |
881 uint16_t | 884 uint16_t |
882 BlockAckManager::GetSeqNumOfNextRetryPacket (Mac48Address recipient, uint8_t tid
) const | 885 BlockAckManager::GetSeqNumOfNextRetryPacket (Mac48Address recipient, uint8_t tid
) const |
883 { | 886 { |
884 NS_LOG_FUNCTION (this << recipient << (uint16_t)tid); | 887 NS_LOG_FUNCTION (this << recipient << +tid); |
885 std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin (); | 888 std::list<PacketQueueI>::const_iterator it = m_retryPackets.begin (); |
886 while (it != m_retryPackets.end ()) | 889 while (it != m_retryPackets.end ()) |
887 { | 890 { |
888 if (!(*it)->hdr.IsQosData ()) | 891 if (!(*it)->hdr.IsQosData ()) |
889 { | 892 { |
890 NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos Dat
a"); | 893 NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos Dat
a"); |
891 } | 894 } |
892 if ((*it)->hdr.GetAddr1 () == recipient && (*it)->hdr.GetQosTid () == tid) | 895 if ((*it)->hdr.GetAddr1 () == recipient && (*it)->hdr.GetQosTid () == tid) |
893 { | 896 { |
894 return (*it)->hdr.GetSequenceNumber (); | 897 return (*it)->hdr.GetSequenceNumber (); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 if (it == m_retryPackets.end ()) | 936 if (it == m_retryPackets.end ()) |
934 { | 937 { |
935 m_retryPackets.push_back (item); | 938 m_retryPackets.push_back (item); |
936 } | 939 } |
937 } | 940 } |
938 } | 941 } |
939 } | 942 } |
940 } | 943 } |
941 | 944 |
942 } //namespace ns3 | 945 } //namespace ns3 |
LEFT | RIGHT |