[LARTC] Basic HTB shaping configuration

2004-03-03 Thread John Buttery
  I'm trying to create a relatively simple traffic shaping environment;
basically, we're a home network with three different classes of traffic:

  1) High-priority, which means usually low bandwidth but very demanding
latency requirements.  In English: online gaming.  :)
  2) Medium-priority, which includes most of what people think of as
normal Internet traffic.  Web browsing, email, USENET, IRC, etc.
  3) Low-priority, which includes bulk traffic like big file downloads.

  Basically, the cake that I'm trying to have and eat it too is where we
can be running a bunch of stuff like BitTorrent clients to download new
Quake maps, and still be playing Battlefield 1942 without getting
hammered on by the P2P clients' data transfers and node-building
traffic.
  This is what I have so far; it has made a definite improvement for
prio 1 traffic (the medium stuff, web browsing and such) but doesn't
seem to be enough; online gaming is still quite laggy while the file
transfers and such are active.  At this point it seems that what I
basically need to do is tweak the values of the $UPSTREAM_* variables,
but I thought I might ask here first to see if there's an entire
design-level improvement to be made.
  The basic idea is that medium traffic should be able to stomp on
low traffic (represented by the default case) when it needs
bandwidth/latency, and that high traffic should be able to stomp on
both medium and low when it needs bandwidth/latency...but the lower
classes can borrow bandwidth when the classes that outrank them aren't
using it.
  From reading the parts of the HOWTO that I could get my mind around, I
understand that only outbound traffic can be molded, so the script below
makes no attempt to do anything with inbound traffic.

  In a tangentally-related question, I'm having some trouble determining
what number I should put for $UPSTREAM_TOTAL.  I sort of arrived at 15
by trial and error -- but if anybody has any suggestions on ways to
empirically determine what your upload speed actually is, they would be
most welcome.  :)

  Oh, one other thing...does u32 match ip [sd]port N match both TCP and
UDP port N, or just TCP?  I'm wondering if that may be part of the
problem, since most online games use UDP for the client connections.

  Thanks to anyone who takes a look; let me know if there's any more
information from our configuration/setup that would be helpful.

- cut here
#! /bin/sh

if [ $1 = status ] ; then tc -s qdisc ls dev eth0 ; exit 0 ; fi

IP=/bin/ip
TC=/sbin/tc
IPT=/sbin/iptables

IFACE_NET=eth0

## These are numbers in kilobytes per second
UPSTREAM_TOTAL=15
## These next three should add up to _TOTAL
UPSTREAM_HI=9
UPSTREAM_MED=5
UPSTREAM_LO=1

## Interface Maximum Transmission Unit
MTU_NET=1500

PORTS_HI=21 22 23 53 123 5190 5191 5192 5193 5222 5269 8767 14567 14568 14690
PORTS_MED=20 25 80 110 113 119 143 443 6667

###

## Delete old rules
${TC} qdisc del dev ${IFACE_NET} root

## Set MTU
${IP} link set dev ${IFACE_NET} mtu ${MTU_NET}

## Set queue size
${IP} link set dev ${IFACE_NET} qlen 2

## Create root queue discipline
${TC} qdisc add dev ${IFACE_NET} root handle 1:0 htb default 12

## Create root class
${TC} class add dev ${IFACE_NET} parent 1:0 classid 1:1 htb rate ${UPSTREAM_TOTAL}kbps

## Create leaf classes where packets will actually be classified
${TC} class add dev ${IFACE_NET} parent 1:1 classid 1:10 htb prio 0 rate 
${UPSTREAM_HI}kbps ceil ${UPSTREAM_TOTAL}kbps
${TC} class add dev ${IFACE_NET} parent 1:1 classid 1:11 htb prio 1 rate 
${UPSTREAM_MED}kbps ceil ${UPSTREAM_TOTAL}kbps
${TC} class add dev ${IFACE_NET} parent 1:1 classid 1:12 htb prio 2 rate 
${UPSTREAM_LO}kbps ceil ${UPSTREAM_TOTAL}kbps

## Add SFQ for beneath these classes
${TC} qdisc add dev ${IFACE_NET} parent 1:10 handle 10: sfq perturb 10
${TC} qdisc add dev ${IFACE_NET} parent 1:11 handle 11: sfq perturb 10
${TC} qdisc add dev ${IFACE_NET} parent 1:12 handle 12: sfq perturb 10

