From e2701685b73bcda54d4ae52785c56b0396d9ea3c Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Sun, 8 May 2016 19:08:59 +0200 Subject: [PATCH] mpLinkCharacteristics: use class, not qdisc for htb --- src/mpLinkCharacteristics.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mpLinkCharacteristics.py b/src/mpLinkCharacteristics.py index ba2c025..f3a9d2e 100644 --- a/src/mpLinkCharacteristics.py +++ b/src/mpLinkCharacteristics.py @@ -4,6 +4,7 @@ class MpLinkCharacteristics: tcNetemParent = "5:1" + tcHtbClassid = "10" tcNetemHandle = "10:" def __init__(self, id, delay, queueSize, bandwidth, loss, back_up=False): @@ -32,12 +33,17 @@ class MpLinkCharacteristics: cmd = "" for n in self.netemAt: cmd = cmd + "sleep " + str(n.delta) - cmd = cmd + " && " - cmd = cmd + " tc qdisc change dev " + ifname + " " - cmd = cmd + " parent " + MpLinkCharacteristics.tcNetemParent - cmd = cmd + " handle " + MpLinkCharacteristics.tcNetemHandle + cmd = cmd + " && (( tc qdisc del dev " + ifname + " root " + cmd = cmd + " && tc class add dev " + ifname + " " + cmd = cmd + " parent root " + cmd = cmd + " classid " + MpLinkCharacteristics.tcHtbClassid cmd = cmd + " htb rate " + self.bandwidth + "mbit" - cmd = cmd + " burst " + str(int(self.queueSize) * 1500) + " && " + cmd = cmd + " burst " + str(int(self.queueSize) * 1500) + ") || " + cmd = cmd + " tc class change dev " + ifname + " " + cmd = cmd + " parent " + MpLinkCharacteristics.tcNetemParent + cmd = cmd + " classid " + MpLinkCharacteristics.tcHtbClassid + cmd = cmd + " htb rate " + self.bandwidth + "mbit" + cmd = cmd + " burst " + str(int(self.queueSize) * 1500) + ") && " cmd = cmd + " tc qdisc add dev " + ifname + " " cmd = cmd + " parent " + MpLinkCharacteristics.tcNetemHandle cmd = cmd + " netem " + n.cmd + " delay " + self.delay + "ms && "