LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2009, 09:26 AM   #1
sebelk
Member
 
Registered: Jan 2007
Posts: 66

Rep: Reputation: 15
About qdiscs and traffic shaping


Hi,

I am reading about traffic shaping and most documentation I've read so far abound on theoretical details but offer few practical examples.

Could you tell me in what cases you would use sfq or tbf?

Thanks in advance!
 
Old 07-07-2009, 10:43 AM   #2
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
I use sfq instead of a tbf style filter in a case where the available bandwith is varying greatly.
(the ISP is a german WIMAX-Provider and the bandwith is varying from often only 10% of the promised rate to 150% of that at rare times - mostly about 60% to 80% of promised rate)

For tbf to work correctly, some fixed bandwith is (has to be) assumed - which you then can use to share between the kind of filtering you want.

If there is no fixed bandwidth, the tbf style algorithms will be useless or at least give wrong results most of the time - leading to ineffective shaping.
All I figured I could do in that particular case was a priorization of certain things over others - which sfq is good for and will always work, no matter what the actual bandwidth.

The practical example to the above situation was given here some time ago - it is still in use.
http://www.linuxquestions.org/questi...8/#post3187186

HTH
 
Old 07-20-2009, 09:59 AM   #3
sebelk
Member
 
Registered: Jan 2007
Posts: 66

Original Poster
Rep: Reputation: 15
I have about 20 wireless routers. Users browse the web, use MSN mainly... I want that nobody eats up the bandwidth...


I've found a script on the web and I wonder if is doing what I want, you can see below:


#!/bin/ash

# Executables
GREP=/bin/grep
INSMOD=/sbin/insmod
TC=/usr/sbin/tc
DEV=eth0.1

# Load kernel modules
$GREP -q ^sch_htb /proc/modules || $INSMOD /lib/modules/`uname -r`/sch_htb.o
$GREP -q ^sch_sfq /proc/modules || $INSMOD /lib/modules/`uname -r`/sch_sfq.o
$GREP -q ^cls_u32 /proc/modules || $INSMOD /lib/modules/`uname -r`/cls_u32.o

# Hierarchical Token Bucket (HTB)
$TC qdisc add dev $DEV root handle 1: htb default 30
$TC class add dev $DEV parent 1: classid 1:1 htb rate 1mbit burst 20k cburst 20k

# HTB Classes
$TC class add dev $DEV parent 1:1 classid 1:10 htb \
rate 87kbit ceil 512mbit burst 15k cburst 15k
$TC class add dev $DEV parent 1:1 classid 1:20 htb \
rate 256kbit ceil 512mbit burst 20k cburst 20k
$TC class add dev $DEV parent 1:1 classid 1:30 htb \
rate 38kbit ceil 256kbit burst 5k cburst 5k

$TC qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
$TC qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
$TC qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10

# Filters
# La prioridad maxima es para el trafico DNS
$TC filter add dev $DEV protocol ip parent 1:0 prio 1 \
u32 match ip dport 53 0xffff flowid 1:10
#La prioridad intermedia es para ssh, msn y comandos ftp.
$TC filter add dev $DEV protocol ip parent 1:0 prio 2 \
u32 match ip dport 22 0xffff flowid 1:10
$TC filter add dev $DEV protocol ip parent 1:0 prio 2 \
u32 match ip dport 1863 0xffff flowid 1:10
# Trafico web
$TC filter add dev $DEV protocol ip parent 1:0 prio 10 \
u32 match ip dport 80 0xffff flowid 1:20
$TC filter add dev $DEV protocol ip parent 1:0 prio 10 \
u32 match ip dport 443 0xffff flowid 1:20
$TC filter add dev $DEV protocol ip parent 1:0 prio 10 \
u32 match ip dport 20 0xffff flowid 1:20


What do you think?
Thanks in advance
 
Old 07-21-2009, 01:49 AM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
I'm too lazy to analyze this thoroughly - but what comes to mind so far:

Did you understand the answer to your initial post?
You have not yet said what kind of connection you have, if it is symmetric or how fast up/downstream is.
But knowing that is a key element in deciding how to shape/filter.

...just one thing about that script:
in the first class it does mention a rate of 87kBit with a ceiling of 512mBit,
the second class mentions 256kBit with that same ceiling of 512mBit - are you connected really that good to have 512mBit upstream?

[edit] one limitation to utilizing that amount of bandwidth would probably be the wireless routers of your users...

Last edited by jomen; 07-21-2009 at 02:30 AM.
 
Old 07-21-2009, 12:45 PM   #5
sebelk
Member
 
Registered: Jan 2007
Posts: 66

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jomen View Post
I'm too lazy to analyze this thoroughly - but what comes to mind so far:

Did you understand the answer to your initial post?
You have not yet said what kind of connection you have, if it is symmetric or how fast up/downstream is.
But knowing that is a key element in deciding how to shape/filter.

...just one thing about that script:
in the first class it does mention a rate of 87kBit with a ceiling of 512mBit,
the second class mentions 256kBit with that same ceiling of 512mBit - are you connected really that good to have 512mBit upstream?

[edit] one limitation to utilizing that amount of bandwidth would probably be the wireless routers of your users...
First: it is simmetric up/downstream.
Secondly: Sorry, and thanks!! shame on me, it was a mistake, it should be 512kbit.

Please could you fix the script if I am wrong?


Thanks in advance!
 
Old 07-22-2009, 05:07 AM   #6
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Quote:
I have about 20 wireless routers. Users browse the web, use MSN mainly... I want that nobody eats up the bandwidth...
and
You have a symmetric connection.

