Blame man/man8/tc-sfq.8

Packit d3f73b
.TH TC 8 "24 January 2012" "iproute2" "Linux"
Packit d3f73b
.SH NAME
Packit d3f73b
sfq \- Stochastic Fairness Queueing
Packit d3f73b
.SH SYNOPSIS
Packit d3f73b
.B tc qdisc ...
Packit d3f73b
.B [ divisor
Packit d3f73b
hashtablesize
Packit d3f73b
.B ] [ limit
Packit d3f73b
packets
Packit d3f73b
.B ] [ perturb
Packit d3f73b
seconds
Packit d3f73b
.B ] [ quantum
Packit d3f73b
bytes
Packit d3f73b
.B ] [ flows
Packit d3f73b
number
Packit d3f73b
.B ] [ depth
Packit d3f73b
number
Packit d3f73b
.B ] [ headdrop
Packit d3f73b
.B ] [ redflowlimit
Packit d3f73b
bytes
Packit d3f73b
.B ] [ min
Packit d3f73b
bytes
Packit d3f73b
.B ] [ max
Packit d3f73b
bytes
Packit d3f73b
.B ] [ avpkt
Packit d3f73b
bytes
Packit d3f73b
.B ] [ burst
Packit d3f73b
packets
Packit d3f73b
.B ] [ probability
Packit d3f73b
P
Packit d3f73b
.B ] [ ecn
Packit d3f73b
.B ] [ harddrop ]
Packit d3f73b
.SH DESCRIPTION
Packit d3f73b
Packit d3f73b
Stochastic Fairness Queueing is a classless queueing discipline available for
Packit d3f73b
traffic control with the
Packit d3f73b
.BR tc (8)
Packit d3f73b
command.
Packit d3f73b
Packit d3f73b
SFQ does not shape traffic but only schedules the transmission of packets, based on 'flows'.
Packit d3f73b
The goal is to ensure fairness so that each flow is able to send data in turn, thus preventing
Packit d3f73b
any single flow from drowning out the rest.
Packit d3f73b
Packit d3f73b
This may in fact have some effect in mitigating a Denial of Service attempt.
Packit d3f73b
Packit d3f73b
SFQ is work-conserving and therefore always delivers a packet if it has one available.
Packit d3f73b
.SH ALGORITHM
Packit d3f73b
On enqueueing, each packet is assigned to a hash bucket, based on the packets hash value.
Packit d3f73b
This hash value is either obtained from an external flow classifier (use
Packit d3f73b
.B
Packit d3f73b
tc filter
Packit d3f73b
to set them), or a default internal classifier if no external classifier has been configured.
Packit d3f73b
Packit d3f73b
When the internal classifier is used, sfq uses
Packit d3f73b
.TP
Packit d3f73b
(i)
Packit d3f73b
Source address
Packit d3f73b
.TP
Packit d3f73b
(ii)
Packit d3f73b
Destination address
Packit d3f73b
.TP
Packit d3f73b
(iii)
Packit d3f73b
Source and Destination port
Packit d3f73b
.P
Packit d3f73b
If these are available. SFQ knows about ipv4 and ipv6 and also UDP, TCP and ESP.
Packit d3f73b
Packets with other protocols are hashed based on the 32bits representation of their
Packit d3f73b
destination and source. A flow corresponds mostly to a TCP/IP connection.
Packit d3f73b
Packit d3f73b
Each of these buckets should represent a unique flow. Because multiple flows may
Packit d3f73b
get hashed to the same bucket, sfqs internal hashing algorithm may be perturbed at configurable
Packit d3f73b
intervals so that the unfairness lasts only for a short while. Perturbation may
Packit d3f73b
however cause some inadvertent packet reordering to occur. After linux-3.3, there is
Packit d3f73b
no packet reordering problem, but possible packet drops if rehashing hits one limit
Packit d3f73b
(number of flows or packets per flow)
Packit d3f73b
Packit d3f73b
When dequeuing, each hashbucket with data is queried in a round robin fashion.
Packit d3f73b
Packit d3f73b
Before linux-3.3, the compile time maximum length of the SFQ is 128 packets, which can be spread over
Packit d3f73b
at most 128 buckets of 1024 available. In case of overflow, tail-drop is performed
Packit d3f73b
on the fullest bucket, thus maintaining fairness.
Packit d3f73b
Packit d3f73b
After linux-3.3, maximum length of SFQ is 65535 packets, and divisor limit is 65536.
Packit d3f73b
In case of overflow, tail-drop is performed on the fullest bucket, unless headdrop was requested.
Packit d3f73b
Packit d3f73b
.SH PARAMETERS
Packit d3f73b
.TP
Packit d3f73b
divisor
Packit d3f73b
Can be used to set a different hash table size, available from kernel 2.6.39 onwards.
Packit d3f73b
The specified divisor must be a power of two and cannot be larger than 65536.
Packit d3f73b
Default value: 1024.
Packit d3f73b
.TP
Packit d3f73b
limit
Packit d3f73b
Upper limit of the SFQ. Can be used to reduce the default length of 127 packets.
Packit d3f73b
After linux-3.3, it can be raised.
Packit d3f73b
.TP
Packit d3f73b
depth
Packit d3f73b
Limit of packets per flow (after linux-3.3). Default to 127 and can be lowered.
Packit d3f73b
.TP
Packit d3f73b
perturb
Packit d3f73b
Interval in seconds for queue algorithm perturbation. Defaults to 0, which means that
Packit d3f73b
no perturbation occurs. Do not set too low for each perturbation may cause some packet
Packit d3f73b
reordering or losses. Advised value: 60
Packit d3f73b
This value has no effect when external flow classification is used.
Packit d3f73b
Its better to increase divisor value to lower risk of hash collisions.
Packit d3f73b
.TP
Packit d3f73b
quantum
Packit d3f73b
Amount of bytes a flow is allowed to dequeue during a round of the round robin process.
Packit d3f73b
Defaults to the MTU of the interface which is also the advised value and the minimum value.
Packit d3f73b
.TP
Packit d3f73b
flows
Packit d3f73b
After linux-3.3, it is possible to change the default limit of flows.
Packit d3f73b
Default value is 127
Packit d3f73b
.TP
Packit d3f73b
headdrop
Packit d3f73b
Default SFQ behavior is to perform tail-drop of packets from a flow.
Packit d3f73b
You can ask a headdrop instead, as this is known to provide a better feedback for TCP flows.
Packit d3f73b
.TP
Packit d3f73b
redflowlimit
Packit d3f73b
Configure the optional RED module on top of each SFQ flow.
Packit d3f73b
Random Early Detection principle is to perform packet marks or drops in a probabilistic way.
Packit d3f73b
(man tc-red for details about RED)
Packit d3f73b
.nf
Packit d3f73b
redflowlimit configures the hard limit on the real (not average) queue size per SFQ flow in bytes.
Packit d3f73b
.fi
Packit d3f73b
.TP
Packit d3f73b
min
Packit d3f73b
Average queue size at which marking becomes a possibility. Defaults to
Packit d3f73b
.B max
Packit d3f73b
/3
Packit d3f73b
.TP
Packit d3f73b
max
Packit d3f73b
At this average queue size, the marking probability is maximal. Defaults to
Packit d3f73b
.B redflowlimit
Packit d3f73b
/4
Packit d3f73b
.TP
Packit d3f73b
probability
Packit d3f73b
Maximum  probability  for  marking, specified as a floating point number from 0.0 to 1.0. Default value is 0.02
Packit d3f73b
.TP
Packit d3f73b
avpkt
Packit d3f73b
Specified in bytes. Used with burst to determine the time constant for average queue size calculations. Default value is 1000
Packit d3f73b
.TP
Packit d3f73b
burst
Packit d3f73b
Used for determining how fast the average queue size is influenced by the real queue size.
Packit d3f73b
.nf
Packit d3f73b
Default value is :
Packit d3f73b
.B (2 * min + max) / (3 * avpkt)
Packit d3f73b
.fi
Packit d3f73b
.TP
Packit d3f73b
ecn
Packit d3f73b
RED can either 'mark' or 'drop'. Explicit Congestion
Packit d3f73b
Notification allows RED to notify remote hosts that their rate exceeds the
Packit d3f73b
amount of bandwidth available. Non-ECN capable hosts can only be notified by
Packit d3f73b
dropping a packet. If this parameter is specified, packets which indicate
Packit d3f73b
that their hosts honor ECN will only be marked and not dropped, unless the
Packit d3f73b
queue size hits
Packit d3f73b
.B depth
Packit d3f73b
packets.
Packit d3f73b
.TP
Packit d3f73b
harddrop
Packit d3f73b
If average flow queue size is above
Packit d3f73b
.B max
Packit d3f73b
bytes, this parameter forces a drop instead of ecn marking.
Packit d3f73b
.SH EXAMPLE & USAGE
Packit d3f73b
Packit d3f73b
To attach to device ppp0:
Packit d3f73b
.P
Packit d3f73b
# tc qdisc add dev ppp0 root sfq
Packit d3f73b
.P
Packit d3f73b
Please note that SFQ, like all non-shaping (work-conserving) qdiscs, is only useful
Packit d3f73b
if it owns the queue.
Packit d3f73b
This is the case when the link speed equals the actually available bandwidth. This holds
Packit d3f73b
for regular phone modems, ISDN connections and direct non-switched ethernet links.
Packit d3f73b
.P
Packit d3f73b
Most often, cable modems and DSL devices do not fall into this category. The same holds
Packit d3f73b
for when connected to a switch  and trying to send data to a congested segment also
Packit d3f73b
connected to the switch.
Packit d3f73b
.P
Packit d3f73b
In this case, the effective queue does not reside within Linux and is therefore not
Packit d3f73b
available for scheduling.
Packit d3f73b
.P
Packit d3f73b
Embed SFQ in a classful qdisc to make sure it owns the queue.
Packit d3f73b
Packit d3f73b
It is possible to use external classifiers with sfq, for example to hash traffic based only
Packit d3f73b
on source/destination ip addresses:
Packit d3f73b
.P
Packit d3f73b
# tc filter add ... flow hash keys src,dst perturb 30 divisor 1024
Packit d3f73b
.P
Packit d3f73b
Note that the given divisor should match the one used by sfq. If you have
Packit d3f73b
changed the sfq default of 1024, use the same value for the flow hash filter, too.
Packit d3f73b
Packit d3f73b
.P
Packit d3f73b
Example of sfq with optional RED mode :
Packit d3f73b
.P
Packit d3f73b
# tc qdisc add dev eth0 parent 1:1 handle 10: sfq limit 3000 flows 512 divisor 16384
Packit d3f73b
  redflowlimit 100000 min 8000 max 60000 probability 0.20 ecn headdrop
