I've added a few more helper functions for a more complete demonstration. I've also added some suggested default values (see script). Here's an example usage for a 100mbit LAN:
# Load the functions into the environment # source diffserv.sh # # Set device queue length and MTU # init_device eth1 10 1500 # # Clear the device qdiscs # reset_qdisc eth1 # # Create the root DSMARK qdisc & filters. # init_classifier eth1 10: # # Now create our main HTB qdisc # We attach to the parent DSMARK qdisc (10:) and give ourselves a handle of 1: # qdisc eth1 "parent 10: handle 1: htb default 1 r2q 1" # # Now we create our leaf HTB + GRED classes and qdiscs to perform diffserv # Note that this will create HTB classes underneath the HTB qdisc (1:) # diffserv 1: eth1 100000 100000 1000 10 1500 1500 64 0
In a more complex setup, you can insert additional levels of HTB classes under
the HTB qdisc and then call 'diffserv' on those leaf classes, but remember to
add additional filters (can NOT use iptables CLASSIFY target) or traffic will
never reach those classes. 'diffserv' assumes traffic has already made it as far
as its parent qdisc (or class) and attaches it's filters there.
Dan-
Attachment:
diffserv.sh
Description: Bourne shell script