I'm using Xen 4.0.1 with Linux 2.6.32-5-xen-amd64 (standard packages on a Debian Squeeze system).
From Xen Networking:
For each new domU, Xen creates a new pair of "connected virtual ethernet interfaces", with one end in domU and the other in dom0. For linux domU's, the device name it sees is named eth0. The other end of that virtual ethernet interface pair exists within dom0 as interface vif<id#>.0
Think of them as two ethernet interfaces connected by an internal crossover ethernet cable.
My understanding of this internal crossover thing is that networking statistics should be the same no matter if you measure it in the dom0 (vifN.N interface) or in the domU (eth0 interface). RX/TX values should be the same, just inverted.
Nevertheless I'm getting ~20% larger values when traffic is measured in dom0. My question is why the values are (that) different?
Starting the guest domain:
root@dev1:/etc/xen# xm create node2050.cfg
Using config file "./node2050.cfg".
Started domain node2050 (id=35)
root@dev1:/etc/xen# xm list node2050
Name ID Mem VCPUs State Time(s)
node2050 35 256 1 -b---- 2.5
root@dev1:/etc/xen# ip address show vif35.0
70: vif35.0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 32
link/ether fe:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff
inet6 fe80::fcff:ffff:feff:ffff/64 scope link
valid_lft forever preferred_lft forever
In domU:
node2050:~# ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:16:3e:44:2e:5a brd ff:ff:ff:ff:ff:ff
inet xx.yy.zz.50/24 brd xx.yy.zz.255 scope global eth0
inet6 fe80::216:3eff:fe44:2e5a/64 scope link
valid_lft forever preferred_lft forever
Just after starting node2050
:
In dom0.
root@dev1:~# while true; do date; cat /sys/class/net/vif35.0/statistics/{r,t}x_bytes; sleep 1; done
...
Thu Jan 19 13:18:00 EST 2012
4826
466049
Thu Jan 19 13:18:01 EST 2012
4826
466580
Thu Jan 19 13:18:02 EST 2012
4826
467427
Thu Jan 19 13:18:03 EST 2012
4826
467910
Thu Jan 19 13:18:04 EST 2012
4826
468769
Thu Jan 19 13:18:05 EST 2012
4826
469764
in domU:
root@node2050:~# while true; do date; cat /sys/class/net/eth0/statistics/{r,t}x_bytes; sleep 1; done
...
Thu Jan 19 13:18:00 EST 2012
395229
5792
Thu Jan 19 13:18:01 EST 2012
395961
5792
Thu Jan 19 13:18:02 EST 2012
396617
5792
Thu Jan 19 13:18:03 EST 2012
397304
5792
Thu Jan 19 13:18:04 EST 2012
397735
5792
Thu Jan 19 13:18:05 EST 2012
398620
5792
The config:
root@dev1:/etc/xen# cat node2050.cfg
kernel = '/boot/vmlinuz-2.6.32-5-xen-amd64'
ramdisk = '/boot/initrd.img-2.6.32-5-xen-amd64'
vcpus = '1'
memory = '256'
root = '/dev/xvda2 ro'
disk = [
'phy:/dev/vg0/node2050-disk,xvda2,w',
'phy:/dev/vg0/node2050-swap,xvda1,w',
]
name = 'node2050'
vif = [ 'ip=xx.yy.zz.50,mac=00:16:3E:44:2E:5A' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
extra = 'console=hvc0 xencons=hvc0'