user1263270
user1263270

Reputation: 61

Looking for traffic control function (i.e. QOS) library in Linux

I try to port some C++ code from Windows to Linux, but I can't find a similar API for traffic control functions in Linux.

I need these functions. Please help if you know where I can find such API?

Thank you for your time.

Upvotes: 0

Views: 3211

Answers (2)

deasoft.com
deasoft.com

Reputation: 21

As already stated you want to use the Linux traffic control command tc. I'd recommend HTB sceduling. You can enable it's kernel module with:

modprobe sch_htb

The basic commands for setting up tc are as follows:

tc qdisc add dev eth0 root handle 1:0 htb
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 100mbit
tc class add dev eth0 parent 1:1 classid 1:1000 htb rate 500Kbit ceil 1000Kbit
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 109.11.28.2 flowid 1:1000

These example commands setup traffic control on device eth0 for IP 109.11.28.2, in more detail they do the following

  1. setup the queueing discipline
  2. setup the parent class and its traffic rate limit
  3. setup a child class with traffic rate and traffic rate ceiling
  4. Add an IP filter to apply the child class limits to a specific IP only

You can setup as many child classes as you want, each could be used for a different IP on your network. For a more thorough and detailed step by step guide to setting up tc traffic control see here: http://hostrepo.com/article.php?id=194

Good Luck !

Upvotes: 2

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49008

You definitely want to start with the Linux advanced routing and traffic control howto. I'd recommend using the tc utility from iproute2 that the howto uses, but if you want a more direct API you can look at its source for an example.

Upvotes: 2

Related Questions