diff --git a/src/mpExperience.py b/src/mpExperience.py index 9e90f96..3d3a727 100644 --- a/src/mpExperience.py +++ b/src/mpExperience.py @@ -14,6 +14,7 @@ class MpExperience: SIRI = "siri" SENDFILE = "sendfile" VLC = "vlc" + IPERF = "iperf" def __init__(self, xpParam, mpTopo, mpConfig): self.xpParam = xpParam diff --git a/src/mpExperienceIperf.py b/src/mpExperienceIperf.py new file mode 100644 index 0000000..2f8030a --- /dev/null +++ b/src/mpExperienceIperf.py @@ -0,0 +1,72 @@ +from mpExperience import MpExperience +from mpParamXp import MpParamXp +from mpPvAt import MpPvAt +import os + +class MpExperienceIperf(MpExperience): + IPERF_LOG = "iperf.log" + SERVER_LOG = "server.log" + IPERF_BIN = "iperf" + PING_OUTPUT = "ping.log" + + def __init__(self, xpParamFile, mpTopo, mpConfig): + MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig) + self.loadParam() + self.ping() + MpExperience.classicRun(self) + + def ping(self): + self.mpTopo.commandTo(self.mpConfig.client, "rm " + \ + MpExperienceIperf.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 + \ + " >> " + MpExperienceIperf.PING_OUTPUT + print(s) + return s + + def loadParam(self): + """ + todo : param LD_PRELOAD ?? + """ + pass + + def prepare(self): + MpExperience.prepare(self) + self.mpTopo.commandTo(self.mpConfig.client, "rm " + + MpExperienceIperf.IPERF_LOG) + self.mpTopo.commandTo(self.mpConfig.server, "rm " + + MpExperienceIperf.SERVER_LOG) + + def getClientCmd(self): + s = MpExperienceIperf.IPERF_BIN + " -c " + self.mpConfig.getServerIP() + \ + " &>" + MpExperienceIperf.IPERF_LOG + print(s) + return s + + def getServerCmd(self): + s = "sudo " + MpExperienceIperf.IPERF_BIN + " -s &>" + \ + MpExperienceIperf.SERVER_LOG + "&" + print(s) + return s + + def clean(self): + MpExperience.clean(self) + #todo use cst + #self.mpTopo.commandTo(self.mpConfig.server, "killall netcat") + + + def run(self): + cmd = self.getServerCmd() + self.mpTopo.commandTo(self.mpConfig.server, cmd) + + self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") + cmd = self.getClientCmd() + self.mpTopo.commandTo(self.mpConfig.client, cmd) + self.mpTopo.commandTo(self.mpConfig.server, "pkill -9 -f iperf") + self.mpTopo.commandTo(self.mpConfig.client, "sleep 2") diff --git a/src/mpXpRunner.py b/src/mpXpRunner.py index 26871c4..d3a7808 100644 --- a/src/mpXpRunner.py +++ b/src/mpXpRunner.py @@ -17,6 +17,7 @@ from mpExperienceNetperf import MpExperienceNetperf from mpExperienceAb import MpExperienceAb from mpExperienceSiri import MpExperienceSiri from mpExperienceVLC import MpExperienceVLC +from mpExperienceIperf import MpExperienceIperf from mpExperienceNone import MpExperienceNone from mpExperience import MpExperience from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo @@ -115,6 +116,9 @@ class MpXpRunner: elif xp == MpExperience.VLC: MpExperienceVLC(self.xpParam, self.mpTopo, self.mpTopoConfig) + elif xp == MpExperience.IPERF: + MpExperienceIperf(self.xpParam, self.mpTopo, + self.mpTopoConfig) else: print("Unfound xp type..." + xp)