2020-06-24 15:18:40 +00:00
|
|
|
from core.experience import Experience, ExperienceParameter
|
|
|
|
import os
|
|
|
|
|
2020-06-25 13:56:14 +00:00
|
|
|
|
|
|
|
class SiriParameter(ExperienceParameter):
|
|
|
|
RUN_TIME = "siriRunTime"
|
|
|
|
QUERY_SIZE = "siriQuerySize"
|
|
|
|
RESPONSE_SIZE = "siriResponseSize"
|
|
|
|
DELAY_QUERY_RESPONSE = "siriDelayQueryResponse"
|
|
|
|
MIN_PAYLOAD_SIZE = "siriMinPayloadSize"
|
|
|
|
MAX_PAYLOAD_SIZE = "siriMaxPayloadSize"
|
|
|
|
INTERVAL_TIME_MS = "siriIntervalTimeMs"
|
|
|
|
BUFFER_SIZE = "siriBufferSize"
|
|
|
|
BURST_SIZE = "siriBurstSize"
|
|
|
|
INTERVAL_BURST_TIME_MS = "siriIntervalBurstTimeMs"
|
|
|
|
|
|
|
|
def __init__(self, experience_parameter_filename):
|
|
|
|
super(SiriParameter, self).__init__(experience_parameter_filename)
|
|
|
|
self.default_parameters.update({
|
|
|
|
SiriParameter.QUERY_SIZE: "2500",
|
|
|
|
SiriParameter.RESPONSE_SIZE: "750",
|
|
|
|
SiriParameter.DELAY_QUERY_RESPONSE: "0",
|
|
|
|
SiriParameter.MIN_PAYLOAD_SIZE: "85",
|
|
|
|
SiriParameter.MAX_PAYLOAD_SIZE: "500",
|
|
|
|
SiriParameter.INTERVAL_TIME_MS: "333",
|
|
|
|
SiriParameter.BUFFER_SIZE: "9",
|
|
|
|
SiriParameter.BURST_SIZE: "0",
|
|
|
|
SiriParameter.INTERVAL_BURST_TIME_MS: "0",
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2020-06-24 15:18:40 +00:00
|
|
|
class Siri(Experience):
|
|
|
|
NAME = "siri"
|
2020-06-25 13:56:14 +00:00
|
|
|
PARAMETER_CLASS = SiriParameter
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
SERVER_LOG = "siri_server.log"
|
|
|
|
CLIENT_LOG = "siri_client.log"
|
|
|
|
CLIENT_ERR = "siri_client.err"
|
|
|
|
JAVA_BIN = "java"
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
2020-06-25 12:56:47 +00:00
|
|
|
def __init__(self, experience_parameter_filename, topo, topo_config):
|
|
|
|
super(Siri, 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
|
|
|
Siri.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 + \
|
|
|
|
" >> " + Siri.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
|
|
|
self.run_time = self.experience_parameter.get(SiriParameter.RUN_TIME)
|
|
|
|
self.query_size = self.experience_parameter.get(SiriParameter.QUERY_SIZE)
|
|
|
|
self.response_size = self.experience_parameter.get(SiriParameter.RESPONSE_SIZE)
|
|
|
|
self.delay_query_response = self.experience_parameter.get(SiriParameter.DELAY_QUERY_RESPONSE)
|
|
|
|
self.min_payload_size = self.experience_parameter.get(SiriParameter.MIN_PAYLOAD_SIZE)
|
|
|
|
self.max_payload_size = self.experience_parameter.get(SiriParameter.MAX_PAYLOAD_SIZE)
|
|
|
|
self.interval_time_ms = self.experience_parameter.get(SiriParameter.INTERVAL_TIME_MS)
|
|
|
|
self.buffer_size = self.experience_parameter.get(SiriParameter.BUFFER_SIZE)
|
|
|
|
self.burst_size = self.experience_parameter.get(SiriParameter.BURST_SIZE)
|
|
|
|
self.interval_burst_time_ms = self.experience_parameter.get(SiriParameter.INTERVAL_BURST_TIME_MS)
|
2020-06-24 15:18:40 +00:00
|
|
|
|
|
|
|
def prepare(self):
|
|
|
|
super(Siri, 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
|
|
|
Siri.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
|
|
|
Siri.SERVER_LOG)
|
|
|
|
|
2020-06-25 13:56:14 +00:00
|
|
|
def get_siri_server_cmd(self):
|
|
|
|
s = "python3 {}/../utils/siri_server.py &> {}&".format(
|
|
|
|
os.path.dirname(os.path.abspath(__file__)), Siri.SERVER_LOG)
|
2020-06-24 15:18:40 +00:00
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
2020-06-25 13:56:14 +00:00
|
|
|
def get_siri_client_cmd(self):
|
|
|
|
s = "{} -jar {}/../utils/siriClient.jar {} 8080 {} {} {} {} {} {} {} {} {} {} > {} 2> {}".format(
|
|
|
|
Siri.JAVA_BIN, os.path.dirname(os.path.abspath(__file__)), self.topo_config.getServerIP(),
|
|
|
|
self.run_time, self.query_size, self.response_size, self.delay_query_response,
|
|
|
|
self.min_payload_size, self.max_payload_size, self.interval_time_ms, self.buffer_size,
|
|
|
|
self.burst_size, self.interval_burst_time_ms, Siri.CLIENT_LOG, Siri.CLIENT_ERR)
|
2020-06-24 15:18:40 +00:00
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
super(Siri, 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-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-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, "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 siri_server.py")
|
|
|
|
self.topo.command_to(self.topo_config.client, "sleep 2")
|