going in the refactor

This commit is contained in:
Quentin De Coninck 2020-06-29 16:02:17 +02:00
parent ee483308b3
commit 705079494f
8 changed files with 88 additions and 62 deletions

View File

@ -152,10 +152,8 @@ class Experiment(object):
""" """
self.setup_sysctl() self.setup_sysctl()
self.run_userspace_path_manager() # TODO to move elsewhere self.run_userspace_path_manager() # TODO to move elsewhere
self.topo_config.configure_network()
self.change_metric() # TODO to move elsewhere self.change_metric() # TODO to move elsewhere
self.put_priority_on_paths() # TODO to move elsewhere self.put_priority_on_paths() # TODO to move elsewhere
self.disable_tso()
self.run_tcpdump() self.run_tcpdump()
self.run_netem_at() self.run_netem_at()
@ -197,9 +195,6 @@ class Experiment(object):
self.topo.command_to(self.topo_config.router, self.topo.command_to(self.topo_config.router,
self.topo_config.interface_backup_command(self.topo_config.get_router_interface_to_switch(1))) self.topo_config.interface_backup_command(self.topo_config.get_router_interface_to_switch(1)))
def disable_tso(self):
self.topo_config.disable_tso()
def run_userspace_path_manager(self): def run_userspace_path_manager(self):
""" """
Function only meaningful to MPTCP with a specific path manager Function only meaningful to MPTCP with a specific path manager

View File

