mininet-sample/experiments/quic.py

131 lines
5.3 KiB
Python
Raw Normal View History

2020-06-26 06:52:56 +00:00
from core.experiment import RandomFileExperiment, RandomFileParameter, ExperimentParameter
from topos.multi_interface_cong import MultiInterfaceCongConfig
import os
2020-06-26 06:52:56 +00:00
class QUICParameter(RandomFileExperiment):
MULTIPATH = "quicMultipath"
2020-06-26 06:52:56 +00:00
def __init__(self, experiment_parameter_filename):
super(QUICParameter, self).__init__(experiment_parameter_filename)
self.default_parameters.update({
QUICParameter.MULTIPATH: "0",
})
2020-06-26 06:52:56 +00:00
class QUIC(RandomFileExperiment):
NAME = "quic"
PARAMETER_CLASS = QUICParameter
GO_BIN = "/usr/local/go/bin/go"
WGET = "~/git/wget/src/wget"
SERVER_LOG = "quic_server.log"
CLIENT_LOG = "quic_client.log"
CLIENT_GO_FILE = "~/go/src/github.com/lucas-clemente/quic-go/example/client_benchmarker_cached/main.go"
SERVER_GO_FILE = "~/go/src/github.com/lucas-clemente/quic-go/example/main.go"
CERTPATH = "~/go/src/github.com/lucas-clemente/quic-go/example/"
PING_OUTPUT = "ping.log"
2020-06-26 06:52:56 +00:00
def __init__(self, experiment_parameter_filename, topo, topo_config):
# Just rely on RandomFileExperiment
super(QUIC, self).__init__(experiment_parameter_filename, topo, topo_config)
def ping(self):
self.topo.command_to(self.topo_config.client, "rm " + \
QUIC.PING_OUTPUT )
2020-06-26 06:52:56 +00:00
count = self.experiment_parameter.get(ExperimentParameter.PING_COUNT)
2020-06-26 09:17:00 +00:00
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)
def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
" >> " + QUIC.PING_OUTPUT
print(s)
return s
2020-06-25 12:56:47 +00:00
def load_parameters(self):
super(QUIC, self).load_parameters()
2020-06-26 06:52:56 +00:00
self.multipath = self.experiment_parameter.get(QUICParameter.MULTIPATH)
def prepare(self):
super(QUIC, self).prepare()
self.topo.command_to(self.topo_config.client, "rm " + \
QUIC.CLIENT_LOG )
self.topo.command_to(self.topo_config.server, "rm " + \
QUIC.SERVER_LOG )
def getQUICServerCmd(self):
s = QUIC.GO_BIN + " run " + QUIC.SERVER_GO_FILE
s += " -www . -certpath " + QUIC.CERTPATH + " &>"
s += QUIC.SERVER_LOG + " &"
print(s)
return s
def getQUICClientCmd(self):
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
print(s)
return s
def getCongServerCmd(self, congID):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
2020-06-25 12:56:47 +00:00
"/../utils/https_server.py &> https_server" + str(congID) + ".log &"
print(s)
return s
def getCongClientCmd(self, congID):
s = "(time " + QUIC.WGET + " https://" + self.topo_config.getCongServerIP(congID) +\
"/" + self.file + " --no-check-certificate --disable-mptcp) &> https_client" + str(congID) + ".log &"
print(s)
return s
def clean(self):
super(QUIC, self).clean()
def run(self):
cmd = self.getQUICServerCmd()
self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
self.topo.command_to(self.topo_config.server, cmd)
if isinstance(self.topo_config, MultiInterfaceCongConfig):
i = 0
for cs in self.topo_config.cong_servers:
cmd = self.getCongServerCmd(i)
self.topo.command_to(cs, cmd)
i = i + 1
self.topo.command_to(self.topo_config.client, "sleep 2")
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
# First run congestion clients, then the main one
if isinstance(self.topo_config, MultiInterfaceCongConfig):
i = 0
for cc in self.topo_config.cong_clients:
cmd = self.getCongClientCmd(i)
self.topo.command_to(cc, cmd)
i = i + 1
cmd = self.getQUICClientCmd()
self.topo.command_to(self.topo_config.client, cmd)
self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_after")
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_after")
# Wait for congestion traffic to end
if isinstance(self.topo_config, MultiInterfaceCongConfig):
for cc in self.topo_config.cong_clients:
self.topo.command_to(cc, "while pkill -f wget -0; do sleep 0.5; done")
self.topo.command_to(self.topo_config.server, "pkill -f " + QUIC.SERVER_GO_FILE)
if isinstance(self.topo_config, MultiInterfaceCongConfig):
for cs in self.topo_config.cong_servers:
self.topo.command_to(cs, "pkill -f https_server.py")
self.topo.command_to(self.topo_config.client, "sleep 2")
# Need to delete the go-build directory in tmp; could lead to no more space left error
self.topo.command_to(self.topo_config.client, "rm -r /tmp/go-build*")
# Remove cache data
self.topo.command_to(self.topo_config.client, "rm cache_*")