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

(-)a/src/wifi/model/block-ack-manager.cc (-1 / +60 lines)
 Lines 322-330    Link Here 
322
  return packet;
322
  return packet;
323
}
323
}
324
324
325
Ptr<const Packet>
326
BlockAckManager::PeekNextPacket (WifiMacHeader &hdr)
327
{
328
  NS_LOG_FUNCTION (this << &hdr);
329
  Ptr<const Packet> packet = 0;
330
  uint8_t tid;
331
  Mac48Address recipient;
332
  CleanupBuffers ();
333
  if (!m_retryPackets.empty ())
334
    {
335
      NS_LOG_DEBUG ("Retry buffer size is " << m_retryPackets.size ());
336
      std::list<PacketQueueI>::iterator it = m_retryPackets.begin ();
337
      while (it != m_retryPackets.end ())
338
        {
339
          if ((*it)->hdr.IsQosData ())
340
            {
341
              tid = (*it)->hdr.GetQosTid ();
342
            }
343
          else
344
            {
345
              NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos Data");
346
            }
347
          recipient = (*it)->hdr.GetAddr1 ();
348
          AgreementsI agreement = m_agreements.find (std::make_pair (recipient, tid));
349
          NS_ASSERT (agreement != m_agreements.end ());
350
          packet = (*it)->packet->Copy ();
351
          hdr = (*it)->hdr;
352
          hdr.SetRetry ();
353
          if (hdr.IsQosData ())
354
            {
355
              tid = hdr.GetQosTid ();
356
            }
357
          else
358
            {
359
              NS_FATAL_ERROR ("Packet in blockAck manager retry queue is not Qos Data");
360
            }
361
          recipient = hdr.GetAddr1 ();
362
          if (!agreement->second.first.IsHtSupported ()
363
              && (ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::ESTABLISHED)
364
                  || SwitchToBlockAckIfNeeded (recipient, tid, hdr.GetSequenceNumber ())))
365
            {
366
              hdr.SetQosAckPolicy (WifiMacHeader::BLOCK_ACK);
367
            }
368
          else
369
            {
370
              /* From section 9.10.3 in IEEE802.11e standard:
371
               * In order to improve efficiency, originators using the Block Ack facility
372
               * may send MPDU frames with the Ack Policy subfield in QoS control frames
373
               * set to Normal Ack if only a few MPDUs are available for transmission.[...]
374
               * When there are sufficient number of MPDUs, the originator may switch back to
375
               * the use of Block Ack.
376
               */
377
              hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK);
378
            }
379
          break;
380
        }
381
    }
382
  return packet;
383
}
325
384
326
Ptr<const Packet>
385
Ptr<const Packet>
327
BlockAckManager::PeekNextPacket (WifiMacHeader &hdr, Mac48Address recipient, uint8_t tid, Time *tstamp)
386
BlockAckManager::PeekNextPacketByTidAndAddress (WifiMacHeader &hdr, Mac48Address recipient, uint8_t tid, Time *tstamp)
328
{
387
{
329
  NS_LOG_FUNCTION (this);
388
  NS_LOG_FUNCTION (this);
330
  Ptr<const Packet> packet = 0;
389
  Ptr<const Packet> packet = 0;
(-)a/src/wifi/model/block-ack-manager.h (-2 / +13 lines)
 Lines 152-157    Link Here 
152
   * corresponding block ack bitmap.
152
   * corresponding block ack bitmap.
153
   */
153
   */
154
  Ptr<const Packet> GetNextPacket (WifiMacHeader &hdr);
154
  Ptr<const Packet> GetNextPacket (WifiMacHeader &hdr);
155
  /**
156
   * \param hdr 802.11 header of returned packet (if exists).
157
   *
158
   * \return the packet
159
   *
160
   * This methods returns a packet (if exists) indicated as not received in
161
   * corresponding block ack bitmap. This method doesn't remove the packet from this queue.
162
   */
163
  Ptr<const Packet> PeekNextPacket (WifiMacHeader &hdr);
155
  bool HasBar (struct Bar &bar);
164
  bool HasBar (struct Bar &bar);
156
  /**
165
  /**
157
   * Returns true if there are packets that need of retransmission or at least a
166
   * Returns true if there are packets that need of retransmission or at least a
 Lines 320-328    Link Here 
320
   */
329
   */
321
  bool RemovePacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
330
  bool RemovePacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber);
322
  /*
331
  /*
323
   * Peek in retransmit queue and get the next packet without removing it from the queue
332
   * Peek in retransmit queue and get the next packet having address indicated
333
   * by <i>type</i> equals to <i>addr</i>, and tid equals to <i>tid</i>.
334
   * This method doesn't remove the packet from this queue.
324
   */
335
   */
325
  Ptr<const Packet> PeekNextPacket (WifiMacHeader &hdr, Mac48Address recipient, uint8_t tid, Time *timestamp);
336
  Ptr<const Packet> PeekNextPacketByTidAndAddress (WifiMacHeader &hdr, Mac48Address recipient, uint8_t tid, Time *timestamp);
326
  /**
337
  /**
327
   * This function returns true if the lifetime of the packets a BAR refers to didn't expire yet else it returns false.
338
   * This function returns true if the lifetime of the packets a BAR refers to didn't expire yet else it returns false.
328
   * If it return false then the BAR will be discarded (i.e. will not be re-transmitted)
339
   * If it return false then the BAR will be discarded (i.e. will not be re-transmitted)
(-)a/src/wifi/model/edca-txop-n.cc (-3 / +92 lines)
 Lines 258-264    Link Here 
258
    m_msduAggregator (0),
258
    m_msduAggregator (0),
259
    m_mpduAggregator (0),
259
    m_mpduAggregator (0),
260
    m_typeOfStation (STA),
260
    m_typeOfStation (STA),
261
    m_blockAckType (COMPRESSED_BLOCK_ACK)
261
    m_blockAckType (COMPRESSED_BLOCK_ACK),
262
    m_isAccessRequestedForRts (false)
262
{
263
{
263
  NS_LOG_FUNCTION (this);
264
  NS_LOG_FUNCTION (this);
264
  m_transmissionListener = new EdcaTxopN::TransmissionListener (this);
265
  m_transmissionListener = new EdcaTxopN::TransmissionListener (this);
 Lines 464-470    Link Here 
464
Ptr<const Packet>
465
Ptr<const Packet>
465
EdcaTxopN::PeekNextRetransmitPacket (WifiMacHeader &header,Mac48Address recipient, uint8_t tid, Time *timestamp)
466
EdcaTxopN::PeekNextRetransmitPacket (WifiMacHeader &header,Mac48Address recipient, uint8_t tid, Time *timestamp)
466
{
467
{
467
  return m_baManager->PeekNextPacket (header,recipient,tid, timestamp);
468
  return m_baManager->PeekNextPacketByTidAndAddress (header,recipient,tid, timestamp);
468
}
469
}
469
470
470
void
471
void
 Lines 477-482    Link Here 
477
EdcaTxopN::NotifyAccessGranted (void)
478
EdcaTxopN::NotifyAccessGranted (void)
478
{
479
{
479
  NS_LOG_FUNCTION (this);
480
  NS_LOG_FUNCTION (this);
481
  m_isAccessRequestedForRts = false;
480
  if (m_currentPacket == 0)
482
  if (m_currentPacket == 0)
481
    {
483
    {
482
      if (m_queue->IsEmpty () && !m_baManager->HasPackets ())
484
      if (m_queue->IsEmpty () && !m_baManager->HasPackets ())
 Lines 633-639    Link Here 
633
void EdcaTxopN::NotifyInternalCollision (void)
635
void EdcaTxopN::NotifyInternalCollision (void)
634
{
636
{
635
  NS_LOG_FUNCTION (this);
637
  NS_LOG_FUNCTION (this);
636
  NotifyCollision ();
638
  bool resetDcf = false;
639
  if (m_isAccessRequestedForRts)
640
    {
641
      if (!NeedRtsRetransmission ())
642
      {
643
        resetDcf = true;
644
        m_stationManager->ReportFinalRtsFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
645
      }
646
      else
647
      {
648
        m_stationManager->ReportRtsFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
649
      }
650
    }
651
  else
652
    {
653
      if (!NeedDataRetransmission ())
654
      {
655
        resetDcf = true;
656
        m_stationManager->ReportFinalDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
657
      }
658
      else
659
      {
660
        m_stationManager->ReportDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
661
      }
662
    }
663
  if (resetDcf)
664
    {
665
      if (!m_txFailedCallback.IsNull ())
666
        {
667
          m_txFailedCallback (m_currentHdr);
668
        }
669
      //to reset the dcf.
670
      m_currentPacket = 0;
671
      m_dcf->ResetCw ();
672
    }
673
  else
674
    {
675
      m_dcf->UpdateFailedCw ();
676
    }
677
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
678
  m_dcf->StartBackoffNow (m_backoffTrace);
679
  RestartAccessIfNeeded ();
637
}
680
}
638
681
639
void
682
void
 Lines 1024-1029    Link Here 
1024
       || !m_queue->IsEmpty () || m_baManager->HasPackets ())
1067
       || !m_queue->IsEmpty () || m_baManager->HasPackets ())
1025
      && !m_dcf->IsAccessRequested ())
1068
      && !m_dcf->IsAccessRequested ())
1026
    {
1069
    {
1070
      Ptr<const Packet> packet;
1071
      WifiMacHeader hdr;
1072
      if (m_currentPacket != 0)
1073
        {
1074
          packet = m_currentPacket;
1075
          hdr = m_currentHdr;
1076
        }
1077
      else if (m_baManager->HasPackets ())
1078
        {
1079
          packet = m_baManager->PeekNextPacket (hdr);
1080
        }
1081
      else if (m_queue->PeekFirstAvailable (&hdr, m_currentPacketTimestamp, m_qosBlockedDestinations) != 0)
1082
        {
1083
          packet = m_queue->PeekFirstAvailable (&hdr, m_currentPacketTimestamp, m_qosBlockedDestinations);
1084
        }
1085
      if (packet != 0)
1086
        {
1087
          m_isAccessRequestedForRts = m_stationManager->NeedRts (hdr.GetAddr1 (), &hdr, packet, m_low->GetDataTxVector (packet, &hdr));
1088
        }
1089
      else
1090
        {
1091
          m_isAccessRequestedForRts = false;
1092
        }
1027
      m_manager->RequestAccess (m_dcf);
1093
      m_manager->RequestAccess (m_dcf);
1028
    }
1094
    }
1029
}
1095
}
 Lines 1036-1041    Link Here 
1036
      && (!m_queue->IsEmpty () || m_baManager->HasPackets ())
1102
      && (!m_queue->IsEmpty () || m_baManager->HasPackets ())
1037
      && !m_dcf->IsAccessRequested ())
1103
      && !m_dcf->IsAccessRequested ())
1038
    {
1104
    {
1105
      Ptr<const Packet> packet;
1106
      WifiMacHeader hdr;
1107
      if (m_currentPacket != 0)
1108
        {
1109
          packet = m_currentPacket;
1110
          hdr = m_currentHdr;
1111
        }
1112
      else if (m_baManager->HasPackets ())
1113
        {
1114
          packet = m_baManager->PeekNextPacket (hdr);
1115
        }
1116
      else if (m_queue->PeekFirstAvailable (&hdr, m_currentPacketTimestamp, m_qosBlockedDestinations) != 0)
1117
        {
1118
          packet = m_queue->PeekFirstAvailable (&hdr, m_currentPacketTimestamp, m_qosBlockedDestinations);
1119
        }
1120
      if (packet != 0)
1121
        {
1122
          m_isAccessRequestedForRts = m_stationManager->NeedRts (hdr.GetAddr1 (), &hdr, packet, m_low->GetDataTxVector (packet, &hdr));
1123
        }
1124
      else
1125
        {
1126
          m_isAccessRequestedForRts = false;
1127
        }
1039
      m_manager->RequestAccess (m_dcf);
1128
      m_manager->RequestAccess (m_dcf);
1040
    }
1129
    }
1041
}
1130
}
(-)a/src/wifi/model/edca-txop-n.h (+1 lines)
 Lines 567-572    Link Here 
567
  Time m_currentPacketTimestamp;
567
  Time m_currentPacketTimestamp;
568
  uint16_t m_blockAckInactivityTimeout;
568
  uint16_t m_blockAckInactivityTimeout;
569
  struct Bar m_currentBar;
569
  struct Bar m_currentBar;
570
  bool m_isAccessRequestedForRts;
570
  TracedValue<uint32_t> m_backoffTrace;
571
  TracedValue<uint32_t> m_backoffTrace;
571
  TracedValue<uint32_t> m_cwTrace;
572
  TracedValue<uint32_t> m_cwTrace;
572
};
573
};
(-)a/src/wifi/model/mac-low.h (-1 / +1 lines)
 Lines 823-829    Link Here 
823
   */
823
   */
824
  void FlushAggregateQueue (void);
824
  void FlushAggregateQueue (void);
825
825
826
protected:
827
  /**
826
  /**
828
   * Return a TXVECTOR for the DATA frame given the destination.
827
   * Return a TXVECTOR for the DATA frame given the destination.
829
   * The function consults WifiRemoteStationManager, which controls the rate
828
   * The function consults WifiRemoteStationManager, which controls the rate
 Lines 834-839    Link Here 
834
   * \return TXVECTOR for the given packet
833
   * \return TXVECTOR for the given packet
835
   */
834
   */
836
  virtual WifiTxVector GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
835
  virtual WifiTxVector GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const;
836
837
private:
837
private:
838
  /**
838
  /**
839
   * Cancel all scheduled events. Called before beginning a transmission
839
   * Cancel all scheduled events. Called before beginning a transmission

Return to bug 2222