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):
|
|
|
|
NAME = "ping"
|
2015-01-08 18:52:45 +00:00
|
|
|
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
|
|
|
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
2020-06-24 14:11:54 +00:00
|
|
|
super(Ping, self).__init__(xpParamFile, mpTopo, mpConfig)
|
|
|
|
super(Ping, self).classicRun()
|
|
|
|
|
|
|
|
def prepare(self):
|
|
|
|
super(Ping, self).prepare()
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def clean(self):
|
2020-06-24 14:11:54 +00:00
|
|
|
super(Ping, self).clean()
|
2015-01-08 18:52:45 +00:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
2020-06-24 14:11:54 +00:00
|
|
|
Ping.PING_OUTPUT )
|
2020-06-24 08:36:26 +00:00
|
|
|
count = self.xpParam.getParam(ExperienceParameter.PINGCOUNT)
|
2015-01-08 18:52:45 +00:00
|
|
|
for i in range(0, self.mpConfig.getClientInterfaceCount()):
|
|
|
|
cmd = self.pingCommand(self.mpConfig.getClientIP(i),
|
|
|
|
self.mpConfig.getServerIP(), n = count)
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, cmd)
|
|
|
|
|
|
|
|
def pingCommand(self, fromIP, toIP, n=5):
|
|
|
|
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
2020-06-24 14:11:54 +00:00
|
|
|
" >> " + Ping.PING_OUTPUT
|
2015-01-08 18:52:45 +00:00
|
|
|
print(s)
|
|
|
|
return s
|