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

(-)a/src/traffic-control/model/queue-disc.cc (+36 lines)
 Lines 118-123   void Link Here 
118
QueueDiscClass::SetQueueDisc (Ptr<QueueDisc> qd)
118
QueueDiscClass::SetQueueDisc (Ptr<QueueDisc> qd)
119
{
119
{
120
  NS_LOG_FUNCTION (this);
120
  NS_LOG_FUNCTION (this);
121
  NS_ABORT_MSG_IF (qd, "Cannot set the queue disc on a class already having an attached queue disc");
121
  m_queueDisc = qd;
122
  m_queueDisc = qd;
122
}
123
}
123
124
 Lines 353-358   QueueDisc::AddQueueDiscClass (Ptr<QueueDiscClass> qdClass) Link Here 
353
{
354
{
354
  NS_LOG_FUNCTION (this);
355
  NS_LOG_FUNCTION (this);
355
  NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0, "Cannot add a class with no attached queue disc");
356
  NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0, "Cannot add a class with no attached queue disc");
357
  // the child queue disc cannot be one with wake mode equal to WAKE_CHILD because
358
  // such queue discs do not implement the enqueue/dequeue methods
359
  NS_ABORT_MSG_IF (qdClass->GetQueueDisc ()->GetWakeMode () == WAKE_CHILD,
360
                   "A queue disc with WAKE_CHILD as wake mode can only be a root queue disc");
361
  // set the parent drop callback on the child queue disc, so that it can notify
362
  // packet drops to the parent queue disc
363
  qdClass->GetQueueDisc ()->SetParentDropCallback (MakeCallback (&QueueDisc::Drop, this));
356
  m_classes.push_back (qdClass);
364
  m_classes.push_back (qdClass);
357
}
365
}
358
366
 Lines 390-398   QueueDisc::GetWakeMode (void) Link Here 
390
}
398
}
391
399
392
void
400
void
401
QueueDisc::SetParentDropCallback (ParentDropCallback cb)
402
{
403
  m_parentDropCallback = cb;
404
}
405
406
void
393
QueueDisc::Drop (Ptr<QueueDiscItem> item)
407
QueueDisc::Drop (Ptr<QueueDiscItem> item)
394
{
408
{
395
  NS_LOG_FUNCTION (this << item);
409
  NS_LOG_FUNCTION (this << item);
410
411
  // if the wake mode of this queue disc is WAKE_CHILD, packets are directly
412
  // enqueued/dequeued from the child queue discs, thus this queue disc does not
413
  // keep valid packets/bytes counters and no actions need to be performed.
414
  if (this->GetWakeMode () == WAKE_CHILD)
415
    {
416
      return;
417
    }
418
396
  NS_ASSERT_MSG (m_nPackets >= 1u, "No packet in the queue disc, cannot drop");
419
  NS_ASSERT_MSG (m_nPackets >= 1u, "No packet in the queue disc, cannot drop");
397
  NS_ASSERT_MSG (m_nBytes >= item->GetPacketSize (), "The size of the packet that"
420
  NS_ASSERT_MSG (m_nBytes >= item->GetPacketSize (), "The size of the packet that"
398
                 << " is reported to be dropped is greater than the amount of bytes"
421
                 << " is reported to be dropped is greater than the amount of bytes"
 Lines 405-410   QueueDisc::Drop (Ptr<QueueDiscItem> item) Link Here 
405
428
406
  NS_LOG_LOGIC ("m_traceDrop (p)");
429
  NS_LOG_LOGIC ("m_traceDrop (p)");
407
  m_traceDrop (item);
430
  m_traceDrop (item);
431
432
  NotifyParentDrop (item);
433
}
434
435
void
436
QueueDisc::NotifyParentDrop (Ptr<QueueDiscItem> item)
437
{
438
  NS_LOG_FUNCTION (this << item);
439
  // the parent drop callback is clearly null on root queue discs
440
  if (!m_parentDropCallback.IsNull ())
441
    {
442
      m_parentDropCallback (item);
443
    }
408
}
444
}
409
445
410
bool
446
bool
(-)a/src/traffic-control/model/queue-disc.h (+18 lines)
 Lines 421-426   public: Link Here 
421
   */
421
   */
422
  WakeMode GetWakeMode (void);
422
  WakeMode GetWakeMode (void);
423
423
424
  /// Callback invoked by a child queue disc to notify the parent of a packet drop
425
  typedef Callback<void, Ptr<QueueDiscItem> > ParentDropCallback;
426
427
  /**
428
   * \brief Set the parent drop callback
429
   * \param cb the callback to set
430
   *
431
   * Called when a queue disc class is added to a queue disc in order to set a
432
   * callback to the Drop method of the parent queue disc.
433
   */
434
  virtual void SetParentDropCallback (ParentDropCallback cb);
435
424
protected:
436
protected:
425
  /**
437
  /**
426
   * \brief Dispose of the object
438
   * \brief Dispose of the object
 Lines 440-445   protected: Link Here 
440
  void Drop (Ptr<QueueDiscItem> item);
452
  void Drop (Ptr<QueueDiscItem> item);
441
453
442
private:
454
private:
455
  /**
456
   *  \brief Notify the parent queue disc of a packet drop
457
   *  \param item item that was dropped
458
   */
459
  void NotifyParentDrop (Ptr<QueueDiscItem> item);
443
460
444
  /**
461
  /**
445
   * This function actually enqueues a packet into the queue disc.
462
   * This function actually enqueues a packet into the queue disc.
 Lines 533-538   private: Link Here 
533
  Ptr<NetDeviceQueueInterface> m_devQueueIface;   //!< NetDevice queue interface
550
  Ptr<NetDeviceQueueInterface> m_devQueueIface;   //!< NetDevice queue interface
534
  bool m_running;                   //!< The queue disc is performing multiple dequeue operations
551
  bool m_running;                   //!< The queue disc is performing multiple dequeue operations
535
  Ptr<QueueDiscItem> m_requeued;    //!< The last packet that failed to be transmitted
552
  Ptr<QueueDiscItem> m_requeued;    //!< The last packet that failed to be transmitted
553
  ParentDropCallback m_parentDropCallback;   //!< Parent drop callback
536
554
537
  /// Traced callback: fired when a packet is enqueued
555
  /// Traced callback: fired when a packet is enqueued
538
  TracedCallback<Ptr<const QueueItem> > m_traceEnqueue;
556
  TracedCallback<Ptr<const QueueItem> > m_traceEnqueue;

Return to bug 2384