Ultimate SQM settings: Layer_cake + DSCP marks (New Script!)

My configuration is:

AT&T (DSL) -> Arris router -> x86 openwrt box -> LAN

I got a unifi lite AP connected after the x86 box. Actually, looking in the Arris router configurations, I don't have a DHCPv6.

Question how do you make this script for a network with multiple segments?

Hi there quick question for you, I am missing the command iptmark with my openwrt at present and I have been unable to figure out which packge provides this. Do you know I should install so I can run your script?

A post was split to a new topic: Intranet lan traffic has too many ping spikes

Hello everyone,

I have been searching this forum to find a way to play cs:go with no lag and I have created a post asking for help (SQM qos for cs:go)
Users of the forum was very helpfull, and told me to check this post to set DSCP on my router.

I use a wrt3200ACM and I have installed the David custom firmware : openwrt-mvebu-cortexa9-linksys_wrt3200acm-squashfs-factory.img
Firmware Version : OpenWrt SNAPSHOT r13342-e35e40ad82 / LuCI Master git-20.144.63033-62ed4e6

I have downloaded the package on github : https://github.com/hisham2630/Ultimate-SQM-settings-Layer_cake-DSCP-marks-New-Script

And I was following the old post to check the setup step before doing anything.

My first question is: is it mandatory to have the extroot ? Because if I'm right I then need to install the version 14.07 of OpenWrt ?

After that I will follow the different step and my second and last question will be concerning the /etc/config/sqm

What should I exactly add on it

This is mine :

config queue 'eth1'
        option ingress_ecn 'ECN'
        option debug_logging '0'
        option verbosity '5'
        option script 'piece_of_cake.qos' **> change to : option script 'layer_cake.qos'**
        option qdisc_advanced '1'
        option squash_dscp '1' **> change to 0**
        option squash_ingress '1' **> change to 0**
        option linklayer 'atm'
        option overhead '44'
        option interface 'eth1.2'
        option qdisc 'cake'
        option enabled '1'
        option download '7480'
        option upload '705'
        option egress_ecn 'NOECN'
        option qdisc_really_really_advanced '1'
        option iqdisc_opts 'nat dual-dsthost ingress' **> change to : option iqdisc_opts 'diffserv4 nat dual-srchost'**
        option eqdisc_opts 'nat dual-srchost ack-filter' **> change to : option eqdisc_opts 'diffserv4 nat dual-dsthost '**

Is that correct ?

Thanks

uhurujam

3 Likes

Hello everyone

Awesome work with this script! @hisham2630

Would this work together with vpn-policy-routing, 2 different wireguard clients etc?

Thank you

Just wondering, is something like this needed for a fibre connection? I'm new to openwrt and this all seems alien to me. Running the regular cake sqm I can max out my downloads and my ping is a stable 8-9ms while doing so. Would trying to set this up benefit me at all? I play FPS a lot and would like to learn more how to tweak my connection to give me a better gaming experience

2 Likes

upstream... ( learn lan-ips 6and4 via mac ) payload rules are up to you...

