still some file restructuration

This commit is contained in:
Quentin De Coninck 2020-06-24 11:26:56 +02:00
parent d37f6d6405
commit dffae6d281
31 changed files with 158 additions and 168 deletions

View File

@ -1,7 +1,118 @@
from .parameter import Parameter from .parameter import Parameter
from mpLinkCharacteristics import MpLinkCharacteristics import math
from mpNetemAt import MpNetemAt
class NetemAt(object):
def __init__(self, at, cmd):
self.at = at
self.cmd = cmd
self.delta = 0
def __str__(self):
return "Netem... at " + str(self.at) + "(" + str(self.delta) + \
") will be " + self.cmd
class LinkCharacteristics(object):
tcNetemParent = "1:1"
tcHtbClassid = "10"
tcNetemHandle = "1:10"
def bandwidthDelayProductDividedByMTU(self):
rtt = 2 * float(self.delay)
""" Since bandwidth is in Mbps and rtt in ms """
bandwidthDelayProduct = (float(self.bandwidth) * 125000.0) * (rtt / 1000.0)
return int(math.ceil(bandwidthDelayProduct * 1.0 / 1500.0))
def bufferSize(self):
return (1500.0 * self.bandwidthDelayProductDividedByMTU()) + (float(self.bandwidth) * 1000.0 * float(self.queuingDelay) / 8)
def extractQueuingDelay(self, queueSize, bandwidth, delay, mtu=1500):
# rtt = 2 * float(delay)
# bdp_queue_size = int((float(rtt) * float(bandwidth) * 1024 * 1024) / (int(mtu) * 8 * 1000))
# if int(queueSize) <= bdp_queue_size:
# Returning 0 seems to bypass everything, then only limited by CPU.
# This is not what we want...
# return 1
# queuingQueueSize = int(queueSize) - bdp_queue_size
queuingDelay = (int(queueSize) * int(mtu) * 8.0 * 1000.0) / (float(bandwidth) * 1024 * 1024)
return max(int(queuingDelay), 1)
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(self.extractQueuingDelay(queueSize, bandwidth, delay))
self.netemAt = []
self.back_up = back_up
def addNetemAt(self, n):
if len(self.netemAt) == 0:
n.delta = n.at
self.netemAt.append(n)
else:
if n.at > self.netemAt[-1].at:
n.delta = n.at - self.netemAt[-1].at
self.netemAt.append(n)
else:
print("Do not take into account " + n.__str__() + \
"because ooo !")
pass
def buildBwCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc del dev {} root ".format(ifname)
cmd = cmd + " ; tc qdisc add dev {} root handle 5:0 tbf rate {}mbit burst 15000 limit {} &&".format(ifname, self.bandwidth, int(self.bufferSize()))
cmd = cmd + " true &"
return cmd
def buildNetemCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep " + str(n.delta)
cmd = cmd + " && tc qdisc del dev " + ifname + " root "
cmd = cmd + " ; tc qdisc add dev {} root handle 10: netem {} delay {}ms limit 50000 &&".format(ifname, n.cmd, self.delay)
cmd = cmd + " true &"
return cmd
def buildPolicingCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc del dev {} ingress".format(ifname)
cmd = cmd + " ; tc qdisc add dev {} handle ffff: ingress".format(ifname)
cmd = cmd + " && tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, int(self.bufferSize() * 1.2))
cmd = cmd + " true &"
return cmd
def asDict(self):
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
def __str__(self):
s = "Link id : " + str(self.id) + "\n"
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
class TopoParameter(Parameter): class TopoParameter(Parameter):
LSUBNET = "leftSubnet" LSUBNET = "leftSubnet"
@ -37,7 +148,7 @@ class TopoParameter(Parameter):
for n in nlist: for n in nlist:
tab = n.split(",") tab = n.split(",")
if len(tab)==2: if len(tab)==2:
o = MpNetemAt(float(tab[0]), tab[1]) o = NetemAt(float(tab[0]), tab[1])
if id < len(self.linkCharacteristics): if id < len(self.linkCharacteristics):
self.linkCharacteristics[id].addNetemAt(o) self.linkCharacteristics[id].addNetemAt(o)
else: else:
@ -63,7 +174,7 @@ class TopoParameter(Parameter):
except ValueError: except ValueError:
bup = tab[3] == 'True' bup = tab[3] == 'True'
if len(tab) == 3 or len(tab) == 4 or len(tab) == 5: if len(tab) == 3 or len(tab) == 4 or len(tab) == 5:
path = MpLinkCharacteristics(i,tab[0], path = LinkCharacteristics(i,tab[0],
tab[1], tab[2], loss, bup) tab[1], tab[2], loss, bup)
self.linkCharacteristics.append(path) self.linkCharacteristics.append(path)
i = i + 1 i = i + 1

