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

(-)a/src/wifi/model/dca-txop.cc (-4 / +4 lines)
 Lines 240-246   DcaTxop::RestartAccessIfNeeded (void) Link Here 
240
{
240
{
241
  NS_LOG_FUNCTION (this);
241
  NS_LOG_FUNCTION (this);
242
  if ((m_currentPacket != 0
242
  if ((m_currentPacket != 0
243
       || m_queue->HasPackets ())
243
       || !m_queue->IsEmpty ())
244
      && !m_dcf->IsAccessRequested ())
244
      && !m_dcf->IsAccessRequested ())
245
    {
245
    {
246
      m_manager->RequestAccess (m_dcf);
246
      m_manager->RequestAccess (m_dcf);
 Lines 252-258   DcaTxop::StartAccessIfNeeded (void) Link Here 
252
{
252
{
253
  NS_LOG_FUNCTION (this);
253
  NS_LOG_FUNCTION (this);
254
  if (m_currentPacket == 0
254
  if (m_currentPacket == 0
255
      && m_queue->HasPackets ()
255
      && !m_queue->IsEmpty ()
256
      && !m_dcf->IsAccessRequested ())
256
      && !m_dcf->IsAccessRequested ())
257
    {
257
    {
258
      m_manager->RequestAccess (m_dcf);
258
      m_manager->RequestAccess (m_dcf);
 Lines 360-366   bool Link Here 
360
DcaTxop::NeedsAccess (void) const
360
DcaTxop::NeedsAccess (void) const
361
{
361
{
362
  NS_LOG_FUNCTION (this);
362
  NS_LOG_FUNCTION (this);
363
  return m_queue->HasPackets () || m_currentPacket != 0;
363
  return !m_queue->IsEmpty () || m_currentPacket != 0;
364
}
364
}
365
365
366
void
366
void
 Lines 369-375   DcaTxop::NotifyAccessGranted (void) Link Here 
369
  NS_LOG_FUNCTION (this);
369
  NS_LOG_FUNCTION (this);
370
  if (m_currentPacket == 0)
370
  if (m_currentPacket == 0)
371
    {
371
    {
372
      if (!m_queue->HasPackets ())
372
      if (m_queue->IsEmpty ())
373
        {
373
        {
374
          NS_LOG_DEBUG ("queue empty");
374
          NS_LOG_DEBUG ("queue empty");
375
          return;
375
          return;
(-)a/src/wifi/model/edca-txop-n.cc (-4 / +4 lines)
 Lines 153-159   bool Link Here 
153
EdcaTxopN::NeedsAccess (void) const
153
EdcaTxopN::NeedsAccess (void) const
154
{
154
{
155
  NS_LOG_FUNCTION (this);
155
  NS_LOG_FUNCTION (this);
156
  return m_queue->HasPackets () || m_currentPacket != 0 || m_baManager->HasPackets ();
156
  return !m_queue->IsEmpty () || m_currentPacket != 0 || m_baManager->HasPackets ();
157
}
157
}
158
158
159
uint16_t EdcaTxopN::GetNextSequenceNumberFor (WifiMacHeader *hdr)
159
uint16_t EdcaTxopN::GetNextSequenceNumberFor (WifiMacHeader *hdr)
 Lines 186-192   EdcaTxopN::NotifyAccessGranted (void) Link Here 
186
  m_startTxop = Simulator::Now ();
186
  m_startTxop = Simulator::Now ();
187
  if (m_currentPacket == 0)
187
  if (m_currentPacket == 0)
188
    {
188
    {
189
      if (!m_queue->HasPackets () && !m_baManager->HasPackets ())
189
      if (m_queue->IsEmpty () && !m_baManager->HasPackets ())
190
        {
190
        {
191
          NS_LOG_DEBUG ("queue is empty");
191
          NS_LOG_DEBUG ("queue is empty");
192
          return;
192
          return;
 Lines 724-730   EdcaTxopN::RestartAccessIfNeeded (void) Link Here 
724
{
724
{
725
  NS_LOG_FUNCTION (this);
725
  NS_LOG_FUNCTION (this);
726
  if ((m_currentPacket != 0
726
  if ((m_currentPacket != 0
727
       || m_queue->HasPackets () || m_baManager->HasPackets ())
727
       || !m_queue->IsEmpty () || m_baManager->HasPackets ())
728
      && !m_dcf->IsAccessRequested ())
728
      && !m_dcf->IsAccessRequested ())
729
    {
729
    {
730
      Ptr<const Packet> packet;
730
      Ptr<const Packet> packet;
 Lines 765-771   EdcaTxopN::StartAccessIfNeeded (void) Link Here 
765
{
765
{
766
  //NS_LOG_FUNCTION (this);
766
  //NS_LOG_FUNCTION (this);
767
  if (m_currentPacket == 0
767
  if (m_currentPacket == 0
768
      && (m_queue->HasPackets () || m_baManager->HasPackets ())
768
      && (!m_queue->IsEmpty () || m_baManager->HasPackets ())
769
      && !m_dcf->IsAccessRequested ())
769
      && !m_dcf->IsAccessRequested ())
770
    {
770
    {
771
      Ptr<const Packet> packet;
771
      Ptr<const Packet> packet;
(-)a/src/wifi/model/wifi-mac-queue.cc (-5 / +39 lines)
 Lines 403-409   WifiMacQueue::GetNPacketsByTidAndAddress (uint8_t tid, WifiMacHeader::AddressTyp Link Here 
403
403
404
template<>
404
template<>
405
bool
405
bool
406
WifiMacQueue::HasPackets (void)
406
WifiMacQueue::IsEmpty (void)
407
{
407
{
408
  NS_LOG_FUNCTION (this);
408
  NS_LOG_FUNCTION (this);
409
409
 Lines 411-422   WifiMacQueue::HasPackets (void) Link Here 
411
    {
411
    {
412
      if (!TtlExceeded (it))
412
      if (!TtlExceeded (it))
413
        {
413
        {
414
          NS_LOG_DEBUG ("returns true");
414
          NS_LOG_DEBUG ("returns false");
415
          return true;
415
          return false;
416
        }
416
        }
417
    }
417
    }
418
  NS_LOG_DEBUG ("returns false");
418
  NS_LOG_DEBUG ("returns true");
419
  return false;
419
  return true;
420
}
421
422
template<>
423
uint32_t
424
WifiMacQueue::GetNPackets (void)
425
{
426
  NS_LOG_FUNCTION (this);
427
428
  // remove packets that stayed in the queue for too long
429
  for (auto it = Head (); it != Tail (); )
430
    {
431
      if (!TtlExceeded (it))
432
        {
433
          it++;
434
        }
435
    }
436
  return QueueBase::GetNPackets ();
437
}
438
439
template<>
440
uint32_t
441
WifiMacQueue::GetNBytes (void)
442
{
443
  NS_LOG_FUNCTION (this);
444
445
  // remove packets that stayed in the queue for too long
446
  for (auto it = Head (); it != Tail (); )
447
    {
448
      if (!TtlExceeded (it))
449
        {
450
          it++;
451
        }
452
    }
453
  return QueueBase::GetNBytes ();
420
}
454
}
421
455
422
NS_OBJECT_TEMPLATE_CLASS_DEFINE (WifiQueue,WifiMacQueueItem);
456
NS_OBJECT_TEMPLATE_CLASS_DEFINE (WifiQueue,WifiMacQueueItem);
(-)a/src/wifi/model/wifi-mac-queue.h (-4 / +23 lines)
 Lines 284-296   public: Link Here 
284
  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
284
  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
285
                                       WifiMacHeader::AddressType type,
285
                                       WifiMacHeader::AddressType type,
286
                                       Mac48Address addr);
286
                                       Mac48Address addr);
287
288
  /**
289
   * \return true if the queue is empty; false otherwise
290
   *
291
   * Overrides the IsEmpty method provided by QueueBase
292
   */
293
  bool IsEmpty (void);
294
287
  /**
295
  /**
288
   * This method must be used (instead of the IsEmpty method of the base class)
296
   * \return The number of packets currently stored in the Queue
289
   * to check whether there are packets with unexpired time to live in the queue
290
   *
297
   *
291
   * \return true if there are packets with unexpired time to live
298
   * Overrides the GetNPackets method provided by QueueBase
292
   */
299
   */
293
  bool HasPackets (void);
300
  uint32_t GetNPackets (void);
301
302
  /**
303
   * \return The number of bytes currently occupied by the packets in the Queue
304
   *
305
   * Overrides the GetNBytes method provided by QueueBase
306
   */
307
  uint32_t GetNBytes (void);
294
308
295
private:
309
private:
296
  /**
310
  /**
 Lines 307-312   private: Link Here 
307
  DropPolicy m_dropPolicy;                  //!< Drop behavior of queue
321
  DropPolicy m_dropPolicy;                  //!< Drop behavior of queue
308
};
322
};
309
323
324
/// Forward declare overridden methods to avoid specializing after instantiation
325
template<> bool WifiQueue<WifiMacQueueItem>::IsEmpty (void);
326
template<> uint32_t WifiQueue<WifiMacQueueItem>::GetNPackets (void);
327
template<> uint32_t WifiQueue<WifiMacQueueItem>::GetNBytes (void);
328
310
/// Declare WifiMacQueue as a specialization of template class WifiQueue
329
/// Declare WifiMacQueue as a specialization of template class WifiQueue
311
typedef WifiQueue<WifiMacQueueItem> WifiMacQueue;
330
typedef WifiQueue<WifiMacQueueItem> WifiMacQueue;
312
331

Return to bug 2744