From these two facts I'd recommend only traffic priorization,
(...because I have a solution and you have not said why TBF will be more useful to you - after all there is nothing wrong with using all the available bandwith)
- to ensure that:

1.) the whole bandwidth can be used by anyone as long as it is not disturbing anyone else too much
2.) certain types of traffic get priority over other types of traffic (e.g.: ssh is more important to you than bittorrent)
3.) the possibility to give some users/machines in the network a higher overall-priority (it might be more important for them to have full performance than it is for "ordinary" users/machines)



The script given by you is insufficient - and also wrong IMO

this part for example matches by port 22 - which is ssh - and also uses some u32 match
and it is supposed to "be good" for ssh, msn and ftp at the same time - which is clearly wrong
Code:
#La prioridad intermedia es para ssh, msn y comandos ftp.
$TC filter add dev $DEV protocol ip parent 1:0 prio 2 \
u32 match ip dport 22 0xffff flowid 1:10
From what you say you need not use some TBF-based solution but should be fine with traffic-priorization.
If you wanted to use TBF the script can be a basis but will need to be changed quite a bit...not by me and not now though
You may google for wondershaper which some people say is configurable and does a good job.

Again I link to a wiki page of the wireless network project I'm a part of.
Post #2 had a link (to the link) already.
http://wiki.leipzig.freifunk.net/Traffic-Shaping
The first script of the two there was made by me - and it does all that was described above (1. through 3.)
It is in use for more than two years and does what I want for me.
It puts a mark on each connection by certain criteria (filesharing traffic gets a different mark than small packets, large packets get their own mark as well as two kinds of TOS are marked differently), and based on that mark the traffic belonging to those connections is prioritized using 6 levels of priority.
If you have questions - please ask. I can provide a version with comments in english to help you understand what it does and how.
(will put that up to that wiki when I have the time)
 
Old 07-22-2009, 10:17 AM   #7
sebelk
Member
 
Registered: Jan 2007
Posts: 66

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jomen View Post
and
You have a symmetric connection.


The script given by you is insufficient - and also wrong IMO

this part for example matches by port 22 - which is ssh - and also uses some u32 match
and it is supposed to "be good" for ssh, msn and ftp at the same time - which is clearly wrong
Code:
#La prioridad intermedia es para ssh, msn y comandos ftp.
$TC filter add dev $DEV protocol ip parent 1:0 prio 2 \
u32 match ip dport 22 0xffff flowid 1:10

Hi jomen, I thought that was right that two o more services share the same priority.

Quote:
From what you say you need not use some TBF-based solution but should be fine with traffic-priorization.
If you wanted to use TBF the script can be a basis but will need to be changed quite a bit...not by me and not now though
You may google for wondershaper which some people say is configurable and does a good job.

But does tbf prevent that some user eats up bw?

Quote:
If you have questions - please ask. I can provide a version with comments in english to help you understand what it does and how.
(will put that up to that wiki when I have the time)

Please could you provide a link with english comments?

Thanks in advance!!
 
Old 07-22-2009, 11:49 AM   #8
sebelk
Member
 
Registered: Jan 2007
Posts: 66

Original Poster
Rep: Reputation: 15
I forget to mention that I want to implement qdisc on routers using OpenWRT kamikaze.
 
Old 07-22-2009, 03:58 PM   #9
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Quote:
I forget to mention that I want to implement qdisc on routers using OpenWRT kamikaze.
This script is actually running on a router running OpenWRT - but as of now still Whiterussian - that very script and integrating it into Kamikaze has kept me from making the switch to it.
It is not much work but will need some time - and since it is working fine as it is ...
Quote:
Please could you provide a link with english comments?
will work on it - will be up there in a few days
Quote:
I thought that was right that two o more services share the same priority.
Indeed - but that snippet of code does only (and weirdly to me) use traffic through port 22, which is ssh.
The other services are only mentioned in the comment above - not useful for classifying anything
Quote:
But does tbf prevent that some user eats up bw?
It can do that if planned and laid out properly.
Better yet: as long as nobody else needs the bandwith - all could be used by one user.
Why not use it all if not needed by anyone else...?
Every user (rather: every machine) gets some fixed amount which can be exceeded when there is bandwith available (aka. nobody else is using it).

Priorization is not as specific - but seems to work equally well for me since I too can define machines which get higher overall priority than others - beside the priorities of the different kinds of traffic.

Soon the version with english comments will be up...

Last edited by jomen; 07-22-2009 at 04:39 PM.
 
Old 07-22-2009, 04:27 PM   #10
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
It seems that faith has spoken just now.
That router - which sits on the roof of a house for more than 3 years now (the project I mentioned is a city-wide wireless mesh network called "freifunk") - seems to just have reached the end of its live there. It is unreachable since a few hours ago.
If that is the case and the thing is really broken, a replacement _will_ run Kamikaze - and I'll be kind of forced to get that scripts functionality onto OpenWRT Kamikaze within the next days.

...lets hope for bad weather, where noone wants to go to the lake and get a tan

Last edited by jomen; 07-22-2009 at 04:29 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Traffic Shaping and HTTP Traffic. redvivi Linux - Networking 1 11-29-2008 12:23 PM
traffic shaping help monohouse Linux - Networking 22 11-06-2008 08:38 AM
Traffic shaping (limiting outgoing bandwidth of all TCP-traffic except FTP/HTTP) ffkodd Linux - Networking 3 10-25-2008 12:09 AM
Traffic Control with tc qdiscs and tc filter on VLAN tagged network amandler Linux - Networking 2 10-23-2008 11:02 AM
Traffic shaping shy Linux - Networking 2 11-30-2004 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration