All of lore.kernel.org
 help / color / mirror / Atom feed
* Netem Delay Normal Distribution
@ 2013-10-27  2:31 anirup dutta
  2013-10-27 19:27 ` Eric Dumazet
  2013-10-27 19:37 ` Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: anirup dutta @ 2013-10-27  2:31 UTC (permalink / raw)
  To: netdev

Hello,

I try this on my device

sudo tc qdisc del dev eth0 root netem delay 100ms 20ms distribution normal

I use iperf for transmitting UDP packets and I modified its code to
get per packet delay. When I plot the distribution of delays and
analyze the delays they pass the normality tests.

The only problem that I am not able to understand is that the mean of
those delays shift to 125ms. Its not only me. There was another study
and it observed the same thing.

http://www.researchgate.net/publication/224256550_An_Empirical_Study_of_NetEm_Network_Emulation_Functionalities/file/d912f5058c9b1e409b.pdf

Figure 7

I found out that this command is valid

sudo tc qdisc del dev eth0 root netem delay 1ms 20ms distribution normal

So I have a feeling that mean gets shifted from the base delay to
avoid negative delay values.

It would be great if someone can confirm how it is implemented?

Regards,

Anirup

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Netem Delay Normal Distribution
  2013-10-27  2:31 Netem Delay Normal Distribution anirup dutta
@ 2013-10-27 19:27 ` Eric Dumazet
  2013-10-27 19:37 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2013-10-27 19:27 UTC (permalink / raw)
  To: anirup dutta; +Cc: netdev, Stephen Hemminger

On Sat, 2013-10-26 at 21:31 -0500, anirup dutta wrote:
> Hello,
> 
> I try this on my device
> 
> sudo tc qdisc del dev eth0 root netem delay 100ms 20ms distribution normal
> 
> I use iperf for transmitting UDP packets and I modified its code to
> get per packet delay. When I plot the distribution of delays and
> analyze the delays they pass the normality tests.
> 
> The only problem that I am not able to understand is that the mean of
> those delays shift to 125ms. Its not only me. There was another study
> and it observed the same thing.
> 
> http://www.researchgate.net/publication/224256550_An_Empirical_Study_of_NetEm_Network_Emulation_Functionalities/file/d912f5058c9b1e409b.pdf
> 
> Figure 7
> 
> I found out that this command is valid
> 
> sudo tc qdisc del dev eth0 root netem delay 1ms 20ms distribution normal
> 
> So I have a feeling that mean gets shifted from the base delay to
> avoid negative delay values.
> 
> It would be great if someone can confirm how it is implemented?

What version of linux are you running exactly ? We had many fixes in
netem...

Here are my results running latest net-next tree. I see no problem for
the mean, but for the min/max (range of the variation)

Omitting "distribution normal" gets expected results :

lpq83:~# tc qd del dev eth0 root
lpq83:~# tc qdisc add dev eth0 root netem delay 100ms 20ms                    
lpq83:~# ping -i 0.1 -q -c 100 lpq84
100 packets transmitted, 100 received, 0% packet loss, time 19721ms
rtt min/avg/max/mdev = 80.504/100.383/120.106/11.534 ms, pipe 2

But using "distribution normal" impacts the min/max :

lpq83:~# tc qd del dev eth0 root
lpq83:~# tc qdisc add dev eth0 root netem delay 10ms 2ms distribution normal
lpq83:~# ping -i 0.1 -q -c 100 lpq84
100 packets transmitted, 100 received, 0% packet loss, time 9963ms
rtt min/avg/max/mdev = 4.829/10.214/13.973/1.988 ms


lpq83:~# tc qd del dev eth0 root
lpq83:~# tc qdisc add dev eth0 root netem delay 100ms 20ms distribution normal
lpq83:~# ping -i 0.1 -q -c 100 lpq84
100 packets transmitted, 100 received, 0% packet loss, time 19166ms
rtt min/avg/max/mdev = 46.137/100.035/159.869/21.136 ms, pipe 2

So the mean seems OK, but the min/max seems scaled by a 2 factor.

NETEM_DIST_SCALE seems to be 8192 in the kernel, but the tc injects
distribution tables with s16 integers, in the -32768 .. 32768 range

Stephen, do you have an idea of what is wrong 
(the distribution files in /usr/lib/tc or the kernel )?

Relevant code in tabledist() is :

        t = dist->table[rnd % dist->size];
        x = (sigma % NETEM_DIST_SCALE) * t;
        if (x >= 0)
                x += NETEM_DIST_SCALE/2;
        else
                x -= NETEM_DIST_SCALE/2;

        return  x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * t + mu;


root@edumazet-glaptop:/usr/lib/tc# head -n 4 /usr/lib/tc/normal.dist 
# This is the distribution table for the normal distribution.
 -32768 -28307 -26871 -25967 -25298 -24765 -24320 -23937
 -23600 -23298 -23025 -22776 -22546 -22333 -22133 -21946
 -21770 -21604 -21445 -21295 -21151 -21013 -20882 -20755

root@edumazet-glaptop:/usr/lib/tc# tail -n 4 /usr/lib/tc/normal.dist 
 19816 19911 20009 20109 20213 20319 20430 20544
 20663 20786 20914 21047 21186 21331 21484 21644
 21813 21991 22181 22384 22601 22836 23091 23370
 23679 24027 24424 24888 25450 26164 27159 28858

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Netem Delay Normal Distribution
  2013-10-27  2:31 Netem Delay Normal Distribution anirup dutta
  2013-10-27 19:27 ` Eric Dumazet
@ 2013-10-27 19:37 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2013-10-27 19:37 UTC (permalink / raw)
  To: anirup dutta; +Cc: netdev

On Sat, 26 Oct 2013 21:31:03 -0500
anirup dutta <adutta2@uh.edu> wrote:

> Hello,
> 
> I try this on my device
> 
> sudo tc qdisc del dev eth0 root netem delay 100ms 20ms distribution normal
> 
> I use iperf for transmitting UDP packets and I modified its code to
> get per packet delay. When I plot the distribution of delays and
> analyze the delays they pass the normality tests.
> 
> The only problem that I am not able to understand is that the mean of
> those delays shift to 125ms. Its not only me. There was another study
> and it observed the same thing.
> 
> http://www.researchgate.net/publication/224256550_An_Empirical_Study_of_NetEm_Network_Emulation_Functionalities/file/d912f5058c9b1e409b.pdf
> 
> Figure 7
> 
> I found out that this command is valid
> 
> sudo tc qdisc del dev eth0 root netem delay 1ms 20ms distribution normal
> 
> So I have a feeling that mean gets shifted from the base delay to
> avoid negative delay values.
> 
> It would be great if someone can confirm how it is implemented?

The table distribution logic actually predates netem.
It came from NIST Net http://snad.ncsl.nist.gov/nistnet/
The code was direct copy from this public domain code.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-27 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-27  2:31 Netem Delay Normal Distribution anirup dutta
2013-10-27 19:27 ` Eric Dumazet
2013-10-27 19:37 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.