DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th May 2009
Enemy Enemy is offline
New User
 
Join Date: May 2009
Posts: 3
Thanked 0 Times in 0 Posts
Question [FreeBSD + PF cbq + borrow] Dynamic shaping

Hi all,

Before now I've only used IPFW + Dummynet, but decided to use PF and ALTQ for dynamic shaping. But I can't make it use whole bandwidth when there is only one host on, so the link is free, borrow parameter is designed to expand parent bandwidth when it is free, but not in my case

current configuration gives host only 50% of bandwidth even when the link is free,
here is PF config:
Code:
ext_if="rl0" # 
int_if="rl1" # 
lan="192.168.10.0/24" # LAN
set loginterface $ext_if

table <user1_ips> { 192.168.10.2, 192.168.10.5 } #IP addresses of user1
table <user2_ips> { 192.168.10.3 } #IP of user2
scrub in all
# IN
altq on $int_if cbq bandwidth 100Mb queue { inet_in, default_in }
queue inet_in bandwidth 512Kb { user1_in, user2_in }
queue user1_in bandwidth 50% cbq(red, borrow)
queue user2_in bandwidth 50% cbq(red, borrow)
queue default_in bandwidth 99% cbq(default)

# OUT
altq on $ext_if cbq bandwidth 100Mb queue { inet_out, default_out }
queue inet_out bandwidth 256Kb { user1_out, user2_out }
queue user1_out bandwidth 50% cbq(red, borrow)
queue user2_out bandwidth 50% cbq(red, borrow)
queue default_out bandwidth 99% cbq(default)

# NAT
nat on $ext_if from $lan to !$lan -> $ext_if

# Queues
# IN
pass in on $int_if from <user1_ips> to !$lan queue user1_out no state
pass in on $int_if from <user2_ips> to !$lan queue user2_out no state
# OUT
pass out on $int_if from !$lan to <user1_ips> queue user1_in no state
pass out on $int_if from !$lan to <user2_ips> queue user2_in no state
Also, when I'll solve this problem, I'd like to make different shapes for local-IX traffic and overseas (World) traffic, what's the best way to do this with this config?

Thanks!
Reply With Quote
  #2   (View Single Post)  
Old 18th May 2009
s0xxx's Avatar
s0xxx s0xxx is offline
Package Pilot
 
Join Date: May 2008
Posts: 194
Thanked 47 Times in 22 Posts
Default

If you want to altq outbound traffic you shoud assign queues to pass out rules on external interface
If you want to altq incoming traffic you should assign queues to pass out rules on internal interface.

i.e. if you want to control download assign rules to int_if, if you want to control upload assign rules to ext_if.

I also see that you did't assign default_* queues to any rules.
__________________
The best way to learn UNIX is to play with it, and the harder you play, the more you learn.
If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD
Reply With Quote
  #3   (View Single Post)  
Old 18th May 2009
Enemy Enemy is offline
New User
 
Join Date: May 2009
Posts: 3
Thanked 0 Times in 0 Posts
Default

s0xxx thanks for your reply!

seems that I've resolved the bandwidth problem by specifying borrow in paren queue:
Code:
# IN
altq on $int_if cbq bandwidth 100Mb queue { inet_in, default_in }
queue inet_in cbq(borrow) bandwidth 512Kb { user1_in, user2_in }
queue user1_in bandwidth 50% cbq(red, borrow)
queue user2_in bandwidth 50% cbq(red, borrow)
queue default_in bandwidth 99% cbq(default)
Quote:
I also see that you did't assign default_* queues to any rules.
Can you, please, show an example how should I do it?
Reply With Quote
  #4   (View Single Post)  
Old 18th May 2009
Enemy Enemy is offline
New User
 
Join Date: May 2009
Posts: 3
Thanked 0 Times in 0 Posts
Arrow Is cbq a valid solution at all?!

Thanks for your advices, but it didn't work so far.

It seems that when I specified borrow in parent queues (inet_in and inet_out) I only allowed them to borrow from "grandparent" queue, which is 100Mb - so it is not 50% anymore, but really is the same as with no shaping at all! I also tried different approaches.
See (in attachment) what pfctl -sq -vv looks like when user2 is downloading (commented out user1 for simplicity)
On user2 machine wget shows stable 32K/s!

Quote:
i.e. if you want to control download assign rules to int_if, if you want to control upload assign rules to ext_if.
Yes, that's 100% true, I've changed the assignment accordingly

Code:
# Queues
# OUT
#pass in on $int_if from <user1_ips> to !$lan queue user1_out no state
pass in on $ext_if from <user2_ips> to !$lan queue user2_out no state
# IN
#pass out on $int_if from !$lan to <user1_ips> queue user1_in no state
pass out on $int_if from !$lan to <user2_ips> queue user2_in no state
assign default_* queues - is this really important in such a situation?
Attached Files
File Type: txt pfctlqlog.txt (9.4 KB, 23 views)
Reply With Quote
  #5   (View Single Post)  
Old 19th May 2009
s0xxx's Avatar
s0xxx s0xxx is offline
Package Pilot
 
Join Date: May 2008
Posts: 194
Thanked 47 Times in 22 Posts
Default

First, I am not a pf expert. Try the following example and see if it works, then change the non functional parts, and/or tight the rules as sutable to you.
Code:
ext_if="rl0" # 
int_if="rl1" # 
lan="192.168.10.0/24"
set loginterface $ext_if

table <user1_ips> { 192.168.10.2, 192.168.10.5 }
table <user2_ips> { 192.168.10.3 }
scrub in all

# NAT
nat on $ext_if from $lan to !$lan -> $ext_if

# IN
altq on $int_if cbq bandwidth 99Mb queue { inet_in, default_in }

queue inet_in bandwidth 512Kb { user1_in, user2_in }
	queue user1_in bandwidth 50% cbq(red, borrow)
	queue user2_in bandwidth 50% cbq(red, borrow)
queue default_in bandwidth 99% cbq(default)

# OUT
altq on $ext_if cbq bandwidth 99Mb queue { inet_out, default_out }

queue inet_out bandwidth 256Kb { user1_out, user2_out }
	queue user1_out bandwidth 50% cbq(red, borrow)
	queue user2_out bandwidth 50% cbq(red, borrow)
queue default_out bandwidth 99% cbq(default)

block in on $ext_if all
block out on $ext_if all

# TAGGING on users
pass in on $int_if from $lan
pass in on $int_if from <user1_ips> to any tag USER1
pass in on $int_if from <user2_ips> to any tag USER2

# Queues
# IN
pass out on $int_if from any to $lan queue default_in
pass out on $int_if from any to <user1_ips> queue user1_in
pass out on $int_if from any to <user2_ips> queue user2_in

# OUT
pass out on $ext_if from ($ext_if) to any queue default_out
pass out on $ext_if from ($ext_if) to any tagged USER1 queue user1_out
pass out on $ext_if from ($ext_if) to any tagged USER2 queue user2_out
This was not tested, I hope it can help you towards the right path.
__________________
The best way to learn UNIX is to play with it, and the harder you play, the more you learn.
If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD
Reply With Quote
Reply

Tags
borrow, cbq, freebsd, pf filter

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Traffic Shaping LordZ OpenBSD Security 6 19th January 2009 04:30 PM
Ajax dynamic table/spreadsheet robbak Programming 1 7th June 2008 10:33 PM
dhcpd problems... dynamic and static leases present edhunter FreeBSD General 7 16th May 2008 02:34 PM


All times are GMT. The time now is 05:50 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick