Adding Netem Filter Rules
Posted
by
fontsix
on Server Fault
See other posts from Server Fault
or by fontsix
Published on 2012-10-04T15:34:58Z
Indexed on
2012/10/04
15:40 UTC
Read the original article
Hit count: 309
iam new in programming and using linux.
My Question is, is it possible to add Netem Filter Rules later ? I want to create an PHP-Interface for Netem and I don't know how much filters were required. This should be some kind of dynamically.
In Example : A user with a static IP starts an Netem Command (Latency) with PHP Interface
this means these five command werde executed by php
in the first step
$classid = 11; $handle = 10;
"sudo tc qdisc add dev eth0 handle 1: root htb";
"sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 100Mbps";
"sudo tc class add dev eth0 parent 1:1 classid 1:$classid htb rate 100Mbps";
"sudo tc qdisc add dev eth0 parent 1:$classid handle $handle: netem delay 100ms";
"sudo tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 match ip dst $dest flowid 1:$classid";
Now, if there would be a second user who wants to use Netem independent of the first user, i only want to execute the last 3 commands, like
"sudo tc class add dev eth0 parent 1:1 classid 1:$classid htb rate 100Mbps";
"sudo tc qdisc add dev eth0 parent 1:$classid handle $handle: netem delay 100ms";
"sudo tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 match ip dst $dest flowid 1:$classid";
There is an Algorithmus for increasing variables $classid and $handle. This should work.
Now my Question: Is it possible only to add these 3 commands to add a new class with new qdisc and a new filter rule ? Or how can i realize it ?
The Apache Error_log tells me "sh: line 1: flowid: command not found" but i can't find any mistake.
I hope you could help
Best regards fontsix
© Server Fault or respective owner