mpParamTopo/mpLinkCharacteristics: added loss parameter in link configuration, but keep compatibility if not specified
This commit is contained in:
parent
165a46a3c4
commit
7e9f2c643d
@ -6,11 +6,12 @@ class MpLinkCharacteristics:
|
||||
tcNetemParent = "5:1"
|
||||
tcNetemHandle = "10:"
|
||||
|
||||
def __init__(self, id, delay, queueSize, bandwidth, back_up=False):
|
||||
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.netemAt = []
|
||||
self.back_up = back_up
|
||||
|
||||
@ -43,6 +44,7 @@ class MpLinkCharacteristics:
|
||||
d = {}
|
||||
d['bw'] = float(self.bandwidth)
|
||||
d['delay'] = self.delay + "ms"
|
||||
d['loss'] = float(self.loss)
|
||||
d['max_queue_size'] = int(self.queueSize)
|
||||
return d
|
||||
|
||||
@ -51,8 +53,8 @@ class MpLinkCharacteristics:
|
||||
s = s + "\tDelay : " + str(self.delay) + "\n"
|
||||
s = s + "\tQueue Size : " + str(self.queueSize) + "\n"
|
||||
s = s + "\tBandwidth : " + str(self.bandwidth) + "\n"
|
||||
s = s + "\tLoss : " + str(self.loss) + "\n"
|
||||
s = s + "\tBack up : " + str(self.back_up) + "\n"
|
||||
for l in self.netemAt:
|
||||
s = s + "\t" + l.__str__() + "\n"
|
||||
return s
|
||||
|
||||
|
@ -51,11 +51,19 @@ class MpParamTopo(MpParam):
|
||||
if k.startswith("path"):
|
||||
tab = self.paramDic[k].split(",")
|
||||
bup = False
|
||||
loss = "0.0"
|
||||
if len(tab) == 5:
|
||||
loss = tab[3]
|
||||
bup = tab[4] == 'True'
|
||||
if len(tab) == 4:
|
||||
bup = tab[3] == 'True'
|
||||
if len(tab) == 3 or len(tab) == 4:
|
||||
try:
|
||||
loss = float(tab[3])
|
||||
loss = tab[3]
|
||||
except ValueError:
|
||||
bup = tab[3] == 'True'
|
||||
if len(tab) == 3 or len(tab) == 4 or len(tab) == 5:
|
||||
path = MpLinkCharacteristics(i,tab[0],
|
||||
tab[1], tab[2], bup)
|
||||
tab[1], tab[2], loss, bup)
|
||||
self.linkCharacteristics.append(path)
|
||||
i = i + 1
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user