OPNsense Forum

Archive => 18.1 Legacy Series => Topic started by: Lukas85 on February 09, 2018, 08:06:10 am

Title: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 08:06:10 am
Hi
I't is my first post on this forum, so hello to everyone.

Yesterday I have installed opnsense on my virtualbox machine to test it before installing it on a Dell Optiplex PC. Everything works as expected, which means great ;).

Here comes the problem. I'm not yet traffic shaping guru and I don't know how to accomplish one task. I have 10Mb download and 2Mb upload isp connection speed. I would like to share it evenly with 5 users. I mean when everybody downloads something from internet each of the users get 2Mb download speed. When only one user is connected to router and bandwidth is free that user downloads at max 10Mb speed. Is this possible ?

I did that using opnsense wiki reading "share evenly" but it doesn't work that way. It just allocate max 2Mb to everyone.

Little help ?
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: hutiucip on February 09, 2018, 09:37:18 am
Hello!

Yes, and also in the doc: https://docs.opnsense.org/manual/how-tos/shaper.html#share-bandwidth-evenly

Hope it helps!

PS. The only exception, I have set my upload pipe with "source" as mask (not "destination"): "upload" + "destination" means destination is outside/ public servers, and I want the shaper to share the upload bandwidth between internal clients (source).
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 09:49:56 am
Yes, I did it exactly as in "Share bandwidth evenly". I tested it with 4Mb download speed and 1Mb upload. But it looks that two machines can now download with 4Mb speed, wchich consumes 8Mb total....

Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: hutiucip on February 09, 2018, 09:57:07 am
Very weird!

I have the same setup, and works up to the limit you define in the pipes: when our ISP increased the service bandwidth from 100 Mbps to 1 Gbps I have forgotten for about 15 - 30 minutes to change the value in the pipe, so nobody could pass the 100 Mbps limit even if alone in the entire network.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 10:12:05 am
Screenshots:

(https://thumb.ibb.co/fvUZyx/pipes.jpg) (https://ibb.co/fvUZyx) (https://thumb.ibb.co/gHHyQc/rules.jpg) (https://ibb.co/gHHyQc)

Pipeup-4Mb is wrong description, don't look at it ;) It should be Pipeup-1Mb in pipes screenshot.

Here is the traffic graph when both users are downloading. It clearly shows that both of them are downloading at 4Mb, wchich gives 8Mb total. I don't even know what exactly I'm doing wrong. Mayjbe this is because of Virtualbox.
(https://image.ibb.co/deBuWH/speed.jpg) (https://imgbb.com/)
tinypics (https://pl.imgbb.com/)
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: advcron on February 09, 2018, 10:27:24 am
For me also works.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 10:40:11 am
Could any of you post your traffic shaping config ? It would be very helpfull.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: hutiucip on February 09, 2018, 10:49:52 am
I only don't bother specifying IPs/ networks in rules for WAN upload/ download, I hit "Advanced" and set interface direction only.

It works both ways, but I find it less fussing... :)
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: hutiucip on February 09, 2018, 11:05:27 am
And, for testing, I changed the pipes to 100 Mbps, and it works as you said (meaning wrong): I asked a colleague of mine to speedtest simultaneously, and we both obtained 100 up and 100 down.

I think it's a bug?!?!  :-\

Or maybe the system is supposed to limit to 100 for every client up for as many clients as the total throughput? Starting to lower for every and each only when total throughput is not enough? But then, how will the shaper would even know what total bandwidth to share evenly?!?!?!

We need @franco (and other testers) here... :)

LE: Also changed mask, from source to destination and back... no change
LLE: No scheduler type made any difference whatsoever, so I disabled TS completely, since it appears the only thing it does is to limit the bandwidth for each client to the maximum configured bandwidth in pipe(s) (and for me this is equal to the total bandwidth I have from ISP), in the meantime making the graph spiky, taking its toll on the quality of the connection.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 12:42:15 pm
So it looks like I'm not the only one with this problem ?
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: tibere86 on February 09, 2018, 02:53:46 pm
Try this...

Set up two pipes, one for download (10Mbps) and one for upload (2Mbps). Then, create two queues. The first queue will be for your download pipe. Set this queue to download pipe created, set weight to 100, then set mask to destination. The second queue will be for your upload pipe. Set this queue to upload pipe created, set weight to 100, then set mask to source.
Then, go to your traffic shaping rules. Instead of setting your download shaping rule target to the "pipe", set the download queue as the target. Same goes for your upload shaping rule, set that target to your upload queue. Now, all devices will evenly share the bandwidth and when only one device is actively using bandwidth, it will be able to have the whole pipe available  :) 
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Animosity022 on February 09, 2018, 04:56:40 pm
Just remember, if you mark on destination, it's all devices that share it. So every single device that's connected split the speed up amongst it including any VOIP phone, wifi connected phone, etc.

I do a bit more granular and have 3 queues setup with a high / med / low and split up my traffic via that route.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 05:18:13 pm
Well, the problem still persist, I did exactly as @tibere86 said. Still both pc's are consuming 8Mb together....  ???
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Animosity022 on February 09, 2018, 05:25:56 pm
Can you post the rules/screenshots that you setup? "It doesn't work" gives really 0 to help out with as we can't see what you've configured.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 05:56:32 pm
Sorry !

