OpenWrt Forum Archive

Topic: TOS with qos-scripts?

The content of this topic has been archived on 27 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, I want to put different TOS' in different QOS classes. Is this possible with qos-scripts?

If it is not possible, will the standard TOS values work? (ie get prioritized correctly)

As far as I know, qos-scripts supports matching and setting tos values, though I have never tried it.

It's possible. I don't know if it can be done directly with qos-scripts though. I just wrote my own script, based on qos-scripts, i.e. run generate.sh all and make the output a script by itself and edit it to your liking. Shaping by TOS, however, is extremely ineffective, unless you set / modify TOS on the router itself. Too many applications don't set the TOS at all, or worse they don't set it correctly, so the results are random at best unless you intervene somehow.

I have some applications that let me specify by hand their priority wink

Have I understood it correct that if I set the a value the scripts in the router will prioritize it correctly?

And what value would I set to down-prio, as I understand the normal seems to be the lowest :S

Here's an example for TOS mangling:

        $BIN_IPT -t mangle -A $FN_PREROUTING -p icmp -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --sport telnet -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --sport ssh -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --sport ftp -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --sport ftp-data -j TOS --set-tos Maximize-Throughput
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --dport telnet -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --dport ssh -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --dport ftp -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp --dport ftp-data -j TOS --set-tos Maximize-Throughput

        # Correcting TOS for large packets with Minimize-Delay-TOS
        $BIN_IPT -t mangle -A $FN_CHK_TOS -p tcp -m length --length 0:512  -j RETURN
        $BIN_IPT -t mangle -A $FN_CHK_TOS -p udp -m length --length 0:1024 -j RETURN
        $BIN_IPT -t mangle -A $FN_CHK_TOS -j TOS --set-tos Maximize-Throughput
        $BIN_IPT -t mangle -A $FN_CHK_TOS -j RETURN

        $BIN_IPT -t mangle -A $FN_PREROUTING -m tos --tos Minimize-Delay -j $FN_CHK_TOS

        # Modifying TOS for TCP control packets: (from www.docum.org / Stef Coene)
        $BIN_IPT -t mangle -A $FN_ACK_TOS -m tos --tos ! Normal-Service -j RETURN
        $BIN_IPT -t mangle -A $FN_ACK_TOS -p tcp -m length --length 0:256 -j TOS --set-tos Minimize-Delay
        $BIN_IPT -t mangle -A $FN_ACK_TOS -p tcp -m length --length 256: -j TOS --set-tos Maximize-Throughput
        $BIN_IPT -t mangle -A $FN_ACK_TOS -j RETURN
        $BIN_IPT -t mangle -A $FN_PREROUTING -p tcp -m tcp --tcp-flags SYN,RST,ACK ACK -j $FN_ACK_TOS

Doing this does not mean that the router will prioritize 'correctly', no. It just changes TOS in a way you specify. Wether you like the results or not is up to you and also depends on the setup as a whole.

I was curious, so I gave matching by TOS a try in qos-scripts:

config reclassify
        option target       "Bulk"
        option tos          "Minimize-Cost"

config reclassify
        option target       "Bulk"
        option tos          "Maximize-Throughput"

config reclassify
        option target       "Bulk"
        option dscp         "CS1"
netprince wrote:

I was curious, so I gave matching by TOS a try in qos-scripts:

config reclassify
        option target       "Bulk"
        option tos          "Minimize-Cost"

config reclassify
        option target       "Bulk"
        option tos          "Maximize-Throughput"

config reclassify
        option target       "Bulk"
        option dscp         "CS1"

nice smile

The discussion might have continued from here.