Search code examples
linuxnetwork-programmingqostrafficshaping

tc-sfq alternative that limits by bytes?


Is there an alternative to tc-sfq (Stochastic Fairness Queueing) that allows to configure a limit based on the packet size (total bytes) instead of packet count?

The reason for this is that given a packet size of 50 bytes, one htb class (rate=1000kbit) could for example dequeue 25 packets per 10ms, but with a packet size of 1500 bytes only 0.83 packets per 10ms.

If I set the tc-sfq limit to 25 packets, then in the worst case a full queue would take 300ms to empty.

--

This is on Linux 3.0.101, so something like fq_codel doesn't work afaik. Maybe someone has a patch that replaces the sfq packet limit with a byte limit (similar to pfifo vs. bfifo)?


Solution

  • Here's what I did: I backported a few changes from the kernel tree into the linux 3.0 sfq.

    Since commit ddecf0... there is a backlog counter maintained for each slot. So all I needed to change is to use the depth parameter (sfq_sched_data.maxdepth) as max backlog bytes: simply drop the packet if slot->backlog >= q->maxdepth in the enqueue function.

    With a rate of 1000kbit I can now set depth 3750, which means that a slot takes max 30ms to empty. This could be 2 large packets with 1500 bytes each or 25 small ones with 150 bytes each.