mininet-sample/mpExperienceQUIC.py

133 lines
4.8 KiB
Python
Raw Normal View History

2020-06-24 08:36:26 +00:00
from core.experience import Experience, ExperienceParameter
2017-06-12 08:45:40 +00:00
from mpMultiInterfaceCongConfig import MpMultiInterfaceCongConfig
2017-05-05 11:19:03 +00:00
import os
2020-06-24 08:36:26 +00:00
class ExperienceQUIC(Experience):
GO_BIN = "/usr/local/go/bin/go"
2017-06-12 08:45:40 +00:00
WGET = "~/git/wget/src/wget"
2017-05-05 11:19:03 +00:00
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"
2017-05-05 11:19:03 +00:00
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"
def __init__(self, xpParamFile, mpTopo, mpConfig):
2020-06-24 08:36:26 +00:00
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
2017-05-05 11:19:03 +00:00
self.loadParam()
self.ping()
2020-06-24 08:36:26 +00:00
Experience.classicRun(self)
2017-05-05 11:19:03 +00:00
def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
2020-06-24 08:36:26 +00:00
ExperienceQUIC.PING_OUTPUT )
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
2017-05-05 11:19:03 +00:00
for i in range(0, self.mpConfig.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i),
self.mpConfig.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd)
def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
2020-06-24 08:36:26 +00:00
" >> " + ExperienceQUIC.PING_OUTPUT
2017-05-05 11:19:03 +00:00
print(s)
return s
def loadParam(self):
"""
todo : param LD_PRELOAD ??
"""
2020-06-24 08:36:26 +00:00
self.file = self.xpParam.getParam(ExperienceParameter.HTTPSFILE)
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPSRANDOMSIZE)
self.multipath = self.xpParam.getParam(ExperienceParameter.QUICMULTIPATH)
2017-05-05 11:19:03 +00:00
def prepare(self):
2020-06-24 08:36:26 +00:00
Experience.prepare(self)
2017-05-05 11:19:03 +00:00
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
2020-06-24 08:36:26 +00:00
ExperienceQUIC.CLIENT_LOG )
2017-05-05 11:19:03 +00:00
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
2020-06-24 08:36:26 +00:00
ExperienceQUIC.SERVER_LOG )
2017-05-05 11:19:03 +00:00
if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client,
"dd if=/dev/urandom of=random bs=1K count=" + \
self.random_size)
def getQUICServerCmd(self):
2020-06-24 08:36:26 +00:00
s = ExperienceQUIC.GO_BIN + " run " + ExperienceQUIC.SERVER_GO_FILE
s += " -www . -certpath " + ExperienceQUIC.CERTPATH + " &>"
s += ExperienceQUIC.SERVER_LOG + " &"
2017-05-05 11:19:03 +00:00
print(s)
return s
def getQUICClientCmd(self):
2020-06-24 08:36:26 +00:00
s = ExperienceQUIC.GO_BIN + " run " + ExperienceQUIC.CLIENT_GO_FILE
2017-05-05 11:19:03 +00:00
if int(self.multipath) > 0:
s += " -m"
2020-06-24 08:36:26 +00:00
s += " https://" + self.mpConfig.getServerIP() + ":6121/random &>" + ExperienceQUIC.CLIENT_LOG
2017-05-05 11:19:03 +00:00
print(s)
return s
2017-06-12 08:45:40 +00:00
def getCongServerCmd(self, congID):
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
2020-06-24 09:26:56 +00:00
"/utils/https.py &> https_server" + str(congID) + ".log &"
2017-06-12 08:45:40 +00:00
print(s)
return s
def getCongClientCmd(self, congID):
2020-06-24 08:36:26 +00:00
s = "(time " + ExperienceQUIC.WGET + " https://" + self.mpConfig.getCongServerIP(congID) +\
2017-06-12 08:45:40 +00:00
"/" + self.file + " --no-check-certificate --disable-mptcp) &> https_client" + str(congID) + ".log &"
print(s)
return s
2017-05-05 11:19:03 +00:00
def clean(self):
2020-06-24 08:36:26 +00:00
Experience.clean(self)
2017-05-05 11:19:03 +00:00
if self.file == "random":
self.mpTopo.commandTo(self.mpConfig.client, "rm random*")
#todo use cst
#self.mpTopo.commandTo(self.mpConfig.server, "killall netcat")
def run(self):
cmd = self.getQUICServerCmd()
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
self.mpTopo.commandTo(self.mpConfig.server, cmd)
2017-06-12 08:45:40 +00:00
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
i = 0
for cs in self.mpConfig.cong_servers:
cmd = self.getCongServerCmd(i)
self.mpTopo.commandTo(cs, cmd)
i = i + 1
2017-05-05 11:19:03 +00:00
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
2017-06-12 08:45:40 +00:00
2017-05-05 11:19:03 +00:00
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
2017-06-12 08:45:40 +00:00
# First run congestion clients, then the main one
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
i = 0
for cc in self.mpConfig.cong_clients:
cmd = self.getCongClientCmd(i)
self.mpTopo.commandTo(cc, cmd)
i = i + 1
cmd = self.getQUICClientCmd()
2017-05-05 11:19:03 +00:00
self.mpTopo.commandTo(self.mpConfig.client, cmd)
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_after")
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_after")
2017-06-12 08:45:40 +00:00
# Wait for congestion traffic to end
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
for cc in self.mpConfig.cong_clients:
self.mpTopo.commandTo(cc, "while pkill -f wget -0; do sleep 0.5; done")
2020-06-24 08:36:26 +00:00
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f " + ExperienceQUIC.SERVER_GO_FILE)
2017-06-12 08:45:40 +00:00
if isinstance(self.mpConfig, MpMultiInterfaceCongConfig):
for cs in self.mpConfig.cong_servers:
self.mpTopo.commandTo(cs, "pkill -f https.py")
2017-05-05 11:19:03 +00:00
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
# Need to delete the go-build directory in tmp; could lead to no more space left error
self.mpTopo.commandTo(self.mpConfig.client, "rm -r /tmp/go-build*")
# Remove cache data
self.mpTopo.commandTo(self.mpConfig.client, "rm cache_*")