@ -95,14 +95,10 @@ class LinkCharacteristics(object):
+ ["true &"] + ["true &"]
) )
def clean_policing_cmd(self, ifname):
return "tc qdisc del dev {} ingress ".format(ifname)
def build_policing_cmd(self, ifname): def build_policing_cmd(self, ifname):
""" For some reason, the delete can break everything """ return "tc qdisc del dev {} ingress ; tc qdisc add dev {} handle ffff: ingress ; \
return "tc qdisc add dev {} handle ffff: ingress ; \ tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop".format(
tc filter add dev {} parent ffff: u32 match u32 0 0 police rate {}mbit burst {} drop".format( ifname, ifname, ifname, self.bandwidth, int(self.buffer_size()) * 1.2)
ifname, ifname, self.bandwidth, int(self.buffer_size()) * 1.2)
def build_changing_policing_cmd(self, ifname): def build_changing_policing_cmd(self, ifname):
return "&&".join( return "&&".join(
@ -237,31 +233,28 @@ class BottleneckLink(object):
def __init__(self, topo_builder, topo, link_characteristics): def __init__(self, topo_builder, topo, link_characteristics):
self.link_characteristics = link_characteristics self.link_characteristics = link_characteristics
self.topo = topo self.topo = topo
self.bs0 = topo_builder.add_switch("{}_{}_0".format( self.bs0 = topo_builder.add_switch(self.get_bs_name(0))
BottleneckLink.BOTTLENECK_SWITCH_NAME_PREFIX, self.link_characteristics.id)) self.bs1 = topo_builder.add_switch(self.get_bs_name(1))
self.bs1 = topo_builder.add_switch("{}_{}_1".format( self.bs2 = topo_builder.add_switch(self.get_bs_name(2))
BottleneckLink.BOTTLENECK_SWITCH_NAME_PREFIX, self.link_characteristics.id)) self.bs3 = topo_builder.add_switch(self.get_bs_name(3))
self.bs2 = topo_builder.add_switch("{}_{}_2".format(
BottleneckLink.BOTTLENECK_SWITCH_NAME_PREFIX, self.link_characteristics.id))
self.bs3 = topo_builder.add_switch("{}_{}_3".format(
BottleneckLink.BOTTLENECK_SWITCH_NAME_PREFIX, self.link_characteristics.id))
topo_builder.add_link(self.bs0, self.bs1) topo_builder.add_link(self.bs0, self.bs1)
topo_builder.add_link(self.bs1, self.bs2) topo_builder.add_link(self.bs1, self.bs2)
topo_builder.add_link(self.bs2, self.bs3) topo_builder.add_link(self.bs2, self.bs3)
def configure_bottleneck(self): def get_bs_name(self, index):
return "{}_{}_{}".format(BottleneckLink.BOTTLENECK_SWITCH_NAME_PREFIX, self.link_characteristics.id, index)
def reinit_variables(self):
# Required to retrieve actual nodes # Required to retrieve actual nodes
self.bs0 = self.topo.get_host(self.bs0) self.bs0 = self.topo.get_host(self.get_bs_name(0))
self.bs1 = self.topo.get_host(self.bs1) self.bs1 = self.topo.get_host(self.get_bs_name(1))
self.bs2 = self.topo.get_host(self.bs2) self.bs2 = self.topo.get_host(self.get_bs_name(2))
self.bs3 = self.topo.get_host(self.bs3) self.bs3 = self.topo.get_host(self.get_bs_name(3))
def configure_bottleneck(self):
bs1_interface_names = self.topo.get_interface_names(self.bs1) bs1_interface_names = self.topo.get_interface_names(self.bs1)
bs2_interface_names = self.topo.get_interface_names(self.bs2) bs2_interface_names = self.topo.get_interface_names(self.bs2)
# Flow bs0 -> bs3 # Flow bs0 -> bs3
# Only once
clean_policing_cmd = self.link_characteristics.clean_policing_cmd(bs1_interface_names[0])
logging.info(clean_policing_cmd)
self.topo.command_to(self.bs1, clean_policing_cmd)
policing_cmd = self.link_characteristics.build_policing_cmd(bs1_interface_names[0]) policing_cmd = self.link_characteristics.build_policing_cmd(bs1_interface_names[0])
logging.info(policing_cmd) logging.info(policing_cmd)
self.topo.command_to(self.bs1, policing_cmd) self.topo.command_to(self.bs1, policing_cmd)
@ -339,10 +332,9 @@ class Topo(object):
MININET_BUILDER = "mininet" MININET_BUILDER = "mininet"
TOPO_ATTR = "topoType" TOPO_ATTR = "topoType"
SWITCH_NAME_PREFIX = "s" SWITCH_NAME_PREFIX = "s"
ROUTER_NAME_PREFIX = "r" CLIENT_NAME_PREFIX = "Client"
CLIENT_NAME = "Client" SERVER_NAME_PREFIX = "Server"
SERVER_NAME = "Server" ROUTER_NAME_PREFIX = "Router"
ROUTER_NAME = "Router"
CMD_LOG_FILENAME = "command.log" CMD_LOG_FILENAME = "command.log"
def __init__(self, topo_builder, topo_parameter): def __init__(self, topo_builder, topo_parameter):
@ -355,6 +347,30 @@ class Topo(object):
self.servers = [] self.servers = []
self.bottleneck_links = [] self.bottleneck_links = []
def get_client_name(self, index):
return "{}_{}".format(Topo.CLIENT_NAME_PREFIX, index)
def get_router_name(self, index):
return "{}_{}".format(Topo.ROUTER_NAME_PREFIX, index)
def get_server_name(self, index):
return "{}_{}".format(Topo.SERVER_NAME_PREFIX, index)
def add_client(self):
client = self.add_host(self.get_client_name(self.client_count()))
self.clients.append(client)
return client
def add_router(self):
router = self.add_host(self.get_router_name(self.router_count()))
self.routers.append(router)
return router
def add_server(self):
server = self.add_host(self.get_server_name(self.server_count()))
self.servers.append(server)
return server
def get_link_characteristics(self): def get_link_characteristics(self):
return self.topo_parameter.link_characteristics return self.topo_parameter.link_characteristics
@ -418,6 +434,14 @@ class Topo(object):
self.topo_builder.add_link(bottleneck_link.get_right(), to_b) self.topo_builder.add_link(bottleneck_link.get_right(), to_b)
return bottleneck_link return bottleneck_link
def reinit_variables(self):
# Because we create nodes before starting mininet
self.clients = [self.get_host(self.get_client_name(i)) for i in range(len(self.clients))]
self.routers = [self.get_host(self.get_router_name(i)) for i in range(len(self.routers))]
self.servers = [self.get_host(self.get_server_name(i)) for i in range(len(self.servers))]
for b in self.bottleneck_links:
b.reinit_variables()
def get_cli(self): def get_cli(self):
self.topo_builder.get_cli() self.topo_builder.get_cli()
@ -443,6 +467,8 @@ class TopoConfig(object):
self.param = param self.param = param
def configure_network(self): def configure_network(self):
self.topo.reinit_variables()
self.disable_tso()
logging.debug("Configure network in TopoConfig") logging.debug("Configure network in TopoConfig")
self.configure_interfaces() self.configure_interfaces()
self.configure_routing() self.configure_routing()
@ -480,7 +506,7 @@ class TopoConfig(object):
def configure_interfaces(self): def configure_interfaces(self):
""" """
Function to override to configure the interfaces of the topology Function to inherit to configure the interfaces of the topology
""" """
for b in self.topo.bottleneck_links: for b in self.topo.bottleneck_links:
b.configure_bottleneck() b.configure_bottleneck()
@ -493,13 +519,13 @@ class TopoConfig(object):
def client_interface_count(self): def client_interface_count(self):
""" """
Return the number of client's interfaces Return the number of client's interfaces, without lo
""" """
raise NotImplementedError() raise NotImplementedError()
def get_client_interface(self, index): def get_client_interface(self, client_index, interface_index):
""" """
Return the client's interface with index `index` Return the interface with index `interface_index` of the client with index `client_index`
""" """
raise NotImplementedError() raise NotImplementedError()

View File

@ -56,8 +56,7 @@ class MininetBuilder(Topo):
def get_interface_names(self, who): def get_interface_names(self, who):
# NOTE: bs1.intfNames()[0] is lo... # NOTE: bs1.intfNames()[0] is lo...
host = self.get_host(who) return [i for i in who.intfNames() if i != "lo"]
return [i for i in host.intfNames() if i != "lo"]
def add_host(self, host): def add_host(self, host):
return self.addHost(host) return self.addHost(host)

View File

@ -22,8 +22,8 @@ class Runner(object):
def __init__(self, builder_type, topo_parameter_file, experiment_parameter_file): def __init__(self, builder_type, topo_parameter_file, experiment_parameter_file):
self.topo_parameter = TopoParameter(topo_parameter_file) self.topo_parameter = TopoParameter(topo_parameter_file)
self.set_builder(builder_type) self.set_builder(builder_type)
self.set_topo() self.apply_topo()
self.set_topo_config() self.apply_topo_config()
self.start_topo() self.start_topo()
self.run_experiment(experiment_parameter_file) self.run_experiment(experiment_parameter_file)
self.stop_topo() self.stop_topo()
@ -37,7 +37,7 @@ class Runner(object):
else: else:
raise Exception("I can not find the builder {}".format(builder_type)) raise Exception("I can not find the builder {}".format(builder_type))
def set_topo(self): def apply_topo(self):
""" """
Matches the name of the topo and find the corresponding Topo class. Matches the name of the topo and find the corresponding Topo class.
""" """
@ -49,7 +49,7 @@ class Runner(object):
logging.info("Using topo {}".format(self.topo)) logging.info("Using topo {}".format(self.topo))
def set_topo_config(self): def apply_topo_config(self):
""" """
Match the name of the topo and find the corresponding TopoConfig class. Match the name of the topo and find the corresponding TopoConfig class.
""" """

View File

@ -5,6 +5,7 @@ class ECMPSingleInterfaceTopo(Topo):
NAME = "ECMPLike" NAME = "ECMPLike"
def __init__(self, topo_builder, parameterFile): def __init__(self, topo_builder, parameterFile):
raise Exception("Broken")
super(ECMPSingleInterfaceTopo, self).__init__(topo_builder, parameterFile) super(ECMPSingleInterfaceTopo, self).__init__(topo_builder, parameterFile)
print("Hello ECMP topo") print("Hello ECMP topo")

View File

@ -6,9 +6,10 @@ class MultiInterfaceTopo(Topo):
def __init__(self, topo_builder, parameterFile): def __init__(self, topo_builder, parameterFile):
super(MultiInterfaceTopo, self).__init__(topo_builder, parameterFile) super(MultiInterfaceTopo, self).__init__(topo_builder, parameterFile)
print("Hello from topo multi if") print("Hello from topo multi if")
self.client = self.add_host(Topo.CLIENT_NAME) self.client = self.add_client()
self.server = self.add_host(Topo.SERVER_NAME) self.server = self.add_server()
self.router = self.add_host(Topo.ROUTER_NAME) self.router = self.add_router()
print(self.router)
self.switchClient = [] self.switchClient = []
self.switchServer = [] self.switchServer = []
for l in self.topo_parameter.link_characteristics: for l in self.topo_parameter.link_characteristics:
@ -58,7 +59,7 @@ class MultiInterfaceConfig(TopoConfig):
cmd = self.add_link_scope_route_command( cmd = self.add_link_scope_route_command(
self.getClientSubnet(i), self.getClientSubnet(i),
self.get_client_interface(i), i) self.get_client_interface(0, i), i)
self.topo.command_to(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.add_table_default_route_command(self.getRouterIPSwitch(i), cmd = self.add_table_default_route_command(self.getRouterIPSwitch(i),
@ -67,7 +68,7 @@ class MultiInterfaceConfig(TopoConfig):
i = i + 1 i = i + 1
cmd = self.add_global_default_route_command(self.getRouterIPSwitch(0), cmd = self.add_global_default_route_command(self.getRouterIPSwitch(0),
self.get_client_interface(0)) self.get_client_interface(0, 0))
self.topo.command_to(self.client, cmd) self.topo.command_to(self.client, cmd)
cmd = self.add_simple_default_route_command(self.getRouterIPServer()) cmd = self.add_simple_default_route_command(self.getRouterIPServer())
@ -75,24 +76,26 @@ class MultiInterfaceConfig(TopoConfig):
def configure_interfaces(self): def configure_interfaces(self):
super(MultiInterfaceConfig, self).configure_interfaces()
print("Configure interfaces for multi inf") print("Configure interfaces for multi inf")
self.client = self.topo.get_host(Topo.CLIENT_NAME) self.client = self.topo.get_client(0)
self.server = self.topo.get_host(Topo.SERVER_NAME) self.server = self.topo.get_server(0)
self.router = self.topo.get_host(Topo.ROUTER_NAME) self.router = self.topo.get_router(0)
i = 0 i = 0
netmask = "255.255.255.0" netmask = "255.255.255.0"
links = self.topo.get_link_characteristics() links = self.topo.get_link_characteristics()
for l in self.topo.switchClient: for l in self.topo.switchClient:
cmd = self.interface_up_command( cmd = self.interface_up_command(
self.get_client_interface(i), self.get_client_interface(0, i),
self.getClientIP(i), netmask) self.getClientIP(i), netmask)
self.topo.command_to(self.client, cmd) self.topo.command_to(self.client, cmd)
clientIntfMac = self.client.intf(self.get_client_interface(i)).MAC() clientIntfMac = self.client.intf(self.get_client_interface(0, i)).MAC()
self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac) self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac)
if(links[i].backup): if(links[i].backup):
cmd = self.interface_backup_command( cmd = self.interface_backup_command(
self.get_client_interface(i)) self.get_client_interface(0, i))
self.topo.command_to(self.client, cmd) self.topo.command_to(self.client, cmd)
i = i + 1 i = i + 1
@ -114,10 +117,10 @@ class MultiInterfaceConfig(TopoConfig):
routerIntfMac = self.router.intf(self.getRouterInterfaceServer()).MAC() routerIntfMac = self.router.intf(self.getRouterInterfaceServer()).MAC()
self.topo.command_to(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac) self.topo.command_to(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac)
cmd = self.interface_up_command(self.get_server_interface(), cmd = self.interface_up_command(self.get_server_interface(0),
self.getServerIP(), netmask) self.getServerIP(), netmask)
self.topo.command_to(self.server, cmd) self.topo.command_to(self.server, cmd)
serverIntfMac = self.server.intf(self.get_server_interface()).MAC() serverIntfMac = self.server.intf(self.get_server_interface(0)).MAC()
self.topo.command_to(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac) self.topo.command_to(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac)
def getClientIP(self, interfaceID): def getClientIP(self, interfaceID):
@ -151,14 +154,14 @@ class MultiInterfaceConfig(TopoConfig):
def getRouterInterfaceServer(self): def getRouterInterfaceServer(self):
return self.get_router_interface_to_switch(len(self.topo.switchServer)) return self.get_router_interface_to_switch(len(self.topo.switchServer))
def get_client_interface(self, interfaceID): def get_client_interface(self, client_index, interface_index):
return Topo.CLIENT_NAME + "-eth" + str(interfaceID) return "{}-eth{}".format(self.topo.get_client_name(client_index), interface_index)
def get_router_interface_to_switch(self, interfaceID): def get_router_interface_to_switch(self, interface_index):
return Topo.ROUTER_NAME + "-eth" + str(interfaceID) return "{}-eth{}".format(self.topo.get_router_name(0), interface_index)
def get_server_interface(self): def get_server_interface(self, server_index):
return Topo.SERVER_NAME + "-eth0" return "{}-eth0".format(self.topo.get_server_name(server_index))
def getSwitchClientName(self, id): def getSwitchClientName(self, id):
return Topo.SWITCH_NAME_PREFIX + str(2 * id) return Topo.SWITCH_NAME_PREFIX + str(2 * id)

View File

@ -8,6 +8,7 @@ class MultiInterfaceCongTopo(Topo):
congServerName = "CSer" congServerName = "CSer"
def __init__(self, topo_builder, parameterFile): def __init__(self, topo_builder, parameterFile):
raise Exception("Broken")
super(MultiInterfaceCongTopo, self).__init__(topo_builder, parameterFile) super(MultiInterfaceCongTopo, self).__init__(topo_builder, parameterFile)
print("Hello from topo multi if") print("Hello from topo multi if")
self.client = self.add_host(Topo.CLIENT_NAME) self.client = self.add_host(Topo.CLIENT_NAME)

View File

@ -5,6 +5,7 @@ class TwoInterfaceCongestionTopo(Topo):
NAME = "twoIfCong" NAME = "twoIfCong"
def __init__(self, topo_builder, parameterFile): def __init__(self, topo_builder, parameterFile):
raise Exception("Broken")
super(TwoInterfaceCongestionTopo, self).__init__(topo_builder, parameterFile) super(TwoInterfaceCongestionTopo, self).__init__(topo_builder, parameterFile)
print("Hello from topo two ifs cong") print("Hello from topo two ifs cong")