aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrinity-1686a <trinity@deuxfleurs.fr>2022-08-31 21:29:18 +0200
committertrinity-1686a <trinity@deuxfleurs.fr>2022-08-31 21:29:18 +0200
commit30643ca50d4646a790080ee12fa3fbe874bfcf73 (patch)
tree980186cb7b0a281cce6f1e092a7a359d56b41f99
parent5a8be6fc734429bf80f0566fd070396be39aa008 (diff)
downloadmknet-30643ca50d4646a790080ee12fa3fbe874bfcf73.tar.gz
mknet-30643ca50d4646a790080ee12fa3fbe874bfcf73.zip
add support for limiting queue len
-rwxr-xr-xmknet8
-rw-r--r--net.py2
2 files changed, 7 insertions, 3 deletions
diff --git a/mknet b/mknet
index 9081aeb..34608a3 100755
--- a/mknet
+++ b/mknet
@@ -87,19 +87,21 @@ class Bandwidth:
class LinkInfo:
- def __init__(self, bandwidth, latency, jitter = None, offset = None, **kwargs):
+ def __init__(self, bandwidth, latency, jitter = None, offset = None, limit = None, **kwargs):
self.bandwidth = Bandwidth(bandwidth)
self.latency = Latency(latency, offset)
self.jitter = Latency(jitter or 0)
+ self.limit = limit
def __eq__(self, o):
return (isinstance(o, LinkInfo) and
o.bandwidth == self.bandwidth and
o.latency == self.latency and
- o.jitter == self.jitter)
+ o.jitter == self.jitter and
+ o.limit == self.limit)
def __str__(self):
- return f'LinkInfo{{bw: {self.bandwidth}, latency: {self.latency}, jitter: {self.jitter}}}'
+ return f'LinkInfo{{bw: {self.bandwidth}, latency: {self.latency}, jitter: {self.jitter}, limit: {self.limit}}}'
class Server:
def __init__(self, name, link):
diff --git a/net.py b/net.py
index 8d0a248..8e8725b 100644
--- a/net.py
+++ b/net.py
@@ -66,4 +66,6 @@ def tc(namespace, name, link, invert=False):
options += ["rate", str(link.bandwidth.down)]
else:
options += ["rate", str(link.bandwidth.up)]
+ if link.limit:
+ options += ["limit", str(link.limit)]
run_netns("exec", namespace, "tc", "qdisc", "add", "dev", name, "root", "netem", *options)