View File

@ -5,7 +5,7 @@ from mininet.node import OVSBridge
from mininet.cli import CLI from mininet.cli import CLI
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
class MpMininetBuilder(Topo): class MininetBuilder(Topo):
def __init__(self): def __init__(self):
Topo.__init__( self ) Topo.__init__( self )
self.net = None self.net = None

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceAb(Experience): class ExperienceAb(Experience):
@ -51,7 +50,7 @@ class ExperienceAb(Experience):
def getAbServerCmd(self): def getAbServerCmd(self):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/http.py &>" + ExperienceAb.SERVER_LOG + "&" "/utils/http.py &>" + ExperienceAb.SERVER_LOG + "&"
print(s) print(s)
return s return s

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceDITG(Experience): class ExperienceDITG(Experience):

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceEpload(Experience): class ExperienceEpload(Experience):

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceHTTP(Experience): class ExperienceHTTP(Experience):

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceHTTPS(Experience): class ExperienceHTTPS(Experience):
@ -49,7 +48,7 @@ class ExperienceHTTPS(Experience):
def getHTTPSServerCmd(self): def getHTTPSServerCmd(self):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/https.py &>" + ExperienceHTTPS.SERVER_LOG + "&" "/utils/https.py &>" + ExperienceHTTPS.SERVER_LOG + "&"
print(s) print(s)
return s return s

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceIperf(Experience): class ExperienceIperf(Experience):

View File

@ -46,13 +46,13 @@ class ExperienceMsg(Experience):
def getMsgServerCmd(self): def getMsgServerCmd(self):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/msg_server.py --sleep " + self.server_sleep + " --bytes " + self.bytes + " &>" + ExperienceMsg.SERVER_LOG + "&" "/utils/msg_server.py --sleep " + self.server_sleep + " --bytes " + self.bytes + " &>" + ExperienceMsg.SERVER_LOG + "&"
print(s) print(s)
return s return s
def getMsgClientCmd(self): def getMsgClientCmd(self):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \ "/utils/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \
" --bytes " + self.bytes + " >" + ExperienceMsg.CLIENT_LOG + " 2>" + ExperienceMsg.CLIENT_ERR " --bytes " + self.bytes + " >" + ExperienceMsg.CLIENT_LOG + " 2>" + ExperienceMsg.CLIENT_ERR
print(s) print(s)
return s return s

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
""" """
Should be the mother of ExperienceNCPV, shame on me, should rewrite Should be the mother of ExperienceNCPV, shame on me, should rewrite

View File

@ -1,5 +1,16 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
class MpPvAt(object):
def __init__(self, at, cmd):
self.at = at
self.cmd = cmd
self.delta = 0
def __str__(self):
return "Pv... at " + str(self.at) + "(" + str(self.delta) + \
") will be " + self.cmd
class ExperienceNCPV(Experience): class ExperienceNCPV(Experience):
""" """

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceNetperf(Experience): class ExperienceNetperf(Experience):

View File