## Add the filters which direct traffic to the right classes
## High-priority traffic
${TC} filter add dev ${IFACE_NET} protocol ip parent 1:0 prio 0 u32 match ip protocol 
1 0xff flowid 1:10 ## ICMP
for PORT in ${PORTS_HI}; do
${TC} filter add dev ${IFACE_NET} protocol ip parent 1:0 prio 0 u32 match ip 
dport ${PORT} 0x flowid 1:10
${TC} filter add dev ${IFACE_NET} protocol ip parent 1:0 prio 0 u32 match ip 
sport ${PORT} 0x flowid 1:10
done
## Normal traffic
for PORT in ${PORTS_MED}; do
${TC} filter add dev ${IFACE_NET} protocol ip parent 1:0 prio 0 u32 match ip 
dport ${PORT} 0x flowid 1:11
${TC} filter add dev ${IFACE_NET} protocol ip parent 1:0 prio 0 u32 match ip 
sport ${PORT} 0x flowid 1:11
done
## Bulk traffic is anything not already classified, so comment this line
## out as it's redundant and anyway it generates an error I don't feel
## like debugging yet :)
#${TC} filter add dev ${IFACE_NET} 

Re: [LARTC] TCNG

2004-03-03 Thread Barry Rooney
Hi Martin,
Eth0 is connected to a private network which has on it a Media Server 
streaming rtsp files
Eth1 is a wireless card on an ad-hoc network with a laptop, a pda, and a 
desktop.

The idea is then to imitate different QoS levels to the different 
devices, the idea being
that the pda shouldn't need as much bw as the desktop etc. So the three 
devices
get dhcp leases dependant on their mac address, and then their ip 
address is used to
identify them and (hopefully) tc will then allow me to create sfqs for 
each device.

I have tested the devices without any shaping, and also with shaping of 
all rtsp/mms protocol based traffic
to the 50kb class. This works and has been confirmed by the stats on the 
media client, it can be quite clearly
seen any way the video starts to jump and stutter.

However I have been unable to get the shaping to only occur on one 
device, maybe the laptop for example
whose address is 10.1.1.10

Martin A. Brown wrote:

Hello Barry,

: I'm using TCNG to restrict certain types of traffic to certain ip
: addresses using a Linux router, and some masq'd computers behind it.
You didn't tell us anything about the networks behind eth1.  So, is this
host running as an Internet access device?
: #define INTERFACE  eth1 
:
: dev INTERFACE {
: egress {
:
: /* In class selection path, the filters come first!  DSmark */
:  class ( $video ) if tcp_sport == 554  ip_dst == 10.1.1.10;
: class ( $other )  if 1 ;
:
: /* section in which we configure the qdiscs and classes */
:
: htb () {
: class ( rate 3500kbps, ceil 3500kbps ) {
:  
: $video = class ( rate 50kbps, ceil 50kbps ) { sfq; } ;
: $other  = class ( rate 1000kbps, ceil 3450kbps ) { sfq; } ;
:  
: }
: }
: }
: }

: Doesn't seem to be working...

Are you able to tell if traffic is classified at all into any classes
(tc -s class show dev eth1)?
What happens if you [off-hours] drop your maximum rate (3500kbps) to
something much slower (2000kbps)?  Are you actually shaping traffic?
Presumably, given the above configuration, the host 10.1.1.10 is a client
and is located on the network reachable via eth1.  The Internet (the
source of the tcp/554 packets) must be reachable on another interface.
-Martin

 

___
LARTC mailing list / [EMAIL PROTECTED]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/


[LARTC] how to add my own traffic scheduler to TC

2004-03-03 Thread Kennedy Cheng
What are the steps needed to add my own traffic scheduler to TC?

My understanding is that I need to do something in the net/sched/
directory: add a schedular eg sch_blue.c, change the Makefile, config.in
and sch_api.c; add the appropriate qopt, xstats struct... in the
include/linux/pkt_sched.h. I've got it all compiled without warnings or
error. When I typed tc add dev eth0 root blue limit 1000kB.., it
complained Unknown qdisc blue, hence option limit is unparsable.
When I typed tc add dev eth0 root red limit 1000kB., it worked
fine (of course).

The code I wrote was a complete copy of the sch_red.c, with text changed
to blue instead of red. TC is not happy with my blue scheduler. What
have I done wrong? Have I missed something?

Linux Kernel version 2.4.20-8

Many Thanks,
Kennedy


___
LARTC mailing list / [EMAIL PROTECTED]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/