At telecommunications switches and routers, RED (random early packet
discard) uses the queue depth to determine whether to keep or discard
each packet as it arrives at a queue. This is done by determining a
discard probability (P), which is dependent on the average depth of the
queue, and comparing the discard probability to a random number. One way
of performing the invention uses the summed discard probabilities,
instead of counting the number of packets (count) and multiplying that by
the current discard probability, as in the prior art. The resulting sum
is compared to the random number for discard operation. The disclosure
further describes a more accurate way of calculating average depth of a
queue, especially when the queue encounters periods of idleness.