@ -70,7 +70,7 @@ class ExperienceQUIC(Experience):
def getCongServerCmd(self, congID): def getCongServerCmd(self, congID):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
"/https.py &> https_server" + str(congID) + ".log &" "/utils/https.py &> https_server" + str(congID) + ".log &"
print(s) print(s)
return s return s

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceSendFile(Experience): class ExperienceSendFile(Experience):

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceSiri(Experience): class ExperienceSiri(Experience):
@ -54,12 +53,12 @@ class ExperienceSiri(Experience):
def getSiriServerCmd(self): def getSiriServerCmd(self):
s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \
"/siri_server.py &>" + ExperienceSiri.SERVER_LOG + "&" "/utils/siri_server.py &>" + ExperienceSiri.SERVER_LOG + "&"
print(s) print(s)
return s return s
def getSiriClientCmd(self): def getSiriClientCmd(self):
s = ExperienceSiri.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/siriClient.jar " + \ s = ExperienceSiri.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \
self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \ self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \
" " + self.delay_query_response + " " + self.min_payload_size + " " + \ " " + self.delay_query_response + " " + self.min_payload_size + " " + \
self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \ self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceSiriHTTP(Experience): class ExperienceSiriHTTP(Experience):
@ -68,12 +67,12 @@ class ExperienceSiriHTTP(Experience):
def getSiriServerCmd(self): def getSiriServerCmd(self):
s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \
"/siri_server.py &>" + ExperienceSiriHTTP.SERVER_LOG + "&" "/utils/siri_server.py &>" + ExperienceSiriHTTP.SERVER_LOG + "&"
print(s) print(s)
return s return s
def getSiriClientCmd(self): def getSiriClientCmd(self):
s = ExperienceSiriHTTP.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/siriClient.jar " + \ s = ExperienceSiriHTTP.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \
self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \ self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \
" " + self.delay_query_response + " " + self.min_payload_size + " " + \ " " + self.delay_query_response + " " + self.min_payload_size + " " + \
self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \ self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceSiriMsg(Experience): class ExperienceSiriMsg(Experience):
@ -21,7 +20,7 @@ class ExperienceSiriMsg(Experience):
def ping(self): def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
ExperienceSiriMsg.PING_OUTPUT ) ExperienceSiriMsg.PING_OUTPUT )
count = self.xpParam.getParam(MpParamXp.PINGCOUNT) count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()): for i in range(0, self.mpConfig.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i), cmd = self.pingCommand(self.mpConfig.getClientIP(i),
self.mpConfig.getServerIP(), n = count) self.mpConfig.getServerIP(), n = count)
@ -37,19 +36,19 @@ class ExperienceSiriMsg(Experience):
""" """
todo : param LD_PRELOAD ?? todo : param LD_PRELOAD ??
""" """
self.run_time = self.xpParam.getParam(MpParamXp.SIRIRUNTIME) self.run_time = self.xpParam.getParam(ExperienceParameter.SIRIRUNTIME)
self.query_size = self.xpParam.getParam(MpParamXp.SIRIQUERYSIZE) self.query_size = self.xpParam.getParam(ExperienceParameter.SIRIQUERYSIZE)
self.response_size = self.xpParam.getParam(MpParamXp.SIRIRESPONSESIZE) self.response_size = self.xpParam.getParam(ExperienceParameter.SIRIRESPONSESIZE)
self.delay_query_response = self.xpParam.getParam(MpParamXp.SIRIDELAYQUERYRESPONSE) self.delay_query_response = self.xpParam.getParam(ExperienceParameter.SIRIDELAYQUERYRESPONSE)
self.min_payload_size = self.xpParam.getParam(MpParamXp.SIRIMINPAYLOADSIZE) self.min_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMINPAYLOADSIZE)
self.max_payload_size = self.xpParam.getParam(MpParamXp.SIRIMAXPAYLOADSIZE) self.max_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMAXPAYLOADSIZE)
self.interval_time_ms = self.xpParam.getParam(MpParamXp.SIRIINTERVALTIMEMS) self.interval_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALTIMEMS)
self.buffer_size = self.xpParam.getParam(MpParamXp.SIRIBUFFERSIZE) self.buffer_size = self.xpParam.getParam(ExperienceParameter.SIRIBUFFERSIZE)
self.burst_size = self.xpParam.getParam(MpParamXp.SIRIBURSTSIZE) self.burst_size = self.xpParam.getParam(ExperienceParameter.SIRIBURSTSIZE)
self.interval_burst_time_ms = self.xpParam.getParam(MpParamXp.SIRIINTERVALBURSTTIMEMS) self.interval_burst_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALBURSTTIMEMS)
self.client_sleep = self.xpParam.getParam(MpParamXp.MSGCLIENTSLEEP) self.client_sleep = self.xpParam.getParam(ExperienceParameter.MSGCLIENTSLEEP)
self.server_sleep = self.xpParam.getParam(MpParamXp.MSGSERVERSLEEP) self.server_sleep = self.xpParam.getParam(ExperienceParameter.MSGSERVERSLEEP)
self.nb_requests = self.xpParam.getParam(MpParamXp.MSGNBREQUESTS) self.nb_requests = self.xpParam.getParam(ExperienceParameter.MSGNBREQUESTS)
def prepare(self): def prepare(self):
Experience.prepare(self) Experience.prepare(self)
@ -68,12 +67,12 @@ class ExperienceSiriMsg(Experience):
def getSiriServerCmd(self): def getSiriServerCmd(self):
s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \
"/siri_server.py &>" + ExperienceSiriMsg.SERVER_LOG + "&" "/utils/siri_server.py &>" + ExperienceSiriMsg.SERVER_LOG + "&"
print(s) print(s)
return s return s
def getSiriClientCmd(self): def getSiriClientCmd(self):
s = ExperienceSiriMsg.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/siriClient.jar " + \ s = ExperienceSiriMsg.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \
self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \ self.mpConfig.getServerIP() + " 8080 " + self.run_time + " " + self.query_size + " " + self.response_size + \
" " + self.delay_query_response + " " + self.min_payload_size + " " + \ " " + self.delay_query_response + " " + self.min_payload_size + " " + \
self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \ self.max_payload_size + " " + self.interval_time_ms + " " + self.buffer_size + " " + self.burst_size + " " + self.interval_burst_time_ms + \
@ -83,13 +82,13 @@ class ExperienceSiriMsg(Experience):
def getMsgServerCmd(self): def getMsgServerCmd(self):
s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \
"/msg_server.py --sleep " + self.server_sleep + " &>" + ExperienceSiriMsg.MSG_SERVER_LOG + "&" "/utils/msg_server.py --sleep " + self.server_sleep + " &>" + ExperienceSiriMsg.MSG_SERVER_LOG + "&"
print(s) print(s)
return s return s
def getMsgClientCmd(self): def getMsgClientCmd(self):
s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \
"/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \ "/utils/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \
" --bulk >" + ExperienceSiriMsg.MSG_CLIENT_LOG + " 2>" + ExperienceSiriMsg.MSG_CLIENT_ERR + "&" " --bulk >" + ExperienceSiriMsg.MSG_CLIENT_LOG + " 2>" + ExperienceSiriMsg.MSG_CLIENT_ERR + "&"
print(s) print(s)
return s return s

View File

@ -1,5 +1,4 @@
from core.experience import Experience, ExperienceParameter from core.experience import Experience, ExperienceParameter
from mpPvAt import MpPvAt
import os import os
class ExperienceVLC(Experience): class ExperienceVLC(Experience):

View File

@ -1,102 +0,0 @@
import math
class MpLinkCharacteristics:
tcNetemParent = "1:1"
tcHtbClassid = "10"
tcNetemHandle = "1:10"
def bandwidthDelayProductDividedByMTU(self):
rtt = 2 * float(self.delay)
""" Since bandwidth is in Mbps and rtt in ms """
bandwidthDelayProduct = (float(self.bandwidth) * 125000.0) * (rtt / 1000.0)
return int(math.ceil(bandwidthDelayProduct * 1.0 / 1500.0))
def bufferSize(self):
return (1500.0 * self.bandwidthDelayProductDividedByMTU()) + (float(self.bandwidth) * 1000.0 * float(self.queuingDelay) / 8)
def extractQueuingDelay(self, queueSize, bandwidth, delay, mtu=1500):
# rtt = 2 * float(delay)
# bdp_queue_size = int((float(rtt) * float(bandwidth) * 1024 * 1024) / (int(mtu) * 8 * 1000))
# if int(queueSize) <= bdp_queue_size:
# Returning 0 seems to bypass everything, then only limited by CPU.
# This is not what we want...
# return 1
# queuingQueueSize = int(queueSize) - bdp_queue_size
queuingDelay = (int(queueSize) * int(mtu) * 8.0 * 1000.0) / (float(bandwidth) * 1024 * 1024)
return max(int(queuingDelay), 1)
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(self.extractQueuingDelay(queueSize, bandwidth, delay))
self.netemAt = []
self.back_up = back_up
def addNetemAt(self, n):
if len(self.netemAt) == 0:
n.delta = n.at
self.netemAt.append(n)
else:
if n.at > self.netemAt[-1].at:
n.delta = n.at - self.netemAt[-1].at
self.netemAt.append(n)
else:
print("Do not take into account " + n.__str__() + \
"because ooo !")
pass
def buildBwCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc del dev {} root ".format(ifname)
cmd = cmd + " ; tc qdisc add dev {} root handle 5:0 tbf rate {}mbit burst 15000 limit {} &&".format(ifname, self.bandwidth, int(self.bufferSize()))
cmd = cmd + " true &"
return cmd
def buildNetemCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep " + str(n.delta)
cmd = cmd + " && tc qdisc del dev " + ifname + " root "
cmd = cmd + " ; tc qdisc add dev {} root handle 10: netem {} delay {}ms limit 50000 &&".format(ifname, n.cmd, self.delay)
cmd = cmd + " true &"
return cmd
def buildPolicingCmd(self, ifname):
cmd = ""
for n in self.netemAt:
cmd = cmd + "sleep {}".format(n.delta)
cmd = cmd + " && tc qdisc del dev {} ingress".format(ifname)
cmd = cmd + " ; tc qdisc add dev {} handle ffff: ingress".format(ifname)
cmd = cmd + " && tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop && ".format(ifname, self.bandwidth, int(self.bufferSize() * 1.2))
cmd = cmd + " true &"
return cmd
def asDict(self):
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
def __str__(self):
s = "Link id : " + str(self.id) + "\n"
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

