Need help with HTB

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Hello,

 1.

 I currently have a 128kbps cable link to the internet..and I'm sharing
 this connection with others.
 I've made the following script(for alocating bandwidth depending on the
 services used: browsing, squid, games like counter-strike, icmp, ssh),
 which unfortunately isn't working very well  as the response times I'm
 getting upon pinging the server are almost the same I get without the
 htb script being loaded.
 Any ideas ?

 Here goes my script:
 where eth1 = the internal network card
            eth0 = the link to my ISP

 ipt="/sbin/iptables"
 tc="/sbin/tc"
 IF_EXT=eth0
 IF_LOC=eth1


########################################################################
 #####
 $tc qdisc del dev $IF_EXT root
 $tc qdisc add dev $IF_EXT handle 1: root htb default 99 r2q 1
 $tc class add dev $IF_EXT parent 1: classid 1:1 htb rate 100kbit
 $tc class add dev $IF_EXT parent 1:1 classid 1:2 htb rate 20kbit ceil
 20kbit prio 1
 $tc class add dev $IF_EXT parent 1:1 classid 1:3 htb rate 60kbit ceil
 90kbit prio 3
 $tc class add dev $IF_EXT parent 1:1 classid 1:99 htb rate 20kbit ceil
 90kbit prio 7

 //I'm letting 1:2 use FIFO...for low-latency
 $tc qdisc add dev $IF_EXT parent 1:3 handle 30: sfq perturb 10
 $tc qdisc add dev $IF_EXT parent 1:99 handle 990: sfq perturb 10

 # ICMP
 $tc filter add dev $IF_EXT protocol ip prio 1 parent 1: u32 \
         match ip protocol 1 0xff flowid 1:2

 #Counter-strike
 $tc filter add dev $IF_EXT protocol ip prio 1 parent 1: u32 \
         match ip dport 27015 0xffff flowid 1:3
 $tc filter add dev $IF_EXT protocol ip prio 1 parent 1: u32 \
         match ip dport 28015 0xffff flowid 1:3

 # TOS Minimum Delay (ssh, NOT scp) in 1:10:
 $tc filter add dev $IF_EXT protocol ip prio 2 parent 1: u32 \
       match ip tos 0x10 0xff  flowid 1:3

 ######################################
 #acks
 $tc filter add dev $IF_EXT parent 1: protocol ip prio 2 u32 \
    match ip protocol 6 0xff \
    match u8 0x05 0x0f at 0 \
    match u16 0x0000 0xffc0 at 2 \
    match u8 0x10 0xff at 33 \
    flowid 1:3
 #dns query-uri
 $tc filter add dev $IF_EXT protocol ip prio 2 parent 1: u32 \
         match ip dport 53 0xffff flowid 1:3

 #############################################
 # other services - web + irc
 $tc filter add dev $IF_EXT parent 1: protocol ip prio 2 u32 \
         match ip dport 80 0xffff flowid 1:3
 $tc filter add dev $IF_EXT parent 1: protocol ip prio 2 u32 \
         match ip dport 6667 0xffff flowid 1:3
 #############################################
 # All others go to 1:99
 $tc filter add dev $IF_EXT protocol ip prio 2 parent 1: u32 \
        match ip dst 0.0.0.0/0 flowid 1:99


########################################################################
 ##################


 and for download I have the following:

 $tc qdisc del dev $IF_LOC root
 $tc qdisc add dev $IF_LOC handle 2: root htb default 99 r2q 1
 $tc class add dev $IF_LOC parent 2: classid 2:1 htb rate 100kbit

 $tc class add dev $IF_LOC parent 2:1 classid 2:2 htb rate 70kbit ceil
 90kbit prio 1
 $tc class add dev $IF_LOC parent 2:1 classid 2:99 htb rate 30kbit ceil
 90kbit prio 5

 #PRIO FIFO...for 2:2 = low latency for counter-strike packets
 $tc qdisc add dev $IF_LOC parent 2:99 handle 299: sfq perturb 10

 #Counter-strike
 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
         match ip dport 27005 0xffff flowid 2:2
 #WEB
 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
         match ip sport 80 0xffff flowid 2:2
 #SQUID
 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
         match ip sport 3128 0xffff flowid 2:2

 # Restu
 $tc filter add dev $IF_LOC protocol ip prio 1 parent 2: u32 \
        match ip dst 0.0.0.0/0 flowid 2:99

 pinging the server without htb script loaded:
 [mihai@...mihai]$ ping -c 5 ip
 PING ip(ip) from .....: 56(84) bytes of data.
 64 bytes from ip: icmp_seq=1 ttl=60 time=94.0 ms
 64 bytes from ip: icmp_seq=2 ttl=60 time=41.3 ms
 64 bytes from ip: icmp_seq=3 ttl=60 time=10.4 ms
 64 bytes from ip: icmp_seq=4 ttl=60 time=25.5 ms
 64 bytes from ip: icmp_seq=5 ttl=60 time=14.1 ms

 --- ip ping statistics ---
 5 packets transmitted, 5 received, 0% loss, time 4036ms
 rtt min/avg/max/mdev = 10.454/37.105/94.057/30.443 ms

 pinging the server with htb script loaded:

 [mihai@.. mihai]$ ping -c 5 ip_addr
 PING ip(ip) from ...: 56(84) bytes of data.
 64 bytes from ip: icmp_seq=1 ttl=60 time=31.1 ms
 64 bytes from ip: icmp_seq=2 ttl=60 time=11.8 ms
 64 bytes from ip: icmp_seq=3 ttl=60 time=38.5 ms
 64 bytes from ip: icmp_seq=4 ttl=60 time=94.8 ms
 64 bytes from ip: icmp_seq=5 ttl=60 time=31.5 ms

 --- ip ping statistics ---
 5 packets transmitted, 5 received, 0% loss, time 4041ms
 rtt min/avg/max/mdev = 11.839/41.584/94.829/28.064 ms

 and tc -s qdisc shows:
 tc -s qdisc
 qdisc sfq 990: dev eth0 quantum 1514b perturb 10sec
  Sent 7574 bytes 75 pkts (dropped 0, overlimits 0)

  qdisc sfq 30: dev eth0 quantum 1514b perturb 10sec
  Sent 123614 bytes 1413 pkts (dropped 0, overlimits 0)

  qdisc htb 1: dev eth0 r2q 1 default 99 direct_packets_stat 0
  Sent 149780 bytes 1678 pkts (dropped 87, overlimits 0)

  qdisc sfq 299: dev eth1 quantum 1514b perturb 10sec
  Sent 824005 bytes 1000 pkts (dropped 0, overlimits 0)
  backlog 3p

  qdisc htb 2: dev eth1 r2q 1 default 99 direct_packets_stat 2
  Sent 1055635 bytes 1398 pkts (dropped 0, overlimits 2046)

 2.

 I have the same problem with a htb script on an adsl connection (with
 the htb script I get ping response times of 80-90..without it I get
 200-300 ms...but these response times aren't very stable..it's
something
 like I'm getting 40 ms..then 100 ms..then 50 ms..)

 Sorry about the size of this message.

 Hope you can help,
Mihai Tanasescu



_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux