Welcome to the Linux Foundation Forum!

netem ratelimit stops limiting rate after short time and restores to default

I have experienced a couple of times that netem stops working when I apply qdisc. This happened with both rate limit as well as loss.

For example, consider a scenario: Internet <------>(eth1) A (eth2)<------> (eth3)B

PC A is connected to an internet access point via ethernet port eth1. PC B is connected to PC A via port eth2 of PC A. So, basically, PC A is a bridge that I configure using OvS. I apply netem rule on eth2 and expect it to be reflected on PC B.

Now, in PC A, I applied a rate limit on eth2 of 30Mbps with a limit of 1000 using the command:

tc qdisc add dev eth2 root handle 1:0 netem rate 30000kbit limit 1000

Then I ran the iperf3 server on PC B and test the bandwidth by running the iperf3 client on a different PC (say 'C' that is connected to the network). The iperf3 result is:

[ 4] local xx.xx.xx.xx port 54838 connected to yy.yy.yy.yy port 5009
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 3.92 MBytes 32.8 Mbits/sec 0 185 KBytes
[ 4] 1.00-2.00 sec 3.50 MBytes 29.4 Mbits/sec 0 210 KBytes
[ 4] 2.00-3.00 sec 3.50 MBytes 29.4 Mbits/sec 0 210 KBytes
[ 4] 3.00-4.00 sec 3.38 MBytes 28.3 Mbits/sec 0 210 KBytes
[ 4] 4.00-5.00 sec 3.50 MBytes 29.4 Mbits/sec 0 210 KBytes
[ 4] 5.00-6.00 sec 3.38 MBytes 28.3 Mbits/sec 0 210 KBytes
[ 4] 6.00-7.00 sec 3.50 MBytes 29.4 Mbits/sec 0 210 KBytes
[ 4] 7.00-8.00 sec 3.50 MBytes 29.4 Mbits/sec 0 210 KBytes
[ 4] 8.00-9.00 sec 65.6 MBytes 550 Mbits/sec 142 210 KBytes
[ 4] 9.00-10.00 sec 109 MBytes 918 Mbits/sec 0 210 KBytes


[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 203 MBytes 170 Mbits/sec 142 sender
[ 4] 0.00-10.00 sec 203 MBytes 170 Mbits/sec receiver

Initially, I am getting around 30Mbps but in the last two runs, the throughput is much higher than 30Mbps. I tried iperf3 again multiple times. Then it was fine. Why netem has this inconsistent behavior?

Another example where I cap rate to 50Mbps, the first iperf3 gave correct rate-limiting but one the second iperf3 attempt I got the inconsistent rate-limiting (as shown below):

[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 6.05 MBytes 50.8 Mbits/sec 0 210 KBytes
[ 4] 1.00-2.00 sec 5.75 MBytes 48.2 Mbits/sec 0 210 KBytes
[ 4] 2.00-3.00 sec 5.75 MBytes 48.2 Mbits/sec 0 210 KBytes
[ 4] 3.00-4.00 sec 5.75 MBytes 48.2 Mbits/sec 0 210 KBytes
[ 4] 4.00-5.00 sec 29.8 MBytes 250 Mbits/sec 143 210 KBytes
[ 4] 5.00-6.00 sec 110 MBytes 920 Mbits/sec 0 210 KBytes
[ 4] 6.00-7.00 sec 109 MBytes 914 Mbits/sec 0 210 KBytes
[ 4] 7.00-8.00 sec 109 MBytes 915 Mbits/sec 0 210 KBytes
[ 4] 8.00-9.00 sec 109 MBytes 914 Mbits/sec 0 210 KBytes
[ 4] 9.00-10.00 sec 109 MBytes 914 Mbits/sec 0 210 KBytes


[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 599 MBytes 502 Mbits/sec 143 sender
[ 4] 0.00-10.00 sec 598 MBytes 502 Mbits/sec receiver

After the fourth run, it appears that netem ratelimit is simply gone and the network is back to its default rate.

I have seen this behaviour when I introduce loss using netem. Please, any help to fix this or explain this inconsistent netem behaviour would be helpful. Thanks.

Comments

  • hiqbal
    hiqbal Posts: 2

    I found a solution to this problem.

    PC A is the one acting as a bridge for two ethernet connections. Once we set OvS bridge, the internet is no longer available on PC A. By default, the OS (ubuntu 20 in this case) is configured to attempt connecting to the internet automatically after regular intervals on both eth1 and eth2. Because of OvS configuration, the connection attempt is bound to fail. After the failure notification, the qdisc is removed on the network devices. This results in the iperf3 behavior as described in the question.

    The fix is simple, just go to the network settings and disable auto-connect on both eth1 and eth2, and save the setting. Once done, netem works fine.

    Hope this helps those who may face this issue in the future.

Categories

Upcoming Training