View | Details | Raw Unified | Return to bug 2470
Collapse All | Expand All

(-)a/src/wifi/model/edca-txop-n.cc (-8 / +76 lines)
 Lines 235-240    Link Here 
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 (),
 Lines 264-270    Link Here 
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);
 Lines 463-468    Link Here 
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
{
 Lines 513-524    Link Here 
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
            {
 Lines 911-917    Link Here 
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
 Lines 939-947    Link Here 
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 ();
 Lines 1466-1473    Link Here 
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
        {
 Lines 1579-1589    Link Here 
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 */
 Lines 1675-1680    Link Here 
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);
 Lines 1728-1739    Link Here 
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);
(-)a/src/wifi/model/edca-txop-n.h (+21 lines)
 Lines 382-387    Link Here 
382
   * can be sent safely.
382
   * can be sent safely.
383
   */
383
   */
384
  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
384
  void Queue (Ptr<const Packet> packet, const WifiMacHeader &hdr);
385
  
386
  /**
387
   * Sets the timeout for ADDBA requests.
388
   *
389
   * \param timeout the duration of the addba failure timeout.
390
   */
391
  void SetAddBaFailureTimeout (Time timeout);
392
  /**
393
   * Return the timeout for ADDBA requests.
394
   *
395
   * \return the timeout the duration of the addba failure timeout
396
   */
397
  Time GetAddBaFailureTimeout () const;
385
398
386
  void SetMsduAggregator (Ptr<MsduAggregator> aggr);
399
  void SetMsduAggregator (Ptr<MsduAggregator> aggr);
387
  void SetMpduAggregator (Ptr<MpduAggregator> aggr);
400
  void SetMpduAggregator (Ptr<MpduAggregator> aggr);
 Lines 536-541    Link Here 
536
   *         false otherwise
549
   *         false otherwise
537
   */
550
   */
538
  bool HasTxop (void) const;
551
  bool HasTxop (void) const;
552
  
553
  /**
554
   * Event handler that is fired once the addba failure timeout has elapsed.
555
   */
556
  void AddBaFailureTimeout ();
539
557
540
  AcIndex m_ac;
558
  AcIndex m_ac;
541
  class Dcf;
559
  class Dcf;
 Lines 580-585    Link Here 
580
  TracedValue<uint32_t> m_backoffTrace;
598
  TracedValue<uint32_t> m_backoffTrace;
581
  TracedValue<uint32_t> m_cwTrace;
599
  TracedValue<uint32_t> m_cwTrace;
582
  TracedCallback<Time, Time> m_txopTrace;
600
  TracedCallback<Time, Time> m_txopTrace;
601
  Time m_addbaFailureTimeout;
602
  EventId m_addbaFailureTimeoutEvent;
603
  bool m_shouldSendAddBa;
583
};
604
};
584
605
585
} //namespace ns3
606
} //namespace ns3

Return to bug 2470