2020-06-26 06:52:56 +00:00
|
|
|
from core.experiment import Experiment, ExperimentParameter
|
2015-01-08 18:52:45 +00:00
|
|
|
|
2020-06-26 06:52:56 +00:00
|
|
|
class Ping(Experiment):
|
2020-06-24 15:18:40 +00:00
|
|
|
NAME = "ping"
|
2015-01-08 18:52:45 +00:00
|
|
|
|
2020-06-24 15:18:40 +00:00
|
|
|
PING_OUTPUT = "ping.log"
|
2015-01-08 18:52:45 +00:00
|
|
|
|
2020-06-26 06:52:56 +00:00
|
|
|
def __init__(self, experiment_parameter_filename, topo, topo_config):
|
|
|
|
super(Ping, self).__init__(experiment_parameter_filename, topo, topo_config)
|
2020-06-24 14:11:54 +00:00
|
|
|
|
2020-06-24 15:18:40 +00:00
|
|
|
def prepare(self):
|
|
|
|
super(Ping, self).prepare()
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2020-06-24 15:18:40 +00:00
|
|
|
def clean(self):
|
|
|
|
super(Ping, self).clean()
|
2015-01-08 18:52:45 +00:00
|
|
|
|
2020-06-24 15:18:40 +00:00
|
|
|
def run(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
|
|
|
Ping.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 07:51:55 +00:00
|
|
|
cmd = self.ping_command(self.topo_config.getClientIP(i),
|
2020-06-25 08:53:56 +00:00
|
|
|
self.topo_config.getServerIP(), n = count)
|
|
|
|
self.topo.command_to(self.topo_config.client, cmd)
|
2015-01-08 18:52:45 +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 + \
|
|
|
|
" >> " + Ping.PING_OUTPUT
|
|
|
|
print(s)
|
|
|
|
return s
|