2020-06-25 12:56:47 +00:00
|
|
|
from core.experience import RandomFileExperience, RandomFileParameter, ExperienceParameter
|
2020-06-24 15:18:40 +00:00
|
|
|
from topos.multi_interface_cong import MultiInterfaceCongConfig
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
2020-06-25 14:57:27 +00:00
|
|
|
class QUICParameter(RandomFileExperience):
|
|
|
|
MULTIPATH = "quicMultipath"
|
|
|
|
|
|
|
|
def __init__(self, experience_parameter_filename):
|
|
|
|
super(QUICParameter, self).__init__(experience_parameter_filename)
|
|
|
|
self.default_parameters.update({
|
|
|
|
QUICParameter.MULTIPATH: "0",
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
class QUIC(RandomFileExperience):
|
2020-06-24 15:18:40 +00:00
|
|
|
NAME = "quic"
|
2020-06-25 14:57:27 +00:00
|
|
|
PARAMETER_CLASS = QUICParameter
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
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-25 12:56:47 +00:00
|
|
|
def __init__(self, experience_parameter_filename, topo, topo_config):
|
|
|
|
# Just rely on RandomFileExperience
|
|
|
|
super(QUIC, self).__init__(experience_parameter_filename, topo, topo_config)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def ping(self):
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm " + \
|
2020-06-24 15:18:40 +00:00
|
|
|
QUIC.PING_OUTPUT )
|
2020-06-25 15:01:58 +00:00
|
|
|
count = self.experience_parameter.get(ExperienceParameter.PING_COUNT)
|
2020-06-25 08:53:56 +00:00
|
|
|
for i in range(0, self.topo_config.getClientInterfaceCount()):
|
|
|
|
cmd = self.pingCommand(self.topo_config.getClientIP(i),
|
|
|
|
self.topo_config.getServerIP(), n = count)
|
|
|
|
self.topo.command_to(self.topo_config.client, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
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-25 14:57:27 +00:00
|
|
|
self.multipath = self.experience_parameter.get(QUICParameter.MULTIPATH)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def prepare(self):
|
|
|
|
super(QUIC, self).prepare()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm " + \
|
2020-06-24 15:18:40 +00:00
|
|
|
QUIC.CLIENT_LOG )
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.server, "rm " + \
|
2020-06-24 15:18:40 +00:00
|
|
|
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"
|
2020-06-25 08:53:56 +00:00
|
|
|
s += " https://" + self.topo_config.getServerIP() + ":6121/random &>" + QUIC.CLIENT_LOG
|
2020-06-24 15:18:40 +00:00
|
|
|
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 &"
|
2020-06-24 15:18:40 +00:00
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def getCongClientCmd(self, congID):
|
2020-06-25 08:53:56 +00:00
|
|
|
s = "(time " + QUIC.WGET + " https://" + self.topo_config.getCongServerIP(congID) +\
|
2020-06-24 15:18:40 +00:00
|
|
|
"/" + 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()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.server, "netstat -sn > netstat_server_before")
|
|
|
|
self.topo.command_to(self.topo_config.server, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
if isinstance(self.topo_config, MultiInterfaceCongConfig):
|
2020-06-24 15:18:40 +00:00
|
|
|
i = 0
|
2020-06-25 08:53:56 +00:00
|
|
|
for cs in self.topo_config.cong_servers:
|
2020-06-24 15:18:40 +00:00
|
|
|
cmd = self.getCongServerCmd(i)
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(cs, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
i = i + 1
|
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 2")
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
|
2020-06-24 15:18:40 +00:00
|
|
|
# First run congestion clients, then the main one
|
2020-06-25 08:53:56 +00:00
|
|
|
if isinstance(self.topo_config, MultiInterfaceCongConfig):
|
2020-06-24 15:18:40 +00:00
|
|
|
i = 0
|
2020-06-25 08:53:56 +00:00
|
|
|
for cc in self.topo_config.cong_clients:
|
2020-06-24 15:18:40 +00:00
|
|
|
cmd = self.getCongClientCmd(i)
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(cc, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
cmd = self.getQUICClientCmd()
|
2020-06-25 08:53:56 +00:00
|
|
|
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")
|
2020-06-24 15:18:40 +00:00
|
|
|
# Wait for congestion traffic to end
|
2020-06-25 08:53:56 +00:00
|
|
|
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")
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
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")
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 2")
|
2020-06-24 15:18:40 +00:00
|
|
|
# Need to delete the go-build directory in tmp; could lead to no more space left error
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm -r /tmp/go-build*")
|
2020-06-24 15:18:40 +00:00
|
|
|
# Remove cache data
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "rm cache_*")
|