|
235 |
.SetParent<ns3::Dcf> () |
235 |
.SetParent<ns3::Dcf> () |
236 |
.SetGroupName ("Wifi") |
236 |
.SetGroupName ("Wifi") |
237 |
.AddConstructor<EdcaTxopN> () |
237 |
.AddConstructor<EdcaTxopN> () |
|
|
238 |
.AddAttribute ("AddBaFailureTimeout", |
239 |
"Specifies a time limit (in multiple of 104 microseconds)" |
240 |
"after which the ADDBA request is restarted. If set to 0," |
241 |
"then there is no protection for ADDBA requests.", |
242 |
TimeValue (MicroSeconds (1024)), |
243 |
MakeTimeAccessor (&EdcaTxopN::SetAddBaFailureTimeout, |
244 |
&EdcaTxopN::GetAddBaFailureTimeout), |
245 |
MakeTimeChecker ()) |
238 |
.AddAttribute ("Queue", |
246 |
.AddAttribute ("Queue", |
239 |
"The WifiMacQueue object", |
247 |
"The WifiMacQueue object", |
240 |
PointerValue (), |
248 |
PointerValue (), |
|
264 |
m_typeOfStation (STA), |
272 |
m_typeOfStation (STA), |
265 |
m_blockAckType (COMPRESSED_BLOCK_ACK), |
273 |
m_blockAckType (COMPRESSED_BLOCK_ACK), |
266 |
m_startTxop (Seconds (0)), |
274 |
m_startTxop (Seconds (0)), |
267 |
m_isAccessRequestedForRts (false) |
275 |
m_isAccessRequestedForRts (false), |
|
|
276 |
m_addbaFailureTimeoutEvent (), |
277 |
m_shouldSendAddBa (false) |
268 |
{ |
278 |
{ |
269 |
NS_LOG_FUNCTION (this); |
279 |
NS_LOG_FUNCTION (this); |
270 |
m_transmissionListener = new EdcaTxopN::TransmissionListener (this); |
280 |
m_transmissionListener = new EdcaTxopN::TransmissionListener (this); |
|
463 |
m_low = low; |
473 |
m_low = low; |
464 |
} |
474 |
} |
465 |
|
475 |
|
|
|
476 |
void |
477 |
EdcaTxopN::SetAddBaFailureTimeout (Time timeout) |
478 |
{ |
479 |
NS_ASSERT_MSG (timeout.GetMicroSeconds () % 1024 == 0, "AddbaFailureTimeout value should be a multiple of 1024 microseconds!"); |
480 |
NS_LOG_FUNCTION (this << timeout); |
481 |
m_addbaFailureTimeout = timeout; |
482 |
} |
483 |
|
484 |
Time |
485 |
EdcaTxopN::GetAddBaFailureTimeout () const |
486 |
{ |
487 |
return m_addbaFailureTimeout; |
488 |
} |
489 |
|
466 |
bool |
490 |
bool |
467 |
EdcaTxopN::NeedsAccess (void) const |
491 |
EdcaTxopN::NeedsAccess (void) const |
468 |
{ |
492 |
{ |
|
513 |
m_currentPacket = m_baManager->GetNextPacket (m_currentHdr); |
537 |
m_currentPacket = m_baManager->GetNextPacket (m_currentHdr); |
514 |
if (m_currentPacket == 0) |
538 |
if (m_currentPacket == 0) |
515 |
{ |
539 |
{ |
|
|
540 |
if (m_shouldSendAddBa && SetupBlockAckIfNeeded ()) |
541 |
{ |
542 |
return; |
543 |
} |
516 |
if (m_queue->PeekFirstAvailable (&m_currentHdr, m_currentPacketTimestamp, m_qosBlockedDestinations) == 0) |
544 |
if (m_queue->PeekFirstAvailable (&m_currentHdr, m_currentPacketTimestamp, m_qosBlockedDestinations) == 0) |
517 |
{ |
545 |
{ |
518 |
NS_LOG_DEBUG ("no available packets in the queue"); |
546 |
NS_LOG_DEBUG ("no available packets in the queue"); |
519 |
return; |
547 |
return; |
520 |
} |
548 |
} |
521 |
if (m_currentHdr.IsQosData () && !m_currentHdr.GetAddr1 ().IsBroadcast () |
549 |
if (m_currentHdr.IsQosData () |
|
|
550 |
&& !m_currentHdr.GetAddr1 ().IsBroadcast () |
522 |
&& !m_baManager->ExistsAgreement (m_currentHdr.GetAddr1 (), m_currentHdr.GetQosTid ()) |
551 |
&& !m_baManager->ExistsAgreement (m_currentHdr.GetAddr1 (), m_currentHdr.GetQosTid ()) |
523 |
&& SetupBlockAckIfNeeded ()) |
552 |
&& SetupBlockAckIfNeeded ()) |
524 |
{ |
553 |
{ |
|
911 |
if (GetAmpduExist (m_currentHdr.GetAddr1 ()) || m_currentHdr.IsQosData ()) |
940 |
if (GetAmpduExist (m_currentHdr.GetAddr1 ()) || m_currentHdr.IsQosData ()) |
912 |
{ |
941 |
{ |
913 |
uint8_t tid = GetTid (m_currentPacket, m_currentHdr); |
942 |
uint8_t tid = GetTid (m_currentPacket, m_currentHdr); |
914 |
|
|
|
915 |
if (GetBaAgreementExists (m_currentHdr.GetAddr1 (), tid)) |
943 |
if (GetBaAgreementExists (m_currentHdr.GetAddr1 (), tid)) |
916 |
{ |
944 |
{ |
917 |
//send Block ACK Request in order to shift WinStart at the receiver |
945 |
//send Block ACK Request in order to shift WinStart at the receiver |
|
939 |
resetCurrentPacket = false; |
967 |
resetCurrentPacket = false; |
940 |
} |
968 |
} |
941 |
} |
969 |
} |
942 |
//to reset the dcf. |
970 |
if (m_currentHdr.IsAction () && GetAddBaFailureTimeout () > NanoSeconds (0)) |
|
|
971 |
{ |
972 |
WifiActionHeader actionHdr; |
973 |
Ptr<Packet> p = m_currentPacket->Copy (); |
974 |
p->RemoveHeader (actionHdr); |
975 |
if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK |
976 |
&& actionHdr.GetAction ().blockAck == WifiActionHeader::BLOCK_ACK_ADDBA_REQUEST) |
977 |
{ |
978 |
resetCurrentPacket = false; |
979 |
} |
980 |
} |
943 |
if (resetCurrentPacket == true) |
981 |
if (resetCurrentPacket == true) |
944 |
{ |
982 |
{ |
|
|
983 |
//to reset the dcf. |
945 |
m_currentPacket = 0; |
984 |
m_currentPacket = 0; |
946 |
} |
985 |
} |
947 |
m_dcf->ResetCw (); |
986 |
m_dcf->ResetCw (); |
|
1466 |
{ |
1505 |
{ |
1467 |
NS_LOG_FUNCTION (this << respHdr << recipient); |
1506 |
NS_LOG_FUNCTION (this << respHdr << recipient); |
1468 |
NS_LOG_DEBUG ("received ADDBA response from " << recipient); |
1507 |
NS_LOG_DEBUG ("received ADDBA response from " << recipient); |
|
|
1508 |
m_shouldSendAddBa = false; |
1509 |
m_addbaFailureTimeoutEvent.Cancel (); |
1469 |
uint8_t tid = respHdr->GetTid (); |
1510 |
uint8_t tid = respHdr->GetTid (); |
1470 |
if (m_baManager->ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::PENDING)) |
1511 |
if (m_baManager->ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::PENDING) |
|
|
1512 |
|| m_baManager->ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::UNSUCCESSFUL)) |
1471 |
{ |
1513 |
{ |
1472 |
if (respHdr->GetStatusCode ().IsSuccess ()) |
1514 |
if (respHdr->GetStatusCode ().IsSuccess ()) |
1473 |
{ |
1515 |
{ |
|
1579 |
EdcaTxopN::SetupBlockAckIfNeeded () |
1621 |
EdcaTxopN::SetupBlockAckIfNeeded () |
1580 |
{ |
1622 |
{ |
1581 |
NS_LOG_FUNCTION (this); |
1623 |
NS_LOG_FUNCTION (this); |
1582 |
uint8_t tid = m_currentHdr.GetQosTid (); |
1624 |
m_addbaFailureTimeoutEvent.Cancel (); |
|
|
1625 |
uint8_t tid; |
1626 |
if (m_currentHdr.IsQosData () || m_currentHdr.IsAction ()) |
1627 |
{ |
1628 |
tid = GetTid (m_currentPacket, m_currentHdr); |
1629 |
} |
1630 |
else |
1631 |
{ |
1632 |
return false; |
1633 |
} |
1583 |
Mac48Address recipient = m_currentHdr.GetAddr1 (); |
1634 |
Mac48Address recipient = m_currentHdr.GetAddr1 (); |
1584 |
|
|
|
1585 |
uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient); |
1635 |
uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient); |
1586 |
|
|
|
1587 |
if ((m_blockAckThreshold > 0 && packets >= m_blockAckThreshold) || (packets > 1 && m_mpduAggregator != 0) || m_stationManager->HasVhtSupported ()) |
1636 |
if ((m_blockAckThreshold > 0 && packets >= m_blockAckThreshold) || (packets > 1 && m_mpduAggregator != 0) || m_stationManager->HasVhtSupported ()) |
1588 |
{ |
1637 |
{ |
1589 |
/* Block ack setup */ |
1638 |
/* Block ack setup */ |
|
1675 |
{ |
1724 |
{ |
1676 |
NS_LOG_FUNCTION (this << dest << static_cast<uint32_t> (tid) << startSeq << timeout << immediateBAck); |
1725 |
NS_LOG_FUNCTION (this << dest << static_cast<uint32_t> (tid) << startSeq << timeout << immediateBAck); |
1677 |
NS_LOG_DEBUG ("sent ADDBA request to " << dest); |
1726 |
NS_LOG_DEBUG ("sent ADDBA request to " << dest); |
|
|
1727 |
m_shouldSendAddBa = false; |
1678 |
WifiMacHeader hdr; |
1728 |
WifiMacHeader hdr; |
1679 |
hdr.SetAction (); |
1729 |
hdr.SetAction (); |
1680 |
hdr.SetAddr1 (dest); |
1730 |
hdr.SetAddr1 (dest); |
|
1728 |
params.DisableRts (); |
1778 |
params.DisableRts (); |
1729 |
params.DisableNextData (); |
1779 |
params.DisableNextData (); |
1730 |
params.DisableOverrideDurationId (); |
1780 |
params.DisableOverrideDurationId (); |
|
|
1781 |
|
1782 |
if (GetAddBaFailureTimeout () > NanoSeconds (0)) |
1783 |
{ |
1784 |
m_addbaFailureTimeoutEvent = Simulator::Schedule (GetAddBaFailureTimeout (), &EdcaTxopN::AddBaFailureTimeout, this); |
1785 |
} |
1731 |
|
1786 |
|
1732 |
m_low->StartTransmission (m_currentPacket, &m_currentHdr, params, |
1787 |
m_low->StartTransmission (m_currentPacket, &m_currentHdr, params, |
1733 |
m_transmissionListener); |
1788 |
m_transmissionListener); |
1734 |
} |
1789 |
} |
1735 |
|
1790 |
|
1736 |
void |
1791 |
void |
|
|
1792 |
EdcaTxopN::AddBaFailureTimeout () |
1793 |
{ |
1794 |
NS_LOG_FUNCTION (this); |
1795 |
uint8_t tid = GetTid (m_currentPacket, m_currentHdr); |
1796 |
m_baManager->NotifyAgreementUnsuccessful (m_currentHdr.GetAddr1 (), tid); |
1797 |
if (GetAddBaFailureTimeout () > NanoSeconds (0)) |
1798 |
{ |
1799 |
m_shouldSendAddBa = true; |
1800 |
} |
1801 |
RestartAccessIfNeeded (); |
1802 |
} |
1803 |
|
1804 |
void |
1737 |
EdcaTxopN::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator) |
1805 |
EdcaTxopN::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator) |
1738 |
{ |
1806 |
{ |
1739 |
NS_LOG_FUNCTION (this << addr << static_cast<uint32_t> (tid) << byOriginator); |
1807 |
NS_LOG_FUNCTION (this << addr << static_cast<uint32_t> (tid) << byOriginator); |