Blame man/man8/tc-sfq.8

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