cleanup of iperf experiment

This commit is contained in:
Quentin De Coninck 2020-07-02 13:38:45 +02:00
parent fa2c16c52e
commit 98b4a63704
3 changed files with 20 additions and 50 deletions

View File

@ -55,7 +55,7 @@ class DITG(Experiment):
self.topo.command_to(self.topo_config.server, "rm " + DITG.DITG_SERVER_LOG)
self.topo.command_to(self.topo_config.client, "rm " + DITG.DITG_TEMP_LOG)
def getClientCmd(self):
def get_client_cmd(self):
s = DITG.ITGSEND_BIN + " -a " + self.topo_config.get_server_ip() + \
" -T TCP -k " + self.kbytes + " -l " + DITG.DITG_TEMP_LOG
@ -72,7 +72,7 @@ class DITG(Experiment):
print(s)
return s
def getServerCmd(self):
def get_server_cmd(self):
s = DITG.ITGRECV_BIN + " -l " + DITG.DITG_SERVER_TEMP_LOG + " &"
print(s)
return s
@ -81,11 +81,11 @@ class DITG(Experiment):
super(DITG, 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.server, "pkill -9 -f ITGRecv")
self.topo.command_to(self.topo_config.server, DITG.ITGDEC_BIN + " " + DITG.DITG_SERVER_TEMP_LOG + " &> " + DITG.DITG_SERVER_LOG)

View File

@ -1,6 +1,8 @@
from core.experiment import Experiment, ExperimentParameter
import logging
import os
class IPerfParameter(ExperimentParameter):
TIME = "iperfTime"
PARALLEL = "iperfParallel"
@ -26,52 +28,34 @@ class IPerf(Experiment):
self.load_parameters()
self.ping()
def ping(self):
self.topo.command_to(self.topo_config.client, "rm " + \
IPerf.PING_OUTPUT)
count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT)
for i in range(0, self.topo_config.client_interface_count()):
cmd = self.ping_command(self.topo_config.get_client_ip(i),
self.topo_config.get_server_ip(), n = count)
self.topo.command_to(self.topo_config.client, cmd)
def ping_command(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
" >> " + IPerf.PING_OUTPUT
print(s)
return s
def load_parameters(self):
self.time = self.experiment_parameter.get(IPerfParameter.TIME)
self.parallel = self.experiment_parameter.get(IPerfParameter.PARALLEL)
def prepare(self):
super(IPerf, self).prepare()
self.topo.command_to(self.topo_config.client, "rm " +
IPerf.IPERF_LOG)
self.topo.command_to(self.topo_config.server, "rm " +
IPerf.SERVER_LOG)
self.topo.command_to(self.topo_config.client, "rm {}".format(IPerf.IPERF_LOG))
self.topo.command_to(self.topo_config.server, "rm {}".format(IPerf.SERVER_LOG))
def getClientCmd(self):
s = IPerf.IPERF_BIN + " -c " + self.topo_config.get_server_ip() + \
" -t " + self.time + " -P " + self.parallel + " &>" + IPerf.IPERF_LOG
print(s)
def get_client_cmd(self):
s = "{} -c {} -t {} -P {} &>{}".format(IPerf.IPERF_BIN,
self.topo_config.get_server_ip(), self.time, self.parallel, IPerf.IPERF_LOG)
logging.info(s)
return s
def getServerCmd(self):
s = "sudo " + IPerf.IPERF_BIN + " -s &>" + \
IPerf.SERVER_LOG + "&"
print(s)
def get_server_cmd(self):
s = "{} -s &> {} &".format(IPerf.IPERF_BIN, IPerf.SERVER_LOG)
logging.info(s)
return s
def clean(self):
super(IPerf, 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")

View File

@ -1,4 +1,5 @@
from core.experiment import Experiment, ExperimentParameter
import logging
import os
@ -31,21 +32,6 @@ class Msg(Experiment):
self.load_parameters()
self.ping()
def ping(self):
self.topo.command_to(self.topo_config.client, "rm " + \
Msg.PING_OUTPUT )
count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT)
for i in range(0, self.topo_config.client_interface_count()):
cmd = self.ping_command(self.topo_config.get_client_ip(i),
self.topo_config.get_server_ip(), n = count)
self.topo.command_to(self.topo_config.client, cmd)
def ping_command(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
" >> " + Msg.PING_OUTPUT
print(s)
return s
def load_parameters(self):
self.client_sleep = self.experiment_parameter.get(MsgParameter.CLIENT_SLEEP)
self.server_sleep = self.experiment_parameter.get(MsgParameter.SERVER_SLEEP)
@ -63,14 +49,14 @@ class Msg(Experiment):
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)
logging.info(s)
return s
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)
logging.info(s)
return s
def clean(self):