mininet-sample/experiences/ping.py

32 lines
1.0 KiB
Python
Raw Normal View History

2020-06-24 08:36:26 +00:00
from core.experience import Experience, ExperienceParameter
2020-06-24 14:11:54 +00:00
class Ping(Experience):
NAME = "ping"
PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig):
super(Ping, self).__init__(xpParamFile, mpTopo, mpConfig)
super(Ping, self).classicRun()
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.mpTopo.commandTo(self.mpConfig.client, "rm " + \
Ping.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 + \
" >> " + Ping.PING_OUTPUT
print(s)
return s