Created
October 9, 2019 09:53
-
-
Save fsamareanu/3e988f0968a60501e62148092f555a72 to your computer and use it in GitHub Desktop.
My short cake crash course
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set cake as qdisc and bbr as your congestion control (either from shell or add them to sysctl.conf or your OS equivalent) | |
sysctl net.core.default_qdisc=cake | |
sysctl net.ipv4.tcp_congestion_control=bbr | |
#Replace the root qdisc to cake diffserv4 (we get 4 distinct queues this way). Replace enp0231f6 with your interface name: | |
/sbin/tc qdisc replace root dev enp0s31f6 cake ethernet diffserv4 wash | |
#Check output. Queue priority (from lowest to highest) is bulk<best effort<video<voice. It should be similar to below one: | |
tc -s qdisc show dev enp0s31f6 | |
qdisc cake 8028: root refcnt 2 bandwidth unlimited diffserv4 triple-isolate nonat wash no-ack-filter split-gso rtt 100.0ms noatm overhead 38 mpu 84 | |
Sent 110902499451704 bytes 2245544728 pkt (dropped 258725334, overlimits 0 requeues 3815608646) | |
backlog 0b 0p requeues 3815608646 | |
memory used: 5786310b of 15140Kb | |
capacity estimate: 0bit | |
min/max network layer size: 21 / 1500 | |
min/max overhead-adjusted size: 84 / 1538 | |
average network hdr offset: 14 | |
Bulk Best Effort Video Voice | |
thresh 0bit 0bit 0bit 0bit | |
target 5.0ms 5.0ms 5.0ms 5.0ms | |
interval 100.0ms 100.0ms 100.0ms 100.0ms | |
pk_delay 5us 34us 27us 4us | |
av_delay 2us 3us 2us 0us | |
sp_delay 0us 0us 0us 0us | |
backlog 0b 0b 0b 0b | |
pkts 3507231516 3192674174 97009583 2322085 | |
bytes 74953140009638 36196052900705 134675833305 246350387 | |
way_inds 3124849622 3685021084 560217 11411 | |
way_miss 26110415 11746396 724773 503043 | |
way_cols 329469 110845 0 0 | |
drops 253089563 5635584 187 0 | |
marks 2665014 138610 0 0 | |
ack_drop 0 0 0 0 | |
sp_flows 85 4 4 1 | |
bk_flows 2 1 0 0 | |
un_flows 0 0 0 0 | |
max_len 69278 69278 66616 590 | |
quantum 1514 1514 1514 1514 | |
#Add iptables rules | |
iptables -t mangle -N set_dscp_prio_bulk | |
iptables -t mangle -N set_dscp_prio_besteffort | |
iptables -t mangle -N set_dscp_prio_video | |
#Plex source ports + http server source port | |
iptables -t mangle -A OUTPUT -o enp0s31f6 -p udp -m multiport --sports 443,32400,32401 -j set_dscp_prio_video | |
iptables -t mangle -A OUTPUT -o enp0s31f6 -p tcp -m multiport --sports 443,32400,32401 -j set_dscp_prio_video | |
#Deluge is listening on port 8999 for torrent traffic | |
iptables -t mangle -A OUTPUT -o enp0s31f6 -p udp -m udp --sport 8999 -j set_dscp_prio_besteffort | |
iptables -t mangle -A OUTPUT -o enp0s31f6 -p tcp -m tcp --sport 8999 -j set_dscp_prio_besteffort | |
#Rtorrent is listening on port 64333 for torrent traffic | |
iptables -t mangle -A OUTPUT -o enp0s31f6 -p udp -m udp --sport 64333 -j set_dscp_prio_bulk | |
iptables -t mangle -A OUTPUT -o enp0s31f6 -p tcp -m tcp --sport 64333 -j set_dscp_prio_bulk | |
#Now we add the mark so that cake assigns the traffic to the correct queue: | |
iptables -t mangle -A set_dscp_prio_besteffort -j DSCP --set-dscp 0x00 | |
iptables -t mangle -A set_dscp_prio_besteffort -j ACCEPT | |
iptables -t mangle -A set_dscp_prio_bulk -j DSCP --set-dscp 0x08 | |
iptables -t mangle -A set_dscp_prio_bulk -j ACCEPT | |
iptables -t mangle -A set_dscp_prio_video -j DSCP --set-dscp 0x18 | |
iptables -t mangle -A set_dscp_prio_video -j ACCEPT | |
#Check output real time and see the counters increasing: | |
watch -t tc -s qdisc show dev enp0s31f6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment