add ping before pv

Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
Benjamin Hesmans 2015-06-05 15:17:47 -07:00
parent 5d7faeacd2
commit 8b39f5f207

View File

@ -8,14 +8,31 @@ class MpExperienceNCPV(MpExperience):
""" """
SERVER_NC_LOG = "netcat_server" SERVER_NC_LOG = "netcat_server"
CLIENT_NC_LOG = "netcat_client" CLIENT_NC_LOG = "netcat_client"
NC_BIN = "netcat" NC_BIN = "/home/mininet/git/netcat-openbsd-1.105/nc"
PV_BIN = "/home/bhesmans/Documents/git/pv/pv" PV_BIN = "pv"
PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig): def __init__(self, xpParamFile, mpTopo, mpConfig):
MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig) MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig)
self.loadParam() self.loadParam()
self.ping()
MpExperience.classicRun(self) MpExperience.classicRun(self)
def ping(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
MpExperienceNCPV.PING_OUTPUT )
count = self.xpParam.getParam(MpParamXp.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 + \
" >> " + MpExperienceNCPV.PING_OUTPUT
print(s)
return s
def loadParam(self): def loadParam(self):
self.pvg = self.xpParam.getParam(MpParamXp.PVG) self.pvg = self.xpParam.getParam(MpParamXp.PVG)
self.pvz = self.xpParam.getParam(MpParamXp.PVZ) self.pvz = self.xpParam.getParam(MpParamXp.PVZ)
@ -85,7 +102,7 @@ class MpExperienceNCPV(MpExperience):
def getNCServerCmd(self, id): def getNCServerCmd(self, id):
s = MpExperienceNCPV.NC_BIN + " -d " + \ s = MpExperienceNCPV.NC_BIN + " -d " + \
" -l " + self.ncServerPort + \ " -l " + self.ncServerPort + \
" &>" + MpExperienceNCPV.SERVER_NC_LOG + \ " 1>/dev/null 2>" + MpExperienceNCPV.SERVER_NC_LOG + \
"_" + str(id) + ".log &" "_" + str(id) + ".log &"
print(s) print(s)
return s return s