from core.experiment import ExperimentParameter, RandomFileExperiment, RandomFileParameter import os import threading class BASICQUIC(RandomFileExperiment): NAME = "basicquic" SERVER_LOG = "echo-quic_server.log" CLIENT_LOG = "echo-quic_client.log" WGET_BIN = "wget" PING_OUTPUT = "ping.log" def __init__(self, experiment_parameter_filename, topo, topo_config): # Just rely on RandomFileExperiment super(BASICQUIC, self).__init__( experiment_parameter_filename, topo, topo_config) def load_parameters(self): # Just rely on RandomFileExperiment super(BASICQUIC, self).load_parameters() def prepare(self): super(BASICQUIC, self).prepare() self.topo.command_to(self.topo_config.client, "rm " + BASICQUIC.CLIENT_LOG) self.topo.command_to(self.topo_config.server, "rm " + BASICQUIC.SERVER_LOG) def getHTTPSServerCmd(self): s = "{}/../utils/basicquic-server -bind ':8443' & > {}".format( os.path.dirname(os.path.abspath(__file__)), BASICQUIC.SERVER_LOG) # s = "/home/mininet/pugit/sample/minitopo/utils/server & > {}".format( # BASICQUIC.SERVER_LOG) print(s) return s def getHTTPSClientCmd(self): # s = "ping -c 3 -I {} {} > ping-result".format( # "10.0.0.", self.topo_config.get_client_ip(1)) s = "{}/../utils/basicquic-client -keylog router.log -insecure https://{}:8443/demo/tiles".format( os.path.dirname(os.path.abspath(__file__)), self.topo_config.get_server_ip(0)) # s = "ping -c 5 {} > client-ping.log".format(self.topo_config.get_server_ip(0)) # s = "/home/mininet/pugit/sample/minitopo/utils/echo-client {} & > {}".format( # self.topo_config.get_server_ip(0), # BASICQUIC.CLIENT_LOG, # ) print(s) return s def clean(self): super(BASICQUIC, self).clean() def startServer(self): self.topo.command_to(self.topo_config.server, cmd) def run(self): cmd = self.getHTTPSServerCmd() self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before") self.topo.command_to(self.topo_config.router, "netstat -sn > netstat_router_before") self.topo.command_to(self.topo_config.server, cmd) print("Waiting for the server to run") self.topo.command_to(self.topo_config.client, "sleep 2") # for i in range(1, self.topo.client_count()): # self.topo.command_to(self.topo_config.clients[i], "sleep 2") cmd = self.getHTTPSClientCmd() # for c in self.topo_config.clients: # self.topo.command_to(c, cmd) def runner(i): self.topo.command_to(self.topo_config.clients[i], cmd) print('client {} start'.format(i)) for i in range(1, self.topo.client_count()): t = threading.Thread(target=runner, args=(i,)) t.start() # self.topo_config.configure_client(i) self.topo.command_to(self.topo_config.client, "sleep 20") self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after") self.topo.command_to(self.topo_config.router, "netstat -sn > netstat_router_after") self.topo.command_to(self.topo_config.server, "pkill -f basicquic-server") self.topo.command_to(self.topo_config.client, "sleep 2")