cgroups和tc / netem:不确定如何让它们一起工作

时间:2014-05-19 07:44:21

标签: linux trafficshaping cgroups

我在问cgroupstc时遇到问题。

我试图为特定进程添加延迟。以下代码无效。但我不知道什么是错的(甚至是对的)。

# Set up net_cls to make 
modprobe cls_cgroup
mount -t cgroup -o net_cls none /sys/fs/cgroup/net_cls

# Create a new CGroup called 'high-latency'
mkdir /sys/fs/cgroup/high-latency
# All packets originating from this CG have their packers
# marked as class 1:11 / 0x1_0011
echo 0x100011 > /sys/fs/cgroup/high-latency/net_cls.classid

# Delete old rules, just in case
tc qdisc del dev eth0 root

# New root
tc qdisc add dev eth0 handle 1: root htb
# Class for filtered packets 1:11 == 0x10011
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 100Mbps
# Apply delay to class 1:11
tc qdisc add dev eth0 parent 1:11 handle 10: netem delay 1000ms

# Don't understand this line at all! Why does tc need to know
# about 'cgroup', when net_cls is already putting them in class 1:11
tc filter add dev eth0 parent 1:11 protocol ip prio 10 handle 1: cgroup

# Add my process to the cgroup
echo 1234 > /sys/fs/cgroup/high-latency/tasks

另一个有趣的事情是,在运行此之后,cat /sys/fs/cgroup/high-latency/tasks 打印一大堆进程(全部?),包括pid 1。

知道我做错了什么,更重要的是 - 在尝试使用tc和cgroup时我可以使用哪些调试工具?

1 个答案:

答案 0 :(得分:0)

无法一起工作。 您可以按export class AppComponent implements ngAfterViewInit{ //some app logic here ngAfterViewInit(){ document.querySelector('button').onclick = function(){ swal("Here's a message!"); }; } } 对数据包进行分类,然后需要通过@Component({ selector: 'my-app', template: ` <form> <button type="button" (click)="popAlert();" class="ticket_button">Book</button> </form> ` }) 将流量重定向到netem interace。