|
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); |