netstat counters on VirtualBox host-only counters are incorrect

Ryan Stone rysto32 at gmail.com
Thu Feb 24 02:43:32 UTC 2011


When I use host-only networking with a FreeBSD host the netstat
counters on vboxnetX are completely wrong.  For example, if I run
netperf between a guest and the host I see the following netstat
output on the guest:

              input          (em1)           output
   packets  errs idrops      bytes    packets  errs      bytes colls
      7776     0     0     513672      11898     0   17745260     0
      9498     0     0     626868      14557     0   21703130     0
      8798     0     0     580668      13471     0   20091246     0
      9371     0     0     620718      14239     0   21251326     0
      9202     0     0     607332      14087     0   21016638     0
      6088     0     0     403052       9307     0   13877798     0
      6445     0     0     425882       9838     0   14687156     0
      9227     0     0     609378      14142     0   21073308     0
      7299     0     0     482634      11145     0   16621458     0
      4721     0     0     314298       7120     0   10633528     0
      9258     0     0     611028      14185     0   21154178     0

On the host, however, I see the following:
            input     (vboxnet0)           output
   packets  errs idrops      bytes    packets  errs      bytes colls
         2     0     0   15234809          2     0        467     0
         0     0     0   21378232          0     0          0     0
         0     0     0   21267106          0     0          0     0
         2     0     0   16843302          2     0        508     0
         0     0     0   19865678          0     0          0     0
         0     0     0   12189452          0     0          0     0
         0     0     0   17398526          0     0          0     0
         0     0     0   15653006          0     0          0     0
         0     0     0   13474242          0     0          0     0
         0     0     0   22144532          0     0          0     0
         0     0     0   11087250          0     0          0     0


Also, if I run tcpdump on vboxnet0, I see almost no packets from the
host to the guest, only packets from the guest to the host.  The
exception is that I see broadcast packets transmitted by the host in
tcpdump.  Broadcast frames from the host seem to line up with the
small number of packets that showed up in the netstat sample output in
the "output" columns.  Looking at the host-only networking kernel
module that makes sense as the opackets counter is incremented right
before the packet is passed to bpf.  It would appear the only
broadcast frames make it to VBoxNetAdpFreeBSDNetstart.

I don't have a lot of insight into what's happening to the input
counters, other than to note that the input packet counter line up
suspiciously with the output packet counter.  I have no idea what's
happening with the input byte counter, unless bytes are getting double
or triple counted somehow?


I see this behaviour under both VirtualBox 3.2.12 and 4.0.4.

Ryan


More information about the freebsd-emulation mailing list