diff --git a/core/experiment.py b/core/experiment.py index 6fa6ac8..2da0ee2 100644 --- a/core/experiment.py +++ b/core/experiment.py @@ -1,9 +1,16 @@ from .parameter import Parameter -from topos.multi_interface import MultiInterfaceTopo + +import logging class ExperimentParameter(Parameter): """ - Handler for experiment parameters stored in configuration files + Handler for experiment parameters stored in configuration files. + The following parameters are common (and thus usable) by all experiments. + If you want to add experiement-specific parameters, you should extend this + class. + + Attribute: + default_parameters Default values for the parameters """ RMEM = "rmem" WMEM = "wmem" @@ -20,18 +27,17 @@ class ExperimentParameter(Parameter): USERPMS_ARGS = "upms_args" CLIENT_PCAP = "clientPcap" SERVER_PCAP = "serverPcap" - SNAPLEN_PCAP = "snaplenPcap" + SNAPLEN_PCAP = "snaplen_pcap" XP_TYPE = "xpType" PING_COUNT = "pingCount" - PRIO_PATH0 = "prioPath0" - PRIO_PATH1 = "prioPath1" - BACKUP_PATH0 = "backupPath0" - BACKUP_PATH1 = "backupPath1" + PRIO_PATH_0 = "priority_path_0" + PRIO_PATH_1 = "priority_path_1" + BACKUP_PATH_0 = "backup_path_0" + BACKUP_PATH_1 = "backup_path_1" EXPIRATION = "expiration" BUFFER_AUTOTUNING = "bufferAutotuning" METRIC = "metric" - # Global sysctl keys SYSCTL_KEY = { RMEM: "net.ipv4.tcp_rmem", @@ -76,10 +82,10 @@ class ExperimentParameter(Parameter): SNAPLEN_PCAP: "65535", # Default snapping value of tcpdump XP_TYPE: "none", PING_COUNT: "5", - PRIO_PATH0: "0", - PRIO_PATH1: "0", - BACKUP_PATH0: "0", - BACKUP_PATH1: "0", + PRIO_PATH_0: "0", + PRIO_PATH_1: "0", + BACKUP_PATH_0: "0", + BACKUP_PATH_1: "0", } def __init__(self, parameter_filename): @@ -87,6 +93,11 @@ class ExperimentParameter(Parameter): self.default_parameters = ExperimentParameter.DEFAULT_PARAMETERS def get(self, key): + """ + Get the value of the parameter with key `key`. + If not defined by the configuration file, return the default value. + Raise Exception if the parameter has no default value and is absent. + """ val = super(ExperimentParameter, self).get(key) if val is None: if key in self.default_parameters: @@ -117,6 +128,8 @@ class Experiment(object): """ PARAMETER_CLASS = ExperimentParameter + IP_BIN = "ip" + def __init__(self, experiment_parameter_filename, topo, topo_config): """ Instantiation of this base class only load the experiment parameter @@ -157,8 +170,8 @@ class Experiment(object): self.change_metric() # TODO to move elsewhere self.put_priority_on_paths() # TODO to move elsewhere self.disable_tso() - self.runTcpDump() - self.runNetemAt() + self.run_tcpdump() + self.run_netem_at() def change_metric(self): """ @@ -173,235 +186,192 @@ class Experiment(object): """ Function only meaningful for MPTCP """ - # Only meaningful if mpTopo is instance of MultiInterfaceTopo - if isinstance(self.topo, MultiInterfaceTopo): - prioPath0 = self.experiment_parameter.get(ExperimentParameter.PRIO_PATH0) - prioPath1 = self.experiment_parameter.get(ExperimentParameter.PRIO_PATH1) - if not prioPath0 == prioPath1: - self.topo.command_to(self.topo_config.client, "/home/mininet/iproute/ip/ip link set dev " + - self.topo_config.getClientInterface(0) + " priority " + str(prioPath0)) - self.topo.command_to(self.topo_config.router, "/home/mininet/iproute/ip/ip link set dev " + - self.topo_config.getRouterInterfaceSwitch(0) + " priority " + - str(prioPath0)) - self.topo.command_to(self.topo_config.client, "/home/mininet/iproute/ip/ip link set dev " + - self.topo_config.getClientInterface(1) + " priority " + str(prioPath1)) - self.topo.command_to(self.topo_config.router, "/home/mininet/iproute/ip/ip link set dev " + - self.topo_config.getRouterInterfaceSwitch(1) + " priority " + - str(prioPath1)) + priority_path_0 = self.experiment_parameter.get(ExperimentParameter.PRIO_PATH_0) + priority_path_1 = self.experiment_parameter.get(ExperimentParameter.PRIO_PATH_1) + if not priority_path_0 == priority_path_1: + self.topo.command_to(self.topo_config.client, "{} link set dev {} priority {}".format( + Experiment.IP_BIN, self.topo_config.get_client_interface(0), priority_path_0)) + self.topo.command_to(self.topo_config.router, "{} link set dev {} priority {}".format( + Experiment.IP_BIN, self.topo_config.get_router_interface_to_switch(0), priority_path_0)) + self.topo.command_to(self.topo_config.client, "{} link set dev {} priority {}".format( + Experiment.IP_BIN, self.topo_config.get_client_interface(1), priority_path_1)) + self.topo.command_to(self.topo_config.router, "{} link set dev {} priority {}".format( + Experiment.IP_BIN, self.topo_config.get_router_interface_to_switch(1), priority_path_1)) - backupPath0 = self.experiment_parameter.get(ExperimentParameter.BACKUP_PATH0) - if int(backupPath0) > 0: - self.topo.command_to(self.topo_config.client, self.topo_config.interfaceBUPCommand(self.topo_config.getClientInterface(0))) - self.topo.command_to(self.topo_config.router, self.topo_config.interfaceBUPCommand(self.topo_config.getRouterInterfaceSwitch(0))) - backupPath1 = self.experiment_parameter.get(ExperimentParameter.BACKUP_PATH1) - if int(backupPath1) > 0: - self.topo.command_to(self.topo_config.client, self.topo_config.interfaceBUPCommand(self.topo_config.getClientInterface(1))) - self.topo.command_to(self.topo_config.router, self.topo_config.interfaceBUPCommand(self.topo_config.getRouterInterfaceSwitch(1))) + backup_path_0 = self.experiment_parameter.get(ExperimentParameter.BACKUP_PATH_0) + if int(backup_path_0) > 0: + self.topo.command_to(self.topo_config.client, + self.topo_config.interface_backup_command(self.topo_config.get_client_interface(0))) + self.topo.command_to(self.topo_config.router, + self.topo_config.interface_backup_command(self.topo_config.get_router_interface_to_switch(0))) + backup_path_1 = self.experiment_parameter.get(ExperimentParameter.BACKUP_PATH_1) + if int(backup_path_1) > 0: + self.topo.command_to(self.topo_config.client, + self.topo_config.interface_backup_command(self.topo_config.get_client_interface(1))) + self.topo.command_to(self.topo_config.router, + self.topo_config.interface_backup_command(self.topo_config.get_router_interface_to_switch(1))) def disable_tso(self): - links = self.topo.getLinkCharacteristics() - i = 0 - for l in links: - lname = self.topo_config.getMidLeftName(i) - rname = self.topo_config.getMidRightName(i) - lbox = self.topo.get_host(lname) - lif = self.topo_config.getMidL2RInterface(i) - rif = self.topo_config.getMidR2LInterface(i) - rbox = self.topo.get_host(rname) - print(str(lname) + " " + str(lif)) - print(str(rname) + " " + str(rif)) - print("boxes " + str(lbox) + " " + str(rbox)) - cmd = "ethtool -K " + lif + " tso off" - print(cmd) - self.topo.command_to(lbox, cmd) - cmd = "ethtool -K " + rif + " tso off" - print(cmd) - self.topo.command_to(rbox, cmd) - i = i + 1 - - # And for the server - cmd = "ethtool -K " + self.topo_config.getServerInterface() + " tso off" - print(cmd) - self.topo.command_to(self.topo_config.server, cmd) - - cmd = "ethtool -K " + self.topo_config.getRouterInterfaceSwitch(self.topo_config.getClientInterfaceCount()) + " tso off" - print(cmd) - self.topo.command_to(self.topo_config.router, cmd) + self.topo_config.disable_tso() def run_userspace_path_manager(self): + """ + Function only meaningful to MPTCP with a specific path manager + """ if self.experiment_parameter.get(ExperimentParameter.KERNELPMC) != "netlink": - print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !") + logging.warning("Client: unable to change the userspace pm if the kernel pm is not netlink") else: upmc = self.experiment_parameter.get(ExperimentParameter.USERPMC) upmca = self.experiment_parameter.get(ExperimentParameter.USERPMC_ARGS) - self.topo.command_to(self.topo_config.client, upmc + \ - " " + upmca + " &>upmc.log &") + self.topo.command_to(self.topo_config.client, "{} {} &>{} &".format( + upmc, upmca, "upmc.log")) if self.experiment_parameter.get(ExperimentParameter.KERNELPMS) != "netlink": - print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !") + logging.warning("Server: unable to change the userspace pm if the kernel pm is not netlink") else: upms = self.experiment_parameter.get(ExperimentParameter.USERPMS) upmsa = self.experiment_parameter.get(ExperimentParameter.USERPMS_ARGS) - self.topo.command_to(self.topo_config.server, upms + \ - " " + upmsa + " &>upms.log &") + self.topo.command_to(self.topo_config.server, "{} {} &>{} &".format( + upms, upmsa, "upms.log")) - def cleanUserspacePM(self): + def clean_userspace_path_manager(self): if self.experiment_parameter.get(ExperimentParameter.KERNELPMC) != "netlink": - print("Client : Error, I can't change the userspace pm if the kernel pm is not netlink !") + logging.warning("Client: unable to change the userspace pm if the kernel pm is not netlink") else: upmc = self.experiment_parameter.get(ExperimentParameter.USERPMC) - self.topo.command_to(self.topo_config.client, "killall " + upmc) + self.topo.command_to(self.topo_config.client, "killall {}".format(upmc)) if self.experiment_parameter.get(ExperimentParameter.KERNELPMS) != "netlink": - print("Server : Error, I can't change the userspace pm if the kernel pm is not netlink !") + logging.warning("Server: unable to change the userspace pm if the kernel pm is not netlink") else: upms = self.experiment_parameter.get(ExperimentParameter.USERPMS) - self.topo.command_to(self.topo_config.server, "killall " + upms) + self.topo.command_to(self.topo_config.client, "killall {}".format(upms)) - def runNetemAt(self): - if not self.topo.changeNetem == "yes": - print("I don't need to change netem") - return - print("Will change netem config on the fly") - links = self.topo.getLinkCharacteristics() - i = 0 - for l in links: - lname = self.topo_config.getMidLeftName(i) - rname = self.topo_config.getMidRightName(i) - lbox = self.topo.get_host(lname) - lif = self.topo_config.getMidL2RInterface(i) - rif = self.topo_config.getMidR2LInterface(i) - rbox = self.topo.get_host(rname) - print(str(lname) + " " + str(lif)) - print(str(rname) + " " + str(rif)) - print("boxes " + str(lbox) + " " + str(rbox)) - cmd = l.buildBwCmd(lif) - print(cmd) - self.topo.command_to(lbox, cmd) - cmd = l.buildBwCmd(rif) - print(cmd) - self.topo.command_to(rbox, cmd) - ilif = self.topo_config.getMidL2RIncomingInterface(i) - irif = self.topo_config.getMidR2LIncomingInterface(i) - cmd = l.buildPolicingCmd(ilif) - print(cmd) - self.topo.command_to(lbox, cmd) - cmd = l.buildPolicingCmd(irif) - print(cmd) - self.topo.command_to(rbox, cmd) - cmd = l.buildNetemCmd(irif) - print(cmd) - self.topo.command_to(rbox, cmd) - cmd = l.buildNetemCmd(ilif) - print(cmd) - self.topo.command_to(lbox, cmd) - - i = i + 1 + def run_netem_at(self): + self.topo_config.run_netem_at() def run(self): - pass + """ + Perform the experiment + + This function MUST be overriden by child classes + """ + raise NotImplementedError("Trying to run Experiment") def clean(self): - self.topo.command_to(self.topo_config.client, - "killall tcpdump") - self.topo.command_to(self.topo_config.server, - "killall tcpdump") - self.backUpSysctl() - self.cleanUserspacePM() - pass + """ + Clean the environment where the experiment took place. + Typically, when you inherit from this class, you want to extend this + method, while still calling this parent function. + """ + self.topo.command_to(self.topo_config.client, "killall tcpdump") + self.topo.command_to(self.topo_config.server, "killall tcpdump") + self.restore_sysctl() + self.clean_userspace_path_manager() def setup_sysctl(self): + """ + Record the current sysctls of the host and write the experiment ones + """ self.save_sysctl() self.write_sysctl() def save_sysctl(self): - self.sysctlBUP = {} - self._save_sysctl(ExperimentParameter.SYSCTL_KEY, self.sysctlBUP) - self.sysctlBUPC = {} - self._save_sysctl(ExperimentParameter.SYSCTL_KEY_CLIENT, self.sysctlBUPC, - ns = True, who = self.topo_config.client) - self.sysctlBUPS = {} - self._save_sysctl(ExperimentParameter.SYSCTL_KEY_SERVER, self.sysctlBUPS, - ns = True, who = self.topo_config.server) + """ + Record the current sysctls + """ + self.sysctl_to_restore = {} + self._save_sysctl(ExperimentParameter.SYSCTL_KEY, self.sysctl_to_restore) + self.client_sysctl_to_restore = {} + self._save_sysctl(ExperimentParameter.SYSCTL_KEY_CLIENT, self.client_sysctl_to_restore, + ns=True, who=self.topo_config.client) + self.server_sysctl_to_restore = {} + self._save_sysctl(ExperimentParameter.SYSCTL_KEY_SERVER, self.server_sysctl_to_restore, + ns=True, who=self.topo_config.server) - def _save_sysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): - for k in sysctlDic: - SYSCTL_KEY = sysctlDic[k] - cmd = self.cmdReadSysctl(SYSCTL_KEY) + def _save_sysctl(self, sysctl_dict, sysctl_to_restore, ns=False, who=None): + for k in sysctl_dict: + sysctl_key = sysctl_dict[k] + cmd = self.read_sysctl_cmd(sysctl_key) if not ns: val = self.topo.command_global(cmd) else: val = self.topo.command_to(who, cmd) if val == "Error": - print("oooops can't get sysctl " + SYSCTL_KEY) + logging.error("unable to get sysctl {}".format(sysctl_key)) else: # For Python3 compatibility if type(val) is bytes: val = val.decode() - sysctlBUP[k] = val.split(" ",2)[2][:-1] + sysctl_to_restore[k] = val.split(" ", 2)[2][:-1] - - def cmdReadSysctl(self, key): - s = "sysctl " + key - return s + def read_sysctl_cmd(self, key): + """ + Return a bash command to read the sysctl key `key` + """ + return "sysctl {}".format(key) def cmd_write_sysctl(self, key, value): - s = self.cmdReadSysctl(key) - s = s + "=\"" + str(value) + "\"" - return s + """ + Return a bash command to write the sysctl key `key`with value `value` + """ + return '{}="{}"'.format(self.read_sysctl_cmd(key), value) def write_sysctl(self): - self._write_sysctl(ExperimentParameter.SYSCTL_KEY, self.sysctlBUP) - self._write_sysctl(ExperimentParameter.SYSCTL_KEY_CLIENT, self.sysctlBUPC, - ns = True, who = self.topo_config.client) - self._write_sysctl(ExperimentParameter.SYSCTL_KEY_SERVER, self.sysctlBUPS, - ns = True, who = self.topo_config.server) + """ + Write the experiment sysctls + """ + self._write_sysctl(ExperimentParameter.SYSCTL_KEY, self.sysctl_to_restore) + self._write_sysctl(ExperimentParameter.SYSCTL_KEY_CLIENT, self.client_sysctl_to_restore, + ns=True, who=self.topo_config.client) + self._write_sysctl(ExperimentParameter.SYSCTL_KEY_SERVER, self.server_sysctl_to_restore, + ns=True, who=self.topo_config.server) - def _write_sysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): - for k in sysctlBUP: - SYSCTL_KEY = sysctlDic[k] - sysctlValue = self.experiment_parameter.get(k) - cmd = self.cmd_write_sysctl(SYSCTL_KEY,sysctlValue) + def _write_sysctl(self, sysctl_dict, sysctl_to_restore, ns = False, who = None): + for k in sysctl_to_restore: + sysctl_key = sysctl_dict[k] + sysctl_value = self.experiment_parameter.get(k) + cmd = self.cmd_write_sysctl(sysctl_key, sysctl_value) if not ns: val = self.topo.command_global(cmd) else: val = self.topo.command_to(who, cmd) if val == "Error": - print("oooops can't set sysctl " + SYSCTL_KEY) + logging.error("unable to set sysctl {}".format(sysctl_key)) + def restore_sysctl(self): + """ + Restore back the sysctls that were present before running the experiment + """ + self._restore_sysctl(ExperimentParameter.SYSCTL_KEY, self.sysctl_to_restore) + self._restore_sysctl(ExperimentParameter.SYSCTL_KEY_CLIENT, self.client_sysctl_to_restore, + ns=True, who=self.topo_config.client) + self._restore_sysctl(ExperimentParameter.SYSCTL_KEY_SERVER, self.server_sysctl_to_restore, + ns=True, who=self.topo_config.server) - def backUpSysctl(self): - self._backUpSysctl(ExperimentParameter.SYSCTL_KEY, self.sysctlBUP) - self._backUpSysctl(ExperimentParameter.SYSCTL_KEY_CLIENT, self.sysctlBUPC, - ns = True, who = self.topo_config.client) - self._backUpSysctl(ExperimentParameter.SYSCTL_KEY_SERVER, self.sysctlBUPS, - ns = True, who = self.topo_config.server) - - - def _backUpSysctl(self, sysctlDic, sysctlBUP, ns = False, who = None): - for k in sysctlBUP: - SYSCTL_KEY = sysctlDic[k] - sysctlValue = sysctlBUP[k] - cmd = self.cmd_write_sysctl(SYSCTL_KEY,sysctlValue) + def _restore_sysctl(self, sysctl_dict, sysctl_to_restore, ns = False, who = None): + for k in sysctl_to_restore: + sysctl_key = sysctl_dict[k] + sysctl_value = sysctl_to_restore[k] + cmd = self.cmd_write_sysctl(sysctl_key, sysctl_value) if not ns: val = self.topo.command_global(cmd) else: val = self.topo.command_to(who, cmd) if val == "Error": - print("oooops can't set sysctl " + SYSCTL_KEY) + logging.error("unable to set sysctl {}".format(sysctl_key)) - - def runTcpDump(self): - #todo : replace filename by cst - cpcap = self.experiment_parameter.get(ExperimentParameter.CLIENT_PCAP) - spcap = self.experiment_parameter.get(ExperimentParameter.SERVER_PCAP) - snaplenpcap = self.experiment_parameter.get(ExperimentParameter.SNAPLEN_PCAP) - if cpcap == "yes" : + def run_tcpdump(self): + client_pcap = self.experiment_parameter.get(ExperimentParameter.CLIENT_PCAP) + server_pcap = self.experiment_parameter.get(ExperimentParameter.SERVER_PCAP) + snaplen_pcap = self.experiment_parameter.get(ExperimentParameter.SNAPLEN_PCAP) + if client_pcap == "yes": self.topo.command_to(self.topo_config.client, - "tcpdump -i any -s " + snaplenpcap + " -w client.pcap &") - if spcap == "yes" : + "tcpdump -i any -s {} -w client.pcap &".format(snaplen_pcap)) + if server_pcap == "yes": self.topo.command_to(self.topo_config.server, - "tcpdump -i any -s " + snaplenpcap + " -w server.pcap &") - if spcap == "yes" or cpcap == "yes": + "tcpdump -i any -s {} -w server.pcap &".format(snaplen_pcap)) + if server_pcap == "yes" or client_pcap == "yes": + logging.info("Activating tcpdump, waiting for it to run") self.topo.command_to(self.topo_config.client,"sleep 5") diff --git a/core/topo.py b/core/topo.py index f0cf21b..794c70e 100644 --- a/core/topo.py +++ b/core/topo.py @@ -1,5 +1,6 @@ from .parameter import Parameter +import logging import math @@ -281,6 +282,79 @@ class TopoConfig(object): self.configureInterfaces() self.configureRoute() + def disable_tso(self): + """ + Disable TSO on all interfaces + """ + links = self.topo.getLinkCharacteristics() + for i, l in enumerate(links): + lname = self.getMidLeftName(i) + rname = self.getMidRightName(i) + lbox = self.topo.get_host(lname) + lif = self.getMidL2RInterface(i) + rif = self.getMidR2LInterface(i) + rbox = self.topo.get_host(rname) + print(str(lname) + " " + str(lif)) + print(str(rname) + " " + str(rif)) + print("boxes " + str(lbox) + " " + str(rbox)) + cmd = "ethtool -K " + lif + " tso off" + print(cmd) + self.topo.command_to(lbox, cmd) + cmd = "ethtool -K " + rif + " tso off" + print(cmd) + self.topo.command_to(rbox, cmd) + + # And for the server + cmd = "ethtool -K " + self.getServerInterface() + " tso off" + print(cmd) + self.topo.command_to(self.server, cmd) + + cmd = "ethtool -K " + self.get_router_interface_to_switch(self.client_interface_count()) + " tso off" + print(cmd) + self.topo.command_to(self.router, cmd) + + def run_netem_at(self): + """ + Prepare netem commands to be run after some delay + """ + if not self.topo.changeNetem == "yes": + # Just rely on defaults of TCLink + logging.debug("No need to change netem") + return + + logging.info("Will change netem config on the fly") + links = self.topo.getLinkCharacteristics() + for i, l in enumerate(links): + lname = self.getMidLeftName(i) + rname = self.getMidRightName(i) + lbox = self.topo.get_host(lname) + lif = self.getMidL2RInterface(i) + rif = self.getMidR2LInterface(i) + rbox = self.topo.get_host(rname) + print(str(lname) + " " + str(lif)) + print(str(rname) + " " + str(rif)) + print("boxes " + str(lbox) + " " + str(rbox)) + cmd = l.buildBwCmd(lif) + print(cmd) + self.topo.command_to(lbox, cmd) + cmd = l.buildBwCmd(rif) + print(cmd) + self.topo.command_to(rbox, cmd) + ilif = self.getMidL2RIncomingInterface(i) + irif = self.getMidR2LIncomingInterface(i) + cmd = l.buildPolicingCmd(ilif) + print(cmd) + self.topo.command_to(lbox, cmd) + cmd = l.buildPolicingCmd(irif) + print(cmd) + self.topo.command_to(rbox, cmd) + cmd = l.buildNetemCmd(irif) + print(cmd) + self.topo.command_to(rbox, cmd) + cmd = l.buildNetemCmd(ilif) + print(cmd) + self.topo.command_to(lbox, cmd) + def getMidL2RInterface(self, id): "get Middle link, left to right interface" pass @@ -298,10 +372,25 @@ class TopoConfig(object): def configureInterfaces(self): pass - def getClientInterfaceCount(self): - raise Exception("To be implemented") + def client_interface_count(self): + """ + Return the number of client's interfaces + """ + raise NotImplementedError() - def interfaceBUPCommand(self, interfaceName): + def get_client_interface(self, index): + """ + Return the client's interface with index `index` + """ + raise NotImplementedError() + + def get_router_interface_to_switch(self, index): + """ + Return the router's interface to switch with index `index` + """ + raise NotImplementedError() + + def interface_backup_command(self, interfaceName): s = "/home/mininet/git/iproute-mptcp/ip/ip link set dev " + interfaceName + " multipath backup " print(s) return s diff --git a/experiments/ab.py b/experiments/ab.py index 5b906e2..b520537 100644 --- a/experiments/ab.py +++ b/experiments/ab.py @@ -30,7 +30,7 @@ class AB(RandomFileExperiment): self.topo.command_to(self.topo_config.client, "rm " + AB.PING_OUTPUT) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/ditg.py b/experiments/ditg.py index 26ff340..f2fec7e 100644 --- a/experiments/ditg.py +++ b/experiments/ditg.py @@ -45,7 +45,7 @@ class DITG(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ Experiment.PING_OUTPUT) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/epload.py b/experiments/epload.py index 16bdef7..b99f63e 100644 --- a/experiments/epload.py +++ b/experiments/epload.py @@ -30,7 +30,7 @@ class Epload(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ Epload.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/http.py b/experiments/http.py index 30a20c4..ba443c1 100644 --- a/experiments/http.py +++ b/experiments/http.py @@ -17,7 +17,7 @@ class HTTP(RandomFileExperiment): self.topo.command_to(self.topo_config.client, "rm " + \ HTTP.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/https.py b/experiments/https.py index ce496ca..c552430 100644 --- a/experiments/https.py +++ b/experiments/https.py @@ -17,7 +17,7 @@ class HTTPS(RandomFileExperiment): self.topo.command_to(self.topo_config.client, "rm " + \ HTTPS.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/iperf.py b/experiments/iperf.py index 250b140..3969247 100644 --- a/experiments/iperf.py +++ b/experiments/iperf.py @@ -30,7 +30,7 @@ class IPerf(Experiment): 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.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/msg.py b/experiments/msg.py index ccf5b86..dd2bbeb 100644 --- a/experiments/msg.py +++ b/experiments/msg.py @@ -35,7 +35,7 @@ class Msg(Experiment): 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.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/ncpv.py b/experiments/ncpv.py index e777f6f..ebb2673 100644 --- a/experiments/ncpv.py +++ b/experiments/ncpv.py @@ -51,7 +51,7 @@ class NCPV(NC): self.topo.command_to(self.topo_config.client, "rm " + \ NCPV.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/netperf.py b/experiments/netperf.py index 7c2d8bd..277294a 100644 --- a/experiments/netperf.py +++ b/experiments/netperf.py @@ -35,7 +35,7 @@ class Netperf(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ Netperf.PING_OUTPUT) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/ping.py b/experiments/ping.py index 31a17dc..853894c 100644 --- a/experiments/ping.py +++ b/experiments/ping.py @@ -18,7 +18,7 @@ class Ping(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ Ping.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/quic.py b/experiments/quic.py index fc4c768..5dbb7d5 100644 --- a/experiments/quic.py +++ b/experiments/quic.py @@ -34,7 +34,7 @@ class QUIC(RandomFileExperiment): self.topo.command_to(self.topo_config.client, "rm " + \ QUIC.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/quic_siri.py b/experiments/quic_siri.py index 10d2642..871ddcc 100644 --- a/experiments/quic_siri.py +++ b/experiments/quic_siri.py @@ -33,7 +33,7 @@ class QUICSiri(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ QUICSiri.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/send_file.py b/experiments/send_file.py index 6909992..fffae71 100644 --- a/experiments/send_file.py +++ b/experiments/send_file.py @@ -17,7 +17,7 @@ class SendFile(RandomFileExperiment): self.topo.command_to(self.topo_config.client, "rm " + \ SendFile.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/siri.py b/experiments/siri.py index 26e37e0..9b99a69 100644 --- a/experiments/siri.py +++ b/experiments/siri.py @@ -48,7 +48,7 @@ class Siri(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ Siri.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/siri_http.py b/experiments/siri_http.py index 84d304e..ddc10d1 100644 --- a/experiments/siri_http.py +++ b/experiments/siri_http.py @@ -22,7 +22,7 @@ class SiriHTTP(Siri, RandomFileExperiment): self.topo.command_to(self.topo_config.client, "rm " + \ SiriHTTP.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/experiments/vlc.py b/experiments/vlc.py index 0d42b9b..49162ca 100644 --- a/experiments/vlc.py +++ b/experiments/vlc.py @@ -30,7 +30,7 @@ class VLC(Experiment): self.topo.command_to(self.topo_config.client, "rm " + \ VLC.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) - for i in range(0, self.topo_config.getClientInterfaceCount()): + for i in range(0, self.topo_config.client_interface_count()): cmd = self.pingCommand(self.topo_config.getClientIP(i), self.topo_config.getServerIP(), n = count) self.topo.command_to(self.topo_config.client, cmd) diff --git a/topos/ecmp_single_interface.py b/topos/ecmp_single_interface.py index c742249..36959e5 100644 --- a/topos/ecmp_single_interface.py +++ b/topos/ecmp_single_interface.py @@ -150,7 +150,7 @@ class ECMPSingleInterfaceConfig(TopoConfig): i = i + 1 - cmd = self.interfaceUpCommand(self.getClientInterface(0), + cmd = self.interfaceUpCommand(self.get_client_interface(0), self.getClientIP(0), netmask) self.topo.command_to(self.client, cmd) @@ -183,7 +183,7 @@ class ECMPSingleInterfaceConfig(TopoConfig): serverIP = rSubnet + "0.1" return serverIP - def getClientInterfaceCount(self): + def client_interface_count(self): return 1 def getRouterInterfaceLSwitch(self, id): @@ -192,7 +192,7 @@ class ECMPSingleInterfaceConfig(TopoConfig): def getRouterInterfaceRSwitch(self, id): return Topo.routerNamePrefix + str(id) + "-eth1" - def getClientInterface(self, interfaceID): + def get_client_interface(self, interfaceID): return Topo.clientName + "-eth" + str(interfaceID) def getServerInterface(self): diff --git a/topos/multi_interface.py b/topos/multi_interface.py index fd0c1f7..8d99861 100644 --- a/topos/multi_interface.py +++ b/topos/multi_interface.py @@ -58,7 +58,7 @@ class MultiInterfaceConfig(TopoConfig): cmd = self.addRouteScopeLinkCommand( self.getClientSubnet(i), - self.getClientInterface(i), i) + self.get_client_interface(i), i) self.topo.command_to(self.client, cmd) cmd = self.addRouteDefaultCommand(self.getRouterIPSwitch(i), @@ -67,7 +67,7 @@ class MultiInterfaceConfig(TopoConfig): i = i + 1 cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0), - self.getClientInterface(0)) + self.get_client_interface(0)) self.topo.command_to(self.client, cmd) cmd = self.addRouteDefaultSimple(self.getRouterIPServer()) @@ -84,15 +84,15 @@ class MultiInterfaceConfig(TopoConfig): links = self.topo.getLinkCharacteristics() for l in self.topo.switchClient: cmd = self.interfaceUpCommand( - self.getClientInterface(i), + self.get_client_interface(i), self.getClientIP(i), netmask) self.topo.command_to(self.client, cmd) - clientIntfMac = self.client.intf(self.getClientInterface(i)).MAC() + clientIntfMac = self.client.intf(self.get_client_interface(i)).MAC() self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac) if(links[i].back_up): - cmd = self.interfaceBUPCommand( - self.getClientInterface(i)) + cmd = self.interface_backup_command( + self.get_client_interface(i)) self.topo.command_to(self.client, cmd) i = i + 1 @@ -100,10 +100,10 @@ class MultiInterfaceConfig(TopoConfig): i = 0 for l in self.topo.switchServer: cmd = self.interfaceUpCommand( - self.getRouterInterfaceSwitch(i), + self.get_router_interface_to_switch(i), self.getRouterIPSwitch(i), netmask) self.topo.command_to(self.router, cmd) - routerIntfMac = self.router.intf(self.getRouterInterfaceSwitch(i)).MAC() + routerIntfMac = self.router.intf(self.get_router_interface_to_switch(i)).MAC() self.topo.command_to(self.client, "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac) print(str(links[i])) i = i + 1 @@ -145,16 +145,16 @@ class MultiInterfaceConfig(TopoConfig): serverIP = rSubnet + "0.1" return serverIP - def getClientInterfaceCount(self): + def client_interface_count(self): return len(self.topo.switchClient) def getRouterInterfaceServer(self): - return self.getRouterInterfaceSwitch(len(self.topo.switchServer)) + return self.get_router_interface_to_switch(len(self.topo.switchServer)) - def getClientInterface(self, interfaceID): + def get_client_interface(self, interfaceID): return Topo.clientName + "-eth" + str(interfaceID) - def getRouterInterfaceSwitch(self, interfaceID): + def get_router_interface_to_switch(self, interfaceID): return Topo.routerName + "-eth" + str(interfaceID) def getServerInterface(self): diff --git a/topos/multi_interface_cong.py b/topos/multi_interface_cong.py index f6e4c1f..4a73e69 100644 --- a/topos/multi_interface_cong.py +++ b/topos/multi_interface_cong.py @@ -73,7 +73,7 @@ class MultiInterfaceCongConfig(TopoConfig): cmd = self.addRouteScopeLinkCommand( self.getClientSubnet(i), - self.getClientInterface(i), i) + self.get_client_interface(i), i) self.topo.command_to(self.client, cmd) # Congestion client @@ -96,7 +96,7 @@ class MultiInterfaceCongConfig(TopoConfig): i = i + 1 cmd = self.addRouteDefaultGlobalCommand(self.getRouterIPSwitch(0), - self.getClientInterface(0)) + self.get_client_interface(0)) self.topo.command_to(self.client, cmd) # Congestion Client @@ -137,15 +137,15 @@ class MultiInterfaceCongConfig(TopoConfig): links = self.topo.getLinkCharacteristics() for l in self.topo.switch: cmd = self.interfaceUpCommand( - self.getClientInterface(i), + self.get_client_interface(i), self.getClientIP(i), netmask) self.topo.command_to(self.client, cmd) - clientIntfMac = self.client.intf(self.getClientInterface(i)).MAC() + clientIntfMac = self.client.intf(self.get_client_interface(i)).MAC() self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac) if(links[i].back_up): - cmd = self.interfaceBUPCommand( - self.getClientInterface(i)) + cmd = self.interface_backup_command( + self.get_client_interface(i)) self.topo.command_to(self.client, cmd) # Congestion client @@ -157,10 +157,10 @@ class MultiInterfaceCongConfig(TopoConfig): self.topo.command_to(self.router, "arp -s " + self.getCongClientIP(i) + " " + congClientIntfMac) cmd = self.interfaceUpCommand( - self.getRouterInterfaceSwitch(i), + self.get_router_interface_to_switch(i), self.getRouterIPSwitch(i), netmask) self.topo.command_to(self.router, cmd) - routerIntfMac = self.router.intf(self.getRouterInterfaceSwitch(i)).MAC() + routerIntfMac = self.router.intf(self.get_router_interface_to_switch(i)).MAC() self.topo.command_to(self.client, "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac) # Don't forget the congestion client self.topo.command_to(self.cong_clients[i], "arp -s " + self.getRouterIPSwitch(i) + " " + routerIntfMac) @@ -235,22 +235,22 @@ class MultiInterfaceCongConfig(TopoConfig): serverIP = rSubnet + str(1 + congID) + ".1" return serverIP - def getClientInterfaceCount(self): + def client_interface_count(self): return len(self.topo.switch) def getRouterInterfaceServer(self): - return self.getRouterInterfaceSwitch(len(self.topo.switch)) + return self.get_router_interface_to_switch(len(self.topo.switch)) def getRouterInterfaceCongServer(self, congID): - return self.getRouterInterfaceSwitch(len(self.topo.switch) + 1 + congID) + return self.get_router_interface_to_switch(len(self.topo.switch) + 1 + congID) - def getClientInterface(self, interfaceID): + def get_client_interface(self, interfaceID): return Topo.clientName + "-eth" + str(interfaceID) def getCongClientInterface(self, interfaceID): return MultiInterfaceCongConfig.congClientName + str(interfaceID) + "-eth0" - def getRouterInterfaceSwitch(self, interfaceID): + def get_router_interface_to_switch(self, interfaceID): return Topo.routerName + "-eth" + str(interfaceID) def getServerInterface(self): diff --git a/topos/two_interface_congestion.py b/topos/two_interface_congestion.py index f9f26a2..59bbbaf 100644 --- a/topos/two_interface_congestion.py +++ b/topos/two_interface_congestion.py @@ -151,7 +151,7 @@ class TwoInterfaceCongestionConfig(TopoConfig): self.configureInterface(self.client, self.router, Topo.clientName + "-eth0", "10.0.0.1", netmask) if(links[0].back_up): - cmd = self.interfaceBUPCommand(Topo.clientName + "-eth0") + cmd = self.interface_backup_command(Topo.clientName + "-eth0") self.topo.command_to(self.client, cmd) self.configureInterface(self.router, self.client, Topo.routerName + "-eth0", "10.0.0.2", netmask) @@ -161,7 +161,7 @@ class TwoInterfaceCongestionConfig(TopoConfig): self.configureInterface(self.client, self.routerCong, Topo.clientName + "-eth1", "10.0.1.1", netmask) if(links[1].back_up): - cmd = self.interfaceBUPCommand(Topo.clientName + "-eth1") + cmd = self.interface_backup_command(Topo.clientName + "-eth1") self.topo.command_to(self.client, cmd) self.configureInterface(self.routerCong, self.client, Topo.routerName + "Cong-eth0", "10.0.1.2", netmask) @@ -219,16 +219,16 @@ class TwoInterfaceCongestionConfig(TopoConfig): serverIP = rSubnet + "0.1" return serverIP - def getClientInterfaceCount(self): + def client_interface_count(self): return len(self.topo.switch) def getRouterInterfaceServer(self): - return self.getRouterInterfaceSwitch(len(self.topo.switch)) + return self.get_router_interface_to_switch(len(self.topo.switch)) - def getClientInterface(self, interfaceID): + def get_client_interface(self, interfaceID): return Topo.clientName + "-eth" + str(interfaceID) - def getRouterInterfaceSwitch(self, interfaceID): + def get_router_interface_to_switch(self, interfaceID): return Topo.routerName + "-eth" + str(interfaceID) def getServerInterface(self):