View File

@ -1,9 +0,0 @@
class MpNetemAt:
def __init__(self, at, cmd):
self.at = at
self.cmd = cmd
self.delta = 0
def __str__(self):
return "Netem... at " + str(self.at) + "(" + str(self.delta) + \
") will be " + self.cmd

View File

@ -1,9 +0,0 @@
class MpPvAt:
def __init__(self, at, cmd):
self.at = at
self.cmd = cmd
self.delta = 0
def __str__(self):
return "Pv... at " + str(self.at) + "(" + str(self.delta) + \
") will be " + self.cmd

View File

@ -1,13 +1,14 @@
from core.experience import Experience, ExperienceParameter, ExperienceParameter from core.experience import Experience, ExperienceParameter, ExperienceParameter
from core.topo import Topo, TopoParameter from core.topo import Topo, TopoParameter
from mininet_builder import MininetBuilder
from mpMultiInterfaceTopo import MpMultiInterfaceTopo from mpMultiInterfaceTopo import MpMultiInterfaceTopo
from mpMultiInterfaceConfig import MpMultiInterfaceConfig from mpMultiInterfaceConfig import MpMultiInterfaceConfig
from mpMultiInterfaceCongConfig import MpMultiInterfaceCongConfig from mpMultiInterfaceCongConfig import MpMultiInterfaceCongConfig
from mpMultiInterfaceCongTopo import MpMultiInterfaceCongTopo from mpMultiInterfaceCongTopo import MpMultiInterfaceCongTopo
from mpECMPSingleInterfaceConfig import MpECMPSingleInterfaceConfig from mpECMPSingleInterfaceConfig import MpECMPSingleInterfaceConfig
from mpTwoInterfaceCongestionConfig import MpTwoInterfaceCongestionConfig from mpTwoInterfaceCongestionConfig import MpTwoInterfaceCongestionConfig
from mpMininetBuilder import MpMininetBuilder
from mpExperiencePing import ExperiencePing from mpExperiencePing import ExperiencePing
from mpExperienceNCPV import ExperienceNCPV from mpExperienceNCPV import ExperienceNCPV
from mpExperienceNC import ExperienceNC from mpExperienceNC import ExperienceNC
@ -46,7 +47,7 @@ class MpXpRunner:
def defBuilder(self, builderType): def defBuilder(self, builderType):
if builderType == Topo.mininetBuilder: if builderType == Topo.mininetBuilder:
self.topoBuilder = MpMininetBuilder() self.topoBuilder = MininetBuilder()
else: else:
raise Exception("I can not find the builder " + raise Exception("I can not find the builder " +
builderType) builderType)

0
utils/__init__.py Normal file
View File