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

(-)a/src/traffic-control/doc/queue-discs.rst (-1 / +14 lines)
 Lines 93-102   queue disc. A subclass is required to implement the following methods: Link Here 
93
93
94
* ``bool DoEnqueue (Ptr<QueueDiscItem> item)``:  Enqueue a packet
94
* ``bool DoEnqueue (Ptr<QueueDiscItem> item)``:  Enqueue a packet
95
* ``Ptr<QueueDiscItem> DoDequeue (void)``:  Dequeue a packet
95
* ``Ptr<QueueDiscItem> DoDequeue (void)``:  Dequeue a packet
96
* ``Ptr<const QueueDiscItem> DoPeek (void) const``: Peek a packet
97
* ``bool CheckConfig (void) const``: Check if the configuration is correct
96
* ``bool CheckConfig (void) const``: Check if the configuration is correct
98
* ``void InitializeParams (void)``: Initialize queue disc parameters
97
* ``void InitializeParams (void)``: Initialize queue disc parameters
99
98
99
and may override the default implementation of the following method:
100
101
* ``Ptr<const QueueDiscItem> DoPeek (void) const``: Peek the next packet to extract
102
103
The default implementation of the ``DoPeek`` method is based on the qdisc_peek_dequeued
104
function of the Linux kernel, which dequeues a packet and retains it in the
105
queue disc as a requeued packet. This approach is recommended
106
especially for queue discs for which it is not obvious what is the next
107
packet that will be dequeued (e.g., queue discs having multiple internal
108
queues or child queue discs or queue discs that drop packets after dequeue).
109
Consequently, if a queue disc queries a child queue disc with the ``Peek`` method,
110
then it has to use the ``DequeuePeeked`` method instead of the ``Dequeue`` method
111
to actually dequeue the peeked packet from the child queue disc.
112
100
The C++ base class QueueDisc implements:
113
The C++ base class QueueDisc implements:
101
114
102
* methods to add/get a single queue, class or filter and methods to get the number \
115
* methods to add/get a single queue, class or filter and methods to get the number \
(-)a/src/traffic-control/model/codel-queue-disc.cc (-19 lines)
 Lines 362-386   CoDelQueueDisc::GetDropNext (void) Link Here 
362
  return m_dropNext;
362
  return m_dropNext;
363
}
363
}
364
364
365
Ptr<const QueueDiscItem>
366
CoDelQueueDisc::DoPeek (void)
367
{
368
  NS_LOG_FUNCTION (this);
369
370
  Ptr<const QueueDiscItem> item = PeekDequeued ();
371
372
  if (!item)
373
    {
374
      NS_LOG_LOGIC ("Queue empty");
375
      return 0;
376
    }
377
378
  NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ());
379
  NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ());
380
381
  return item;