addconsoledynamicipsets() {

ipset create consoles4 hash:ip family inet 2>/dev/null
ipset create consoles6 hash:ip family inet6 2>/dev/null
ipset create consoles list:set 2>/dev/null
ipset add consoles consoles4 2>/dev/null
ipset add consoles consoles6 2>/dev/null

if [ ! -z "$DSCPCONSOLEMACS" ]; then
	for cMAC in $DSCPCONSOLEMACS; do
		echo "consolemac: $cMAC [learnips>dcsp5-6]"; sleep 1

#learndeviceaddresses>ipsets
echo "console $cMAC rule4"
iptables -t mangle -D PREROUTING -m conntrack --ctstate NEW -m mac --mac-source ${cMAC} -j SET --add-set consoles src --exist 2>/dev/null
iptables -t mangle -I PREROUTING -m conntrack --ctstate NEW -m mac --mac-source ${cMAC} -j SET --add-set consoles src --exist

echo "console $cMAC rule6"
ip6tables -t mangle -D PREROUTING -m conntrack --ctstate NEW -m mac --mac-source ${cMAC} -j SET --add-set consoles src --exist 2>/dev/null
ip6tables -t mangle -I PREROUTING -m conntrack --ctstate NEW -m mac --mac-source ${cMAC} -j SET --add-set consoles src --exist


############################ payload rules
#>ip4console4toCSbyproto
iptmark -p tcp -m set --match-set consoles4 src,dst -m multiport ! --ports 80,591,8008,8080,443 -j DSCP --set-dscp-class CS5 -m comment --comment "ConsolesCS5-TCPfrom4"
iptmark -p udp -m set --match-set consoles4 src,dst -m multiport ! --ports 80,591,8008,8080,443 -j DSCP --set-dscp-class CS6 -m comment --comment "ConsolesCS6-UDPfrom4"
#>ip6console6toCSbyproto
ipt6mark -p tcp -m set --match-set consoles6 src,dst -m multiport ! --ports 80,591,8008,8080,443 -j DSCP --set-dscp-class CS5 -m comment --comment "ConsolesCS5-TCPfrom6"
ipt6mark -p udp -m set --match-set consoles6 src,dst -m multiport ! --ports 80,591,8008,8080,443 -j DSCP --set-dscp-class CS6 -m comment --comment "ConsolesCS6-UDPfrom6"

	done
else
		echo "specialmac: CMACS [none]"; sleep 1
fi

}

#DSCPCONSOLEMACS="bb:bb:bb:bb:bb:bb cc:cc:cc:cc:cc:cc"
#addconsoledynamicipsets

1 Like

what is non veth method for mikrotik rb750gr3 please my wan is eth0.2

thanks in advance

At the risk of sounding like a complete idiot, I need to ask what is this all about? isn't SQM supposed to work out of the box with minimal configurations? I mean I configured SQM with cake and I managed to beat bufferbloat, +A in dslreports test, so what are those scripts offering? what I'm missing here?

If you also want to use dedicated priority tiers to have important traffic bypass background traffic, you need to propetly assign dscp marks before sqm gets hold of the packets, and especially for ingress traffic that is a bit of a challenge. A challenge this thread accepted and found a solution for.

1 Like

Ah I see, that's interesting! Actually I asked the question in the first place as I have a problem when playing some P2P games on Dolphin Emu, I get a high packet loss percentage while talking with my friends over any VoIP services, that lead the emulator to desync or worst disconnect completely.

I don't suffer from these symptoms if I don't use VoIP, so I thought that these scripts could help me in this situation.

Hi

I am using this configuration.

I have done it in my Rpi4. eth1 is my wan and eth0 is my lan. Do I need to change any value in the script? And how do I check this script is working?

Thanks
Badri M

I try to run this command - tc -s qdisc - and I see packet loss. Am I doing any mistake?

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 cake 800d: dev eth0 root refcnt 6 bandwidth 680960Kbit besteffort dual-srchost nat nowash no-ack-filter split-gso rtt 100ms noatm overhead 44
 Sent 13692257243 bytes 10536822 pkt (dropped 2, overlimits 2102947 requeues 957)
 backlog 0b 0p requeues 957
 memory used: 666454b of 15140Kb
 capacity estimate: 680960Kbit
 min/max network layer size:           28 /    1500
 min/max overhead-adjusted size:       72 /    1544
 average network hdr offset:           14

                  Tin 0
  thresh     680960Kbit
  target            5ms
  interval        100ms
  pk_delay         11us
  av_delay          2us
  sp_delay          1us
  backlog            0b
  pkts         10536824
  bytes     13692260219
  way_inds       393121
  way_miss        44393
  way_cols            0
  drops               2
  marks               0
  ack_drop            0
  sp_flows            2
  bk_flows            1
  un_flows            0
  max_len         15140
  quantum          1514

