Script for switching QoS configurations, triggered by ports?

Discussion in 'Tomato Firmware' started by Jones69, May 23, 2011.

  1. Jones69

    Jones69 Networkin' Nut Member


    I am a total noob to tomato and to linux scripting, so building scripts for my router myself is out of reach for me right now and this topic is very huge and complicated for a newcomer. :eek:

    My problem, a quite common one, is: I "simply" want to get good pings in online games, no matter what others do in the network, which usually is surfing and streaming youtube. No P2P at least. :tongue:

    I have read forums and tutorials for days now and understand, that I have to prevent saturation of the given bandwidth for QoS to work properly. I (think I) understand how to classify my gaming traffic, how to priorize it over the rest and so on (select by port, class "highest", no restrictions, top position in classification list). But still one big problem is unsolved:

    I need to limit other download traffic way too much to get good results. On my 1 Mbit DSL, I need to limit other inbound traffic to at least 66% of the available bandwidth until streaming & co. has no remarkeble effect to the gaming ping any more. I got this value out of one of the tutorials here and found it to be true for my line by testing. While this extreme limitation is an acceptable solution while playing, it is not acceptable to permanently limit a home network to nearly half of it's bandwidth, even, when no games are played and no limitation would be needed at all. (Except of moderate saturation prevention of course)

    Right now I manually change this configuration setting before and after a gaming session, but I am sure, there is a way to manage this changing automatically.

    What I had in mind was a solution like this:

    You all know port triggering, where the use of a port opens other ports, and, after a while of not using the trigger port, closes it again.

    Now imagine:

    A list of ports given. If any of the ports in the list is used, tomato switches to another QoS configuration which is optimized for the special needs of the applications, that use these ports. E.g. a gaming configuration for gaming ports. After a while of not using any port from the list, it switches back to the default configuration.

    Is there anything out there like this, any mod with such a funtion built in, or any skilled scripter willing to give this idea a try? :)

    Sincerely, Jones69
  2. Azuse

    Azuse LI Guru Member

    The whole point of qos is it limits traffic by priority. There's absolutely zero reason for any type of switching and any who thinks their is* needs to take a good look at the qos and set it up correctly.

    Consider posting/reading here

    *inbound qos could do with some polish ;)
  3. Jones69

    Jones69 Networkin' Nut Member

    Thank you for the link.

    Unfortunately this tutorial is Toastman's QoS tutorail I referred to in my posting. I read it completely, used it to set up priorizing and all just as described. And after doing so, I experience the problems I described in detail in my posting.

    You might want to have a short look at the two graphs, Toastman attached to his great guide or read his short explanation why you need a good part of the bandwith reserved to achieve a good latency, and where he states that, on a 1.5MBit line this value would be at least 34%. So you see, that my adressed problem can NOT be solved by setting up the QoS "correctly" for at least 1.5 MBit/s lines or below. Except if you want to accept to permanently loose at least 40% of your inbound bandwidth for a 1MBit line, no matter if good latency is needed or not.

    "Correct" QoS settings for a 1MBit line means: Live with a limited line down to 600 kbit/s (hundred, not thousand) which hurts alot and was the reason for my posting. All I asked for was a solution to autumatically remove this necessary limitation when it is not needed.

    There are very many people who still have to live with small banwidths like mine without any alternatives, and usually those lines already have bad latency. There really is no need to make a bad latency even worse or to permanently limit a small line to a very much smaller line.

    But thank you anyway. If I did not know the tutorial, it would surely have been a great start.
  4. Azuse

    Azuse LI Guru Member

    Unfortunately the limitation of inbound qos is delay. The real problem is so many games like to use upnp or random ports but if you have specific ones then it would, in theory, be possible.

    The qos gui is simply a gui for writing firewall rules i.e. you could manually write qos rules there just like dd-wrt but it's a pain hence there's a gui. Now it would take a lot of testing, but if you created one set of qos rules for regular use and a second for gaming and set a port, or port list, as the trigger for switching qos rules then it should work. That's the basis for the virgin media script so many people use, but those triggers are data used.
  5. Toastman

    Toastman Super Moderator Staff Member Member

    I believe someone did write something along those lines a while back, maybe a year or so. It may be hard to find, or I may be wrong, but try trawling though this forum and also and see what you can find.
  6. Jones69

    Jones69 Networkin' Nut Member

    That was exactly what I had in mind, but no idea how to realize it and no starting point yet, from where to start learnig about it.

    Hmm, sounds good. Do you have any link that could direct me to this script? Google just directed me to virgin media, which may be right, but I cannot find a scipt besides a monitoring script. Or was it this one you were talking about?
  7. tievolu

    tievolu Network Guru Member

    This is the VM STM Monitoring script:

    It switches QOS policies based on data usage, as mentioned above. To apply a new QOS policy, you set the relevant nvram variables for the aspects you want to change, then restart the QOS service. For example:

    # Set QOS NVRAM variables
    nvram set qos_obw=2048
    nvram set qos_ibw=8192
    # Restart QOS
    service qos restart
    Relevant nvram variables include:

       qos_ibw - inbound bandwidth
       qos_obw - outbound bandwidth
    qos_irates - inbound rates
    qos_orates - outbound rates
    qos_orules - outbound rules
    My VM script only modifies the inbound/outbound rates and bandwidth, so I'm not sure about the syntax for the outbound rules variable, which seems to be the one you need to concentrate on. If I were you I would configure the policies using the GUI then examine the values on the command line (using "nvram get [variable]"), then you don't have to worry about understanding the syntax.

    This covers only one half of what you want to do though - I have no idea how you would got about triggering the QOS policy change based on port activity.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice