xref: /freebsd/share/examples/pf/ackpri (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
142a227f8SMax Laier# $OpenBSD: ackpri,v 1.3 2006/10/07 04:48:01 mcbride Exp $
29d7ccc0fSMax Laier
39d7ccc0fSMax Laier# Use a simple priority queue to prioritize empty (no payload) TCP ACKs,
49d7ccc0fSMax Laier# which dramatically improves throughput on (asymmetric) links when the
59d7ccc0fSMax Laier# reverse direction is saturated. The empty ACKs use an insignificant
69d7ccc0fSMax Laier# part of the bandwidth, but if they get delayed, downloads suffer
79d7ccc0fSMax Laier# badly, so prioritize them.
89d7ccc0fSMax Laier
99d7ccc0fSMax Laier# Example: 512/128 kbps ADSL. Download is 50 kB/s. When a concurrent
109d7ccc0fSMax Laier# upload saturates the uplink, download drops to 7 kB/s. With the
119d7ccc0fSMax Laier# priority queue below, download drops only to 48 kB/s.
129d7ccc0fSMax Laier
139d7ccc0fSMax Laier# Replace lo0 with your real external interface
149d7ccc0fSMax Laier
159d7ccc0fSMax Laierext_if="lo0"
169d7ccc0fSMax Laier
179d7ccc0fSMax Laier# For a 512/128 kbps ADSL with PPPoE link, using "bandwidth 100Kb"
189d7ccc0fSMax Laier# is optimal. Some experimentation might be needed to find the best
199d7ccc0fSMax Laier# value. If it's set too high, the priority queue is not effective, and
209d7ccc0fSMax Laier# if it's set too low, the available bandwidth is not fully used.
219d7ccc0fSMax Laier# A good starting point would be real_uplink_bandwidth * 90 / 100.
229d7ccc0fSMax Laier
239d7ccc0fSMax Laieraltq on $ext_if priq bandwidth 100Kb queue { q_pri, q_def }
249d7ccc0fSMax Laierqueue q_pri priority 7
259d7ccc0fSMax Laierqueue q_def priority 1 priq(default)
269d7ccc0fSMax Laier
2742a227f8SMax Laierpass out on $ext_if proto tcp from $ext_if to any queue (q_def, q_pri)
289d7ccc0fSMax Laier
2942a227f8SMax Laierpass in  on $ext_if proto tcp from any to $ext_if queue (q_def, q_pri)
309d7ccc0fSMax Laier
31