Ping's definition of mdev
Derek Burdick
derek at burdick.cc
Fri Jun 17 08:21:57 MDT 2005
Looking at the code, i'm not sure they are even calculating the standard
deviation correctly. They are using this formula:
dev = sqrt( (E (sqr(x)))/N - sqr( (E(x))/N))
standard deviation is defined as
sqrt( 1 / (N) * E sqr((x - E(x)/N) ))
where E represents sigma, or the sum all items from i=1 to n.
The mean deviation is the mean of the absolute deviations, which is
nothing like standard deviation.
MD = 1/N * E abs(x - E(x))
Josh, you are absolutely correct it should be sdev, not mdev. However,
sdev is not being calculated correctly. When they expanded sqr(x -
(E(x))/N) it should be
sqr(x) - 2x E(x)/N + sqr((E(x))/N)
They have
sqr(x) + sqr((E(x))/N)
So they essentially removed E(-2x E(x)/N) from the calculation, giving a
number that is not the standard deviation. Am I off base anywhere here?
This should be an easy one to fix. I've already added a jitter
calculation by retrieving the average of the differences of each
response time. That should be close to the standard deviation isn't it?
Derek
Josh Coates wrote:
>>I searched the man page and google but can not find a definition for
>>mdev, which is a returned statistic when ping exits. Does anybody
>>know what it is measuring?
>>
>>
>
>
>
>>>I found the answer. It is the standard deviation. mdev stands for mean
>>>deviation.
>>>
>>>
>
>mdev is the std dev? standard deviation is not the same thing as the mean
>deviation.
>
>http://mathworld.wolfram.com/StandardDeviation.html
>
>http://mathworld.wolfram.com/MeanDeviation.html
>
>i didn't look at the source, but what you've excerpted below looks like they
>are assigning 'mdev' the stnd deviation, which doesn't look right.
>
>quick, now is your chance to make a contribution to the open source
>movement!!
>
>submit a bug and patch: s/mdev/sdev/g on ping_common.c
>
>w00t!
>
>Josh Coates
>www.jcoates.org
>
>
>-----Original Message-----
>From: plug-bounces at plug.org [mailto:plug-bounces at plug.org]On Behalf Of
>Derek Burdick
>Sent: Friday, June 17, 2005 12:28 AM
>To: Provo Linux Users Group Mailing List
>Subject: Re: Ping's definition of mdev
>
>
>I found the answer. It is the standard deviation. mdev stands for mean
>deviation.
>
>Derek Burdick wrote:
>
>
>
>>I searched the man page and google but can not find a definition for
>>mdev, which is a returned statistic when ping exits. Does anybody
>>know what it is measuring? I have looked through the code and
>>determined mathematically what the algorithm does, but I don't see any
>>relevance to networking. Does anybody have any insight? I have
>>attached my comments on what the code is doing in case somebody knows
>>of a generic use for this algorithm.
>>
>>Here is the sample output
>>3460 packets transmitted, 3451 received, 0% packet loss, time 119983ms
>>rtt min/avg/max/mdev = 303.108/305.426/347.859/2.979 ms, pipe 11
>>
>>Here is what I believe ping_common.c is doing to determine mdev:
>>
>>for each packet received and assuming tsum and tsum2 start at 0:
>>tsum += triptime
>>tsum2 += triptime * triptime
>>
>>Once ping finishes
>>tsum /= nreceived + nrepeats // Get the average of the triptimes. We
>>have 0 repeats so it has no effect here.
>>tsum2 /= nreceived + nrepeats // Get the average of the squared
>>triptimes. Once again we have 0 repeats
>>
>>tmdev = llsqrt(tsum2 - tsum * tsum); // Take the square root of the
>>difference of the average squared triptimes and the average triptime
>>squared.
>>
>>tmdev is then printed as printf("%ld.%03ld ms", tmdev /1000,
>>tmdev%1000); //This is giving us the results in milliseconds
>>
>>If anybody has any insight or comments i'd love to hear them.
>>
>>Thanks,
>> Derek
>>
>>p.s. This is not a class assignment. Our sales team wants to sell IP
>>phone service to a client in India using the Internet for the
>>bandwidth. I was looking for any numbers I could find to help me give
>>them a good idea of what to expect.
>>
>>I think I will add a Jitter calculation in to ping as that is usually
>>a great indication along with packet loss on what to expect with VOIP.
>>
>>Thanks again.
>>.===================================.
>>| This has been a P.L.U.G. mailing. |
>>| Don't Fear the Penguin. |
>>| IRC: #utah at irc.freenode.net |
>>`==================================='
>>
>>
>
>.===================================.
>| This has been a P.L.U.G. mailing. |
>| Don't Fear the Penguin. |
>| IRC: #utah at irc.freenode.net |
>`==================================='
>
>
>
>.===================================.
>| This has been a P.L.U.G. mailing. |
>| Don't Fear the Penguin. |
>| IRC: #utah at irc.freenode.net |
>`==================================='
>
>
More information about the PLUG
mailing list