mininet-sample/experiments/ping.py

31 lines
1.0 KiB
Python
Raw Normal View History

2020-06-26 06:52:56 +00:00
from core.experiment import Experiment, ExperimentParameter
2020-06-26 06:52:56 +00:00
class Ping(Experiment):
NAME = "ping"
PING_OUTPUT = "ping.log"
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
def prepare(self):
super(Ping, self).prepare()
def clean(self):
super(Ping, self).clean()
def run(self):
self.topo.command_to(self.topo_config.client, "rm " + \
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),
self.topo_config.getServerIP(), n = count)
self.topo.command_to(self.topo_config.client, cmd)
2020-06-29 07:51:55 +00:00
def ping_command(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
" >> " + Ping.PING_OUTPUT
print(s)
return s