Packit d3f73b
Packit d3f73b
.SH SOURCE
Packit d3f73b
.TP
Packit d3f73b
o
Packit d3f73b
Paul E. McKenney "Stochastic Fairness Queuing",
Packit d3f73b
IEEE INFOCOMM'90 Proceedings, San Francisco, 1990.
Packit d3f73b
Packit d3f73b
.TP
Packit d3f73b
o
Packit d3f73b
Paul E. McKenney "Stochastic Fairness Queuing",
Packit d3f73b
"Interworking: Research and Experience", v.2, 1991, p.113-131.
Packit d3f73b
Packit d3f73b
.TP
Packit d3f73b
o
Packit d3f73b
See also:
Packit d3f73b
M. Shreedhar and George Varghese "Efficient Fair
Packit d3f73b
Queuing using Deficit Round Robin", Proc. SIGCOMM 95.
Packit d3f73b
Packit d3f73b
.SH SEE ALSO
Packit d3f73b
.BR tc (8),
Packit d3f73b
.BR tc-red (8)
Packit d3f73b
Packit d3f73b
.SH AUTHORS
Packit d3f73b
Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>,
Packit d3f73b
Eric Dumazet <eric.dumazet@gmail.com>.
Packit d3f73b
.P
Packit d3f73b
This manpage maintained by bert hubert <ahu@ds9a.nl>