dockerudptcpdumpubuntu-serveriperf

Missing UDP packets between docker containers


I'm developing a project where I need to exchange UDP packets between 2 docker containers on the same host. The host is a new dedicated server running ubuntu server 14.04LTS (Dell PowerEdge R410, 32 GB RAM, Intel Xeon CPU E5640 @ 2.67GHz).

While developing my project, I noticed that I was losing packets between 2 docker containers, so I developed the following scenario to demonstrate my problem:

I created 3 docker containers from ubuntu:14.04 running on the same host, let's call them container #1, container #2 and container #3. Docker version is 1.11.1 (build 5604cbe).

After the 60sec, Container #1 reports that sent 2786350 datagrams.

Container #2 reports that:

Interval      Transfer      Bandwidth       Jitter   Lost/Total Datagrams
0.0-60.0 sec  3.81 GBytes   546 Mbits/sec   0.001 ms 2250/2786349 (0.081%) 

Container #3 reports that:

2770477 packets captured
2786351 packets received by filter
15874   packets dropped by kernel

So, a couple of questions:

  1. Why containers #2 and #3 don't report the same number of received packets (container #2 has 1 less datagram and container #3 has 1 more)?

  2. Why the number of lost packets are very different if this is a controlled virtual network? Also, what does it means "packets dropped by kernel"?

  3. Why am I loosing packets in the first place? Once again, this is a controlled virtual environment, no network equipment is being used.

Thanks in advance.


Solution

  • packets ``dropped by kernel'' (this is the number of packets that were dropped, due to a lack of buffer space, by the packet capture mechanism in the OS on which tcpdump is running, if the OS reports that information to applications; if not, it will be reported as 0).

    kernel writes captured data to special buffer and tcpdump reads data from that buffer. If buffer is full packet is dropped.

    Network often faster than disk, which mean sometimes you can't just capture all the packets. But since number of packed dropped is small this is not your case so you could do the following.

    1. Increase buffer for tcpdump, -B or --buffer-size options, size in KB. Default is 2048KB.
    2. sudo nice -10 tcpdump - give tcpdump additional priority (or even -20)
    3. if you on linux sudo nice -10 ionice -c 1 tcpdump additional disk write priority