1The rate estimator can match on estimated rates as collected by the RATEEST
2target. It supports matching on absolute bps/pps values, comparing two rate
3estimators and matching on the difference between two rate estimators.
4.PP
5For a better understanding of the available options, these are all possible
6combinations:
7.\" * Absolute:
8.IP \(bu 4
9\fBrateest\fP \fIoperator\fP \fBrateest-bps\fP
10.IP \(bu 4
11\fBrateest\fP \fIoperator\fP \fBrateest-pps\fP
12.\" * Absolute + Delta:
13.IP \(bu 4
14(\fBrateest\fP minus \fBrateest-bps1\fP) \fIoperator\fP \fBrateest-bps2\fP
15.IP \(bu 4
16(\fBrateest\fP minus \fBrateest-pps1\fP) \fIoperator\fP \fBrateest-pps2\fP
17.\" * Relative:
18.IP \(bu 4
19\fBrateest1\fP \fIoperator\fP \fBrateest2\fP \fBrateest-bps\fP(without rate!)
20.IP \(bu 4
21\fBrateest1\fP \fIoperator\fP \fBrateest2\fP \fBrateest-pps\fP(without rate!)
22.\" * Relative + Delta:
23.IP \(bu 4
24(\fBrateest1\fP minus \fBrateest-bps1\fP) \fIoperator\fP
25(\fBrateest2\fP minus \fBrateest-bps2\fP)
26.IP \(bu 4
27(\fBrateest1\fP minus \fBrateest-pps1\fP) \fIoperator\fP
28(\fBrateest2\fP minus \fBrateest-pps2\fP)
29.TP
30\fB\-\-rateest\-delta\fP
31For each estimator (either absolute or relative mode), calculate the difference
32between the estimator-determined flow rate and the static value chosen with the
33BPS/PPS options. If the flow rate is higher than the specified BPS/PPS, 0 will
34be used instead of a negative value. In other words, "max(0, rateest#_rate -
35rateest#_bps)" is used.
36.TP
37[\fB!\fP] \fB\-\-rateest\-lt\fP
38Match if rate is less than given rate/estimator.
39.TP
40[\fB!\fP] \fB\-\-rateest\-gt\fP
41Match if rate is greater than given rate/estimator.
42.TP
43[\fB!\fP] \fB\-\-rateest\-eq\fP
44Match if rate is equal to given rate/estimator.
45.PP
46In the so-called "absolute mode", only one rate estimator is used and compared
47against a static value, while in "relative mode", two rate estimators are
48compared against another.
49.TP
50\fB\-\-rateest\fP \fIname\fP
51Name of the one rate estimator for absolute mode.
52.TP
53\fB\-\-rateest1\fP \fIname\fP
54.TP
55\fB\-\-rateest2\fP \fIname\fP
56The names of the two rate estimators for relative mode.
57.TP
58\fB\-\-rateest\-bps\fP [\fIvalue\fP]
59.TP
60\fB\-\-rateest\-pps\fP [\fIvalue\fP]
61.TP
62\fB\-\-rateest\-bps1\fP [\fIvalue\fP]
63.TP
64\fB\-\-rateest\-bps2\fP [\fIvalue\fP]
65.TP
66\fB\-\-rateest\-pps1\fP [\fIvalue\fP]
67.TP
68\fB\-\-rateest\-pps2\fP [\fIvalue\fP]
69Compare the estimator(s) by bytes or packets per second, and compare against
70the chosen value. See the above bullet list for which option is to be used in
71which case. A unit suffix may be used - available ones are: bit, [kmgt]bit,
72[KMGT]ibit, Bps, [KMGT]Bps, [KMGT]iBps.
73.PP
74Example: This is what can be used to route outgoing data connections from an
75FTP server over two lines based on the available bandwidth at the time the data
76connection was started:
77.PP
78# Estimate outgoing rates
79.PP
80iptables \-t mangle \-A POSTROUTING \-o eth0 \-j RATEEST \-\-rateest\-name eth0
81\-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s
82.PP
83iptables \-t mangle \-A POSTROUTING \-o ppp0 \-j RATEEST \-\-rateest\-name ppp0
84\-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s
85.PP
86# Mark based on available bandwidth
87.PP
88iptables \-t mangle \-A balance \-m conntrack \-\-ctstate NEW \-m helper \-\-helper ftp
89\-m rateest \-\-rateest\-delta \-\-rateest1 eth0 \-\-rateest\-bps1 2.5mbit \-\-rateest\-gt
90\-\-rateest2 ppp0 \-\-rateest\-bps2 2mbit \-j CONNMARK \-\-set\-mark 1
91.PP
92iptables \-t mangle \-A balance \-m conntrack \-\-ctstate NEW \-m helper \-\-helper ftp
93\-m rateest \-\-rateest\-delta \-\-rateest1 ppp0 \-\-rateest\-bps1 2mbit \-\-rateest\-gt
94\-\-rateest2 eth0 \-\-rateest\-bps2 2.5mbit \-j CONNMARK \-\-set\-mark 2
95.PP
96iptables \-t mangle \-A balance \-j CONNMARK \-\-restore\-mark
97