From: "George Adams" Date: Mon, 24 May 2004 22:37:15 +0000 Subject: [LARTC] Newbie STILL trying to limit bandwidth - is this script wrong? Message-Id: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: lartc@vger.kernel.org My previous message=20 (http://mailman.ds9a.nl/pipermail/lartc/2004q2/012285.html) didn't generate= =20 any replies, so I thought I'd try posting what I've done trying to solve my= =20 own problem, in hopes that someone will take pity and show me if/where I'm = going wrong. Just to recap, I'm trying to accomplish this on my server, which streams=20 RealAudio files and allows HTTP downloads of large files. 1) SSH connections (port 22) (i.e. me connecting remotely) should get all=20 the bandwidth they can consume (highest priority). 2) RealAudio streaming clients (port 554) should get all the bandwidth left= =20 after #1 that they can consume. 3) Web downloaders (port 80) should get all the bandwidth left after #1 and= =20 #2 that they can consume (lowest priority). I've tried adapting an existing tcng script into this: --------------------------------------------------------------------- #include "fields.tc" #include "ports.tc" #define INTERFACE eth0 dev INTERFACE { egress { class ( <$ssh> ) if tcp_sport =3D 22 ; class ( <$audio> ) if tcp_sport =3D 554 || tcp_sport =3D 7070 ; class ( <$web> ) if tcp_sport =3D 80 ; class ( <$other> ) if 1 ; htb () { class ( rate 600kbps, ceil 600kbps ) { $ssh =3D class ( rate 64kbps, ceil 128kbps ) { sfq; } ; $audio =3D class ( rate 128kbps, ceil 128kbps ) { sfq; } ; $web =3D class ( rate 256kbps, ceil 512kbps ) { sfq; } ; $other =3D class ( rate 128kbps, ceil 384kbps ) { sfq; } ; } } } } --------------------------------------------------------------------- which creates the follow tc commands: --------------------------------------------------------------------- tc qdisc add dev eth0 handle 1:0 root dsmark indices 8 default_index 0 tc qdisc add dev eth0 handle 2:0 parent 1:0 htb tc class add dev eth0 parent 2:0 classid 2:1 htb rate 75000bps ceil 75000bps tc class add dev eth0 parent 2:1 classid 2:2 htb rate 8000bps ceil 16000bps tc qdisc add dev eth0 handle 3:0 parent 2:2 sfq tc class add dev eth0 parent 2:1 classid 2:3 htb rate 16000bps ceil 16000bps tc qdisc add dev eth0 handle 4:0 parent 2:3 sfq tc class add dev eth0 parent 2:1 classid 2:4 htb rate 32000bps ceil 64000bps tc qdisc add dev eth0 handle 5:0 parent 2:4 sfq tc class add dev eth0 parent 2:1 classid 2:5 htb rate 16000bps ceil 48000bps tc qdisc add dev eth0 handle 6:0 parent 2:5 sfq tc filter add dev eth0 parent 2:0 protocol all prio 1 tcindex mask 0x7 shif= t=20 0 tc filter add dev eth0 parent 2:0 protocol all prio 1 handle 4 tcindex=20 classid 2:5 tc filter add dev eth0 parent 2:0 protocol all prio 1 handle 3 tcindex=20 classid 2:4 tc filter add dev eth0 parent 2:0 protocol all prio 1 handle 2 tcindex=20 classid 2:3 tc filter add dev eth0 parent 2:0 protocol all prio 1 handle 1 tcindex=20 classid 2:2 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 1:0:0 u32=20 divisor 1 tc filter add dev eth0 parent 1:0 protocol all prio 1 u32 match u8 0x6 0xff= =20 at 9 offset at 0 mask 0f00 shift 6 eat link 1:0:0 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 1:0:1 u32 ht=20 1:0:0 match u16 0x16 0xffff at 0 classid 1:1 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 2:0:0 u32=20 divisor 1 tc filter add dev eth0 parent 1:0 protocol all prio 1 u32 match u8 0x6 0xff= =20 at 9 offset at 0 mask 0f00 shift 6 eat link 2:0:0 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 2:0:1 u32 ht=20 2:0:0 match u16 0x22a 0xffff at 0 classid 1:2 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 3:0:0 u32=20 divisor 1 tc filter add dev eth0 parent 1:0 protocol all prio 1 u32 match u8 0x6 0xff= =20 at 9 offset at 0 mask 0f00 shift 6 eat link 3:0:0 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 3:0:1 u32 ht=20 3:0:0 match u16 0x1b9e 0xffff at 0 classid 1:2 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 4:0:0 u32=20 divisor 1 tc filter add dev eth0 parent 1:0 protocol all prio 1 u32 match u8 0x6 0xff= =20 at 9 offset at 0 mask 0f00 shift 6 eat link 4:0:0 tc filter add dev eth0 parent 1:0 protocol all prio 1 handle 4:0:1 u32 ht=20 4:0:0 match u16 0x50 0xffff at 0 classid 1:3 tc filter add dev eth0 parent 1:0 protocol all prio 1 u32 match u32 0x0 0x0= =20 at 0 classid 1:4 I've tried loading them into tc, but I'm not really sure if it's working or= =20 not. The only way I could think to test it was to get a friend (in another= =20 state) to trying download 3 files via HTTP, which would normally cause my=20 SSH sessions to slow to a crawl. The 3 downloads started, and it still=20 seemed like the latency in my SSH sessions was high (i.e. it didn't appear = that they had any priority over the HTTP downloads). So am I totally on the wrong track here? Or am I on the right track but=20 just needing some tweaks to my script? Thanks to anyone who can help - I need it! _________________________________________________________________ MSN Toolbar provides one-click access to Hotmail from any Web page =96 FREE= =20 download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/ _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/