fully refactor experiment.py file

This commit is contained in:
Quentin De Coninck 2020-06-26 11:17:00 +02:00
parent 36fed8cc71
commit bdba7f3bf1
22 changed files with 292 additions and 233 deletions

View File

@ -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")

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):