mininet-sample/experiments/basicquic.py

97 lines
3.6 KiB
Python
Raw Normal View History

2022-02-16 04:26:18 +00:00
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):
2022-02-17 11:46:07 +00:00
s = "{}/../utils/basicquic-server -bind ':8443' & > {}".format(
2022-02-17 07:40:28 +00:00
os.path.dirname(os.path.abspath(__file__)), BASICQUIC.SERVER_LOG)
# s = "/home/mininet/pugit/sample/minitopo/utils/server & > {}".format(
# BASICQUIC.SERVER_LOG)
2022-02-16 04:26:18 +00:00
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))
2022-02-17 11:46:07 +00:00
s = "{}/../utils/basicquic-client -keylog router.log -insecure https://{}:8443/demo/tiles".format(
2022-02-17 07:40:28 +00:00
os.path.dirname(os.path.abspath(__file__)),
self.topo_config.get_server_ip(0))
2022-02-16 04:26:18 +00:00
2022-02-17 11:46:07 +00:00
# s = "ping -c 5 {} > client-ping.log".format(self.topo_config.get_server_ip(0))
2022-02-17 07:40:28 +00:00
# s = "/home/mininet/pugit/sample/minitopo/utils/echo-client {} & > {}".format(
# self.topo_config.get_server_ip(0),
# BASICQUIC.CLIENT_LOG,
# )
2022-02-16 04:26:18 +00:00
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)
2022-02-17 07:40:28 +00:00
def runner(i):
2022-02-16 04:26:18 +00:00
self.topo.command_to(self.topo_config.clients[i], cmd)
2022-02-17 07:40:28 +00:00
print('client {} start'.format(i))
for i in range(1, self.topo.client_count()):
t = threading.Thread(target=runner, args=(i,))
t.start()
2022-02-16 04:26:18 +00:00
# self.topo_config.configure_client(i)
2022-02-17 07:40:28 +00:00
self.topo.command_to(self.topo_config.client, "sleep 20")
2022-02-16 04:26:18 +00:00
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,
2022-02-17 07:40:28 +00:00
"pkill -f basicquic-server")
2022-02-16 04:26:18 +00:00
self.topo.command_to(self.topo_config.client, "sleep 2")