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

(-)a/src/traffic-control/model/codel-queue-disc.cc (-36 / +27 lines)
 Lines 309-321   CoDelQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item) Link Here 
309
}
309
}
310
310
311
bool
311
bool
312
CoDelQueueDisc::OkToDrop (Ptr<Packet> p, uint32_t now)
312
CoDelQueueDisc::OkToDrop (Ptr<QueueDiscItem> item, uint32_t now)
313
{
313
{
314
  NS_LOG_FUNCTION (this);
314
  NS_LOG_FUNCTION (this);
315
  CoDelTimestampTag tag;
315
  CoDelTimestampTag tag;
316
  bool okToDrop;
316
  bool okToDrop;
317
317
318
  bool found = p->RemovePacketTag (tag);
318
  if (!item)
319
    {
320
      m_firstAboveTime = 0;
321
      return false;
322
    }
323
324
  bool found = item->GetPacket ()->RemovePacketTag (tag);
319
  NS_ASSERT_MSG (found, "found a packet without an input timestamp tag");
325
  NS_ASSERT_MSG (found, "found a packet without an input timestamp tag");
320
  NS_UNUSED (found);    //silence compiler warning
326
  NS_UNUSED (found);    //silence compiler warning
321
  Time delta = Simulator::Now () - tag.GetTxTime ();
327
  Time delta = Simulator::Now () - tag.GetTxTime ();
 Lines 355-378   CoDelQueueDisc::DoDequeue (void) Link Here 
355
{
361
{
356
  NS_LOG_FUNCTION (this);
362
  NS_LOG_FUNCTION (this);
357
363
358
  if (GetInternalQueue (0)->IsEmpty ())
364
  Ptr<QueueDiscItem> item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
365
  if (!item)
359
    {
366
    {
360
      // Leave dropping state when queue is empty
367
      // Leave dropping state when queue is empty
361
      m_dropping = false;
368
      m_dropping = false;
362
      m_firstAboveTime = 0;
363
      NS_LOG_LOGIC ("Queue empty");
369
      NS_LOG_LOGIC ("Queue empty");
364
      return 0;
370
      return 0;
365
    }
371
    }
366
  uint32_t now = CoDelGetTime ();
372
  uint32_t now = CoDelGetTime ();
367
  Ptr<QueueDiscItem> item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
368
  Ptr<Packet> p = item->GetPacket ();
369
373
370
  NS_LOG_LOGIC ("Popped " << item);
374
  NS_LOG_LOGIC ("Popped " << item);
371
  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
375
  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
372
  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
376
  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
373
377
374
  // Determine if p should be dropped
378
  // Determine if item should be dropped
375
  bool okToDrop = OkToDrop (p, now);
379
  bool okToDrop = OkToDrop (item, now);
376
380
377
  if (m_dropping)
381
  if (m_dropping)
378
    { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
382
    { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
 Lines 396-422   CoDelQueueDisc::DoDequeue (void) Link Here 
396
              // A large amount of packets in queue might result in drop
400
              // A large amount of packets in queue might result in drop
397
              // rates so high that the next drop should happen now,
401
              // rates so high that the next drop should happen now,
398
              // hence the while loop.
402
              // hence the while loop.
399
              NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << p);
403
              NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << item);
400
              Drop (item);
404
              Drop (item);
401
405
402
              ++m_dropCount;
406
              ++m_dropCount;
403
              ++m_count;
407
              ++m_count;
404
              NewtonStep ();
408
              NewtonStep ();
405
              if (GetInternalQueue (0)->IsEmpty ())
406
                {
407
                  m_dropping = false;
408
                  NS_LOG_LOGIC ("Queue empty");
409
                  ++m_states;
410
                  return 0;
411
                }
412
              item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
409
              item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
413
              p = item ->GetPacket ();
414
410
415
              NS_LOG_LOGIC ("Popped " << item);
411
              if (item)
416
              NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
412
                {
417
              NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
413
                  NS_LOG_LOGIC ("Popped " << item);
414
                  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
415
                  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
416
                }
418
417
419
              if (!OkToDrop (p, now))
418
              if (!OkToDrop (item, now))
420
                {
419
                {
421
                  /* leave dropping state */
420
                  /* leave dropping state */
422
                  NS_LOG_LOGIC ("Leaving dropping state");
421
                  NS_LOG_LOGIC ("Leaving dropping state");
 Lines 440-468   CoDelQueueDisc::DoDequeue (void) Link Here 
440
      if (okToDrop)
439
      if (okToDrop)
441
        {
440
        {
442
          // Drop the first packet and enter dropping state unless the queue is empty
441
          // Drop the first packet and enter dropping state unless the queue is empty
443
          NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << p << " and entering the dropping state");
442
          NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << item << " and entering the dropping state");
444
          ++m_dropCount;
443
          ++m_dropCount;
445
          Drop (item);
444
          Drop (item);
446
445
447
          if (GetInternalQueue (0)->IsEmpty ())
446
          item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
448
            {
449
              m_dropping = false;
450
              okToDrop = false;
451
              NS_LOG_LOGIC ("Queue empty");
452
              ++m_states;
453
            }
454
          else
455
            {
456
              item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
457
              p = item->GetPacket ();
458
447
448
          if (item)
449
            {
459
              NS_LOG_LOGIC ("Popped " << item);
450
              NS_LOG_LOGIC ("Popped " << item);
460
              NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
451
              NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
461
              NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
452
              NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
462
463
              okToDrop = OkToDrop (p, now);
464
              m_dropping = true;
465
            }
453
            }
454
455
          OkToDrop (item, now);
456
          m_dropping = true;
466
          ++m_state3;
457
          ++m_state3;
467
          /*
458
          /*
468
           * if min went above target close to when we last went below it
459
           * if min went above target close to when we last went below it
(-)a/src/traffic-control/model/codel-queue-disc.h (-2 / +2 lines)
 Lines 182-192   private: Link Here 
182
   * \brief Determine whether a packet is OK to be dropped. The packet
182
   * \brief Determine whether a packet is OK to be dropped. The packet
183
   * may not be actually dropped (depending on the drop state)
183
   * may not be actually dropped (depending on the drop state)
184
   *
184
   *
185
   * \param p The packet that is considered
185
   * \param item The packet that is considered
186
   * \param now The current time represented as 32-bit unsigned integer (us)
186
   * \param now The current time represented as 32-bit unsigned integer (us)
187
   * \returns True if it is OK to drop the packet (sojourn time above target for at least interval)
187
   * \returns True if it is OK to drop the packet (sojourn time above target for at least interval)
188
   */
188
   */
189
  bool OkToDrop (Ptr<Packet> p, uint32_t now);
189
  bool OkToDrop (Ptr<QueueDiscItem> item, uint32_t now);
190
190
191
  /**
191
  /**
192
   * Check if CoDel time a is successive to b
192
   * Check if CoDel time a is successive to b

Return to bug 2537