{
    "content": [
        {
            "type": "text",
            "text": "# tc-sfq (info)\n\n## NAME\n\nsfq - Stochastic Fairness Queueing\n\n## SYNOPSIS\n\ntc  qdisc  ...   [  divisor hashtablesize ] [ limit packets ] [ perturb\nseconds ] [ quantum bytes ] [ flows number ] [ depth number ]  [  head-\ndrop ] [ redflowlimit bytes ] [ min bytes ] [ max bytes ] [ avpkt bytes\n] [ burst packets ] [ probability P ] [ ecn ] [ harddrop ]\n\n## DESCRIPTION\n\nStochastic Fairness Queueing is a classless queueing discipline  avail-\nable for traffic control with the tc(8) command.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **ALGORITHM**\n- **PARAMETERS**\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": "info",
        "summary": "sfq - Stochastic Fairness Queueing",
        "synopsis": "tc  qdisc  ...   [  divisor hashtablesize ] [ limit packets ] [ perturb\nseconds ] [ quantum bytes ] [ flows number ] [ depth number ]  [  head-\ndrop ] [ redflowlimit bytes ] [ min bytes ] [ max bytes ] [ avpkt bytes\n] [ 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": 5,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "ALGORITHM",
                "lines": 38,
                "subsections": []
            },
            {
                "name": "PARAMETERS",
                "lines": 103,
                "subsections": []
            },
            {
                "name": "SOURCE",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "sfq - Stochastic Fairness Queueing\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "tc  qdisc  ...   [  divisor hashtablesize ] [ limit packets ] [ perturb\nseconds ] [ quantum bytes ] [ flows number ] [ depth number ]  [  head-\ndrop ] [ redflowlimit bytes ] [ min bytes ] [ max bytes ] [ avpkt bytes\n] [ burst packets ] [ probability P ] [ ecn ] [ harddrop ]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Stochastic Fairness Queueing is a classless queueing discipline  avail-\nable for traffic control with the tc(8) command.\n\nSFQ does not shape traffic but only schedules the transmission of pack-\nets, based on 'flows'.  The goal is to ensure  fairness  so  that  each\nflow is able to send data in turn, thus preventing any single flow from\ndrowning out the rest.\n\nThis may in fact have some effect in mitigating a Denial of Service at-\ntempt.\n\nSFQ is work-conserving and therefore always delivers a packet if it has\none available.\n",
                "subsections": []
            },
            "ALGORITHM": {
                "content": "On enqueueing, each packet is assigned to a hash bucket, based  on  the\npackets  hash value.  This hash value is either obtained from an exter-\nnal flow classifier (use tc filter to set them), or a default  internal\nclassifier 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\nand ESP.  Packets with other protocols are hashed based on  the  32bits\nrepresentation  of  their  destination  and  source. A flow corresponds\nmostly to a TCP/IP connection.\n\nEach of these buckets should represent a unique flow. Because  multiple\nflows  may  get  hashed to the same bucket, sfqs internal hashing algo-\nrithm may be perturbed at configurable intervals so that the unfairness\nlasts only for a short while. Perturbation may however cause some inad-\nvertent packet reordering to occur. After linux-3.3, there is no packet\nreordering  problem,  but  possible  packet drops if rehashing hits one\nlimit (number of flows or packets per flow)\n\nWhen dequeuing, each hashbucket with data is queried in a  round  robin\nfashion.\n\nBefore  linux-3.3,  the  compile  time maximum length of the SFQ is 128\npackets, which can be spread over at most 128 buckets  of  1024  avail-\nable.  In  case  of  overflow,  tail-drop  is  performed on the fullest\nbucket, thus maintaining fairness.\n\nAfter linux-3.3, maximum length of SFQ is 65535  packets,  and  divisor\nlimit  is  65536.   In  case of overflow, tail-drop is performed on the\nfullest bucket, unless headdrop was requested.\n",
                "subsections": []
            },
            "PARAMETERS": {
                "content": "divisor\nCan be used to set a different hash table size,  available  from\nkernel 2.6.39 onwards.  The specified divisor must be a power of\ntwo and cannot be larger than 65536.  Default value: 1024.\n\nlimit  Upper limit of the SFQ. Can be used to reduce the default length\nof 127 packets.  After linux-3.3, it can be raised.\n\ndepth  Limit  of packets per flow (after linux-3.3). Default to 127 and\ncan be lowered.\n\nperturb\nInterval in seconds for queue algorithm  perturbation.  Defaults\nto  0,  which  means that no perturbation occurs. Do not set too\nlow for each perturbation may cause some  packet  reordering  or\nlosses. Advised value: 60 This value has no effect when external\nflow classification is used.  Its  better  to  increase  divisor\nvalue to lower risk of hash collisions.\n\nquantum\nAmount  of  bytes a flow is allowed to dequeue during a round of\nthe round robin process.  Defaults to the MTU of  the  interface\nwhich is also the advised value and the minimum value.\n\nflows  After  linux-3.3,  it is possible to change the default limit of\nflows.  Default value is 127\n\nheaddrop\nDefault SFQ behavior is to perform tail-drop of packets  from  a\nflow.   You can ask a headdrop instead, as this is known to pro-\nvide a better feedback for TCP flows.\n\nredflowlimit\nConfigure the optional RED module on top of each SFQ flow.  Ran-\ndom  Early  Detection  principle  is  to perform packet marks or\ndrops in a probabilistic way.  (man  tc-red  for  details  about\nRED)\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. De-\nfaults to max /3\n\nmax    At this average queue size, the marking probability is  maximal.\nDefaults to redflowlimit /4\n\nprobability\nMaximum   probability   for   marking,  specified  as a floating\npoint number from 0.0 to 1.0. Default value is 0.02\n\navpkt  Specified in bytes. Used with burst to determine the  time  con-\nstant for average queue size calculations. Default value is 1000\n\nburst  Used  for  determining how fast the average queue size is influ-\nenced by the real queue size.\nDefault value is :\n(2 * min + max) / (3 * avpkt)\n\necn    RED can either 'mark' or 'drop'. Explicit  Congestion  Notifica-\ntion  allows  RED to notify remote hosts that their rate exceeds\nthe amount of bandwidth available.  Non-ECN  capable  hosts  can\nonly  be  notified  by  dropping  a packet. If this parameter is\nspecified, packets which indicate that  their  hosts  honor  ECN\nwill  only be marked and not dropped, unless the queue size hits\ndepth packets.\n\nharddrop\nIf average flow queue size is above max  bytes,  this  parameter\nforces a drop instead of ecn marking.\n\nEXAMPLE & USAGE\nTo 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\nonly useful if it owns the queue.  This is the case when the link speed\nequals  the  actually available bandwidth. This holds for regular phone\nmodems, ISDN connections and direct non-switched ethernet links.\n\nMost often, cable modems and DSL devices do not fall  into  this  cate-\ngory. The same holds for when connected to a switch  and trying to send\ndata to a congested segment also connected to the switch.\n\nIn this case, the effective queue does not reside within Linux  and  is\ntherefore not available for 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\nhash traffic based only on 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\nhave  changed  the sfq default of 1024, use the same value for the flow\nhash filter, too.\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\ndivisor 16384\nredflowlimit 100000 min 8000 max 60000 probability 0.20 ecn headdrop\n",
                "subsections": []
            },
            "SOURCE": {
                "content": "o      Paul E. McKenney \"Stochastic Fairness Queuing\", IEEE INFOCOMM'90\nProceedings, San Francisco, 1990.\n\no      Paul E. McKenney \"Stochastic Fairness  Queuing\",  \"Interworking:\nResearch and Experience\", v.2, 1991, p.113-131.\n\no      See also: M. Shreedhar and George Varghese \"Efficient Fair Queu-\ning using Deficit Round Robin\", Proc. SIGCOMM 95.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "tc(8), tc-red(8)\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Alexey N. Kuznetsov,  <kuznet@ms2.inr.ac.ru>,  Eric  Dumazet  <eric.du-\nmazet@gmail.com>.\n\nThis manpage maintained by bert hubert <ahu@ds9a.nl>\n\niproute2                        24 January 2012                          TC(8)",
                "subsections": []
            }
        }
    }
}