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 08:36:26 +00:00
|
|
|
class ExperiencePing(Experience):
|
2015-01-08 18:52:45 +00:00
|
|
|
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
|
|
|
def __init__(self, xpParamFile, mpTopo, mpConfig):
|
2020-06-24 08:36:26 +00:00
|
|
|
Experience.__init__(self, xpParamFile, mpTopo, mpConfig)
|
|
|
|
Experience.classicRun(self)
|
2015-01-08 18:52:45 +00:00
|
|
|
def prepapre(self):
|
2020-06-24 08:36:26 +00:00
|
|
|
Experience.prepare(self)
|
2015-02-26 16:43:45 +00:00
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def clean(self):
|
2020-06-24 08:36:26 +00:00
|
|
|
Experience.clean(self)
|
2015-01-08 18:52:45 +00:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
|
2020-06-24 08:36:26 +00:00
|
|
|
ExperiencePing.PING_OUTPUT )
|
|
|
|
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 08:36:26 +00:00
|
|
|
" >> " + ExperiencePing.PING_OUTPUT
|
2015-01-08 18:52:45 +00:00
|
|
|
print(s)
|
|
|
|
return s
|