{
    "content": [
        {
            "type": "text",
            "text": "# tc-sfq (man)\n\n## NAME\n\nsfq - Stochastic Fairness Queueing\n\n## SYNOPSIS\n\ntc qdisc ...  [ divisor hashtablesize ] [ limit packets ] [ perturb seconds ] [ quantum bytes\n] [ flows number ] [ depth number ] [ headdrop ] [ redflowlimit bytes ] [ min bytes ]  [  max\nbytes ] [ avpkt bytes ] [ burst packets ] [ probability P ] [ ecn ] [ harddrop ]\n\n## DESCRIPTION\n\nStochastic Fairness Queueing is a classless queueing discipline available for traffic control\nwith the tc(8) command.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **ALGORITHM**\n- **PARAMETERS** (1 subsections)\n- **SOURCE**\n- **SEE ALSO**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "tc-sfq",
        "section": "",
        "mode": "man",
        "summary": "sfq - Stochastic Fairness Queueing",
        "synopsis": "tc qdisc ...  [ divisor hashtablesize ] [ limit packets ] [ perturb seconds ] [ quantum bytes\n] [ flows number ] [ depth number ] [ headdrop ] [ redflowlimit bytes ] [ min bytes ]  [  max\nbytes ] [ avpkt bytes ] [ burst packets ] [ probability P ] [ ecn ] [ harddrop ]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "tc",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/tc/8/json"
            },
            {
                "name": "tc-red",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/tc-red/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "ALGORITHM",
                "lines": 33,
                "subsections": []
            },
            {
                "name": "PARAMETERS",
                "lines": 62,
                "subsections": [
                    {
                        "name": "EXAMPLE & USAGE",
                        "lines": 33
                    }
                ]
            },
            {
                "name": "SOURCE",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "sfq - Stochastic Fairness Queueing\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "tc qdisc ...  [ divisor hashtablesize ] [ limit packets ] [ perturb seconds ] [ quantum bytes\n] [ flows number ] [ depth number ] [ headdrop ] [ redflowlimit bytes ] [ min bytes ]  [  max\nbytes ] [ avpkt bytes ] [ burst packets ] [ probability P ] [ ecn ] [ harddrop ]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Stochastic Fairness Queueing is a classless queueing discipline available for traffic control\nwith the tc(8) command.\n\nSFQ does not shape traffic but only schedules the transmission of packets, based on  'flows'.\nThe  goal is to ensure fairness so that each flow is able to send data in turn, thus prevent‐\ning any single flow from drowning out the rest.\n\nThis may in fact have some effect in mitigating a Denial of Service attempt.\n\nSFQ is work-conserving and therefore always delivers a packet if it has one available.\n",
                "subsections": []
            },
            "ALGORITHM": {
                "content": "On enqueueing, each packet is assigned to a hash bucket, based on  the  packets  hash  value.\nThis  hash  value  is  either obtained from an external flow classifier (use tc filter to set\nthem), or a default internal classifier if no external classifier has been configured.\n\nWhen the internal classifier is used, sfq uses\n\n(i)    Source address\n\n(ii)   Destination address\n\n(iii)  Source and Destination port\n\nIf these are available. SFQ knows about ipv4 and ipv6 and also UDP,  TCP  and  ESP.   Packets\nwith  other  protocols are hashed based on the 32bits representation of their destination and\nsource. A flow corresponds mostly to a TCP/IP connection.\n\nEach of these buckets should represent a unique flow. Because multiple flows may  get  hashed\nto  the  same bucket, sfqs internal hashing algorithm may be perturbed at configurable inter‐\nvals so that the unfairness lasts only for a short while. Perturbation may however cause some\ninadvertent  packet reordering to occur. After linux-3.3, there is no packet reordering prob‐\nlem, but possible packet drops if rehashing hits one limit (number of flows  or  packets  per\nflow)\n\nWhen dequeuing, each hashbucket with data is queried in a round robin fashion.\n\nBefore  linux-3.3,  the  compile  time maximum length of the SFQ is 128 packets, which can be\nspread over at most 128 buckets of 1024 available. In case of  overflow,  tail-drop  is  per‐\nformed on the fullest bucket, thus maintaining fairness.\n\nAfter linux-3.3, maximum length of SFQ is 65535 packets, and divisor limit is 65536.  In case\nof overflow, tail-drop is performed on the fullest bucket, unless headdrop was requested.\n\n",
                "subsections": []
            },
            "PARAMETERS": {
                "content": "divisor\nCan be used to set a different hash table size, available from kernel 2.6.39  onwards.\nThe specified divisor must be a power of two and cannot be larger than 65536.  Default\nvalue: 1024.\n\nlimit  Upper limit of the SFQ. Can be used to reduce the default length of 127 packets.   Af‐\nter linux-3.3, it can be raised.\n\ndepth  Limit of packets per flow (after linux-3.3). Default to 127 and can be lowered.\n\nperturb\nInterval  in seconds for queue algorithm perturbation. Defaults to 0, which means that\nno perturbation occurs. Do not set too low for each perturbation may cause some packet\nreordering  or  losses.  Advised value: 60 This value has no effect when external flow\nclassification is used.  Its better to increase divisor value to lower  risk  of  hash\ncollisions.\n\nquantum\nAmount  of  bytes  a  flow  is  allowed  to  dequeue during a round of the round robin\nprocess.  Defaults to the MTU of the interface which is also the advised value and the\nminimum value.\n\nflows  After  linux-3.3,  it is possible to change the default limit of flows.  Default value\nis 127\n\nheaddrop\nDefault SFQ behavior is to perform tail-drop of packets from a flow.  You  can  ask  a\nheaddrop instead, as this is known to provide a better feedback for TCP flows.\n\nredflowlimit\nConfigure  the  optional  RED  module on top of each SFQ flow.  Random Early Detection\nprinciple is to perform packet marks or drops in a probabilistic way.  (man tc-red for\ndetails about RED)\nredflowlimit configures the hard limit on the real (not average) queue size per SFQ flow in bytes.\n\nmin    Average queue size at which marking becomes a possibility. Defaults to max /3\n\nmax    At  this  average  queue  size,  the  marking probability is maximal. Defaults to red‐‐\nflowlimit /4\n\nprobability\nMaximum  probability  for  marking, specified as a floating point number from  0.0  to\n1.0. Default value is 0.02\n\navpkt  Specified  in  bytes. Used with burst to determine the time constant for average queue\nsize calculations. Default value is 1000\n\nburst  Used for determining how fast the average queue size is influenced by the  real  queue\nsize.\nDefault value is :\n(2 * min + max) / (3 * avpkt)\n\necn    RED can either 'mark' or 'drop'. Explicit Congestion Notification allows RED to notify\nremote hosts that their rate exceeds the amount of bandwidth available. Non-ECN  capa‐\nble  hosts  can only be notified by dropping a packet. If this parameter is specified,\npackets which indicate that their hosts honor ECN will only be marked and not dropped,\nunless the queue size hits depth packets.\n\nharddrop\nIf average flow queue size is above max bytes, this parameter forces a drop instead of\necn marking.\n",
                "subsections": [
                    {
                        "name": "EXAMPLE & USAGE",
                        "content": "To attach to device ppp0:\n\n# tc qdisc add dev ppp0 root sfq\n\nPlease note that SFQ, like all non-shaping (work-conserving) qdiscs, is  only  useful  if  it\nowns  the  queue.   This  is the case when the link speed equals the actually available band‐\nwidth. This holds for regular phone modems, ISDN connections and direct non-switched ethernet\nlinks.\n\nMost  often,  cable modems and DSL devices do not fall into this category. The same holds for\nwhen connected to a switch  and trying to send data to a congested segment also connected  to\nthe switch.\n\nIn this case, the effective queue does not reside within Linux and is therefore not available\nfor scheduling.\n\nEmbed SFQ in a classful qdisc to make sure it owns the queue.\n\nIt is possible to use external classifiers with sfq, for example to hash traffic  based  only\non source/destination ip addresses:\n\n# tc filter add ... flow hash keys src,dst perturb 30 divisor 1024\n\nNote that the given divisor should match the one used by sfq. If you have changed the sfq de‐\nfault of 1024, use the same value for the flow hash filter, too.\n\n\nExample of sfq with optional RED mode :\n\n# tc qdisc add dev eth0 parent 1:1 handle 10: sfq limit 3000 flows 512 divisor 16384\nredflowlimit 100000 min 8000 max 60000 probability 0.20 ecn headdrop\n\n"
                    }
                ]
            },
            "SOURCE": {
                "content": "o      Paul E. McKenney \"Stochastic Fairness  Queuing\",  IEEE  INFOCOMM'90  Proceedings,  San\nFrancisco, 1990.\n\n\no      Paul  E.  McKenney  \"Stochastic Fairness Queuing\", \"Interworking: Research and Experi‐\nence\", v.2, 1991, p.113-131.\n\n\no      See also: M. Shreedhar and George Varghese \"Efficient Fair Queuing using Deficit Round\nRobin\", Proc. SIGCOMM 95.\n\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "tc(8), tc-red(8)\n\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>, Eric Dumazet <eric.dumazet@gmail.com>.\n\nThis manpage maintained by bert hubert <ahu@ds9a.nl>\n\n\n\niproute2                                   24 January 2012                                     TC(8)",
                "subsections": []
            }
        }
    }
}