Search This Blog

Friday, March 12, 2010

shaping: balancing hosts, then connections

I have HTB shaping set up on internet interface eth0 with rate limiting.
# tc qdisc add dev eth0 root handle 1: htb default 13
# tc class add dev eth0 parent 1:0 classid 1:1 htb rate ${UP}bps ceil ${UP}bps

Then split into 3 groups by MARKs:
# tc filter add dev eth0 parent 1: handle 21 protocol ip \
u32 match mark 0x00001 0x0000F flowid 1:11
# tc filter add dev eth0 parent 1: handle 22 protocol ip \
u32 match mark 0x00002 0x0000F flowid 1:12
# tc filter add dev eth0 parent 1: handle 23 protocol ip \
u32 match mark 0x00003 0x0000F flowid 1:13

One of those groups:
# ttc class add dev eth0 parent 1:1 classid 1:11 \
htb rate $( echo "$UP * 0.8" | bc )bps ceil ${UP}bps prio 1

Now this would logically follow:
# tc qdisc add dev eth0 parent 1:11 handle 11: sfq perturb 10

But I want to balance hosts, not flows/connections, so I include:
# tc filter add dev eth0 parent 11: handle 1 protocol ip \
flow hash keys nfct-src divisor 1024

Which I think works. But then multiple connections on a single host are not
fairly balanced. How can I do that?

More specifically: I would like, for each group like 1:11, to shape traffic in
this order:
- source host balance (like SFQ and nfct-src)
- PRIO qdisc (for TOS especially) for each
- SFQ (for flows/connections) for each PRIO qdisc

I do not have a static set of source hosts.

Alternative methods are welcome, especially if they accomplish the same thing.

Thanks.

No comments: