OPNsense Forum

Archive => 15.7 Legacy Series => Topic started by: lukepower on July 21, 2015, 09:06:27 am

Title: [SOLVED] Traffic Shaper for VoIP?
Post by: lukepower on July 21, 2015, 09:06:27 am
Hi there,

I am successfully running the latest version in our production environment (after having switched in winter time from Endian firewall), and have eagerly awaited the release of the traffic shaper. Now, what I would like to achieve is to prioritize VoIP traffic over all interfaces (or at least over our two WAN interfaces). How could I do that?
I could actually use the IP of our VoIP provider as to & from address, but I cannot figure out how to program the shaper...  :o
Any help is welcome :)
Title: Re: Traffic Shaper for VoIP?
Post by: JoeT on September 01, 2015, 09:13:52 pm
Were you ever able to figure this out?  I would be very interested in the results.  One of the reasons I installed OPNSense was to help with this same issue at one of my locations...

I'm using Asterisk IAX2 on port 4569 and I'd love to be able to tell the system to prioritize this traffic above ALL else.
Title: Re: Traffic Shaper for VoIP?
Post by: AdSchellevis on September 01, 2015, 09:22:47 pm
I kind of missed this one the first time, so if it wasn't solved yet, here is how you could prioritize traffic to your voice server.

1. create a pipe with the total bandwidth available
2. create multiple queues connected to that pipe and prioritize using the weight property
3. create rules to send traffic to your queue

By using a higher weight on a queue you should be able to give your voice traffic priority over the rest of the traffic.
 
Title: Re: Traffic Shaper for VoIP?
Post by: JoeT on September 01, 2015, 09:26:54 pm
Thank you, I'll check this out.  I tried to follow what is listed on this page in the wiki:

https://wiki.opnsense.org/index.php/Traffic_shaper

But I see that just limits per session bandwidth.   Maybe the queue part is what I couldn't figure out. 
Title: Re: Traffic Shaper for VoIP?
Post by: AdSchellevis on September 01, 2015, 09:31:30 pm
Yes, the queue is the extra feature needed to prioritize :)
Title: Re: Traffic Shaper for VoIP?
Post by: JoeT on September 02, 2015, 08:58:57 pm
I think that may have done it!!!  I just implemented this, then did some large downloading while making calls, and the few calls I did sounded so much better... the choppiness was almost gone.  During the worst parts when the pipe was full there was a small bit of choppiness, but it was noted it was so much better than it would have been previously if the pipe were even barely in use.

I've only done a few calls, but like I said, I've filled the pipe (verified with the traffic graph while doing so, while on the call to boot), so I'm really hoping it's good.  As time goes on I'll get more input on call quality from my people. 

Basically, I did what Ad said above.  Roughly, the steps are (hopefully I'm not missing anything major here, as I'm retracing my steps):
- On my OPNSense 15.7 WebGUI:
- Went into Firewall -> Traffic Shaper, then clicked on the Pipes (if not already there)
- Added a pipe for the total size of my pipe - put value in bandwidth field, like 3 for 3Mb, then changed bandwidth metric to Mbit/sec, in description put in Main Pipe, didn't change/set nothing else, clicked Save Changes.
- Clicked Apply
- Clicked on Queues tab near the top
- Added 3 queues.  I may only ended up using two in my rules, but may revisit this. 
- All queues are associated with the Main Pipe I just created.  The first one I put in a weight of 100, and in the description I put HIGH priority, no Mask or anything else.  The second one I put in a weight of 25, and in the description I put Regular priority, no Mask or anything else.  The last one I put in a weight of 10 and put in a description of Low priority, no Mask or anything else.  Saved each one and then Apply when done with all.
- NOTE:  I chose these weights purely arbitrarily. Others here with more knowledge may have much more valuable input than I.
- Then I clicked on the Rules tab near the top
- Here I created two rules.  The first one I set the sequence to 1, hoping that would ensure it always would get evaluated the soonest.   I changed dst-port to 4569 since I'm using IAX2.  If you're using SIP or something else, you need to change this accordingly.  In target I associated it with the HIGH Priority queue.  In description I put VoIP.
- The second rule I left the sequence at 11, which is what it put in by default.  I left everything else alone except I associated it with the Regular Priority queue, and in the description I put Regular Traffic. 
- Save each and then Apply.

That's it.  Test and pray.

My thought process was that with the rules since IAX uses just the one port, 4569, it will get caught with the first rule and put into the HIGH priority queue.  The other rule, since it's sequence number is higher (11 vs 1) gets evaluated after the VoIP rule, catches basically all the rest of the traffic, and gets put into the Regular Priority queue.

Again, no idea if this is at all proper or correct, but it's what I did, and a short bit of testing provided some positive results.  Time will tell if it's good or not.  Hopefully I'll come back with good news.  Or at least some tweaks.  I'd be happy to receive any feedback, good or bad.   

I think this would also make for a great wiki page to complement the current Traffic Shaper page, with a focus on VoIP.  But I'm not going to touch that until I find that this actually works for a bit, and get some feedback on whether or not my reasoning is solid here.

Anyway, thanks Ad for the help, and thanks to all involved with the OPNSense project!
Title: Re: [SOLVED] Traffic Shaper for VoIP?
Post by: dpbklyn on August 04, 2017, 10:33:32 pm
I know this is old, but is this the best way to shape traffic for VOIP?
Title: Re: [SOLVED] Traffic Shaper for VoIP?
Post by: JoeT on August 07, 2017, 01:59:03 pm
Probably not "the best way".  This is not my area of expertise.   It has functioned with some success for the past almost two years.  We have very limited bandwidth due to location and cost, but we have a fairly large campus of people, all trying to do streaming video, music, etc... and then of course things like Windows Updates.  This shaping has certainly helped, but there are times when even the shaping can't keep the rest of the traffic at bay.