-1

We are doing QoS (traffic control) for our server application. This server provides file download service for users and we want to give different users different priority and bandwith. Suppose the Linux server gives our applicaton a bandwith of 1M, then we will give the user who has highest priority the most bandwith.

I am going to use the Token and Token Bucket concepts to achieve this, but I don't know how to use Timer and Measurement skills to control the rate of generating Tokens, so I decide to learn from existing sw source code. Can anyone recommend some traffic control software/tools?

[update]
I want to know how to use timers to generate tokens by rate (because the tokens are generated at some rate, so we can consider the thread who gets the tokens will send the data to network interface at the same rate with that tokens being generated).

Steve Peng
  • 509
  • 1
  • 8
  • 18

2 Answers2

3

Typically the application doesn't control the bandwidth allocated to specific sockets, nor does it know how much the kernel is sending its traffic versus that of other applications.

The utility tc (part of iproute2), combined with iptables setting marks on packets and connections, can be used to implement an arbitrarily complex hierarchical token bucket system (with its htb qdisc), and you should consider looking into this.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
2

MasterShapper could be what you are looking for. One can read

It (MasterShapper) targets to let users learn and use the traffic shaping mechanism. This should be possible for everyone who has no deeper knowledge of Linux and the difficult syntax of the tc commands from the iproute2 package.

and is OpenSource, so you can as you said

learn from existing sw source code

  • 1
    @slm Thanks. Is now right? –  Jul 07 '13 at 02:41
  • is it written by PHP? Am I wrong? I can't find any source code written in Java, c or C++ from this [repository](http://git.netshadow.at/gitweb/?p=MasterShaper.git;a=summary) – Steve Peng Jul 07 '13 at 05:47
  • 1
    Is written in PHP, [here](http://git.netshadow.at/gitweb/?p=MasterShaper.git;a=blob;f=htdocs/class/rules/interface.php;h=aea0f00dea9a53f39a78641dd9bd2080fce44317;hb=05bd27e7705868270550f5722fba4bf8e1a08e20) you can see code that build the `tc` commands. –  Jul 07 '13 at 05:54
  • sorry, I know nothing about PHP, does it contain any code telling how to use timers to generate tokens by rate (coz the tokens are generated at some rate, then we can consider thread who gets the tokens will send the data to network interface at the same rate with that tokens being generated). – Steve Peng Jul 07 '13 at 06:17
  • 1
    So **learn from existing sw source code** is not what you want, even you found a software in a language that you know, reading source code will be too difficult to learn about `tc`. I recommend you read related doc, [this one](http://lartc.org/lartc.html#LARTC.QDISC) could be a good start and then code whatever app you want. –  Jul 07 '13 at 14:52
  • In the end, I think, that software is merely a frontend to `tc`. – Falcon Momot Jul 07 '13 at 16:38
  • @FalconMomot Exactly! MasterShapper just make `tc` calls. One could control flow bandwidth/priority with **tc** after knowing flow coordinates (IP1:PORT1;IP2:PORT2) –  Jul 08 '13 at 03:20