From 788f223dde0bd2237bd0ff84f3ec7022fb91043d Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Thu, 28 Sep 2017 09:21:05 +0200 Subject: [PATCH] fix queuingDelay computation --- src/mpLinkCharacteristics.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mpLinkCharacteristics.py b/src/mpLinkCharacteristics.py index 27fdee2..1554298 100644 --- a/src/mpLinkCharacteristics.py +++ b/src/mpLinkCharacteristics.py @@ -13,13 +13,23 @@ class MpLinkCharacteristics: bandwidthDelayProduct = (float(self.bandwidth) * 125000.0) * (rtt / 1000.0) return int(math.ceil(bandwidthDelayProduct * 1.0 / 1500.0)) + def extractQueuingDelay(queueSize, bandwidth, delay, mtu=1500): + rtt = 2 * float(delay) + bdp_queue_size = int(rtt * bandwidth * 1024 * 1024 / (mtu * 8 * 1000)) + if int(queueSize) <= bdp_queue_size: + return 0 + + queuingQueueSize = int(queueSize) - bdp_queue_size + queuingDelay = (queuingQueueSize * mtu * 8 * 1000) / (bandwidth * 1024 * 1024) + return int(queuingDelay) + def __init__(self, id, delay, queueSize, bandwidth, loss, back_up=False): self.id = id self.delay = delay self.queueSize = queueSize self.bandwidth = bandwidth self.loss = loss - self.queuingDelay = str(int(1000.0 * int(queueSize) / self.bandwidthDelayProductDividedByMTU())) + self.queuingDelay = str(extractQueuingDelay(queueSize, bandwidth, delay)) self.netemAt = [] self.back_up = back_up