blob: 5a651fff457bf0439ac065c237a10fab977feaf2 [file] [log] [blame]
Eric Dumazet50c6f3e2012-01-24 14:29:38 +01001.TH TC 8 "24 January 2012" "iproute2" "Linux"
osdl.org!shemminger985794a2004-06-08 20:34:17 +00002.SH NAME
3sfq \- Stochastic Fairness Queueing
4.SH SYNOPSIS
Florian Westphal610b22a2011-08-01 11:23:37 +00005.B tc qdisc ...
Eric Dumazet50c6f3e2012-01-24 14:29:38 +01006.B [ divisor
Florian Westphal610b22a2011-08-01 11:23:37 +00007hashtablesize
Eric Dumazet50c6f3e2012-01-24 14:29:38 +01008.B ] [ limit
Florian Westphal610b22a2011-08-01 11:23:37 +00009packets
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010010.B ] [ perturb
osdl.org!shemminger985794a2004-06-08 20:34:17 +000011seconds
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010012.B ] [ quantum
osdl.org!shemminger985794a2004-06-08 20:34:17 +000013bytes
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010014.B ] [ flows
15number
16.B ] [ depth
17number
18.B ] [ headdrop
19.B ] [ redflowlimit
20bytes
21.B ] [ min
22bytes
23.B ] [ max
24bytes
25.B ] [ avpkt
26bytes
27.B ] [ burst
28packets
29.B ] [ probability
30P
31.B ] [ ecn
32.B ] [ harddrop ]
osdl.org!shemminger985794a2004-06-08 20:34:17 +000033.SH DESCRIPTION
34
35Stochastic Fairness Queueing is a classless queueing discipline available for
36traffic control with the
37.BR tc (8)
38command.
39
40SFQ does not shape traffic but only schedules the transmission of packets, based on 'flows'.
41The goal is to ensure fairness so that each flow is able to send data in turn, thus preventing
42any single flow from drowning out the rest.
43
44This may in fact have some effect in mitigating a Denial of Service attempt.
45
46SFQ is work-conserving and therefore always delivers a packet if it has one available.
47.SH ALGORITHM
Florian Westphal610b22a2011-08-01 11:23:37 +000048On enqueueing, each packet is assigned to a hash bucket, based on the packets hash value.
49This hash value is either obtained from an external flow classifier (use
50.B
51tc filter
52to set them), or a default internal classifier if no external classifier has been configured.
53
54When the internal classifier is used, sfq uses
osdl.org!shemminger985794a2004-06-08 20:34:17 +000055.TP
56(i)
57Source address
58.TP
59(ii)
60Destination address
61.TP
62(iii)
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010063Source and Destination port
osdl.org!shemminger985794a2004-06-08 20:34:17 +000064.P
65If these are available. SFQ knows about ipv4 and ipv6 and also UDP, TCP and ESP.
66Packets with other protocols are hashed based on the 32bits representation of their
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010067destination and source. A flow corresponds mostly to a TCP/IP connection.
osdl.org!shemminger985794a2004-06-08 20:34:17 +000068
69Each of these buckets should represent a unique flow. Because multiple flows may
Florian Westphal610b22a2011-08-01 11:23:37 +000070get hashed to the same bucket, sfqs internal hashing algorithm may be perturbed at configurable
osdl.org!shemminger985794a2004-06-08 20:34:17 +000071intervals so that the unfairness lasts only for a short while. Perturbation may
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010072however cause some inadvertent packet reordering to occur. After linux-3.3, there is
73no packet reordering problem, but possible packet drops if rehashing hits one limit
74(number of flows or packets per flow)
osdl.org!shemminger985794a2004-06-08 20:34:17 +000075
76When dequeuing, each hashbucket with data is queried in a round robin fashion.
77
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010078Before linux-3.3, the compile time maximum length of the SFQ is 128 packets, which can be spread over
osdl.org!shemminger985794a2004-06-08 20:34:17 +000079at most 128 buckets of 1024 available. In case of overflow, tail-drop is performed
80on the fullest bucket, thus maintaining fairness.
81
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010082After linux-3.3, maximum length of SFQ is 65535 packets, and divisor limit is 65536.
83In case of overflow, tail-drop is performed on the fullest bucket, unless headdrop was requested.
84
osdl.org!shemminger985794a2004-06-08 20:34:17 +000085.SH PARAMETERS
Florian Westphal610b22a2011-08-01 11:23:37 +000086.TP
87divisor
88Can be used to set a different hash table size, available from kernel 2.6.39 onwards.
89The specified divisor must be a power of two and cannot be larger than 65536.
90Default value: 1024.
osdl.org!shemminger985794a2004-06-08 20:34:17 +000091.TP
Florian Westphal60de6502010-01-12 21:39:12 +010092limit
Eric Dumazet50c6f3e2012-01-24 14:29:38 +010093Upper limit of the SFQ. Can be used to reduce the default length of 127 packets.
94After linux-3.3, it can be raised.
95.TP
96depth
97Limit of packets per flow (after linux-3.3). Default to 127 and can be lowered.
Florian Westphal60de6502010-01-12 21:39:12 +010098.TP
osdl.org!shemminger985794a2004-06-08 20:34:17 +000099perturb
100Interval in seconds for queue algorithm perturbation. Defaults to 0, which means that
101no perturbation occurs. Do not set too low for each perturbation may cause some packet
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100102reordering or losses. Advised value: 60
Florian Westphal610b22a2011-08-01 11:23:37 +0000103This value has no effect when external flow classification is used.
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100104Its better to increase divisor value to lower risk of hash collisions.
osdl.org!shemminger985794a2004-06-08 20:34:17 +0000105.TP
106quantum
107Amount of bytes a flow is allowed to dequeue during a round of the round robin process.
108Defaults to the MTU of the interface which is also the advised value and the minimum value.
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100109.TP
110flows
111After linux-3.3, it is possible to change the default limit of flows.
112Default value is 127
113.TP
114headdrop
115Default SFQ behavior is to perform tail-drop of packets from a flow.
116You can ask a headdrop instead, as this is known to provide a better feedback for TCP flows.
117.TP
118redflowlimit
119Configure the optional RED module on top of each SFQ flow.
120Random Early Detection principle is to perform packet marks or drops in a probabilistic way.
121(man tc-red for details about RED)
122.nf
123redflowlimit configures the hard limit on the real (not average) queue size per SFQ flow in bytes.
124.fi
125.TP
126min
127Average queue size at which marking becomes a possibility. Defaults to
128.B max
129/3
130.TP
131max
132At this average queue size, the marking probability is maximal. Defaults to
133.B redflowlimit
134/4
135.TP
136probability
137Maximum probability for marking, specified as a floating point number from 0.0 to 1.0. Default value is 0.02
138.TP
139avpkt
140Specified in bytes. Used with burst to determine the time constant for average queue size calculations. Default value is 1000
141.TP
142burst
143Used for determining how fast the average queue size is influenced by the real queue size.
144.nf
145Default value is :
146.B (2 * min + max) / (3 * avpkt)
147.fi
148.TP
149ecn
150RED can either 'mark' or 'drop'. Explicit Congestion
151Notification allows RED to notify remote hosts that their rate exceeds the
152amount of bandwidth available. Non-ECN capable hosts can only be notified by
153dropping a packet. If this parameter is specified, packets which indicate
154that their hosts honor ECN will only be marked and not dropped, unless the
155queue size hits
156.B depth
157packets.
158.TP
159harddrop
160If average flow queue size is above
161.B max
162bytes, this parameter forces a drop instead of ecn marking.
osdl.org!shemminger985794a2004-06-08 20:34:17 +0000163.SH EXAMPLE & USAGE
164
165To attach to device ppp0:
166.P
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100167# tc qdisc add dev ppp0 root sfq
osdl.org!shemminger985794a2004-06-08 20:34:17 +0000168.P
169Please note that SFQ, like all non-shaping (work-conserving) qdiscs, is only useful
170if it owns the queue.
171This is the case when the link speed equals the actually available bandwidth. This holds
172for regular phone modems, ISDN connections and direct non-switched ethernet links.
173.P
174Most often, cable modems and DSL devices do not fall into this category. The same holds
175for when connected to a switch and trying to send data to a congested segment also
176connected to the switch.
177.P
178In this case, the effective queue does not reside within Linux and is therefore not
179available for scheduling.
180.P
181Embed SFQ in a classful qdisc to make sure it owns the queue.
182
Florian Westphal610b22a2011-08-01 11:23:37 +0000183It is possible to use external classifiers with sfq, for example to hash traffic based only
184on source/destination ip addresses:
185.P
186# tc filter add ... flow hash keys src,dst perturb 30 divisor 1024
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100187.P
Florian Westphal610b22a2011-08-01 11:23:37 +0000188Note that the given divisor should match the one used by sfq. If you have
189changed the sfq default of 1024, use the same value for the flow hash filter, too.
190
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100191.P
192Example of sfq with optional RED mode :
193.P
194# tc qdisc add dev eth0 parent 1:1 handle 10: sfq limit 3000 flows 512 divisor 16384
195 redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn headdrop
Florian Westphal610b22a2011-08-01 11:23:37 +0000196
osdl.org!shemminger985794a2004-06-08 20:34:17 +0000197.SH SOURCE
198.TP
199o
200Paul E. McKenney "Stochastic Fairness Queuing",
201IEEE INFOCOMM'90 Proceedings, San Francisco, 1990.
202
203.TP
204o
205Paul E. McKenney "Stochastic Fairness Queuing",
206"Interworking: Research and Experience", v.2, 1991, p.113-131.
207
208.TP
209o
210See also:
211M. Shreedhar and George Varghese "Efficient Fair
212Queuing using Deficit Round Robin", Proc. SIGCOMM 95.
213
214.SH SEE ALSO
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100215.BR tc (8),
216.BR tc-red (8)
osdl.org!shemminger985794a2004-06-08 20:34:17 +0000217
Eric Dumazet50c6f3e2012-01-24 14:29:38 +0100218.SH AUTHORS
219Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>,
220Eric Dumazet <eric.dumazet@gmail.com>.
221.P
222This manpage maintained by bert hubert <ahu@ds9a.nl>
osdl.org!shemminger985794a2004-06-08 20:34:17 +0000223
224