2020-06-24 08:36:26 +00:00
|
|
|
from core.experience import Experience, ExperienceParameter
|
2015-01-08 18:52:45 +00:00
|
|
|
|
2020-06-24 14:11:54 +00:00
|
|
|
class Ping(Experience):
|
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-25 12:56:47 +00:00
|
|
|
def __init__(self, experience_parameter_filename, topo, topo_config):
|
|
|
|
super(Ping, self).__init__(experience_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-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)
|
2015-01-08 18:52:45 +00:00
|
|
|
|
2020-06-24 15:18:40 +00:00
|
|
|
def pingCommand(self, fromIP, toIP, n=5):
|
|
|
|
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
|
|
|
" >> " + Ping.PING_OUTPUT
|
|
|
|
print(s)
|
|
|
|
return s
|