Lines 322-328
RedQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item)
|
Link Here
|
---|
|
322 |
// simulate number of packets arrival during idle period |
322 |
// simulate number of packets arrival during idle period |
323 |
uint32_t m = 0; |
323 |
uint32_t m = 0; |
324 |
|
324 |
|
325 |
if (m_idle == 1) |
325 |
if (nQueued == 0) |
326 |
{ |
326 |
{ |
327 |
NS_LOG_DEBUG ("RED Queue Disc is idle."); |
327 |
NS_LOG_DEBUG ("RED Queue Disc is idle."); |
328 |
Time now = Simulator::Now (); |
328 |
Time now = Simulator::Now (); |
Lines 337-343
RedQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item)
|
Link Here
|
---|
|
337 |
m = uint32_t (m_ptc * (now - m_idleTime).GetSeconds ()); |
337 |
m = uint32_t (m_ptc * (now - m_idleTime).GetSeconds ()); |
338 |
} |
338 |
} |
339 |
|
339 |
|
340 |
m_idle = 0; |
340 |
m_idleTime = Time::Min (); // not idle anymore |
341 |
} |
341 |
} |
342 |
|
342 |
|
343 |
m_qAvg = Estimator (nQueued, m + 1, m_qAvg, m_qW); |
343 |
m_qAvg = Estimator (nQueued, m + 1, m_qAvg, m_qW); |
Lines 357-363
RedQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item)
|
Link Here
|
---|
|
357 |
NS_LOG_DEBUG ("adding DROP FORCED MARK"); |
357 |
NS_LOG_DEBUG ("adding DROP FORCED MARK"); |
358 |
dropType = DTYPE_FORCED; |
358 |
dropType = DTYPE_FORCED; |
359 |
} |
359 |
} |
360 |
else if (m_old == 0) |
360 |
else if (!m_old) |
361 |
{ |
361 |
{ |
362 |
/* |
362 |
/* |
363 |
* The average queue size has just crossed the |
363 |
* The average queue size has just crossed the |
Lines 367-373
RedQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item)
|
Link Here
|
---|
|
367 |
*/ |
367 |
*/ |
368 |
m_count = 1; |
368 |
m_count = 1; |
369 |
m_countBytes = item->GetPacketSize (); |
369 |
m_countBytes = item->GetPacketSize (); |
370 |
m_old = 1; |
370 |
m_old = true; |
371 |
} |
371 |
} |
372 |
else if (DropEarly (item, nQueued)) |
372 |
else if (DropEarly (item, nQueued)) |
373 |
{ |
373 |
{ |
Lines 379-385
RedQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item)
|
Link Here
|
---|
|
379 |
{ |
379 |
{ |
380 |
// No packets are being dropped |
380 |
// No packets are being dropped |
381 |
m_vProb = 0.0; |
381 |
m_vProb = 0.0; |
382 |
m_old = 0; |
382 |
m_old = false; |
383 |
} |
383 |
} |
384 |
|
384 |
|
385 |
if ((GetMode () == Queue::QUEUE_MODE_PACKETS && nQueued >= m_queueLimit) || |
385 |
if ((GetMode () == Queue::QUEUE_MODE_PACKETS && nQueued >= m_queueLimit) || |
Lines 475-482
RedQueueDisc::InitializeParams (void)
|
Link Here
|
---|
|
475 |
m_qAvg = 0.0; |
475 |
m_qAvg = 0.0; |
476 |
m_count = 0; |
476 |
m_count = 0; |
477 |
m_countBytes = 0; |
477 |
m_countBytes = 0; |
478 |
m_old = 0; |
478 |
m_old = false; |
479 |
m_idle = 1; |
|
|
480 |
|
479 |
|
481 |
double th_diff = (m_maxTh - m_minTh); |
480 |
double th_diff = (m_maxTh - m_minTh); |
482 |
if (th_diff == 0) |
481 |
if (th_diff == 0) |
Lines 492-498
RedQueueDisc::InitializeParams (void)
|
Link Here
|
---|
|
492 |
m_vC = (1.0 - m_curMaxP) / m_maxTh; |
491 |
m_vC = (1.0 - m_curMaxP) / m_maxTh; |
493 |
m_vD = 2.0 * m_curMaxP - 1.0; |
492 |
m_vD = 2.0 * m_curMaxP - 1.0; |
494 |
} |
493 |
} |
495 |
m_idleTime = NanoSeconds (0); |
494 |
m_idleTime = Time::Min (); |
496 |
|
495 |
|
497 |
/* |
496 |
/* |
498 |
* If m_qW=0, set it to a reasonable value of 1-exp(-1/C) |
497 |
* If m_qW=0, set it to a reasonable value of 1-exp(-1/C) |
Lines 769-805
RedQueueDisc::DoDequeue (void)
|
Link Here
|
---|
|
769 |
{ |
768 |
{ |
770 |
NS_LOG_FUNCTION (this); |
769 |
NS_LOG_FUNCTION (this); |
771 |
|
770 |
|
772 |
if (GetInternalQueue (0)->IsEmpty ()) |
771 |
Ptr<QueueDiscItem> item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ()); |
|
|
772 |
|
773 |
NS_LOG_LOGIC ("Popped " << item); |
774 |
|
775 |
NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ()); |
776 |
NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ()); |
777 |
|
778 |
if (GetInternalQueue (0)->IsEmpty () |
779 |
&& m_idleTime == Time::Min ()) |
773 |
{ |
780 |
{ |
774 |
NS_LOG_LOGIC ("Queue empty"); |
|
|
775 |
m_idle = 1; |
776 |
m_idleTime = Simulator::Now (); |
781 |
m_idleTime = Simulator::Now (); |
777 |
|
|
|
778 |
return 0; |
779 |
} |
782 |
} |
780 |
else |
|
|
781 |
{ |
782 |
m_idle = 0; |
783 |
Ptr<QueueDiscItem> item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ()); |
784 |
|
785 |
NS_LOG_LOGIC ("Popped " << item); |
786 |
|
783 |
|
787 |
NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ()); |
|
|
788 |
NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ()); |
789 |
|
784 |
|
790 |
return item; |
785 |
return item; |
791 |
} |
|
|
792 |
} |
786 |
} |
793 |
|
787 |
|
794 |
Ptr<const QueueDiscItem> |
788 |
Ptr<const QueueDiscItem> |
795 |
RedQueueDisc::DoPeek (void) const |
789 |
RedQueueDisc::DoPeek (void) const |
796 |
{ |
790 |
{ |
797 |
NS_LOG_FUNCTION (this); |
791 |
NS_LOG_FUNCTION (this); |
798 |
if (GetInternalQueue (0)->IsEmpty ()) |
|
|
799 |
{ |
800 |
NS_LOG_LOGIC ("Queue empty"); |
801 |
return 0; |
802 |
} |
803 |
|
792 |
|
804 |
Ptr<const QueueDiscItem> item = StaticCast<const QueueDiscItem> (GetInternalQueue (0)->Peek ()); |
793 |
Ptr<const QueueDiscItem> item = StaticCast<const QueueDiscItem> (GetInternalQueue (0)->Peek ()); |
805 |
|
794 |
|