#StackBounty: #port #tc #filter Using tc to delay packets to several ports

Bounty: 50

After reading several pages like this this and without having a really deep knowledge about the kernel Linux, I am able to filter up to 3 ports using just the three first leaves of the tree.

tc qdisc del dev enp0s3 root //clear any previous configuration
tc qdisc add dev enp0s3 root handle 1: prio //start new queue disc but no classes yet

tc filter add dev enp0s3 parent 1: protocol ip prio 1 u32 match ip dport 6332 0xffff flowid 1:1
tc filter add dev enp0s3 parent 1: protocol ip prio 1 u32 match ip dport 6333 0xffff flowid 1:2
tc filter add dev enp0s3 parent 1: protocol ip prio 1 u32 match ip dport 6334 0xffff flowid 1:3

tc qdisc add dev enp0s3 parent 1:1 handle 30: netem delay 146ms 
tc qdisc add dev enp0s3 parent 1:2 handle 20: netem delay 275ms 
tc qdisc add dev enp0s3 parent 1:3 handle 10: netem delay 258ms 

My problem is that I would like to have more port filters in order to simulate a big scenario with up to 16 possible ports destination. If I try to add a new filter using 10:1 what I get is that the delay is not correct because it starts adding two or more rules and I reach to have more than 1 second delay which is what I don’t want to have.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.