diff --git a/core/experiment.py b/core/experiment.py index 6e50d22..6821375 100644 --- a/core/experiment.py +++ b/core/experiment.py @@ -360,8 +360,8 @@ class Experiment(object): "rm {}".format(Experiment.PING_OUTPUT)) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, from_ip, to_ip, n=5): diff --git a/core/topo.py b/core/topo.py index 4cff68f..ce71454 100644 --- a/core/topo.py +++ b/core/topo.py @@ -497,13 +497,6 @@ class TopoConfig(object): for b in self.topo.bottleneck_links: b.configure_changing_bottleneck() - def getMidLeftName(self, i): - "get Middle link, left box name" - pass - - def getMidRightName(self, i): - pass - def configure_interfaces(self): """ Function to inherit to configure the interfaces of the topology diff --git a/experiments/ab.py b/experiments/ab.py index cd4b178..4d85bb0 100644 --- a/experiments/ab.py +++ b/experiments/ab.py @@ -46,7 +46,7 @@ class AB(RandomFileExperiment): def get_ab_client_cmd(self): s = "{} -c {} -t {} http://{}/{} &> {}".format(AB.AB_BIN, self.concurrent_requests, - self.time_limit, self.topo_config.getServerIP(), self.file, AB.CLIENT_LOG) + self.time_limit, self.topo_config.get_server_ip(), self.file, AB.CLIENT_LOG) print(s) return s diff --git a/experiments/ditg.py b/experiments/ditg.py index bbad1c7..a45c679 100644 --- a/experiments/ditg.py +++ b/experiments/ditg.py @@ -56,7 +56,7 @@ class DITG(Experiment): self.topo.command_to(self.topo_config.client, "rm " + DITG.DITG_TEMP_LOG) def getClientCmd(self): - s = DITG.ITGSEND_BIN + " -a " + self.topo_config.getServerIP() + \ + s = DITG.ITGSEND_BIN + " -a " + self.topo_config.get_server_ip() + \ " -T TCP -k " + self.kbytes + " -l " + DITG.DITG_TEMP_LOG if self.constant_packet_size != "0": diff --git a/experiments/epload.py b/experiments/epload.py index 1f7bfc6..1ff6e9e 100644 --- a/experiments/epload.py +++ b/experiments/epload.py @@ -55,14 +55,14 @@ class Epload(Experiment): def getSubHostCmd(self): s = "for f in `ls " + self.test_dir + "/*`; do " + \ - " sed -i 's/@host@/" + self.topo_config.getServerIP() + "/' " + \ + " sed -i 's/@host@/" + self.topo_config.get_server_ip() + "/' " + \ "$f; done" print(s) return s def getSubBackHostCmd(self): s = "for f in `ls " + self.test_dir + "/*`; do " + \ - " sed -i 's/" + self.topo_config.getServerIP() + "/@host@/' " + \ + " sed -i 's/" + self.topo_config.get_server_ip() + "/@host@/' " + \ "$f; done" print(s) return s diff --git a/experiments/http.py b/experiments/http.py index bea71da..9f98b3c 100644 --- a/experiments/http.py +++ b/experiments/http.py @@ -31,7 +31,7 @@ class HTTP(RandomFileExperiment): def getHTTPClientCmd(self): s = "(time {} http://{}/{} --no-check-certificate) &> {}".format(HTTP.WGET_BIN, - self.topo_config.getServerIP(), self.file, HTTP.CLIENT_LOG) + self.topo_config.get_server_ip(), self.file, HTTP.CLIENT_LOG) print(s) return s diff --git a/experiments/https.py b/experiments/https.py index 415f710..a887b6e 100644 --- a/experiments/https.py +++ b/experiments/https.py @@ -31,7 +31,7 @@ class HTTPS(RandomFileExperiment): return s def getHTTPSClientCmd(self): - s = "(time " + HTTPS.WGET_BIN + " https://" + self.topo_config.getServerIP() + \ + s = "(time " + HTTPS.WGET_BIN + " https://" + self.topo_config.get_server_ip() + \ "/" + self.file + " --no-check-certificate) &>" + HTTPS.CLIENT_LOG print(s) return s diff --git a/experiments/iperf.py b/experiments/iperf.py index 1e08538..e342503 100644 --- a/experiments/iperf.py +++ b/experiments/iperf.py @@ -31,8 +31,8 @@ class IPerf(Experiment): IPerf.PING_OUTPUT) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -53,7 +53,7 @@ class IPerf(Experiment): IPerf.SERVER_LOG) def getClientCmd(self): - s = IPerf.IPERF_BIN + " -c " + self.topo_config.getServerIP() + \ + s = IPerf.IPERF_BIN + " -c " + self.topo_config.get_server_ip() + \ " -t " + self.time + " -P " + self.parallel + " &>" + IPerf.IPERF_LOG print(s) return s diff --git a/experiments/msg.py b/experiments/msg.py index 70afb11..878fa74 100644 --- a/experiments/msg.py +++ b/experiments/msg.py @@ -36,8 +36,8 @@ class Msg(Experiment): Msg.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): diff --git a/experiments/nc.py b/experiments/nc.py index ae1506f..d1fb476 100644 --- a/experiments/nc.py +++ b/experiments/nc.py @@ -71,7 +71,7 @@ class NC(Experiment): def getNCClientCmd(self, id): s = NC.NC_BIN + " " + \ " -p " + self.ncClientPort[id] + " " + \ - self.topo_config.getServerIP() + " " + \ + self.topo_config.get_server_ip() + " " + \ self.ncServerPort + " " + \ "&>" + NC.CLIENT_NC_LOG + \ "_" + str(id) + ".log" diff --git a/experiments/ncpv.py b/experiments/ncpv.py index c8551d8..f6ffd6f 100644 --- a/experiments/ncpv.py +++ b/experiments/ncpv.py @@ -52,8 +52,8 @@ class NCPV(NC): NCPV.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -129,7 +129,7 @@ class NCPV(NC): " -q --rate-limit " + self.pvRateLimit + \ " | " + NC.NC_BIN + " " + \ " -p " + self.ncClientPort[id] + " " + \ - self.topo_config.getServerIP() + " " + \ + self.topo_config.get_server_ip() + " " + \ self.ncServerPort + " " + \ "&>" + NCPV.CLIENT_NC_LOG + \ "_" + str(id) + ".log" diff --git a/experiments/netperf.py b/experiments/netperf.py index 52972dd..77f5287 100644 --- a/experiments/netperf.py +++ b/experiments/netperf.py @@ -36,8 +36,8 @@ class Netperf(Experiment): Netperf.PING_OUTPUT) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -60,7 +60,7 @@ class Netperf(Experiment): def get_client_cmd(self): s = "{} -H {} -l {} -t {} -- -r {} &> {}".format(Netperf.NETPERF_BIN, - self.topo_config.getServerIP(), self.testlen, self.testname, self.reqres_size, + self.topo_config.get_server_ip(), self.testlen, self.testname, self.reqres_size, Netperf.NETPERF_LOG) print(s) return s diff --git a/experiments/ping.py b/experiments/ping.py index a332677..b1cfa7f 100644 --- a/experiments/ping.py +++ b/experiments/ping.py @@ -19,8 +19,8 @@ class Ping(Experiment): Ping.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): diff --git a/experiments/quic.py b/experiments/quic.py index 39233f7..d97bcba 100644 --- a/experiments/quic.py +++ b/experiments/quic.py @@ -35,8 +35,8 @@ class QUIC(RandomFileExperiment): QUIC.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -67,7 +67,7 @@ class QUIC(RandomFileExperiment): s = QUIC.GO_BIN + " run " + QUIC.CLIENT_GO_FILE if int(self.multipath) > 0: s += " -m" - s += " https://" + self.topo_config.getServerIP() + ":6121/random &>" + QUIC.CLIENT_LOG + s += " https://" + self.topo_config.get_server_ip() + ":6121/random &>" + QUIC.CLIENT_LOG print(s) return s diff --git a/experiments/quic_siri.py b/experiments/quic_siri.py index 627d04a..273002c 100644 --- a/experiments/quic_siri.py +++ b/experiments/quic_siri.py @@ -34,8 +34,8 @@ class QUICSiri(Experiment): QUICSiri.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -63,7 +63,7 @@ class QUICSiri(Experiment): def get_quic_siri_client_cmd(self): s = "{} run {} -addr {}:8080 -runTime {}s {} &> {}".format(QUICSiri.GO_BIN, - QUICSiri.CLIENT_GO_FILE, self.topo_config.getServerIP(), self.run_time, + QUICSiri.CLIENT_GO_FILE, self.topo_config.get_server_ip(), self.run_time, "-m" if int(self.multipath) > 0 else "", QUICSiri.CLIENT_LOG) print(s) return s diff --git a/experiments/send_file.py b/experiments/send_file.py index ca81272..88209ab 100644 --- a/experiments/send_file.py +++ b/experiments/send_file.py @@ -18,8 +18,8 @@ class SendFile(RandomFileExperiment): SendFile.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -44,7 +44,7 @@ class SendFile(RandomFileExperiment): return s def getSendFileClientCmd(self): - s = SendFile.WGET_BIN + " " + self.topo_config.getServerIP() + " &>" + SendFile.CLIENT_LOG + s = SendFile.WGET_BIN + " " + self.topo_config.get_server_ip() + " &>" + SendFile.CLIENT_LOG print(s) return s diff --git a/experiments/siri.py b/experiments/siri.py index 5d13647..456a712 100644 --- a/experiments/siri.py +++ b/experiments/siri.py @@ -49,8 +49,8 @@ class Siri(Experiment): Siri.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -86,7 +86,7 @@ class Siri(Experiment): def get_siri_client_cmd(self): s = "{} -jar {}/../utils/siriClient.jar {} 8080 {} {} {} {} {} {} {} {} {} {} > {} 2> {}".format( - Siri.JAVA_BIN, os.path.dirname(os.path.abspath(__file__)), self.topo_config.getServerIP(), + Siri.JAVA_BIN, os.path.dirname(os.path.abspath(__file__)), self.topo_config.get_server_ip(), self.run_time, self.query_size, self.response_size, self.delay_query_response, self.min_payload_size, self.max_payload_size, self.interval_time_ms, self.buffer_size, self.burst_size, self.interval_burst_time_ms, Siri.CLIENT_LOG, Siri.CLIENT_ERR) diff --git a/experiments/siri_http.py b/experiments/siri_http.py index 38fbc01..8cad8b8 100644 --- a/experiments/siri_http.py +++ b/experiments/siri_http.py @@ -23,8 +23,8 @@ class SiriHTTP(Siri, RandomFileExperiment): SiriHTTP.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -54,7 +54,7 @@ class SiriHTTP(Siri, RandomFileExperiment): return s def getHTTPClientCmd(self): - s = SiriHTTP.WGET_BIN + " http://" + self.topo_config.getServerIP() + \ + s = SiriHTTP.WGET_BIN + " http://" + self.topo_config.get_server_ip() + \ "/" + self.file + " --no-check-certificate" print(s) return s diff --git a/experiments/vlc.py b/experiments/vlc.py index c78db0b..b2d8912 100644 --- a/experiments/vlc.py +++ b/experiments/vlc.py @@ -31,8 +31,8 @@ class VLC(Experiment): VLC.PING_OUTPUT ) count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT) for i in range(0, self.topo_config.client_interface_count()): - cmd = self.ping_command(self.topo_config.getClientIP(i), - self.topo_config.getServerIP(), n = count) + cmd = self.ping_command(self.topo_config.get_client_ip(i), + self.topo_config.get_server_ip(), n = count) self.topo.command_to(self.topo_config.client, cmd) def ping_command(self, fromIP, toIP, n=5): @@ -62,7 +62,7 @@ class VLC(Experiment): s = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mininet/usr/lib/ && sudo ldconfig && \ {} -I dummy --x11-display :66 --adaptive-logic 3 --no-loop --play-and-exit \ http://{}/{} 2>&1 | grep -E '(Neb|halp|bandwidth|late|Buffering|buffering)' > {} {}".format( - VLC.VLC_BIN, self.topo_config.getServerIP(), self.file, VLC.CLIENT_LOG, + VLC.VLC_BIN, self.topo_config.get_server_ip(), self.file, VLC.CLIENT_LOG, "&" if self.time != "0" else "") print(s) return s diff --git a/topos/ecmp_single_interface.py b/topos/ecmp_single_interface.py index 511d434..40f2105 100644 --- a/topos/ecmp_single_interface.py +++ b/topos/ecmp_single_interface.py @@ -152,14 +152,14 @@ class ECMPSingleInterfaceConfig(TopoConfig): i = i + 1 cmd = self.interface_up_command(self.get_client_interface(0), - self.getClientIP(0), netmask) + self.get_client_ip(0), netmask) self.topo.command_to(self.client, cmd) cmd = self.interface_up_command(self.get_server_interface(), - self.getServerIP(), netmask) + self.get_server_ip(), netmask) self.topo.command_to(self.server, cmd) - def getClientIP(self, interfaceID): + def get_client_ip(self, interfaceID): lSubnet = self.param.get(TopoParameter.LEFT_SUBNET) clientIP = lSubnet + str(interfaceID) + ".1" return clientIP @@ -179,7 +179,7 @@ class ECMPSingleInterfaceConfig(TopoConfig): routerIP = rSubnet + "0." + str(id + 2) return routerIP - def getServerIP(self): + def get_server_ip(self): rSubnet = self.param.get(TopoParameter.RIGHT_SUBNET) serverIP = rSubnet + "0.1" return serverIP diff --git a/topos/multi_interface.py b/topos/multi_interface.py index 7e2bd33..ad20284 100644 --- a/topos/multi_interface.py +++ b/topos/multi_interface.py @@ -1,32 +1,31 @@ from core.topo import Topo, TopoConfig, TopoParameter +import logging + class MultiInterfaceTopo(Topo): NAME = "MultiIf" def __init__(self, topo_builder, parameterFile): + logging.info("Initializing MultiInterfaceTopo...") super(MultiInterfaceTopo, self).__init__(topo_builder, parameterFile) - print("Hello from topo multi if") self.client = self.add_client() self.server = self.add_server() self.router = self.add_router() - print(self.router) - self.switchClient = [] - self.switchServer = [] + self.client_switches = [] + self.server_switches = [] for l in self.topo_parameter.link_characteristics: - self.switchClient.append(self.add_switch1ForLink(l)) - self.add_link(self.client,self.switchClient[-1]) - self.switchServer.append(self.add_switch2ForLink(l)) - self.add_bottleneck_link(self.switchClient[-1], self.switchServer[-1], link_characteristics=l) - self.add_link(self.switchServer[-1],self.router) + self.client_switches.append(self.add_client_side_switch(l)) + self.add_link(self.client,self.client_switches[-1]) + self.server_switches.append(self.add_router_side_switch(l)) + self.add_bottleneck_link(self.client_switches[-1], self.server_switches[-1], link_characteristics=l) + self.add_link(self.server_switches[-1],self.router) self.add_link(self.router, self.server) - def add_switch1ForLink(self, link): - return self.add_switch(MultiInterfaceTopo.SWITCH_NAME_PREFIX + - str(2 * link.id)) + def add_client_side_switch(self, link): + return self.add_switch("{}{}".format(MultiInterfaceTopo.SWITCH_NAME_PREFIX, 2 * link.id)) - def add_switch2ForLink(self, link): - return self.add_switch(MultiInterfaceTopo.SWITCH_NAME_PREFIX + - str(2 * link.id + 1)) + def add_router_side_switch(self, link): + return self.add_switch("{}{}".format(MultiInterfaceTopo.SWITCH_NAME_PREFIX, 2 * link.id + 1)) def __str__(self): s = "Simple multiple interface topolgy \n" @@ -53,31 +52,31 @@ class MultiInterfaceConfig(TopoConfig): def configure_routing(self): i = 0 - for l in self.topo.switchClient: - cmd = self.add_table_route_command(self.getClientIP(i), i) + for l in self.topo.client_switches: + cmd = self.add_table_route_command(self.get_client_ip(i), i) self.topo.command_to(self.client, cmd) cmd = self.add_link_scope_route_command( - self.getClientSubnet(i), + self.get_client_subnet(i), self.get_client_interface(0, i), i) 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.get_router_ip_to_switch(i), i) self.topo.command_to(self.client, cmd) i = i + 1 - cmd = self.add_global_default_route_command(self.getRouterIPSwitch(0), + cmd = self.add_global_default_route_command(self.get_router_ip_to_switch(0), self.get_client_interface(0, 0)) self.topo.command_to(self.client, cmd) - cmd = self.add_simple_default_route_command(self.getRouterIPServer()) + cmd = self.add_simple_default_route_command(self.get_router_ip_to_server()) self.topo.command_to(self.server, cmd) def configure_interfaces(self): + logging.info("Configure interfaces using MultiInterfaceConfig...") super(MultiInterfaceConfig, self).configure_interfaces() - print("Configure interfaces for multi inf") self.client = self.topo.get_client(0) self.server = self.topo.get_server(0) self.router = self.topo.get_router(0) @@ -85,13 +84,13 @@ class MultiInterfaceConfig(TopoConfig): netmask = "255.255.255.0" links = self.topo.get_link_characteristics() - for l in self.topo.switchClient: + for l in self.topo.client_switches: cmd = self.interface_up_command( self.get_client_interface(0, i), - self.getClientIP(i), netmask) + self.get_client_ip(i), netmask) self.topo.command_to(self.client, cmd) 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.get_client_ip(i) + " " + clientIntfMac) if(links[i].backup): cmd = self.interface_backup_command( @@ -101,58 +100,47 @@ class MultiInterfaceConfig(TopoConfig): i = i + 1 i = 0 - for l in self.topo.switchServer: + for l in self.topo.server_switches: cmd = self.interface_up_command( self.get_router_interface_to_switch(i), - self.getRouterIPSwitch(i), netmask) + self.get_router_ip_to_switch(i), netmask) self.topo.command_to(self.router, cmd) 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])) + self.topo.command_to(self.client, "arp -s " + self.get_router_ip_to_switch(i) + " " + routerIntfMac) i = i + 1 cmd = self.interface_up_command(self.getRouterInterfaceServer(), - self.getRouterIPServer(), netmask) + self.get_router_ip_to_server(), netmask) self.topo.command_to(self.router, cmd) 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.get_router_ip_to_server() + " " + routerIntfMac) cmd = self.interface_up_command(self.get_server_interface(0), - self.getServerIP(), netmask) + self.get_server_ip(), netmask) self.topo.command_to(self.server, cmd) 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.get_server_ip() + " " + serverIntfMac) - def getClientIP(self, interfaceID): - lSubnet = self.param.get(TopoParameter.LEFT_SUBNET) - clientIP = lSubnet + str(interfaceID) + ".1" - return clientIP + def get_client_ip(self, interface_index): + return "{}{}.1".format(self.param.get(TopoParameter.LEFT_SUBNET), interface_index) - def getClientSubnet(self, interfaceID): - lSubnet = self.param.get(TopoParameter.LEFT_SUBNET) - clientSubnet = lSubnet + str(interfaceID) + ".0/24" - return clientSubnet + def get_client_subnet(self, interface_index): + return "{}{}.0/24".format(self.param.get(TopoParameter.LEFT_SUBNET), interface_index) - def getRouterIPSwitch(self, interfaceID): - lSubnet = self.param.get(TopoParameter.LEFT_SUBNET) - routerIP = lSubnet + str(interfaceID) + ".2" - return routerIP + def get_router_ip_to_switch(self, switch_index): + return "{}{}.2".format(self.param.get(TopoParameter.LEFT_SUBNET), switch_index) - def getRouterIPServer(self): - rSubnet = self.param.get(TopoParameter.RIGHT_SUBNET) - routerIP = rSubnet + "0.2" - return routerIP + def get_router_ip_to_server(self): + return "{}0.2".format(self.param.get(TopoParameter.RIGHT_SUBNET)) - def getServerIP(self): - rSubnet = self.param.get(TopoParameter.RIGHT_SUBNET) - serverIP = rSubnet + "0.1" - return serverIP + def get_server_ip(self): + return "{}0.1".format(self.param.get(TopoParameter.RIGHT_SUBNET)) def client_interface_count(self): - return len(self.topo.switchClient) + return len(self.topo.client_switches) def getRouterInterfaceServer(self): - return self.get_router_interface_to_switch(len(self.topo.switchServer)) + return self.get_router_interface_to_switch(len(self.topo.server_switches)) def get_client_interface(self, client_index, interface_index): return "{}-eth{}".format(self.topo.get_client_name(client_index), interface_index) @@ -161,22 +149,4 @@ class MultiInterfaceConfig(TopoConfig): return "{}-eth{}".format(self.topo.get_router_name(0), interface_index) def get_server_interface(self, server_index): - return "{}-eth0".format(self.topo.get_server_name(server_index)) - - def getSwitchClientName(self, id): - return Topo.SWITCH_NAME_PREFIX + str(2 * id) - - def getSwitchServerName(self, id): - return Topo.SWITCH_NAME_PREFIX + str(2 * id + 1) - - def getMidLeftName(self, id): - return self.getSwitchClientName(id) - - def getMidRightName(self, id): - return self.getSwitchServerName(id) - - def getMidL2RIncomingInterface(self, id): - return self.getMidLeftName(id) + "-eth1" - - def getMidR2LIncomingInterface(self, id): - return self.getMidRightName(id) + "-eth2" + return "{}-eth0".format(self.topo.get_server_name(server_index)) \ No newline at end of file diff --git a/topos/multi_interface_cong.py b/topos/multi_interface_cong.py index 6ad4e57..d980740 100644 --- a/topos/multi_interface_cong.py +++ b/topos/multi_interface_cong.py @@ -65,7 +65,7 @@ class MultiInterfaceCongConfig(TopoConfig): def configure_routing(self): i = 0 for l in self.topo.switch: - cmd = self.add_table_route_command(self.getClientIP(i), i) + cmd = self.add_table_route_command(self.get_client_ip(i), i) self.topo.command_to(self.client, cmd) # Congestion client @@ -139,10 +139,10 @@ class MultiInterfaceCongConfig(TopoConfig): for l in self.topo.switch: cmd = self.interface_up_command( self.get_client_interface(i), - self.getClientIP(i), netmask) + self.get_client_ip(i), netmask) self.topo.command_to(self.client, cmd) clientIntfMac = self.client.intf(self.get_client_interface(i)).MAC() - self.topo.command_to(self.router, "arp -s " + self.getClientIP(i) + " " + clientIntfMac) + self.topo.command_to(self.router, "arp -s " + self.get_client_ip(i) + " " + clientIntfMac) if(links[i].backup): cmd = self.interface_backup_command( @@ -175,10 +175,10 @@ class MultiInterfaceCongConfig(TopoConfig): self.topo.command_to(self.server, "arp -s " + self.getRouterIPServer() + " " + routerIntfMac) cmd = self.interface_up_command(self.get_server_interface(), - self.getServerIP(), netmask) + self.get_server_ip(), netmask) self.topo.command_to(self.server, cmd) serverIntfMac = self.server.intf(self.get_server_interface()).MAC() - self.topo.command_to(self.router, "arp -s " + self.getServerIP() + " " + serverIntfMac) + self.topo.command_to(self.router, "arp -s " + self.get_server_ip() + " " + serverIntfMac) # Congestion servers i = 0 @@ -196,7 +196,7 @@ class MultiInterfaceCongConfig(TopoConfig): self.topo.command_to(self.router, "arp -s " + self.getCongServerIP(i) + " " + congServerIntfMac) i = i + 1 - def getClientIP(self, interfaceID): + def get_client_ip(self, interfaceID): lSubnet = self.param.get(TopoParameter.LEFT_SUBNET) clientIP = lSubnet + str(interfaceID) + ".1" return clientIP @@ -226,7 +226,7 @@ class MultiInterfaceCongConfig(TopoConfig): routerIP = rSubnet + str(1 + congID) + ".2" return routerIP - def getServerIP(self): + def get_server_ip(self): rSubnet = self.param.get(TopoParameter.RIGHT_SUBNET) serverIP = rSubnet + "0.1" return serverIP diff --git a/topos/two_interface_congestion.py b/topos/two_interface_congestion.py index 56d0cc2..8e14da7 100644 --- a/topos/two_interface_congestion.py +++ b/topos/two_interface_congestion.py @@ -185,7 +185,7 @@ class TwoInterfaceCongestionConfig(TopoConfig): self.configureInterface(self.serverCong, self.router, Topo.SERVER_NAME + "Cong-eth0", "10.1.1.1", netmask) self.configureInterface(self.router, self.serverCong, Topo.ROUTER_NAME + "-eth3", "10.1.1.2", netmask) - def getClientIP(self, interfaceID): + def get_client_ip(self, interfaceID): lSubnet = self.param.get(TopoParameter.LEFT_SUBNET) clientIP = lSubnet + str(interfaceID) + ".1" return clientIP @@ -215,7 +215,7 @@ class TwoInterfaceCongestionConfig(TopoConfig): routerIP = rSubnet + "0.2" return routerIP - def getServerIP(self): + def get_server_ip(self): rSubnet = self.param.get(TopoParameter.RIGHT_SUBNET) serverIP = rSubnet + "0.1" return serverIP