ensure bandwidth is a float

This commit is contained in:
Quentin De Coninck 2017-09-28 09:47:05 +02:00 committed by None
parent 7df509dd0d
commit a3e434207f

View File

@ -15,12 +15,12 @@ class MpLinkCharacteristics:
def extractQueuingDelay(queueSize, bandwidth, delay, mtu=1500): def extractQueuingDelay(queueSize, bandwidth, delay, mtu=1500):
rtt = 2 * float(delay) rtt = 2 * float(delay)
bdp_queue_size = int(rtt * bandwidth * 1024 * 1024 / (mtu * 8 * 1000)) bdp_queue_size = int(rtt * float(bandwidth) * 1024 * 1024 / (mtu * 8 * 1000))
if int(queueSize) <= bdp_queue_size: if int(queueSize) <= bdp_queue_size:
return 0 return 0
queuingQueueSize = int(queueSize) - bdp_queue_size queuingQueueSize = int(queueSize) - bdp_queue_size
queuingDelay = (queuingQueueSize * mtu * 8 * 1000) / (bandwidth * 1024 * 1024) queuingDelay = (queuingQueueSize * mtu * 8 * 1000) / (float(bandwidth) * 1024 * 1024)
return int(queuingDelay) return int(queuingDelay)
def __init__(self, id, delay, queueSize, bandwidth, loss, back_up=False): def __init__(self, id, delay, queueSize, bandwidth, loss, back_up=False):