diff --git a/core/experience.py b/core/experience.py index af06462..3145ecd 100644 --- a/core/experience.py +++ b/core/experience.py @@ -23,13 +23,6 @@ class ExperienceParameter(Parameter): SNAPLENPCAP = "snaplenPcap" XPTYPE = "xpType" PINGCOUNT = "pingCount" - NETPERFTESTLEN = "netperfTestlen" - NETPERFTESTNAME = "netperfTestname" - NETPERFREQRESSIZE = "netperfReqresSize" - VLCFILE = "vlcFile" - VLCTIME = "vlcTime" - QUICMULTIPATH = "quicMultipath" - QUICSIRIRUNTIME = "quicSiriRunTime" PRIOPATH0 = "prioPath0" PRIOPATH1 = "prioPath1" BACKUPPATH0 = "backupPath0" @@ -83,12 +76,6 @@ class ExperienceParameter(Parameter): SNAPLENPCAP: "65535", # Default snapping value of tcpdump XPTYPE: "none", PINGCOUNT: "5", - NETPERFTESTLEN: "10", - NETPERFTESTNAME: "TCP_RR", - NETPERFREQRESSIZE: "2K,256", - VLCFILE: "bunny_ibmff_360.mpd", - VLCTIME: "0", - QUICMULTIPATH: "0", PRIOPATH0: "0", PRIOPATH1: "0", BACKUPPATH0: "0", @@ -432,6 +419,7 @@ class RandomFileParameter(ExperienceParameter): RandomFileParameter.RANDOM_SIZE: "1024", }) + class RandomFileExperience(Experience): """ Enable a experience to use random files diff --git a/experiences/msg.py b/experiences/msg.py index 58488af..b00d398 100644 --- a/experiences/msg.py +++ b/experiences/msg.py @@ -19,6 +19,7 @@ class MsgParameter(ExperienceParameter): class Msg(Experience): NAME = "msg" + PARAMETER_CLASS = MsgParameter SERVER_LOG = "msg_server.log" CLIENT_LOG = "msg_client.log" @@ -50,7 +51,6 @@ class Msg(Experience): self.server_sleep = self.experience_parameter.get(MsgParameter.SERVER_SLEEP) self.nb_requests = self.experience_parameter.get(MsgParameter.NB_REQUESTS) self.bytes = self.experience_parameter.get(MsgParameter.BYTES) - print("load parameter msg") def prepare(self): super(Msg, self).prepare() diff --git a/experiences/netperf.py b/experiences/netperf.py index 68db96e..76cc7ab 100644 --- a/experiences/netperf.py +++ b/experiences/netperf.py @@ -1,8 +1,24 @@ from core.experience import Experience, ExperienceParameter import os + +class NetperfParameter(ExperienceParameter): + TESTLEN = "netperfTestlen" + TESTNAME = "netperfTestname" + REQRES_SIZE = "netperfReqresSize" + + def __init__(self, experience_parameter_filename): + super(NetperfParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + NetperfParameter.TESTLEN: "10", + NetperfParameter.TESTNAME: "TCP_RR", + NetperfParameter.REQRES_SIZE: "2K,256", + }) + + class Netperf(Experience): NAME = "netperf" + PARAMETER_CLASS = NetperfParameter NETPERF_LOG = "netperf.log" NETSERVER_LOG = "netserver.log" @@ -14,7 +30,6 @@ class Netperf(Experience): super(Netperf, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(Netperf, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ @@ -32,9 +47,9 @@ class Netperf(Experience): return s def load_parameters(self): - self.testlen = self.experience_parameter.get(ExperienceParameter.NETPERFTESTLEN) - self.testname = self.experience_parameter.get(ExperienceParameter.NETPERFTESTNAME) - self.reqres_size = self.experience_parameter.get(ExperienceParameter.NETPERFREQRESSIZE) + self.testlen = self.experience_parameter.get(NetperfParameter.TESTLEN) + self.testname = self.experience_parameter.get(NetperfParameter.TESTNAME) + self.reqres_size = self.experience_parameter.get(NetperfParameter.REQRES_SIZE) def prepare(self): super(Netperf, self).prepare() @@ -43,16 +58,15 @@ class Netperf(Experience): self.topo.command_to(self.topo_config.server, "rm " + Netperf.NETSERVER_LOG) - def getClientCmd(self): - s = Netperf.NETPERF_BIN + " -H " + self.topo_config.getServerIP() + \ - " -l " + self.testlen + " -t " + self.testname + " -- -r " + self.reqres_size + \ - " &>" + Netperf.NETPERF_LOG + def get_client_cmd(self): + s = "{} -H {} -l {} -t {} -- -r {} &> {}".format(Netperf.NETPERF_BIN, + self.topo_config.getServerIP(), self.testlen, self.testname, self.reqres_size, + Netperf.NETPERF_LOG) print(s) return s - def getServerCmd(self): - s = "sudo " + Netperf.NETSERVER_BIN + " &>" + \ - Netperf.NETSERVER_LOG + "&" + def get_server_cmd(self): + s = "sudo {} &> {} &".format(Netperf.NETSERVER_BIN, Netperf.NETSERVER_LOG) print(s) return s @@ -60,10 +74,10 @@ class Netperf(Experience): super(Netperf, self).clean() def run(self): - cmd = self.getServerCmd() + cmd = self.get_server_cmd() self.topo.command_to(self.topo_config.server, cmd) self.topo.command_to(self.topo_config.client, "sleep 2") - cmd = self.getClientCmd() + cmd = self.get_client_cmd() self.topo.command_to(self.topo_config.client, cmd) self.topo.command_to(self.topo_config.client, "sleep 2") diff --git a/experiences/quic.py b/experiences/quic.py index 2a2f438..f310c83 100644 --- a/experiences/quic.py +++ b/experiences/quic.py @@ -3,8 +3,19 @@ from topos.multi_interface_cong import MultiInterfaceCongConfig import os +class QUICParameter(RandomFileExperience): + MULTIPATH = "quicMultipath" + + def __init__(self, experience_parameter_filename): + super(QUICParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + QUICParameter.MULTIPATH: "0", + }) + + class QUIC(RandomFileExperience): NAME = "quic" + PARAMETER_CLASS = QUICParameter GO_BIN = "/usr/local/go/bin/go" WGET = "~/git/wget/src/wget" @@ -36,7 +47,7 @@ class QUIC(RandomFileExperience): def load_parameters(self): super(QUIC, self).load_parameters() - self.multipath = self.experience_parameter.get(ExperienceParameter.QUICMULTIPATH) + self.multipath = self.experience_parameter.get(QUICParameter.MULTIPATH) def prepare(self): super(QUIC, self).prepare() diff --git a/experiences/quic_siri.py b/experiences/quic_siri.py index 1e44110..0fc0d9f 100644 --- a/experiences/quic_siri.py +++ b/experiences/quic_siri.py @@ -2,8 +2,20 @@ from core.experience import Experience, ExperienceParameter import os +class QUICSiriParameter(ExperienceParameter): + MULTIPATH = "quicMultipath" + RUN_TIME = "quicSiriRunTime" + + def __init__(self, experience_parameter_filename): + super(QUICSiriParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + QUICSiriParameter.MULTIPATH: "0", + }) + + class QUICSiri(Experience): NAME = "quicsiri" + PARAMETER_CLASS = QUICSiriParameter GO_BIN = "/usr/local/go/bin/go" SERVER_LOG = "quic_server.log" @@ -33,8 +45,8 @@ class QUICSiri(Experience): return s def load_parameters(self): - self.run_time = self.experience_parameter.get(ExperienceParameter.QUICSIRIRUNTIME) - self.multipath = self.experience_parameter.get(ExperienceParameter.QUICMULTIPATH) + self.run_time = self.experience_parameter.get(QUICSiriParameter.RUN_TIME) + self.multipath = self.experience_parameter.get(QUICSiriParameter.MULTIPATH) def prepare(self): super(QUICSiri, self).prepare() @@ -43,18 +55,16 @@ class QUICSiri(Experience): self.topo.command_to(self.topo_config.server, "rm " + \ QUICSiri.SERVER_LOG ) - def getQUICSiriServerCmd(self): - s = QUICSiri.GO_BIN + " run " + QUICSiri.SERVER_GO_FILE - s += " -addr 0.0.0.0:8080 &>" + QUICSiri.SERVER_LOG + " &" + def get_quic_siri_server_cmd(self): + s = "{} run {} -addr 0.0.0.0:8080 &> {} &".format(QUICSiri.GO_BIN, + QUICSiri.SERVER_GO_FILE, QUICSiri.SERVER_LOG) print(s) return s - def getQUICSiriClientCmd(self): - s = QUICSiri.GO_BIN + " run " + QUICSiri.CLIENT_GO_FILE - s += " -addr " + self.topo_config.getServerIP() + ":8080 -runTime " + self.run_time + "s" - if int(self.multipath) > 0: - s += " -m" - s += " &>" + QUICSiri.CLIENT_LOG + def get_quic_siri_client_cmd(self): + s = "{} run {} -addr {}:8080 -runTime {}s {} &> {}".format(QUICSiri.GO_BIN, + QUICSiri.CLIENT_GO_FILE, self.topo_config.getServerIP(), self.run_time, + "-m" if int(self.multipath) > 0 else "", QUICSiri.CLIENT_LOG) print(s) return s @@ -62,12 +72,12 @@ class QUICSiri(Experience): super(QUICSiri, self).clean() def run(self): - cmd = self.getQUICSiriServerCmd() + cmd = self.get_quic_siri_server_cmd() self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.server, cmd) self.topo.command_to(self.topo_config.client, "sleep 2") - cmd = self.getQUICSiriClientCmd() + cmd = self.get_quic_siri_client_cmd() self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before") self.topo.command_to(self.topo_config.client, cmd) self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after") diff --git a/experiences/siri.py b/experiences/siri.py index 7ec05ee..6fb35c3 100644 --- a/experiences/siri.py +++ b/experiences/siri.py @@ -70,7 +70,6 @@ class Siri(Experience): self.buffer_size = self.experience_parameter.get(SiriParameter.BUFFER_SIZE) self.burst_size = self.experience_parameter.get(SiriParameter.BURST_SIZE) self.interval_burst_time_ms = self.experience_parameter.get(SiriParameter.INTERVAL_BURST_TIME_MS) - print("load parameter siri") def prepare(self): super(Siri, self).prepare() diff --git a/experiences/vlc.py b/experiences/vlc.py index 4246757..166aa70 100644 --- a/experiences/vlc.py +++ b/experiences/vlc.py @@ -1,6 +1,18 @@ from core.experience import Experience, ExperienceParameter import os + +class VLCParameter(ExperienceParameter): + FILE = "vlcFile" + TIME = "vlcTime" + + def __init__(self, experience_parameter_filename): + super(VLCParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + VLCParameter.FILE: "bunny_ibmff_360.mpd", + VLCParameter.TIME: "0", + }) + class VLC(Experience): NAME = "vlc" @@ -30,8 +42,8 @@ class VLC(Experience): return s def load_parameters(self): - self.file = self.experience_parameter.get(ExperienceParameter.VLCFILE) - self.time = self.experience_parameter.get(ExperienceParameter.VLCTIME) + self.file = self.experience_parameter.get(VLCParameter.FILE) + self.time = self.experience_parameter.get(VLCParameter.TIME) def prepare(self): super(VLC, self).prepare() @@ -40,39 +52,31 @@ class VLC(Experience): self.topo.command_to(self.topo_config.client, "Xvfb :66 &") self.topo.command_to(self.topo_config.server, "rm " + \ VLC.SERVER_LOG ) - if self.file == "random": - self.topo.command_to(self.topo_config.client, - "dd if=/dev/urandom of=random bs=1K count=" + \ - self.random_size) - def getVLCServerCmd(self): - s = "/etc/init.d/apache2 restart &>" + VLC.SERVER_LOG + " " + def get_vlc_server_cmd(self): + s = "/etc/init.d/apache2 restart &> {}".format(VLC.SERVER_LOG) print(s) return s - def getVLCClientCmd(self): - s = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mininet/usr/lib/ && sudo ldconfig && " \ - + VLC.VLC_BIN + " -I dummy --x11-display :66" + \ - " --adaptive-logic 3 --no-loop --play-and-exit " + \ - " http://" + self.topo_config.getServerIP() + \ - "/" + self.file + " 2>&1 | grep -E '(Neb|halp|bandwidth|late|Buffering|buffering)' > " + VLC.CLIENT_LOG - if self.time != "0" : - s = s + " &" + def get_vlc_client_cmd(self): + s = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mininet/usr/lib/ && sudo ldconfig && \ + {} -I dummy --x11-display :66 --adaptive-logic 3 --no-loop --play-and-exit \ + http://{}/{} 2>&1 | grep -E '(Neb|halp|bandwidth|late|Buffering|buffering)' > {} {}".format( + VLC.VLC_BIN, self.topo_config.getServerIP(), self.file, VLC.CLIENT_LOG, + "&" if self.time != "0" else "") print(s) return s def clean(self): super(VLC, self).clean(self) - if self.file == "random": - self.topo.command_to(self.topo_config.client, "rm random*") self.topo.command_to(self.topo_config.client, "pkill Xvfb") def run(self): - cmd = self.getVLCServerCmd() + cmd = self.get_vlc_server_cmd() self.topo.command_to(self.topo_config.server, cmd) self.topo.command_to(self.topo_config.client, "sleep 1") - cmd = self.getVLCClientCmd() + cmd = self.get_vlc_client_cmd() self.topo.command_to(self.topo_config.client, cmd) if self.time != "0" :