From 3a654e0a6791a35a4ffe1c8b7652e1374b3ba1c1 Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Thu, 28 Nov 2019 18:50:28 +0100 Subject: [PATCH] FINALLY WORKING WITH POLICING --- src/mpLinkCharacteristics.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mpLinkCharacteristics.py b/src/mpLinkCharacteristics.py index 642bed7..cbb7fe5 100644 --- a/src/mpLinkCharacteristics.py +++ b/src/mpLinkCharacteristics.py @@ -55,7 +55,8 @@ class MpLinkCharacteristics: cmd = "" for n in self.netemAt: cmd = cmd + "sleep {}".format(n.delta) - cmd = cmd + " && tc qdisc add dev {} root handle 5:0 tbf rate {}mbit burst 15000 limit {} &&".format(ifname, self.bandwidth, int(self.bufferSize())) + cmd = cmd + " && tc qdisc del dev {} root ".format(ifname) + cmd = cmd + " ; tc qdisc add dev {} root handle 5:0 tbf rate {}mbit burst 15000 limit {} &&".format(ifname, self.bandwidth, int(self.bufferSize())) cmd = cmd + " true &" return cmd @@ -65,7 +66,7 @@ class MpLinkCharacteristics: for n in self.netemAt: cmd = cmd + "sleep " + str(n.delta) cmd = cmd + " && tc qdisc del dev " + ifname + " root " - cmd = cmd + " && tc qdisc add dev {} root handle 10: netem {} delay {}ms limit {} &&".format(ifname, n.cmd, self.delay, int(2 * self.bufferSize() // 1500)) + cmd = cmd + " ; tc qdisc add dev {} root handle 10: netem {} delay {}ms limit 50000 &&".format(ifname, n.cmd, self.delay) cmd = cmd + " true &" return cmd @@ -76,7 +77,7 @@ class MpLinkCharacteristics: cmd = cmd + "sleep {}".format(n.delta) cmd = cmd + " && tc qdisc del dev {} ingress".format(ifname) cmd = cmd + " ; tc qdisc add dev {} handle ffff: ingress".format(ifname) - cmd = cmd + " && tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, int(self.bufferSize() * 8)) + cmd = cmd + " && tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, int(self.bufferSize() * 1.2)) cmd = cmd + " true &" return cmd