> +             if (unlikely(first_sample)) {
> +                     first_sample = false;
> +
>                       glob_stats->min_latency = latency;
> -             else if (latency > glob_stats->max_latency)
>                       glob_stats->max_latency = latency;
> -             /*
> -              * The average latency is measured using exponential moving
> -              * average, i.e. using EWMA
> -              * https://en.wikipedia.org/wiki/Moving_average
> -              */
> -             glob_stats->avg_latency +=
> -                     alpha * (latency - glob_stats->avg_latency);
> +                     glob_stats->avg_latency = latency;
> +                     glob_stats->jitter = latency / 2;

Setting jitter at first sample as latency / 2 is wrong.
Jitter should remain zero at first sample.

> +             } else {
> +                     /*
> +                      * The jitter is calculated as statistical mean of
> interpacket
> +                      * delay variation. The "jitter estimate" is computed
> by taking
> +                      * the absolute values of the ipdv sequence and
> applying an
> +                      * exponential filter with parameter 1/16 to generate
> the
> +                      * estimate. i.e J=J+(|D(i-1,i)|-J)/16. Where J is
> jitter,
> +                      * D(i-1,i) is difference in latency of two
> consecutive packets
> +                      * i-1 and i.
> +                      * Reference: Calculated as per RFC 5481, sec 4.1,
> +                      * RFC 3393 sec 4.5, RFC 1889 sec.
> +                      */
> +                     glob_stats->jitter += ((prev_latency - latency)
> +                                            - glob_stats->jitter) / 16;

With jitter remaining zero at first sample,
Acked-by: Morten Brørup <m...@smartsharesystems.com>

Reply via email to