Traffic Shaping with pfSense 2.0
Traffic shaping (also known as “packet shaping”) is the control of computer network traffic in order to optimize or guarantee performance, improve latency, and/or increase usable bandwidth for some kinds of packets by delaying other kinds of packets that meet certain criteria. If a link becomes saturated to the point where there is a significant level of contention (either upstream or downstream) latency can rise substantially. As a result, traffic shaping can be used to prevent this from occurring and keep latency in check.
As an example, a typical working environment where Traffic shaping would have an enormous and positive impact would be an Graphics, Design, & Media Production Office.
You usually have Media Designers regularly transfer their media files to servers or customers. A Team of Developers holding a Real-Time Video Conference and a Secretary on the Voip Phone setting up an appointment with a customer. In this case you have different type of packets flowing through your Network which all have a certain criteria.
The Voip Calls and the Video Conference require real-time scheduling to be interrupt free but at the same time you have data-transfers from the Media Designers going in and out, which saturate the link and might even cause the real-time Media to become interrupted or to be cut off completely. This is were Traffic Shaping really shines.
It categorizes traffic in queues which are given different priority. Priority queuing allows traffic at a higher priority to have transmission precedence over traffic at a lower priority. When traffic reaches one of the priority queues, it may only be transmitted if traffic in higher priority queues do not need the bandwidth. In our example environment, the data-transfer from the Media-Designers would be queued in a lower priority than the Voip/Video Media, the Traffic-Shaper would drop packets in the lower queue to achieve interrupt free calls.
The drop in packets could only be noticed by the Media-Designers in a slight slowdown of transfer speeds, so instead of a transfer that would finish in 2mins it would take 30secs longer.
(these numbers a pure Hypothetical, it all depends on the actual Data being transferred and the available Bandwidth)
For beginners i highly recommend using the Wizard. If you are an advanced user you can setup the rules manually or out of simplicity, run the wizard once and change the queues which are generated by the wizard, to your liking. Keep in mind that the wizard is made with symmetric links in mind, so if you have an asymmetric link you must adjust the required bandwidth for ACK queues!
This Forum Post of Dusan will explain every little detail of how to calculate the required bandwidth! Warning – high level math!
I attached the Excel Spreadsheet which is used for the calculation here qWanAck.
Make sure to use the solver! The solver will not work if you use Excel in an other language than English because “Cell” and “Row” are localized in any Excel localized version.
If you are serious about IT, you will want to use the english language applications as much as possible since English is the standard technical language. It makes things so much easier!
Here is an example of what happens if you download a file from a web-server (port 80) which is set to a higher priority than that of a default-queue.
The default-queue in my case is a “CatchAll” queue, named “qP2P”. Everything that is not specifically defined (such as voip/realtime-media etc) or has to do with Peer to Peer gets fed into that queue.
While the link gets saturated by the data-transfer from port 80 the qP2P slows down. In this case i had not much traffic going on in the qP2P queue to be needing packet drops.
If you are looking for a step by step guide (still work in progress) have a look at the official pfSense docs.