From dffae6d281e3f0f79c6c1138c3b40c1ddc75df3c Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Wed, 24 Jun 2020 11:26:56 +0200 Subject: [PATCH] still some file restructuration --- core/topo.py | 119 +++++++++++++++++++++- mpMininetBuilder.py => mininet_builder.py | 2 +- mpExperienceAb.py | 3 +- mpExperienceDITG.py | 1 - mpExperienceEpload.py | 1 - mpExperienceHTTP.py | 1 - mpExperienceHTTPS.py | 3 +- mpExperienceIperf.py | 1 - mpExperienceMsg.py | 4 +- mpExperienceNC.py | 1 - mpExperienceNCPV.py | 13 ++- mpExperienceNetperf.py | 1 - mpExperienceQUIC.py | 2 +- mpExperienceSendFile.py | 1 - mpExperienceSiri.py | 5 +- mpExperienceSiriHTTP.py | 5 +- mpExperienceSiriMsg.py | 37 ++++--- mpExperienceVLC.py | 1 - mpLinkCharacteristics.py | 102 ------------------- mpNetemAt.py | 9 -- mpPvAt.py | 9 -- mpXpRunner.py | 5 +- SiriClient.java => utils/SiriClient.java | 0 utils/__init__.py | 0 http.py => utils/http.py | 0 https.py => utils/https.py | 0 msg_client.py => utils/msg_client.py | 0 msg_server.py => utils/msg_server.py | 0 server.pem => utils/server.pem | 0 siriClient.jar => utils/siriClient.jar | Bin siri_server.py => utils/siri_server.py | 0 31 files changed, 158 insertions(+), 168 deletions(-) rename mpMininetBuilder.py => mininet_builder.py (97%) delete mode 100644 mpLinkCharacteristics.py delete mode 100644 mpNetemAt.py delete mode 100644 mpPvAt.py rename SiriClient.java => utils/SiriClient.java (100%) create mode 100644 utils/__init__.py rename http.py => utils/http.py (100%) rename https.py => utils/https.py (100%) rename msg_client.py => utils/msg_client.py (100%) rename msg_server.py => utils/msg_server.py (100%) rename server.pem => utils/server.pem (100%) rename siriClient.jar => utils/siriClient.jar (100%) rename siri_server.py => utils/siri_server.py (100%) diff --git a/core/topo.py b/core/topo.py index 46934ea..c5bd9da 100644 --- a/core/topo.py +++ b/core/topo.py @@ -1,7 +1,118 @@ from .parameter import Parameter -from mpLinkCharacteristics import MpLinkCharacteristics -from mpNetemAt import MpNetemAt +import math + + +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): LSUBNET = "leftSubnet" @@ -37,7 +148,7 @@ class TopoParameter(Parameter): for n in nlist: tab = n.split(",") if len(tab)==2: - o = MpNetemAt(float(tab[0]), tab[1]) + o = NetemAt(float(tab[0]), tab[1]) if id < len(self.linkCharacteristics): self.linkCharacteristics[id].addNetemAt(o) else: @@ -63,7 +174,7 @@ class TopoParameter(Parameter): except ValueError: bup = tab[3] == 'True' 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) self.linkCharacteristics.append(path) i = i + 1 diff --git a/mpMininetBuilder.py b/mininet_builder.py similarity index 97% rename from mpMininetBuilder.py rename to mininet_builder.py index c020764..e45f711 100644 --- a/mpMininetBuilder.py +++ b/mininet_builder.py @@ -5,7 +5,7 @@ from mininet.node import OVSBridge from mininet.cli import CLI from subprocess import Popen, PIPE -class MpMininetBuilder(Topo): +class MininetBuilder(Topo): def __init__(self): Topo.__init__( self ) self.net = None diff --git a/mpExperienceAb.py b/mpExperienceAb.py index 17f94d2..11c050f 100644 --- a/mpExperienceAb.py +++ b/mpExperienceAb.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceAb(Experience): @@ -51,7 +50,7 @@ class ExperienceAb(Experience): def getAbServerCmd(self): s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ - "/http.py &>" + ExperienceAb.SERVER_LOG + "&" + "/utils/http.py &>" + ExperienceAb.SERVER_LOG + "&" print(s) return s diff --git a/mpExperienceDITG.py b/mpExperienceDITG.py index 68692c8..49ea728 100644 --- a/mpExperienceDITG.py +++ b/mpExperienceDITG.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceDITG(Experience): diff --git a/mpExperienceEpload.py b/mpExperienceEpload.py index 004c574..213f915 100644 --- a/mpExperienceEpload.py +++ b/mpExperienceEpload.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceEpload(Experience): diff --git a/mpExperienceHTTP.py b/mpExperienceHTTP.py index bd3b0ed..73d3af0 100644 --- a/mpExperienceHTTP.py +++ b/mpExperienceHTTP.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceHTTP(Experience): diff --git a/mpExperienceHTTPS.py b/mpExperienceHTTPS.py index 2809edb..9ec3645 100644 --- a/mpExperienceHTTPS.py +++ b/mpExperienceHTTPS.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceHTTPS(Experience): @@ -49,7 +48,7 @@ class ExperienceHTTPS(Experience): def getHTTPSServerCmd(self): s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ - "/https.py &>" + ExperienceHTTPS.SERVER_LOG + "&" + "/utils/https.py &>" + ExperienceHTTPS.SERVER_LOG + "&" print(s) return s diff --git a/mpExperienceIperf.py b/mpExperienceIperf.py index d88dc7c..1a357a8 100644 --- a/mpExperienceIperf.py +++ b/mpExperienceIperf.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceIperf(Experience): diff --git a/mpExperienceMsg.py b/mpExperienceMsg.py index de7e220..7965bdc 100644 --- a/mpExperienceMsg.py +++ b/mpExperienceMsg.py @@ -46,13 +46,13 @@ class ExperienceMsg(Experience): def getMsgServerCmd(self): 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) return s def getMsgClientCmd(self): 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 print(s) return s diff --git a/mpExperienceNC.py b/mpExperienceNC.py index bf19a36..aa70510 100644 --- a/mpExperienceNC.py +++ b/mpExperienceNC.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt """ Should be the mother of ExperienceNCPV, shame on me, should rewrite diff --git a/mpExperienceNCPV.py b/mpExperienceNCPV.py index 8842411..5347f86 100644 --- a/mpExperienceNCPV.py +++ b/mpExperienceNCPV.py @@ -1,5 +1,16 @@ 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): """ diff --git a/mpExperienceNetperf.py b/mpExperienceNetperf.py index 15021bd..8a49b69 100644 --- a/mpExperienceNetperf.py +++ b/mpExperienceNetperf.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceNetperf(Experience): diff --git a/mpExperienceQUIC.py b/mpExperienceQUIC.py index fade901..88b9ac3 100644 --- a/mpExperienceQUIC.py +++ b/mpExperienceQUIC.py @@ -70,7 +70,7 @@ class ExperienceQUIC(Experience): def getCongServerCmd(self, congID): 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) return s diff --git a/mpExperienceSendFile.py b/mpExperienceSendFile.py index 4fae03e..8c8091e 100644 --- a/mpExperienceSendFile.py +++ b/mpExperienceSendFile.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceSendFile(Experience): diff --git a/mpExperienceSiri.py b/mpExperienceSiri.py index 87a5f42..a523551 100644 --- a/mpExperienceSiri.py +++ b/mpExperienceSiri.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceSiri(Experience): @@ -54,12 +53,12 @@ class ExperienceSiri(Experience): def getSiriServerCmd(self): s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/siri_server.py &>" + ExperienceSiri.SERVER_LOG + "&" + "/utils/siri_server.py &>" + ExperienceSiri.SERVER_LOG + "&" print(s) return s 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.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 + \ diff --git a/mpExperienceSiriHTTP.py b/mpExperienceSiriHTTP.py index 07b2234..17b8e27 100644 --- a/mpExperienceSiriHTTP.py +++ b/mpExperienceSiriHTTP.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceSiriHTTP(Experience): @@ -68,12 +67,12 @@ class ExperienceSiriHTTP(Experience): def getSiriServerCmd(self): s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/siri_server.py &>" + ExperienceSiriHTTP.SERVER_LOG + "&" + "/utils/siri_server.py &>" + ExperienceSiriHTTP.SERVER_LOG + "&" print(s) return s 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.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 + \ diff --git a/mpExperienceSiriMsg.py b/mpExperienceSiriMsg.py index ddc3588..ebf0494 100644 --- a/mpExperienceSiriMsg.py +++ b/mpExperienceSiriMsg.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceSiriMsg(Experience): @@ -21,7 +20,7 @@ class ExperienceSiriMsg(Experience): def ping(self): self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ ExperienceSiriMsg.PING_OUTPUT ) - count = self.xpParam.getParam(MpParamXp.PINGCOUNT) + count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT) for i in range(0, self.mpConfig.getClientInterfaceCount()): cmd = self.pingCommand(self.mpConfig.getClientIP(i), self.mpConfig.getServerIP(), n = count) @@ -37,19 +36,19 @@ class ExperienceSiriMsg(Experience): """ todo : param LD_PRELOAD ?? """ - self.run_time = self.xpParam.getParam(MpParamXp.SIRIRUNTIME) - self.query_size = self.xpParam.getParam(MpParamXp.SIRIQUERYSIZE) - self.response_size = self.xpParam.getParam(MpParamXp.SIRIRESPONSESIZE) - self.delay_query_response = self.xpParam.getParam(MpParamXp.SIRIDELAYQUERYRESPONSE) - self.min_payload_size = self.xpParam.getParam(MpParamXp.SIRIMINPAYLOADSIZE) - self.max_payload_size = self.xpParam.getParam(MpParamXp.SIRIMAXPAYLOADSIZE) - self.interval_time_ms = self.xpParam.getParam(MpParamXp.SIRIINTERVALTIMEMS) - self.buffer_size = self.xpParam.getParam(MpParamXp.SIRIBUFFERSIZE) - self.burst_size = self.xpParam.getParam(MpParamXp.SIRIBURSTSIZE) - self.interval_burst_time_ms = self.xpParam.getParam(MpParamXp.SIRIINTERVALBURSTTIMEMS) - self.client_sleep = self.xpParam.getParam(MpParamXp.MSGCLIENTSLEEP) - self.server_sleep = self.xpParam.getParam(MpParamXp.MSGSERVERSLEEP) - self.nb_requests = self.xpParam.getParam(MpParamXp.MSGNBREQUESTS) + self.run_time = self.xpParam.getParam(ExperienceParameter.SIRIRUNTIME) + self.query_size = self.xpParam.getParam(ExperienceParameter.SIRIQUERYSIZE) + self.response_size = self.xpParam.getParam(ExperienceParameter.SIRIRESPONSESIZE) + self.delay_query_response = self.xpParam.getParam(ExperienceParameter.SIRIDELAYQUERYRESPONSE) + self.min_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMINPAYLOADSIZE) + self.max_payload_size = self.xpParam.getParam(ExperienceParameter.SIRIMAXPAYLOADSIZE) + self.interval_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALTIMEMS) + self.buffer_size = self.xpParam.getParam(ExperienceParameter.SIRIBUFFERSIZE) + self.burst_size = self.xpParam.getParam(ExperienceParameter.SIRIBURSTSIZE) + self.interval_burst_time_ms = self.xpParam.getParam(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) + self.client_sleep = self.xpParam.getParam(ExperienceParameter.MSGCLIENTSLEEP) + self.server_sleep = self.xpParam.getParam(ExperienceParameter.MSGSERVERSLEEP) + self.nb_requests = self.xpParam.getParam(ExperienceParameter.MSGNBREQUESTS) def prepare(self): Experience.prepare(self) @@ -68,12 +67,12 @@ class ExperienceSiriMsg(Experience): def getSiriServerCmd(self): s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/siri_server.py &>" + ExperienceSiriMsg.SERVER_LOG + "&" + "/utils/siri_server.py &>" + ExperienceSiriMsg.SERVER_LOG + "&" print(s) return s 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.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 + \ @@ -83,13 +82,13 @@ class ExperienceSiriMsg(Experience): def getMsgServerCmd(self): 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) return s def getMsgClientCmd(self): 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 + "&" print(s) return s diff --git a/mpExperienceVLC.py b/mpExperienceVLC.py index 4142838..acad9e4 100644 --- a/mpExperienceVLC.py +++ b/mpExperienceVLC.py @@ -1,5 +1,4 @@ from core.experience import Experience, ExperienceParameter -from mpPvAt import MpPvAt import os class ExperienceVLC(Experience): diff --git a/mpLinkCharacteristics.py b/mpLinkCharacteristics.py deleted file mode 100644 index a222b65..0000000 --- a/mpLinkCharacteristics.py +++ /dev/null @@ -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 diff --git a/mpNetemAt.py b/mpNetemAt.py deleted file mode 100644 index bbbdeaa..0000000 --- a/mpNetemAt.py +++ /dev/null @@ -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 diff --git a/mpPvAt.py b/mpPvAt.py deleted file mode 100644 index 9e1af2b..0000000 --- a/mpPvAt.py +++ /dev/null @@ -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 diff --git a/mpXpRunner.py b/mpXpRunner.py index 968489b..90dbfa2 100644 --- a/mpXpRunner.py +++ b/mpXpRunner.py @@ -1,13 +1,14 @@ from core.experience import Experience, ExperienceParameter, ExperienceParameter from core.topo import Topo, TopoParameter +from mininet_builder import MininetBuilder + from mpMultiInterfaceTopo import MpMultiInterfaceTopo from mpMultiInterfaceConfig import MpMultiInterfaceConfig from mpMultiInterfaceCongConfig import MpMultiInterfaceCongConfig from mpMultiInterfaceCongTopo import MpMultiInterfaceCongTopo from mpECMPSingleInterfaceConfig import MpECMPSingleInterfaceConfig from mpTwoInterfaceCongestionConfig import MpTwoInterfaceCongestionConfig -from mpMininetBuilder import MpMininetBuilder from mpExperiencePing import ExperiencePing from mpExperienceNCPV import ExperienceNCPV from mpExperienceNC import ExperienceNC @@ -46,7 +47,7 @@ class MpXpRunner: def defBuilder(self, builderType): if builderType == Topo.mininetBuilder: - self.topoBuilder = MpMininetBuilder() + self.topoBuilder = MininetBuilder() else: raise Exception("I can not find the builder " + builderType) diff --git a/SiriClient.java b/utils/SiriClient.java similarity index 100% rename from SiriClient.java rename to utils/SiriClient.java diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/http.py b/utils/http.py similarity index 100% rename from http.py rename to utils/http.py diff --git a/https.py b/utils/https.py similarity index 100% rename from https.py rename to utils/https.py diff --git a/msg_client.py b/utils/msg_client.py similarity index 100% rename from msg_client.py rename to utils/msg_client.py diff --git a/msg_server.py b/utils/msg_server.py similarity index 100% rename from msg_server.py rename to utils/msg_server.py diff --git a/server.pem b/utils/server.pem similarity index 100% rename from server.pem rename to utils/server.pem diff --git a/siriClient.jar b/utils/siriClient.jar similarity index 100% rename from siriClient.jar rename to utils/siriClient.jar diff --git a/siri_server.py b/utils/siri_server.py similarity index 100% rename from siri_server.py rename to utils/siri_server.py