382
}
383
384
bool
365
bool
385
CoDelQueueDisc::CoDelTimeAfter (uint32_t a, uint32_t b)
366
CoDelQueueDisc::CoDelTimeAfter (uint32_t a, uint32_t b)
386
{
367
{
(-)a/src/traffic-control/model/codel-queue-disc.h (-1 lines)
 Lines 124-130   private: Link Here 
124
   */
124
   */
125
  virtual Ptr<QueueDiscItem> DoDequeue (void);
125
  virtual Ptr<QueueDiscItem> DoDequeue (void);
126
126
127
  virtual Ptr<const QueueDiscItem> DoPeek (void);
128
  virtual bool CheckConfig (void);
127
  virtual bool CheckConfig (void);
129
128
130
  /**
129
  /**
(-)a/src/traffic-control/model/fq-codel-queue-disc.cc (-8 lines)
 Lines 302-315   FqCoDelQueueDisc::DoDequeue (void) Link Here 
302
  return item;
302
  return item;
303
}
303
}
304
304
305
Ptr<const QueueDiscItem>
306
FqCoDelQueueDisc::DoPeek (void)
307
{
308
  NS_LOG_FUNCTION (this);
309
310
  return PeekDequeued ();
311
}
312
313
bool
305
bool
314
FqCoDelQueueDisc::CheckConfig (void)
306
FqCoDelQueueDisc::CheckConfig (void)
315
{
307
{
(-)a/src/traffic-control/model/fq-codel-queue-disc.h (-1 lines)
 Lines 133-139   public: Link Here 
133
private:
133
private:
134
  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
134
  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
135
  virtual Ptr<QueueDiscItem> DoDequeue (void);
135
  virtual Ptr<QueueDiscItem> DoDequeue (void);
136
  virtual Ptr<const QueueDiscItem> DoPeek (void);
137
  virtual bool CheckConfig (void);
136
  virtual bool CheckConfig (void);
138
  virtual void InitializeParams (void);
137
  virtual void InitializeParams (void);
139
138
(-)a/src/traffic-control/model/pie-queue-disc.cc (-19 lines)
 Lines 406-430   PieQueueDisc::DoDequeue () Link Here 
406
  return item;
406
  return item;
407
}
407
}
408
408
409
Ptr<const QueueDiscItem>
410
PieQueueDisc::DoPeek ()
411
{
412
  NS_LOG_FUNCTION (this);
413
414
  Ptr<const QueueDiscItem> item = PeekDequeued ();
415
416
  if (!item)
417
    {
418
      NS_LOG_LOGIC ("Queue empty");
419
      return 0;
420
    }
421
422
  NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ());
423
  NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ());
424
425
  return item;
426
}
427
428
bool
409
bool
429
PieQueueDisc::CheckConfig (void)
410
PieQueueDisc::CheckConfig (void)
430
{
411
{
(-)a/src/traffic-control/model/pie-queue-disc.h (-1 lines)
 Lines 107-113   protected: Link Here 
107
private:
107
private:
108
  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
108
  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
109
  virtual Ptr<QueueDiscItem> DoDequeue (void);
109
  virtual Ptr<QueueDiscItem> DoDequeue (void);
110
  virtual Ptr<const QueueDiscItem> DoPeek (void);
111
  virtual bool CheckConfig (void);
110
  virtual bool CheckConfig (void);
112
111
113
  /**
112
  /**
(-)a/src/traffic-control/model/queue-disc.cc (-1 / +1 lines)
 Lines 877-883   QueueDisc::Peek (void) Link Here 
877
}
877
}
878
878
879
Ptr<const QueueDiscItem>
879
Ptr<const QueueDiscItem>
880
QueueDisc::PeekDequeued (void)
880
QueueDisc::DoPeek (void)
881
{
881
{
882
  NS_LOG_FUNCTION (this);
882
  NS_LOG_FUNCTION (this);
883
883
(-)a/src/traffic-control/model/queue-disc.h (-20 / +20 lines)
 Lines 373-379   public: Link Here 
373
  /**
373
  /**
374
   * Request the queue discipline to extract a packet. This function only updates
374
   * Request the queue discipline to extract a packet. This function only updates
375
   * the statistics and calls the (private) DoDequeue function, which must be
375
   * the statistics and calls the (private) DoDequeue function, which must be
376
   * implemented by derived classes.
376
   * implemented by derived classes. Use DequeuePeeked instead of this method if
377
   * the queue disc has been previously queried with Peek.
377
   * \return 0 if the operation was not successful; the item otherwise.
378
   * \return 0 if the operation was not successful; the item otherwise.
378
   */
379
   */
379
  Ptr<QueueDiscItem> Dequeue (void);
380
  Ptr<QueueDiscItem> Dequeue (void);
 Lines 381-394   public: Link Here 
381
  /**
382
  /**
382
   * Get a copy of the next packet the queue discipline will extract, without
383
   * Get a copy of the next packet the queue discipline will extract, without
383
   * actually extracting the packet. This function only calls the (private)
384
   * actually extracting the packet. This function only calls the (private)
384
   * DoPeek function, which must be implemented by derived classes.
385
   * DoPeek function.
385
   * \return 0 if the operation was not successful; the item otherwise.
386
   * \return 0 if the operation was not successful; the item otherwise.
386
   */
387
   */
387
  Ptr<const QueueDiscItem> Peek (void);
388
  Ptr<const QueueDiscItem> Peek (void);
388
389
389
  /**
390
  /**
390
   * Extract from the queue disc the packet that has been dequeued by calling
391
   * Extract from the queue disc the packet that has been dequeued by calling
391
   * PeekDequeued.
392
   * Peek, if any, or dequeue a packet, otherwise. Use this method instead of
393
   * Dequeue if the queue disc has been previously queried with Peek.
392
   *
394
   *
393
   * \return 0 if the operation was not successful; the item otherwise.
395
   * \return 0 if the operation was not successful; the item otherwise.
394
   */
396
   */
 Lines 543-563   protected: Link Here 
543
   */
545
   */
544
  bool Mark (Ptr<QueueDiscItem> item, const char* reason);
546
  bool Mark (Ptr<QueueDiscItem> item, const char* reason);
545
547
546
  /**
547
   * Dequeue a packet and retain it in the queue disc as a requeued packet.
548
   * The packet is not traced as requeued, nor is the total count of requeued
549
   * packets increased. The dequeued packet is not counted in the backlog of
550
   * the queue disc and is actually extracted from the queue disc by calling
551
   * DequeuePeeked. Queue discs can point their DoPeek method to this one. This
552
   * is recommended especially for queue discs for which it is not obvious what
553
   * is the next packet that will be dequeued (e.g., queue discs having multiple
554
   * internal queues or child queue discs or queue discs that drop packets
555
   * after dequeue).
556
   *
557
   * \return 0 if the operation was not successful; the item otherwise.
558
   */
559
  Ptr<const QueueDiscItem> PeekDequeued (void);
560
561
private:
548
private:
562
  /**
549
  /**
563
   * \brief Copy constructor
550
   * \brief Copy constructor
 Lines 590-599   private: Link Here 
590
  virtual Ptr<QueueDiscItem> DoDequeue (void) = 0;
577
  virtual Ptr<QueueDiscItem> DoDequeue (void) = 0;
591
578
592
  /**
579
  /**
593
   * This function returns a copy of the next packet the queue disc will extract.
580
   * \brief Return a copy of the next packet the queue disc will extract.
581
   *
582
   * The implementation of this method is based on the qdisc_peek_dequeued
583
   * function of the Linux kernel, which dequeues a packet and retains it in the
584
   * queue disc as a requeued packet. The packet is not traced as requeued, nor
585
   * is the total count of requeued packets increased. The dequeued packet is
586
   * not counted in the backlog of the queue disc and is actually extracted from
587
   * the queue disc by calling DequeuePeeked. This approach is recommended
588
   * especially for queue discs for which it is not obvious what is the next
589
   * packet that will be dequeued (e.g., queue discs having multiple internal
590
   * queues or child queue discs or queue discs that drop packets after dequeue).
591
   * Subclasses can however provide their own implementation of this method that
592
   * overrides the default one.
593
   *
594
   * \return 0 if the operation was not successful; the packet otherwise.
594
   * \return 0 if the operation was not successful; the packet otherwise.
595
   */
595
   */
596
  virtual Ptr<const QueueDiscItem> DoPeek (void) = 0;
596
  virtual Ptr<const QueueDiscItem> DoPeek (void);
597
597
598
  /**
598
  /**
599
   * Check whether the current configuration is correct. Default objects (such
599
   * Check whether the current configuration is correct. Default objects (such
(-)a/src/traffic-control/model/tbf-queue-disc.cc (-18 lines)
 Lines 193-216   TbfQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item) Link Here 
193
  return retval;
193
  return retval;
194
}
194
}
195
195
196
Ptr<const QueueDiscItem>
197
TbfQueueDisc::DoPeek ()
198
{
199
  NS_LOG_FUNCTION (this);
200
201
  Ptr<const QueueDiscItem> item = PeekDequeued ();
202
203
  if (!item)
204
    {
205
      NS_LOG_LOGIC ("No packet returned");
206
      return 0;
207
    }
208
209
  NS_LOG_LOGIC ("Current queue size: " << GetNPackets () << " packets, " << GetNBytes () << " bytes");
210
211
  return item;
212
}
213
214
Ptr<QueueDiscItem>
196
Ptr<QueueDiscItem>
215
TbfQueueDisc::DoDequeue (void)
197
TbfQueueDisc::DoDequeue (void)
216
{
198
{
(-)a/src/traffic-control/model/tbf-queue-disc.h (-1 lines)
 Lines 149-155   private: Link Here 
149
149
150
  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
150
  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
151
  virtual Ptr<QueueDiscItem> DoDequeue (void);
151
  virtual Ptr<QueueDiscItem> DoDequeue (void);
152
  virtual Ptr<const QueueDiscItem> DoPeek (void);
153
  virtual bool CheckConfig (void);
152
  virtual bool CheckConfig (void);
154
  virtual void InitializeParams (void);
153
  virtual void InitializeParams (void);
155
154

Return to bug 2924