Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

[Release] FreshJR Adaptive QOS (Improvements / Custom Rules / and Inner workings)

Discussion in 'Asuswrt-Merlin' started by FreshJR, Jan 12, 2017.

  1. FreshJR

    FreshJR Regular Contributor

    Joined:
    Oct 8, 2016
    Messages:
    174
    To my knowledge the actual traffic control scheduling/filtering/etc actions are taken place inside at kernel level.
    The tc binary (application) just configures the kernel by passing commands into it or retrieving parameters from it.

    This means our overall feature set is limited to what the kernel offers, but tc newer binary can have more "blueprints" available to work with the materials available inside the "kernel".
    At least this is how I think it works. I am not very well versed in this area.

    The current realTC merlin is using has a special fq_codel (lite) backported specially to work with out limited kernel. So this custom realTC we are using is going to be better than the standard TC binaries.

    Iptables and TC rules both support AND (multi-match) rules.

    DOWNLOAD RULE:

    Code:
    ${tc} filter add dev br0 protocol all prio 1 u32 match u32 0xCCDDEEFF 0xffffffff at -16 match ip dport 4500 0xffff  flowid {VOIP}
    
    Let me break it down line by line, so you can see the two matches simulanously
    
    ${tc} filter add dev br0 protocol all prio 1 u32
    match u32 0xCCDDEEFF 0xffffffff at -16
    match ip dport 1234 0xffff
    flowid {VOIP}
    
    
    UPLOAD RULE (note perform delete before append):

    Code:
    iptables -D POSTROUTING -t mangle -o eth0 -m mac --mac-source AA:BB:CC:DD:EE:FF -p tcp --sport 1234 -j MARK ${VOIP_mark}
    
    iptables -A POSTROUTING -t mangle -o eth0 -m mac --mac-source AA:BB:CC:DD:EE:FF -p tcp --sport 1234 -j MARK ${VOIP_mark}
    
    Let me break it down again
    
    iptables -A POSTROUTING -t mangle -o eth0
    -m mac --mac-source AA:BB:CC:DD:EE:FF
    -p tcp --sport 1234
    -j MARK ${VOIP_mark}
    
    
     
    Last edited: Sep 9, 2017
    Vexira, charlie2alpha and MarCoMLXXV like this.
  2. charlie2alpha

    charlie2alpha Senior Member

    Joined:
    Nov 15, 2014
    Messages:
    353
    Location:
    Greece
    Excellent. I'll try the script soon, I'm looking for a replacement of traditional QoS and this script seems to be it.
     
  3. MarCoMLXXV

    MarCoMLXXV Guest

    Without the intention to diminish all the hard work @FreshJR has put in this great script, but if you upgrade to the current stable release of Asuswrt-Merlin (380.68), you'll most likely will already be amazed by the improvements @RMerlin has made to Adaptive QoS, specifically by adding the fq_codel discipline. There's nothing 'traditional' about it anymore and it works great out of the box, with some simple, minor configuration (choose which discipline you want to use, defining your bandwith etc.).

    Having said that, @FreshJR has managed to take that even a step further, by allowing you to define max bandwidth per category, adding custom rules, the ability for unidentified traffic to have it being redirected to the right category, so it's get the right priority. If you upgrade, you'll be in for a treat :) (don't forget to read the 380.68 changelog as there are some major changes, specifically to the UI which you need to be aware of and follow the instructions!)
     
  4. charlie2alpha

    charlie2alpha Senior Member

    Joined:
    Nov 15, 2014
    Messages:
    353
    Location:
    Greece
    Custom rules are a must for my use case. Tried Adaptive QoS in the not so distant past and it was worthless for me. It's major flaw (which makes it a success in generic consumer use cases!) for me is it's lack of customization and that causes most of my traffic to end up as unknown.

    Sent from my Nexus 9 using Tapatalk
     
  5. MarCoMLXXV

    MarCoMLXXV Guest

    then I think you've come to the right place :) I don't use any custom rules, very satisfied as it's running currently, but there are many around here with specific knowledge way over my head...
     
    charlie2alpha likes this.
  6. strangeluck

    strangeluck Occasional Visitor

    Joined:
    Aug 11, 2015
    Messages:
    47
    fq_codel is definitely a big improvement, but the limits as set in the Asus defaults are borderline worthless. I wouldn't recommend anyone run adaptive QoS without this script. See the first post in this thread for a good explanation of how terrible the Asus implementation is.
     
  7. MarCoMLXXV

    MarCoMLXXV Guest

    That's absolutely true, but for those with no interest in running and editing custom scripts, thinking ssh is short for shush, fq_codel is definitely an improvement over the previous available diciplines, even with Asus ridiculous preset boundaries.
     
    Vexira likes this.
  8. strangeluck

    strangeluck Occasional Visitor

    Joined:
    Aug 11, 2015
    Messages:
    47
    Heh, good point. Any QoS implementation is probably better than none for most people.
     
    Vexira likes this.
  9. Vexira

    Vexira Very Senior Member

    Joined:
    Jan 20, 2017
    Messages:
    855
    Location:
    Australia
    asus should be more open with traffic detection, they need a way to allow users to submit requsts for games to be added to classification or devices
     
  10. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    24,608
    Location:
    Canada
    Nothing custom about realtc, it's just a copy of the regular tc. This is so it can be called by the script that patches itself on top of "tc", intercept parameters, modify them, then pass them along to realtc.

    The fq_codel code resides entirely in the kernel (aside from tc needing to be a recent enough version to handle the fq_codel and overhead parameters).
     
  11. MarCoMLXXV

    MarCoMLXXV Guest

    If I understood correctly, even Asus is not to blame, as they can't change anything about that, they've just decided to use closed, proprietary code from Trend Micro (good code, used in there enterprise solutions as well) in our router's firmware. But I agree with you, they should either keep it fully up to date (if ever possible, as every user has it's own preferences/requirements and there will probably not be a way to satisfy each and every one of them) or allow user requests so they can modify traffic detection to fit our needs.
     
  12. Vexira

    Vexira Very Senior Member

    Joined:
    Jan 20, 2017
    Messages:
    855
    Location:
    Australia
    sry I mean they should have a way for us to make requests that they pass on to trend.
     
    MarCoMLXXV likes this.
  13. MarCoMLXXV

    MarCoMLXXV Guest

    So, if I understand you correctly, when using QoS, one shouldn't install tc from entware-ng, as it won't have the patches applied needed for QoS currenlty?
     
  14. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    24,608
    Location:
    Canada
    The source code is not patched. The patch is done at the filesystem level, where all calls to /usr/sbin/tc are redirected to faketc, which modifies the parameters, before handing them over to realtc.
     
  15. maxsteel

    maxsteel Occasional Visitor

    Joined:
    Dec 27, 2014
    Messages:
    25
    Am I missing something guys? My connection is more stable with ATM unchecked and overhead set to Zero instead of 40 (since I use ADSL) ?
     
  16. Vexira

    Vexira Very Senior Member

    Joined:
    Jan 20, 2017
    Messages:
    855
    Location:
    Australia
    thats odd what modem are you using?
     
  17. beboptrumpet

    beboptrumpet Occasional Visitor

    Joined:
    Nov 15, 2013
    Messages:
    41
    Location:
    Indianapolis, IN, USA
    IMG_1116.PNG
    Does setting a custom order or setting it to prioritize game, streaming, or web surfing do anything while running this script?
     
  18. Tomo

    Tomo New Around Here

    Joined:
    Apr 28, 2016
    Messages:
    2
    Hi FreshJR, thank you for the great job.

    I'm using the 380.68 Merlin firmware on my Ac68U with automatic Qos ( manual bandwith, fq_codel), i have a Adsl2+ 20/1.

    I wanted try your script but i'm not very expert, i changed the ip of the router from 192.168.1.1 to 10.0.0.1 and i wanted know if i need change some things in the script (ip router and bandwith for 20/1) before send it.

    Then i discovered that the game GuildWars2 isn't recognise from Trend Micro Engine, any chance in the future to optimizing the script in this case ?

    Thank you !
     
  19. FreshJR

    FreshJR Regular Contributor

    Joined:
    Oct 8, 2016
    Messages:
    174
    No nothing needs changing.

    When you are installing, on the pscp step change the ip from 192.168.1.1 to your 10.0.0.1 router ip.

    As for guild wars, find out what port it uses and add a custom rule.
     
    Tomo likes this.
  20. charlie2alpha

    charlie2alpha Senior Member

    Joined:
    Nov 15, 2014
    Messages:
    353
    Location:
    Greece
    So I have the script a try, unfortunately my iptables rules although they appear correct they do not seem to work. The counters remain always at zero, which means no packets are ever marked.

    Everything I read about the DPI engine suggest that iptables rules are useless as the packet marking is completely overridden by the DPI engine itself.

    I had partial success with some tc rules only but tc rules are just too limited for the filtering I need. I'm afraid that I'm stuck with the traditional QoS for now and that means that I am also stuck with firmware 380.65_4 since anything newer breaks IPv6 mangle handling. Bummer.
     
    Last edited: Sep 12, 2017

Share This Page