2020-06-26 06:52:56 +00:00
|
|
|
from core.experiment import ExperimentParameter, RandomFileExperiment, RandomFileParameter
|
2020-06-25 13:56:14 +00:00
|
|
|
from .siri import Siri
|
2020-06-24 15:18:40 +00:00
|
|
|
import os
|
|
|
|
|
2020-06-26 06:52:56 +00:00
|
|
|
class SiriHTTP(Siri, RandomFileExperiment):
|
2020-06-24 15:18:40 +00:00
|
|
|
NAME = "sirihttp"
|
|
|
|
|
|
|
|
HTTP_SERVER_LOG = "http_server.log"
|
|
|
|
HTTP_CLIENT_LOG = "http_client.log"
|
|
|
|
WGET_BIN = "wget"
|
|
|
|
SERVER_LOG = "siri_server.log"
|
|
|
|
CLIENT_LOG = "siri_client.log"
|
|
|
|
CLIENT_ERR = "siri_client.err"
|
|
|
|
JAVA_BIN = "java"
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
2020-06-26 06:52:56 +00:00
|
|
|
def __init__(self, experiment_parameter_filename, topo, topo_config):
|
2020-06-25 12:56:47 +00:00
|
|
|
# Just rely on RandomFileExperiment
|
2020-06-26 06:52:56 +00:00
|
|
|
super(SiriHTTP, self).__init__(experiment_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
|
|
|
SiriHTTP.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()):
|
2020-06-29 14:23:39 +00:00
|
|
|
cmd = self.ping_command(self.topo_config.get_client_ip(i),
|
|
|
|
self.topo_config.get_server_ip(), n = count)
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, cmd)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
2020-06-29 07:51:55 +00:00
|
|
|
def ping_command(self, fromIP, toIP, n=5):
|
2020-06-24 15:18:40 +00:00
|
|
|
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
|
|
|
" >> " + SiriHTTP.PING_OUTPUT
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
def load_parameters(self):
|
2020-06-25 13:56:14 +00:00
|
|
|
# Start collecting parameters of RandomFileExperiment and Siri
|
2020-06-25 12:56:47 +00:00
|
|
|
super(SiriHTTP, self).load_parameters()
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def prepare(self):
|
|
|
|
super(SiriHTTP, 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
|
|
|
SiriHTTP.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
|
|
|
SiriHTTP.SERVER_LOG)
|
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
|
|
|
SiriHTTP.HTTP_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
|
|
|
SiriHTTP.HTTP_SERVER_LOG)
|
|
|
|
|
2020-07-01 14:02:54 +00:00
|
|
|
def get_http_server_cmd(self):
|
2020-06-24 15:18:40 +00:00
|
|
|
s = "/etc/init.d/apache2 restart &>" + SiriHTTP.SERVER_LOG + "&"
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
2020-07-01 14:02:54 +00:00
|
|
|
def get_http_client_cmd(self):
|
2020-06-29 14:23:39 +00:00
|
|
|
s = SiriHTTP.WGET_BIN + " http://" + self.topo_config.get_server_ip() + \
|
2020-06-24 15:18:40 +00:00
|
|
|
"/" + self.file + " --no-check-certificate"
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
super(SiriHTTP, self).clean()
|
|
|
|
|
|
|
|
def run(self):
|
2020-06-25 13:56:14 +00:00
|
|
|
cmd = self.get_siri_server_cmd()
|
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-07-01 14:02:54 +00:00
|
|
|
cmd = self.get_http_server_cmd()
|
2020-06-25 08:53:56 +00:00
|
|
|
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")
|
|
|
|
self.topo.command_to(self.topo_config.client, "netstat -sn > netstat_client_before")
|
2020-07-01 14:02:54 +00:00
|
|
|
cmd = self.get_http_client_cmd()
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo.command_to(self.topo_config.client, "for i in {1..200}; do " + cmd + "; done &")
|
2020-06-25 13:56:14 +00:00
|
|
|
cmd = self.get_siri_client_cmd()
|
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")
|
|
|
|
self.topo.command_to(self.topo_config.server, "pkill -f siri_server.py")
|
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 2")
|