Guest User!

You are not Sophos Staff.

This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

New features #3 - IP Traffic shaping

With 2.4 kernel and iptables - it would be nice to have traffic shaping built into ASL.

Ørjan


This thread was automatically locked due to age.
Parents
  • Agree fully!!!

    I would like to use Traffic Shaping on the VPN tunnels, so i can put a MAX Bandwidth for a certain person.

    Would be very nice if you could write rules like. IF full bandwidth is taken shape VPNNET3 to 50%. Or something like that.

    RGS 
    LUNI
Reply
  • Agree fully!!!

    I would like to use Traffic Shaping on the VPN tunnels, so i can put a MAX Bandwidth for a certain person.

    Would be very nice if you could write rules like. IF full bandwidth is taken shape VPNNET3 to 50%. Or something like that.

    RGS 
    LUNI
Children
  • Gentlemen,

    I haven't attempted to impliment it as of yet, however, the iproute2 utility "tc" is located in "/bin" - this is the Linux traffic control tool used for traffic shaping.

    I would recommend all to read the Linux 2.4 Advanced Routing HOWTO.

    If the Astaro Admins have any input on how to best integrate traffic shaping into a stock Astaro install, please contribute!

    Regardless, I'll be off playing with it.

    Thanks
    Jake
  • Traffic control (shaping) - 

    Yes, aparently all the needed traffic control (QoS - Advanced routing) stuff has been compiled into the kernel leaving us with an operable platform for traffic control.

    The following (basic) script divides up a 512Kbit connection into a 160Kbit connection from internal computer 10.0.0.151 and a 80Kbit connection from 10.0.0.203 - any other computer using the Astaro box as the gateway is unaffected by the traffic control...

    Save the following into an executable script file and run it.  (Directly taken from the Linux 2.4 Advanced Routing HOWTO)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Divide the upstream bandwidth

    # Setup traffic control - queueing disciplin of eth0
    # we denote that this is the root discipline, given the handle of 10
    # we denote that CBQ is to be used
    # Tell the kernel that it can allocate 10Mbit
    # The average packet is somewhere around 1000 octets

    # Attach CBQ to eth0

    tc qdisc add dev eth0 root handle 10: cbq bandwidth 512Kbit avpkt 1000

    # Add root class

    tc class add dev eth0 parent 10:0 classid 10:1 cbq bandwidth 512Kbit rate \
    512Kbit allot 1514 weight 51Kbit prio 8 maxburst 20 avpkt 1000

    # Add default interactive class

    tc class add dev eth0 parent 10:1 classid 10:100 cbq bandwidth 512Kbit rate \
    160Kbit allot 1514 weight 16Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded

    # Add default class

    tc class add dev eth0 parent 10:1 classid 10:200 cbq bandwidth 512Kbit rate \
    80Kbit allot 1514 weight 8Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded


    # Tell the kernel how to manage the queues

    tc qdisc add dev eth0 parent 10:100 sfq quantum 1514b perturb 15
    tc qdisc add dev eth0 parent 10:200 sfq quantum 1514b perturb 15


    # Tells the kernel which packets belong to which class

    tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dst \
    10.0.0.203 flowid 10:200


    tc filter add dev eth0 parent 10:0 protocol ip prio 25 u32 match ip dst \
    10.0.0.151 flowid 10:100


    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
    # Divide the downstream bandwidth


    tc qdisc add dev eth1 root handle 20: cbq bandwidth 512Kbit avpkt 1000


    tc class add dev eth1 parent 20:0 classid 20:1 cbq bandwidth 512Kbit rate \
    512Kbit allot 1514 weight 51Kbit prio 8 maxburst 20 avpkt 1000


    tc class add dev eth1 parent 20:1 classid 20:100 cbq bandwidth 512Kbit rate \
    160Kbit allot 1514 weight 16Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded
      

    tc class add dev eth1 parent 20:1 classid 20:200 cbq bandwidth 512Kbit rate \
    80Kbit allot 1514 weight 8Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded


    tc qdisc add dev eth1 parent 20:100 sfq quantum 1514b perturb 15
    tc qdisc add dev eth1 parent 20:200 sfq quantum 1514b perturb 15


    tc filter add dev eth1 parent 20:0 protocol ip prio 100 u32 match ip src \
    10.0.0.203 flowid 20:200


    tc filter add dev eth1 parent 20:0 protocol ip prio 25 u32 match ip src \
    10.0.0.151 flowid 20:100
  • very useful will be trying this out come monday morning


    robin
  • Can you post a link to the Advanced Routing for 2.4?

    Thank You 

    Ryan Bloch
  • You can find the Linux Advanced Routing HOWTO at the Linux Documentation Project.

    The following link will take you directly to the chapterized HTML document, however there is plain text, PS, PDF etc available on that site.
     http://www.linuxdoc.org/HOWTO/Adv-Routing-HOWTO.html 

    Another note about the script that I pointed earlier, if you need to RESET the traffic control, you have two options, reboot the machine (We run Linux, not Windows - we shouldn't NEED to reboot for a config change)
    -OR- run a script to delete each of the items that my original script created - I haven't found a command to zero the settings out.  So I use the following script to delete the traffic control items:

    (I've simply reversed the order of the original script and replaced "add" with "del" - this works fine, however it's a hefty way to make changes. - I've been using the echos for brief runtime debug - nothing elaborate)

    Thanks
    Jake

    #### Remove the traffic control settings
    ###
    echo "#1 "
    tc filter del dev eth0 parent 10:0 protocol ip prio 25 u32 match ip dst \
    10.0.0.151 flowid 10:100

    echo "#2 "
    tc filter del dev eth0 parent 10:0 protocol ip prio 100 u32 match ip dst \
    10.0.1.3 flowid 10:200

    echo "#3 "
    tc qdisc del dev eth0 parent 10:100 sfq quantum 1514b perturb 15
    tc qdisc del dev eth0 parent 10:200 sfq quantum 1514b perturb 15


    echo "#4 "
    tc class del dev eth0 parent 10:1 classid 10:200 cbq bandwidth 512Kbit rate \
    80Kbit allot 1514 weight 8Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded

    echo "#5 "
    tc class del dev eth0 parent 10:1 classid 10:100 cbq bandwidth 512Kbit rate \
    160Kbit allot 1514 weight 16Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded

    echo "#6 "
    tc class del dev eth0 parent 10:0 classid 10:1 cbq bandwidth 512Kbit rate \
    512Kbit allot 1514 weight 51Kbit prio 8 maxburst 20 avpkt 1000

    echo "#7 "
    tc qdisc del dev eth0 root handle 10: cbq bandwidth 512Kbit avpkt 1000


    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

    echo "#1 "
    tc filter del dev eth1 parent 20:0 protocol ip prio 25 u32 match ip src \
    10.0.0.151 flowid 20:100


    echo "#2 "
    tc filter del dev eth1 parent 20:0 protocol ip prio 100 u32 match ip src \
    10.0.1.3 flowid 20:200

    echo "#3 "
    tc qdisc del dev eth1 parent 20:100 sfq quantum 1514b perturb 15
    tc qdisc del dev eth1 parent 20:200 sfq quantum 1514b perturb 15

    echo "#4 "
    tc class del dev eth1 parent 20:1 classid 20:200 cbq bandwidth 512Kbit rate \
    80Kbit allot 1514 weight 8Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded

    echo "#4 "
    tc class del dev eth1 parent 20:1 classid 20:200 cbq bandwidth 512Kbit rate \
    80Kbit allot 1514 weight 8Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded

    echo "#5 "
    tc class del dev eth1 parent 20:1 classid 20:100 cbq bandwidth 512Kbit rate \
    160Kbit allot 1514 weight 16Kbit prio 5 maxburst 20 avpkt 1000 \
    bounded

    echo "#6 "
    tc class del dev eth1 parent 20:0 classid 20:1 cbq bandwidth 512Kbit rate \
    512Kbit allot 1514 weight 51Kbit prio 8 maxburst 20 avpkt 1000

    echo "#7 "
    tc qdisc del dev eth1 root handle 20: cbq bandwidth 512Kbit avpkt 1000