qdisc ingress ffff: dev eth0 parent ffff:fff1 ----------------
 Sent 514871764 bytes 4031393 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc cake 8011: dev eth1 root refcnt 2 bandwidth 35840Kbit besteffort dual-srchost nat nowash no-ack-filter split-gso rtt 100ms noatm overhead 44
 Sent 563488435 bytes 3974790 pkt (dropped 0, overlimits 696989 requeues 5)
 backlog 0b 0p requeues 5
 memory used: 77056b of 4Mb
 capacity estimate: 35840Kbit
 min/max network layer size:           28 /    1500
 min/max overhead-adjusted size:       72 /    1544
 average network hdr offset:           14

                  Tin 0
  thresh      35840Kbit
  target            5ms
  interval        100ms
  pk_delay         27us
  av_delay          3us
  sp_delay          2us
  backlog            0b
  pkts          3974790
  bytes       563488435
  way_inds       166811
  way_miss        41609
  way_cols            0
  drops               0
  marks               0
  ack_drop            0
  sp_flows            2
  bk_flows            1
  un_flows            0
  max_len          1514
  quantum          1093

qdisc ingress ffff: dev eth1 parent ffff:fff1 ----------------
 Sent 13128931977 bytes 10478376 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc cake 800e: dev ifb4eth0 root refcnt 2 bandwidth 35840Kbit besteffort dual-dsthost nat wash ingress no-ack-filter split-gso rtt 100ms noatm overhead 44
 Sent 571631446 bytes 4031386 pkt (dropped 7, overlimits 592111 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 327488b of 4Mb
 capacity estimate: 35840Kbit
 min/max network layer size:           46 /    1500
 min/max overhead-adjusted size:       90 /    1544
 average network hdr offset:           14

                  Tin 0
  thresh      35840Kbit
  target            5ms
  interval        100ms
  pk_delay        173us
  av_delay          9us
  sp_delay          5us
  backlog            0b
  pkts          4031393
  bytes       571638602
  way_inds       165738
  way_miss        68883
  way_cols            0
  drops               7
  marks               0
  ack_drop            0
  sp_flows            3
  bk_flows            1
  un_flows            0
  max_len          8964
  quantum          1093

qdisc cake 8012: dev ifb4eth1 root refcnt 2 bandwidth 680960Kbit besteffort dual-dsthost nat wash ingress no-ack-filter split-gso rtt 100ms noatm overhead 44
 Sent 13633185655 bytes 10478296 pkt (dropped 80, overlimits 2155173 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 1782984b of 15140Kb
 capacity estimate: 680960Kbit
 min/max network layer size:           46 /    1500
 min/max overhead-adjusted size:       90 /    1544
 average network hdr offset:           14

                  Tin 0
  thresh     680960Kbit
  target            5ms
  interval        100ms
  pk_delay        258us
  av_delay        101us
  sp_delay          5us
  backlog            0b
  pkts         10478376
  bytes     13633304009
  way_inds       226773
  way_miss        40821
  way_cols            0
  drops              80
  marks               0
  ack_drop            0
  sp_flows            1
  bk_flows            1
  un_flows            0
  max_len         68130
  quantum          1514

Thanks
Badri M

Nope packet drops are normal, that is how congested links behave and hence what TCP waits for... That is TCP will slowly increase its transmission rate until it encounters packet drops, at which point it will scale back to classically 50% transmission rate and again slowly ramp up. The goal is that TCP will adapt to a link's capacity. AQMs like cake or fq_codel now selectively drop a few packets to signal individual flows to slow down with the aim to give each flow its fair share of the capacity.
This is a bit simplified, but in short a few drops are not only benign but essential for TCP to function.

1 Like

Thanks for the clarification.

Badri M

hello everybody i have make a video for your sqm script hisham is correct you think ? thanks

1 Like

Did anyone attempt running hisham's script on netgear R7800. If yes please share the used installation routine and your results

Do you have the TEXT-SCRIPT ?

no i'm returned to mikrotik routerOS for testing im' search script rsc now for my better experience gaming

1 Like