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

(-)a/src/node/drop-tail-queue.cc (-13 / +26 lines)
 Lines 78-102    Link Here 
78
  NS_LOG_FUNCTION_NOARGS ();
78
  NS_LOG_FUNCTION_NOARGS ();
79
  return m_mode;
79
  return m_mode;
80
}
80
}
81
82
bool 
83
DropTailQueue::WillDrop (Ptr<Packet> p) const
84
{
85
  NS_LOG_FUNCTION (p);
86
87
  if (m_mode == PACKETS && (m_packets.size () >= m_maxPackets))
88
  {
89
    NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
90
    return true;
91
  }
92
93
  if (m_mode == BYTES && (m_bytesInQueue + p->GetSize () >= m_maxBytes))
94
  {
95
    NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
96
    return true;
97
  }
98
99
  // the packet is not going to be dropped
100
  return false;
101
}
81
  
102
  
82
bool 
103
bool 
83
DropTailQueue::DoEnqueue (Ptr<Packet> p)
104
DropTailQueue::DoEnqueue (Ptr<Packet> p)
84
{
105
{
85
  NS_LOG_FUNCTION (this << p);
106
  NS_LOG_FUNCTION (this << p);
86
107
87
  if (m_mode == PACKETS && (m_packets.size () >= m_maxPackets))
108
  if (WillDrop (p)) 
88
    {
109
  {
89
      NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
110
    Drop (p);
90
      Drop (p);
111
    return false;
91
      return false;
112
  }
92
    }
93
94
  if (m_mode == BYTES && (m_bytesInQueue + p->GetSize () >= m_maxBytes))
95
    {
96
      NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
97
      Drop (p);
98
      return false;
99
    }
100
113
101
  m_bytesInQueue += p->GetSize ();
114
  m_bytesInQueue += p->GetSize ();
102
  m_packets.push(p);
115
  m_packets.push(p);
(-)a/src/node/drop-tail-queue.h (+4 lines)
 Lines 68-73    Link Here 
68
   * \returns The encapsulation mode of this device.
68
   * \returns The encapsulation mode of this device.
69
   */
69
   */
70
  DropTailQueue::Mode  GetMode (void);
70
  DropTailQueue::Mode  GetMode (void);
71
  /**
72
   * \see Queue::WillDrop ()
73
   */
74
  bool WillDrop (Ptr<Packet> p) const;
71
75
72
private:
76
private:
73
  virtual bool DoEnqueue (Ptr<Packet> p);
77
  virtual bool DoEnqueue (Ptr<Packet> p);
(-)a/src/node/queue.h (+6 lines)
 Lines 60-65    Link Here 
60
   */
60
   */
61
  bool Enqueue (Ptr<Packet> p);
61
  bool Enqueue (Ptr<Packet> p);
62
  /**
62
  /**
63
   * \brief Check if the packet is going to be dropped
64
   * \param p The packet that is going to enqueue into a net device
65
   * \return True of the packet is decided to be dropped, false otherwise
66
   */
67
  virtual bool WillDrop (Ptr<Packet> p) const = 0;
68
  /**
63
   * Remove a packet from the front of the Queue
69
   * Remove a packet from the front of the Queue
64
   * \return 0 if the operation was not successful; the packet otherwise.
70
   * \return 0 if the operation was not successful; the packet otherwise.
65
   */
71
   */

Return to bug 635