From f9ba25934368708c89b3505406cf60a5fee642df Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Wed, 2 Dec 2015 10:22:57 +0100 Subject: [PATCH] mpExperienceNetperf --- src/mpExperience.py | 1 + src/mpExperienceNetperf.py | 73 ++++++++++++++++++++++++++++++++++++++ src/mpParamXp.py | 6 ++++ src/mpXpRunner.py | 4 +++ 4 files changed, 84 insertions(+) create mode 100644 src/mpExperienceNetperf.py diff --git a/src/mpExperience.py b/src/mpExperience.py index fabbdf5..b9105f4 100644 --- a/src/mpExperience.py +++ b/src/mpExperience.py @@ -8,6 +8,7 @@ class MpExperience: HTTPS = "https" HTTP = "http" EPLOAD = "epload" + NETPERF = "netperf" def __init__(self, xpParam, mpTopo, mpConfig): self.xpParam = xpParam diff --git a/src/mpExperienceNetperf.py b/src/mpExperienceNetperf.py new file mode 100644 index 0000000..207e6e6 --- /dev/null +++ b/src/mpExperienceNetperf.py @@ -0,0 +1,73 @@ +from mpExperience import MpExperience +from mpParamXp import MpParamXp +from mpPvAt import MpPvAt +import os + +class MpExperienceNetperf(MpExperience): + NETPERF_LOG = "netperf.log" + NETSERVER_LOG = "netserver.log" + NETPERF_BIN = "netperf" + NETSERVER_BIN = "netserver" + 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 " + \ + MpExperienceNetperf.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 + \ + " >> " + MpExperienceNetperf.PING_OUTPUT + print(s) + return s + + def loadParam(self): + """ + todo : param LD_PRELOAD ?? + """ + self.testlen = self.xpParam.getParam(MpParamXp.NETPERFTESTLEN) + self.testname = self.xpParam.getParam(MpParamXp.NETPERFTESTNAME) + self.reqres_size = self.XpParam.getParam(MpParamXp.NETPERFREQRESSIZE) + + def prepare(self): + MpExperience.prepare(self) + self.mpTopo.commandTo(self.mpConfig.client, "rm " + + MpExperienceNetperf.NETPERF_LOG) + self.mpTopo.commandTo(self.mpConfig.server, "rm " + + MpExperienceNetperf.NETSERVER_LOG) + + def getClientCmd(self): + s = MpExperienceNetperf.NETPERF_BIN + " -H " + self.mpConfig.getServerIP() + \ + " -l " + self.testlen + " -t " + self.testname + " -r " + self.reqres_size + print(s) + return s + + def getServerCmd(self): + s = "sudo " + MpExperienceNetperf.NETSERVER_BIN + 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.client, "sleep 2") diff --git a/src/mpParamXp.py b/src/mpParamXp.py index 27e311b..9dfa509 100644 --- a/src/mpParamXp.py +++ b/src/mpParamXp.py @@ -32,6 +32,9 @@ class MpParamXp(MpParam): EPLOADTESTDIR = "epload_test_dir" HTTPFILE = "http_file" HTTPRANDOMSIZE = "http_file_size" + NETPERFTESTLEN = "netperfTestlen" + NETPERFTESTNAME = "netperfTestname" + NETPERFREQRESSIZE = "netperfReqresSize" # global sysctl @@ -79,6 +82,9 @@ class MpParamXp(MpParam): defaultValue[EPLOADTESTDIR] = "/bla/bla/bla" defaultValue[HTTPFILE] = "random" defaultValue[HTTPRANDOMSIZE] = "1024" + defaultValue[NETPERFTESTLEN] = "10" + defaultValue[NETPERFTESTNAME] = "TCP_RR" + defaultValue[NETPERFREQRESSIZE] = "2k,256" def __init__(self, paramFile): MpParam.__init__(self, paramFile) diff --git a/src/mpXpRunner.py b/src/mpXpRunner.py index 97ed7ca..5ac6546 100644 --- a/src/mpXpRunner.py +++ b/src/mpXpRunner.py @@ -11,6 +11,7 @@ from mpExperienceNC import MpExperienceNC from mpExperienceHTTPS import MpExperienceHTTPS from mpExperienceHTTP import MpExperienceHTTP from mpExperienceEpload import MpExperienceEpload +from mpExperienceNetperf import MpExperienceNetperf from mpExperienceNone import MpExperienceNone from mpExperience import MpExperience from mpECMPSingleInterfaceTopo import MpECMPSingleInterfaceTopo @@ -87,6 +88,9 @@ class MpXpRunner: elif xp == MpExperience.EPLOAD: MpExperienceEpload(self.xpParam, self.mpTopo, self.mpTopoConfig) + elif xp == MpExperience.NETPERF: + MpExperienceNetperf(self.xpParam, self.mpTopo, + self.mpTopoConfig) else: print("Unfound xp type..." + xp)