blob: 42a82f3229071ff650f96570c38eeef8c9b2f4f9 [file] [log] [blame]
Jan Engelhardta47bb4a2008-08-15 22:13:57 +02001The 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.
Jan Engelhardt25ea60d2011-05-17 15:17:08 +02004.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)
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020029.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010030\fB\-\-rateest\-delta\fP
Jan Engelhardt25ea60d2011-05-17 15:17:08 +020031For 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.
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020036.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010037[\fB!\fP] \fB\-\-rateest\-lt\fP
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020038Match if rate is less than given rate/estimator.
39.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010040[\fB!\fP] \fB\-\-rateest\-gt\fP
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020041Match if rate is greater than given rate/estimator.
42.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010043[\fB!\fP] \fB\-\-rateest\-eq\fP
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020044Match if rate is equal to given rate/estimator.
45.PP
Jan Engelhardt25ea60d2011-05-17 15:17:08 +020046In 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
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020074Example: 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
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010080iptables \-t mangle \-A POSTROUTING \-o eth0 \-j RATEEST \-\-rateest\-name eth0
81\-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020082.PP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010083iptables \-t mangle \-A POSTROUTING \-o ppp0 \-j RATEEST \-\-rateest\-name ppp0
84\-\-rateest\-interval 250ms \-\-rateest\-ewma 0.5s
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020085.PP
86# Mark based on available bandwidth
87.PP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010088iptables \-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
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020091.PP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010092iptables \-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
Jan Engelhardta47bb4a2008-08-15 22:13:57 +020095.PP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010096iptables \-t mangle \-A balance \-j CONNMARK \-\-restore\-mark