From be1d4091ea21c25edf209d2d8aa29cc5b9a502b7 Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Thu, 25 Jun 2020 15:56:14 +0200 Subject: [PATCH] making progress in refactoring, enabling combination of experiments --- config/xp/sirimsg | 2 + core/experience.py | 43 ---------------- experiences/ab.py | 1 - experiences/ditg.py | 35 ++++++++++--- experiences/epload.py | 1 - experiences/iperf.py | 1 - experiences/msg.py | 45 +++++++++++------ experiences/nc.py | 1 - experiences/ncpv.py | 1 - experiences/none.py | 1 - experiences/ping.py | 1 - experiences/quic_siri.py | 1 - experiences/siri.py | 73 +++++++++++++++++++-------- experiences/siri_http.py | 41 ++------------- experiences/siri_msg.py | 106 ++++++++++----------------------------- experiences/vlc.py | 1 - runner.py | 4 +- 17 files changed, 146 insertions(+), 212 deletions(-) create mode 100644 config/xp/sirimsg diff --git a/config/xp/sirimsg b/config/xp/sirimsg new file mode 100644 index 0000000..6d399e0 --- /dev/null +++ b/config/xp/sirimsg @@ -0,0 +1,2 @@ +xpType:sirimsg +siriRunTime:10 diff --git a/core/experience.py b/core/experience.py index 8b35b77..af06462 100644 --- a/core/experience.py +++ b/core/experience.py @@ -26,29 +26,8 @@ class ExperienceParameter(Parameter): NETPERFTESTLEN = "netperfTestlen" NETPERFTESTNAME = "netperfTestname" NETPERFREQRESSIZE = "netperfReqresSize" - - SIRIRUNTIME = "siriRunTime" - SIRIQUERYSIZE = "siriQuerySize" - SIRIRESPONSESIZE = "siriResponseSize" - SIRIDELAYQUERYRESPONSE = "siriDelayQueryResponse" - SIRIMINPAYLOADSIZE = "siriMinPayloadSize" - SIRIMAXPAYLOADSIZE = "siriMaxPayloadSize" - SIRIINTERVALTIMEMS = "siriIntervalTimeMs" - SIRIBUFFERSIZE = "siriBufferSize" - SIRIBURSTSIZE = "siriBurstSize" - SIRIINTERVALBURSTTIMEMS = "siriIntervalBurstTimeMs" VLCFILE = "vlcFile" VLCTIME = "vlcTime" - DITGKBYTES = "ditgKBytes" - DITGCONSTANTPACKETSIZE = "ditgConstantPacketSize" - DITGMEANPOISSONPACKETSSEC = "ditgMeanPoissonPacketsSec" - DITGCONSTANTPACKETSSEC = "ditgConstantPacketsSec" - DITGBURSTSONPACKETSSEC = "ditgBurstsOnPacketsSec" - DITGBURSTSOFFPACKETSSEC = "ditgBurstsOffPacketsSec" - MSGCLIENTSLEEP = "msgClientSleep" - MSGSERVERSLEEP = "msgServerSleep" - MSGNBREQUESTS = "msgNbRequests" - MSGBYTES = "msgBytes" QUICMULTIPATH = "quicMultipath" QUICSIRIRUNTIME = "quicSiriRunTime" PRIOPATH0 = "prioPath0" @@ -107,27 +86,8 @@ class ExperienceParameter(Parameter): NETPERFTESTLEN: "10", NETPERFTESTNAME: "TCP_RR", NETPERFREQRESSIZE: "2K,256", - SIRIQUERYSIZE: "2500", - SIRIRESPONSESIZE: "750", - SIRIDELAYQUERYRESPONSE: "0", - SIRIMINPAYLOADSIZE: "85", - SIRIMAXPAYLOADSIZE: "500", - SIRIINTERVALTIMEMS: "333", - SIRIBUFFERSIZE: "9", - SIRIBURSTSIZE: "0", - SIRIINTERVALBURSTTIMEMS: "0", VLCFILE: "bunny_ibmff_360.mpd", VLCTIME: "0", - DITGKBYTES: "10000", - DITGCONSTANTPACKETSIZE: "1428", - DITGMEANPOISSONPACKETSSEC: "0", - DITGCONSTANTPACKETSSEC: "0", - DITGBURSTSONPACKETSSEC: "0", - DITGBURSTSOFFPACKETSSEC: "0", - MSGCLIENTSLEEP: "5.0", - MSGSERVERSLEEP: "5.0", - MSGNBREQUESTS: "5", - MSGBYTES: "1200", QUICMULTIPATH: "0", PRIOPATH0: "0", PRIOPATH1: "0", @@ -191,8 +151,6 @@ class Experience(object): - A preparation phase through `prepare()` (generating experiment files,...) - A running phase through `run()` (where the actual experience takes place) - A cleaning phase through `clean()` (stopping traffic, removing generated files,...) - - Typically, this function is called in the constructor of child classes. """ self.prepare() self.run() @@ -486,7 +444,6 @@ class RandomFileExperience(Experience): super(RandomFileExperience, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(RandomFileExperience, self).classic_run() def load_parameters(self): super(RandomFileExperience, self).load_parameters() diff --git a/experiences/ab.py b/experiences/ab.py index 69b8e71..b6d04f9 100644 --- a/experiences/ab.py +++ b/experiences/ab.py @@ -76,4 +76,3 @@ class AB(RandomFileExperience): cmd = self.get_ab_client_cmd() self.topo.command_to(self.topo_config.client, cmd) self.topo.command_to(self.topo_config.client, "sleep 2") - self.topo.get_cli() diff --git a/experiences/ditg.py b/experiences/ditg.py index 499a1fd..8996910 100644 --- a/experiences/ditg.py +++ b/experiences/ditg.py @@ -1,8 +1,30 @@ from core.experience import Experience, ExperienceParameter import os + +class DITGParameter(ExperienceParameter): + KBYTES = "ditgKBytes" + CONSTANT_PACKET_SIZE = "ditgConstantPacketSize" + MEAN_POISSON_PACKETS_SEC = "ditgMeanPoissonPacketsSec" + CONSTANT_PACKETS_SEC = "ditgConstantPacketsSec" + BURSTS_ON_PACKETS_SEC = "ditgBurstsOnPacketsSec" + BURSTS_OFF_PACKETS_SEC = "ditgBurstsOffPacketsSec" + + def __init__(self, experience_parameter_filename): + super(DITGParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + DITGParameter.KBYTES: "10000", + DITGParameter.CONSTANT_PACKET_SIZE: "1428", + DITGParameter.MEAN_POISSON_PACKETS_SEC: "0", + DITGParameter.CONSTANT_PACKETS_SEC: "0", + DITGParameter.BURSTS_ON_PACKETS_SEC: "0", + DITGParameter.BURSTS_OFF_PACKETS_SEC: "0", + }) + + class DITG(Experience): NAME = "ditg" + PARAMETER_CLASS = DITGParameter DITG_LOG = "ditg.log" DITG_SERVER_LOG = "ditg_server.log" @@ -18,7 +40,6 @@ class DITG(Experience): super(DITG, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(DITG, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ @@ -36,12 +57,12 @@ class DITG(Experience): return s def load_parameters(self): - self.kbytes = self.experience_parameter.get(ExperienceParameter.DITGKBYTES) - self.constant_packet_size = self.experience_parameter.get(ExperienceParameter.DITGCONSTANTPACKETSIZE) - self.mean_poisson_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGMEANPOISSONPACKETSSEC) - self.constant_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGCONSTANTPACKETSSEC) - self.bursts_on_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGBURSTSONPACKETSSEC) - self.bursts_off_packets_sec = self.experience_parameter.get(ExperienceParameter.DITGBURSTSOFFPACKETSSEC) + self.kbytes = self.experience_parameter.get(DITGParameter.KBYTES) + self.constant_packet_size = self.experience_parameter.get(DITGParameter.CONSTANT_PACKET_SIZE) + self.mean_poisson_packets_sec = self.experience_parameter.get(DITGParameter.MEAN_POISSON_PACKETS_SEC) + self.constant_packets_sec = self.experience_parameter.get(DITGParameter.CONSTANT_PACKETS_SEC) + self.bursts_on_packets_sec = self.experience_parameter.get(DITGParameter.BURSTS_ON_PACKETS_SEC) + self.bursts_off_packets_sec = self.experience_parameter.get(DITGParameter.BURSTS_OFF_PACKETS_SEC) def prepare(self): super(DITG, self).prepare() diff --git a/experiences/epload.py b/experiences/epload.py index c10fc74..cf79568 100644 --- a/experiences/epload.py +++ b/experiences/epload.py @@ -25,7 +25,6 @@ class Epload(Experience): super(Epload, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(Epload, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ diff --git a/experiences/iperf.py b/experiences/iperf.py index d06609c..dd2281d 100644 --- a/experiences/iperf.py +++ b/experiences/iperf.py @@ -25,7 +25,6 @@ class IPerf(Experience): super(IPerf, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(IPerf, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ diff --git a/experiences/msg.py b/experiences/msg.py index 09620ec..58488af 100644 --- a/experiences/msg.py +++ b/experiences/msg.py @@ -1,6 +1,22 @@ from core.experience import Experience, ExperienceParameter import os + +class MsgParameter(ExperienceParameter): + CLIENT_SLEEP = "msgClientSleep" + SERVER_SLEEP = "msgServerSleep" + NB_REQUESTS = "msgNbRequests" + BYTES = "msgBytes" + + def __init__(self, experience_parameter_filename): + super(MsgParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + MsgParameter.CLIENT_SLEEP: "5.0", + MsgParameter.SERVER_SLEEP: "5.0", + MsgParameter.NB_REQUESTS: "5", + MsgParameter.BYTES: "1200", + }) + class Msg(Experience): NAME = "msg" @@ -13,7 +29,6 @@ class Msg(Experience): super(Msg, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(Msg, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ @@ -31,10 +46,11 @@ class Msg(Experience): return s def load_parameters(self): - self.client_sleep = self.experience_parameter.get(ExperienceParameter.MSGCLIENTSLEEP) - self.server_sleep = self.experience_parameter.get(ExperienceParameter.MSGSERVERSLEEP) - self.nb_requests = self.experience_parameter.get(ExperienceParameter.MSGNBREQUESTS) - self.bytes = self.experience_parameter.get(ExperienceParameter.MSGBYTES) + self.client_sleep = self.experience_parameter.get(MsgParameter.CLIENT_SLEEP) + 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() @@ -43,16 +59,17 @@ class Msg(Experience): self.topo.command_to(self.topo_config.server, "rm " + \ Msg.SERVER_LOG) - def getMsgServerCmd(self): - s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/msg_server.py --sleep " + self.server_sleep + " --bytes " + self.bytes + " &>" + Msg.SERVER_LOG + "&" + def get_msg_server_cmd(self): + s = "python {}/../utils/msg_server.py --sleep {} --bytes {} &> {}&".format( + os.path.dirname(os.path.abspath(__file__)), self.server_sleep, self.bytes, + Msg.SERVER_LOG) print(s) return s - def getMsgClientCmd(self): - s = "python " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \ - " --bytes " + self.bytes + " >" + Msg.CLIENT_LOG + " 2>" + Msg.CLIENT_ERR + def get_msg_client_cmd(self, daemon=False): + s = "python {}/../utils/msg_client.py --sleep {} --nb {} --bytes {} > {} 2> {} {}".format( + os.path.dirname(os.path.abspath(__file__)), self.client_sleep, self.nb_requests, + self.bytes, Msg.CLIENT_LOG, Msg.CLIENT_ERR, "&" if daemon else "") print(s) return s @@ -60,12 +77,12 @@ class Msg(Experience): super(Msg, self).clean() def run(self): - cmd = self.getMsgServerCmd() + cmd = self.get_msg_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.getMsgClientCmd() + cmd = self.get_msg_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/nc.py b/experiences/nc.py index cd755e8..96dadf1 100644 --- a/experiences/nc.py +++ b/experiences/nc.py @@ -34,7 +34,6 @@ class NC(Experience): def __init__(self, experience_parameter_filename, topo, topo_config): super(NC, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() - super(NC, self).classic_run() def load_parameters(self): self.ddibs = self.experience_parameter.get(NCParameter.DD_IBS) diff --git a/experiences/ncpv.py b/experiences/ncpv.py index 8debfc2..58ec9e0 100644 --- a/experiences/ncpv.py +++ b/experiences/ncpv.py @@ -46,7 +46,6 @@ class NCPV(NC): super(NCPV, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(NCPV, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ diff --git a/experiences/none.py b/experiences/none.py index 5084548..fc8bd47 100644 --- a/experiences/none.py +++ b/experiences/none.py @@ -5,7 +5,6 @@ class NoneExperience(Experience): def __init__(self, experience_parameter_filename, topo, topo_config): super(NoneExperience, self).__init__(experience_parameter_filename, topo, topo_config) - super(NoneExperience, self).classic_run() def prepare(self): Experience.prepare(self) diff --git a/experiences/ping.py b/experiences/ping.py index be2503d..7eee3c1 100644 --- a/experiences/ping.py +++ b/experiences/ping.py @@ -7,7 +7,6 @@ class Ping(Experience): def __init__(self, experience_parameter_filename, topo, topo_config): super(Ping, self).__init__(experience_parameter_filename, topo, topo_config) - super(Ping, self).classic_run() def prepare(self): super(Ping, self).prepare() diff --git a/experiences/quic_siri.py b/experiences/quic_siri.py index 9d7160b..1e44110 100644 --- a/experiences/quic_siri.py +++ b/experiences/quic_siri.py @@ -16,7 +16,6 @@ class QUICSiri(Experience): super(QUICSiri, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(QUICSiri, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ diff --git a/experiences/siri.py b/experiences/siri.py index 10b587a..7ec05ee 100644 --- a/experiences/siri.py +++ b/experiences/siri.py @@ -1,8 +1,37 @@ from core.experience import Experience, ExperienceParameter import os + +class SiriParameter(ExperienceParameter): + RUN_TIME = "siriRunTime" + QUERY_SIZE = "siriQuerySize" + RESPONSE_SIZE = "siriResponseSize" + DELAY_QUERY_RESPONSE = "siriDelayQueryResponse" + MIN_PAYLOAD_SIZE = "siriMinPayloadSize" + MAX_PAYLOAD_SIZE = "siriMaxPayloadSize" + INTERVAL_TIME_MS = "siriIntervalTimeMs" + BUFFER_SIZE = "siriBufferSize" + BURST_SIZE = "siriBurstSize" + INTERVAL_BURST_TIME_MS = "siriIntervalBurstTimeMs" + + def __init__(self, experience_parameter_filename): + super(SiriParameter, self).__init__(experience_parameter_filename) + self.default_parameters.update({ + SiriParameter.QUERY_SIZE: "2500", + SiriParameter.RESPONSE_SIZE: "750", + SiriParameter.DELAY_QUERY_RESPONSE: "0", + SiriParameter.MIN_PAYLOAD_SIZE: "85", + SiriParameter.MAX_PAYLOAD_SIZE: "500", + SiriParameter.INTERVAL_TIME_MS: "333", + SiriParameter.BUFFER_SIZE: "9", + SiriParameter.BURST_SIZE: "0", + SiriParameter.INTERVAL_BURST_TIME_MS: "0", + }) + + class Siri(Experience): NAME = "siri" + PARAMETER_CLASS = SiriParameter SERVER_LOG = "siri_server.log" CLIENT_LOG = "siri_client.log" @@ -14,7 +43,6 @@ class Siri(Experience): super(Siri, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(Siri, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ @@ -32,16 +60,17 @@ class Siri(Experience): return s def load_parameters(self): - self.run_time = self.experience_parameter.get(ExperienceParameter.SIRIRUNTIME) - self.query_size = self.experience_parameter.get(ExperienceParameter.SIRIQUERYSIZE) - self.response_size = self.experience_parameter.get(ExperienceParameter.SIRIRESPONSESIZE) - self.delay_query_response = self.experience_parameter.get(ExperienceParameter.SIRIDELAYQUERYRESPONSE) - self.min_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMINPAYLOADSIZE) - self.max_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMAXPAYLOADSIZE) - self.interval_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALTIMEMS) - self.buffer_size = self.experience_parameter.get(ExperienceParameter.SIRIBUFFERSIZE) - self.burst_size = self.experience_parameter.get(ExperienceParameter.SIRIBURSTSIZE) - self.interval_burst_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) + self.run_time = self.experience_parameter.get(SiriParameter.RUN_TIME) + self.query_size = self.experience_parameter.get(SiriParameter.QUERY_SIZE) + self.response_size = self.experience_parameter.get(SiriParameter.RESPONSE_SIZE) + self.delay_query_response = self.experience_parameter.get(SiriParameter.DELAY_QUERY_RESPONSE) + self.min_payload_size = self.experience_parameter.get(SiriParameter.MIN_PAYLOAD_SIZE) + self.max_payload_size = self.experience_parameter.get(SiriParameter.MAX_PAYLOAD_SIZE) + self.interval_time_ms = self.experience_parameter.get(SiriParameter.INTERVAL_TIME_MS) + 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() @@ -50,18 +79,18 @@ class Siri(Experience): self.topo.command_to(self.topo_config.server, "rm " + \ Siri.SERVER_LOG) - def getSiriServerCmd(self): - s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/siri_server.py &>" + Siri.SERVER_LOG + "&" + def get_siri_server_cmd(self): + s = "python3 {}/../utils/siri_server.py &> {}&".format( + os.path.dirname(os.path.abspath(__file__)), Siri.SERVER_LOG) print(s) return s - def getSiriClientCmd(self): - s = Siri.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \ - self.topo_config.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 + \ - " >" + Siri.CLIENT_LOG + " 2>" + Siri.CLIENT_ERR + def get_siri_client_cmd(self): + s = "{} -jar {}/../utils/siriClient.jar {} 8080 {} {} {} {} {} {} {} {} {} {} > {} 2> {}".format( + Siri.JAVA_BIN, os.path.dirname(os.path.abspath(__file__)), self.topo_config.getServerIP(), + 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, Siri.CLIENT_LOG, Siri.CLIENT_ERR) print(s) return s @@ -69,12 +98,12 @@ class Siri(Experience): super(Siri, self).clean() def run(self): - cmd = self.getSiriServerCmd() + cmd = self.get_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.getSiriClientCmd() + cmd = self.get_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_http.py b/experiences/siri_http.py index 40c4845..ae3b4d5 100644 --- a/experiences/siri_http.py +++ b/experiences/siri_http.py @@ -1,7 +1,8 @@ from core.experience import ExperienceParameter, RandomFileExperience, RandomFileParameter +from .siri import Siri import os -class SiriHTTP(RandomFileExperience): +class SiriHTTP(Siri, RandomFileExperience): NAME = "sirihttp" HTTP_SERVER_LOG = "http_server.log" @@ -33,18 +34,8 @@ class SiriHTTP(RandomFileExperience): return s def load_parameters(self): - # Start collecting parameters of RandomFileExperiment + # Start collecting parameters of RandomFileExperiment and Siri super(SiriHTTP, self).load_parameters() - self.run_time = self.experience_parameter.get(ExperienceParameter.SIRIRUNTIME) - self.query_size = self.experience_parameter.get(ExperienceParameter.SIRIQUERYSIZE) - self.response_size = self.experience_parameter.get(ExperienceParameter.SIRIRESPONSESIZE) - self.delay_query_response = self.experience_parameter.get(ExperienceParameter.SIRIDELAYQUERYRESPONSE) - self.min_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMINPAYLOADSIZE) - self.max_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMAXPAYLOADSIZE) - self.interval_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALTIMEMS) - self.buffer_size = self.experience_parameter.get(ExperienceParameter.SIRIBUFFERSIZE) - self.burst_size = self.experience_parameter.get(ExperienceParameter.SIRIBURSTSIZE) - self.interval_burst_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) def prepare(self): super(SiriHTTP, self).prepare() @@ -56,26 +47,6 @@ class SiriHTTP(RandomFileExperience): SiriHTTP.HTTP_CLIENT_LOG) self.topo.command_to(self.topo_config.server, "rm " + \ SiriHTTP.HTTP_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 getSiriServerCmd(self): - s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/siri_server.py &>" + SiriHTTP.SERVER_LOG + "&" - print(s) - return s - - def getSiriClientCmd(self): - s = SiriHTTP.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \ - self.topo_config.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 + \ - " >" + SiriHTTP.CLIENT_LOG + " 2>" + SiriHTTP.CLIENT_ERR - print(s) - return s def getHTTPServerCmd(self): s = "/etc/init.d/apache2 restart &>" + SiriHTTP.SERVER_LOG + "&" @@ -90,11 +61,9 @@ class SiriHTTP(RandomFileExperience): def clean(self): super(SiriHTTP, self).clean() - if self.file == "random": - self.topo.command_to(self.topo_config.client, "rm random*") def run(self): - cmd = self.getSiriServerCmd() + cmd = self.get_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) cmd = self.getHTTPServerCmd() @@ -104,7 +73,7 @@ class SiriHTTP(RandomFileExperience): self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before") cmd = self.getHTTPClientCmd() self.topo.command_to(self.topo_config.client, "for i in {1..200}; do " + cmd + "; done &") - cmd = self.getSiriClientCmd() + cmd = self.get_siri_client_cmd() self.topo.command_to(self.topo_config.client, cmd) self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after") diff --git a/experiences/siri_msg.py b/experiences/siri_msg.py index b3682de..d8e89a7 100644 --- a/experiences/siri_msg.py +++ b/experiences/siri_msg.py @@ -1,8 +1,20 @@ -from core.experience import Experience, ExperienceParameter +from core.experience import ExperienceParameter +from .siri import Siri, SiriParameter +from .msg import Msg, MsgParameter import os -class SiriMsg(Experience): + +class SiriMsgParameter(SiriParameter, MsgParameter): + """ + This class is needed because Python has no way to know what we prefer over Siri or + Msg parameters. So explicitly state that we want both. + """ + pass + + +class SiriMsg(Siri, Msg): NAME = "sirimsg" + PARAMETER_CLASS = SiriMsgParameter MSG_SERVER_LOG = "msg_server.log" MSG_CLIENT_LOG = "msg_client.log" @@ -15,98 +27,34 @@ class SiriMsg(Experience): def __init__(self, experience_parameter_filename, topo, topo_config): super(SiriMsg, self).__init__(experience_parameter_filename, topo, topo_config) - self.load_parameters() - self.ping() - super(SiriMsg, self).classic_run() - - def ping(self): - self.topo.command_to(self.topo_config.client, "rm " + \ - SiriMsg.PING_OUTPUT ) - count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): - cmd = self.pingCommand(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) - self.topo.command_to(self.topo_config.client, cmd) - - def pingCommand(self, fromIP, toIP, n=5): - s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \ - " >> " + SiriMsg.PING_OUTPUT - print(s) - return s def load_parameters(self): - self.run_time = self.experience_parameter.get(ExperienceParameter.SIRIRUNTIME) - self.query_size = self.experience_parameter.get(ExperienceParameter.SIRIQUERYSIZE) - self.response_size = self.experience_parameter.get(ExperienceParameter.SIRIRESPONSESIZE) - self.delay_query_response = self.experience_parameter.get(ExperienceParameter.SIRIDELAYQUERYRESPONSE) - self.min_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMINPAYLOADSIZE) - self.max_payload_size = self.experience_parameter.get(ExperienceParameter.SIRIMAXPAYLOADSIZE) - self.interval_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALTIMEMS) - self.buffer_size = self.experience_parameter.get(ExperienceParameter.SIRIBUFFERSIZE) - self.burst_size = self.experience_parameter.get(ExperienceParameter.SIRIBURSTSIZE) - self.interval_burst_time_ms = self.experience_parameter.get(ExperienceParameter.SIRIINTERVALBURSTTIMEMS) - self.client_sleep = self.experience_parameter.get(ExperienceParameter.MSGCLIENTSLEEP) - self.server_sleep = self.experience_parameter.get(ExperienceParameter.MSGSERVERSLEEP) - self.nb_requests = self.experience_parameter.get(ExperienceParameter.MSGNBREQUESTS) + # Fetch both Msg and Siri parameters + Siri.load_parameters(self) + Msg.load_parameters(self) def prepare(self): - super(SiriMsg, self).prepare() - self.topo.command_to(self.topo_config.client, "rm " + \ - SiriMsg.CLIENT_LOG) - self.topo.command_to(self.topo_config.client, "rm " + \ - SiriMsg.CLIENT_ERR) - self.topo.command_to(self.topo_config.server, "rm " + \ - SiriMsg.SERVER_LOG) - self.topo.command_to(self.topo_config.client, "rm " + \ - SiriMsg.MSG_CLIENT_LOG) - self.topo.command_to(self.topo_config.client, "rm " + \ - SiriMsg.MSG_CLIENT_ERR) - self.topo.command_to(self.topo_config.server, "rm " + \ - SiriMsg.MSG_SERVER_LOG) - - def getSiriServerCmd(self): - s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/siri_server.py &>" + SiriMsg.SERVER_LOG + "&" - print(s) - return s - - def getSiriClientCmd(self): - s = SiriMsg.JAVA_BIN + " -jar " + os.path.dirname(os.path.abspath(__file__)) + "/utils/siriClient.jar " + \ - self.topo_config.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 + \ - " >" + SiriMsg.CLIENT_LOG + " 2>" + SiriMsg.CLIENT_ERR - print(s) - return s - - def getMsgServerCmd(self): - s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/msg_server.py --sleep " + self.server_sleep + " &>" + SiriMsg.MSG_SERVER_LOG + "&" - print(s) - return s - - def getMsgClientCmd(self): - s = "python3 " + os.path.dirname(os.path.abspath(__file__)) + \ - "/utils/msg_client.py --sleep " + self.client_sleep + " --nb " + self.nb_requests + \ - " --bulk >" + SiriMsg.MSG_CLIENT_LOG + " 2>" + SiriMsg.MSG_CLIENT_ERR + "&" - print(s) - return s + # Should be the combination of Siri and Msg + Siri.prepare(self) + Msg.prepare(self) def clean(self): - super(SiriMsg, self).clean() + # Should be the combination of Siri and Msg + Siri.clean(self) + Msg.clean(self) def run(self): - cmd = self.getSiriServerCmd() + cmd = self.get_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) - cmd = self.getMsgServerCmd() + cmd = self.get_msg_server_cmd() self.topo.command_to(self.topo_config.server, cmd) self.topo.command_to(self.topo_config.client, "sleep 2") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before") - cmd = self.getMsgClientCmd() + cmd = self.get_msg_client_cmd(daemon=True) self.topo.command_to(self.topo_config.client, cmd) - cmd = self.getSiriClientCmd() + cmd = self.get_siri_client_cmd() self.topo.command_to(self.topo_config.client, cmd) self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after") diff --git a/experiences/vlc.py b/experiences/vlc.py index 396dd3a..4246757 100644 --- a/experiences/vlc.py +++ b/experiences/vlc.py @@ -13,7 +13,6 @@ class VLC(Experience): super(VLC, self).__init__(experience_parameter_filename, topo, topo_config) self.load_parameters() self.ping() - super(VLC, self).classic_run() def ping(self): self.topo.command_to(self.topo_config.client, "rm " + \ diff --git a/runner.py b/runner.py index 4ea3f01..145d783 100644 --- a/runner.py +++ b/runner.py @@ -74,9 +74,9 @@ class Runner(object): """ # Well, we need to load twice the experience parameters, is it really annoying? xp = ExperienceParameter(experience_parameter_file).get(ExperienceParameter.XPTYPE) - print(EXPERIENCES) if xp in EXPERIENCES: - EXPERIENCES[xp](experience_parameter_file, self.topo, self.topo_config) + exp = EXPERIENCES[xp](experience_parameter_file, self.topo, self.topo_config) + exp.classic_run() else: raise Exception("Unknown experience {}".format(xp))