(https://preview.ibb.co/ih5iRH/pipe_download.jpg) (https://ibb.co/cAHK0c)
(https://preview.ibb.co/mdwe0c/pipe_upload.jpg) (https://ibb.co/kbCxmH)
(https://preview.ibb.co/cmN8tx/queue_download.jpg) (https://ibb.co/iTbCLc)
(https://preview.ibb.co/hpqHmH/queue_upload.jpg) (https://ibb.co/fGFiRH)
(https://preview.ibb.co/gKkiRH/rule_download.jpg) (https://ibb.co/b2OEYx)
(https://preview.ibb.co/iPkiRH/rule_upload.jpg) (https://ibb.co/njNmfc)
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Animosity022 on February 09, 2018, 06:08:45 pm
To separate traffic from inbound (download) and outbound (upload), click on the advanced button to bring up the "Direction" and change from any to either in or out and I have a rule for each:


In
https://imgur.com/a/5R58Y

Out
https://imgur.com/a/5R58Y

If you want to check the rules are hitting, you can run this "ipfw -a list" from a shell on the firewall and see:

Code: [Select]
60001   1970328   2927868270 queue 10005 ip from any to 192.168.1.30 src-port 563 in via igb0
60002    981160    127114594 queue 10005 ip from any to 192.168.1.31 in via igb0
60003    984304     53916560 queue 10002 ip from 192.168.1.30 to any dst-port 563 out via igb0
60004    871946     77914668 queue 10002 ip from 192.168.1.31 to any out via igb0
60005    138803      9919162 queue 10003 icmp from any to any in via igb0
60006    142521     10189045 queue 10000 icmp from any to any out via igb0
60007    196846     51535283 queue 10003 ip from any to any src-port 53 in via igb0
60008    199322     15488643 queue 10000 ip from any to any dst-port 53 out via igb0
60009   2361942   1658878829 queue 10003 ip from any to 192.168.1.50 in via igb0
60010         0            0 queue 10003 ip from any to 192.168.1.51 in via igb0
60011     10562      1304059 queue 10003 ip from any to 192.168.1.55 in via igb0
60012    171010    127520953 queue 10003 ip from any to 192.168.1.90 in via igb0
60013   1771676    437027734 queue 10000 ip from 192.168.1.50 to any out via igb0
60014         0            0 queue 10000 ip from 192.168.1.51 to any out via igb0
60015     20849      1811706 queue 10000 ip from 192.168.1.55 to any out via igb0
60016    107855     14693889 queue 10000 ip from 192.168.1.90 to any out via igb0
60017 138197566 136992406549 queue 10004 ip from any to any in via igb0
60018 118202500  80854482004 queue 10001 ip from any to any out via igb0

For me, I can see all my in and out queues are working properly as traffic is matching in and out.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 06:24:33 pm
Well I gues this is too complicated for me. I did exactly as in the wiki, exactly as anybody else posted before and still no luck. 
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 08:07:20 pm
I created only download pipe and download rule. 5Mb in this test. No upload no nothing else.

(https://preview.ibb.co/ke3JbH/download_pipe.jpg) (https://ibb.co/cBWRVc)
(https://preview.ibb.co/dBwFOx/download_rule.jpg) (https://ibb.co/exE23x)

Can anyone confirm this scenario working for him ? In my case it doesn't. Just for simple test, I have connected two computers, both of them downloading at 5Mb at the same time, which gives 10Mb.

This shouldn't happen, because it violates the "pipe" max bandwidth which is only 5Mb no 10Mb.

Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 08:18:20 pm
Hey !!! I found the solution !

It was the mask Destination ! I unchecked it in pipe rule. Now it works !
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Animosity022 on February 09, 2018, 08:32:47 pm
Were you setting the mask in the Pipe or the Queue?
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 08:36:45 pm
I disabled any mask (empty) in pipe rule. Now it looks like it works, not so sure, but both clients dont exceed the max pipe bandwidth. Hard to tell if the get fair 50/50 download speed. I'm not using the queues.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Animosity022 on February 09, 2018, 09:27:52 pm
Hmm. I did some testing and I couldn't reproduce a limiter not working with source or destination checked.

You will get some errors at times if you reconfigure stuff too much in your syslog:

config_aqm Unable to configure flowset, flowset busy!
config_aqm Unable to configure flowset, flowset busy!

That sometimes can cause an issue with things 'working'. I just reboot if I see that in the logs with end config and that usually clears it up.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 09, 2018, 09:53:05 pm
Which version of opnsense are you using ?
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Animosity022 on February 09, 2018, 11:26:48 pm
OPNsense 18.1.2_2-amd64

The flowset issue has been there for quite a bit though.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 10, 2018, 12:37:37 pm
I'm posting also status page.

(https://image.ibb.co/kVoxO7/stats.jpg) (https://imgbb.com/)
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 10, 2018, 02:41:23 pm
I think this topic should be closed. If nobody believes me that I'm doing exactly as I'm supposed to, than it doesn't make any sens to continue this. I posted all my config in screenshots and I tested it on virtualbox also tested it on my Dell optiplex PC. Same behaviour. I gues it's a bug somewhere. I'll try another time. Thanks for help anyway.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: mateusjua on February 10, 2018, 09:13:13 pm
in the rule replaces the protocol "ip" with "ipv4"
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: Lukas85 on February 11, 2018, 11:59:14 am
Thanks for help, but I'm no longer using Opnsense. I also found this topic on opnsense forum, so now I have a proof that I'm not alone. The topic is 2 years old, and it describes exactly the same problem I'm facing.

https://forum.opnsense.org/index.php?topic=3966.0

As I said, I'm no longer on Opnsense, so thanks for your support.
Title: Re: Traffic shaping (divide 10Mb evenly for 5 users)
Post by: hutiucip on February 12, 2018, 10:06:35 am
I was the first to confirm is not working as expected. The link in the reply upon proves that is not an isolated issue, and is not new. I think this time maybe we should take a better care for this issue, and even if it manifests randomly, now is the time for it to go to github.

I post it there.
Thank you!