# dynamic shaping or smth like that :)



## romeor (Feb 29, 2012)

Dear Sirs,

*I*'ve got FTP server running behind linux firewall, but in short plans *I* will replace it with freebsd FreeBSD one and PF (*I* love PF). so as new FW will be used, we would like to implement such a thing like a dynamic shaping, which means, that when some client logs in and starts transfer, the traffic will be shaped equally between number of users. If every client had s static IP *I* could do something like this with PF shaping mechanism and borrow function, but IPs are not known (clients use DHCP IPs). Can PF handle this? or IPFW? *O*r do *I* need some other type of load-balancer?

Thanks..


----------



## SirDice (Feb 29, 2012)

Handbook: 31.4 The OpenBSD Packet Filter (PF) and ALTQ


----------



## romeor (Feb 29, 2012)

Hello, SirDice!

Are *y*ou pointing me at ALTQ_HFSC?


----------



## SirDice (Feb 29, 2012)

romeor said:
			
		

> Are You pointing me at ALTQ_HFSC?


I'm pointing you to ALTQ in general. Not just ALTQ HFSC.


----------



## romeor (Feb 29, 2012)

*W*ell, *I* know, what is ALTQ in general (and *I* gave an example in my post, when cCBQbq could be in use), but it is not suitable for my situation.
*B*ut *I*'ve never played with HFSC, seems like it should solve this problem?


----------



## SirDice (Feb 29, 2012)

You usually don't shape based on a user, you shape traffic based on protocol/functionality.

You would, for example limit FTP traffic so it doesn't interfere with your VoIP. If only one user uses FTP he/she is lucky and gets a lot of bandwidth (but not enough to interfere with VoIP). If more users start FTP'ing that available bandwidth is split up.


----------



## romeor (Feb 29, 2012)

*O*h, *I* gave wrong information (due to poor *E*nglish? *I* don't use google translate, *I* swear ) 

*T*here is no some real priority for anything more behind the firewall. *S*o the thing I managed to make is to share the overall bandwidth more or less equally between all the incoming ftp connections. *I* even could say more: *I* would like to share the overall bandwidth between all incoming connections (*I* would say between incoming IPs). *T*oday *I* fall in such a situation, when some clients with high speed connections start to download via FTP or UDP, they get all the 40 Mbits bandwidth we have for that department and others, who manage to connect to ftp or udp services transfer files too slow and frequently their connections get timed-out.

*S*o *I* want to make it shaped more or less equally among incoming IPs.


----------



## overmind (Feb 29, 2012)

Note that *HFSC* is kind of linear algorithm, which means if you have lots of queues (like more than 128) it won't scale. I don't know about latest versions of PF but in earlier version they hardcoded *HFSC* queues to 64 (with a C #define line).

On the other hand I don't know how you will do upperlimits using *CBQ*.

Check this: http://www.freebsdonline.com/content/view/513/531/
And this: http://www.freebsdonline.com/content/view/512/531/

A tutorial on traffic shaping would be nice on this forum.


----------



## romeor (Mar 1, 2012)

overmind, thanks for your post, but I do know how ALTQ works. I'd like to know if I am able to resolve my problem using ALTQ. The rules in those configurations are bound to IP addresses. Unfortunately I don't know what IP addresses our clients use, as these are not clients on our LAN network. These are WAN clients from over the world, that connect to our server. Some of them have high speed connections, some of them low. Those who have high speed connections are using all of our available bandwidth, preventing users with less high speed connections getting data from our FTP and UDP servers. I want to shape/share our available bandwidth dynamically and more or less equally between those clients despite number of clients. Is there something that could solve my problem?


----------



## overmind (Mar 1, 2012)

I think you can do dynamic shaping only with ipfw.

See this link: http://www.freebsdonline.com/content/view/725/531/

Read *Example 5. Router with IPFW Nat Dynamic Limits*. That example limits upload to 128Kbps and download to 256Kbps. Instead of hardcoded values, define two variables for upload and download. Note that the value of 256Kbps is for all computers combined. Instead of that value use your own bandwidth values (total upload and total download bandwidth).

This solution is done by using dummynet instead of ALTQ.

You can test your bandwidth with: http://www.numion.com.

If you can accomplish that with *PF*, I am interested too.


----------

