2020-06-24 15:18:40 +00:00
|
|
|
from core.experience import Experience, ExperienceParameter
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
class QUICSiri(Experience):
|
|
|
|
NAME = "quicsiri"
|
|
|
|
|
|
|
|
GO_BIN = "/usr/local/go/bin/go"
|
|
|
|
SERVER_LOG = "quic_server.log"
|
|
|
|
CLIENT_LOG = "quic_client.log"
|
|
|
|
CLIENT_GO_FILE = "~/go/src/github.com/lucas-clemente/quic-go/example/siri/client/siri.go"
|
|
|
|
SERVER_GO_FILE = "~/go/src/github.com/lucas-clemente/quic-go/example/siri/siri.go"
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
def __init__(self, experience_parameter_filename, topo, topo_config):
|
|
|
|
super(QUICSiri, self).__init__(experience_parameter_filename, topo, topo_config)
|
|
|
|
self.load_parameters()
|
2020-06-24 15:18:40 +00:00
|
|
|
self.ping()
|
|
|
|
|
|
|
|
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
|
|
|
QUICSiri.PING_OUTPUT )
|
2020-06-25 08:53:56 +00:00
|
|
|
count = self.experience_parameter.get(ExperienceParameter.PINGCOUNT)
|
|
|
|
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 + \
|
|
|
|
" >> " + QUICSiri.PING_OUTPUT
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
def load_parameters(self):
|
2020-06-25 08:53:56 +00:00
|
|
|
self.run_time = self.experience_parameter.get(ExperienceParameter.QUICSIRIRUNTIME)
|
|
|
|
self.multipath = self.experience_parameter.get(ExperienceParameter.QUICMULTIPATH)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def prepare(self):
|
|
|
|
super(QUICSiri, 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
|
|
|
QUICSiri.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
|
|
|
QUICSiri.SERVER_LOG )
|
|
|
|
|
|
|
|
def getQUICSiriServerCmd(self):
|
|
|
|
s = QUICSiri.GO_BIN + " run " + QUICSiri.SERVER_GO_FILE
|
|
|
|
s += " -addr 0.0.0.0:8080 &>" + QUICSiri.SERVER_LOG + " &"
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def getQUICSiriClientCmd(self):
|
|
|
|
s = QUICSiri.GO_BIN + " run " + QUICSiri.CLIENT_GO_FILE
|
2020-06-25 08:53:56 +00:00
|
|
|
s += " -addr " + self.topo_config.getServerIP() + ":8080 -runTime " + self.run_time + "s"
|
2020-06-24 15:18:40 +00:00
|
|
|
if int(self.multipath) > 0:
|
|
|
|
s += " -m"
|
|
|
|
s += " &>" + QUICSiri.CLIENT_LOG
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
super(QUICSiri, self).clean()
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
cmd = self.getQUICSiriServerCmd()
|
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
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 2")
|
2020-06-24 15:18:40 +00:00
|
|
|
cmd = self.getQUICSiriClientCmd()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
|
|
|
|
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")
|
|
|
|
self.topo.command_to(self.topo_config.server, "pkill -f " + QUICSiri.SERVER_GO_FILE)
|
|
|
|
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*")
|