mininet-sample/mpExperiencePing.py

30 lines
912 B
Python
Raw Normal View History

2020-06-24 08:36:26 +00:00
from core.experience import Experience, ExperienceParameter
2020-06-24 08:36:26 +00:00
class ExperiencePing(Experience):
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)
def prepapre(self):
2020-06-24 08:36:26 +00:00
Experience.prepare(self)
def clean(self):
2020-06-24 08:36:26 +00:00
Experience.clean(self)
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)
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
print(s)
return s