[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] Average queue lenght...



"Ignacio M�s Ivars" wrote:

>         I have a doubt that I do not know how to solve. I am trying to get the
> average queue length in a link and I though that I could do it using a queue
> monitor like this:
> ...
> //begin of the loop
> set byte_integ [$qmon get-bytes-integrator]
> set pkt_integ [$qmon get-pkts-integrator]
> puts "Queue_size= [$pkt_integ set sum_]"
> $qmon reset
> ...But it turns out that I am getting values of the queue of 30 packets when my
> link has a queue of only ten packets!!

Hi,

First of all, queue-monitor doesn't have a method reset, so "$qmon reset" is
useless (see source code in queue-monitor.cc).

Second, an integrator computes the area under the curve for a given function (in
this case, f(time)=queue_size). If what you want to obtain is the average queue
length over the entire simulation, you have to divide sum_ by the time elapsed
from the beginning of the simulation.

However, if you want to sample the average queue length at regular intervals, you
cannot call reset on the integrators each time. The problem is that the
integrators will miss the first delta, since reset not only zeroes the sum_ but
also lastx_ and lasty_. Use

$xxxx_integrator set sum_ 0

instead of "$xxx_integrator reset". If you sample every 1 second, you don't have
to divide sum_ by the time interval (it is 1.0).

-- Felix Hernandez

(This is a simple example I used to test the integrator:

set ns [new Simulator]

set int [new Integrator]

$int newpoint 0.0 0.0

$int newpoint 0.25 1.0
$int newpoint 0.5 2.0
$int newpoint 0.75 2.0
$int newpoint 1.0 2.0

puts [$int set sum_]

$int set sum_ 0.0

$int newpoint 1.25 3.0
$int newpoint 1.5 3.0
$int newpoint 1.75 3.0
$int newpoint 2.0 3.0

puts [$int set sum_]

# if you do not reset sum_ every second, you have to do something like this...
# puts [expr [$int set sum_] / 2.0]

)