CAKE QoS Script (OpenWrt)

full reset seems to have sorted it

root@ImmortalWrt:~# tc -s qdisc
qdisc noqueue 0: dev lo root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc mq 0: dev eth0 root
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc fq_codel 0: dev eth0 parent :2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
  maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc fq_codel 0: dev eth0 parent :1 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
  maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc mq 0: dev eth2 root
 Sent 5171420 bytes 21538 pkt (dropped 0, overlimits 0 requeues 2)
 backlog 0b 0p requeues 2
qdisc fq_codel 0: dev eth2 parent :2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 2584189 bytes 12182 pkt (dropped 0, overlimits 0 requeues 1)
 backlog 0b 0p requeues 1
  maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc fq_codel 0: dev eth2 parent :1 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 2587231 bytes 9356 pkt (dropped 0, overlimits 0 requeues 1)
 backlog 0b 0p requeues 1
  maxpacket 1474 drop_overlimit 0 new_flow_count 1 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc mq 0: dev eth1 root
 Sent 35500293 bytes 40355 pkt (dropped 0, overlimits 0 requeues 9)
 backlog 0b 0p requeues 9
qdisc fq_codel 0: dev eth1 parent :2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 27355675 bytes 27647 pkt (dropped 0, overlimits 0 requeues 5)
 backlog 0b 0p requeues 5
  maxpacket 1392 drop_overlimit 0 new_flow_count 1 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc fq_codel 0: dev eth1 parent :1 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 8144618 bytes 12708 pkt (dropped 0, overlimits 0 requeues 4)
 backlog 0b 0p requeues 4
  maxpacket 1392 drop_overlimit 0 new_flow_count 3 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc noqueue 0: dev br-lan root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc cake 8006: dev pppoe-wan root refcnt 2 bandwidth 100Mbit diffserv4 dual-srchost nat wash no-ack-filter split-gso rtt 100ms noatm overhead 38 mpu 84
 Sent 1528516 bytes 8991 pkt (dropped 0, overlimits 2015 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 39104b of 5000000b
 capacity estimate: 100Mbit
 min/max network layer size:           29 /    1492
 min/max overhead-adjusted size:       84 /    1530
 average network hdr offset:            0

                   Bulk  Best Effort        Video        Voice
  thresh       6250Kbit      100Mbit       50Mbit       25Mbit
  target            5ms          5ms          5ms          5ms
  interval        100ms        100ms        100ms        100ms
  pk_delay       1.29ms        108us        179us          1us
  av_delay        334us          8us         22us          0us
  sp_delay         36us          1us          2us          0us
  backlog            0b           0b           0b           0b
  pkts              470         5936         2526           59
  bytes          673153       343896       503442         8025
  way_inds            0           53            0            0
  way_miss          122          538          442           11
  way_cols            0            0            0            0
  drops               0            0            0            0
  marks               0            0            0            0
  ack_drop            0            0            0            0
  sp_flows            3            4            0            1
  bk_flows            0            0            0            0
  un_flows            0            0            0            0
  max_len         15972         1113         1226         1111
  quantum           300         1514         1514          762

qdisc ingress ffff: dev pppoe-wan parent ffff:fff1 ----------------
 Sent 23405937 bytes 21610 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc cake 8005: dev ifb-pppoe-wan root refcnt 2 bandwidth 800Mbit diffserv4 dual-dsthost nonat nowash ingress no-ack-filter split-gso rtt 100ms noatm overhead 38 mpu 84
 Sent 23403490 bytes 21605 pkt (dropped 0, overlimits 26700 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 535296b of 15140Kb
 capacity estimate: 800Mbit
 min/max network layer size:           32 /    1492
 min/max overhead-adjusted size:       84 /    1530
 average network hdr offset:            0

                   Bulk  Best Effort        Video        Voice
  thresh         50Mbit      800Mbit      400Mbit      200Mbit
  target            5ms          5ms          5ms          5ms
  interval        100ms        100ms        100ms        100ms
  pk_delay         14us        464us         86us         33us
  av_delay          0us        284us          7us          1us
  sp_delay          0us          0us          0us          1us
  backlog            0b           0b           0b           0b
  pkts              135        19443         1970           57
  bytes           28768     22954078       400877        19767
  way_inds            0          142            0            0
  way_miss          100          548          353            9
  way_cols            0            0            0            0
  drops               0            0            0            0
  marks               0            0            0            0
  ack_drop            0            0            0            0
  sp_flows            1            4            2            1
  bk_flows            0            2            0            0
  un_flows            0            0            0            0
  max_len          1492         1492         1492         1492
  quantum          1514         1514         1514         1514

1 Like
root@ImmortalWrt:~# tc -s filter show dev pppoe-wan ingress
filter parent ffff: protocol all pref 49152 matchall chain 0
filter parent ffff: protocol all pref 49152 matchall chain 0 handle 0x1
  not_in_hw (rule hit 20725602)
        action order 1: ctinfo zone 0 pipe
         index 1 ref 1 bind 1 dscp 0x0000003f 0x00000080 installed 21415 sec used 0 sec firstused 21415 sec DSCP set 2932249 error 0 CPMARK set 0
        Action statistics:
        Sent 28669731376 bytes 20725602 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

        action order 2: mirred (Egress Redirect to device ifb-pppoe-wan) stolen
        index 1 ref 1 bind 1 installed 21415 sec used 0 sec firstused 21415 sec
        Action statistics:
        Sent 28669731376 bytes 20725602 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

2 Likes

yes seems good now !

just i'm not sure @Hudra but is normal is marked this

 [invalid type] |

See here:

1 Like

hi i has a question

if i put like this result qdisc

diffserv4  dual-srchost nat wash noatm

my output show 0x00 in

tcpdump -i eth1 -vv

but if i put

diffserv4  dual-srchost nat nowash noatm

i has dscp show example 0x80

why ?

i talk to egress qdisc

what is the best ?

thanks

What is your expected behavior when washing dscp on eth1 (egress) with cake?

If your are not sure read here:
https://man7.org/linux/man-pages/man8/tc-cake.8.html#:~:text=wash %20%20%20%20%20%20%20%20%20%20%20%20Traffic%20entering,has%20taken%20place.

1 Like

Because that is what wash does it takes the DSCP value to sort a packet into cake' priority tires and then resets the DSCP value to 0 so on the interface after cake you will only see DSCP 0, if you want to check whether cake works as expected you will need to look at the tc -s qdisc output and see whether the packet/byte counters for the relevant tier increases with supposedly marked packets.

1 Like

my copy in putty bug

just i send only 2 screen with tc qdisc

eth1

ifb-eth1

You can use this method to easily check if packets are hitting the right tin:

or this command:

watch -n 1 'tc -s qdisc show | grep -A 20 -B 2 "diffserv4"'

1 Like

Looks good to me

1 Like

I left both nonat and not wash

in wireshark I see cs4 more

2.168 is my ps5

thanks for all

1 Like

Actually, you can leave wash...

If you're unsure, you can test it by setting both directions (ingress and egress) to 'wash,' then use this command to check if packets are still reaching your voice tin:

watch -n 1 'tc -s qdisc show | grep -A 20 -B 2 "diffserv4"'
1 Like

yes with wash and wash egress and ingress

i has traffic all

and wiresharkshow always cs4

So I know I am the odd one out in this thread (as I am not an active QoS user and always caution to restrict prioritisation games as much as possible*) but I would always leave ICMP out of any strict rules, as that allow to use ping's -t argument to set the TOS bitfield which allows to easily steer test packets into any priority tier... (except windows ping stopped honouring its equivalent setting...)

*) So instead of creating elaborate QoS hierarchies that try to cover all eventualities and games, just create as few rules as possible for a given game you actually play and only bother about other games if you actually plaz them...

3 Likes

Only use nonat, if cake is not running on a router that handles NAT/masquerading...
so on a typical router, on the LAN interface cake does not need the nat keyword but on the WAN interface it really needs it for the dual-xxxhost and triple-isolate fairness modes.

1 Like

I agree, this was meant for testing only...

1 Like

maybe my only impression but your old script with br l'an intégrate seems better in games, thé hit seems a little better good

Do You has compared br l'an with ctinfo in this script

I play on ps5 and FPS You too

My question IS br-lan or ctinfo ? IS very interressing

I don't think the way or place where we apply traffic shaping for downloads affects gaming behavior.

I thought the script was working fine for you?

I believe the inconsistent results you're getting with all the gaming scripts are due to the servers or the game itself. For instance, Warzone or COD servers have been generally poor over the past few weeks, and the game is plagued by numerous bugs. Additionally, other factors like skill-based matchmaking (SBMM) and cheaters can also influence your gameplay.

1 Like

hi @moeller0

if i has a connexion small conexion like this 20 dl and 3 up can you change the cs4 for af41 like your explication

Yes, cake diffserv4 will put all of the following DSCPs into its highest priority tin (Voice):
CS7, CS6, EF, VA, CS5, CS4
whether that is the correct thing to do or not depends a bit on the traffic. if the guaranteed rate is too small for the application it might be better to move the application to the second highest Video-tin (AF4x, AF3x, CS3, AF2x, TOS4, CS2, TOS1) simply because there the guaranteed rate id 50% of the full capacity. As always test whether any of this actually helps.

change DSCP_GAMING CS4 TO AF41

# Unmarked TCP traffic
    meta nfproto ipv4 tcp sport != { 80, 443, 8080, 1935-1936, 2396, 2935 } tcp dport != { 80, 443, 8080, 1935-1936, 2396, 2935 } meta mark != { 40, 41 } meta length 0-1256 limit rate over 200/second burst 100 packets ip dscp cs1 counter meta mark set 45 comment "Packet mark for unmarked TCP traffic of packet lengths between 0 and 1256 bytes that have more than 200 pps"
    meta nfproto ipv4 meta l4proto tcp numgen random mod 1000 < 5 meta mark 45 counter meta mark set 0 comment "0.5% probability of unmark a packet that go over 200 pps to be prioritized to $DSCP_GAMING_COMMENT (TCP)"
    meta nfproto ipv4 meta l4proto tcp meta length 0-77 ct direction reply meta mark 45 counter ip dscp set af41 comment "Prioritize ingress unmarked traffic of packet lengths between 0 and 77 bytes that have more than 200 pps to AF41 (TCP)"
    meta nfproto ipv4 meta l4proto tcp meta length 0-77 ct direction original meta mark 45 counter ip dscp set cs0 comment "Prioritize egress unmarked traffic of packet lengths between 0 and 77 bytes that have more than 200 pps to CS0 (TCP)"
    meta nfproto ipv4 meta l4proto tcp meta length > 77 meta mark 45 counter ip dscp set af41 comment "Prioritize unmarked traffic of packet lengths between 77 and 1256 bytes that have more than 200 pps to AF41 (TCP)"
    meta nfproto ipv4 tcp sport != { 80, 443, 8080, 1935-1936, 2396, 2935 } tcp dport != { 80, 443, 8080, 1935-1936, 2396, 2935 } meta mark != { 40, 41, 45 } meta length 0-1256 ip dscp cs1 counter ip dscp set $DSCP_GAMING comment "Prioritize unmarked traffic of packet lengths between 0 and 1256 bytes that have less than 200 pps to $DSCP_GAMING_COMMENT (TCP)"

    # Unmarked UDP traffic (Some games also tend to use really tiny packets on upload side (same range as ACKs))
    meta nfproto ipv4 udp sport != { 80, 443 } udp dport != { 80, 443 } meta mark != { 42, 43 } meta length 0-1256 limit rate over 250/second burst 100 packets ip dscp cs1 counter meta mark set 50 comment "Packet mark for unmarked UDP traffic of packet lengths between 0 and 1256 bytes that have more than 250 pps"
    meta nfproto ipv4 meta l4proto udp numgen random mod 1000 < 5 meta mark 50 counter meta mark set 0 comment "0.5% probability of unmark a packet that go over 250 pps to be prioritized to $DSCP_GAMING_COMMENT (UDP)"
    meta nfproto ipv4 meta l4proto udp meta length 0-77 ct direction reply meta mark 50 counter ip dscp set af41 comment "Prioritize ingress unmarked traffic of packet lengths between 0 and 77 bytes that have more than 250 pps to AF41 (UDP)"
    meta nfproto ipv4 meta l4proto udp meta length 0-77 ct direction original meta mark 50 counter ip dscp set cs0 comment "Prioritize egress unmarked traffic of packet lengths between 0 and 77 bytes that have more than 250 pps to CS0 (UDP)"
    meta nfproto ipv4 meta l4proto udp meta length > 77 meta mark 50 counter ip dscp set af41 comment "Prioritize unmarked traffic of packet lengths between 77 and 1256 bytes that have more than 250 pps to AF41 (UDP)"
    meta nfproto ipv4 udp sport != { 80, 443 } udp dport != { 80, 443 } meta mark != { 42, 43, 50 } meta length 0-1256 ip dscp cs1 counter ip dscp set $DSCP_GAMING comment "Prioritize unmarked traffic of packet lengths between 0 and 1256 bytes that have less than 250 pps to $DSCP_GAMING_COMMENT (UDP) - Gaming & VoIP"

thanks

@Hudra @moeller0
What is more advisable,
putting only the IP of the game console and letting the script handle everything else or putting the console IP plus all the other device IPs (PHONE, TV, Laptop) IN bulk