Dynamic QOS max bandwidth setting?

Discussion in 'Tomato Firmware' started by blackjackel, Aug 26, 2009.

  1. blackjackel

    blackjackel LI Guru Member

    I'm wondering if there is a way to make it the max bandwidth setting depend on something else... a script maybe?

    Basically when Im playing games I want the max bandwidth setting reduced to say 600 but when im not I want it at 700 or so...

    So maybe the script would look at active ports... when port XXXX is active then set max bandwidth to XXXX when port XXX inactive set max bandwidth to XXXX

    is this possible or easy in any way?
  2. david101

    david101 Addicted to LI Member


    i realise this is old--and i actually found it by chance, searching the forum for something else! but i did exactly this, so i'll share with you what i did, even if it ends up helping someone else in the future (gotta give back to the community for pointing out my own mistake in making my script :p)

    here is the code:

    sleep 10
    while sleep 30; do
    #	sleep 3
    	if [ `cat /proc/net/ip_conntrack | grep -c 'dport=7777 '` -ge 1 -a `nvram get qos_ibw` -eq 9999 ]; then 
    		nvram set qos_ibw=4520
    		service qos restart
    		logger qos_ibw=4520
    	elif [ `cat /proc/net/ip_conntrack | grep -c 'dport=7777 '` -eq 0 -a `nvram get qos_ibw` -eq 4520 ]; then
    		let count=count+1
    		if [ $count -eq 5 ]; then
    			nvram set qos_ibw=9999
    			service qos restart
    			logger qos_ibw=9999
    #	echo `nvram get qos_ibw` and num_conn is `cat /proc/net/ip_conntrack | grep -c 'dport=7777 '`
    put this in script-->initialization. probably not the bestscript, but my router has been up 40 days and all seems good, so its good enough i think :p

    settings to change:
    7777 is the DESTINATION game port, so obviously change if the game is not unreal tournament
    the count variable i have is because the router 'updates' the entry of udp 'connections' (the timeout part changes) and sometime when i do the grep search it wont find it (this is my only explanation). sooo you could increase the count to 6 or 7 instead of 5 if you want, but it'll take more than the (5*30) seconds it takes now to change the bandwidth back.

    oops, obv change 9999 to whatever you want it to be by default, and 4520 to whatever you want it to be while in-game. (and change qos_ibw to qos_obw if thats what you want...inbound to outbound)
  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