In VirtualBox, I have two Ubuntu 18.04 VMs running on an Ubuntu 18.04 host. My target is to simulate network traffic between the two VMs (one as a Server, one as a Client). Therefore I set the VM adapter settings to Internal Network. So basically, there are just these two VMs on two different static IP addresses and that's it.
Now I want to limit the available bandwidth for that connection. Therefore I used the VirtualBox command bandwidthctl in the Host terminal to limit the available bandwidth for both VMs to 300mbit/s:
VBoxManage bandwidthctl "VM-Server" add LimitServer --type network --limit 300m
VBoxManage bandwidthctl "VM-Client" add LimitClient --type network --limit 300m
VBoxManage bandwidthctl "VM-Server" --nicbandwidthgroup1 LimitServer
VBoxManage bandwidthctl "VM-Client" --nicbandwidthgroup1 LimitClient
Then I used iPerf to check the maximum bandwidth. After starting it on the Server-VM (iPerf -s) I tried the following on the Client-VM:
iperf -c 192.168.0.2 -t 20 -i 10
what leads to a duration time of 20 seconds (-t 20) and an interval of 10 seconds (-i 10) between each bandwidth report.
The result was an average bandwidth of 302mbit/s in the interval of 0-10seconds and 298mbit/s in the interval of 10-20 seconds.
Now I changed the interval time from 10 seconds to 0.5 seconds. The result was a very inconstant bandwidth from e.g 287mbit/s in the interval of 6.0-6.5 seconds or 319mbit/s in the interval of 3.5-4.0 seconds.
Changing the interval time to 0.1 seconds made it even worse and the result was 161mbit/s from 1.4-1.5 seconds and then 412mbit/s from 1.5-1.6 seconds.
The average bandwidth over the whole duration time of 20 seconds was always something about 300mbit/s but my question is:
Why do I get an inconstant bandwidth in the intervals between despite adjusting a limitation of 300mbit/s?