continuing the code refactoring
This commit is contained in:
parent
bcd306b21d
commit
b5c9306284
5
config/https/topo
Normal file
5
config/https/topo
Normal file
@ -0,0 +1,5 @@
|
||||
leftSubnet:10.0.
|
||||
rightSubnet:10.1.
|
||||
path_0:100,20,4
|
||||
path_1:1,20,4
|
||||
topoType:MultiIf
|
5
config/https/xp
Normal file
5
config/https/xp
Normal file
@ -0,0 +1,5 @@
|
||||
xpType:https
|
||||
clientPcap:yes
|
||||
kpms:fullmesh
|
||||
kpmc:fullmesh
|
||||
rmem:300000 300000 300000
|
@ -2,20 +2,25 @@ from .parameter import ExperienceParameter
|
||||
from topos.multi_interface import MultiInterfaceTopo
|
||||
|
||||
class Experience(object):
|
||||
PING = "ping"
|
||||
"""
|
||||
Base class to instantiate an experience to perform.
|
||||
|
||||
This class is not instantiable as it. You must define a child class with the
|
||||
`NAME` attribute.
|
||||
"""
|
||||
|
||||
NCPV = "ncpv"
|
||||
NC = "nc"
|
||||
NONE = "none"
|
||||
|
||||
HTTPS = "https"
|
||||
HTTP = "http"
|
||||
EPLOAD = "epload"
|
||||
NETPERF = "netperf"
|
||||
AB = "ab"
|
||||
|
||||
SIRI = "siri"
|
||||
SENDFILE = "sendfile"
|
||||
VLC = "vlc"
|
||||
IPERF = "iperf"
|
||||
DITG = "ditg"
|
||||
MSG = "msg"
|
||||
SIRIHTTP = "sirihttp"
|
||||
SIRIMSG = "sirimsg"
|
||||
|
11
experiences/__init__.py
Normal file
11
experiences/__init__.py
Normal file
@ -0,0 +1,11 @@
|
||||
import importlib
|
||||
import pkgutil
|
||||
import os
|
||||
|
||||
from core.experience import Experience
|
||||
|
||||
pkg_dir = os.path.dirname(__file__)
|
||||
for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]):
|
||||
importlib.import_module('.' + name, __package__)
|
||||
|
||||
EXPERIENCES = {cls.NAME: cls for cls in Experience.__subclasses__()}
|
78
experiences/ab.py
Normal file
78
experiences/ab.py
Normal file
@ -0,0 +1,78 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class AB(Experience):
|
||||
NAME = "ab"
|
||||
|
||||
SERVER_LOG = "ab_server.log"
|
||||
CLIENT_LOG = "ab_client.log"
|
||||
AB_BIN = "ab"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
super(AB, self).__init__(xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
super(AB, self).classicRun()
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"rm " + AB.PING_OUTPUT)
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + AB.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE)
|
||||
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE)
|
||||
self.concurrent_requests = self.xpParam.getParam(ExperienceParameter.ABCONCURRENTREQUESTS)
|
||||
self.timelimit = self.xpParam.getParam(ExperienceParameter.ABTIMELIMIT)
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
AB.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
AB.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getAbServerCmd(self):
|
||||
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
|
||||
"/utils/http_server.py &>" + AB.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getAbClientCmd(self):
|
||||
s = AB.AB_BIN + " -c " + self.concurrent_requests + " -t " + \
|
||||
self.timelimit + " http://" + self.mpConfig.getServerIP() + "/" + self.file + \
|
||||
" &>" + AB.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
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.getAbServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getAbClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
86
experiences/ditg.py
Normal file
86
experiences/ditg.py
Normal file
@ -0,0 +1,86 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class DITG(Experience):
|
||||
NAME = "ditg"
|
||||
|
||||
DITG_LOG = "ditg.log"
|
||||
DITG_SERVER_LOG = "ditg_server.log"
|
||||
ITGDEC_BIN = "/home/mininet/D-ITG-2.8.1-r1023/bin/ITGDec"
|
||||
ITGRECV_BIN = "/home/mininet/D-ITG-2.8.1-r1023/bin/ITGRecv"
|
||||
ITGSEND_BIN = "/home/mininet/D-ITG-2.8.1-r1023/bin/ITGSend"
|
||||
DITG_TEMP_LOG = "snd_log_file"
|
||||
DITG_SERVER_TEMP_LOG = "recv_log_file"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
super(DITG, self).__init__(xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
super(DITG, self).classicRun()
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
Experience.PING_OUTPUT)
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + DITG.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
self.kbytes = self.xpParam.getParam(ExperienceParameter.DITGKBYTES)
|
||||
self.constant_packet_size = self.xpParam.getParam(ExperienceParameter.DITGCONSTANTPACKETSIZE)
|
||||
self.mean_poisson_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGMEANPOISSONPACKETSSEC)
|
||||
self.constant_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGCONSTANTPACKETSSEC)
|
||||
self.bursts_on_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGBURSTSONPACKETSSEC)
|
||||
self.bursts_off_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGBURSTSOFFPACKETSSEC)
|
||||
|
||||
def prepare(self):
|
||||
super(DITG, self).prepare()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + DITG.DITG_LOG)
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + DITG.DITG_SERVER_LOG)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + DITG.DITG_TEMP_LOG)
|
||||
|
||||
def getClientCmd(self):
|
||||
s = DITG.ITGSEND_BIN + " -a " + self.mpConfig.getServerIP() + \
|
||||
" -T TCP -k " + self.kbytes + " -l " + DITG.DITG_TEMP_LOG
|
||||
|
||||
if self.constant_packet_size != "0":
|
||||
s += " -c " + self.constant_packet_size
|
||||
elif self.mean_poisson_packets_sec != "0":
|
||||
s += " -O " + self.mean_poisson_packets_sec
|
||||
elif self.constant_packets_sec != "0":
|
||||
s += " -C " + self.constant_packets_sec
|
||||
elif self.bursts_on_packets_sec != "0" and self.bursts_off_packets_sec != "0":
|
||||
s += " -B C " + self.bursts_on_packets_sec + " C " + self.bursts_off_packets_sec
|
||||
|
||||
s += " && " + DITG.ITGDEC_BIN + " " + DITG.DITG_TEMP_LOG + " &> " + DITG.DITG_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getServerCmd(self):
|
||||
s = DITG.ITGRECV_BIN + " -l " + DITG.DITG_SERVER_TEMP_LOG + " &"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
super(DITG, self).clean()
|
||||
|
||||
def run(self):
|
||||
cmd = self.getServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "pkill -9 -f ITGRecv")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, DITG.ITGDEC_BIN + " " + DITG.DITG_SERVER_TEMP_LOG + " &> " + DITG.DITG_SERVER_LOG)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
75
experiences/http.py
Normal file
75
experiences/http.py
Normal file
@ -0,0 +1,75 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class HTTP(Experience):
|
||||
NAME = "http"
|
||||
|
||||
SERVER_LOG = "http_server.log"
|
||||
CLIENT_LOG = "http_client.log"
|
||||
WGET_BIN = "wget"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
super(HTTP, self).__init__(xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
super(HTTP, self).classicRun()
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
HTTP.PING_OUTPUT )
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + HTTP.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE)
|
||||
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE)
|
||||
|
||||
def prepare(self):
|
||||
super(HTTP, self).prepare()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
HTTP.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
HTTP.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getHTTPServerCmd(self):
|
||||
s = "/etc/init.d/apache2 restart &>" + HTTP.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getHTTPClientCmd(self):
|
||||
s = "(time " + HTTP.WGET_BIN + " http://" + self.mpConfig.getServerIP() + \
|
||||
"/" + self.file + " --no-check-certificate) &>" + HTTP.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
super(HTTP, self).clean()
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm random*")
|
||||
|
||||
def run(self):
|
||||
cmd = self.getHTTPServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getHTTPClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
|
||||
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")
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
78
experiences/https.py
Normal file
78
experiences/https.py
Normal file
@ -0,0 +1,78 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class HTTPS(Experience):
|
||||
NAME = "https"
|
||||
|
||||
SERVER_LOG = "https_server.log"
|
||||
CLIENT_LOG = "https_client.log"
|
||||
WGET_BIN = "wget"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
super(HTTPS, self).__init__(xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
super(HTTPS, self).classicRun()
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
HTTPS.PING_OUTPUT )
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + HTTPS.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
self.file = self.xpParam.getParam(ExperienceParameter.HTTPSFILE)
|
||||
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPSRANDOMSIZE)
|
||||
|
||||
def prepare(self):
|
||||
super(HTTPS, self).prepare()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
HTTPS.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
HTTPS.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getHTTPSServerCmd(self):
|
||||
s = "python {}/../utils/https_server.py {}/../utils/server.pem &> {}&".format(os.path.dirname(os.path.abspath(__file__)),
|
||||
os.path.dirname(os.path.abspath(__file__)), HTTPS.SERVER_LOG)
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getHTTPSClientCmd(self):
|
||||
s = "(time " + HTTPS.WGET_BIN + " https://" + self.mpConfig.getServerIP() + \
|
||||
"/" + self.file + " --no-check-certificate) &>" + HTTPS.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
super(HTTPS, self).clean()
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm random*")
|
||||
|
||||
def run(self):
|
||||
cmd = self.getHTTPSServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
print("Waiting for the server to run")
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 15")
|
||||
cmd = self.getHTTPSClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
|
||||
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")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f https_server.py")
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
17
experiences/none.py
Normal file
17
experiences/none.py
Normal file
@ -0,0 +1,17 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
|
||||
class NoneExperience(Experience):
|
||||
NAME = "none"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
super(NoneExperience, self).__init__(xpParamFile, mpTopo, mpConfig)
|
||||
super(NoneExperience, self).classicRun()
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
|
||||
def run(self):
|
||||
self.mpTopo.getCLI()
|
@ -1,21 +1,23 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
|
||||
class ExperiencePing(Experience):
|
||||
class Ping(Experience):
|
||||
NAME = "ping"
|
||||
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
Experience.classicRun(self)
|
||||
def prepapre(self):
|
||||
Experience.prepare(self)
|
||||
super(Ping, self).__init__(xpParamFile, mpTopo, mpConfig)
|
||||
super(Ping, self).classicRun()
|
||||
|
||||
def prepare(self):
|
||||
super(Ping, self).prepare()
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
super(Ping, self).clean()
|
||||
|
||||
def run(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperiencePing.PING_OUTPUT )
|
||||
Ping.PING_OUTPUT )
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
for i in range(0, self.mpConfig.getClientInterfaceCount()):
|
||||
cmd = self.pingCommand(self.mpConfig.getClientIP(i),
|
||||
@ -24,6 +26,6 @@ class ExperiencePing(Experience):
|
||||
|
||||
def pingCommand(self, fromIP, toIP, n=5):
|
||||
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
||||
" >> " + ExperiencePing.PING_OUTPUT
|
||||
" >> " + Ping.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
@ -1,79 +0,0 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class ExperienceAb(Experience):
|
||||
SERVER_LOG = "ab_server.log"
|
||||
CLIENT_LOG = "ab_client.log"
|
||||
AB_BIN = "ab"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
Experience.classicRun(self)
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"rm " + ExperienceAb.PING_OUTPUT)
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + ExperienceAb.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
"""
|
||||
todo : param LD_PRELOAD ??
|
||||
"""
|
||||
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE)
|
||||
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE)
|
||||
self.concurrent_requests = self.xpParam.getParam(ExperienceParameter.ABCONCURRENTREQUESTS)
|
||||
self.timelimit = self.xpParam.getParam(ExperienceParameter.ABTIMELIMIT)
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperienceAb.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
ExperienceAb.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getAbServerCmd(self):
|
||||
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
|
||||
"/utils/http.py &>" + ExperienceAb.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getAbClientCmd(self):
|
||||
s = ExperienceAb.AB_BIN + " -c " + self.concurrent_requests + " -t " + \
|
||||
self.timelimit + " http://" + self.mpConfig.getServerIP() + "/" + self.file + \
|
||||
" &>" + ExperienceAb.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
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.getAbServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getAbClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
@ -1,90 +0,0 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class ExperienceDITG(Experience):
|
||||
DITG_LOG = "ditg.log"
|
||||
DITG_SERVER_LOG = "ditg_server.log"
|
||||
ITGDEC_BIN = "/home/mininet/D-ITG-2.8.1-r1023/bin/ITGDec"
|
||||
ITGRECV_BIN = "/home/mininet/D-ITG-2.8.1-r1023/bin/ITGRecv"
|
||||
ITGSEND_BIN = "/home/mininet/D-ITG-2.8.1-r1023/bin/ITGSend"
|
||||
DITG_TEMP_LOG = "snd_log_file"
|
||||
DITG_SERVER_TEMP_LOG = "recv_log_file"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
Experience.classicRun(self)
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperienceDITG.PING_OUTPUT)
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + ExperienceDITG.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
"""
|
||||
todo : param LD_PRELOAD ??
|
||||
"""
|
||||
self.kbytes = self.xpParam.getParam(ExperienceParameter.DITGKBYTES)
|
||||
self.constant_packet_size = self.xpParam.getParam(ExperienceParameter.DITGCONSTANTPACKETSIZE)
|
||||
self.mean_poisson_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGMEANPOISSONPACKETSSEC)
|
||||
self.constant_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGCONSTANTPACKETSSEC)
|
||||
self.bursts_on_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGBURSTSONPACKETSSEC)
|
||||
self.bursts_off_packets_sec = self.xpParam.getParam(ExperienceParameter.DITGBURSTSOFFPACKETSSEC)
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + ExperienceDITG.DITG_LOG)
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + ExperienceDITG.DITG_SERVER_LOG)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + ExperienceDITG.DITG_TEMP_LOG)
|
||||
|
||||
def getClientCmd(self):
|
||||
s = ExperienceDITG.ITGSEND_BIN + " -a " + self.mpConfig.getServerIP() + \
|
||||
" -T TCP -k " + self.kbytes + " -l " + ExperienceDITG.DITG_TEMP_LOG
|
||||
|
||||
if self.constant_packet_size != "0":
|
||||
s += " -c " + self.constant_packet_size
|
||||
elif self.mean_poisson_packets_sec != "0":
|
||||
s += " -O " + self.mean_poisson_packets_sec
|
||||
elif self.constant_packets_sec != "0":
|
||||
s += " -C " + self.constant_packets_sec
|
||||
elif self.bursts_on_packets_sec != "0" and self.bursts_off_packets_sec != "0":
|
||||
s += " -B C " + self.bursts_on_packets_sec + " C " + self.bursts_off_packets_sec
|
||||
|
||||
s += " && " + ExperienceDITG.ITGDEC_BIN + " " + ExperienceDITG.DITG_TEMP_LOG + " &> " + ExperienceDITG.DITG_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getServerCmd(self):
|
||||
s = ExperienceDITG.ITGRECV_BIN + " -l " + ExperienceDITG.DITG_SERVER_TEMP_LOG + " &"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
#todo use cst
|
||||
#self.mpTopo.commandTo(self.mpConfig.server, "killall netcat")
|
||||
|
||||
|
||||
def run(self):
|
||||
cmd = self.getServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "pkill -9 -f ITGRecv")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, ExperienceDITG.ITGDEC_BIN + " " + ExperienceDITG.DITG_SERVER_TEMP_LOG + " &> " + ExperienceDITG.DITG_SERVER_LOG)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
@ -1,79 +0,0 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class ExperienceHTTP(Experience):
|
||||
SERVER_LOG = "http_server.log"
|
||||
CLIENT_LOG = "http_client.log"
|
||||
WGET_BIN = "wget"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
Experience.classicRun(self)
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperienceHTTP.PING_OUTPUT )
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + ExperienceHTTP.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
"""
|
||||
todo : param LD_PRELOAD ??
|
||||
"""
|
||||
self.file = self.xpParam.getParam(ExperienceParameter.HTTPFILE)
|
||||
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPRANDOMSIZE)
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperienceHTTP.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
ExperienceHTTP.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getHTTPServerCmd(self):
|
||||
s = "/etc/init.d/apache2 restart &>" + ExperienceHTTP.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getHTTPClientCmd(self):
|
||||
s = "(time " + ExperienceHTTP.WGET_BIN + " http://" + self.mpConfig.getServerIP() + \
|
||||
"/" + self.file + " --no-check-certificate) &>" + ExperienceHTTP.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
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.getHTTPServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getHTTPClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
|
||||
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")
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
@ -1,81 +0,0 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
import os
|
||||
|
||||
class ExperienceHTTPS(Experience):
|
||||
SERVER_LOG = "https_server.log"
|
||||
CLIENT_LOG = "https_client.log"
|
||||
WGET_BIN = "wget"
|
||||
PING_OUTPUT = "ping.log"
|
||||
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
self.loadParam()
|
||||
self.ping()
|
||||
Experience.classicRun(self)
|
||||
|
||||
def ping(self):
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperienceHTTPS.PING_OUTPUT )
|
||||
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
||||
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 + \
|
||||
" >> " + ExperienceHTTPS.PING_OUTPUT
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def loadParam(self):
|
||||
"""
|
||||
todo : param LD_PRELOAD ??
|
||||
"""
|
||||
self.file = self.xpParam.getParam(ExperienceParameter.HTTPSFILE)
|
||||
self.random_size = self.xpParam.getParam(ExperienceParameter.HTTPSRANDOMSIZE)
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
||||
ExperienceHTTPS.CLIENT_LOG )
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "rm " + \
|
||||
ExperienceHTTPS.SERVER_LOG )
|
||||
if self.file == "random":
|
||||
self.mpTopo.commandTo(self.mpConfig.client,
|
||||
"dd if=/dev/urandom of=random bs=1K count=" + \
|
||||
self.random_size)
|
||||
|
||||
def getHTTPSServerCmd(self):
|
||||
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
|
||||
"/utils/https.py &>" + ExperienceHTTPS.SERVER_LOG + "&"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def getHTTPSClientCmd(self):
|
||||
s = "(time " +ExperienceHTTPS.WGET_BIN + " https://" + self.mpConfig.getServerIP() + \
|
||||
"/" + self.file + " --no-check-certificate) &>" + ExperienceHTTPS.CLIENT_LOG
|
||||
print(s)
|
||||
return s
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
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.getHTTPSServerCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "netstat -sn > netstat_server_before")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, cmd)
|
||||
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
||||
cmd = self.getHTTPSClientCmd()
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "netstat -sn > netstat_client_before")
|
||||
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")
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f https.py")
|
||||
self.mpTopo.commandTo(self.mpConfig.client, "sleep 2")
|
@ -1,15 +0,0 @@
|
||||
from core.experience import Experience, ExperienceParameter
|
||||
|
||||
class ExperienceNone(Experience):
|
||||
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
||||
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
||||
Experience.classicRun(self)
|
||||
|
||||
def prepare(self):
|
||||
Experience.prepare(self)
|
||||
|
||||
def clean(self):
|
||||
Experience.clean(self)
|
||||
|
||||
def run(self):
|
||||
self.mpTopo.getCLI()
|
@ -70,7 +70,7 @@ class ExperienceQUIC(Experience):
|
||||
|
||||
def getCongServerCmd(self, congID):
|
||||
s = "python " + os.path.dirname(os.path.abspath(__file__)) + \
|
||||
"/utils/https.py &> https_server" + str(congID) + ".log &"
|
||||
"/utils/https_server.py &> https_server" + str(congID) + ".log &"
|
||||
print(s)
|
||||
return s
|
||||
|
||||
@ -123,7 +123,7 @@ class ExperienceQUIC(Experience):
|
||||
self.mpTopo.commandTo(self.mpConfig.server, "pkill -f " + ExperienceQUIC.SERVER_GO_FILE)
|
||||
if isinstance(self.mpConfig, MultiInterfaceCongConfig):
|
||||
for cs in self.mpConfig.cong_servers:
|
||||
self.mpTopo.commandTo(cs, "pkill -f https.py")
|
||||
self.mpTopo.commandTo(cs, "pkill -f https_server.py")
|
||||
|
||||
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
|
||||
|
@ -3,27 +3,23 @@ from core.topo import Topo, TopoParameter
|
||||
|
||||
from mininet_builder import MininetBuilder
|
||||
|
||||
import topos
|
||||
from topos import TOPO_CONFIGS, TOPOS
|
||||
from experiences import EXPERIENCES
|
||||
|
||||
from mpExperiencePing import ExperiencePing
|
||||
from mpExperienceNCPV import ExperienceNCPV
|
||||
from mpExperienceNC import ExperienceNC
|
||||
from mpExperienceHTTPS import ExperienceHTTPS
|
||||
from mpExperienceHTTP import ExperienceHTTP
|
||||
from mpExperienceSendFile import ExperienceSendFile
|
||||
from mpExperienceEpload import ExperienceEpload
|
||||
from mpExperienceNetperf import ExperienceNetperf
|
||||
from mpExperienceAb import ExperienceAb
|
||||
from mpExperienceSiri import ExperienceSiri
|
||||
from mpExperienceVLC import ExperienceVLC
|
||||
from mpExperienceIperf import ExperienceIperf
|
||||
from mpExperienceDITG import ExperienceDITG
|
||||
from mpExperienceMsg import ExperienceMsg
|
||||
from mpExperienceSiriHTTP import ExperienceSiriHTTP
|
||||
from mpExperienceSiriMsg import ExperienceSiriMsg
|
||||
from mpExperienceQUIC import ExperienceQUIC
|
||||
from mpExperienceQUICSiri import ExperienceQUICSiri
|
||||
from mpExperienceNone import ExperienceNone
|
||||
|
||||
|
||||
class MpXpRunner:
|
||||
def __init__(self, builderType, topoParamFile, xpParamFile):
|
||||
@ -47,16 +43,16 @@ class MpXpRunner:
|
||||
builderType)
|
||||
def defTopo(self):
|
||||
t = self.topoParam.getParam(Topo.topoAttr)
|
||||
if t in topos.topos:
|
||||
self.Topo = topos.topos[t](self.topoBuilder, self.topoParam)
|
||||
if t in TOPOS:
|
||||
self.Topo = TOPOS[t](self.topoBuilder, self.topoParam)
|
||||
else:
|
||||
raise Exception("Unknown topo: {}".format(t))
|
||||
print(self.Topo)
|
||||
|
||||
def defConfig(self):
|
||||
t = self.topoParam.getParam(Topo.topoAttr)
|
||||
if t in topos.configs:
|
||||
self.TopoConfig = topos.configs[t](self.Topo, self.topoParam)
|
||||
if t in TOPO_CONFIGS:
|
||||
self.TopoConfig = TOPO_CONFIGS[t](self.Topo, self.topoParam)
|
||||
else:
|
||||
raise Exception("Unknown topo config: {}".format(t))
|
||||
|
||||
@ -66,33 +62,20 @@ class MpXpRunner:
|
||||
|
||||
def runXp(self):
|
||||
xp = self.xpParam.getParam(ExperienceParameter.XPTYPE)
|
||||
if xp ==Experience.PING:
|
||||
ExperiencePing(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
if xp in EXPERIENCES:
|
||||
EXPERIENCES[xp](self.xpParam, self.Topo, self.TopoConfig)
|
||||
elif xp ==Experience.NCPV:
|
||||
ExperienceNCPV(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.NC:
|
||||
ExperienceNC(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.NONE:
|
||||
ExperienceNone(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.HTTPS:
|
||||
ExperienceHTTPS(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.HTTP:
|
||||
ExperienceHTTP(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.EPLOAD:
|
||||
ExperienceEpload(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.NETPERF:
|
||||
ExperienceNetperf(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.AB:
|
||||
ExperienceAb(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.SIRI:
|
||||
ExperienceSiri(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
@ -105,8 +88,6 @@ class MpXpRunner:
|
||||
elif xp ==Experience.IPERF:
|
||||
ExperienceIperf(self.xpParam, self.Topo,
|
||||
self.TopoConfig)
|
||||
elif xp ==Experience.DITG:
|
||||
ExperienceDITG(self.xpParam, self.Topo, self.TopoConfig)
|
||||
elif xp ==Experience.MSG:
|
||||
ExperienceMsg(self.xpParam, self.Topo, self.TopoConfig)
|
||||
elif xp ==Experience.SIRIHTTP:
|
||||
@ -118,7 +99,7 @@ class MpXpRunner:
|
||||
elif xp ==Experience.QUICSIRI:
|
||||
ExperienceQUICSiri(self.xpParam, self.Topo, self.TopoConfig)
|
||||
else:
|
||||
print("Unfound xp type..." + xp)
|
||||
raise Exception("Unknown experience {}".format(xp))
|
||||
|
||||
def stopTopo(self):
|
||||
self.Topo.stopNetwork()
|
||||
|
@ -8,5 +8,5 @@ pkg_dir = os.path.dirname(__file__)
|
||||
for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]):
|
||||
importlib.import_module('.' + name, __package__)
|
||||
|
||||
configs = {cls.NAME: cls for cls in TopoConfig.__subclasses__()}
|
||||
topos = {cls.NAME: cls for cls in Topo.__subclasses__()}
|
||||
TOPO_CONFIGS = {cls.NAME: cls for cls in TopoConfig.__subclasses__()}
|
||||
TOPOS = {cls.NAME: cls for cls in Topo.__subclasses__()}
|
@ -10,18 +10,24 @@ usage: python SimpleHTTPServer.py
|
||||
'''
|
||||
|
||||
import socket, os
|
||||
from SocketServer import BaseServer
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from OpenSSL import SSL
|
||||
try:
|
||||
# Python 2
|
||||
from SocketServer import BaseServer
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
except ImportError:
|
||||
# Python 3
|
||||
from socketserver import BaseServer
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
|
||||
from OpenSSL import SSL
|
||||
|
||||
def test(HandlerClass=SimpleHTTPRequestHandler,
|
||||
ServerClass=HTTPServer):
|
||||
server_address = ('', 80) # (address, port)
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
sa = httpd.socket.getsockname()
|
||||
print("Serving HTTPS on", sa[0], "port", sa[1], "...")
|
||||
print("Serving HTTP on", sa[0], "port", sa[1], "...")
|
||||
httpd.serve_forever()
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
'''
|
||||
From :
|
||||
http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
|
||||
|
||||
SimpleSecureHTTPServer.py - simple HTTP server supporting SSL.
|
||||
|
||||
- replace fpem with the location of your .pem server file.
|
||||
- the default port is 443.
|
||||
|
||||
usage: python SimpleSecureHTTPServer.py
|
||||
'''
|
||||
|
||||
import socket, os
|
||||
from SocketServer import BaseServer
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from OpenSSL import SSL
|
||||
|
||||
|
||||
class SecureHTTPServer(HTTPServer):
|
||||
def __init__(self, server_address, HandlerClass):
|
||||
BaseServer.__init__(self, server_address, HandlerClass)
|
||||
ctx = SSL.Context(SSL.SSLv23_METHOD)
|
||||
#server.pem's location (containing the server private key and
|
||||
#the server certificate).
|
||||
fpem = os.path.dirname(os.path.abspath(__file__)) + "/server.pem"
|
||||
ctx.use_privatekey_file (fpem)
|
||||
ctx.use_certificate_file(fpem)
|
||||
self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
|
||||
self.socket_type))
|
||||
self.server_bind()
|
||||
self.server_activate()
|
||||
|
||||
def shutdown_request(self,request):
|
||||
request.shutdown()
|
||||
|
||||
class SecureHTTPRequestHandler(SimpleHTTPRequestHandler):
|
||||
def setup(self):
|
||||
self.connection = self.request
|
||||
self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
|
||||
self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
|
||||
|
||||
|
||||
def test(HandlerClass = SecureHTTPRequestHandler,
|
||||
ServerClass = SecureHTTPServer):
|
||||
server_address = ('', 443) # (address, port)
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
sa = httpd.socket.getsockname()
|
||||
print("Serving HTTPS on", sa[0], "port", sa[1], "...")
|
||||
httpd.serve_forever()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
38
utils/https_server.py
Normal file
38
utils/https_server.py
Normal file
@ -0,0 +1,38 @@
|
||||
'''
|
||||
From :
|
||||
http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/
|
||||
|
||||
SimpleSecureHTTPServer.py - simple HTTP server supporting SSL.
|
||||
|
||||
- replace fpem with the location of your .pem server file.
|
||||
- the default port is 443.
|
||||
|
||||
usage: python SimpleSecureHTTPServer.py
|
||||
'''
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] == 3:
|
||||
# Python 3
|
||||
import http.server, ssl
|
||||
server_address = ('', 443)
|
||||
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
|
||||
httpd.socket = ssl.wrap_socket(httpd.socket,
|
||||
server_side=True,
|
||||
certfile=sys.argv[1],
|
||||
ssl_version=ssl.PROTOCOL_TLS)
|
||||
print("Serving HTTPS on 0.0.0.0 port 443...")
|
||||
httpd.serve_forever()
|
||||
else:
|
||||
# Python2
|
||||
import BaseHTTPServer, SimpleHTTPServer
|
||||
import ssl
|
||||
import os
|
||||
|
||||
httpd = BaseHTTPServer.HTTPServer(('', 443), SimpleHTTPServer.SimpleHTTPRequestHandler)
|
||||
httpd.socket = ssl.wrap_socket(httpd.socket, certfile=sys.argv[1], server_side=True)
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
os.chdir(sys.argv[1])
|
||||
|
||||
print("Serving HTTPS on 0.0.0.0 port 443...")
|
||||
httpd.serve_forever()
|
Loading…
Reference in New Issue
Block a user