aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rumba/elements/topology.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/rumba/elements/topology.py b/rumba/elements/topology.py
index f717a5a..87aeb4c 100644
--- a/rumba/elements/topology.py
+++ b/rumba/elements/topology.py
@@ -485,24 +485,31 @@ class LinkQuality(object):
def rate(self):
return self._rate
- def build_command(self, ipcp):
- cmd = []
+ def build_commands(self, ipcp):
+ netem_cmd = []
+ cmds = []
+ qref = "root"
if ipcp in LinkQuality._active:
- cmd.append("tc qdisc change dev %s root netem" % ipcp.ifname)
- else:
- cmd.append("tc qdisc add dev %s root netem" % ipcp.ifname)
-
- if self.delay:
- cmd.append(self.delay.build_command())
-
- if self.loss:
- cmd.append(self.loss.build_command())
+ cmds.append("tc qdisc del dev %s root" % ipcp.ifname)
if self.rate:
- cmd.append("rate %imbit" % self.rate)
-
- return " ".join(cmd)
+ cmds.append("tc qdisc add dev %s root handle 1: htb default 1" \
+ % ipcp.ifname)
+ cmds.append("tc class add dev %s parent 1: classid 1:1 htb rate %imbit" \
+ % (ipcp.ifname, self.rate))
+ qref = "parent 1:1"
+
+ if self.delay or self.loss:
+ netem_cmd.append("tc qdisc add dev %s %s netem" \
+ % (ipcp.ifname, qref))
+ if self.delay:
+ netem_cmd.append(self.delay.build_command())
+ if self.loss:
+ netem_cmd.append(self.loss.build_command())
+ cmds.append(" ".join(netem_cmd))
+
+ return cmds
def apply(self, shim):
if not (self.delay or self.loss or self.rate):
@@ -514,8 +521,8 @@ class LinkQuality(object):
"the interface name is None")
continue
- ipcp.node.execute_command(self.build_command(ipcp),
- as_root=True)
+ ipcp.node.execute_commands(self.build_commands(ipcp),
+ as_root=True)
LinkQuality._active.add(ipcp)
def deactivate(self, shim):
@@ -527,8 +534,8 @@ class LinkQuality(object):
"the interface name is None")
continue
- ipcp.node.execute_command("tc qdisc del dev %s root "
- "netem" % ipcp.ifname, as_root=True)
+ ipcp.node.execute_command("tc qdisc del dev %s root"
+ % ipcp.ifname, as_root=True)
LinkQuality._active.remove(ipcp)