xref: /dflybsd-src/share/examples/pf/ackpri (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino# $OpenBSD: ackpri,v 1.2 2003/03/10 14:24:33 henning Exp $
286d7f5d3SJohn Marino# $DragonFly: src/share/examples/pf/ackpri,v 1.1 2005/12/13 01:58:27 corecode Exp $
386d7f5d3SJohn Marino
486d7f5d3SJohn Marino# Use a simple priority queue to prioritize empty (no payload) TCP ACKs,
586d7f5d3SJohn Marino# which dramatically improves throughput on (asymmetric) links when the
686d7f5d3SJohn Marino# reverse direction is saturated. The empty ACKs use an insignificant
786d7f5d3SJohn Marino# part of the bandwidth, but if they get delayed, downloads suffer
886d7f5d3SJohn Marino# badly, so prioritize them.
986d7f5d3SJohn Marino
1086d7f5d3SJohn Marino# Example: 512/128 kbps ADSL. Download is 50 kB/s. When a concurrent
1186d7f5d3SJohn Marino# upload saturates the uplink, download drops to 7 kB/s. With the
1286d7f5d3SJohn Marino# priority queue below, download drops only to 48 kB/s.
1386d7f5d3SJohn Marino
1486d7f5d3SJohn Marino# Replace lo0 with your real external interface
1586d7f5d3SJohn Marino
1686d7f5d3SJohn Marinoext_if="lo0"
1786d7f5d3SJohn Marino
1886d7f5d3SJohn Marino# For a 512/128 kbps ADSL with PPPoE link, using "bandwidth 100Kb"
1986d7f5d3SJohn Marino# is optimal. Some experimentation might be needed to find the best
2086d7f5d3SJohn Marino# value. If it's set too high, the priority queue is not effective, and
2186d7f5d3SJohn Marino# if it's set too low, the available bandwidth is not fully used.
2286d7f5d3SJohn Marino# A good starting point would be real_uplink_bandwidth * 90 / 100.
2386d7f5d3SJohn Marino
2486d7f5d3SJohn Marinoaltq on $ext_if priq bandwidth 100Kb queue { q_pri, q_def }
2586d7f5d3SJohn Marinoqueue q_pri priority 7
2686d7f5d3SJohn Marinoqueue q_def priority 1 priq(default)
2786d7f5d3SJohn Marino
2886d7f5d3SJohn Marinopass out on $ext_if proto tcp from $ext_if to any flags S/SA \
2986d7f5d3SJohn Marino	keep state queue (q_def, q_pri)
3086d7f5d3SJohn Marino
3186d7f5d3SJohn Marinopass in  on $ext_if proto tcp from any to $ext_if flags S/SA \
3286d7f5d3SJohn Marino	keep state queue (q_def, q_pri)
3386d7f5d3SJohn Marino
34