QoS using DSCP

Discussion in 'Linux Networking' started by Maciej Matachowski, Feb 7, 2008.

  1. The problem consist in following. The script is attached to OpenWRT on
    linksys router. Then I stream from one network to another. I use
    IPTABLES command to mark the outgoing packets with DSCP field.
    Parallely
    with that I start to flood with Best Effort packets just to check if
    BE
    traffic affects DSCP traffic.


    #!/bin/sh -x

    insmod /lib/modules/2.4.34/sch_dsmark.o
    insmod /lib/modules/2.4.34/cls_tcindex.o
    insmod /lib/modules/2.4.34/sch_htb.o
    insmod /lib/modules/2.4.34/sch_gred.o
    insmod /lib/modules/2.4.34/sch_red.o

    interface=br-lan
    rate=15Mbit
    ceil=15Mbit

    qrate=1500Kbit

    limit=128KB
    min=20KB
    max=60KB

    burst=20
    avpkt=1000

    bandwidth=15Mbit

    # Creating tcindex table
    tc qdisc add dev $interface handle 1:0 root dsmark indices 64
    set_tc_index
    tc filter add dev $interface parent 1:0 protocol ip prio 1 tcindex
    mask
    0xfc shift 2 pass_on

    # Classification's elements / Architecture elements

    # Class AF1
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 10
    tcindex classid 1:111
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 12
    tcindex classid 1:112
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 14
    tcindex classid 1:113
    # Class AF2
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 18
    tcindex classid 1:121
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 20
    tcindex classid 1:122
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 22
    tcindex classid 1:123
    # Class AF3
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 26
    tcindex classid 1:131
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 28
    tcindex classid 1:132
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 30
    tcindex classid 1:133
    # Class AF4
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 34
    tcindex classid 1:141
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 36
    tcindex classid 1:142
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 38
    tcindex classid 1:143
    # Class BF
    tc filter add dev $interface parent 1:0 protocol ip prio 2 handle 0
    tcindex mask 0 classid 1:1
    # Class EF
    tc filter add dev $interface parent 1:0 protocol ip prio 1 handle 46
    tcindex classid 1:150


    # HTB filter
    tc qdisc add dev $interface parent 1:0 handle 2:0 htb

    tc class add dev $interface parent 2:0 classid 2:1 htb rate $rate ceil
    $ceil

    tc filter add dev $interface parent 2:0 protocol ip prio 1 tcindex
    mask
    0xf0 shift 4 pass_on


    # AF class 1
    tc class add dev $interface parent 2:1 classid 2:10 htb rate $qrate
    ceil
    $ceil
    tc qdisc add dev $interface parent 2:10 gred setup DPs 3 default 2
    grio

    tc filter add dev $interface parent 2:0 protocol ip prio 1 handle 1
    tcindex classid 2:10

    # AF Class 11
    tc qdisc change dev $interface parent 2:10 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 1
    probability
    0.02 prio 2
    # AF Class 12
    tc qdisc change dev $interface parent 2:10 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 2
    probability
    0.04 prio 3
    # AF Class 13
    tc qdisc change dev $interface parent 2:10 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 3
    probability
    0.06 prio 4


    # AF Class 2
    tc class add dev $interface parent 2:1 classid 2:20 htb rate $qrate
    ceil
    $ceil
    tc qdisc add dev $interface parent 2:20 gred setup DPs 3 default 2
    grio

    tc filter add dev $interface parent 2:0 protocol ip prio 1 handle 2
    tcindex classid 2:20

    # AF Class 21
    tc qdisc change dev $interface parent 2:20 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 1
    probability
    0.02 prio 2
    # AF Class 22
    tc qdisc change dev $interface parent 2:20 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 2
    probability
    0.04 prio 3
    # AF Class 23
    tc qdisc change dev $interface parent 2:20 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 3
    probability
    0.06 prio 4


    # AF Class 3
    tc class add dev $interface parent 2:1 classid 2:30 htb rate $qrate
    ceil
    $ceil
    tc qdisc add dev $interface parent 2:30 gred setup DPs 3 default 2
    grio

    tc filter add dev $interface parent 2:0 protocol ip prio 1 handle 3
    tcindex classid 2:30

    # AF Class 31
    tc qdisc change dev $interface parent 2:30 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 1
    probability
    0.02 prio 2
    # AF Class 32
    tc qdisc change dev $interface parent 2:30 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 2
    probability
    0.04 prio 3
    # AF Class 33
    tc qdisc change dev $interface parent 2:30 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 3
    probability
    0.06 prio 4


    # AF Class 4
    tc class add dev $interface parent 2:1 classid 2:40 htb rate $qrate
    ceil
    $ceil
    tc qdisc add dev $interface parent 2:40 gred setup DPs 3 default 2
    grio

    tc filter add dev $interface parent 2:0 protocol ip prio 1 handle 4
    tcindex classid 2:40

    # AF Class 41
    tc qdisc change dev $interface parent 2:40 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 1
    probability
    0.02 prio 2
    # AF Class 42
    tc qdisc change dev $interface parent 2:40 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 2
    probability
    0.04 prio 3
    # AF Class 43
    tc qdisc change dev $interface parent 2:40 gred limit $limit min $min
    max $max burst $burst avpkt $avpkt bandwidth $bandwidth DP 3
    probability
    0.06 prio 4


    # BE
    tc class add dev $interface parent 2:1 classid 2:50 htb rate $qrate
    ceil
    $ceil
    tc qdisc add dev $interface parent 2:50 red limit $limit min $min max
    $max burst $burst avpkt $avpkt bandwidth $bandwidth probability 0.4

    tc filter add dev $interface parent 2:0 protocol ip prio 1 handle 0
    tcindex classid 2:50


    # EF
    tc class add dev $interface parent 2:1 classid 2:60 htb rate $qrate
    ceil
    $ceil
    tc qdisc add dev $interface parent 2:60 red limit $limit min $min max
    $max burst $burst avpkt $avpkt bandwidth $bandwidth probability 0.2

    tc filter add dev $interface parent 2:0 protocol ip prio 1 handle 5
    tcindex classid 2:60

    From script you can see that I have a separate queues allocated for
    each traffic but when I start BE traffic I see that it affects DSCP
    traffic. Can you explain what is the reason and how I can correct it?

    thx

    Regards,
    Maciek
     
    Maciej Matachowski, Feb 7, 2008
    #1
    1. Advertisements

  2. Maciej Matachowski

    Andy Furniss Guest

    I've never used DSCP or *RED so can't really spot errors in the script
    as such.

    I can comment generally on a few things.

    If you are doing all of this on one device then it seems overcomplicated
    to use DHCP - you may as well just mark with iptables and filter on
    those (there is a way to get htb to map marks to classes without any
    filters at all)

    *RED AFAIK was designed and tested as root on a fixed bandwidth link -
    you have several attached to htb classes with variable rates. I am not
    saying it won't work at all but it's something to consider.

    I am not sure of your setup - shaping on br-lan I wonder where the
    traffic is coming from - if 15mbit is a WAN say ADSL2 then that's
    shaping from the wrong end of a bottleneck which has issues which
    shaping from the right end doesn't.

    If you keep this setup, the way you are using htb means that all the
    classes are equal. It would be better to use htb's prio option to give
    the latency sensitive traffic priority - but this also affects how htb
    shares bandwidth.

    Andy.
     
    Andy Furniss, Feb 9, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.