xref: /freebsd/share/examples/pf/ackpri (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1# $FreeBSD$
2# $OpenBSD: ackpri,v 1.3 2006/10/07 04:48:01 mcbride Exp $
3
4# Use a simple priority queue to prioritize empty (no payload) TCP ACKs,
5# which dramatically improves throughput on (asymmetric) links when the
6# reverse direction is saturated. The empty ACKs use an insignificant
7# part of the bandwidth, but if they get delayed, downloads suffer
8# badly, so prioritize them.
9
10# Example: 512/128 kbps ADSL. Download is 50 kB/s. When a concurrent
11# upload saturates the uplink, download drops to 7 kB/s. With the
12# priority queue below, download drops only to 48 kB/s.
13
14# Replace lo0 with your real external interface
15
16ext_if="lo0"
17
18# For a 512/128 kbps ADSL with PPPoE link, using "bandwidth 100Kb"
19# is optimal. Some experimentation might be needed to find the best
20# value. If it's set too high, the priority queue is not effective, and
21# if it's set too low, the available bandwidth is not fully used.
22# A good starting point would be real_uplink_bandwidth * 90 / 100.
23
24altq on $ext_if priq bandwidth 100Kb queue { q_pri, q_def }
25queue q_pri priority 7
26queue q_def priority 1 priq(default)
27
28pass out on $ext_if proto tcp from $ext_if to any queue (q_def, q_pri)
29
30pass in  on $ext_if proto tcp from any to $ext_if queue (q_def, q_pri)
31
32