Page MenuHomeVyOS Platform

Wrong default units when defining traffic policy bandwidth
Closed, ResolvedPublicBUG

Description

There is a mistake in Traffic Policy related to default units. It ruins your Traffic Policy if you use them.

In the three examples below, when setting the bandwidth without giving a sufix (using just <number>), VyOS says it takes it as kbps (kilobyte/s), but that is wrong, it actually takes it as something very different: kbit/s (kilobit/s).

vyos@vyos# set traffic-policy shaper S-F_C bandwidth 
Possible completions:
   auto         Rate matches interface speed (default)
   <number>     Rate in k (1000) bytes per second
   <number>bit  bit(1), kbit(10^3), mbit(10^6), gbit, tbit
   <number>ibit kibit(1024), mibit(1024^2), gibit(1024^3), tbit(1024^4)
   <number>ibps kibps(1024*8), mibps(1024^2*8), gibps, tibps *Byte/sec*
   <number>bps  bps(8),kbps(8*10^3),mbps(8*10^6), gbps, tbps *Byte/sec*
vyos@vyos#  set traffic-policy rate-control TBF bandwidth 
Possible completions:
   <number>     Rate in k (1000) bytes per second
   <number><suffix>
                Rate with scaling suffix (mbit, mbps, ...)
vyos@vyos# set traffic-policy limiter LIMITER default bandwidth 
Possible completions:
   <number>     Rate in k (1000) bytes per second
   <number><suffix>
                Rate with scaling suffix (mbit, mbps, ...)

Moreover, when defining the bandwidth of a class or the bandwidth of default traffic, VyOS does not only make the same mistake but it also shows the confusion:

vyos@vyos# set traffic-policy shaper S-F_C class 10 bandwidth 
Possible completions:
   <number>     Bandwidth in Kbps(10^3 bits per second)
   <number>%    Percentage of overall rate (default 100%)
   <number>bit  bit(1), kbit(10^3), mbit(10^6), gbit, tbit
   <number>ibit kibit(1024), mibit(1024^2), gibit(1024^3), tbit(1024^4)
   <number>ibps kibps(1024*8), mibps(1024^2*8), gibps, tibps *Byte/sec*
   <number>bps  bps(8),kbps(8*10^3),mbps(8*10^6), gbps, tbps *Byte/sec*
vyos@vyos#     set traffic-policy shaper S-F_C default bandwidth
Possible completions:
   <number>     Bandwidth in Kbps(10^3 bits per second)
   <number>%    Percentage of overall rate (default 100%)
   <number>bit  bit(1), kbit(10^3), mbit(10^6), gbit, tbit
   <number>ibit kibit(1024), mibit(1024^2), gibit(1024^3), tbit(1024^4)
   <number>ibps kibps(1024*8), mibps(1024^2*8), gibps, tibps *Byte/sec*
   <number>bps  bps(8),kbps(8*10^3),mbps(8*10^6), gbps, tbps *Byte/sec*

In the two examples above VyOS says (in the first line of possible completions), "if you don't give a unit suffix, your number will be taken as kbps" and it also explains that it means 10^3 bits per second, which is wrong. kbps is not 10^3 bit per second but 10^3 byte per second.

VyOS will again actually take the given number as kbit (kilobit per second), not as kbps.

Besides fixing these mistakes, it would also be good to check every default unit for every setting of every traffic policy.

Details

Difficulty level
Unknown (require assessment)
Version
1.2.x ; 1.3
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

s.lorente created this task.Jun 8 2020, 9:02 PM
pasik added a subscriber: pasik.Jun 9 2020, 8:58 AM
s.lorente updated the task description. (Show Details)Jun 9 2020, 9:31 AM
zsdc assigned this task to s.lorente.Jun 15 2020, 11:13 AM
zsdc added a subscriber: zsdc.

@s.lorente can you check this with actually configured tc values?

Note: generally accepted in networking that the difference between bytes and bits are in letter case:
bps (kbps, Mbps, Gbps) - bits per second
Bps (kBps, MBps, GBps) - bytes per second

s.lorente added a comment.EditedJun 15 2020, 3:14 PM

Hey @zsdc , thanks for having a look into it.

Yes, I'm also more used to b and B to differentiate between bits and Bytes, but VyOS QoS uses 'bit' for bits and 'b' for bytes.

I have verified it both with the tc command and with actual tests in my qos lab, those default units are wrong.

vyos@vyos# run show config commands | grep '1 bandwidth'
set traffic-policy shaper 1 bandwidth '1500'
[edit]
vyos@vyos# run show config commands | grep 'eth1 traffic-policy'
set interfaces ethernet eth1 traffic-policy out '1'
[edit]
vyos@vyos# tc class show dev eth1
class htb 1:1 root rate 1500Kbit ceil 1500Kbit burst 1599b cburst 1599b 
class htb 1:2 parent 1:1 leaf 8002: prio 0 rate 1500Kbit ceil 1500Kbit burst 15Kb cburst 1599b 
class fq_codel 8002:ba parent 8002: 
class fq_codel 8002:1e8 parent 8002: 
class fq_codel 8002:286 parent 8002: 
class fq_codel 8002:3d3 parent 8002: 
[edit]
vyos@vyos#

I guess soon I'll come back to you with some questions on how to fix this :)

c-po added a subscriber: c-po.Jun 15 2020, 3:23 PM
vyos@vyos:~$ show config commands | grep traffic
set interfaces pppoe pppoe0 traffic-policy out 'QoS'
set traffic-policy shaper QoS bandwidth '50mbit'
set traffic-policy shaper QoS default bandwidth '100%'
set traffic-policy shaper QoS default queue-type 'fq-codel'
vyos@vyos:~$ tc class show dev pppoe0
vyos@vyos:~$

does this not work on PPPoE?

@c-po I have never tested QoS on PPPoE in my lab. I'm having a look and come back to you.

Hey @c-po

I tested on PPPoE the simple configuration I gave you on slack. It works perfectly, delay goes down for interactive traffic and bulk flows are distributed fairly.

If your bandwidth is 50mbit maybe you want to try to reduce the queue-limit. 1000 packets could be ok.

set traffic-policy shaper QoS default queue-limit 1000

If you want to see your policy, use tc qdisc show

vyos@vyos# tc qdisc show dev pppoe0
qdisc htb 1: root refcnt 2 r2q 10 default 2 direct_packets_stat 0 direct_qlen 3
qdisc fq_codel 8007: parent 1:2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb 
[edit]
vyos@vyos#

By the way, shouldn't we better talk through slack? : )

s.lorente added a comment.EditedJun 25 2020, 12:30 AM

Done.

I have checked and fixed bandwidth default units for Limiter, Network Emulator, Rate Control,
Shaper and Shaper HFSC.

I have not been able to verify the default unit for Random Detect's bandwidth (through tc show commands and tests in the lab), so I have deleted its default unit help. Users configuring Random Detect and trying to configure its bandwidth parameter, they will specify the unit they want to use as they will not see the possibility of using a default unit.

s.lorente closed this task as Resolved.Jun 25 2020, 12:39 AM