Find the answer to your Linux question:
Results 1 to 3 of 3
I've been trying to create a simple htb qdisc on my computer for learning purposes, but it does not seem to be working as I want it to. Ive made ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    59

    Simple shaper on single pc


    I've been trying to create a simple htb qdisc on my computer for learning purposes, but it does not seem to be working as I want it to. Ive made this script that creates a simple qdisc scheme and assigns filters to it:

    tc qdisc add dev $ETH root handle 1:0 htb default 1
    tc class add dev $ETH parent 1:0 classid 1:1 htb rate 20kbps ceil 0kbps
    tc class add dev $ETH parent 1:0 classid 1:2 htb rate 30kbps ceil 100kbps
    tc class add dev $ETH parent 1:0 classid 1:3 htb rate 10kbps ceil 100kbps
    tc class add dev $ETH parent 1:0 classid 1:4 htb rate 60kbps ceil 100kbps

    tc filter add dev $ETH parent 1:0 prio 1 u32 match ip src $IP match ip dport 80 0xffff flowid 1:2
    tc filter add dev $ETH parent 1:0 prio 1 u32 match ip src $IP match ip dport 443 0xffff flowid 1:3
    tc filter add dev $ETH parent 1:0 prio 1 u32 match ip src $IP match ip dport 21 0xffff flowid 1:4
    I want it to simply shape packets on my single machine so that when I go to view web pages it will limit the download rate, same thing for p21 ftp and 443 https. I just want to try out how it works and use these trial to get a hang of it, but I noticed so far that its not limiting port 80 at all. Anyone can help me with this?

  2. #2
    Just Joined!
    Join Date
    Oct 2010
    Location
    Reston, VA
    Posts
    26
    You are limiting your outbound traffic only. You can only shape what you transmit, you can't control how many packets you get.

    If you want to limit downloads you need to create a choke point.

    Basically do the same thing on both interfaces. Here is how it will flow for downloads:

    internet -> Linux router -> PC

    Traffic comes in too fast but leaves the router at a set speed. Traffic is now backed up at the router. As you receive the packets your PC will send ACKs back to the server enabling it to send more packets.

    For TCP the server will only send a few packets then wait for the ACK. Your choke point slows this whole process down creating space between the server's trasmits. You have now limited TCP download speed.

    This is much less (if at all) effective with UDP. UDP doesn't have a built in ACK. The server will send packets as fast as it can. If you don't get them fast enough they just que up on the router.

    Many UDP applications have their own built in speed control so it is worth a try to shape them also.

    This is complicated but very fun stuff.

    -Gooney0

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    59
    Thanks for the reply gooney0, I had a hunch I could only shape outbound traffic but I wasn't sure why. So if I have two interfaces and I shape outbound traffic on both interfaces, I can limit both the upload and download rate between those two. Thanks!

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •