1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

QOS of a diffrent sort.

Discussion in 'DD-WRT Firmware' started by kidkl, Oct 18, 2005.

  1. kidkl

    kidkl Network Guru Member

    Since i've seen this asked a few times ill post what i've came up with here.

    One of my freinds pays for the broadband internet connection and shares it wirelessly with his roommate. His roommate ends up running a TON of p2p programs that saturate the upload/download of the connection while my friend is trying to game. He was just turning off the wireless when he wanted to game (bare in mind hes the one paying for the internet and is just being nice by sharing it) I came up with the follwoing QOS settings for him to cap his roomate down to a 512kbit/s down and a 140kbit/s up connection while still retaining full speed for in network transfers.

    Code:
    tc qdisc del dev eth1 root    2> /dev/null > /dev/null
    tc qdisc del dev br0 ingress 2> /dev/null > /dev/null
    
    tc qdisc add dev eth1 root handle 1: htb default 20
    tc class add dev eth1 parent 1: classid 1:10 htb rate 53mbit burst 6k prio 1
    tc class add dev eth1 parent 1:1 classid 1:20 htb rate 140kbit burst 6k prio 2
    tc filter add dev eth1 parent 1: protocol ip prio 13 u32 match ip src 192.168.0.0/23 match ip dst 0.0.0.0/0 flowid 1:20
    tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip src 192.168.0.0/23 match ip dst 192.168.0.0/23 flowid 1:10
    tc qdisc add dev eth1 parent 1:10 handle 10: sfq perturb 10
    tc qdisc add dev eth1 parent 1:20 handle 20: sfq perturb 10
    
    
    tc qdisc add dev br0 handle ffff: ingress
    tc filter add dev br0 parent ffff: protocol ip prio 50 u32 match ip src 192.168.0.0/23 match ip dst 192.168.0.0/23 police rate 100mbit burst 10k drop flowid :1
    tc filter add dev br0 parent ffff: protocol ip prio 51 u32 match ip src 192.168.0.101/32 match ip dst 0.0.0.0/0 police rate 1mbit burst 10k drop flowid :2
    tc filter add dev br0 parent ffff: protocol ip prio 52 u32 match ip src 192.168.0.102/32 match ip dst 0.0.0.0/0 police rate 1mbit burst 10k drop flowid :3
    tc filter add dev br0 parent ffff: protocol ip prio 53 u32 match ip src 192.168.0.121/32 match ip dst 0.0.0.0/0 police rate 1mbit burst 10k drop flowid :4
    tc filter add dev br0 parent ffff: protocol ip prio 55 u32 match ip src 192.168.0.0/23 match ip dst 0.0.0.0/0 police rate 80kbit burst 10k drop flowid :5
    
    
    Let me go through it in a little bit more detail:

    Code:
    tc qdisc add dev eth1 root handle 1: htb default 20
    tc class add dev eth1 parent 1: classid 1:10 htb rate 53mbit burst 6k prio 1
    tc class add dev eth1 parent 1:1 classid 1:20 htb rate 140kbit burst 6k prio 2
    tc filter add dev eth1 parent 1: protocol ip prio 13 u32 match ip src 192.168.0.0/23 match ip dst 0.0.0.0/0 flowid 1:20
    tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip src 192.168.0.0/23 match ip dst 192.168.0.0/23 flowid 1:10
    tc qdisc add dev eth1 parent 1:10 handle 10: sfq perturb 10
    tc qdisc add dev eth1 parent 1:20 handle 20: sfq perturb 10
    
    In the above code basically any ip that is within the 192.168.x.x (actually its limited to 192.168.0.x and 192.168.1.x) network going to the 192.168.x.x network will get full speed downloads on the wireless lan (ie a wlan to lan or wlan to wlan transfer). Anyone on the wireless trying to go out to the internet will get capped at 140kbit/s or 17.5kbytes/s

    Code:
    tc qdisc add dev br0 handle ffff: ingress
    tc filter add dev br0 parent ffff: protocol ip prio 50 u32 match ip src 192.168.0.0/23 match ip dst 192.168.0.0/23 police rate 100mbit burst 10k drop flowid :1
    tc filter add dev br0 parent ffff: protocol ip prio 51 u32 match ip src 192.168.0.101/32 match ip dst 0.0.0.0/0 police rate 1mbit burst 10k drop flowid :2
    tc filter add dev br0 parent ffff: protocol ip prio 52 u32 match ip src 192.168.0.102/32 match ip dst 0.0.0.0/0 police rate 1mbit burst 10k drop flowid :3
    tc filter add dev br0 parent ffff: protocol ip prio 53 u32 match ip src 192.168.0.121/32 match ip dst 0.0.0.0/0 police rate 1mbit burst 10k drop flowid :4
    tc filter add dev br0 parent ffff: protocol ip prio 55 u32 match ip src 192.168.0.0/23 match ip dst 0.0.0.0/0 police rate 80kbit burst 10k drop flowid :5
    
    The first line is again a wlan to lan or lan to lan or wlan to wlan transfer give full speed. The next lines limit the upload rate for 192.168.0.101, 102 and 121 to 1mbit up to the internet (cable connection is 6mbit down 1 mbit up). The last line is basically saying for anyone else trying to upload cap them at 80kbits/s or 10kbytes/s.

    My friends roommate knows enough about computers to be dangerous so he figured out that he could just change his ip to whatever in the 192.168.x.x subnet and then be unfiltered so thats why I came up with the above. The only bad part is basically anything you don't want to be capped you have to enter a qos setting just for them to not be filtered on the upload. If hes not that smart you can enter in the following instead so that it just caps bandwidth for that ip where in this example 101 is the one being limited to 140kbit/s down and 40kbit/s up but still has full lan/wlan transfer speeds:

    Code:
    tc qdisc del dev eth1 root    2> /dev/null > /dev/null
    tc qdisc del dev br0 ingress 2> /dev/null > /dev/null
    
    tc qdisc add dev eth1 root handle 1: htb default 20
    tc class add dev eth1 parent 1: classid 1:10 htb rate 53mbit burst 6k prio 1
    tc class add dev eth1 parent 1:1 classid 1:20 htb rate 140kbit burst 6k prio 2
    tc filter add dev eth1 parent 1: protocol ip prio 13 u32 match ip src 192.168.0.101/32 match ip dst 0.0.0.0/0 flowid 1:20
    tc filter add dev eth1 parent 1: protocol ip prio 1 u32 match ip src 192.168.0.0/23 match ip dst 192.168.0.0/23 flowid 1:10
    tc qdisc add dev eth1 parent 1:10 handle 10: sfq perturb 10
    tc qdisc add dev eth1 parent 1:20 handle 20: sfq perturb 10
    
    tc qdisc add dev br0 handle ffff: ingress
    tc filter add dev br0 parent ffff: protocol ip prio 50 u32 match ip src 192.168.0.0/23 match ip dst 192.168.0.0/23 police rate 100mbit burst 10k drop flowid :1
    tc filter add dev br0 parent ffff: protocol ip prio 51 u32 match ip src 192.168.0.101/32 match ip dst 0.0.0.0/0 police rate 40kbit burst 10k drop flowid :2
    
     

Share This Page